@plexui/react-native 0.2.3 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/components/ContextMenu/ContextMenu.js +128 -0
- package/dist/es/components/DatePicker/Calendar.js +112 -0
- package/dist/es/components/DatePicker/DatePicker.js +335 -0
- package/dist/es/components/DatePicker/TimeDial.js +123 -0
- package/dist/es/components/DatePicker/Wheel.js +164 -0
- package/dist/es/components/DatePicker/dates.js +147 -0
- package/dist/es/components/Dialog/Dialog.js +21 -0
- package/dist/es/components/Icon/material.js +16 -0
- package/dist/es/components/List/List.js +3 -3
- package/dist/es/components/Menu/Menu.js +50 -9
- package/dist/es/index.js +2 -0
- package/dist/types/components/ContextMenu/ContextMenu.d.ts +57 -0
- package/dist/types/components/DatePicker/Calendar.d.ts +29 -0
- package/dist/types/components/DatePicker/DatePicker.d.ts +57 -0
- package/dist/types/components/DatePicker/TimeDial.d.ts +20 -0
- package/dist/types/components/DatePicker/Wheel.d.ts +40 -0
- package/dist/types/components/DatePicker/dates.d.ts +45 -0
- package/dist/types/components/Dialog/Dialog.d.ts +18 -0
- package/dist/types/components/Icon/material.d.ts +6 -0
- package/dist/types/components/List/List.d.ts +3 -1
- package/dist/types/components/Menu/Menu.d.ts +15 -6
- package/dist/types/index.d.ts +2 -0
- package/package.json +1 -1
- package/src/components/ContextMenu/ContextMenu.tsx +164 -0
- package/src/components/DatePicker/Calendar.tsx +227 -0
- package/src/components/DatePicker/DatePicker.tsx +608 -0
- package/src/components/DatePicker/TimeDial.tsx +201 -0
- package/src/components/DatePicker/Wheel.tsx +247 -0
- package/src/components/DatePicker/dates.ts +161 -0
- package/src/components/Dialog/Dialog.tsx +46 -0
- package/src/components/Icon/material.ts +18 -0
- package/src/components/List/List.tsx +8 -1
- package/src/components/Menu/Menu.tsx +67 -7
- package/src/index.ts +2 -0
|
@@ -40,3 +40,21 @@ export const MaterialCheckSymbol = createIcon("MaterialCheckSymbol", "0 -960 960
|
|
|
40
40
|
* `abc_ic_ab_back_material` that Settings' toolbar shows); it is mirrored right to left.
|
|
41
41
|
*/
|
|
42
42
|
export const MaterialArrowBack = createIcon("MaterialArrowBack", "0 0 24 24", [["path", { d: "M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z", fill: 0 }]])
|
|
43
|
+
|
|
44
|
+
/** Material Symbols' chevron_left and chevron_right (24, the outlined weight 400): a month's arrows in the date picker. */
|
|
45
|
+
export const MaterialChevronLeft = createIcon("MaterialChevronLeft", "0 -960 960 960", [["path", { d: "M560-240 320-480l240-240 56 56-184 184 184 184-56 56Z", fill: 0 }]])
|
|
46
|
+
export const MaterialChevronRight = createIcon("MaterialChevronRight", "0 -960 960 960", [["path", { d: "M504-480 320-664l56-56 240 240-240 240-56-56 184-184Z", fill: 0 }]])
|
|
47
|
+
|
|
48
|
+
/** Material Symbols' calendar_today and schedule (24, outlined weight 400): the trailing icons of a date and a time field. */
|
|
49
|
+
export const MaterialCalendarToday = createIcon("MaterialCalendarToday", "0 -960 960 960", [
|
|
50
|
+
["path", { d: "M200-80q-33 0-56.5-23.5T120-160v-560q0-33 23.5-56.5T200-800h40v-80h80v80h320v-80h80v80h40q33 0 56.5 23.5T840-720v560q0 33-23.5 56.5T760-80H200Zm0-80h560v-400H200v400Zm0-480h560v-80H200v80Zm0 0v-80 80Z", fill: 0 }],
|
|
51
|
+
])
|
|
52
|
+
export const MaterialSchedule = createIcon("MaterialSchedule", "0 -960 960 960", [
|
|
53
|
+
[
|
|
54
|
+
"path",
|
|
55
|
+
{
|
|
56
|
+
d: "m612-292 56-56-148-148v-184h-80v216l172 172ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 320q133 0 226.5-93.5T800-480q0-133-93.5-226.5T480-800q-133 0-226.5 93.5T160-480q0 133 93.5 226.5T480-160Z",
|
|
57
|
+
fill: 0,
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
])
|
|
@@ -330,6 +330,8 @@ export type ListItemProps = {
|
|
|
330
330
|
/** The chevron of a row that opens a page. @default true when the row has `onPress`, no `trailing` and is not `destructive` */
|
|
331
331
|
disclosure?: boolean
|
|
332
332
|
onPress?: () => void
|
|
333
|
+
/** A touch and hold on the row (half a second): a ContextMenu around the row sets it. */
|
|
334
|
+
onLongPress?: () => void
|
|
333
335
|
disabled?: boolean
|
|
334
336
|
/** A row in red, as a destructive action row. */
|
|
335
337
|
destructive?: boolean
|
|
@@ -363,6 +365,7 @@ export function ListItem({
|
|
|
363
365
|
onCheckedChange,
|
|
364
366
|
disclosure,
|
|
365
367
|
onPress,
|
|
368
|
+
onLongPress,
|
|
366
369
|
disabled = false,
|
|
367
370
|
destructive = false,
|
|
368
371
|
accessibilityLabel,
|
|
@@ -452,7 +455,7 @@ export function ListItem({
|
|
|
452
455
|
</RowFrameContext.Provider>
|
|
453
456
|
)
|
|
454
457
|
}
|
|
455
|
-
if (press) {
|
|
458
|
+
if (press || onLongPress) {
|
|
456
459
|
// Android's rows press in the list selector: the native ripple on a device, the drawn one on the web
|
|
457
460
|
const highlight = controlHighlight(theme.scheme)
|
|
458
461
|
const drawn = theme.isAndroid && !nativeRipple
|
|
@@ -472,6 +475,10 @@ export function ListItem({
|
|
|
472
475
|
aria-checked={switchRow ? checked : undefined}
|
|
473
476
|
disabled={disabled}
|
|
474
477
|
onPress={press}
|
|
478
|
+
onLongPress={onLongPress}
|
|
479
|
+
delayLongPress={onLongPress ? 500 : undefined}
|
|
480
|
+
accessibilityActions={onLongPress ? [{ name: "longpress" }] : undefined}
|
|
481
|
+
onAccessibilityAction={onLongPress ? (event) => event.nativeEvent.actionName === "longpress" && onLongPress() : undefined}
|
|
475
482
|
onPressIn={drawn ? ripple.start : undefined}
|
|
476
483
|
onPressOut={drawn ? ripple.end : undefined}
|
|
477
484
|
android_ripple={nativeRipple ? { color: highlight, foreground: true } : undefined}
|
|
@@ -199,7 +199,7 @@ function MenuContent(props: MenuContentProps) {
|
|
|
199
199
|
return <MenuSurface {...props} check={hasCheckedItems(props.children)} open={menu.open} anchor={menu.anchor} row={menu.row} header={menu.header} onClose={() => menu.setOpen(false)} />
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
function hasCheckedItems(children: ReactNode): boolean {
|
|
202
|
+
export function hasCheckedItems(children: ReactNode): boolean {
|
|
203
203
|
return Children.toArray(children).some((child) =>
|
|
204
204
|
isValidElement<{ checked?: boolean; children?: ReactNode }>(child) ? child.props.checked !== undefined || (child.type === Fragment && hasCheckedItems(child.props.children)) : false,
|
|
205
205
|
)
|
|
@@ -219,6 +219,11 @@ type SurfaceProps = MenuContentProps & {
|
|
|
219
219
|
row?: MenuRow | null
|
|
220
220
|
/** Opened from a bar's button: on Android the header menu, in the bar's glass. */
|
|
221
221
|
header?: boolean
|
|
222
|
+
/**
|
|
223
|
+
* A context menu's touch and hold (ContextMenu): on iOS the screen dims and blurs but the element, drawn again
|
|
224
|
+
* over the dimming as its lifted `preview`, and the menu stands 16 from it, by the third of the screen it is in.
|
|
225
|
+
*/
|
|
226
|
+
context?: { preview: ReactNode; radius: number }
|
|
222
227
|
}
|
|
223
228
|
|
|
224
229
|
/** The floating panel of a menu, placed under its anchor (over it when the screen ends first). */
|
|
@@ -228,7 +233,7 @@ export function MenuSurface(props: SurfaceProps) {
|
|
|
228
233
|
}
|
|
229
234
|
|
|
230
235
|
/** iOS 26's pop-up menu: glass, a submenu over the menu at its row while the menu steps back. */
|
|
231
|
-
function IOSMenuSurface({ open, anchor, onClose, align = "start", width, check = false, multiple = false, cover, children, "aria-label": ariaLabel, testID }: SurfaceProps) {
|
|
236
|
+
function IOSMenuSurface({ open, anchor, onClose, align = "start", width, check = false, multiple = false, cover, context, children, "aria-label": ariaLabel, testID }: SurfaceProps) {
|
|
232
237
|
const theme = useTheme()
|
|
233
238
|
const insets = useSafeAreaInsets()
|
|
234
239
|
const window = useWindowDimensions()
|
|
@@ -269,9 +274,33 @@ function IOSMenuSurface({ open, anchor, onClose, align = "start", width, check =
|
|
|
269
274
|
const below = over ? box.y : box.y + box.height + gap
|
|
270
275
|
const fitsBelow = below + height <= window.height - bottomEdge
|
|
271
276
|
const above = over ? box.y + box.height - height : box.y - gap - height
|
|
272
|
-
|
|
277
|
+
let top = size == null ? -window.height - 1000 : fitsBelow ? below : Math.max(topEdge, above)
|
|
278
|
+
let previewTop = box.y
|
|
279
|
+
if (context) {
|
|
280
|
+
// iOS 27.2 places a context menu by where the element stands (ref-app menus-context): in the left third at its
|
|
281
|
+
// left edge, in the right third at its right edge, else at its centre; 16 under it, or over it when the element
|
|
282
|
+
// is in the lower half and the menu fits there (the web's ContextMenu, contextMenuPreview)
|
|
283
|
+
const centre = box.x + box.width / 2
|
|
284
|
+
left = centre < window.width / 3 ? box.x : centre > (window.width * 2) / 3 ? box.x + box.width - measured : centre - measured / 2
|
|
285
|
+
left = Math.max(margin, Math.min(left, window.width - measured - margin))
|
|
286
|
+
const lift = 16
|
|
287
|
+
const overIt = box.y - lift - height
|
|
288
|
+
const underIt = box.y + box.height + lift
|
|
289
|
+
const lower = box.y + box.height / 2 > window.height / 2
|
|
290
|
+
if (size != null) {
|
|
291
|
+
if (lower && overIt >= topEdge) top = overIt
|
|
292
|
+
else {
|
|
293
|
+
// Where the menu does not fit under the element it lifts the element up with it, as iOS moves the preview, so
|
|
294
|
+
// the menu never covers it
|
|
295
|
+
const overflow = underIt + height - (window.height - bottomEdge)
|
|
296
|
+
previewTop = overflow > 0 ? Math.max(topEdge, box.y - overflow) : box.y
|
|
297
|
+
top = Math.max(topEdge, Math.min(previewTop + box.height + lift, window.height - bottomEdge - height))
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
273
301
|
// The measures are from the screen's left; a phone in a right-to-left layout reads `left` as the start edge
|
|
274
|
-
const
|
|
302
|
+
const swap = Platform.OS !== "web" && I18nManager.isRTL && I18nManager.doLeftAndRightSwapInRTL
|
|
303
|
+
const horizontal = swap ? { right: left } : { left }
|
|
275
304
|
const maxHeight = window.height - topEdge - bottomEdge
|
|
276
305
|
const timing = overlayTiming(theme, "menu")
|
|
277
306
|
const moveTo = (value: Animated.Value, to: number, enter: boolean, done?: () => void) => {
|
|
@@ -347,6 +376,36 @@ function IOSMenuSurface({ open, anchor, onClose, align = "start", width, check =
|
|
|
347
376
|
<Overlay open={open} onDismiss={onClose} motion="menu" testID={testID}>
|
|
348
377
|
{(progress, opening) => (
|
|
349
378
|
<>
|
|
379
|
+
{context ? (
|
|
380
|
+
<>
|
|
381
|
+
{/* The page dims (black at 20%, 50% at night) over a 30px blur on the web; the element stays clear */}
|
|
382
|
+
<Animated.View
|
|
383
|
+
pointerEvents="none"
|
|
384
|
+
style={[
|
|
385
|
+
StyleSheet.absoluteFill,
|
|
386
|
+
{ backgroundColor: theme.color("--context-menu-dimming-background", theme.scheme === "dark" ? "rgba(0, 0, 0, 0.5)" : "rgba(0, 0, 0, 0.2)"), opacity: progress },
|
|
387
|
+
web ? ({ backdropFilter: "blur(30px)", WebkitBackdropFilter: "blur(30px)" } as ViewStyle) : null,
|
|
388
|
+
]}
|
|
389
|
+
/>
|
|
390
|
+
<View
|
|
391
|
+
pointerEvents="none"
|
|
392
|
+
style={[
|
|
393
|
+
styles.preview,
|
|
394
|
+
swap ? { right: box.x } : { left: box.x },
|
|
395
|
+
{
|
|
396
|
+
top: previewTop,
|
|
397
|
+
width: box.width,
|
|
398
|
+
height: box.height,
|
|
399
|
+
borderRadius: context.radius,
|
|
400
|
+
backgroundColor: theme.colors.groupedSurface,
|
|
401
|
+
boxShadow: String(theme.token("--context-menu-preview-shadow") ?? "0 0 32px rgba(0, 0, 0, 0.2)"),
|
|
402
|
+
},
|
|
403
|
+
]}
|
|
404
|
+
>
|
|
405
|
+
{context.preview}
|
|
406
|
+
</View>
|
|
407
|
+
</>
|
|
408
|
+
) : null}
|
|
350
409
|
<Animated.View
|
|
351
410
|
ref={panel as never}
|
|
352
411
|
// The panel takes the focus of a menu opened by a pointer (the web), with no ring of its own
|
|
@@ -996,7 +1055,7 @@ type RowExtras = {
|
|
|
996
1055
|
rowRef?: { current: unknown }
|
|
997
1056
|
}
|
|
998
1057
|
|
|
999
|
-
function MenuItem(props: MenuItemProps) {
|
|
1058
|
+
export function MenuItem(props: MenuItemProps) {
|
|
1000
1059
|
return <MenuRow {...props} />
|
|
1001
1060
|
}
|
|
1002
1061
|
MenuItem.displayName = "Menu.Item"
|
|
@@ -1216,7 +1275,7 @@ MenuSubTrigger.displayName = "Menu.SubTrigger"
|
|
|
1216
1275
|
const MenuSubContent: ((props: MenuSubContentProps) => null) & { displayName?: string } = () => null
|
|
1217
1276
|
MenuSubContent.displayName = "Menu.SubContent"
|
|
1218
1277
|
|
|
1219
|
-
function MenuSeparator() {
|
|
1278
|
+
export function MenuSeparator() {
|
|
1220
1279
|
const theme = useTheme()
|
|
1221
1280
|
const surface = useContext(SurfaceContext)
|
|
1222
1281
|
// Android parts a popup's groups with an 8dp band: a light gray (#F5F5F5, #262626 at night) in a row's menu, the text
|
|
@@ -1245,7 +1304,7 @@ function MenuSeparator() {
|
|
|
1245
1304
|
MenuSeparator.displayName = "Menu.Separator"
|
|
1246
1305
|
|
|
1247
1306
|
/** A heading over a group of items. */
|
|
1248
|
-
function MenuLabel({ children }: { children: ReactNode }) {
|
|
1307
|
+
export function MenuLabel({ children }: { children: ReactNode }) {
|
|
1249
1308
|
const theme = useTheme()
|
|
1250
1309
|
const surface = useContext(SurfaceContext)
|
|
1251
1310
|
if (theme.isAndroid) {
|
|
@@ -1295,6 +1354,7 @@ export const Menu = Object.assign(MenuRoot, {
|
|
|
1295
1354
|
})
|
|
1296
1355
|
|
|
1297
1356
|
const styles = StyleSheet.create({
|
|
1357
|
+
preview: { position: "absolute", overflow: "hidden" },
|
|
1298
1358
|
trigger: { alignSelf: "flex-start" },
|
|
1299
1359
|
surface: { position: "absolute", outlineWidth: 0, outlineStyle: "none" as "solid" },
|
|
1300
1360
|
shrink: { flexShrink: 1 },
|
package/src/index.ts
CHANGED
|
@@ -80,6 +80,8 @@ export { TagInput, type Tag, type TagInputProps } from "./components/TagInput/Ta
|
|
|
80
80
|
export { OTPInput, type OTPInputProps } from "./components/OTPInput/OTPInput"
|
|
81
81
|
export { Select, type SelectOption, type SelectProps } from "./components/Select/Select"
|
|
82
82
|
export { Menu, type MenuContentProps, type MenuItemProps, type MenuProps } from "./components/Menu/Menu"
|
|
83
|
+
export { ContextMenu, type ContextMenuContentProps, type ContextMenuProps } from "./components/ContextMenu/ContextMenu"
|
|
84
|
+
export { DatePicker, type DatePickerDisplay, type DatePickerMode, type DatePickerProps } from "./components/DatePicker/DatePicker"
|
|
83
85
|
export { ActionSheet, type ActionSheetAction, type ActionSheetProps } from "./components/ActionSheet/ActionSheet"
|
|
84
86
|
export { BottomSheet, type BottomSheetFooterProps, type BottomSheetProps } from "./components/BottomSheet/BottomSheet"
|
|
85
87
|
export { Dialog, type DialogAction, type DialogProps } from "./components/Dialog/Dialog"
|