Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions .github/workflows/ReleaseUtils.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: Release internal utilities

# Packs @mendix/piw-native-utils-internal and attaches the tarball to a GitHub release, the way mendix-native is
# released, so the Mendix client can depend on it through the release's download URL, for example
# "@mendix/piw-native-utils-internal": "https://github.com/mendix/native-widgets/releases/download/piw-native-utils-internal-v1.1.0/piw-native-utils-internal-v1.1.0.tgz"
# Only run it by hand: it publishes a release.

on:
workflow_dispatch:
inputs:
version:
description: "Version bump type"
required: true
type: choice
options:
- patch
- minor
- major

permissions: {}

env:
PACKAGE_DIR: packages/tools/piw-native-utils-internal
PACKAGE_NAME: "@mendix/piw-native-utils-internal"

jobs:
release:
name: "Pack and release"
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write

steps:
- name: "Checking-out code"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: "Defining node version"
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version-file: ".nvmrc"
package-manager-cache: false
- name: "Setup pnpm"
uses: pnpm/action-setup@a8198c4bff370c8506180b035930dea56dbd5288 # v5

- name: "Calculating the next version"
id: version
env:
BUMP: ${{ inputs.version }}
run: |
cd "$PACKAGE_DIR"
CURRENT=$(node -p "require('./package.json').version")
# Bumps package.json only: no git tag, no lifecycle scripts
NEXT=$(npm version "$BUMP" --no-git-tag-version --ignore-scripts | sed 's/^v//')
echo "current=$CURRENT" >> "$GITHUB_OUTPUT"
echo "next=$NEXT" >> "$GITHUB_OUTPUT"
echo "tag=piw-native-utils-internal-v$NEXT" >> "$GITHUB_OUTPUT"
echo "Version $CURRENT -> $NEXT ($BUMP)"

- name: "Checking the release does not exist yet"
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ steps.version.outputs.tag }}
run: |
if git ls-remote --tags origin | grep -q "refs/tags/$TAG$"; then
echo "::error::The tag $TAG already exists"
exit 1
fi
if gh release view "$TAG" &>/dev/null; then
echo "::error::The release $TAG already exists"
exit 1
fi

- name: "Installing dependencies"
# The internal utilities are built once below instead of by the workspace lifecycle scripts
run: pnpm install --frozen-lockfile --ignore-scripts
- name: "Building internal utilities"
run: pnpm run build:internal-utils
- name: "Linting and testing"
run: |
pnpm --filter "$PACKAGE_NAME" run lint
pnpm --filter "$PACKAGE_NAME" run test

- name: "Packing"
id: pack
env:
TAG: ${{ steps.version.outputs.tag }}
run: |
mkdir -p "$RUNNER_TEMP/pack"
# Ships a package.json without scripts: the build scripts of this workspace package would fail on install
TARBALL=$(node "$PACKAGE_DIR/scripts/pack.mjs" "$RUNNER_TEMP/pack" "$TAG.tgz")
echo "tarball=$TARBALL" >> "$GITHUB_OUTPUT"
echo "Tarball contents:"
tar -tzf "$TARBALL"

- name: "Creating the release"
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0
with:
tag_name: ${{ steps.version.outputs.tag }}
name: ${{ steps.version.outputs.tag }}
body: "Internal utilities of the native widgets (@mendix/piw-native-utils-internal ${{ steps.version.outputs.next }}), packed for use as a dependency of the Mendix client. Not a widget release."
files: ${{ steps.pack.outputs.tarball }}
target_commitish: ${{ github.sha }}
fail_on_unmatched_files: true
draft: false
prerelease: false
# This repository's widget releases decide what "latest" is
make_latest: "false"

- name: "Opening a pull request with the version bump"
uses: peter-evans/create-pull-request@84ae59a2cdc2258d6fa0732dd66352dddae2a412 # v7.0.9
with:
commit-message: "chore: release piw-native-utils-internal ${{ steps.version.outputs.next }}"
branch: release/piw-native-utils-internal-${{ steps.version.outputs.next }}
title: "Release piw-native-utils-internal ${{ steps.version.outputs.next }}"
body: "Updates the version of @mendix/piw-native-utils-internal for the release ${{ steps.version.outputs.tag }}."
base: ${{ github.ref_name }}
add-paths: ${{ env.PACKAGE_DIR }}/package.json
1 change: 0 additions & 1 deletion configs/e2e/native_dependencies.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"react-native-geocoder": "0.5.0",
"react-native-device-info": "15.0.2",
"react-native-action-button": "2.8.5",
"react-native-material-menu": "1.2.0",
"react-native-linear-gradient": "2.8.3",
"@react-native-community/netinfo": "11.5.2",
"react-native-svg": "15.15.4",
Expand Down
7 changes: 7 additions & 0 deletions packages/pluggableWidgets/popup-menu-native/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

### Changed

- The menu is now presented through the shared MxMenu component instead of react-native-material-menu, which has been removed as a dependency. The style keys, the four item style classes and the ripple colour keep working as before.
- Screen readers now treat the popup as a menu with menu items, report whether the menu is open on the trigger, and return focus to the trigger when the menu closes.
- Items no longer crash the app when a style sets a font size of 0.
- On iOS an item now dims and shows the ripple colour as its background while it is pressed, the same as on the drop-down. Before it used the default highlight of a touchable.

## [4.1.1] - 2026-9-2

### Changed
Expand Down
8 changes: 3 additions & 5 deletions packages/pluggableWidgets/popup-menu-native/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "popup-menu-native",
"widgetName": "PopupMenu",
"version": "4.1.1",
"version": "4.2.0",
"license": "Apache-2.0",
"repository": {
"type": "git",
Expand All @@ -20,11 +20,9 @@
},
"dependencies": {
"@mendix/piw-native-utils-internal": "*",
"@mendix/piw-utils-internal": "*",
"react-native-material-menu": "1.2.0"
"@mendix/piw-utils-internal": "*"
},
"devDependencies": {
"@mendix/pluggable-widgets-tools": "*",
"@types/react-native-material-menu": "^1.0.6"
"@mendix/pluggable-widgets-tools": "*"
}
}
87 changes: 42 additions & 45 deletions packages/pluggableWidgets/popup-menu-native/src/PopupMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,110 +1,107 @@
import { ComponentType, ReactElement, useCallback, useRef, Fragment } from "react";
import { ComponentType, ReactElement, useCallback } from "react";
import { PopupMenuProps } from "../typings/PopupMenuProps";
import { PopupMenuStyle } from "./ui/Styles";
import { executeAction } from "@mendix/piw-utils-internal";
import { MxMenu, MxMenuDivider, MxMenuItem, useMxMenu } from "@mendix/piw-native-utils-internal";
import {
Platform,
StyleSheet,
TouchableHighlight,
TouchableHighlightProps,
TouchableNativeFeedback,
TouchableNativeFeedbackProps,
TouchableOpacity,
View
} from "react-native";
import { ActionValue } from "mendix";
import Menu, { MenuDivider, MenuItem } from "react-native-material-menu";

const TouchableItem: ComponentType<TouchableNativeFeedbackProps | TouchableHighlightProps> =
Platform.OS === "android" ? TouchableNativeFeedback : TouchableHighlight;

const TouchableButton: ComponentType<TouchableNativeFeedbackProps | typeof TouchableOpacity> =
Platform.OS === "android" ? TouchableNativeFeedback : TouchableOpacity;

// Custom items hold whatever the app puts in them, so they do not get the minimum size of a text item
const customItemDefaults = { minHeight: 0, minWidth: 0, justifyContent: "flex-start" } as const;
const basicItemDefaults = { height: 48, maxWidth: 248 } as const;

export function PopupMenu(props: PopupMenuProps<PopupMenuStyle>): ReactElement {
const styles = StyleSheet.flatten(props.style);

const menuRef = useRef<Menu | null>(null);
const showMenu = useCallback(() => {
menuRef.current?.show();
}, [menuRef.current]);
const { anchorRef, anchor, visible, expanded, open, close } = useMxMenu();
const handlePress = useCallback(
(action?: ActionValue) => {
menuRef.current?.hide();
close();
// Set timeout needed since modal closes the alerts which might be shown in action
setTimeout(() => {
executeAction(action);
}, 500);
},
[menuRef.current]
[close]
);

let menuOptions: ReactElement[];
if (props.popupRenderMode === "basic") {
menuOptions = props.basicItems.map((item, index) => {
const itemStyle = styles.basic?.itemStyle && styles.basic?.itemStyle[item.styleClass];
return item.itemType === "divider" ? (
<MenuDivider key={index} color={styles.basic?.dividerColor} />
<MxMenuDivider key={index} color={styles.basic?.dividerColor} testID={`${props.name}_divider`} />
) : (
<MenuItem
<MxMenuItem
key={index}
onPress={() => handlePress(item.action)}
textStyle={itemStyle}
ellipsizeMode={styles.basic?.itemStyle?.ellipsizeMode as any}
style={styles.basic?.container as any}
ellipsizeMode={styles.basic?.itemStyle?.ellipsizeMode}
style={[basicItemDefaults, styles.basic?.container]}
{...getRippleColor(styles.basic?.itemStyle?.rippleColor)}
testID={`${props.name}_basic-item`}
>
{item.caption}
</MenuItem>
</MxMenuItem>
);
});
} else {
menuOptions = props.customItems.map((item, index) => (
<TouchableItem
<MxMenuItem
key={index}
style={styles.custom?.container}
style={[customItemDefaults, styles.custom?.container]}
onPress={() => handlePress(item.action)}
{...getRippleColor(styles.custom?.itemStyle?.rippleColor)}
testID={`${props.name}_custom-item`}
>
{Platform.OS === "android" ? (
<View style={styles.custom?.container}>{item.content}</View>
) : (
<Fragment>{item.content}</Fragment>
)}
</TouchableItem>
{item.content}
</MxMenuItem>
));
}

return (
<Menu
animationDuration={150}
ref={menuRef}
style={styles?.container as any}
button={
<TouchableButton onPress={showMenu} testID={`${props.name}_trigger`}>
<>
<View ref={anchorRef} collapsable={false}>
<TouchableButton
onPress={open}
testID={`${props.name}_trigger`}
accessibilityRole="button"
accessibilityState={{ expanded }}
>
<View style={styles.buttonContainer} pointerEvents="box-only">
<View pointerEvents="none">{props.menuTriggerer}</View>
</View>
</TouchableButton>
}
>
<View
style={{ overflow: "hidden", borderRadius: styles.container?.borderRadius }}
</View>
<MxMenu
visible={visible}
anchor={anchor}
onRequestClose={close}
animationDuration={150}
style={styles.container}
returnFocusRef={anchorRef}
testID={`${props.name}_menu`}
>
{menuOptions}
</View>
</Menu>
</MxMenu>
</>
);
}

function getRippleColor(color: string | undefined) {
if (color) {
return Platform.OS === "android"
? color && { background: TouchableNativeFeedback.Ripple(color, false) }
: { underlayColor: color };
}
return undefined;
/**
* One style key, two platform behaviours: rippleColor is the colour of the ripple on Android and the
* background shown while an item is pressed on iOS. The menu item picks the one for its platform.
*/
function getRippleColor(color: string | undefined): { rippleColor: string; underlayColor: string } | undefined {
return color ? { rippleColor: color, underlayColor: color } : undefined;
}
Loading
Loading