@ankhorage/zora 28.5.3 → 28.6.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 (71) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -1
  3. package/dist/capabilities/index.js +73 -3
  4. package/dist/capabilities/index.js.map +3 -3
  5. package/dist/features/form/select/adapters/inbound/Select.native.d.ts.map +1 -1
  6. package/dist/features/form/select/adapters/inbound/Select.native.js +71 -8
  7. package/dist/features/form/select/adapters/inbound/Select.native.js.map +1 -1
  8. package/dist/features/form/select/adapters/inbound/Select.web.d.ts.map +1 -1
  9. package/dist/features/form/select/adapters/inbound/Select.web.js +5 -3
  10. package/dist/features/form/select/adapters/inbound/Select.web.js.map +1 -1
  11. package/dist/features/form/select/composition/SelectSearchInput.d.ts +10 -0
  12. package/dist/features/form/select/composition/SelectSearchInput.d.ts.map +1 -0
  13. package/dist/features/form/select/composition/SelectSearchInput.js +11 -0
  14. package/dist/features/form/select/composition/SelectSearchInput.js.map +1 -0
  15. package/dist/features/form/select/composition/getVisibleSelectOptions.d.ts +4 -0
  16. package/dist/features/form/select/composition/getVisibleSelectOptions.d.ts.map +1 -0
  17. package/dist/features/form/select/composition/getVisibleSelectOptions.js +8 -0
  18. package/dist/features/form/select/composition/getVisibleSelectOptions.js.map +1 -0
  19. package/dist/features/form/select/composition/useSelectController.d.ts +3 -0
  20. package/dist/features/form/select/composition/useSelectController.d.ts.map +1 -1
  21. package/dist/features/form/select/composition/useSelectController.js +11 -2
  22. package/dist/features/form/select/composition/useSelectController.js.map +1 -1
  23. package/dist/features/form/select/selectMeta.d.ts +99 -1
  24. package/dist/features/form/select/selectMeta.d.ts.map +1 -1
  25. package/dist/features/form/select/selectMeta.js +71 -1
  26. package/dist/features/form/select/selectMeta.js.map +1 -1
  27. package/dist/features/registry/bindableComponentMeta.d.ts +79 -1
  28. package/dist/features/registry/bindableComponentMeta.d.ts.map +1 -1
  29. package/dist/features/registry/bindableComponentMeta.js +59 -1
  30. package/dist/features/registry/bindableComponentMeta.js.map +1 -1
  31. package/dist/types/select.d.ts +10 -0
  32. package/dist/types/select.d.ts.map +1 -1
  33. package/dist/types/select.js.map +1 -1
  34. package/package.json +27 -1
  35. package/src/features/form/select/adapters/inbound/Select.native.test.tsx +322 -0
  36. package/src/features/form/select/adapters/inbound/Select.native.tsx +135 -13
  37. package/src/features/form/select/adapters/inbound/Select.web.tsx +6 -3
  38. package/src/features/form/select/composition/SelectSearchInput.tsx +33 -0
  39. package/src/features/form/select/composition/getVisibleSelectOptions.test.ts +22 -0
  40. package/src/features/form/select/composition/getVisibleSelectOptions.ts +13 -0
  41. package/src/features/form/select/composition/useSelectController.ts +25 -2
  42. package/src/features/form/select/public.test.ts +31 -1
  43. package/src/features/form/select/selectMeta.ts +71 -1
  44. package/src/features/registry/bindableComponentMeta.test.ts +6 -0
  45. package/src/features/registry/bindableComponentMeta.ts +59 -1
  46. package/src/features/registry/featureManifest.test.ts +10 -0
  47. package/src/types/select.ts +10 -0
  48. package/web-dist/chunks/{Accordion-sj1n06dw.js → Accordion-9dk62zn9.js} +84 -24
  49. package/web-dist/chunks/Accordion-ar8qe05j.js +53 -0
  50. package/web-dist/chunks/{Accordion-ge7cjtwy.js → Accordion-mpb070cf.js} +3 -3
  51. package/web-dist/chunks/{Accordion-554f42yj.js → Accordion-sj30964p.js} +4 -4
  52. package/web-dist/chunks/{Accordion-2bygfpwg.js → Accordion-xhxv2v0g.js} +62 -2
  53. package/web-dist/chunks/{RichTextClient-70qt7037.js → RichTextClient-7qqj2dpw.js} +3 -4
  54. package/web-dist/components/auth-screen/AuthScreen.js +2 -3
  55. package/web-dist/components/color-hue-scale/ColorHueScale.js +4 -3
  56. package/web-dist/components/color-picker/ColorPicker.js +4 -3
  57. package/web-dist/components/color-tone/ColorTone.js +4 -3
  58. package/web-dist/components/color-wheel/ColorWheel.js +4 -3
  59. package/web-dist/components/forgot-password-form/ForgotPasswordForm.js +2 -3
  60. package/web-dist/components/o-auth-provider-button/OAuthProviderButton.js +2 -3
  61. package/web-dist/components/o-auth-provider-list/OAuthProviderList.js +2 -3
  62. package/web-dist/components/otp-form/OtpForm.js +2 -3
  63. package/web-dist/components/rich-text/RichText.js +2 -2
  64. package/web-dist/components/search-input/SearchInput.js +5 -52
  65. package/web-dist/components/select/Select.js +3 -1
  66. package/web-dist/components/select/Select.types-0.d.ts +10 -0
  67. package/web-dist/components/sign-in-form/SignInForm.js +2 -3
  68. package/web-dist/components/sign-up-form/SignUpForm.js +2 -3
  69. package/web-dist/components/text-input/TextInput.js +4 -5
  70. package/web-dist/manifest.json +39 -41
  71. package/web-dist/chunks/Accordion-49d0frg7.js +0 -66
@@ -1 +1 @@
1
- {"version":3,"file":"Select.native.d.ts","sourceRoot":"","sources":["../../../../../../src/features/form/select/adapters/inbound/Select.native.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,KAAK,EAAgB,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAU7E,iFAAiF;AACjF,eAAO,MAAM,MAAM,GAGE,MAAM,SAAS,MAAM,mEAHW,CAAC"}
1
+ {"version":3,"file":"Select.native.d.ts","sourceRoot":"","sources":["../../../../../../src/features/form/select/adapters/inbound/Select.native.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,KAAK,EAAgB,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAW7E,iFAAiF;AACjF,eAAO,MAAM,MAAM,GAGE,MAAM,SAAS,MAAM,mEAHW,CAAC"}
@@ -4,6 +4,7 @@ import { BottomSheetFlatList, useBottomSheet } from '../../../../bottom-sheet/pu
4
4
  import { withZoraThemeScope } from '../../../../theme/adapters/inbound/withZoraThemeScope';
5
5
  import { SelectField } from '../../composition/SelectField';
6
6
  import { SelectOptionRow } from '../../composition/SelectOptionRow';
7
+ import { SelectSearchInput } from '../../composition/SelectSearchInput';
7
8
  import { SelectTrigger } from '../../composition/SelectTrigger';
8
9
  import { useSelectController } from '../../composition/useSelectController';
9
10
  const SELECT_SHEET_MAX_HEIGHT = 480;
@@ -12,28 +13,90 @@ export const Select = withZoraThemeScope(SelectInner);
12
13
  /*** Connects shared Select state and controls to the native BottomSheet host. */
13
14
  function SelectInner({ themeId: _themeId, mode: _mode, ...props }) {
14
15
  const { dismiss, present } = useBottomSheet();
15
- const { select, selectedOption, value } = useSelectController(props);
16
+ const [open, setOpen] = React.useState(false);
17
+ const ownsSheet = React.useRef(false);
18
+ const sheetRequestId = React.useRef(0);
19
+ const sheetId = React.useId();
20
+ const { search, searchValue, select, selectedOption, value, visibleOptions } = useSelectController(props);
16
21
  const passive = props.interactionPolicy === 'passive';
17
- const { disabled, interactionPolicy, options, readOnly, testID } = props;
18
- const listData = React.useMemo(() => [...options], [options]);
22
+ const { disabled, interactionPolicy, readOnly, testID } = props;
23
+ const listData = React.useMemo(() => [...visibleOptions], [visibleOptions]);
24
+ const releaseSheet = React.useCallback(() => {
25
+ ownsSheet.current = false;
26
+ setOpen(false);
27
+ }, []);
28
+ const isCurrentSheetRequest = React.useCallback((requestId) => sheetRequestId.current === requestId, []);
29
+ const claimSheet = React.useCallback((requestId) => {
30
+ if (isCurrentSheetRequest(requestId))
31
+ ownsSheet.current = true;
32
+ }, [isCurrentSheetRequest]);
33
+ const releaseSheetOwnership = React.useCallback((requestId) => {
34
+ if (isCurrentSheetRequest(requestId))
35
+ ownsSheet.current = false;
36
+ }, [isCurrentSheetRequest]);
19
37
  const handleSelect = React.useCallback((nextValue) => {
20
38
  select(nextValue);
39
+ releaseSheet();
21
40
  dismiss();
22
- }, [dismiss, select]);
41
+ }, [dismiss, releaseSheet, select]);
23
42
  const renderOption = React.useCallback(({ item }) => (<SelectOptionRow interactionPolicy={interactionPolicy} onSelect={handleSelect} option={item} selected={value === item.value} testID={testID}/>), [handleSelect, interactionPolicy, testID, value]);
24
- const openSelect = React.useCallback(() => {
25
- if (disabled || readOnly || passive)
43
+ React.useEffect(() => {
44
+ if (!open || !ownsSheet.current)
26
45
  return;
46
+ ownsSheet.current = true;
47
+ const requestId = sheetRequestId.current + 1;
48
+ sheetRequestId.current = requestId;
27
49
  present({
28
50
  contentMode: 'direct',
29
51
  maxDynamicContentSize: SELECT_SHEET_MAX_HEIGHT,
30
- content: (<BottomSheetFlatList contentContainerStyle={styles.listContent} data={listData} keyExtractor={(item) => item.value} renderItem={renderOption}/>),
52
+ content: (<SelectSheetContent key={sheetId} onClaim={claimSheet} listData={listData} isCurrentRequest={isCurrentSheetRequest} onRelease={releaseSheet} onReleaseOwnership={releaseSheetOwnership} props={props} renderOption={renderOption} requestId={requestId} search={search} searchValue={searchValue}/>),
53
+ onDismiss: releaseSheet,
31
54
  });
32
- }, [disabled, listData, passive, present, readOnly, renderOption]);
55
+ }, [
56
+ claimSheet,
57
+ isCurrentSheetRequest,
58
+ listData,
59
+ open,
60
+ present,
61
+ props,
62
+ releaseSheet,
63
+ releaseSheetOwnership,
64
+ renderOption,
65
+ search,
66
+ searchValue,
67
+ sheetId,
68
+ ]);
69
+ React.useEffect(() => () => {
70
+ if (ownsSheet.current)
71
+ dismiss();
72
+ }, [dismiss]);
73
+ const openSelect = React.useCallback(() => {
74
+ if (disabled || readOnly || passive)
75
+ return;
76
+ ownsSheet.current = true;
77
+ setOpen(true);
78
+ }, [disabled, passive, readOnly]);
33
79
  return (<SelectField props={props}>
34
80
  <SelectTrigger displayLabel={selectedOption?.label} leadingMedia={selectedOption?.leadingMedia} onPress={openSelect} props={props}/>
35
81
  </SelectField>);
36
82
  }
83
+ /*** Renders and releases the Select-owned sheet content when another request replaces it. */
84
+ function SelectSheetContent({ isCurrentRequest, listData, onClaim, onRelease, onReleaseOwnership, props, renderOption, requestId, search, searchValue, }) {
85
+ const mounted = React.useRef(false);
86
+ React.useEffect(() => {
87
+ mounted.current = true;
88
+ onClaim(requestId);
89
+ return () => {
90
+ mounted.current = false;
91
+ onReleaseOwnership(requestId);
92
+ void Promise.resolve().then(() => {
93
+ if (!mounted.current && isCurrentRequest(requestId))
94
+ onRelease();
95
+ });
96
+ };
97
+ }, [isCurrentRequest, onClaim, onRelease, onReleaseOwnership, requestId]);
98
+ return (<BottomSheetFlatList contentContainerStyle={styles.listContent} data={listData} keyExtractor={(item) => item.value} ListHeaderComponent={<SelectSearchInput onSearchChange={search} props={props} searchValue={searchValue}/>} renderItem={renderOption}/>);
99
+ }
37
100
  const styles = StyleSheet.create({
38
101
  listContent: {
39
102
  padding: 16,
@@ -1 +1 @@
1
- {"version":3,"file":"Select.native.js","sourceRoot":"","sources":["../../../../../../src/features/form/select/adapters/inbound/Select.native.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAA2B,UAAU,EAAE,MAAM,cAAc,CAAC;AAGnE,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uDAAuD,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAE5E,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAEpC,iFAAiF;AACjF,MAAM,CAAC,MAAM,MAAM,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC;AAEtD,iFAAiF;AACjF,SAAS,WAAW,CAAiC,EACnD,OAAO,EAAE,QAAQ,EACjB,IAAI,EAAE,KAAK,EACX,GAAG,KAAK,EACY;IACpB,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,cAAc,EAAE,CAAC;IAC9C,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,GAAG,mBAAmB,CAAC,KAAK,CAAC,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,CAAC,IAA0B,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CACzD,UAAU,CAAC,CAAC,YAAY,CAAC,EACzB,CACH;SACF,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC;IAEnE,OAAO,CACL,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CACxB;MAAA,CAAC,aAAa,CACZ,YAAY,CAAC,CAAC,cAAc,EAAE,KAAK,CAAC,CACpC,YAAY,CAAC,CAAC,cAAc,EAAE,YAAY,CAAC,CAC3C,OAAO,CAAC,CAAC,UAAU,CAAC,CACpB,KAAK,CAAC,CAAC,KAAK,CAAC,EAEjB;IAAA,EAAE,WAAW,CAAC,CACf,CAAC;AACJ,CAAC;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,WAAW,EAAE;QACX,OAAO,EAAE,EAAE;KACZ;CACF,CAAC,CAAC","sourcesContent":["import React from 'react';\nimport { type ListRenderItemInfo, StyleSheet } from 'react-native';\n\nimport type { SelectOption, SelectProps } from '../../../../../types/select';\nimport { BottomSheetFlatList, useBottomSheet } from '../../../../bottom-sheet/public';\nimport { withZoraThemeScope } from '../../../../theme/adapters/inbound/withZoraThemeScope';\nimport { SelectField } from '../../composition/SelectField';\nimport { SelectOptionRow } from '../../composition/SelectOptionRow';\nimport { SelectTrigger } from '../../composition/SelectTrigger';\nimport { useSelectController } from '../../composition/useSelectController';\n\nconst SELECT_SHEET_MAX_HEIGHT = 480;\n\n/*** Renders Select with BottomSheetFlatList presentation on native platforms. */\nexport const Select = withZoraThemeScope(SelectInner);\n\n/*** Connects shared Select state and controls to the native BottomSheet host. */\nfunction SelectInner<TValue extends string = string>({\n themeId: _themeId,\n mode: _mode,\n ...props\n}: SelectProps<TValue>) {\n const { dismiss, present } = useBottomSheet();\n const { select, selectedOption, value } = useSelectController(props);\n const passive = props.interactionPolicy === 'passive';\n const { disabled, interactionPolicy, options, readOnly, testID } = props;\n const listData = React.useMemo(() => [...options], [options]);\n\n const handleSelect = React.useCallback(\n (nextValue: TValue) => {\n select(nextValue);\n dismiss();\n },\n [dismiss, select],\n );\n\n const renderOption = React.useCallback(\n ({ item }: ListRenderItemInfo<SelectOption<TValue>>) => (\n <SelectOptionRow\n interactionPolicy={interactionPolicy}\n onSelect={handleSelect}\n option={item}\n selected={value === item.value}\n testID={testID}\n />\n ),\n [handleSelect, interactionPolicy, testID, value],\n );\n\n const openSelect = React.useCallback(() => {\n if (disabled || readOnly || passive) return;\n\n present({\n contentMode: 'direct',\n maxDynamicContentSize: SELECT_SHEET_MAX_HEIGHT,\n content: (\n <BottomSheetFlatList\n contentContainerStyle={styles.listContent}\n data={listData}\n keyExtractor={(item: SelectOption<TValue>) => item.value}\n renderItem={renderOption}\n />\n ),\n });\n }, [disabled, listData, passive, present, readOnly, renderOption]);\n\n return (\n <SelectField props={props}>\n <SelectTrigger\n displayLabel={selectedOption?.label}\n leadingMedia={selectedOption?.leadingMedia}\n onPress={openSelect}\n props={props}\n />\n </SelectField>\n );\n}\n\nconst styles = StyleSheet.create({\n listContent: {\n padding: 16,\n },\n});\n"]}
1
+ {"version":3,"file":"Select.native.js","sourceRoot":"","sources":["../../../../../../src/features/form/select/adapters/inbound/Select.native.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAA2B,UAAU,EAAE,MAAM,cAAc,CAAC;AAGnE,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uDAAuD,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,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AAkB,EAAE,SAAS,CAAC,CAAC,CAAC;IAE1E,OAAO,CACL,CAAC,mBAAmB,CAClB,qBAAqB,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAC1C,IAAI,CAAC,CAAC,QAAQ,CAAC,CACf,YAAY,CAAC,CAAC,CAAC,IAA0B,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CACzD,mBAAmB,CAAC,CAClB,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC,EACpF,CAAC,CACD,UAAU,CAAC,CAAC,YAAY,CAAC,EACzB,CACH,CAAC;AACJ,CAAC;AAeD,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,WAAW,EAAE;QACX,OAAO,EAAE,EAAE;KACZ;CACF,CAAC,CAAC","sourcesContent":["import React from 'react';\nimport { type ListRenderItemInfo, StyleSheet } from 'react-native';\n\nimport type { SelectOption, SelectProps } from '../../../../../types/select';\nimport { BottomSheetFlatList, useBottomSheet } from '../../../../bottom-sheet/public';\nimport { withZoraThemeScope } from '../../../../theme/adapters/inbound/withZoraThemeScope';\nimport { SelectField } from '../../composition/SelectField';\nimport { SelectOptionRow } from '../../composition/SelectOptionRow';\nimport { SelectSearchInput } from '../../composition/SelectSearchInput';\nimport { SelectTrigger } from '../../composition/SelectTrigger';\nimport { useSelectController } from '../../composition/useSelectController';\n\nconst SELECT_SHEET_MAX_HEIGHT = 480;\n\n/*** Renders Select with BottomSheetFlatList presentation on native platforms. */\nexport const Select = withZoraThemeScope(SelectInner);\n\n/*** Connects shared Select state and controls to the native BottomSheet host. */\nfunction SelectInner<TValue extends string = string>({\n themeId: _themeId,\n mode: _mode,\n ...props\n}: SelectProps<TValue>) {\n const { dismiss, present } = useBottomSheet();\n const [open, setOpen] = React.useState(false);\n const ownsSheet = React.useRef(false);\n const sheetRequestId = React.useRef(0);\n const sheetId = React.useId();\n const { search, searchValue, select, selectedOption, value, visibleOptions } =\n useSelectController(props);\n const passive = props.interactionPolicy === 'passive';\n const { disabled, interactionPolicy, readOnly, testID } = props;\n const listData = React.useMemo(() => [...visibleOptions], [visibleOptions]);\n\n const releaseSheet = React.useCallback(() => {\n ownsSheet.current = false;\n setOpen(false);\n }, []);\n\n const isCurrentSheetRequest = React.useCallback(\n (requestId: number) => sheetRequestId.current === requestId,\n [],\n );\n\n const claimSheet = React.useCallback(\n (requestId: number) => {\n if (isCurrentSheetRequest(requestId)) ownsSheet.current = true;\n },\n [isCurrentSheetRequest],\n );\n\n const releaseSheetOwnership = React.useCallback(\n (requestId: number) => {\n if (isCurrentSheetRequest(requestId)) ownsSheet.current = false;\n },\n [isCurrentSheetRequest],\n );\n\n const handleSelect = React.useCallback(\n (nextValue: TValue) => {\n select(nextValue);\n releaseSheet();\n dismiss();\n },\n [dismiss, releaseSheet, select],\n );\n\n const renderOption = React.useCallback(\n ({ item }: ListRenderItemInfo<SelectOption<TValue>>) => (\n <SelectOptionRow\n interactionPolicy={interactionPolicy}\n onSelect={handleSelect}\n option={item}\n selected={value === item.value}\n testID={testID}\n />\n ),\n [handleSelect, interactionPolicy, testID, value],\n );\n\n React.useEffect(() => {\n if (!open || !ownsSheet.current) return;\n ownsSheet.current = true;\n const requestId = sheetRequestId.current + 1;\n sheetRequestId.current = requestId;\n present({\n contentMode: 'direct',\n maxDynamicContentSize: SELECT_SHEET_MAX_HEIGHT,\n content: (\n <SelectSheetContent\n key={sheetId}\n onClaim={claimSheet}\n listData={listData}\n isCurrentRequest={isCurrentSheetRequest}\n onRelease={releaseSheet}\n onReleaseOwnership={releaseSheetOwnership}\n props={props}\n renderOption={renderOption}\n requestId={requestId}\n search={search}\n searchValue={searchValue}\n />\n ),\n onDismiss: releaseSheet,\n });\n }, [\n claimSheet,\n isCurrentSheetRequest,\n listData,\n open,\n present,\n props,\n releaseSheet,\n releaseSheetOwnership,\n renderOption,\n search,\n searchValue,\n sheetId,\n ]);\n\n React.useEffect(\n () => () => {\n if (ownsSheet.current) dismiss();\n },\n [dismiss],\n );\n\n const openSelect = React.useCallback(() => {\n if (disabled || readOnly || passive) return;\n\n ownsSheet.current = true;\n setOpen(true);\n }, [disabled, passive, readOnly]);\n\n return (\n <SelectField props={props}>\n <SelectTrigger\n displayLabel={selectedOption?.label}\n leadingMedia={selectedOption?.leadingMedia}\n onPress={openSelect}\n props={props}\n />\n </SelectField>\n );\n}\n\n/*** Renders and releases the Select-owned sheet content when another request replaces it. */\nfunction SelectSheetContent<TValue extends string>({\n isCurrentRequest,\n listData,\n onClaim,\n onRelease,\n onReleaseOwnership,\n props,\n renderOption,\n requestId,\n search,\n searchValue,\n}: SelectSheetContentProps<TValue>) {\n const mounted = React.useRef(false);\n\n React.useEffect(() => {\n mounted.current = true;\n onClaim(requestId);\n\n return () => {\n mounted.current = false;\n onReleaseOwnership(requestId);\n void Promise.resolve().then(() => {\n if (!mounted.current && isCurrentRequest(requestId)) onRelease();\n });\n };\n }, [isCurrentRequest, onClaim, onRelease, onReleaseOwnership, requestId]);\n\n return (\n <BottomSheetFlatList\n contentContainerStyle={styles.listContent}\n data={listData}\n keyExtractor={(item: SelectOption<TValue>) => item.value}\n ListHeaderComponent={\n <SelectSearchInput onSearchChange={search} props={props} searchValue={searchValue} />\n }\n renderItem={renderOption}\n />\n );\n}\n\ninterface SelectSheetContentProps<TValue extends string> {\n readonly isCurrentRequest: (requestId: number) => boolean;\n readonly listData: readonly SelectOption<TValue>[];\n readonly onClaim: (requestId: number) => void;\n readonly onRelease: () => void;\n readonly onReleaseOwnership: (requestId: number) => void;\n readonly props: SelectProps<TValue>;\n readonly renderOption: (info: ListRenderItemInfo<SelectOption<TValue>>) => React.ReactElement;\n readonly requestId: number;\n readonly search: (value: string) => void;\n readonly searchValue: string;\n}\n\nconst styles = StyleSheet.create({\n listContent: {\n padding: 16,\n },\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Select.web.d.ts","sourceRoot":"","sources":["../../../../../../src/features/form/select/adapters/inbound/Select.web.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAS/D,iEAAiE;AACjE,eAAO,MAAM,MAAM,GAGE,MAAM,SAAS,MAAM,mEAHW,CAAC"}
1
+ {"version":3,"file":"Select.web.d.ts","sourceRoot":"","sources":["../../../../../../src/features/form/select/adapters/inbound/Select.web.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAU/D,iEAAiE;AACjE,eAAO,MAAM,MAAM,GAGE,MAAM,SAAS,MAAM,mEAHW,CAAC"}
@@ -5,6 +5,7 @@ import { Surface } from '../../../../surface/public';
5
5
  import { withZoraThemeScope } from '../../../../theme/adapters/inbound/withZoraThemeScope';
6
6
  import { SelectField } from '../../composition/SelectField';
7
7
  import { SelectOptionRow } from '../../composition/SelectOptionRow';
8
+ import { SelectSearchInput } from '../../composition/SelectSearchInput';
8
9
  import { SelectTrigger } from '../../composition/SelectTrigger';
9
10
  import { useSelectController } from '../../composition/useSelectController';
10
11
  /*** Renders Select with anchored Popover presentation on web. */
@@ -12,8 +13,8 @@ export const Select = withZoraThemeScope(SelectInner);
12
13
  /*** Connects shared Select state and controls to the web Popover host. */
13
14
  function SelectInner({ themeId: _themeId, mode: _mode, ...props }) {
14
15
  const [open, setOpen] = React.useState(false);
15
- const { select, selectedOption, value } = useSelectController(props);
16
- const { interactionPolicy, options, testID } = props;
16
+ const { search, searchValue, select, selectedOption, value, visibleOptions } = useSelectController(props);
17
+ const { interactionPolicy, testID } = props;
17
18
  const selectAndClose = React.useCallback((nextValue) => {
18
19
  select(nextValue);
19
20
  setOpen(false);
@@ -22,7 +23,8 @@ function SelectInner({ themeId: _themeId, mode: _mode, ...props }) {
22
23
  <Popover anchor={({ toggle }) => (<SelectTrigger displayLabel={selectedOption?.label} leadingMedia={selectedOption?.leadingMedia} onPress={toggle} props={props}/>)} interactionPolicy={props.interactionPolicy} onOpenChange={setOpen} open={open} placement="bottom-start" testID={testID ? `${testID}-popover` : undefined}>
23
24
  <Surface variant="raised">
24
25
  <View gap="xs" p="xs">
25
- {options.map((option) => (<SelectOptionRow interactionPolicy={interactionPolicy} key={option.value} onSelect={selectAndClose} option={option} selected={value === option.value} testID={testID}/>))}
26
+ <SelectSearchInput onSearchChange={search} props={props} searchValue={searchValue}/>
27
+ {visibleOptions.map((option) => (<SelectOptionRow interactionPolicy={interactionPolicy} key={option.value} onSelect={selectAndClose} option={option} selected={value === option.value} testID={testID}/>))}
26
28
  </View>
27
29
  </Surface>
28
30
  </Popover>
@@ -1 +1 @@
1
- {"version":3,"file":"Select.web.js","sourceRoot":"","sources":["../../../../../../src/features/form/select/adapters/inbound/Select.web.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uDAAuD,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAE5E,iEAAiE;AACjE,MAAM,CAAC,MAAM,MAAM,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC;AAEtD,0EAA0E;AAC1E,SAAS,WAAW,CAAiC,EACnD,OAAO,EAAE,QAAQ,EACjB,IAAI,EAAE,KAAK,EACX,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C,CAAC,MAAM,EAAE,EAAE,CAAC,CACvB,CAAC,eAAe,CACd,iBAAiB,CAAC,CAAC,iBAAiB,CAAC,CACrC,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAClB,QAAQ,CAAC,CAAC,cAAc,CAAC,CACzB,MAAM,CAAC,CAAC,MAAM,CAAC,CACf,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,CAAC,CACjC,MAAM,CAAC,CAAC,MAAM,CAAC,EACf,CACH,CAAC,CACJ;UAAA,EAAE,IAAI,CACR;QAAA,EAAE,OAAO,CACX;MAAA,EAAE,OAAO,CACX;IAAA,EAAE,WAAW,CAAC,CACf,CAAC;AACJ,CAAC","sourcesContent":["import { Popover } from '@ankhorage/surface';\nimport React from 'react';\n\nimport type { SelectProps } from '../../../../../types/select';\nimport { View } from '../../../../layout/public';\nimport { Surface } from '../../../../surface/public';\nimport { withZoraThemeScope } from '../../../../theme/adapters/inbound/withZoraThemeScope';\nimport { SelectField } from '../../composition/SelectField';\nimport { SelectOptionRow } from '../../composition/SelectOptionRow';\nimport { SelectTrigger } from '../../composition/SelectTrigger';\nimport { useSelectController } from '../../composition/useSelectController';\n\n/*** Renders Select with anchored Popover presentation on web. */\nexport const Select = withZoraThemeScope(SelectInner);\n\n/*** Connects shared Select state and controls to the web Popover host. */\nfunction SelectInner<TValue extends string = string>({\n themeId: _themeId,\n mode: _mode,\n ...props\n}: SelectProps<TValue>) {\n const [open, setOpen] = React.useState(false);\n const { select, selectedOption, value } = useSelectController(props);\n const { interactionPolicy, options, testID } = props;\n\n const selectAndClose = React.useCallback(\n (nextValue: TValue) => {\n select(nextValue);\n setOpen(false);\n },\n [select],\n );\n\n return (\n <SelectField props={props}>\n <Popover\n anchor={({ toggle }) => (\n <SelectTrigger\n displayLabel={selectedOption?.label}\n leadingMedia={selectedOption?.leadingMedia}\n onPress={toggle}\n props={props}\n />\n )}\n interactionPolicy={props.interactionPolicy}\n onOpenChange={setOpen}\n open={open}\n placement=\"bottom-start\"\n testID={testID ? `${testID}-popover` : undefined}\n >\n <Surface variant=\"raised\">\n <View gap=\"xs\" p=\"xs\">\n {options.map((option) => (\n <SelectOptionRow\n interactionPolicy={interactionPolicy}\n key={option.value}\n onSelect={selectAndClose}\n option={option}\n selected={value === option.value}\n testID={testID}\n />\n ))}\n </View>\n </Surface>\n </Popover>\n </SelectField>\n );\n}\n"]}
1
+ {"version":3,"file":"Select.web.js","sourceRoot":"","sources":["../../../../../../src/features/form/select/adapters/inbound/Select.web.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uDAAuD,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAE5E,iEAAiE;AACjE,MAAM,CAAC,MAAM,MAAM,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC;AAEtD,0EAA0E;AAC1E,SAAS,WAAW,CAAiC,EACnD,OAAO,EAAE,QAAQ,EACjB,IAAI,EAAE,KAAK,EACX,GAAG,KAAK,EACY;IACpB,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,cAAc,EA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AC9B,CAAC,eAAe,CACd,iBAAiB,CAAC,CAAC,iBAAiB,CAAC,CACrC,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAClB,QAAQ,CAAC,CAAC,cAAc,CAAC,CACzB,MAAM,CAAC,CAAC,MAAM,CAAC,CACf,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,CAAC,CACjC,MAAM,CAAC,CAAC,MAAM,CAAC,EACf,CACH,CAAC,CACJ;UAAA,EAAE,IAAI,CACR;QAAA,EAAE,OAAO,CACX;MAAA,EAAE,OAAO,CACX;IAAA,EAAE,WAAW,CAAC,CACf,CAAC;AACJ,CAAC","sourcesContent":["import { Popover } from '@ankhorage/surface';\nimport React from 'react';\n\nimport type { SelectProps } from '../../../../../types/select';\nimport { View } from '../../../../layout/public';\nimport { Surface } from '../../../../surface/public';\nimport { withZoraThemeScope } from '../../../../theme/adapters/inbound/withZoraThemeScope';\nimport { SelectField } from '../../composition/SelectField';\nimport { SelectOptionRow } from '../../composition/SelectOptionRow';\nimport { SelectSearchInput } from '../../composition/SelectSearchInput';\nimport { SelectTrigger } from '../../composition/SelectTrigger';\nimport { useSelectController } from '../../composition/useSelectController';\n\n/*** Renders Select with anchored Popover presentation on web. */\nexport const Select = withZoraThemeScope(SelectInner);\n\n/*** Connects shared Select state and controls to the web Popover host. */\nfunction SelectInner<TValue extends string = string>({\n themeId: _themeId,\n mode: _mode,\n ...props\n}: SelectProps<TValue>) {\n const [open, setOpen] = React.useState(false);\n const { search, searchValue, select, selectedOption, value, visibleOptions } =\n useSelectController(props);\n const { interactionPolicy, testID } = props;\n\n const selectAndClose = React.useCallback(\n (nextValue: TValue) => {\n select(nextValue);\n setOpen(false);\n },\n [select],\n );\n\n return (\n <SelectField props={props}>\n <Popover\n anchor={({ toggle }) => (\n <SelectTrigger\n displayLabel={selectedOption?.label}\n leadingMedia={selectedOption?.leadingMedia}\n onPress={toggle}\n props={props}\n />\n )}\n interactionPolicy={props.interactionPolicy}\n onOpenChange={setOpen}\n open={open}\n placement=\"bottom-start\"\n testID={testID ? `${testID}-popover` : undefined}\n >\n <Surface variant=\"raised\">\n <View gap=\"xs\" p=\"xs\">\n <SelectSearchInput onSearchChange={search} props={props} searchValue={searchValue} />\n {visibleOptions.map((option) => (\n <SelectOptionRow\n interactionPolicy={interactionPolicy}\n key={option.value}\n onSelect={selectAndClose}\n option={option}\n selected={value === option.value}\n testID={testID}\n />\n ))}\n </View>\n </Surface>\n </Popover>\n </SelectField>\n );\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import type { SelectProps } from '../../../../types/select';
2
+ /*** Renders the optional controlled search input shared by Select presentations. */
3
+ export declare function SelectSearchInput<TValue extends string>({ onSearchChange, props, searchValue, }: SelectSearchInputProps<TValue>): import("react").JSX.Element | null;
4
+ interface SelectSearchInputProps<TValue extends string> {
5
+ readonly onSearchChange: (value: string) => void;
6
+ readonly props: SelectProps<TValue>;
7
+ readonly searchValue: string;
8
+ }
9
+ export {};
10
+ //# sourceMappingURL=SelectSearchInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SelectSearchInput.d.ts","sourceRoot":"","sources":["../../../../../src/features/form/select/composition/SelectSearchInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAI5D,oFAAoF;AACpF,wBAAgB,iBAAiB,CAAC,MAAM,SAAS,MAAM,EAAE,EACvD,cAAc,EACd,KAAK,EACL,WAAW,GACZ,EAAE,sBAAsB,CAAC,MAAM,CAAC,sCAiBhC;AAED,UAAU,sBAAsB,CAAC,MAAM,SAAS,MAAM;IACpD,QAAQ,CAAC,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACjD,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACpC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B"}
@@ -0,0 +1,11 @@
1
+ import { View } from '../../../layout/public';
2
+ import { SearchInput } from '../../search-input/public';
3
+ /*** Renders the optional controlled search input shared by Select presentations. */
4
+ export function SelectSearchInput({ onSearchChange, props, searchValue, }) {
5
+ if (!props.searchable)
6
+ return null;
7
+ return (<View pb="xs">
8
+ <SearchInput disabled={props.disabled} interactionPolicy={props.interactionPolicy} onValueChange={onSearchChange} placeholder={props.searchPlaceholder ?? 'Search options'} readOnly={props.readOnly} size="m" testID={props.testID ? `${props.testID}-search` : undefined} value={searchValue}/>
9
+ </View>);
10
+ }
11
+ //# sourceMappingURL=SelectSearchInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SelectSearchInput.js","sourceRoot":"","sources":["../../../../../src/features/form/select/composition/SelectSearchInput.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,oFAAoF;AACpF,MAAM,UAAU,iBAAiB,CAAwB,EACvD,cAAc,EACd,KAAK,EACL,WAAW,GACoB;IAC/B,IAAI,CAAC,KAAK,CAAC,UAAU;QAAE,OAAO,IAAI,CAAC;IAEnC,OAAO,CACL,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CACX;MAAA,CAAC,WAAW,CACV,QAAQ,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CACzB,iBAAiB,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAC3C,aAAa,CAAC,CAAC,cAAc,CAAC,CAC9B,WAAW,CAAC,CAAC,KAAK,CAAC,iBAAiB,IAAI,gBAAgB,CAAC,CACzD,QAAQ,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CACzB,IAAI,CAAC,GAAG,CACR,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAC5D,KAAK,CAAC,CAAC,WAAW,CAAC,EAEvB;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC","sourcesContent":["import type { SelectProps } from '../../../../types/select';\nimport { View } from '../../../layout/public';\nimport { SearchInput } from '../../search-input/public';\n\n/*** Renders the optional controlled search input shared by Select presentations. */\nexport function SelectSearchInput<TValue extends string>({\n onSearchChange,\n props,\n searchValue,\n}: SelectSearchInputProps<TValue>) {\n if (!props.searchable) return null;\n\n return (\n <View pb=\"xs\">\n <SearchInput\n disabled={props.disabled}\n interactionPolicy={props.interactionPolicy}\n onValueChange={onSearchChange}\n placeholder={props.searchPlaceholder ?? 'Search options'}\n readOnly={props.readOnly}\n size=\"m\"\n testID={props.testID ? `${props.testID}-search` : undefined}\n value={searchValue}\n />\n </View>\n );\n}\n\ninterface SelectSearchInputProps<TValue extends string> {\n readonly onSearchChange: (value: string) => void;\n readonly props: SelectProps<TValue>;\n readonly searchValue: string;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { SelectOption } from '../../../../types/select';
2
+ /*** Preserves option identity while limiting a searchable Select to labels matching its query. */
3
+ export declare function getVisibleSelectOptions<TValue extends string>(options: readonly SelectOption<TValue>[], searchable: boolean | undefined, searchValue: string): readonly SelectOption<TValue>[];
4
+ //# sourceMappingURL=getVisibleSelectOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getVisibleSelectOptions.d.ts","sourceRoot":"","sources":["../../../../../src/features/form/select/composition/getVisibleSelectOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,kGAAkG;AAClG,wBAAgB,uBAAuB,CAAC,MAAM,SAAS,MAAM,EAC3D,OAAO,EAAE,SAAS,YAAY,CAAC,MAAM,CAAC,EAAE,EACxC,UAAU,EAAE,OAAO,GAAG,SAAS,EAC/B,WAAW,EAAE,MAAM,GAClB,SAAS,YAAY,CAAC,MAAM,CAAC,EAAE,CAKjC"}
@@ -0,0 +1,8 @@
1
+ /*** Preserves option identity while limiting a searchable Select to labels matching its query. */
2
+ export function getVisibleSelectOptions(options, searchable, searchValue) {
3
+ const query = searchValue.trim().toLocaleLowerCase();
4
+ if (!searchable || query.length === 0)
5
+ return options;
6
+ return options.filter((option) => option.label.toLocaleLowerCase().includes(query));
7
+ }
8
+ //# sourceMappingURL=getVisibleSelectOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getVisibleSelectOptions.js","sourceRoot":"","sources":["../../../../../src/features/form/select/composition/getVisibleSelectOptions.ts"],"names":[],"mappings":"AAEA,kGAAkG;AAClG,MAAM,UAAU,uBAAuB,CACrC,OAAwC,EACxC,UAA+B,EAC/B,WAAmB;IAEnB,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC,iBAAiB,EAAE,CAAC;IACrD,IAAI,CAAC,UAAU,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC;IAEtD,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;AACtF,CAAC","sourcesContent":["import type { SelectOption } from '../../../../types/select';\n\n/*** Preserves option identity while limiting a searchable Select to labels matching its query. */\nexport function getVisibleSelectOptions<TValue extends string>(\n options: readonly SelectOption<TValue>[],\n searchable: boolean | undefined,\n searchValue: string,\n): readonly SelectOption<TValue>[] {\n const query = searchValue.trim().toLocaleLowerCase();\n if (!searchable || query.length === 0) return options;\n\n return options.filter((option) => option.label.toLocaleLowerCase().includes(query));\n}\n"]}
@@ -1,8 +1,11 @@
1
1
  import type { SelectProps } from '../../../../types/select';
2
2
  /*** Resolves controlled or uncontrolled Select value state and the selected option. */
3
3
  export declare function useSelectController<TValue extends string>(props: SelectProps<TValue>): {
4
+ readonly search: (nextValue: string) => void;
5
+ readonly searchValue: string;
4
6
  readonly select: (nextValue: TValue) => void;
5
7
  readonly selectedOption: import("../public").SelectOption<TValue> | undefined;
6
8
  readonly value: TValue | undefined;
9
+ readonly visibleOptions: readonly import("../public").SelectOption<TValue>[];
7
10
  };
8
11
  //# sourceMappingURL=useSelectController.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useSelectController.d.ts","sourceRoot":"","sources":["../../../../../src/features/form/select/composition/useSelectController.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D,uFAAuF;AACvF,wBAAgB,mBAAmB,CAAC,MAAM,SAAS,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC;iCAOrE,MAAM;;;EAQrB"}
1
+ {"version":3,"file":"useSelectController.d.ts","sourceRoot":"","sources":["../../../../../src/features/form/select/composition/useSelectController.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAG5D,uFAAuF;AACvF,wBAAgB,mBAAmB,CAAC,MAAM,SAAS,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC;iCA6BrE,MAAM;;iCARN,MAAM;;;;EAgBrB"}
@@ -1,15 +1,24 @@
1
1
  import React from 'react';
2
+ import { getVisibleSelectOptions } from './getVisibleSelectOptions';
2
3
  /*** Resolves controlled or uncontrolled Select value state and the selected option. */
3
4
  export function useSelectController(props) {
4
- const { defaultValue, onValueChange, options, value: controlledValue } = props;
5
+ const { defaultSearchValue, defaultValue, onSearchChange, onValueChange, options, searchValue: controlledSearchValue, value: controlledValue, } = props;
5
6
  const [localValue, setLocalValue] = React.useState(defaultValue);
7
+ const [localSearchValue, setLocalSearchValue] = React.useState(defaultSearchValue ?? '');
6
8
  const value = controlledValue ?? localValue;
9
+ const searchValue = controlledSearchValue ?? localSearchValue;
7
10
  const selectedOption = options.find((option) => option.value === value);
11
+ const visibleOptions = React.useMemo(() => getVisibleSelectOptions(options, props.searchable, searchValue), [options, props.searchable, searchValue]);
8
12
  const select = React.useCallback((nextValue) => {
9
13
  if (controlledValue === undefined)
10
14
  setLocalValue(nextValue);
11
15
  onValueChange?.(nextValue);
12
16
  }, [controlledValue, onValueChange]);
13
- return { select, selectedOption, value };
17
+ const search = React.useCallback((nextValue) => {
18
+ if (controlledSearchValue === undefined)
19
+ setLocalSearchValue(nextValue);
20
+ onSearchChange?.(nextValue);
21
+ }, [controlledSearchValue, onSearchChange]);
22
+ return { search, searchValue, select, selectedOption, value, visibleOptions };
14
23
  }
15
24
  //# sourceMappingURL=useSelectController.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useSelectController.js","sourceRoot":"","sources":["../../../../../src/features/form/select/composition/useSelectController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,uFAAuF;AACvF,MAAM,UAAU,mBAAmB,CAAwB,KAA0B;IACnF,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,GAAG,KAAK,CAAC;IAC/E,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAqB,YAAY,CAAC,CAAC;IACrF,MAAM,KAAK,GAAG,eAAe,IAAI,UAAU,CAAC;IAC5C,MAAM,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;IAExE,MAAM,MAAM,GAAG,KAAK,CAAC,WAAW,CAC9B,CAAC,SAAiB,EAAE,EAAE;QACpB,IAAI,eAAe,KAAK,SAAS;YAAE,aAAa,CAAC,SAAS,CAAC,CAAC;QAC5D,aAAa,EAAE,CAAC,SAAS,CAAC,CAAC;IAC7B,CAAC,EACD,CAAC,eAAe,EAAE,aAAa,CAAC,CACjC,CAAC;IAEF,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAW,CAAC;AACpD,CAAC","sourcesContent":["import React from 'react';\n\nimport type { SelectProps } from '../../../../types/select';\n\n/*** Resolves controlled or uncontrolled Select value state and the selected option. */\nexport function useSelectController<TValue extends string>(props: SelectProps<TValue>) {\n const { defaultValue, onValueChange, options, value: controlledValue } = props;\n const [localValue, setLocalValue] = React.useState<TValue | undefined>(defaultValue);\n const value = controlledValue ?? localValue;\n const selectedOption = options.find((option) => option.value === value);\n\n const select = React.useCallback(\n (nextValue: TValue) => {\n if (controlledValue === undefined) setLocalValue(nextValue);\n onValueChange?.(nextValue);\n },\n [controlledValue, onValueChange],\n );\n\n return { select, selectedOption, value } as const;\n}\n"]}
1
+ {"version":3,"file":"useSelectController.js","sourceRoot":"","sources":["../../../../../src/features/form/select/composition/useSelectController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,uFAAuF;AACvF,MAAM,UAAU,mBAAmB,CAAwB,KAA0B;IACnF,MAAM,EACJ,kBAAkB,EAClB,YAAY,EACZ,cAAc,EACd,aAAa,EACb,OAAO,EACP,WAAW,EAAE,qBAAqB,EAClC,KAAK,EAAE,eAAe,GACvB,GAAG,KAAK,CAAC;IACV,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAqB,YAAY,CAAC,CAAC;IACrF,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,kBAAkB,IAAI,EAAE,CAAC,CAAC;IACzF,MAAM,KAAK,GAAG,eAAe,IAAI,UAAU,CAAC;IAC5C,MAAM,WAAW,GAAG,qBAAqB,IAAI,gBAAgB,CAAC;IAC9D,MAAM,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;IACxE,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,CAClC,GAAG,EAAE,CAAC,uBAAuB,CAAC,OAAO,EAAE,KAAK,CAAC,UAAU,EAAE,WAAW,CAAC,EACrE,CAAC,OAAO,EAAE,KAAK,CAAC,UAAU,EAAE,WAAW,CAAC,CACzC,CAAC;IAEF,MAAM,MAAM,GAAG,KAAK,CAAC,WAAW,CAC9B,CAAC,SAAiB,EAAE,EAAE;QACpB,IAAI,eAAe,KAAK,SAAS;YAAE,aAAa,CAAC,SAAS,CAAC,CAAC;QAC5D,aAAa,EAAE,CAAC,SAAS,CAAC,CAAC;IAC7B,CAAC,EACD,CAAC,eAAe,EAAE,aAAa,CAAC,CACjC,CAAC;IAEF,MAAM,MAAM,GAAG,KAAK,CAAC,WAAW,CAC9B,CAAC,SAAiB,EAAE,EAAE;QACpB,IAAI,qBAAqB,KAAK,SAAS;YAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;QACxE,cAAc,EAAE,CAAC,SAAS,CAAC,CAAC;IAC9B,CAAC,EACD,CAAC,qBAAqB,EAAE,cAAc,CAAC,CACxC,CAAC;IAEF,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,cAAc,EAAW,CAAC;AACzF,CAAC","sourcesContent":["import React from 'react';\n\nimport type { SelectProps } from '../../../../types/select';\nimport { getVisibleSelectOptions } from './getVisibleSelectOptions';\n\n/*** Resolves controlled or uncontrolled Select value state and the selected option. */\nexport function useSelectController<TValue extends string>(props: SelectProps<TValue>) {\n const {\n defaultSearchValue,\n defaultValue,\n onSearchChange,\n onValueChange,\n options,\n searchValue: controlledSearchValue,\n value: controlledValue,\n } = props;\n const [localValue, setLocalValue] = React.useState<TValue | undefined>(defaultValue);\n const [localSearchValue, setLocalSearchValue] = React.useState(defaultSearchValue ?? '');\n const value = controlledValue ?? localValue;\n const searchValue = controlledSearchValue ?? localSearchValue;\n const selectedOption = options.find((option) => option.value === value);\n const visibleOptions = React.useMemo(\n () => getVisibleSelectOptions(options, props.searchable, searchValue),\n [options, props.searchable, searchValue],\n );\n\n const select = React.useCallback(\n (nextValue: TValue) => {\n if (controlledValue === undefined) setLocalValue(nextValue);\n onValueChange?.(nextValue);\n },\n [controlledValue, onValueChange],\n );\n\n const search = React.useCallback(\n (nextValue: string) => {\n if (controlledSearchValue === undefined) setLocalSearchValue(nextValue);\n onSearchChange?.(nextValue);\n },\n [controlledSearchValue, onSearchChange],\n );\n\n return { search, searchValue, select, selectedOption, value, visibleOptions } as const;\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  export declare const selectMeta: {
2
2
  readonly name: "Select";
3
3
  readonly category: "component";
4
- readonly description: "Single-value form selection with Popover presentation on web and BottomSheet presentation on native.";
4
+ readonly description: "Single-value form selection with optional searchable options, Popover presentation on web, and BottomSheet presentation on native.";
5
5
  readonly directManifestNode: true;
6
6
  readonly allowedChildren: readonly [];
7
7
  readonly blueprint: {
@@ -23,6 +23,7 @@ export declare const selectMeta: {
23
23
  readonly disabled: false;
24
24
  readonly readOnly: false;
25
25
  readonly invalid: false;
26
+ readonly searchable: false;
26
27
  };
27
28
  };
28
29
  readonly bindings: {
@@ -45,6 +46,47 @@ export declare const selectMeta: {
45
46
  readonly acceptsFallback: true;
46
47
  readonly acceptsTransforms: true;
47
48
  };
49
+ readonly options: {
50
+ readonly label: "Options";
51
+ readonly description: "Reactive serializable options rendered by the select.";
52
+ readonly value: {
53
+ readonly type: "array";
54
+ readonly itemType: "object";
55
+ readonly fields: readonly [{
56
+ readonly path: "[].value";
57
+ readonly type: "string";
58
+ readonly label: "Value";
59
+ }, {
60
+ readonly path: "[].label";
61
+ readonly type: "string";
62
+ readonly label: "Label";
63
+ }, {
64
+ readonly path: "[].disabled";
65
+ readonly type: "boolean";
66
+ readonly label: "Disabled";
67
+ }];
68
+ };
69
+ readonly acceptsFallback: true;
70
+ readonly acceptsTransforms: true;
71
+ };
72
+ readonly searchValue: {
73
+ readonly label: "Search value";
74
+ readonly description: "Current query for the searchable option list.";
75
+ readonly value: {
76
+ readonly type: "string";
77
+ };
78
+ readonly acceptsFallback: true;
79
+ readonly acceptsTransforms: true;
80
+ };
81
+ readonly searchable: {
82
+ readonly label: "Searchable";
83
+ readonly description: "Whether the option list exposes a search control.";
84
+ readonly value: {
85
+ readonly type: "boolean";
86
+ };
87
+ readonly acceptsFallback: true;
88
+ readonly acceptsTransforms: true;
89
+ };
48
90
  };
49
91
  readonly events: {
50
92
  readonly valueChange: {
@@ -59,6 +101,18 @@ export declare const selectMeta: {
59
101
  }];
60
102
  };
61
103
  };
104
+ readonly searchChange: {
105
+ readonly label: "Search change";
106
+ readonly description: "Runs when the searchable option query changes.";
107
+ readonly payload: {
108
+ readonly eventType: "select.searchChange";
109
+ readonly fields: readonly [{
110
+ readonly path: "value";
111
+ readonly type: "string";
112
+ readonly label: "Value";
113
+ }];
114
+ };
115
+ };
62
116
  };
63
117
  };
64
118
  readonly events: {
@@ -72,6 +126,16 @@ export declare const selectMeta: {
72
126
  readonly label: "Value";
73
127
  }];
74
128
  };
129
+ readonly searchChange: {
130
+ readonly label: "Search change";
131
+ readonly eventType: "select.searchChange";
132
+ readonly description: "Emitted when the searchable option query changes.";
133
+ readonly payloadFields: readonly [{
134
+ readonly path: "value";
135
+ readonly type: "string";
136
+ readonly label: "Value";
137
+ }];
138
+ };
75
139
  };
76
140
  readonly props: {
77
141
  readonly defaultValue: {
@@ -129,6 +193,40 @@ export declare const selectMeta: {
129
193
  readonly authority: "instance";
130
194
  };
131
195
  };
196
+ readonly searchable: {
197
+ readonly type: "boolean";
198
+ readonly category: "Behavior";
199
+ readonly label: "Searchable";
200
+ readonly default: false;
201
+ readonly authoring: {
202
+ readonly authority: "instance";
203
+ };
204
+ };
205
+ readonly defaultSearchValue: {
206
+ readonly type: "string";
207
+ readonly category: "State";
208
+ readonly label: "Initial search value";
209
+ readonly authoring: {
210
+ readonly authority: "instance";
211
+ };
212
+ };
213
+ readonly searchValue: {
214
+ readonly type: "string";
215
+ readonly category: "State";
216
+ readonly label: "Search value";
217
+ readonly authoring: {
218
+ readonly authority: "instance";
219
+ };
220
+ };
221
+ readonly searchPlaceholder: {
222
+ readonly type: "string";
223
+ readonly category: "Content";
224
+ readonly label: "Search placeholder";
225
+ readonly default: "Search options";
226
+ readonly authoring: {
227
+ readonly authority: "instance";
228
+ };
229
+ };
132
230
  readonly label: {
133
231
  readonly type: "string";
134
232
  readonly category: "Content";
@@ -1 +1 @@
1
- {"version":3,"file":"selectMeta.d.ts","sourceRoot":"","sources":["../../../../src/features/form/select/selectMeta.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsLe,CAAC"}
1
+ {"version":3,"file":"selectMeta.d.ts","sourceRoot":"","sources":["../../../../src/features/form/select/selectMeta.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4Pe,CAAC"}
@@ -1,7 +1,7 @@
1
1
  export const selectMeta = {
2
2
  name: 'Select',
3
3
  category: 'component',
4
- description: 'Single-value form selection with Popover presentation on web and BottomSheet presentation on native.',
4
+ description: 'Single-value form selection with optional searchable options, Popover presentation on web, and BottomSheet presentation on native.',
5
5
  directManifestNode: true,
6
6
  allowedChildren: [],
7
7
  blueprint: {
@@ -18,6 +18,7 @@ export const selectMeta = {
18
18
  disabled: false,
19
19
  readOnly: false,
20
20
  invalid: false,
21
+ searchable: false,
21
22
  },
22
23
  },
23
24
  bindings: {
@@ -36,6 +37,35 @@ export const selectMeta = {
36
37
  acceptsFallback: true,
37
38
  acceptsTransforms: true,
38
39
  },
40
+ options: {
41
+ label: 'Options',
42
+ description: 'Reactive serializable options rendered by the select.',
43
+ value: {
44
+ type: 'array',
45
+ itemType: 'object',
46
+ fields: [
47
+ { path: '[].value', type: 'string', label: 'Value' },
48
+ { path: '[].label', type: 'string', label: 'Label' },
49
+ { path: '[].disabled', type: 'boolean', label: 'Disabled' },
50
+ ],
51
+ },
52
+ acceptsFallback: true,
53
+ acceptsTransforms: true,
54
+ },
55
+ searchValue: {
56
+ label: 'Search value',
57
+ description: 'Current query for the searchable option list.',
58
+ value: { type: 'string' },
59
+ acceptsFallback: true,
60
+ acceptsTransforms: true,
61
+ },
62
+ searchable: {
63
+ label: 'Searchable',
64
+ description: 'Whether the option list exposes a search control.',
65
+ value: { type: 'boolean' },
66
+ acceptsFallback: true,
67
+ acceptsTransforms: true,
68
+ },
39
69
  },
40
70
  events: {
41
71
  valueChange: {
@@ -46,6 +76,14 @@ export const selectMeta = {
46
76
  fields: [{ path: 'value', type: 'string', label: 'Value' }],
47
77
  },
48
78
  },
79
+ searchChange: {
80
+ label: 'Search change',
81
+ description: 'Runs when the searchable option query changes.',
82
+ payload: {
83
+ eventType: 'select.searchChange',
84
+ fields: [{ path: 'value', type: 'string', label: 'Value' }],
85
+ },
86
+ },
49
87
  },
50
88
  },
51
89
  events: {
@@ -55,6 +93,12 @@ export const selectMeta = {
55
93
  description: 'Emitted when the selected option value changes.',
56
94
  payloadFields: [{ path: 'value', type: 'string', label: 'Value' }],
57
95
  },
96
+ searchChange: {
97
+ label: 'Search change',
98
+ eventType: 'select.searchChange',
99
+ description: 'Emitted when the searchable option query changes.',
100
+ payloadFields: [{ path: 'value', type: 'string', label: 'Value' }],
101
+ },
58
102
  },
59
103
  props: {
60
104
  defaultValue: {
@@ -103,6 +147,32 @@ export const selectMeta = {
103
147
  ],
104
148
  authoring: { authority: 'instance' },
105
149
  },
150
+ searchable: {
151
+ type: 'boolean',
152
+ category: 'Behavior',
153
+ label: 'Searchable',
154
+ default: false,
155
+ authoring: { authority: 'instance' },
156
+ },
157
+ defaultSearchValue: {
158
+ type: 'string',
159
+ category: 'State',
160
+ label: 'Initial search value',
161
+ authoring: { authority: 'instance' },
162
+ },
163
+ searchValue: {
164
+ type: 'string',
165
+ category: 'State',
166
+ label: 'Search value',
167
+ authoring: { authority: 'instance' },
168
+ },
169
+ searchPlaceholder: {
170
+ type: 'string',
171
+ category: 'Content',
172
+ label: 'Search placeholder',
173
+ default: 'Search options',
174
+ authoring: { authority: 'instance' },
175
+ },
106
176
  label: {
107
177
  type: 'string',
108
178
  category: 'Content',