@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.
- package/CHANGELOG.md +6 -0
- package/README.md +1 -1
- package/dist/capabilities/index.js +73 -3
- package/dist/capabilities/index.js.map +3 -3
- package/dist/features/form/select/adapters/inbound/Select.native.d.ts.map +1 -1
- package/dist/features/form/select/adapters/inbound/Select.native.js +71 -8
- package/dist/features/form/select/adapters/inbound/Select.native.js.map +1 -1
- package/dist/features/form/select/adapters/inbound/Select.web.d.ts.map +1 -1
- package/dist/features/form/select/adapters/inbound/Select.web.js +5 -3
- package/dist/features/form/select/adapters/inbound/Select.web.js.map +1 -1
- package/dist/features/form/select/composition/SelectSearchInput.d.ts +10 -0
- package/dist/features/form/select/composition/SelectSearchInput.d.ts.map +1 -0
- package/dist/features/form/select/composition/SelectSearchInput.js +11 -0
- package/dist/features/form/select/composition/SelectSearchInput.js.map +1 -0
- package/dist/features/form/select/composition/getVisibleSelectOptions.d.ts +4 -0
- package/dist/features/form/select/composition/getVisibleSelectOptions.d.ts.map +1 -0
- package/dist/features/form/select/composition/getVisibleSelectOptions.js +8 -0
- package/dist/features/form/select/composition/getVisibleSelectOptions.js.map +1 -0
- package/dist/features/form/select/composition/useSelectController.d.ts +3 -0
- package/dist/features/form/select/composition/useSelectController.d.ts.map +1 -1
- package/dist/features/form/select/composition/useSelectController.js +11 -2
- package/dist/features/form/select/composition/useSelectController.js.map +1 -1
- package/dist/features/form/select/selectMeta.d.ts +99 -1
- package/dist/features/form/select/selectMeta.d.ts.map +1 -1
- package/dist/features/form/select/selectMeta.js +71 -1
- package/dist/features/form/select/selectMeta.js.map +1 -1
- package/dist/features/registry/bindableComponentMeta.d.ts +79 -1
- package/dist/features/registry/bindableComponentMeta.d.ts.map +1 -1
- package/dist/features/registry/bindableComponentMeta.js +59 -1
- package/dist/features/registry/bindableComponentMeta.js.map +1 -1
- package/dist/types/select.d.ts +10 -0
- package/dist/types/select.d.ts.map +1 -1
- package/dist/types/select.js.map +1 -1
- package/package.json +27 -1
- package/src/features/form/select/adapters/inbound/Select.native.test.tsx +322 -0
- package/src/features/form/select/adapters/inbound/Select.native.tsx +135 -13
- package/src/features/form/select/adapters/inbound/Select.web.tsx +6 -3
- package/src/features/form/select/composition/SelectSearchInput.tsx +33 -0
- package/src/features/form/select/composition/getVisibleSelectOptions.test.ts +22 -0
- package/src/features/form/select/composition/getVisibleSelectOptions.ts +13 -0
- package/src/features/form/select/composition/useSelectController.ts +25 -2
- package/src/features/form/select/public.test.ts +31 -1
- package/src/features/form/select/selectMeta.ts +71 -1
- package/src/features/registry/bindableComponentMeta.test.ts +6 -0
- package/src/features/registry/bindableComponentMeta.ts +59 -1
- package/src/features/registry/featureManifest.test.ts +10 -0
- package/src/types/select.ts +10 -0
- package/web-dist/chunks/{Accordion-sj1n06dw.js → Accordion-9dk62zn9.js} +84 -24
- package/web-dist/chunks/Accordion-ar8qe05j.js +53 -0
- package/web-dist/chunks/{Accordion-ge7cjtwy.js → Accordion-mpb070cf.js} +3 -3
- package/web-dist/chunks/{Accordion-554f42yj.js → Accordion-sj30964p.js} +4 -4
- package/web-dist/chunks/{Accordion-2bygfpwg.js → Accordion-xhxv2v0g.js} +62 -2
- package/web-dist/chunks/{RichTextClient-70qt7037.js → RichTextClient-7qqj2dpw.js} +3 -4
- package/web-dist/components/auth-screen/AuthScreen.js +2 -3
- package/web-dist/components/color-hue-scale/ColorHueScale.js +4 -3
- package/web-dist/components/color-picker/ColorPicker.js +4 -3
- package/web-dist/components/color-tone/ColorTone.js +4 -3
- package/web-dist/components/color-wheel/ColorWheel.js +4 -3
- package/web-dist/components/forgot-password-form/ForgotPasswordForm.js +2 -3
- package/web-dist/components/o-auth-provider-button/OAuthProviderButton.js +2 -3
- package/web-dist/components/o-auth-provider-list/OAuthProviderList.js +2 -3
- package/web-dist/components/otp-form/OtpForm.js +2 -3
- package/web-dist/components/rich-text/RichText.js +2 -2
- package/web-dist/components/search-input/SearchInput.js +5 -52
- package/web-dist/components/select/Select.js +3 -1
- package/web-dist/components/select/Select.types-0.d.ts +10 -0
- package/web-dist/components/sign-in-form/SignInForm.js +2 -3
- package/web-dist/components/sign-up-form/SignUpForm.js +2 -3
- package/web-dist/components/text-input/TextInput.js +4 -5
- package/web-dist/manifest.json +39 -41
- package/web-dist/chunks/Accordion-49d0frg7.js +0 -66
|
@@ -3,12 +3,29 @@ import { expect, test } from 'bun:test';
|
|
|
3
3
|
import type { SelectProps } from '../../../types/select';
|
|
4
4
|
import { selectMeta } from './selectMeta';
|
|
5
5
|
|
|
6
|
-
test('Select is a direct manifest node with
|
|
6
|
+
test('Select is a direct manifest node with controlled selection and search payloads', () => {
|
|
7
7
|
expect(selectMeta.directManifestNode).toBe(true);
|
|
8
8
|
expect(selectMeta.events.valueChange.eventType).toBe('select.valueChange');
|
|
9
9
|
expect(selectMeta.events.valueChange.payloadFields).toEqual([
|
|
10
10
|
{ path: 'value', type: 'string', label: 'Value' },
|
|
11
11
|
]);
|
|
12
|
+
expect(selectMeta.events.searchChange).toEqual({
|
|
13
|
+
label: 'Search change',
|
|
14
|
+
eventType: 'select.searchChange',
|
|
15
|
+
description: 'Emitted when the searchable option query changes.',
|
|
16
|
+
payloadFields: [{ path: 'value', type: 'string', label: 'Value' }],
|
|
17
|
+
});
|
|
18
|
+
expect(selectMeta.bindings.props.options.value).toEqual({
|
|
19
|
+
type: 'array',
|
|
20
|
+
itemType: 'object',
|
|
21
|
+
fields: [
|
|
22
|
+
{ path: '[].value', type: 'string', label: 'Value' },
|
|
23
|
+
{ path: '[].label', type: 'string', label: 'Label' },
|
|
24
|
+
{ path: '[].disabled', type: 'boolean', label: 'Disabled' },
|
|
25
|
+
],
|
|
26
|
+
});
|
|
27
|
+
expect(selectMeta.bindings.props.searchValue.value.type).toBe('string');
|
|
28
|
+
expect(selectMeta.bindings.events.searchChange.payload.eventType).toBe('select.searchChange');
|
|
12
29
|
});
|
|
13
30
|
|
|
14
31
|
test('Select registers the optional leading icon as instance-owned media metadata', () => {
|
|
@@ -109,3 +126,16 @@ test('Select supports label emphasis, SVG icons, and leading images', async () =
|
|
|
109
126
|
expect(selectTrigger).toContain('source={media}');
|
|
110
127
|
expect(selectOptionRow).toContain('source={option.leadingMedia}');
|
|
111
128
|
});
|
|
129
|
+
|
|
130
|
+
test('Select exposes searchable controlled props through its public contract', () => {
|
|
131
|
+
const props: SelectProps = {
|
|
132
|
+
options: [{ label: 'Repository', value: 'repository' }],
|
|
133
|
+
searchable: true,
|
|
134
|
+
searchValue: 'repo',
|
|
135
|
+
onSearchChange: () => undefined,
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
expect(props.searchable).toBe(true);
|
|
139
|
+
expect(props.searchValue).toBe('repo');
|
|
140
|
+
expect(props.onSearchChange).toBeDefined();
|
|
141
|
+
});
|
|
@@ -4,7 +4,7 @@ export const selectMeta = {
|
|
|
4
4
|
name: 'Select',
|
|
5
5
|
category: 'component',
|
|
6
6
|
description:
|
|
7
|
-
'Single-value form selection with Popover presentation on web and BottomSheet presentation on native.',
|
|
7
|
+
'Single-value form selection with optional searchable options, Popover presentation on web, and BottomSheet presentation on native.',
|
|
8
8
|
directManifestNode: true,
|
|
9
9
|
allowedChildren: [],
|
|
10
10
|
blueprint: {
|
|
@@ -21,6 +21,7 @@ export const selectMeta = {
|
|
|
21
21
|
disabled: false,
|
|
22
22
|
readOnly: false,
|
|
23
23
|
invalid: false,
|
|
24
|
+
searchable: false,
|
|
24
25
|
},
|
|
25
26
|
},
|
|
26
27
|
bindings: {
|
|
@@ -39,6 +40,35 @@ export const selectMeta = {
|
|
|
39
40
|
acceptsFallback: true,
|
|
40
41
|
acceptsTransforms: true,
|
|
41
42
|
},
|
|
43
|
+
options: {
|
|
44
|
+
label: 'Options',
|
|
45
|
+
description: 'Reactive serializable options rendered by the select.',
|
|
46
|
+
value: {
|
|
47
|
+
type: 'array',
|
|
48
|
+
itemType: 'object',
|
|
49
|
+
fields: [
|
|
50
|
+
{ path: '[].value', type: 'string', label: 'Value' },
|
|
51
|
+
{ path: '[].label', type: 'string', label: 'Label' },
|
|
52
|
+
{ path: '[].disabled', type: 'boolean', label: 'Disabled' },
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
acceptsFallback: true,
|
|
56
|
+
acceptsTransforms: true,
|
|
57
|
+
},
|
|
58
|
+
searchValue: {
|
|
59
|
+
label: 'Search value',
|
|
60
|
+
description: 'Current query for the searchable option list.',
|
|
61
|
+
value: { type: 'string' },
|
|
62
|
+
acceptsFallback: true,
|
|
63
|
+
acceptsTransforms: true,
|
|
64
|
+
},
|
|
65
|
+
searchable: {
|
|
66
|
+
label: 'Searchable',
|
|
67
|
+
description: 'Whether the option list exposes a search control.',
|
|
68
|
+
value: { type: 'boolean' },
|
|
69
|
+
acceptsFallback: true,
|
|
70
|
+
acceptsTransforms: true,
|
|
71
|
+
},
|
|
42
72
|
},
|
|
43
73
|
events: {
|
|
44
74
|
valueChange: {
|
|
@@ -49,6 +79,14 @@ export const selectMeta = {
|
|
|
49
79
|
fields: [{ path: 'value', type: 'string', label: 'Value' }],
|
|
50
80
|
},
|
|
51
81
|
},
|
|
82
|
+
searchChange: {
|
|
83
|
+
label: 'Search change',
|
|
84
|
+
description: 'Runs when the searchable option query changes.',
|
|
85
|
+
payload: {
|
|
86
|
+
eventType: 'select.searchChange',
|
|
87
|
+
fields: [{ path: 'value', type: 'string', label: 'Value' }],
|
|
88
|
+
},
|
|
89
|
+
},
|
|
52
90
|
},
|
|
53
91
|
},
|
|
54
92
|
events: {
|
|
@@ -58,6 +96,12 @@ export const selectMeta = {
|
|
|
58
96
|
description: 'Emitted when the selected option value changes.',
|
|
59
97
|
payloadFields: [{ path: 'value', type: 'string', label: 'Value' }],
|
|
60
98
|
},
|
|
99
|
+
searchChange: {
|
|
100
|
+
label: 'Search change',
|
|
101
|
+
eventType: 'select.searchChange',
|
|
102
|
+
description: 'Emitted when the searchable option query changes.',
|
|
103
|
+
payloadFields: [{ path: 'value', type: 'string', label: 'Value' }],
|
|
104
|
+
},
|
|
61
105
|
},
|
|
62
106
|
props: {
|
|
63
107
|
defaultValue: {
|
|
@@ -106,6 +150,32 @@ export const selectMeta = {
|
|
|
106
150
|
],
|
|
107
151
|
authoring: { authority: 'instance' },
|
|
108
152
|
},
|
|
153
|
+
searchable: {
|
|
154
|
+
type: 'boolean',
|
|
155
|
+
category: 'Behavior',
|
|
156
|
+
label: 'Searchable',
|
|
157
|
+
default: false,
|
|
158
|
+
authoring: { authority: 'instance' },
|
|
159
|
+
},
|
|
160
|
+
defaultSearchValue: {
|
|
161
|
+
type: 'string',
|
|
162
|
+
category: 'State',
|
|
163
|
+
label: 'Initial search value',
|
|
164
|
+
authoring: { authority: 'instance' },
|
|
165
|
+
},
|
|
166
|
+
searchValue: {
|
|
167
|
+
type: 'string',
|
|
168
|
+
category: 'State',
|
|
169
|
+
label: 'Search value',
|
|
170
|
+
authoring: { authority: 'instance' },
|
|
171
|
+
},
|
|
172
|
+
searchPlaceholder: {
|
|
173
|
+
type: 'string',
|
|
174
|
+
category: 'Content',
|
|
175
|
+
label: 'Search placeholder',
|
|
176
|
+
default: 'Search options',
|
|
177
|
+
authoring: { authority: 'instance' },
|
|
178
|
+
},
|
|
109
179
|
label: {
|
|
110
180
|
type: 'string',
|
|
111
181
|
category: 'Content',
|
|
@@ -23,6 +23,12 @@ describe('ZORA bindable component metadata', () => {
|
|
|
23
23
|
expect(select.directManifestNode).toBe(true);
|
|
24
24
|
expect(select.directManifestNode).toBe(ZORA_COMPONENT_META.Select.directManifestNode);
|
|
25
25
|
expect(select.bindings.events.valueChange.payload.eventType).toBe('select.valueChange');
|
|
26
|
+
expect(select.bindings.props.options.value).toMatchObject({
|
|
27
|
+
type: 'array',
|
|
28
|
+
itemType: 'object',
|
|
29
|
+
});
|
|
30
|
+
expect(select.bindings.props.searchValue.value.type).toBe('string');
|
|
31
|
+
expect(select.bindings.events.searchChange.payload.eventType).toBe('select.searchChange');
|
|
26
32
|
});
|
|
27
33
|
|
|
28
34
|
it('does not duplicate controlled component event ownership', () => {
|
|
@@ -177,7 +177,7 @@ export const ZORA_BINDABLE_COMPONENT_META = {
|
|
|
177
177
|
Select: {
|
|
178
178
|
name: 'Select',
|
|
179
179
|
category: 'component',
|
|
180
|
-
description: 'Captures one selected string value.',
|
|
180
|
+
description: 'Captures one selected string value with optional searchable options.',
|
|
181
181
|
directManifestNode: true,
|
|
182
182
|
allowedChildren: [],
|
|
183
183
|
bindings: {
|
|
@@ -196,6 +196,35 @@ export const ZORA_BINDABLE_COMPONENT_META = {
|
|
|
196
196
|
acceptsFallback: true,
|
|
197
197
|
acceptsTransforms: true,
|
|
198
198
|
},
|
|
199
|
+
options: {
|
|
200
|
+
label: 'Options',
|
|
201
|
+
description: 'Reactive serializable options rendered by the select.',
|
|
202
|
+
value: {
|
|
203
|
+
type: 'array',
|
|
204
|
+
itemType: 'object',
|
|
205
|
+
fields: [
|
|
206
|
+
{ path: '[].value', type: 'string', label: 'Value' },
|
|
207
|
+
{ path: '[].label', type: 'string', label: 'Label' },
|
|
208
|
+
{ path: '[].disabled', type: 'boolean', label: 'Disabled' },
|
|
209
|
+
],
|
|
210
|
+
},
|
|
211
|
+
acceptsFallback: true,
|
|
212
|
+
acceptsTransforms: true,
|
|
213
|
+
},
|
|
214
|
+
searchValue: {
|
|
215
|
+
label: 'Search value',
|
|
216
|
+
description: 'Current query for the searchable option list.',
|
|
217
|
+
value: { type: 'string' },
|
|
218
|
+
acceptsFallback: true,
|
|
219
|
+
acceptsTransforms: true,
|
|
220
|
+
},
|
|
221
|
+
searchable: {
|
|
222
|
+
label: 'Searchable',
|
|
223
|
+
description: 'Whether the option list exposes a search control.',
|
|
224
|
+
value: { type: 'boolean' },
|
|
225
|
+
acceptsFallback: true,
|
|
226
|
+
acceptsTransforms: true,
|
|
227
|
+
},
|
|
199
228
|
},
|
|
200
229
|
events: {
|
|
201
230
|
valueChange: {
|
|
@@ -206,6 +235,14 @@ export const ZORA_BINDABLE_COMPONENT_META = {
|
|
|
206
235
|
fields: [{ path: 'value', type: 'string', label: 'Value' }],
|
|
207
236
|
},
|
|
208
237
|
},
|
|
238
|
+
searchChange: {
|
|
239
|
+
label: 'Search change',
|
|
240
|
+
description: 'Runs when the searchable option query changes.',
|
|
241
|
+
payload: {
|
|
242
|
+
eventType: 'select.searchChange',
|
|
243
|
+
fields: [{ path: 'value', type: 'string', label: 'Value' }],
|
|
244
|
+
},
|
|
245
|
+
},
|
|
209
246
|
},
|
|
210
247
|
},
|
|
211
248
|
events: {
|
|
@@ -215,6 +252,12 @@ export const ZORA_BINDABLE_COMPONENT_META = {
|
|
|
215
252
|
description: 'Emitted when the selected value changes.',
|
|
216
253
|
payloadFields: [{ path: 'value', type: 'string', label: 'Value' }],
|
|
217
254
|
},
|
|
255
|
+
searchChange: {
|
|
256
|
+
label: 'Search change',
|
|
257
|
+
eventType: 'select.searchChange',
|
|
258
|
+
description: 'Emitted when the searchable option query changes.',
|
|
259
|
+
payloadFields: [{ path: 'value', type: 'string', label: 'Value' }],
|
|
260
|
+
},
|
|
218
261
|
},
|
|
219
262
|
props: {
|
|
220
263
|
inverted: INVERTED_POLARITY_PROP,
|
|
@@ -228,6 +271,21 @@ export const ZORA_BINDABLE_COMPONENT_META = {
|
|
|
228
271
|
category: 'State',
|
|
229
272
|
label: 'Disabled',
|
|
230
273
|
},
|
|
274
|
+
options: {
|
|
275
|
+
type: 'array',
|
|
276
|
+
category: 'Content',
|
|
277
|
+
label: 'Options',
|
|
278
|
+
},
|
|
279
|
+
searchable: {
|
|
280
|
+
type: 'boolean',
|
|
281
|
+
category: 'Behavior',
|
|
282
|
+
label: 'Searchable',
|
|
283
|
+
},
|
|
284
|
+
searchValue: {
|
|
285
|
+
type: 'string',
|
|
286
|
+
category: 'State',
|
|
287
|
+
label: 'Search value',
|
|
288
|
+
},
|
|
231
289
|
},
|
|
232
290
|
},
|
|
233
291
|
Checkbox: {
|
|
@@ -77,6 +77,16 @@ test('final ownership form and tab components retain bindings in core metadata',
|
|
|
77
77
|
expect(meta.Tabs?.bindings?.events?.valueChange?.payload?.eventType).toBe('tabs.valueChange');
|
|
78
78
|
});
|
|
79
79
|
|
|
80
|
+
test('Select retains reactive options and searchable manifest bindings', () => {
|
|
81
|
+
const select = ZORA_COMPONENT_META.Select;
|
|
82
|
+
expect(select?.bindings?.props?.options?.value).toMatchObject({
|
|
83
|
+
type: 'array',
|
|
84
|
+
itemType: 'object',
|
|
85
|
+
});
|
|
86
|
+
expect(select?.bindings?.props?.searchValue?.value.type).toBe('string');
|
|
87
|
+
expect(select?.bindings?.events?.searchChange?.payload?.eventType).toBe('select.searchChange');
|
|
88
|
+
});
|
|
89
|
+
|
|
80
90
|
test('existing scalar authoring bindings remain available in core metadata', () => {
|
|
81
91
|
const meta = ZORA_COMPONENT_META;
|
|
82
92
|
expect(meta.Heading?.bindings?.props?.level?.value.type).toBe('number');
|
package/src/types/select.ts
CHANGED
|
@@ -16,6 +16,16 @@ export interface SelectProps<TValue extends string = string> extends ZoraBasePro
|
|
|
16
16
|
defaultValue?: TValue;
|
|
17
17
|
options: readonly SelectOption<TValue>[];
|
|
18
18
|
onValueChange?: (value: TValue) => void;
|
|
19
|
+
/** Enables an inline search control that filters the currently supplied options. */
|
|
20
|
+
searchable?: boolean;
|
|
21
|
+
/** Controlled query for the optional inline search control. */
|
|
22
|
+
searchValue?: string;
|
|
23
|
+
/** Initial query when the optional inline search control is uncontrolled. */
|
|
24
|
+
defaultSearchValue?: string;
|
|
25
|
+
/** Proposes an updated search query for local filtering or remote discovery. */
|
|
26
|
+
onSearchChange?: (value: string) => void;
|
|
27
|
+
/** Placeholder rendered by the optional inline search control. */
|
|
28
|
+
searchPlaceholder?: string;
|
|
19
29
|
label?: string;
|
|
20
30
|
helperText?: string;
|
|
21
31
|
errorText?: string;
|
|
@@ -29,6 +29,9 @@ import {
|
|
|
29
29
|
import {
|
|
30
30
|
Text3
|
|
31
31
|
} from "./Accordion-8skz71ct.js";
|
|
32
|
+
import {
|
|
33
|
+
SearchInput2
|
|
34
|
+
} from "./Accordion-ar8qe05j.js";
|
|
32
35
|
import {
|
|
33
36
|
useZoraTheme2
|
|
34
37
|
} from "./Accordion-b1y5mjac.js";
|
|
@@ -118,8 +121,32 @@ function SelectOptionRow({
|
|
|
118
121
|
});
|
|
119
122
|
}
|
|
120
123
|
|
|
124
|
+
// src/features/form/select/composition/SelectSearchInput.tsx
|
|
125
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
126
|
+
function SelectSearchInput({
|
|
127
|
+
onSearchChange,
|
|
128
|
+
props,
|
|
129
|
+
searchValue
|
|
130
|
+
}) {
|
|
131
|
+
if (!props.searchable)
|
|
132
|
+
return null;
|
|
133
|
+
return /* @__PURE__ */ jsx3(View2, {
|
|
134
|
+
pb: "xs",
|
|
135
|
+
children: /* @__PURE__ */ jsx3(SearchInput2, {
|
|
136
|
+
disabled: props.disabled,
|
|
137
|
+
interactionPolicy: props.interactionPolicy,
|
|
138
|
+
onValueChange: onSearchChange,
|
|
139
|
+
placeholder: props.searchPlaceholder ?? "Search options",
|
|
140
|
+
readOnly: props.readOnly,
|
|
141
|
+
size: "m",
|
|
142
|
+
testID: props.testID ? `${props.testID}-search` : undefined,
|
|
143
|
+
value: searchValue
|
|
144
|
+
})
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
121
148
|
// src/features/form/select/composition/SelectTrigger.tsx
|
|
122
|
-
import { jsx as
|
|
149
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
123
150
|
var SELECT_CHEVRON_ICON = { name: "chevron-down" };
|
|
124
151
|
function SelectTrigger({
|
|
125
152
|
displayLabel,
|
|
@@ -130,7 +157,7 @@ function SelectTrigger({
|
|
|
130
157
|
const { theme } = useZoraTheme2();
|
|
131
158
|
const media = leadingMedia ?? props.leadingMedia;
|
|
132
159
|
if (media) {
|
|
133
|
-
return /* @__PURE__ */
|
|
160
|
+
return /* @__PURE__ */ jsx4(Pressable, {
|
|
134
161
|
accessibilityLabel: displayLabel ?? props.placeholder ?? "Select",
|
|
135
162
|
disabled: props.disabled,
|
|
136
163
|
interactionPolicy: props.interactionPolicy,
|
|
@@ -148,16 +175,16 @@ function SelectTrigger({
|
|
|
148
175
|
px: "m",
|
|
149
176
|
radius: "m",
|
|
150
177
|
children: [
|
|
151
|
-
/* @__PURE__ */
|
|
178
|
+
/* @__PURE__ */ jsx4(Image2, {
|
|
152
179
|
alt: "",
|
|
153
180
|
height: 28,
|
|
154
181
|
radius: "s",
|
|
155
182
|
source: media,
|
|
156
183
|
width: 28
|
|
157
184
|
}),
|
|
158
|
-
/* @__PURE__ */
|
|
185
|
+
/* @__PURE__ */ jsx4(View2, {
|
|
159
186
|
flex: 1,
|
|
160
|
-
children: /* @__PURE__ */
|
|
187
|
+
children: /* @__PURE__ */ jsx4(Text3, {
|
|
161
188
|
emphasis: displayLabel ? "default" : "muted",
|
|
162
189
|
numberOfLines: 1,
|
|
163
190
|
variant: "label",
|
|
@@ -165,7 +192,7 @@ function SelectTrigger({
|
|
|
165
192
|
children: displayLabel ?? props.placeholder ?? "Select"
|
|
166
193
|
})
|
|
167
194
|
}),
|
|
168
|
-
/* @__PURE__ */
|
|
195
|
+
/* @__PURE__ */ jsx4(Icon2, {
|
|
169
196
|
name: "chevron-down",
|
|
170
197
|
size: 18
|
|
171
198
|
})
|
|
@@ -173,7 +200,7 @@ function SelectTrigger({
|
|
|
173
200
|
})
|
|
174
201
|
});
|
|
175
202
|
}
|
|
176
|
-
return /* @__PURE__ */
|
|
203
|
+
return /* @__PURE__ */ jsx4(Button3, {
|
|
177
204
|
color: props.invalid ? "danger" : "neutral",
|
|
178
205
|
disabled: props.disabled,
|
|
179
206
|
fullWidth: true,
|
|
@@ -191,21 +218,47 @@ function SelectTrigger({
|
|
|
191
218
|
|
|
192
219
|
// src/features/form/select/composition/useSelectController.ts
|
|
193
220
|
import React from "react";
|
|
221
|
+
|
|
222
|
+
// src/features/form/select/composition/getVisibleSelectOptions.ts
|
|
223
|
+
function getVisibleSelectOptions(options, searchable, searchValue) {
|
|
224
|
+
const query = searchValue.trim().toLocaleLowerCase();
|
|
225
|
+
if (!searchable || query.length === 0)
|
|
226
|
+
return options;
|
|
227
|
+
return options.filter((option) => option.label.toLocaleLowerCase().includes(query));
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// src/features/form/select/composition/useSelectController.ts
|
|
194
231
|
function useSelectController(props) {
|
|
195
|
-
const {
|
|
232
|
+
const {
|
|
233
|
+
defaultSearchValue,
|
|
234
|
+
defaultValue,
|
|
235
|
+
onSearchChange,
|
|
236
|
+
onValueChange,
|
|
237
|
+
options,
|
|
238
|
+
searchValue: controlledSearchValue,
|
|
239
|
+
value: controlledValue
|
|
240
|
+
} = props;
|
|
196
241
|
const [localValue, setLocalValue] = React.useState(defaultValue);
|
|
242
|
+
const [localSearchValue, setLocalSearchValue] = React.useState(defaultSearchValue ?? "");
|
|
197
243
|
const value = controlledValue ?? localValue;
|
|
244
|
+
const searchValue = controlledSearchValue ?? localSearchValue;
|
|
198
245
|
const selectedOption = options.find((option) => option.value === value);
|
|
246
|
+
const visibleOptions = React.useMemo(() => getVisibleSelectOptions(options, props.searchable, searchValue), [options, props.searchable, searchValue]);
|
|
199
247
|
const select = React.useCallback((nextValue) => {
|
|
200
248
|
if (controlledValue === undefined)
|
|
201
249
|
setLocalValue(nextValue);
|
|
202
250
|
onValueChange?.(nextValue);
|
|
203
251
|
}, [controlledValue, onValueChange]);
|
|
204
|
-
|
|
252
|
+
const search = React.useCallback((nextValue) => {
|
|
253
|
+
if (controlledSearchValue === undefined)
|
|
254
|
+
setLocalSearchValue(nextValue);
|
|
255
|
+
onSearchChange?.(nextValue);
|
|
256
|
+
}, [controlledSearchValue, onSearchChange]);
|
|
257
|
+
return { search, searchValue, select, selectedOption, value, visibleOptions };
|
|
205
258
|
}
|
|
206
259
|
|
|
207
260
|
// src/features/form/select/adapters/inbound/Select.web.tsx
|
|
208
|
-
import { jsx as
|
|
261
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
209
262
|
var Select2 = withZoraThemeScope(SelectInner);
|
|
210
263
|
function SelectInner({
|
|
211
264
|
themeId: _themeId,
|
|
@@ -213,16 +266,16 @@ function SelectInner({
|
|
|
213
266
|
...props
|
|
214
267
|
}) {
|
|
215
268
|
const [open, setOpen] = React2.useState(false);
|
|
216
|
-
const { select, selectedOption, value } = useSelectController(props);
|
|
217
|
-
const { interactionPolicy,
|
|
269
|
+
const { search, searchValue, select, selectedOption, value, visibleOptions } = useSelectController(props);
|
|
270
|
+
const { interactionPolicy, testID } = props;
|
|
218
271
|
const selectAndClose = React2.useCallback((nextValue) => {
|
|
219
272
|
select(nextValue);
|
|
220
273
|
setOpen(false);
|
|
221
274
|
}, [select]);
|
|
222
|
-
return /* @__PURE__ */
|
|
275
|
+
return /* @__PURE__ */ jsx5(SelectField, {
|
|
223
276
|
props,
|
|
224
|
-
children: /* @__PURE__ */
|
|
225
|
-
anchor: ({ toggle }) => /* @__PURE__ */
|
|
277
|
+
children: /* @__PURE__ */ jsx5(Popover2, {
|
|
278
|
+
anchor: ({ toggle }) => /* @__PURE__ */ jsx5(SelectTrigger, {
|
|
226
279
|
displayLabel: selectedOption?.label,
|
|
227
280
|
leadingMedia: selectedOption?.leadingMedia,
|
|
228
281
|
onPress: toggle,
|
|
@@ -233,18 +286,25 @@ function SelectInner({
|
|
|
233
286
|
open,
|
|
234
287
|
placement: "bottom-start",
|
|
235
288
|
testID: testID ? `${testID}-popover` : undefined,
|
|
236
|
-
children: /* @__PURE__ */
|
|
289
|
+
children: /* @__PURE__ */ jsx5(Surface2, {
|
|
237
290
|
variant: "raised",
|
|
238
|
-
children: /* @__PURE__ */
|
|
291
|
+
children: /* @__PURE__ */ jsxs3(View2, {
|
|
239
292
|
gap: "xs",
|
|
240
293
|
p: "xs",
|
|
241
|
-
children:
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
294
|
+
children: [
|
|
295
|
+
/* @__PURE__ */ jsx5(SelectSearchInput, {
|
|
296
|
+
onSearchChange: search,
|
|
297
|
+
props,
|
|
298
|
+
searchValue
|
|
299
|
+
}),
|
|
300
|
+
visibleOptions.map((option) => /* @__PURE__ */ jsx5(SelectOptionRow, {
|
|
301
|
+
interactionPolicy,
|
|
302
|
+
onSelect: selectAndClose,
|
|
303
|
+
option,
|
|
304
|
+
selected: value === option.value,
|
|
305
|
+
testID
|
|
306
|
+
}, option.value))
|
|
307
|
+
]
|
|
248
308
|
})
|
|
249
309
|
})
|
|
250
310
|
})
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import {
|
|
3
|
+
withZoraThemeScope
|
|
4
|
+
} from "./Accordion-tk8zf9ff.js";
|
|
5
|
+
import {
|
|
6
|
+
TextInput3
|
|
7
|
+
} from "./Accordion-xhxv2v0g.js";
|
|
8
|
+
|
|
9
|
+
// src/features/form/search-input/adapters/inbound/SearchInput.tsx
|
|
10
|
+
import { jsx } from "react/jsx-runtime";
|
|
11
|
+
var SearchInput2 = withZoraThemeScope(SearchInputInner);
|
|
12
|
+
function SearchInputInner({
|
|
13
|
+
themeId: _themeId,
|
|
14
|
+
mode: _mode,
|
|
15
|
+
testID,
|
|
16
|
+
value = "",
|
|
17
|
+
onValueChange,
|
|
18
|
+
placeholder = "Search",
|
|
19
|
+
onSubmit,
|
|
20
|
+
onClear,
|
|
21
|
+
clearable = true,
|
|
22
|
+
size = "l",
|
|
23
|
+
disabled,
|
|
24
|
+
readOnly,
|
|
25
|
+
interactionPolicy
|
|
26
|
+
}) {
|
|
27
|
+
const passive = interactionPolicy === "passive";
|
|
28
|
+
const trailingAction = clearable && value.length > 0 ? {
|
|
29
|
+
icon: { name: "close-circle" },
|
|
30
|
+
label: "Clear search",
|
|
31
|
+
onPress: () => {
|
|
32
|
+
if (passive)
|
|
33
|
+
return;
|
|
34
|
+
onValueChange?.("");
|
|
35
|
+
onClear?.();
|
|
36
|
+
}
|
|
37
|
+
} : undefined;
|
|
38
|
+
return /* @__PURE__ */ jsx(TextInput3, {
|
|
39
|
+
disabled,
|
|
40
|
+
interactionPolicy,
|
|
41
|
+
leadingIcon: { name: "search-outline" },
|
|
42
|
+
onChangeText: onValueChange,
|
|
43
|
+
onSubmitEditing: onSubmit ? passive ? undefined : () => onSubmit(value) : undefined,
|
|
44
|
+
placeholder,
|
|
45
|
+
readOnly,
|
|
46
|
+
returnKeyType: "search",
|
|
47
|
+
size,
|
|
48
|
+
testID,
|
|
49
|
+
trailingAction,
|
|
50
|
+
value
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
export { SearchInput2 };
|
|
@@ -29,8 +29,8 @@ import {
|
|
|
29
29
|
Field2
|
|
30
30
|
} from "./Accordion-gs838h0n.js";
|
|
31
31
|
import {
|
|
32
|
-
|
|
33
|
-
} from "./Accordion-
|
|
32
|
+
TextInput3
|
|
33
|
+
} from "./Accordion-xhxv2v0g.js";
|
|
34
34
|
import {
|
|
35
35
|
require_cjs
|
|
36
36
|
} from "./Accordion-xgpzh4wq.js";
|
|
@@ -267,7 +267,7 @@ function AuthFormField({
|
|
|
267
267
|
readOnly: field.readOnly,
|
|
268
268
|
required: field.required ?? hasRequiredRule(field.rules),
|
|
269
269
|
testID: field.testID,
|
|
270
|
-
children: /* @__PURE__ */ jsx3(
|
|
270
|
+
children: /* @__PURE__ */ jsx3(TextInput3, {
|
|
271
271
|
accessibilityLabel: typeof field.label === "string" ? field.label : undefined,
|
|
272
272
|
autoCapitalize: field.autoCapitalize ?? (["email", "password", "url"].includes(field.type ?? "text") ? "none" : undefined),
|
|
273
273
|
autoComplete: field.autoComplete,
|
|
@@ -27,8 +27,8 @@ import {
|
|
|
27
27
|
writeClipboardTextAsync
|
|
28
28
|
} from "./Accordion-chdbfcm6.js";
|
|
29
29
|
import {
|
|
30
|
-
|
|
31
|
-
} from "./Accordion-
|
|
30
|
+
TextInput2
|
|
31
|
+
} from "./Accordion-xhxv2v0g.js";
|
|
32
32
|
import {
|
|
33
33
|
Button2,
|
|
34
34
|
Circle,
|
|
@@ -51,7 +51,7 @@ import {
|
|
|
51
51
|
} from "./Accordion-3zzzw7a8.js";
|
|
52
52
|
import {
|
|
53
53
|
Select2
|
|
54
|
-
} from "./Accordion-
|
|
54
|
+
} from "./Accordion-9dk62zn9.js";
|
|
55
55
|
import {
|
|
56
56
|
Gradient2
|
|
57
57
|
} from "./Accordion-zd15byha.js";
|
|
@@ -84,7 +84,7 @@ function ColorHexField({
|
|
|
84
84
|
}
|
|
85
85
|
return /* @__PURE__ */ jsxs(View2, {
|
|
86
86
|
children: [
|
|
87
|
-
/* @__PURE__ */ jsx(
|
|
87
|
+
/* @__PURE__ */ jsx(TextInput2, {
|
|
88
88
|
accessibilityLabel: "Color hex value",
|
|
89
89
|
disabled,
|
|
90
90
|
leadingAccessory: /* @__PURE__ */ jsx(View2, {
|