@joralvmel/cosmos-core 0.2.0 → 0.4.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/dist/catalog.d.ts +3 -3
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +25 -6
- package/dist/catalog.js.map +1 -1
- package/dist/codegen.d.ts +16 -0
- package/dist/codegen.d.ts.map +1 -1
- package/dist/codegen.js +396 -57
- package/dist/codegen.js.map +1 -1
- package/dist/headless/calendar.d.ts +32 -0
- package/dist/headless/calendar.d.ts.map +1 -0
- package/dist/headless/calendar.js +242 -0
- package/dist/headless/calendar.js.map +1 -0
- package/dist/headless/listbox.d.ts +9 -0
- package/dist/headless/listbox.d.ts.map +1 -0
- package/dist/headless/listbox.js +103 -0
- package/dist/headless/listbox.js.map +1 -0
- package/dist/headless/pagination.d.ts +34 -0
- package/dist/headless/pagination.d.ts.map +1 -0
- package/dist/headless/pagination.js +92 -0
- package/dist/headless/pagination.js.map +1 -0
- package/dist/headless/radio-group.d.ts +10 -0
- package/dist/headless/radio-group.d.ts.map +1 -0
- package/dist/headless/radio-group.js +59 -0
- package/dist/headless/radio-group.js.map +1 -0
- package/dist/headless/select.d.ts +4 -0
- package/dist/headless/select.d.ts.map +1 -0
- package/dist/headless/select.js +7 -0
- package/dist/headless/select.js.map +1 -0
- package/dist/headless/size.d.ts +3 -0
- package/dist/headless/size.d.ts.map +1 -0
- package/dist/headless/size.js +7 -0
- package/dist/headless/size.js.map +1 -0
- package/dist/headless/text-field.d.ts +25 -0
- package/dist/headless/text-field.d.ts.map +1 -0
- package/dist/headless/text-field.js +12 -0
- package/dist/headless/text-field.js.map +1 -0
- package/dist/index.d.ts +1709 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +60 -1
- package/dist/index.js.map +1 -1
- package/dist/markdown.d.ts.map +1 -1
- package/dist/markdown.js +7 -3
- package/dist/markdown.js.map +1 -1
- package/dist/specs/badge.d.ts +65 -0
- package/dist/specs/badge.d.ts.map +1 -0
- package/dist/specs/badge.js +64 -0
- package/dist/specs/badge.js.map +1 -0
- package/dist/specs/badge.scenarios.d.ts +21 -0
- package/dist/specs/badge.scenarios.d.ts.map +1 -0
- package/dist/specs/badge.scenarios.js +35 -0
- package/dist/specs/badge.scenarios.js.map +1 -0
- package/dist/specs/calendar.d.ts +120 -0
- package/dist/specs/calendar.d.ts.map +1 -0
- package/dist/specs/calendar.js +121 -0
- package/dist/specs/calendar.js.map +1 -0
- package/dist/specs/calendar.scenarios.d.ts +39 -0
- package/dist/specs/calendar.scenarios.d.ts.map +1 -0
- package/dist/specs/calendar.scenarios.js +139 -0
- package/dist/specs/calendar.scenarios.js.map +1 -0
- package/dist/specs/checkbox.d.ts +139 -0
- package/dist/specs/checkbox.d.ts.map +1 -0
- package/dist/specs/checkbox.js +129 -0
- package/dist/specs/checkbox.js.map +1 -0
- package/dist/specs/checkbox.scenarios.d.ts +28 -0
- package/dist/specs/checkbox.scenarios.d.ts.map +1 -0
- package/dist/specs/checkbox.scenarios.js +54 -0
- package/dist/specs/checkbox.scenarios.js.map +1 -0
- package/dist/specs/dialog.d.ts +167 -0
- package/dist/specs/dialog.d.ts.map +1 -0
- package/dist/specs/dialog.js +136 -0
- package/dist/specs/dialog.js.map +1 -0
- package/dist/specs/dialog.scenarios.d.ts +42 -0
- package/dist/specs/dialog.scenarios.d.ts.map +1 -0
- package/dist/specs/dialog.scenarios.js +129 -0
- package/dist/specs/dialog.scenarios.js.map +1 -0
- package/dist/specs/icon-button.d.ts +136 -0
- package/dist/specs/icon-button.d.ts.map +1 -0
- package/dist/specs/icon-button.js +119 -0
- package/dist/specs/icon-button.js.map +1 -0
- package/dist/specs/icon-button.scenarios.d.ts +28 -0
- package/dist/specs/icon-button.scenarios.d.ts.map +1 -0
- package/dist/specs/icon-button.scenarios.js +95 -0
- package/dist/specs/icon-button.scenarios.js.map +1 -0
- package/dist/specs/icon.d.ts +11 -20
- package/dist/specs/icon.d.ts.map +1 -1
- package/dist/specs/icon.js +11 -20
- package/dist/specs/icon.js.map +1 -1
- package/dist/specs/icon.scenarios.d.ts +9 -1
- package/dist/specs/icon.scenarios.d.ts.map +1 -1
- package/dist/specs/icon.scenarios.js +70 -6
- package/dist/specs/icon.scenarios.js.map +1 -1
- package/dist/specs/listbox.d.ts +157 -0
- package/dist/specs/listbox.d.ts.map +1 -0
- package/dist/specs/listbox.js +144 -0
- package/dist/specs/listbox.js.map +1 -0
- package/dist/specs/listbox.scenarios.d.ts +37 -0
- package/dist/specs/listbox.scenarios.d.ts.map +1 -0
- package/dist/specs/listbox.scenarios.js +110 -0
- package/dist/specs/listbox.scenarios.js.map +1 -0
- package/dist/specs/pagination.d.ts +147 -0
- package/dist/specs/pagination.d.ts.map +1 -0
- package/dist/specs/pagination.js +122 -0
- package/dist/specs/pagination.js.map +1 -0
- package/dist/specs/pagination.scenarios.d.ts +15 -0
- package/dist/specs/pagination.scenarios.d.ts.map +1 -0
- package/dist/specs/pagination.scenarios.js +29 -0
- package/dist/specs/pagination.scenarios.js.map +1 -0
- package/dist/specs/popover.d.ts +201 -0
- package/dist/specs/popover.d.ts.map +1 -0
- package/dist/specs/popover.js +169 -0
- package/dist/specs/popover.js.map +1 -0
- package/dist/specs/popover.scenarios.d.ts +83 -0
- package/dist/specs/popover.scenarios.d.ts.map +1 -0
- package/dist/specs/popover.scenarios.js +368 -0
- package/dist/specs/popover.scenarios.js.map +1 -0
- package/dist/specs/radio-group.d.ts +154 -0
- package/dist/specs/radio-group.d.ts.map +1 -0
- package/dist/specs/radio-group.js +133 -0
- package/dist/specs/radio-group.js.map +1 -0
- package/dist/specs/radio-group.scenarios.d.ts +35 -0
- package/dist/specs/radio-group.scenarios.d.ts.map +1 -0
- package/dist/specs/radio-group.scenarios.js +67 -0
- package/dist/specs/radio-group.scenarios.js.map +1 -0
- package/dist/specs/select.d.ts +167 -0
- package/dist/specs/select.d.ts.map +1 -0
- package/dist/specs/select.js +148 -0
- package/dist/specs/select.js.map +1 -0
- package/dist/specs/select.scenarios.d.ts +37 -0
- package/dist/specs/select.scenarios.d.ts.map +1 -0
- package/dist/specs/select.scenarios.js +77 -0
- package/dist/specs/select.scenarios.js.map +1 -0
- package/dist/specs/switch.d.ts +123 -0
- package/dist/specs/switch.d.ts.map +1 -0
- package/dist/specs/switch.js +113 -0
- package/dist/specs/switch.js.map +1 -0
- package/dist/specs/switch.scenarios.d.ts +27 -0
- package/dist/specs/switch.scenarios.d.ts.map +1 -0
- package/dist/specs/switch.scenarios.js +54 -0
- package/dist/specs/switch.scenarios.js.map +1 -0
- package/dist/specs/text-field.d.ts +232 -0
- package/dist/specs/text-field.d.ts.map +1 -0
- package/dist/specs/text-field.js +220 -0
- package/dist/specs/text-field.js.map +1 -0
- package/dist/specs/text-field.scenarios.d.ts +52 -0
- package/dist/specs/text-field.scenarios.d.ts.map +1 -0
- package/dist/specs/text-field.scenarios.js +106 -0
- package/dist/specs/text-field.scenarios.js.map +1 -0
- package/dist/specs/textarea.d.ts +144 -0
- package/dist/specs/textarea.d.ts.map +1 -0
- package/dist/specs/textarea.js +134 -0
- package/dist/specs/textarea.js.map +1 -0
- package/dist/specs/textarea.scenarios.d.ts +33 -0
- package/dist/specs/textarea.scenarios.d.ts.map +1 -0
- package/dist/specs/textarea.scenarios.js +82 -0
- package/dist/specs/textarea.scenarios.js.map +1 -0
- package/llms.md +797 -6
- package/package.json +1 -1
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { defineContract } from '../contract.js';
|
|
2
|
+
/**
|
|
3
|
+
* A single-selection form control with optional selection and native Web form behavior.
|
|
4
|
+
*
|
|
5
|
+
* | State | Autonomous | Controlled | Event |
|
|
6
|
+
* | --- | --- | --- | --- |
|
|
7
|
+
* | value | Starts at defaultValue (null by default) and commits selection | A supplied value, including null, proposes changes without committing | change |
|
|
8
|
+
*/
|
|
9
|
+
export const radioGroupContract = defineContract({
|
|
10
|
+
name: 'radio-group',
|
|
11
|
+
tag: 'cosm-radio-group',
|
|
12
|
+
description: 'Selects one option from a labeled collection, with optional selection and native Web form behavior.',
|
|
13
|
+
role: 'radiogroup',
|
|
14
|
+
pattern: 'https://www.w3.org/WAI/ARIA/apg/patterns/radio/',
|
|
15
|
+
props: {
|
|
16
|
+
label: {
|
|
17
|
+
type: 'string',
|
|
18
|
+
required: true,
|
|
19
|
+
description: 'Required visible accessible name for the group.',
|
|
20
|
+
},
|
|
21
|
+
options: {
|
|
22
|
+
type: 'reference',
|
|
23
|
+
reference: 'RadioGroupOptions',
|
|
24
|
+
required: true,
|
|
25
|
+
options: ['contact-methods'],
|
|
26
|
+
example: 'contact-methods',
|
|
27
|
+
description: 'Readonly flat options with unique nonempty values and labels, optional descriptions and disabled states.',
|
|
28
|
+
},
|
|
29
|
+
value: {
|
|
30
|
+
type: 'reference',
|
|
31
|
+
reference: 'RadioGroupValue',
|
|
32
|
+
options: ['none', 'email', 'phone', 'basic', 'plus', 'premium', 'weekly', 'monthly'],
|
|
33
|
+
description: 'Controlled selected value; null means no selection, and a supplied null remains controlled.',
|
|
34
|
+
},
|
|
35
|
+
defaultValue: {
|
|
36
|
+
type: 'reference',
|
|
37
|
+
reference: 'RadioGroupValue',
|
|
38
|
+
options: ['none', 'email', 'phone', 'basic', 'plus', 'premium', 'weekly', 'monthly'],
|
|
39
|
+
description: 'Initial autonomous selection; null by default.',
|
|
40
|
+
},
|
|
41
|
+
size: {
|
|
42
|
+
type: 'enum',
|
|
43
|
+
values: ['sm', 'md', 'lg'],
|
|
44
|
+
default: 'md',
|
|
45
|
+
reflect: true,
|
|
46
|
+
description: 'Small, medium or large radio indicator.',
|
|
47
|
+
},
|
|
48
|
+
orientation: {
|
|
49
|
+
type: 'enum',
|
|
50
|
+
values: ['vertical', 'horizontal'],
|
|
51
|
+
default: 'vertical',
|
|
52
|
+
reflect: true,
|
|
53
|
+
description: 'Vertical list or wrapping horizontal options.',
|
|
54
|
+
},
|
|
55
|
+
disabled: {
|
|
56
|
+
type: 'boolean',
|
|
57
|
+
default: false,
|
|
58
|
+
reflect: true,
|
|
59
|
+
description: 'Prevents interaction and excludes the value from Web form submission.',
|
|
60
|
+
},
|
|
61
|
+
required: {
|
|
62
|
+
type: 'boolean',
|
|
63
|
+
default: false,
|
|
64
|
+
reflect: true,
|
|
65
|
+
description: 'Requires a selection in Web form validation; Native exposes descriptive semantics.',
|
|
66
|
+
},
|
|
67
|
+
invalid: {
|
|
68
|
+
type: 'boolean',
|
|
69
|
+
default: false,
|
|
70
|
+
reflect: true,
|
|
71
|
+
description: 'Externally supplied invalid presentation state when the visible error is supplied elsewhere.',
|
|
72
|
+
},
|
|
73
|
+
helperText: {
|
|
74
|
+
type: 'string',
|
|
75
|
+
description: 'Optional supporting text associated with the group.',
|
|
76
|
+
},
|
|
77
|
+
errorText: {
|
|
78
|
+
type: 'string',
|
|
79
|
+
description: 'Optional consumer-localized error text; a nonempty trimmed value also exposes invalid state.',
|
|
80
|
+
},
|
|
81
|
+
name: {
|
|
82
|
+
type: 'string',
|
|
83
|
+
reflect: true,
|
|
84
|
+
platforms: ['web', 'react', 'angular'],
|
|
85
|
+
description: 'Web form field name; React Native has no HTML form association.',
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
events: {
|
|
89
|
+
change: {
|
|
90
|
+
description: 'Proposes a selection after enabled user activation; autonomous state commits and controlled state waits for the owner.',
|
|
91
|
+
detail: 'RadioGroupChangeDetail',
|
|
92
|
+
names: {
|
|
93
|
+
dom: 'cosm-change',
|
|
94
|
+
react: 'onChange',
|
|
95
|
+
angular: 'valueChange',
|
|
96
|
+
native: 'onValueChange',
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
states: [{ prop: 'value', event: 'change', defaultProp: 'defaultValue' }],
|
|
101
|
+
slots: {},
|
|
102
|
+
parts: {
|
|
103
|
+
base: 'Group wrapper and accessible fieldset.',
|
|
104
|
+
label: 'Visible group label.',
|
|
105
|
+
options: 'Option collection.',
|
|
106
|
+
option: 'Selectable option row.',
|
|
107
|
+
input: 'Native radio input and Web focus target.',
|
|
108
|
+
control: 'Visible circular radio boundary.',
|
|
109
|
+
indicator: 'Selected radio dot.',
|
|
110
|
+
'option-label': 'Primary option text.',
|
|
111
|
+
description: 'Optional option description.',
|
|
112
|
+
'help-text': 'Supporting text associated with the group.',
|
|
113
|
+
'error-text': 'Error description associated with the group.',
|
|
114
|
+
},
|
|
115
|
+
cssProperties: {
|
|
116
|
+
'--cosm-radio-group-gap': 'Space between option rows.',
|
|
117
|
+
'--cosm-radio-group-option-gap': 'Space between the radio control and option content.',
|
|
118
|
+
'--cosm-radio-group-control-size': 'Diameter of the visible radio control.',
|
|
119
|
+
'--cosm-radio-group-border': 'Unchecked radio boundary color.',
|
|
120
|
+
'--cosm-radio-group-selected-border': 'Selected radio boundary color.',
|
|
121
|
+
'--cosm-radio-group-indicator': 'Selected radio dot color.',
|
|
122
|
+
'--cosm-radio-group-focus': 'Visible keyboard focus indicator color.',
|
|
123
|
+
},
|
|
124
|
+
keyboard: [
|
|
125
|
+
{ keys: ['Tab', 'Shift+Tab'], action: 'Enters or leaves the group as one tab stop.' },
|
|
126
|
+
{ keys: ['Space'], action: 'Selects the focused enabled option.' },
|
|
127
|
+
{
|
|
128
|
+
keys: ['ArrowRight', 'ArrowDown', 'ArrowLeft', 'ArrowUp'],
|
|
129
|
+
action: 'Moves focus and selection through enabled options with wrapping.',
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
});
|
|
133
|
+
//# sourceMappingURL=radio-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radio-group.js","sourceRoot":"","sources":["../../src/specs/radio-group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAqBhD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,cAAc,CAAC;IAC/C,IAAI,EAAE,aAAa;IACnB,GAAG,EAAE,kBAAkB;IACvB,WA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zD,YAAY,EAAE,8CAA8C;KAC7D;IACD,aAAa,EAAE;QACb,wBAAwB,EAAE,4BAA4B;QACtD,+BAA+B,EAAE,qDAAqD;QACtF,iCAAiC,EAAE,wCAAwC;QAC3E,2BAA2B,EAAE,iCAAiC;QAC9D,oCAAoC,EAAE,gCAAgC;QACtE,8BAA8B,EAAE,2BAA2B;QAC3D,0BAA0B,EAAE,yCAAyC;KACtE;IACD,QAAQ,EAAE;QACR,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,6CAA6C,EAAE;QACrF,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,qCAAqC,EAAE;QAClE;YACE,IAAI,EAAE,CAAC,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,CAAC;YACzD,MAAM,EAAE,kEAAkE;SAC3E;KACF;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Platform } from '../contract.js';
|
|
2
|
+
import type { RadioGroupOption, RadioGroupValue } from './radio-group.js';
|
|
3
|
+
export type RadioGroupAction = {
|
|
4
|
+
type: 'select';
|
|
5
|
+
value: string;
|
|
6
|
+
} | {
|
|
7
|
+
type: 'set-value';
|
|
8
|
+
value: RadioGroupValue;
|
|
9
|
+
};
|
|
10
|
+
export interface RadioGroupScenario {
|
|
11
|
+
name: string;
|
|
12
|
+
props: {
|
|
13
|
+
label?: string;
|
|
14
|
+
options?: readonly RadioGroupOption[];
|
|
15
|
+
value?: RadioGroupValue;
|
|
16
|
+
defaultValue?: RadioGroupValue;
|
|
17
|
+
orientation?: 'vertical' | 'horizontal';
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
required?: boolean;
|
|
20
|
+
invalid?: boolean;
|
|
21
|
+
helperText?: string;
|
|
22
|
+
errorText?: string;
|
|
23
|
+
name?: string;
|
|
24
|
+
};
|
|
25
|
+
actions: readonly RadioGroupAction[];
|
|
26
|
+
expected: {
|
|
27
|
+
value: RadioGroupValue;
|
|
28
|
+
changes: readonly RadioGroupValue[];
|
|
29
|
+
};
|
|
30
|
+
platforms?: readonly Platform[];
|
|
31
|
+
}
|
|
32
|
+
export declare const radioGroupScenarioOptions: readonly RadioGroupOption[];
|
|
33
|
+
export declare const radioGroupScenarios: readonly RadioGroupScenario[];
|
|
34
|
+
export declare const radioGroupScenariosFor: (platform: Platform) => RadioGroupScenario[];
|
|
35
|
+
//# sourceMappingURL=radio-group.scenarios.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radio-group.scenarios.d.ts","sourceRoot":"","sources":["../../src/specs/radio-group.scenarios.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAE1E,MAAM,MAAM,gBAAgB,GACxB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,eAAe,CAAA;CAAE,CAAC;AAElD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE;QACL,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAC;QACtC,KAAK,CAAC,EAAE,eAAe,CAAC;QACxB,YAAY,CAAC,EAAE,eAAe,CAAC;QAC/B,WAAW,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;QACxC,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;IACF,OAAO,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACrC,QAAQ,EAAE;QACR,KAAK,EAAE,eAAe,CAAC;QACvB,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;KACrC,CAAC;IACF,SAAS,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAC;CACjC;AAED,eAAO,MAAM,yBAAyB,EAAE,SAAS,gBAAgB,EAIhE,CAAC;AAIF,eAAO,MAAM,mBAAmB,EAAE,SAAS,kBAAkB,EA0D5D,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,UAAU,QAAQ,yBAGtD,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export const radioGroupScenarioOptions = [
|
|
2
|
+
{ value: 'email', label: 'Email', description: 'Receive updates by email.' },
|
|
3
|
+
{ value: 'phone', label: 'Phone', description: 'Receive updates by text.' },
|
|
4
|
+
{ value: 'mail', label: 'Mail', disabled: true },
|
|
5
|
+
];
|
|
6
|
+
const baseProps = { label: 'Contact method', options: radioGroupScenarioOptions };
|
|
7
|
+
export const radioGroupScenarios = [
|
|
8
|
+
{
|
|
9
|
+
name: 'starts without a selection',
|
|
10
|
+
props: baseProps,
|
|
11
|
+
actions: [],
|
|
12
|
+
expected: { value: null, changes: [] },
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: 'initializes autonomous selection from defaultValue',
|
|
16
|
+
props: { ...baseProps, defaultValue: 'email' },
|
|
17
|
+
actions: [],
|
|
18
|
+
expected: { value: 'email', changes: [] },
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: 'commits autonomous selection and emits its proposal',
|
|
22
|
+
props: baseProps,
|
|
23
|
+
actions: [{ type: 'select', value: 'phone' }],
|
|
24
|
+
expected: { value: 'phone', changes: ['phone'] },
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'controlled selection waits for the owner',
|
|
28
|
+
props: { ...baseProps, value: 'email' },
|
|
29
|
+
actions: [{ type: 'select', value: 'phone' }],
|
|
30
|
+
expected: { value: 'email', changes: ['phone'] },
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: 'controlled null remains unselected until the owner accepts',
|
|
34
|
+
props: { ...baseProps, value: null },
|
|
35
|
+
actions: [{ type: 'select', value: 'email' }],
|
|
36
|
+
expected: { value: null, changes: ['email'] },
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'controlled selection commits after the owner updates',
|
|
40
|
+
props: { ...baseProps, value: 'email' },
|
|
41
|
+
actions: [
|
|
42
|
+
{ type: 'select', value: 'phone' },
|
|
43
|
+
{ type: 'set-value', value: 'phone' },
|
|
44
|
+
],
|
|
45
|
+
expected: { value: 'phone', changes: ['phone'] },
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'does not emit when the selected option is activated',
|
|
49
|
+
props: { ...baseProps, defaultValue: 'email' },
|
|
50
|
+
actions: [{ type: 'select', value: 'email' }],
|
|
51
|
+
expected: { value: 'email', changes: [] },
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'does not select a disabled option',
|
|
55
|
+
props: baseProps,
|
|
56
|
+
actions: [{ type: 'select', value: 'mail' }],
|
|
57
|
+
expected: { value: null, changes: [] },
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: 'does not select an option when the group is disabled',
|
|
61
|
+
props: { ...baseProps, disabled: true },
|
|
62
|
+
actions: [{ type: 'select', value: 'email' }],
|
|
63
|
+
expected: { value: null, changes: [] },
|
|
64
|
+
},
|
|
65
|
+
];
|
|
66
|
+
export const radioGroupScenariosFor = (platform) => radioGroupScenarios.filter(scenario => !scenario.platforms || scenario.platforms.includes(platform));
|
|
67
|
+
//# sourceMappingURL=radio-group.scenarios.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radio-group.scenarios.js","sourceRoot":"","sources":["../../src/specs/radio-group.scenarios.ts"],"names":[],"mappings":"AA8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AS,EAAE,QAAQ,EAAE,IAAI,EAAE;QACvC,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;QAC7C,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;KACvC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,QAAkB,EAAE,EAAE,CAC3D,mBAAmB,CAAC,MAAM,CACxB,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,SAAS,IAAI,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,CACzE,CAAC"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
export type SelectValue = string | null;
|
|
2
|
+
export interface SelectOption {
|
|
3
|
+
value: string;
|
|
4
|
+
label: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export type SelectItems = readonly SelectOption[];
|
|
8
|
+
export type SelectReferences = {
|
|
9
|
+
SelectItems: SelectItems;
|
|
10
|
+
SelectValue: SelectValue;
|
|
11
|
+
};
|
|
12
|
+
export interface SelectChangeDetail {
|
|
13
|
+
value: SelectValue;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Selects one value from a labeled collection using a select-only combobox and a
|
|
17
|
+
* form-associated custom popup on the Web.
|
|
18
|
+
*/
|
|
19
|
+
export declare const selectContract: {
|
|
20
|
+
readonly name: "select";
|
|
21
|
+
readonly tag: "cosm-select";
|
|
22
|
+
readonly description: "Selects one option from an accessible collection, with native Web form behavior.";
|
|
23
|
+
readonly role: "combobox";
|
|
24
|
+
readonly pattern: "https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/";
|
|
25
|
+
readonly props: {
|
|
26
|
+
readonly label: {
|
|
27
|
+
readonly type: "string";
|
|
28
|
+
readonly required: true;
|
|
29
|
+
readonly description: "Required visible accessible name for the control.";
|
|
30
|
+
};
|
|
31
|
+
readonly items: {
|
|
32
|
+
readonly type: "reference";
|
|
33
|
+
readonly reference: "SelectItems";
|
|
34
|
+
readonly required: true;
|
|
35
|
+
readonly options: readonly ["flat"];
|
|
36
|
+
readonly example: "flat";
|
|
37
|
+
readonly description: "Readonly flat options with unique nonempty values, nonempty labels, and optional disabled state.";
|
|
38
|
+
};
|
|
39
|
+
readonly value: {
|
|
40
|
+
readonly type: "reference";
|
|
41
|
+
readonly reference: "SelectValue";
|
|
42
|
+
readonly options: readonly ["none", "apple", "cherry"];
|
|
43
|
+
readonly description: "Controlled selected value; null means no selection, and a supplied null remains controlled.";
|
|
44
|
+
};
|
|
45
|
+
readonly defaultValue: {
|
|
46
|
+
readonly type: "reference";
|
|
47
|
+
readonly reference: "SelectValue";
|
|
48
|
+
readonly options: readonly ["none", "apple", "cherry"];
|
|
49
|
+
readonly example: "none";
|
|
50
|
+
readonly description: "Initial autonomous selection; null by default.";
|
|
51
|
+
};
|
|
52
|
+
readonly placeholder: {
|
|
53
|
+
readonly type: "string";
|
|
54
|
+
readonly required: true;
|
|
55
|
+
readonly description: "Consumer-localized text shown when no value is selected.";
|
|
56
|
+
};
|
|
57
|
+
readonly variant: {
|
|
58
|
+
readonly type: "enum";
|
|
59
|
+
readonly values: readonly ["outlined", "filled"];
|
|
60
|
+
readonly default: "outlined";
|
|
61
|
+
readonly reflect: true;
|
|
62
|
+
readonly description: "Outlined or filled trigger appearance.";
|
|
63
|
+
};
|
|
64
|
+
readonly size: {
|
|
65
|
+
readonly type: "enum";
|
|
66
|
+
readonly values: readonly ["sm", "md", "lg"];
|
|
67
|
+
readonly default: "md";
|
|
68
|
+
readonly reflect: true;
|
|
69
|
+
readonly description: "Small, medium, or large control size.";
|
|
70
|
+
};
|
|
71
|
+
readonly disabled: {
|
|
72
|
+
readonly type: "boolean";
|
|
73
|
+
readonly default: false;
|
|
74
|
+
readonly reflect: true;
|
|
75
|
+
readonly description: "Prevents interaction and excludes the value from Web form submission.";
|
|
76
|
+
};
|
|
77
|
+
readonly required: {
|
|
78
|
+
readonly type: "boolean";
|
|
79
|
+
readonly default: false;
|
|
80
|
+
readonly reflect: true;
|
|
81
|
+
readonly description: "Requires a selection in Web form validation; Native exposes descriptive semantics.";
|
|
82
|
+
};
|
|
83
|
+
readonly invalid: {
|
|
84
|
+
readonly type: "boolean";
|
|
85
|
+
readonly default: false;
|
|
86
|
+
readonly reflect: true;
|
|
87
|
+
readonly description: "Externally supplied invalid presentation state when the visible error is supplied elsewhere.";
|
|
88
|
+
};
|
|
89
|
+
readonly helperText: {
|
|
90
|
+
readonly type: "string";
|
|
91
|
+
readonly description: "Optional supporting text associated with the control.";
|
|
92
|
+
};
|
|
93
|
+
readonly errorText: {
|
|
94
|
+
readonly type: "string";
|
|
95
|
+
readonly description: "Optional consumer-localized error text; a nonempty trimmed value also exposes invalid state.";
|
|
96
|
+
};
|
|
97
|
+
readonly name: {
|
|
98
|
+
readonly type: "string";
|
|
99
|
+
readonly reflect: true;
|
|
100
|
+
readonly platforms: readonly ["web", "react", "angular"];
|
|
101
|
+
readonly description: "Web form field name; React Native has no HTML form association.";
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
readonly events: {
|
|
105
|
+
readonly change: {
|
|
106
|
+
readonly description: "Proposes a selected value after user activation; autonomous state commits and controlled state waits for the owner.";
|
|
107
|
+
readonly detail: "SelectChangeDetail";
|
|
108
|
+
readonly names: {
|
|
109
|
+
readonly dom: "cosm-change";
|
|
110
|
+
readonly react: "onChange";
|
|
111
|
+
readonly angular: "valueChange";
|
|
112
|
+
readonly native: "onValueChange";
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
readonly states: readonly [{
|
|
117
|
+
readonly prop: "value";
|
|
118
|
+
readonly event: "change";
|
|
119
|
+
readonly defaultProp: "defaultValue";
|
|
120
|
+
}];
|
|
121
|
+
readonly slots: {};
|
|
122
|
+
readonly parts: {
|
|
123
|
+
readonly base: "Field wrapper.";
|
|
124
|
+
readonly label: "Visible accessible label.";
|
|
125
|
+
readonly trigger: "Select-only combobox trigger.";
|
|
126
|
+
readonly value: "Selected option text.";
|
|
127
|
+
readonly placeholder: "Text displayed when no option is selected.";
|
|
128
|
+
readonly popup: "Anchored popup surface.";
|
|
129
|
+
readonly listbox: "Single-selection option collection.";
|
|
130
|
+
readonly option: "Selectable row with selected, active, and disabled states.";
|
|
131
|
+
readonly content: "Option text wrapper.";
|
|
132
|
+
readonly 'option-label': "Primary option text.";
|
|
133
|
+
readonly help: "Supporting text associated with the control.";
|
|
134
|
+
readonly error: "Error description associated with the control.";
|
|
135
|
+
};
|
|
136
|
+
readonly cssProperties: {
|
|
137
|
+
readonly '--cosm-select-background': "Control background.";
|
|
138
|
+
readonly '--cosm-select-color': "Control and value text color.";
|
|
139
|
+
readonly '--cosm-select-placeholder': "Placeholder text color.";
|
|
140
|
+
readonly '--cosm-select-border': "Control boundary color.";
|
|
141
|
+
readonly '--cosm-select-focus': "Visible keyboard focus indicator color.";
|
|
142
|
+
readonly '--cosm-select-radius': "Control corner radius.";
|
|
143
|
+
readonly '--cosm-select-trigger-min-height': "Custom minimum trigger height.";
|
|
144
|
+
readonly '--cosm-select-option-selected-background': "Selected option background.";
|
|
145
|
+
readonly '--cosm-select-option-selected-color': "Selected option text color.";
|
|
146
|
+
};
|
|
147
|
+
readonly keyboard: readonly [{
|
|
148
|
+
readonly keys: readonly ["Tab", "Shift+Tab"];
|
|
149
|
+
readonly action: "Moves focus to or from the enabled combobox trigger.";
|
|
150
|
+
}, {
|
|
151
|
+
readonly keys: readonly ["Enter", "Space", "ArrowDown", "ArrowUp"];
|
|
152
|
+
readonly action: "On Web, opens the popup; arrows move the active option without changing selection.";
|
|
153
|
+
}, {
|
|
154
|
+
readonly keys: readonly ["ArrowDown", "ArrowUp", "Home", "End"];
|
|
155
|
+
readonly action: "On Web, moves the active option without changing the selected value.";
|
|
156
|
+
}, {
|
|
157
|
+
readonly keys: readonly ["Printable characters"];
|
|
158
|
+
readonly action: "On Web and React Native Web, moves to a matching option using locale-aware typeahead. Native iOS/Android use touch and platform accessibility navigation; React Native core does not expose hardware key events on this control.";
|
|
159
|
+
}, {
|
|
160
|
+
readonly keys: readonly ["Enter", "Space"];
|
|
161
|
+
readonly action: "On Web, selects the active enabled option.";
|
|
162
|
+
}, {
|
|
163
|
+
readonly keys: readonly ["Escape"];
|
|
164
|
+
readonly action: "On Web, closes the popup without changing the selected value.";
|
|
165
|
+
}];
|
|
166
|
+
};
|
|
167
|
+
//# sourceMappingURL=select.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../src/specs/select.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,IAAI,CAAC;AACxC,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AACD,MAAM,MAAM,WAAW,GAAG,SAAS,YAAY,EAAE,CAAC;AAClD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,EAAE,WAAW,CAAC;IACzB,WAAW,EAAE,WAAW,CAAC;CAC1B,CAAC;AAEF,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,WAAW,CAAC;CACpB;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoJzB,CAAC"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { defineContract } from '../contract.js';
|
|
2
|
+
/**
|
|
3
|
+
* Selects one value from a labeled collection using a select-only combobox and a
|
|
4
|
+
* form-associated custom popup on the Web.
|
|
5
|
+
*/
|
|
6
|
+
export const selectContract = defineContract({
|
|
7
|
+
name: 'select',
|
|
8
|
+
tag: 'cosm-select',
|
|
9
|
+
description: 'Selects one option from an accessible collection, with native Web form behavior.',
|
|
10
|
+
role: 'combobox',
|
|
11
|
+
pattern: 'https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/',
|
|
12
|
+
props: {
|
|
13
|
+
label: {
|
|
14
|
+
type: 'string',
|
|
15
|
+
required: true,
|
|
16
|
+
description: 'Required visible accessible name for the control.',
|
|
17
|
+
},
|
|
18
|
+
items: {
|
|
19
|
+
type: 'reference',
|
|
20
|
+
reference: 'SelectItems',
|
|
21
|
+
required: true,
|
|
22
|
+
options: ['flat'],
|
|
23
|
+
example: 'flat',
|
|
24
|
+
description: 'Readonly flat options with unique nonempty values, nonempty labels, and optional disabled state.',
|
|
25
|
+
},
|
|
26
|
+
value: {
|
|
27
|
+
type: 'reference',
|
|
28
|
+
reference: 'SelectValue',
|
|
29
|
+
options: ['none', 'apple', 'cherry'],
|
|
30
|
+
description: 'Controlled selected value; null means no selection, and a supplied null remains controlled.',
|
|
31
|
+
},
|
|
32
|
+
defaultValue: {
|
|
33
|
+
type: 'reference',
|
|
34
|
+
reference: 'SelectValue',
|
|
35
|
+
options: ['none', 'apple', 'cherry'],
|
|
36
|
+
example: 'none',
|
|
37
|
+
description: 'Initial autonomous selection; null by default.',
|
|
38
|
+
},
|
|
39
|
+
placeholder: {
|
|
40
|
+
type: 'string',
|
|
41
|
+
required: true,
|
|
42
|
+
description: 'Consumer-localized text shown when no value is selected.',
|
|
43
|
+
},
|
|
44
|
+
variant: {
|
|
45
|
+
type: 'enum',
|
|
46
|
+
values: ['outlined', 'filled'],
|
|
47
|
+
default: 'outlined',
|
|
48
|
+
reflect: true,
|
|
49
|
+
description: 'Outlined or filled trigger appearance.',
|
|
50
|
+
},
|
|
51
|
+
size: {
|
|
52
|
+
type: 'enum',
|
|
53
|
+
values: ['sm', 'md', 'lg'],
|
|
54
|
+
default: 'md',
|
|
55
|
+
reflect: true,
|
|
56
|
+
description: 'Small, medium, or large control size.',
|
|
57
|
+
},
|
|
58
|
+
disabled: {
|
|
59
|
+
type: 'boolean',
|
|
60
|
+
default: false,
|
|
61
|
+
reflect: true,
|
|
62
|
+
description: 'Prevents interaction and excludes the value from Web form submission.',
|
|
63
|
+
},
|
|
64
|
+
required: {
|
|
65
|
+
type: 'boolean',
|
|
66
|
+
default: false,
|
|
67
|
+
reflect: true,
|
|
68
|
+
description: 'Requires a selection in Web form validation; Native exposes descriptive semantics.',
|
|
69
|
+
},
|
|
70
|
+
invalid: {
|
|
71
|
+
type: 'boolean',
|
|
72
|
+
default: false,
|
|
73
|
+
reflect: true,
|
|
74
|
+
description: 'Externally supplied invalid presentation state when the visible error is supplied elsewhere.',
|
|
75
|
+
},
|
|
76
|
+
helperText: {
|
|
77
|
+
type: 'string',
|
|
78
|
+
description: 'Optional supporting text associated with the control.',
|
|
79
|
+
},
|
|
80
|
+
errorText: {
|
|
81
|
+
type: 'string',
|
|
82
|
+
description: 'Optional consumer-localized error text; a nonempty trimmed value also exposes invalid state.',
|
|
83
|
+
},
|
|
84
|
+
name: {
|
|
85
|
+
type: 'string',
|
|
86
|
+
reflect: true,
|
|
87
|
+
platforms: ['web', 'react', 'angular'],
|
|
88
|
+
description: 'Web form field name; React Native has no HTML form association.',
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
events: {
|
|
92
|
+
change: {
|
|
93
|
+
description: 'Proposes a selected value after user activation; autonomous state commits and controlled state waits for the owner.',
|
|
94
|
+
detail: 'SelectChangeDetail',
|
|
95
|
+
names: {
|
|
96
|
+
dom: 'cosm-change',
|
|
97
|
+
react: 'onChange',
|
|
98
|
+
angular: 'valueChange',
|
|
99
|
+
native: 'onValueChange',
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
states: [{ prop: 'value', event: 'change', defaultProp: 'defaultValue' }],
|
|
104
|
+
slots: {},
|
|
105
|
+
parts: {
|
|
106
|
+
base: 'Field wrapper.',
|
|
107
|
+
label: 'Visible accessible label.',
|
|
108
|
+
trigger: 'Select-only combobox trigger.',
|
|
109
|
+
value: 'Selected option text.',
|
|
110
|
+
placeholder: 'Text displayed when no option is selected.',
|
|
111
|
+
popup: 'Anchored popup surface.',
|
|
112
|
+
listbox: 'Single-selection option collection.',
|
|
113
|
+
option: 'Selectable row with selected, active, and disabled states.',
|
|
114
|
+
content: 'Option text wrapper.',
|
|
115
|
+
'option-label': 'Primary option text.',
|
|
116
|
+
help: 'Supporting text associated with the control.',
|
|
117
|
+
error: 'Error description associated with the control.',
|
|
118
|
+
},
|
|
119
|
+
cssProperties: {
|
|
120
|
+
'--cosm-select-background': 'Control background.',
|
|
121
|
+
'--cosm-select-color': 'Control and value text color.',
|
|
122
|
+
'--cosm-select-placeholder': 'Placeholder text color.',
|
|
123
|
+
'--cosm-select-border': 'Control boundary color.',
|
|
124
|
+
'--cosm-select-focus': 'Visible keyboard focus indicator color.',
|
|
125
|
+
'--cosm-select-radius': 'Control corner radius.',
|
|
126
|
+
'--cosm-select-trigger-min-height': 'Custom minimum trigger height.',
|
|
127
|
+
'--cosm-select-option-selected-background': 'Selected option background.',
|
|
128
|
+
'--cosm-select-option-selected-color': 'Selected option text color.',
|
|
129
|
+
},
|
|
130
|
+
keyboard: [
|
|
131
|
+
{ keys: ['Tab', 'Shift+Tab'], action: 'Moves focus to or from the enabled combobox trigger.' },
|
|
132
|
+
{
|
|
133
|
+
keys: ['Enter', 'Space', 'ArrowDown', 'ArrowUp'],
|
|
134
|
+
action: 'On Web, opens the popup; arrows move the active option without changing selection.',
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
keys: ['ArrowDown', 'ArrowUp', 'Home', 'End'],
|
|
138
|
+
action: 'On Web, moves the active option without changing the selected value.',
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
keys: ['Printable characters'],
|
|
142
|
+
action: 'On Web and React Native Web, moves to a matching option using locale-aware typeahead. Native iOS/Android use touch and platform accessibility navigation; React Native core does not expose hardware key events on this control.',
|
|
143
|
+
},
|
|
144
|
+
{ keys: ['Enter', 'Space'], action: 'On Web, selects the active enabled option.' },
|
|
145
|
+
{ keys: ['Escape'], action: 'On Web, closes the popup without changing the selected value.' },
|
|
146
|
+
],
|
|
147
|
+
});
|
|
148
|
+
//# sourceMappingURL=select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select.js","sourceRoot":"","sources":["../../src/specs/select.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAkBhD;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,cAAc,CAAC;IAC3C,IAAI,EAAE,QAAQ;IACd,GAAG,EAAE,aAAa;IAClB,WAAW,EAAE,kFAAkF;IAC/F,IAAI,EAAE,UAAU;IAChB,OAAO,EAAE,kFAAkF;IAC3F,KAAK,EAAE;QACL,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,mDAAmD;SACjE;QACD,KAAK,EAAE;YACL,IAAI,EAAE,WAAW;YACjB,SAAS,EAAE,aAAa;YACxB,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,CAAC,MAAM,CAAC;YACjB,OAAO,EAAE,MAAM;YACf,WAAW,EACT,kGAAkG;SACrG;QACD,KAAK,EAAE;YACL,IAAI,EAAE,WAAW;YACjB,SAAS,EAAE,aAAa;YACxB,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC;YACpC,WAAW,EACT,6FAA6F;SAChG;QACD,YAAY,EAAE;YACZ,IAAI,EAAE,WAAW;YACjB,SAAS,EAAE,aAAa;YACxB,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC;YACpC,OAAO,EAAE,MAAM;YACf,WAAW,EAAE,gDAAgD;SAC9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J,kOAAkO;SACrO;QACD,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,4CAA4C,EAAE;QAClF,EAAE,IAAI,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,+DAA+D,EAAE;KAC9F;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Platform } from '../contract.js';
|
|
2
|
+
import type { SelectItems, SelectValue } from './select.js';
|
|
3
|
+
export type SelectAction = {
|
|
4
|
+
type: 'select';
|
|
5
|
+
value: string;
|
|
6
|
+
} | {
|
|
7
|
+
type: 'set-value';
|
|
8
|
+
value: SelectValue;
|
|
9
|
+
};
|
|
10
|
+
export interface SelectScenario {
|
|
11
|
+
name: string;
|
|
12
|
+
props: {
|
|
13
|
+
label?: string;
|
|
14
|
+
items?: SelectItems;
|
|
15
|
+
value?: SelectValue;
|
|
16
|
+
defaultValue?: SelectValue;
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
variant?: 'outlined' | 'filled';
|
|
19
|
+
size?: 'sm' | 'md' | 'lg';
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
required?: boolean;
|
|
22
|
+
invalid?: boolean;
|
|
23
|
+
helperText?: string;
|
|
24
|
+
errorText?: string;
|
|
25
|
+
name?: string;
|
|
26
|
+
};
|
|
27
|
+
actions: readonly SelectAction[];
|
|
28
|
+
expected: {
|
|
29
|
+
value: SelectValue;
|
|
30
|
+
changes: readonly SelectValue[];
|
|
31
|
+
};
|
|
32
|
+
platforms?: readonly Platform[];
|
|
33
|
+
}
|
|
34
|
+
export declare const selectScenarioItems: SelectItems;
|
|
35
|
+
export declare const selectScenarios: readonly SelectScenario[];
|
|
36
|
+
export declare const selectScenariosFor: (platform: Platform) => SelectScenario[];
|
|
37
|
+
//# sourceMappingURL=select.scenarios.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select.scenarios.d.ts","sourceRoot":"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