@plexui/ui 0.42.0 → 0.43.0

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.
Files changed (77) hide show
  1. package/dist/es/components/Alert/Alert.js +12 -2
  2. package/dist/es/components/Alert/Alert.js.map +1 -1
  3. package/dist/es/components/ColorPicker/ColorPicker.js +12 -10
  4. package/dist/es/components/ColorPicker/ColorPicker.js.map +1 -1
  5. package/dist/es/components/ColorPicker/ColorWell.js +1 -1
  6. package/dist/es/components/ColorPicker/ColorWell.js.map +1 -1
  7. package/dist/es/components/ColorPicker/shared.js +5 -4
  8. package/dist/es/components/ColorPicker/shared.js.map +1 -1
  9. package/dist/es/components/ContextMenu/ContextMenu.js +9 -9
  10. package/dist/es/components/ContextMenu/ContextMenu.js.map +1 -1
  11. package/dist/es/components/ContextMenu/shared.js +25 -5
  12. package/dist/es/components/ContextMenu/shared.js.map +1 -1
  13. package/dist/es/components/DatePicker/DatePicker.js +3 -3
  14. package/dist/es/components/DatePicker/DatePicker.js.map +1 -1
  15. package/dist/es/components/DatePicker/useCalendarCollisionPadding.js +25 -0
  16. package/dist/es/components/DatePicker/useCalendarCollisionPadding.js.map +1 -0
  17. package/dist/es/components/DateRangePicker/DateRangePicker.js +3 -3
  18. package/dist/es/components/DateRangePicker/DateRangePicker.js.map +1 -1
  19. package/dist/es/components/Dialog/Dialog.js +1 -1
  20. package/dist/es/components/Dialog/Dialog.js.map +1 -1
  21. package/dist/es/components/Input/Input.js +1 -1
  22. package/dist/es/components/Input/Input.js.map +1 -1
  23. package/dist/es/components/Menu/Menu.js +15 -2
  24. package/dist/es/components/Menu/Menu.js.map +1 -1
  25. package/dist/es/components/PhoneLayout/PhoneLayout.js +6 -1
  26. package/dist/es/components/PhoneLayout/PhoneLayout.js.map +1 -1
  27. package/dist/es/components/Popover/Popover.js.map +1 -1
  28. package/dist/es/components/ProgressSteps/ProgressSteps.js +1 -1
  29. package/dist/es/components/ProgressSteps/ProgressSteps.js.map +1 -1
  30. package/dist/es/components/ProgressSteps/index.js.map +1 -1
  31. package/dist/es/components/Select/Select.js +155 -25
  32. package/dist/es/components/Select/Select.js.map +1 -1
  33. package/dist/es/components/SelectControl/SelectControl.js +1 -1
  34. package/dist/es/components/SelectControl/SelectControl.js.map +1 -1
  35. package/dist/es/components/Slider/Slider.js +19 -12
  36. package/dist/es/components/Slider/Slider.js.map +1 -1
  37. package/dist/es/components/Sortable/Sortable.js +1 -1
  38. package/dist/es/components/Sortable/Sortable.js.map +1 -1
  39. package/dist/es/components/StatCard/index.js +5 -1
  40. package/dist/es/components/StatCard/index.js.map +1 -1
  41. package/dist/es/components/StatsCard/StatsCard.js +48 -0
  42. package/dist/es/components/StatsCard/StatsCard.js.map +1 -0
  43. package/dist/es/components/StatsCard/index.js +2 -0
  44. package/dist/es/components/StatsCard/index.js.map +1 -0
  45. package/dist/es/components/SwipeActions/SwipeActions.js +30 -8
  46. package/dist/es/components/SwipeActions/SwipeActions.js.map +1 -1
  47. package/dist/es/components/TabBar/TabBar.js +11 -4
  48. package/dist/es/components/TabBar/TabBar.js.map +1 -1
  49. package/dist/es/components/Tabs/Tabs.js +200 -7
  50. package/dist/es/components/Tabs/Tabs.js.map +1 -1
  51. package/dist/es/components/Toolbar/Toolbar.js.map +1 -1
  52. package/dist/es/lib/menuTriggerCover.js +40 -3
  53. package/dist/es/lib/menuTriggerCover.js.map +1 -1
  54. package/dist/types/components/ColorPicker/ColorPicker.d.ts +3 -2
  55. package/dist/types/components/ColorPicker/shared.d.ts +5 -4
  56. package/dist/types/components/ContextMenu/shared.d.ts +28 -6
  57. package/dist/types/components/DatePicker/useCalendarCollisionPadding.d.ts +8 -0
  58. package/dist/types/components/Dialog/Dialog.d.ts +1 -1
  59. package/dist/types/components/PhoneLayout/PhoneLayout.d.ts +5 -0
  60. package/dist/types/components/Popover/Popover.d.ts +2 -2
  61. package/dist/types/components/ProgressSteps/ProgressSteps.d.ts +11 -4
  62. package/dist/types/components/ProgressSteps/index.d.ts +1 -1
  63. package/dist/types/components/Select/Select.d.ts +11 -3
  64. package/dist/types/components/StatCard/index.d.ts +5 -1
  65. package/dist/types/components/{StatCard/StatCard.d.ts → StatsCard/StatsCard.d.ts} +7 -7
  66. package/dist/types/components/StatsCard/index.d.ts +1 -0
  67. package/dist/types/components/SwipeActions/SwipeActions.d.ts +1 -1
  68. package/dist/types/components/TabBar/TabBar.d.ts +12 -2
  69. package/dist/types/components/Tabs/Tabs.d.ts +12 -0
  70. package/dist/types/components/Toolbar/Toolbar.d.ts +1 -1
  71. package/dist/types/lib/menuTriggerCover.d.ts +16 -2
  72. package/package.json +2 -2
  73. package/dist/es/components/DatePicker/useCalendarGutter.js +0 -8
  74. package/dist/es/components/DatePicker/useCalendarGutter.js.map +0 -1
  75. package/dist/es/components/StatCard/StatCard.js +0 -39
  76. package/dist/es/components/StatCard/StatCard.js.map +0 -1
  77. package/dist/types/components/DatePicker/useCalendarGutter.d.ts +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ProgressSteps.js","sourceRoot":"","sources":["../../../../src/components/ProgressSteps/ProgressSteps.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAkB,MAAM,OAAO,CAAA;AAClF,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAE7C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,CAAC,MAAM,kEAAkE,CAAA;AAkBhF,MAAM,oBAAoB,GAAG,aAAa,CAAmC,IAAI,CAAC,CAAA;AAElF,MAAM,uBAAuB,GAAG,GAAG,EAAE;IACnC,MAAM,OAAO,GAAG,GAAG,CAAC,oBAAoB,CAAC,CAAA;IACzC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,+DAA+D,CA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AAC,CAAC,MAAM,KAAK,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAA;IAErF,MAAM,MAAM,GAAG,MAAM,KAAK,UAAU,GAAG,CAAC,CAAA;IAExC,OAAO,CACL,cACE,SAAS,EAAE,CAAC,CAAC,IAAI,gBACL,KAAK,kBACH,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,aAErD,cAAK,SAAS,EAAE,CAAC,CAAC,aAAa,YAC5B,KAAK,KAAK,WAAW,CAAC,CAAC,CAAC,KAAC,OAAO,+BAAoB,CAAC,CAAC,CAAC,IAAI,IAAI,MAAM,GAAG,CAAC,GACtE,EACL,CAAC,MAAM,IAAI,cAAK,SAAS,EAAE,CAAC,CAAC,aAAa,GAAI,EAC/C,cAAK,SAAS,EAAE,CAAC,CAAC,WAAW,YAAG,QAAQ,GAAO,IAC5C,CACN,CAAA;AACH,CAAC,CAAA;AAED,MAAM,KAAK,GAAG,CAAC,EAAE,QAAQ,EAAE,SAAS,EAA+C,EAAE,EAAE,CAAC,CACtF,cAAK,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,YAAG,QAAQ,GAAO,CAC/D,CAAA;AAED,MAAM,WAAW,GAAG,CAAC,EAAE,QAAQ,EAAE,SAAS,EAA+C,EAAE,EAAE,CAAC,CAC5F,cAAK,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,eAAe,EAAE,SAAS,CAAC,YAAG,QAAQ,GAAO,CACrE,CAAA;AAED,aAAa,CAAC,IAAI,GAAG,IAAI,CAAA;AACzB,aAAa,CAAC,KAAK,GAAG,KAAK,CAAA;AAC3B,aAAa,CAAC,WAAW,GAAG,WAAW,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport React, { createContext, use, useMemo, useRef, type ReactNode } from \"react\"\nimport { isDev } from \"../../lib/environment\"\nimport type { Sizes } from \"../../types\"\nimport { CheckMd } from \"../Icon\"\nimport s from \"@plexui/styles/components/ProgressSteps/ProgressSteps.module.css\"\n\ntype Orientation = \"horizontal\" | \"vertical\"\ntype StepState = \"completed\" | \"active\" | \"inactive\"\ntype ConnectorStyle = \"solid\" | \"dashed\"\ntype Variant = \"default\" | \"minimal\"\ntype Color = \"default\" | \"success\"\n\ntype ProgressStepsContextValue = {\n current: number\n orientation: Orientation\n size: Sizes<\"sm\" | \"md\" | \"lg\">\n connectorStyle: ConnectorStyle\n variant: Variant\n color: Color\n totalSteps: number\n}\n\nconst ProgressStepsContext = createContext<ProgressStepsContextValue | null>(null)\n\nconst useProgressStepsContext = () => {\n const context = use(ProgressStepsContext)\n if (!context) {\n throw new Error(\"ProgressSteps components must be wrapped in <ProgressSteps />\")\n }\n return context\n}\n\nexport type ProgressStepsProps = {\n /** Current active step (1-indexed, starts from 1) */\n current: number\n /**\n * Total number of steps (required for minimal variant)\n */\n total?: number\n /**\n * Visual variant\n * @default default\n */\n variant?: Variant\n /**\n * Color scheme\n * @default default\n */\n color?: Color\n /**\n * Layout orientation\n * @default horizontal\n */\n orientation?: Orientation\n /**\n * Size of step indicators\n * @default md\n */\n size?: Sizes<\"sm\" | \"md\" | \"lg\">\n /**\n * Connector line style\n * @default solid\n */\n connectorStyle?: ConnectorStyle\n /** Class applied to the container */\n className?: string\n children?: ReactNode\n}\n\nexport const ProgressSteps = ({\n current,\n total,\n variant = \"default\",\n color = \"default\",\n orientation = \"horizontal\",\n size = \"md\",\n connectorStyle = \"solid\",\n children,\n className,\n}: ProgressStepsProps) => {\n const totalSteps = variant === \"minimal\" ? total ?? 0 : React.Children.count(children)\n\n const warnedRef = useRef(false)\n if (isDev && variant === \"minimal\" && (total == null || total <= 0) && !warnedRef.current) {\n warnedRef.current = true\n // eslint-disable-next-line no-console\n console.warn(\n '[ProgressSteps] variant=\"minimal\" requires a positive `total` prop. Received:',\n total,\n )\n }\n\n const store = useMemo<ProgressStepsContextValue>(\n () => ({ current, orientation, size, connectorStyle, variant, color, totalSteps }),\n [current, orientation, size, connectorStyle, variant, color, totalSteps],\n )\n\n // Minimal variant: render horizontal bar segments\n if (variant === \"minimal\") {\n return (\n // A div, not nav: role=\"progressbar\" is not allowed on <nav>\n <div\n aria-label=\"Progress\"\n role=\"progressbar\"\n aria-valuenow={current}\n aria-valuemin={1}\n aria-valuemax={totalSteps}\n className={clsx(s.ProgressSteps, s.Minimal, className)}\n data-size={size}\n data-color={color}\n data-variant=\"minimal\"\n >\n <div className={s.MinimalList}>\n {Array.from({ length: totalSteps }, (_, i) => (\n <div\n key={i}\n className={s.MinimalSegment}\n data-state={i < current ? \"completed\" : \"upcoming\"}\n />\n ))}\n </div>\n </div>\n )\n }\n\n return (\n <ProgressStepsContext value={store}>\n <nav\n aria-label=\"Progress\"\n className={clsx(s.ProgressSteps, className)}\n data-size={size}\n data-color={color}\n data-variant={variant}\n >\n <ol\n className={s.List}\n data-orientation={orientation}\n data-connector={connectorStyle}\n data-variant={variant}\n >\n {React.Children.map(children, (child, index) =>\n React.isValidElement(child)\n ? React.cloneElement(child, { _index: index } as Record<string, unknown>)\n : child,\n )}\n </ol>\n </nav>\n </ProgressStepsContext>\n )\n}\n\nexport type StepProps = {\n /** Custom icon (replaces step number) */\n icon?: ReactNode\n /** Step content (Title and/or Description) */\n children?: ReactNode\n /** @internal - injected by parent */\n _index?: number\n}\n\nconst Step = ({ children, icon, _index = 0 }: StepProps) => {\n const { current, totalSteps } = useProgressStepsContext()\n\n const state: StepState =\n _index < current - 1 ? \"completed\" : _index === current - 1 ? \"active\" : \"inactive\"\n\n const isLast = _index === totalSteps - 1\n\n return (\n <li\n className={s.Step}\n data-state={state}\n aria-current={state === \"active\" ? \"step\" : undefined}\n >\n <div className={s.StepIndicator}>\n {state === \"completed\" ? <CheckMd data-no-autosize /> : icon ?? _index + 1}\n </div>\n {!isLast && <div className={s.StepConnector} />}\n <div className={s.StepContent}>{children}</div>\n </li>\n )\n}\n\nconst Title = ({ children, className }: { children: ReactNode; className?: string }) => (\n <div className={clsx(s.StepTitle, className)}>{children}</div>\n)\n\nconst Description = ({ children, className }: { children: ReactNode; className?: string }) => (\n <div className={clsx(s.StepDescription, className)}>{children}</div>\n)\n\nProgressSteps.Step = Step\nProgressSteps.Title = Title\nProgressSteps.Description = Description\n"]}
1
+ {"version":3,"file":"ProgressSteps.js","sourceRoot":"","sources":["../../../../src/components/ProgressSteps/ProgressSteps.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAkB,MAAM,OAAO,CAAA;AAClF,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAE7C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,CAAC,MAAM,kEAAkE,CAAA;AAkBhF,MAAM,oBAAoB,GAAG,aAAa,CAAmC,IAAI,CAAC,CAAA;AAElF,MAAM,uBAAuB,GAAG,GAAG,EAAE;IACnC,MAAM,OAAO,GAAG,GAAG,CAAC,oBAAoB,CAAC,CAAA;IACzC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAA;IAClF,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAuCD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAC5B,OAAO,EACP,KAAK,EACL,OAAO,GAAG,SAAS,EACnB,KAAK,GAAG,SAAS,EACjB,WAAW,GAAG,YAAY,EAC1B,IAAI,GAAG,IAAI,EACX,cAAc,GAAG,OAAO,EACxB,QAAQ,EACR,SAAS,GACU,EAAE,EAAE;IACvB,MAAM,UAAU,GAAG,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,KA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AC,IAAI,IAAI,MAAM,GAAG,CAAC,GACtE,EACL,CAAC,MAAM,IAAI,cAAK,SAAS,EAAE,CAAC,CAAC,aAAa,GAAI,EAC/C,cAAK,SAAS,EAAE,CAAC,CAAC,WAAW,YAAG,QAAQ,GAAO,IAC5C,CACN,CAAA;AACH,CAAC,CAAA;AAaD,MAAM,KAAK,GAAG,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,cAAc,GAAG,KAAK,EAAc,EAAE,EAAE,CAAC,CAC7E,cAAK,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,0BAAwB,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,YAAG,QAAQ,GAAO,CACtH,CAAA;AAED,MAAM,WAAW,GAAG,CAAC,EAAE,QAAQ,EAAE,SAAS,EAA+C,EAAE,EAAE,CAAC,CAC5F,cAAK,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,eAAe,EAAE,SAAS,CAAC,YAAG,QAAQ,GAAO,CACrE,CAAA;AAED,aAAa,CAAC,IAAI,GAAG,IAAI,CAAA;AACzB,aAAa,CAAC,KAAK,GAAG,KAAK,CAAA;AAC3B,aAAa,CAAC,WAAW,GAAG,WAAW,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport React, { createContext, use, useMemo, useRef, type ReactNode } from \"react\"\nimport { isDev } from \"../../lib/environment\"\nimport type { Sizes } from \"../../types\"\nimport { CheckMd } from \"../Icon\"\nimport s from \"@plexui/styles/components/ProgressSteps/ProgressSteps.module.css\"\n\ntype Orientation = \"horizontal\" | \"vertical\"\ntype StepState = \"completed\" | \"active\" | \"inactive\"\ntype ConnectorStyle = \"solid\" | \"dashed\"\ntype Variant = \"default\" | \"minimal\"\ntype Color = \"default\" | \"success\"\n\ntype ProgressStepsContextValue = {\n current: number\n orientation: Orientation\n size: Sizes<\"sm\" | \"md\" | \"lg\">\n connectorStyle: ConnectorStyle\n variant: Variant\n color: Color\n totalSteps: number\n}\n\nconst ProgressStepsContext = createContext<ProgressStepsContextValue | null>(null)\n\nconst useProgressStepsContext = () => {\n const context = use(ProgressStepsContext)\n if (!context) {\n throw new Error(\"ProgressSteps components must be wrapped in <ProgressSteps />\")\n }\n return context\n}\n\nexport type ProgressStepsProps = {\n /** Current active step (1-indexed, starts from 1) */\n current: number\n /**\n * Total number of steps (required for minimal variant)\n */\n total?: number\n /**\n * Visual variant\n * @default default\n */\n variant?: Variant\n /**\n * Color scheme\n * @default default\n */\n color?: Color\n /**\n * Layout orientation\n * @default horizontal\n */\n orientation?: Orientation\n /**\n * Size of step indicators\n * @default md\n */\n size?: Sizes<\"sm\" | \"md\" | \"lg\">\n /**\n * Connector line style\n * @default solid\n */\n connectorStyle?: ConnectorStyle\n /** Class applied to the container */\n className?: string\n children?: ReactNode\n}\n\nexport const ProgressSteps = ({\n current,\n total,\n variant = \"default\",\n color = \"default\",\n orientation = \"horizontal\",\n size = \"md\",\n connectorStyle = \"solid\",\n children,\n className,\n}: ProgressStepsProps) => {\n const totalSteps = variant === \"minimal\" ? total ?? 0 : React.Children.count(children)\n\n const warnedRef = useRef(false)\n if (isDev && variant === \"minimal\" && (total == null || total <= 0) && !warnedRef.current) {\n warnedRef.current = true\n // eslint-disable-next-line no-console\n console.warn(\n '[ProgressSteps] variant=\"minimal\" requires a positive `total` prop. Received:',\n total,\n )\n }\n\n const store = useMemo<ProgressStepsContextValue>(\n () => ({ current, orientation, size, connectorStyle, variant, color, totalSteps }),\n [current, orientation, size, connectorStyle, variant, color, totalSteps],\n )\n\n // Minimal variant: render horizontal bar segments\n if (variant === \"minimal\") {\n return (\n // A div, not nav: role=\"progressbar\" is not allowed on <nav>\n <div\n aria-label=\"Progress\"\n role=\"progressbar\"\n aria-valuenow={current}\n aria-valuemin={1}\n aria-valuemax={totalSteps}\n className={clsx(s.ProgressSteps, s.Minimal, className)}\n data-size={size}\n data-color={color}\n data-variant=\"minimal\"\n >\n <div className={s.MinimalList}>\n {Array.from({ length: totalSteps }, (_, i) => (\n <div\n key={i}\n className={s.MinimalSegment}\n data-state={i < current ? \"completed\" : \"upcoming\"}\n />\n ))}\n </div>\n </div>\n )\n }\n\n return (\n <ProgressStepsContext value={store}>\n <nav\n aria-label=\"Progress\"\n className={clsx(s.ProgressSteps, className)}\n data-size={size}\n data-color={color}\n data-variant={variant}\n >\n <ol\n className={s.List}\n data-orientation={orientation}\n data-connector={connectorStyle}\n data-variant={variant}\n >\n {React.Children.map(children, (child, index) =>\n React.isValidElement(child)\n ? React.cloneElement(child, { _index: index } as Record<string, unknown>)\n : child,\n )}\n </ol>\n </nav>\n </ProgressStepsContext>\n )\n}\n\nexport type StepProps = {\n /** Custom icon (replaces step number) */\n icon?: ReactNode\n /** Step content (Title and/or Description) */\n children?: ReactNode\n /** @internal - injected by parent */\n _index?: number\n}\n\nconst Step = ({ children, icon, _index = 0 }: StepProps) => {\n const { current, totalSteps } = useProgressStepsContext()\n\n const state: StepState =\n _index < current - 1 ? \"completed\" : _index === current - 1 ? \"active\" : \"inactive\"\n\n const isLast = _index === totalSteps - 1\n\n return (\n <li\n className={s.Step}\n data-state={state}\n aria-current={state === \"active\" ? \"step\" : undefined}\n >\n <div className={s.StepIndicator}>\n {state === \"completed\" ? <CheckMd data-no-autosize /> : icon ?? _index + 1}\n </div>\n {!isLast && <div className={s.StepConnector} />}\n <div className={s.StepContent}>{children}</div>\n </li>\n )\n}\n\nexport type TitleProps = {\n children: ReactNode\n className?: string\n /**\n * Hides the title from view and keeps it for screen readers, for steps that show their indicators alone: an icon\n * or a check has no name. The step then takes no room under its indicator.\n * @default false\n */\n visuallyHidden?: boolean\n}\n\nconst Title = ({ children, className, visuallyHidden = false }: TitleProps) => (\n <div className={clsx(s.StepTitle, className)} data-visually-hidden={visuallyHidden ? \"\" : undefined}>{children}</div>\n)\n\nconst Description = ({ children, className }: { children: ReactNode; className?: string }) => (\n <div className={clsx(s.StepDescription, className)}>{children}</div>\n)\n\nProgressSteps.Step = Step\nProgressSteps.Title = Title\nProgressSteps.Description = Description\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/ProgressSteps/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA2C,MAAM,iBAAiB,CAAA","sourcesContent":["export { ProgressSteps, type ProgressStepsProps, type StepProps } from \"./ProgressSteps\"\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/ProgressSteps/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA4D,MAAM,iBAAiB,CAAA","sourcesContent":["export { ProgressSteps, type ProgressStepsProps, type StepProps, type TitleProps } from \"./ProgressSteps\"\n"]}
@@ -17,6 +17,8 @@ import { overlayTiming } from "../Transition/shared.js";
17
17
  import { isHoverPointer } from "../../lib/inputMode.js";
18
18
  import { createSelectPress } from "../../lib/selectPress.js";
19
19
  import { createFocusRestore } from "../../lib/focusRestore.js";
20
+ import { ignoreReleaseOverTrigger, markCoveredMenuTrigger, observeMenuTriggerCover } from "../../lib/menuTriggerCover.js";
21
+ import { usePhoneWindow } from "../PhoneLayout/PhoneLayout.js";
20
22
  import s from "@plexui/styles/components/Select/Select.module.css";
21
23
  const SelectContext = createContext(null);
22
24
  const useSelectContext = () => {
@@ -41,7 +43,7 @@ const DefaultMultiTriggerView = ({ values, selectedAll, }) => {
41
43
  return _jsx(_Fragment, { children: displayValue });
42
44
  };
43
45
  export const Select = (props) => {
44
- const { id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, required, value, name, multiple, variant = "outline", size = "md", dropdownIconType = "dropdown", loading = false, clearable = false, disabled = false, placeholder = "Select...", loadingPlaceholder = "Loading...", allSelectedLabel = "All selected", pill: pillProp, listMinWidth, options, actions: propActions = [], side = "bottom", avoidCollisions = true, onChange, optionClassName, OptionView = DefaultOptionView, TriggerStartIcon, triggerClassName, opticallyAlign, TriggerView: TriggerViewFromProps, searchPlaceholder = "", searchAriaLabel = "Search options", searchSize, searchPredicate = defaultSearchPredicate, searchEmptyMessage = "No results found.", trigger, checkPosition = 'start', } = props;
46
+ const { id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, required, value, name, multiple, variant = "outline", size = "md", dropdownIconType = "dropdown", loading = false, clearable = false, disabled = false, placeholder = "Select...", loadingPlaceholder = "Loading...", allSelectedLabel = "All selected", noneLabel = "None", pill: pillProp, listMinWidth, options, actions: propActions = [], side, avoidCollisions = true, onChange, optionClassName, OptionView = DefaultOptionView, TriggerStartIcon, triggerClassName, opticallyAlign, TriggerView: TriggerViewFromProps, searchPlaceholder = "", searchAriaLabel = "Search options", searchSize, searchPredicate = defaultSearchPredicate, searchEmptyMessage = "No results found.", trigger, checkPosition = 'start', } = props;
45
47
  const pill = useFieldRowPill(pillProp);
46
48
  // At the end of a Field row the menu opens from the row's end and fits its options: on a phone
47
49
  // the trigger there is only as wide as its value, so a menu of the trigger's width breaks every word.
@@ -103,7 +105,16 @@ export const Select = (props) => {
103
105
  const internalTriggerId = useId();
104
106
  const triggerId = `select-trigger-${internalTriggerId}`;
105
107
  // Locking down searchable count to a single value. Could make this customizable in the future, but would want guardrails.
106
- const searchable = optionsCount > 15;
108
+ // A phone's list is an iOS menu, and a menu has no search: a long list scrolls (iOS-menu IMG_5490, Add Payment's
109
+ // Province, 52 options; the owner 10.11 on a search row in the list), so it opens with no keyboard either. The window
110
+ // decides, as for the list's place: the list is portaled out of any PhoneLayout.
111
+ const phone = usePhoneWindow();
112
+ const searchable = optionsCount > 15 && !phone;
113
+ // An iOS pop-up button has no clear button: its value is unset by a None row, first in the list and in a section of
114
+ // its own, checked while nothing is chosen (Reminders' Early Reminder, iOS-menu IMG_5821). The window decides, as for
115
+ // the search.
116
+ // A custom trigger owns its clearing, so only the default one gives its clear button to the row.
117
+ const noneRow = clearable && phone && !trigger;
107
118
  // A block menu matches its field. An inline one, or one at the end of a Field row, fits its
108
119
  // options: no narrower than its trigger (the CSS fallback reads the trigger width), no wider than 300px.
109
120
  const fitsOptions = (!block || inRow) && props.listWidth === undefined;
@@ -141,6 +152,8 @@ export const Select = (props) => {
141
152
  allSelectedLabel,
142
153
  loading,
143
154
  clearable,
155
+ noneRow,
156
+ noneLabel,
144
157
  variant,
145
158
  pill,
146
159
  size,
@@ -187,6 +200,8 @@ export const Select = (props) => {
187
200
  allSelectedLabel,
188
201
  loading,
189
202
  clearable,
203
+ noneRow,
204
+ noneLabel,
190
205
  variant,
191
206
  pill,
192
207
  size,
@@ -223,7 +238,7 @@ export const Select = (props) => {
223
238
  _jsx(SelectContext.Provider, { value: store, children: _jsx(CustomSelect, {}) }));
224
239
  };
225
240
  export const SelectTrigger = (props) => {
226
- const { triggerId, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, id, required, value, multiple, options, loading, disabled, clearable, name, variant, pill, size, dropdownIconType, placeholder, loadingPlaceholder, block, opticallyAlign, triggerClassName, TriggerStartIcon, TriggerView, onSelectRef, } = useSelectContext();
241
+ const { triggerId, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, id, required, value, multiple, options, loading, disabled, clearable, noneRow, name, variant, pill, size, dropdownIconType, placeholder, loadingPlaceholder, block, opticallyAlign, triggerClassName, TriggerStartIcon, TriggerView, onSelectRef, } = useSelectContext();
227
242
  const { onOpenChange,
228
243
  // pass along props from Radix
229
244
  ...restProps } = props;
@@ -277,7 +292,10 @@ export const SelectTrigger = (props) => {
277
292
  // Ensure open state is closed
278
293
  onOpenChange?.(false);
279
294
  };
280
- return (_jsxs(SelectControl, { id: triggerId, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy ? `${ariaLabelledBy} ${triggerId}-value` : undefined, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, className: triggerClassName, selected: !isPlaceholder, variant: variant, pill: pill, block: block, size: size, disabled: disabled, loading: loading, StartIcon: TriggerStartIcon, opticallyAlign: opticallyAlign, dropdownIconType: dropdownIconType, onClearClick: clearable ? handleClearClick : undefined, onInteract: onOpenChange, interactOnEnter: true, onKeyDown: handleKeyDown, ...restProps, children: [ariaLabelledBy ? (_jsx("span", { id: `${triggerId}-value`, children: multiple ? _jsx(TriggerView, { ...multipleTriggerViewProps }) : _jsx(TriggerView, { ...selectedItem }) })) : multiple ? _jsx(TriggerView, { ...multipleTriggerViewProps }) : _jsx(TriggerView, { ...selectedItem }), (name || id) &&
295
+ return (_jsxs(SelectControl, { id: triggerId, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy ? `${ariaLabelledBy} ${triggerId}-value` : undefined, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, className: triggerClassName, selected: !isPlaceholder, variant: variant, pill: pill, block: block, size: size, disabled: disabled, loading: loading, StartIcon: TriggerStartIcon, opticallyAlign: opticallyAlign, dropdownIconType: dropdownIconType,
296
+ // On a phone the list's None row unsets the value: an iOS pop-up button has no clear button. The mark lets CSS
297
+ // hide it from the first paint, before a server-rendered page knows the window (SelectControl.module.css)
298
+ onClearClick: clearable && !noneRow ? handleClearClick : undefined, "data-select-none-row": clearable ? "" : undefined, onInteract: onOpenChange, interactOnEnter: true, onKeyDown: handleKeyDown, ...restProps, children: [ariaLabelledBy ? (_jsx("span", { id: `${triggerId}-value`, children: multiple ? _jsx(TriggerView, { ...multipleTriggerViewProps }) : _jsx(TriggerView, { ...selectedItem }) })) : multiple ? _jsx(TriggerView, { ...multipleTriggerViewProps }) : _jsx(TriggerView, { ...selectedItem }), (name || id) &&
281
299
  // One input per selected value, so a form submits every value of a
282
300
  // multi-select; an empty one keeps `id` and `required` working
283
301
  (multiple && value.length ? value : [firstValue ?? ""]).map((formValue, index) => (_jsx("input", { id: index === 0 ? id : undefined, name: name, value: formValue,
@@ -305,6 +323,45 @@ const CustomSelect = () => {
305
323
  const selectContentRef = useRef(null);
306
324
  // The trigger element, the default one or a custom `trigger` (which has no `triggerId`)
307
325
  const popoverTriggerRef = useRef(null);
326
+ // Both as state too, for the effects below: the list mounts after the trigger's cover is known
327
+ const [triggerElement, setTriggerElement] = useState(null);
328
+ const setTrigger = useCallback((node) => {
329
+ popoverTriggerRef.current = node;
330
+ setTriggerElement(node);
331
+ }, []);
332
+ const [contentElement, setContentElement] = useState(null);
333
+ const setContent = useCallback((node) => {
334
+ selectContentRef.current = node;
335
+ setContentElement(node);
336
+ }, []);
337
+ // On a phone the list opens over its trigger, as the pop-up menu of an iOS picker does (ref-app pickers, block 8:
338
+ // the 250pt menu stands over the row's value, its end at the chevron's end, the value hidden under it), and toward
339
+ // the larger part of the screen, as Menu does (menuTriggerCover.ts)
340
+ // Only in a phone-wide window, where the list is laid out as on a phone (Select.module.css)
341
+ const [cover, setCover] = useState(null);
342
+ useLayoutEffect(() => {
343
+ if (!open || !triggerElement)
344
+ return;
345
+ return observeMenuTriggerCover(triggerElement, setCover, { windowOnly: true });
346
+ }, [open, triggerElement]);
347
+ // The covered trigger is hidden while the list is open, and shown again as it closes, before focus returns to it
348
+ useLayoutEffect(() => {
349
+ if (!open || !cover || !triggerElement || !contentElement)
350
+ return;
351
+ return markCoveredMenuTrigger(triggerElement, contentElement);
352
+ }, [open, cover, triggerElement, contentElement]);
353
+ // A mouse opens the list as its button goes down, so on a phone the list is under it when the button comes up: that
354
+ // release chooses nothing while it is over the trigger, as in Menu
355
+ useEffect(() => {
356
+ if (!triggerElement)
357
+ return;
358
+ const press = (event) => {
359
+ if (event.button === 0 && isHoverPointer(event))
360
+ ignoreReleaseOverTrigger(triggerElement, event.pointerId);
361
+ };
362
+ triggerElement.addEventListener("pointerdown", press);
363
+ return () => triggerElement.removeEventListener("pointerdown", press);
364
+ }, [triggerElement]);
308
365
  const focusRestoreRef = useRef(null);
309
366
  const focusRestoreTimer = useRef(undefined);
310
367
  useEffect(() => {
@@ -357,8 +414,8 @@ const CustomSelect = () => {
357
414
  return;
358
415
  }
359
416
  handleOpenChange(nextState);
360
- }, modal: false, children: [_jsx(Popover.Trigger, { asChild: true, ref: popoverTriggerRef, children: trigger ? trigger({ open, onToggle: () => { if (!disabled && !loading)
361
- setOpen((current) => !current); } }) : _jsx(SelectTrigger, { onOpenChange: handleOpenChange }) }), _jsx(Popover.Portal, { forceMount: true, children: _jsx(TransitionGroup, { className: s.Menu, ...overlayTiming, overlay: true, children: open && (_jsx(Popover.Content, { ref: selectContentRef, forceMount: true, className: s.MenuList, "data-pill": pill ? "" : undefined, side: side, sideOffset: 5, align: align, alignOffset: alignOffset, avoidCollisions: avoidCollisions, ...floatingBoundary,
417
+ }, modal: false, children: [_jsx(Popover.Trigger, { asChild: true, ref: setTrigger, children: trigger ? trigger({ open, onToggle: () => { if (!disabled && !loading)
418
+ setOpen((current) => !current); } }) : _jsx(SelectTrigger, { onOpenChange: handleOpenChange }) }), _jsx(Popover.Portal, { forceMount: true, children: _jsx(TransitionGroup, { className: s.Menu, ...overlayTiming, overlay: true, children: open && (_jsx(Popover.Content, { ref: setContent, forceMount: true, className: s.MenuList, "data-pill": pill ? "" : undefined, "data-list-width": listWidth === "auto" ? "auto" : undefined, "data-list-sized": typeof listWidth === "number" ? "" : undefined, side: side ?? cover?.side ?? "bottom", sideOffset: cover ? cover.sideOffset : 5, align: align, alignOffset: alignOffset, avoidCollisions: avoidCollisions, ...floatingBoundary,
362
419
  // Prevent Radix auto focus so we can handle our own from within <CustomSelectMenu />
363
420
  onOpenAutoFocus: preventDefaultHandler,
364
421
  // Radix waits until the animation completes before directing focus, which is janky.
@@ -373,7 +430,8 @@ const CustomSelect = () => {
373
430
  }, onEscapeKeyDown: preventDefaultHandler, style: toCssVariables({
374
431
  "select-list-width": listWidth,
375
432
  "select-list-min-width": listMinWidth,
376
- "select-list-max-width": listMaxWidth,
433
+ // "auto" is no maximum: the variable is left out, so a phone's 250pt floor can read the cap
434
+ "select-list-max-width": listMaxWidth === "auto" ? undefined : listMaxWidth,
377
435
  }), children: _jsx(CustomSelectMenu, { onOpenChange: handleOpenChange }) }, "dropdown")) }) })] }));
378
436
  };
379
437
  const CustomSelectMenuContext = createContext(null);
@@ -385,13 +443,16 @@ const useCustomSelectMenuContext = () => {
385
443
  return context;
386
444
  };
387
445
  const CustomSelectMenu = ({ onOpenChange }) => {
388
- const { multiple, value, options, searchable, searchPredicateRef, listWidth } = useSelectContext();
446
+ const { multiple, value, options, searchable, searchPredicateRef, listWidth, noneRow } = useSelectContext();
389
447
  const requestCloseRef = useRef(() => onOpenChange(false));
390
448
  const menuRef = useRef(null);
391
449
  const listRef = useRef(null);
392
450
  const searchInputRef = useRef(null);
393
451
  const [searchTerm, setSearchTerm] = useState("");
394
452
  const [highlightedValue, setHighlightedValue] = useState(() => {
453
+ // With nothing chosen, the None row is the checked one
454
+ if (noneRow && !hasChosenOption(options, value))
455
+ return NONE_OPTION_VALUE;
395
456
  const selectedValue = multiple ? value[0] : value;
396
457
  return (selectedValue || getFirstValidOption(options)?.value) ?? "";
397
458
  });
@@ -402,7 +463,9 @@ const CustomSelectMenu = ({ onOpenChange }) => {
402
463
  // MultiSelect reads its live selection instead of this per-open snapshot.
403
464
  const [openingValue] = useState(() => multiple ? "" : value);
404
465
  // Trim and lowercase search value
405
- const literalSearchTerm = useMemo(() => searchTerm.trim().toLocaleLowerCase(), [searchTerm]);
466
+ // A term counts only while the list has its search: one typed on a desktop is dropped when the window narrows to a
467
+ // phone, whose list has none
468
+ const literalSearchTerm = useMemo(() => (searchable ? searchTerm.trim().toLocaleLowerCase() : ""), [searchable, searchTerm]);
406
469
  const filteredOptions = useMemo(() => filterOptions(options, literalSearchTerm, searchPredicateRef.current), [options, literalSearchTerm, searchPredicateRef]);
407
470
  const firstOption = useMemo(() => getFirstValidOption(filteredOptions), [filteredOptions]);
408
471
  const shownValuesRef = useRef(optionValues(filteredOptions));
@@ -439,6 +502,12 @@ const CustomSelectMenu = ({ onOpenChange }) => {
439
502
  return;
440
503
  }
441
504
  }
505
+ // Without a value the None row is the checked one
506
+ const noneElement = noneRow && !hasChosenOption(options, value) ? findOptionByValue(NONE_OPTION_VALUE, menuElement) : null;
507
+ if (noneElement) {
508
+ highlightOption(NONE_OPTION_VALUE, noneElement);
509
+ return;
510
+ }
442
511
  // If value isn't set, or the selected node wasn't found in the DOM,
443
512
  // attempt to move focus to the first valid option.
444
513
  const firstValidOption = getFirstValidOption(options);
@@ -562,6 +631,25 @@ const CustomSelectMenu = ({ onOpenChange }) => {
562
631
  };
563
632
  // eslint-disable-next-line react-hooks/exhaustive-deps -- Intentionally an onMount effect
564
633
  }, []);
634
+ // The window crossed the phone's width while the list was open: the search came or went (a phone's list has none),
635
+ // so its term is cleared and focus moves to what holds the keys now, the search or the list
636
+ const wasSearchableRef = useRef(searchable);
637
+ useLayoutEffect(() => {
638
+ if (wasSearchableRef.current === searchable)
639
+ return;
640
+ wasSearchableRef.current = searchable;
641
+ if (!searchable)
642
+ setSearchTerm("");
643
+ // The width a desktop list locked for its search would overflow a phone's 250px panel; a desktop locks it again
644
+ if (menuRef.current) {
645
+ menuRef.current.style.minWidth = "";
646
+ if (searchable && listWidth === "auto")
647
+ menuRef.current.style.minWidth = `${menuRef.current.offsetWidth}px`;
648
+ }
649
+ if (menuRef.current?.contains(document.activeElement) && document.activeElement !== listRef.current)
650
+ return;
651
+ (searchable ? searchInputRef.current : listRef.current)?.focus({ preventScroll: true });
652
+ }, [searchable]);
565
653
  // A long list has a search field: the menu keeps the width of all its options as the results narrow.
566
654
  useLayoutEffect(() => {
567
655
  if (searchable && listWidth === "auto" && menuRef.current) {
@@ -590,11 +678,30 @@ const CustomSelectMenu = ({ onOpenChange }) => {
590
678
  shownValuesRef.current = nextValues;
591
679
  // Reset scroll position to the top
592
680
  listRef.current.scrollTop = 0;
593
- // Highlight first item in the list
681
+ // Highlight first item in the list, or the None row while nothing is chosen
594
682
  const maybeFirstOption = getFirstValidOption(filteredOptions);
595
- if (maybeFirstOption)
683
+ if (noneRow && !hasChosenOption(options, value))
684
+ setHighlightedValue(NONE_OPTION_VALUE);
685
+ else if (maybeFirstOption)
596
686
  setHighlightedValue(maybeFirstOption.value);
687
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- Intentionally a reaction to the shown options
597
688
  }, [filteredOptions]);
689
+ // The window crossed the phone's width while the list was open: the None row came or went. With nothing chosen the
690
+ // highlight moves to it; when it goes, a highlight on it moves to the chosen option or the first one.
691
+ const hadNoneRowRef = useRef(noneRow);
692
+ useLayoutEffect(() => {
693
+ if (hadNoneRowRef.current === noneRow)
694
+ return;
695
+ hadNoneRowRef.current = noneRow;
696
+ if (noneRow) {
697
+ if (!hasChosenOption(options, value))
698
+ setHighlightedValue(NONE_OPTION_VALUE);
699
+ return;
700
+ }
701
+ const selectedValue = multiple ? value[0] : value;
702
+ setHighlightedValue((current) => current === NONE_OPTION_VALUE ? ((selectedValue || getFirstValidOption(filteredOptions)?.value) ?? "") : current);
703
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- Intentionally a reaction to the row coming or going
704
+ }, [noneRow]);
598
705
  // The focused element (the search input, or the list without one) points
599
706
  // assistive tech at the highlighted option, when that option is rendered
600
707
  useLayoutEffect(() => {
@@ -602,6 +709,9 @@ const CustomSelectMenu = ({ onOpenChange }) => {
602
709
  if (!target || !menuRef.current) {
603
710
  return;
604
711
  }
712
+ // A list that gave the keys to a search that came with a wider window points at nothing itself
713
+ if (target !== listRef.current)
714
+ listRef.current?.removeAttribute("aria-activedescendant");
605
715
  const highlightedOption = highlightedValue ? findOptionByValue(highlightedValue, menuRef.current) : null;
606
716
  if (highlightedOption?.id) {
607
717
  target.setAttribute("aria-activedescendant", highlightedOption.id);
@@ -609,11 +719,12 @@ const CustomSelectMenu = ({ onOpenChange }) => {
609
719
  else {
610
720
  target.removeAttribute("aria-activedescendant");
611
721
  }
612
- }, [highlightedValue, filteredOptions]);
722
+ // The search coming or going moves the keys, so the pointer follows them, and the None row coming or going
723
+ }, [highlightedValue, filteredOptions, searchable, noneRow]);
613
724
  return (_jsx(CustomSelectMenuContext, { value: store, children: _jsxs("div", { className: s.MenuInner, onKeyDown: handleKeyDown, ref: menuRef,
614
725
  // Without search, the list takes focus (and the tab stop); the container
615
726
  // stays focusable so a click on it keeps the keys here
616
- tabIndex: !searchable && filteredOptions.length ? -1 : 0, children: [searchable && (_jsx(CustomSelectSearch, { value: searchTerm, onChange: setSearchTerm, hasResults: !!filteredOptions.length })), _jsx(CustomSelectList, { filteredOptions: filteredOptions }), _jsx(CustomSelectActions, {})] }) }));
727
+ tabIndex: !searchable && (filteredOptions.length || noneRow) ? -1 : 0, children: [searchable && (_jsx(CustomSelectSearch, { value: searchTerm, onChange: setSearchTerm, hasResults: !!filteredOptions.length })), _jsx(CustomSelectList, { filteredOptions: filteredOptions }), _jsx(CustomSelectActions, {})] }) }));
617
728
  };
618
729
  const CustomSelectSearch = ({ value, onChange, hasResults }) => {
619
730
  const { searchPlaceholder, searchAriaLabel, searchSize } = useSelectContext();
@@ -634,22 +745,25 @@ const optionValues = (options) => (isOptionGroupArray(options) ? options.flatMap
634
745
  .join("\n");
635
746
  const HARD_OPTIONS_LIMIT = 300;
636
747
  const CustomSelectList = ({ filteredOptions, }) => {
637
- const { searchEmptyMessage, multiple, searchable, triggerId, trigger, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, } = useSelectContext();
748
+ const { searchEmptyMessage, multiple, searchable, noneRow, noneLabel, triggerId, trigger, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, } = useSelectContext();
638
749
  const { listId, listRef } = useCustomSelectMenuContext();
639
- if (!filteredOptions.length) {
750
+ // A phone's None row still unsets a value when there are no options to show
751
+ if (!filteredOptions.length && !noneRow) {
640
752
  return typeof searchEmptyMessage === "string" ? (_jsx("p", { className: s.SearchEmpty, "data-text-only": true, children: searchEmptyMessage })) : (_jsx("div", { className: s.SearchEmpty, children: searchEmptyMessage }));
641
753
  }
642
- // We hard limit within groups, so at this level we will only limit flat arrays
754
+ // We hard limit within groups, so at this level we will only limit flat arrays. The limit asks to search for the
755
+ // rest, so a list with no search (a phone's) shows every option, as a long iOS menu scrolls (IMG_5490).
643
756
  const isGrouped = isOptionGroupArray(filteredOptions);
644
- const hasHardLimit = !isGrouped && filteredOptions.length > HARD_OPTIONS_LIMIT;
757
+ const hardLimit = searchable ? HARD_OPTIONS_LIMIT : Infinity;
758
+ const hasHardLimit = !isGrouped && filteredOptions.length > hardLimit;
645
759
  const options = isGrouped
646
760
  ? filteredOptions.map((group) => _jsx(CustomSelectGroup, { ...group }, group.label))
647
761
  : filteredOptions
648
- .slice(0, HARD_OPTIONS_LIMIT)
762
+ .slice(0, hardLimit)
649
763
  .map((option) => _jsx(CustomSelectOption, { ...option }, option.value));
650
764
  return (_jsxs("div", { id: listId, className: s.OptionsList, ref: listRef, role: "listbox", "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy ?? (ariaLabel || trigger ? undefined : triggerId), "aria-multiselectable": multiple || undefined,
651
765
  // Without search, the list is the focused element
652
- tabIndex: searchable ? undefined : 0, children: [options, hasHardLimit && (_jsx(CustomSelectHardLimit, { numHidden: filteredOptions.length - HARD_OPTIONS_LIMIT }))] }));
766
+ tabIndex: searchable ? undefined : 0, children: [noneRow && (_jsx("div", { className: s.NoneSection, role: "none", children: _jsx(CustomSelectOption, { value: NONE_OPTION_VALUE, label: noneLabel, none: true }) })), options, hasHardLimit && (_jsx(CustomSelectHardLimit, { numHidden: filteredOptions.length - HARD_OPTIONS_LIMIT }))] }));
653
767
  };
654
768
  const DEFAULT_OPTIONS_LIMIT = {
655
769
  limit: 100,
@@ -659,9 +773,11 @@ const CustomSelectGroup = ({ label, options, optionsLimit = DEFAULT_OPTIONS_LIMI
659
773
  const groupId = useId();
660
774
  const headingId = useId();
661
775
  const { searchTerm, setHighlightedValue } = useCustomSelectMenuContext();
776
+ const { searchable } = useSelectContext();
662
777
  const [limitExpanded, setLimitExpanded] = useState(false);
663
778
  const hasExpandableLimit = optionsLimit.limit < options.length && !searchTerm && !limitExpanded;
664
- const hasHardLimit = HARD_OPTIONS_LIMIT < options.length && !hasExpandableLimit;
779
+ // The hard limit asks to search for the rest: a list with no search (a phone's) shows the whole group once expanded
780
+ const hasHardLimit = searchable && HARD_OPTIONS_LIMIT < options.length && !hasExpandableLimit;
665
781
  let maybeLimitedOptions = options;
666
782
  if (hasExpandableLimit) {
667
783
  maybeLimitedOptions = options.slice(0, optionsLimit.limit);
@@ -726,18 +842,30 @@ const CustomSelectExpandableLimit = ({ value, label, onPointerUp, }) => {
726
842
  role: "option", "aria-selected": false, ...press, onPointerMove: handlePointerMove, onPointerLeave: handlePointerLeave, children: _jsxs("div", { className: clsx(s.PressableInner, s.OptionInner), children: [checkPosition === 'start' && _jsx("div", { className: s.OptionIndicatorSlot }), label] }) }));
727
843
  };
728
844
  const INTERNAL_DOM_SELECTION_DATA_ATTR = "data-option-id";
729
- const CustomSelectOption = (option) => {
730
- const { optionClassName, OptionView, value: propsValue, multiple, onSelectRef, checkPosition, } = useSelectContext();
845
+ // The None row's id among the options: it never reaches `onChange`, which gets an empty value instead
846
+ const NONE_OPTION_VALUE = "plexui-select-none";
847
+ const CustomSelectOption = ({ none = false, ...option }) => {
848
+ const { optionClassName, OptionView, value: propsValue, options, multiple, onSelectRef, checkPosition, } = useSelectContext();
731
849
  const { openingValue, requestCloseRef, highlightedValue, setHighlightedValue } = useCustomSelectMenuContext();
732
850
  const { value, disabled, tooltip } = option;
733
851
  // Referenced by the list's aria-activedescendant while highlighted
734
852
  const optionId = useId();
735
853
  // NOTE: SingleSelect mode keeps the opening value instead of the live `propsValue`
736
854
  // to avoid selecting the item as the select closes.
737
- const isSelected = multiple ? propsValue.includes(value) : value === openingValue;
855
+ // The None row is checked while nothing is chosen: no value, or none that an option has (the trigger shows the
856
+ // placeholder then)
857
+ const isSelected = none
858
+ ? !hasChosenOption(options, multiple ? propsValue : openingValue)
859
+ : multiple ? propsValue.includes(value) : value === openingValue;
738
860
  const isHighlighted = value === highlightedValue;
739
861
  const handlePointerUp = () => {
740
- if (multiple) {
862
+ if (none) {
863
+ // Unsets the value, as the clear button does, and closes the list, a multiple one too: an iOS menu closes on a
864
+ // choice, and None leaves nothing more to choose (owner 10.11)
865
+ onSelectRef.current({ value: "", label: "" });
866
+ requestCloseRef.current?.();
867
+ }
868
+ else if (multiple) {
741
869
  // Trigger the change ref, optionally as a remove
742
870
  onSelectRef.current(option, isSelected);
743
871
  }
@@ -769,7 +897,7 @@ const CustomSelectOption = (option) => {
769
897
  return (_jsx("div", { id: optionId, className: clsx(s.Option, optionClassName), "data-highlight": isHighlighted ? "" : undefined, role: "option", "aria-selected": isSelected, "data-selected": isSelected ? "" : undefined, [INTERNAL_DOM_SELECTION_DATA_ATTR]: value, ...(disabled ? {} : press),
770
898
  // Pointer move allows us to prevent contention from keyboard presses and a still mouse
771
899
  // which does trigger events like onMouseEnter, creating weird battles with mouse and keyboard focus.
772
- onPointerMove: disabled ? undefined : handlePointerMove, onPointerLeave: disabled ? undefined : handlePointerLeave, "aria-disabled": disabled, "data-disabled": disabled ? "" : undefined, children: _jsxs("div", { className: s.PressableInner, children: [checkPosition === 'start' && (_jsx("div", { className: s.OptionIndicatorSlot, "data-position": "start", children: isSelected && _jsx(Check, { className: s.OptionCheck }) })), _jsxs("div", { className: s.OptionLeading, children: [_jsxs("div", { className: s.OptionInner, children: [_jsx(OptionView, { ...option }), tooltip && (_jsx(Tooltip, { content: tooltip.content, maxWidth: tooltip.maxWidth, side: "right", children: _jsx(Info, {}) }))] }), option.description && (_jsx("div", { className: clsx(s.OptionInner, s.OptionDescription), children: option.description }))] }), checkPosition === 'end' && (_jsx("div", { className: s.OptionIndicatorSlot, "data-position": "end", children: isSelected && _jsx(Check, { className: s.OptionCheck }) }))] }) }));
900
+ onPointerMove: disabled ? undefined : handlePointerMove, onPointerLeave: disabled ? undefined : handlePointerLeave, "aria-disabled": disabled, "data-disabled": disabled ? "" : undefined, children: _jsxs("div", { className: s.PressableInner, children: [checkPosition === 'start' && (_jsx("div", { className: s.OptionIndicatorSlot, "data-position": "start", children: isSelected && _jsx(Check, { className: s.OptionCheck }) })), _jsxs("div", { className: s.OptionLeading, children: [_jsxs("div", { className: s.OptionInner, children: [none ? option.label : _jsx(OptionView, { ...option }), tooltip && (_jsx(Tooltip, { content: tooltip.content, maxWidth: tooltip.maxWidth, side: "right", children: _jsx(Info, { className: s.OptionTooltipIcon }) }))] }), option.description && (_jsx("div", { className: clsx(s.OptionInner, s.OptionDescription), children: option.description })), tooltip && (_jsx("div", { className: clsx(s.OptionInner, s.OptionTooltipText), children: tooltip.content }))] }), checkPosition === 'end' && (_jsx("div", { className: s.OptionIndicatorSlot, "data-position": "end", children: isSelected && _jsx(Check, { className: s.OptionCheck }) }))] }) }));
773
901
  };
774
902
  const CustomSelectActions = () => {
775
903
  const { actions } = useSelectContext();
@@ -880,6 +1008,8 @@ const getOptionByValue = (options, value) => {
880
1008
  }
881
1009
  return found;
882
1010
  };
1011
+ // Whether a value names an option: a value no option has shows the placeholder, as no value does
1012
+ const hasChosenOption = (options, value) => Array.isArray(value) ? getOptionsByValues(options, value).length > 0 : !!getOptionByValue(options, value);
883
1013
  const getOptionsByValues = (options, values) => {
884
1014
  let found = [];
885
1015
  const lookup = new Set(values);