@joralvmel/cosmos-core 0.1.0 → 0.3.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 +15 -3
- package/dist/catalog.js.map +1 -1
- package/dist/codegen.d.ts +10 -0
- package/dist/codegen.d.ts.map +1 -1
- package/dist/codegen.js +259 -29
- package/dist/codegen.js.map +1 -1
- package/dist/contract.d.ts +33 -4
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +2 -2
- package/dist/contract.js.map +1 -1
- package/dist/headless/listbox.d.ts +9 -0
- package/dist/headless/listbox.d.ts.map +1 -0
- package/dist/headless/listbox.js +107 -0
- package/dist/headless/listbox.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 +702 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -1
- package/dist/index.js.map +1 -1
- package/dist/markdown.d.ts.map +1 -1
- package/dist/markdown.js +24 -5
- package/dist/markdown.js.map +1 -1
- 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 +66 -0
- package/dist/specs/icon.d.ts.map +1 -0
- package/dist/specs/icon.js +58 -0
- package/dist/specs/icon.js.map +1 -0
- package/dist/specs/icon.scenarios.d.ts +19 -0
- package/dist/specs/icon.scenarios.d.ts.map +1 -0
- package/dist/specs/icon.scenarios.js +25 -0
- package/dist/specs/icon.scenarios.js.map +1 -0
- package/dist/specs/listbox.d.ts +162 -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/popover.d.ts +213 -0
- package/dist/specs/popover.d.ts.map +1 -0
- package/dist/specs/popover.js +181 -0
- package/dist/specs/popover.js.map +1 -0
- package/dist/specs/popover.scenarios.d.ts +77 -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/text-field.d.ts +246 -0
- package/dist/specs/text-field.d.ts.map +1 -0
- package/dist/specs/text-field.js +229 -0
- package/dist/specs/text-field.js.map +1 -0
- package/dist/specs/text-field.scenarios.d.ts +49 -0
- package/dist/specs/text-field.scenarios.d.ts.map +1 -0
- package/dist/specs/text-field.scenarios.js +88 -0
- package/dist/specs/text-field.scenarios.js.map +1 -0
- package/llms.md +292 -0
- package/package.json +1 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { defineContract } from '../contract.js';
|
|
2
|
+
/** A non-interactive vector icon with decorative or informative semantics. */
|
|
3
|
+
export const iconContract = defineContract({
|
|
4
|
+
name: 'icon',
|
|
5
|
+
tag: 'cosm-icon',
|
|
6
|
+
description: 'Renders a structured SVG icon. Decorative icons are hidden from assistive technology; informative icons require a text label.',
|
|
7
|
+
role: 'img',
|
|
8
|
+
pattern: 'https://www.w3.org/WAI/WCAG22/Techniques/aria/ARIA24',
|
|
9
|
+
props: {
|
|
10
|
+
icon: {
|
|
11
|
+
type: 'reference',
|
|
12
|
+
reference: 'IconDefinition',
|
|
13
|
+
required: true,
|
|
14
|
+
options: ['house', 'heart', 'search', 'star'],
|
|
15
|
+
example: 'house',
|
|
16
|
+
description: 'Structured icon definition, commonly imported from @joralvmel/cosmos-icons.',
|
|
17
|
+
},
|
|
18
|
+
size: {
|
|
19
|
+
type: 'union',
|
|
20
|
+
variants: [{ type: 'enum', values: ['sm', 'md', 'lg'] }, { type: 'number' }],
|
|
21
|
+
default: 'md',
|
|
22
|
+
reflect: true,
|
|
23
|
+
description: 'Semantic size (16, 20 or 24) or a positive finite number in pixels / native units.',
|
|
24
|
+
},
|
|
25
|
+
stroke: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
default: 'currentColor',
|
|
28
|
+
description: 'Stroke paint; currentColor inherits on web and resolves to the theme foreground on native.',
|
|
29
|
+
},
|
|
30
|
+
fill: {
|
|
31
|
+
type: 'string',
|
|
32
|
+
default: 'none',
|
|
33
|
+
description: 'Root fill paint. Explicit node fills take precedence.',
|
|
34
|
+
},
|
|
35
|
+
strokeWidth: {
|
|
36
|
+
type: 'number',
|
|
37
|
+
default: 2,
|
|
38
|
+
description: 'Finite nonnegative stroke width in SVG viewBox units.',
|
|
39
|
+
},
|
|
40
|
+
label: {
|
|
41
|
+
type: 'string',
|
|
42
|
+
description: 'Accessible name required when decorative is false.',
|
|
43
|
+
},
|
|
44
|
+
decorative: {
|
|
45
|
+
type: 'boolean',
|
|
46
|
+
default: true,
|
|
47
|
+
reflect: true,
|
|
48
|
+
description: 'Hides the icon from assistive technology when true.',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
events: {},
|
|
52
|
+
states: [],
|
|
53
|
+
slots: {},
|
|
54
|
+
parts: { icon: 'Rendered SVG image.' },
|
|
55
|
+
cssProperties: { '--cosm-icon-size': 'Override the rendered icon width and height.' },
|
|
56
|
+
keyboard: [],
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=icon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon.js","sourceRoot":"","sources":["../../src/specs/icon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA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AE;IACV,MAAM,EAAE,EAAE;IACV,KAAK,EAAE,EAAE;IACT,KAAK,EAAE,EAAE,IAAI,EAAE,qBAAqB,EAAE;IACtC,aAAa,EAAE,EAAE,kBAAkB,EAAE,8CAA8C,EAAE;IACrF,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Platform } from '../contract.js';
|
|
2
|
+
export interface IconScenario {
|
|
3
|
+
name: string;
|
|
4
|
+
props: {
|
|
5
|
+
size?: 'sm' | 'md' | 'lg' | number;
|
|
6
|
+
label?: string;
|
|
7
|
+
decorative?: boolean;
|
|
8
|
+
};
|
|
9
|
+
expected: {
|
|
10
|
+
size: 'sm' | 'md' | 'lg' | number;
|
|
11
|
+
label?: string;
|
|
12
|
+
decorative: boolean;
|
|
13
|
+
};
|
|
14
|
+
platforms?: readonly Platform[];
|
|
15
|
+
}
|
|
16
|
+
/** Shared rendering and accessibility scenarios, run by every platform. */
|
|
17
|
+
export declare const iconScenarios: readonly IconScenario[];
|
|
18
|
+
export declare const iconScenariosFor: (platform: Platform) => IconScenario[];
|
|
19
|
+
//# sourceMappingURL=icon.scenarios.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon.scenarios.d.ts","sourceRoot":"","sources":["../../src/specs/icon.scenarios.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE;QAAE,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IACpF,QAAQ,EAAE;QAAE,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,OAAO,CAAA;KAAE,CAAC;IACrF,SAAS,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAC;CACjC;AAED,2EAA2E;AAC3E,eAAO,MAAM,aAAa,EAAE,SAAS,YAAY,EAqBhD,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,UAAU,QAAQ,mBAC6C,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Shared rendering and accessibility scenarios, run by every platform. */
|
|
2
|
+
export const iconScenarios = [
|
|
3
|
+
{
|
|
4
|
+
name: 'uses the medium decorative default',
|
|
5
|
+
props: {},
|
|
6
|
+
expected: { size: 'md', decorative: true },
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
name: 'supports a small informative icon',
|
|
10
|
+
props: { size: 'sm', decorative: false, label: 'Home' },
|
|
11
|
+
expected: { size: 'sm', decorative: false, label: 'Home' },
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: 'supports a large decorative icon',
|
|
15
|
+
props: { size: 'lg' },
|
|
16
|
+
expected: { size: 'lg', decorative: true },
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: 'supports a numeric decorative size',
|
|
20
|
+
props: { size: 32 },
|
|
21
|
+
expected: { size: 32, decorative: true },
|
|
22
|
+
},
|
|
23
|
+
];
|
|
24
|
+
export const iconScenariosFor = (platform) => iconScenarios.filter(scenario => !scenario.platforms || scenario.platforms.includes(platform));
|
|
25
|
+
//# sourceMappingURL=icon.scenarios.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon.scenarios.js","sourceRoot":"","sources":["../../src/specs/icon.scenarios.ts"],"names":[],"mappings":"AASA,2EAA2E;AAC3E,MAAM,CAAC,MAAM,aAAa,GAA4B;IACpD;QACE,IAAI,EAAE,oCAAoC;QAC1C,KAAK,EAAE,EAAE;QACT,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE;KAC3C;IACD;QACE,IAAI,EAAE,mCAAmC;QACzC,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE;QACvD,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE;KAC3D;IACD;QACE,IAAI,EAAE,kCAAkC;QACxC,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;QACrB,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE;KAC3C;IACD;QACE,IAAI,EAAE,oCAAoC;QAC1C,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;QACnB,QAAQ,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;KACzC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,QAAkB,EAAE,EAAE,CACrD,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,SAAS,IAAI,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
export interface ListboxOption<Icon = unknown> {
|
|
2
|
+
value: string;
|
|
3
|
+
label: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
icon?: Icon;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface ListboxGroup<Icon = unknown> {
|
|
9
|
+
label: string;
|
|
10
|
+
options: readonly ListboxOption<Icon>[];
|
|
11
|
+
}
|
|
12
|
+
export type ListboxItem<Icon = unknown> = ListboxOption<Icon> | ListboxGroup<Icon>;
|
|
13
|
+
export type ListboxSelectionMode = 'single' | 'multiple';
|
|
14
|
+
export interface ListboxSelectionChangeDetail {
|
|
15
|
+
selectedValues: readonly string[];
|
|
16
|
+
value: string;
|
|
17
|
+
source: 'pointer' | 'keyboard';
|
|
18
|
+
}
|
|
19
|
+
/** Vertical selection with independent active focus and controlled or autonomous selected values. */
|
|
20
|
+
export declare const listboxContract: {
|
|
21
|
+
readonly name: "listbox";
|
|
22
|
+
readonly tag: "cosm-listbox";
|
|
23
|
+
readonly description: "Selects one or more values from a named vertical collection, with groups, descriptions, icons and independent keyboard focus.";
|
|
24
|
+
readonly role: "listbox";
|
|
25
|
+
readonly pattern: "https://www.w3.org/WAI/ARIA/apg/patterns/listbox/";
|
|
26
|
+
readonly props: {
|
|
27
|
+
readonly label: {
|
|
28
|
+
readonly type: "string";
|
|
29
|
+
readonly required: true;
|
|
30
|
+
readonly description: "Required nonempty accessible label, visible unless labelHidden is true.";
|
|
31
|
+
};
|
|
32
|
+
readonly labelHidden: {
|
|
33
|
+
readonly type: "boolean";
|
|
34
|
+
readonly default: false;
|
|
35
|
+
readonly reflect: true;
|
|
36
|
+
readonly description: "Visually hides the label without removing its accessible name.";
|
|
37
|
+
};
|
|
38
|
+
readonly items: {
|
|
39
|
+
readonly type: "reference";
|
|
40
|
+
readonly reference: "ListboxItems";
|
|
41
|
+
readonly required: true;
|
|
42
|
+
readonly options: readonly ["flat", "grouped"];
|
|
43
|
+
readonly example: "grouped";
|
|
44
|
+
readonly description: "Readonly collection of options or named groups. Options have globally unique nonempty value and label strings, optional description, decorative IconDefinition and disabled. Groups have a nonempty label and options array.";
|
|
45
|
+
};
|
|
46
|
+
readonly selectionMode: {
|
|
47
|
+
readonly type: "enum";
|
|
48
|
+
readonly values: readonly ["single", "multiple"];
|
|
49
|
+
readonly default: "single";
|
|
50
|
+
readonly reflect: true;
|
|
51
|
+
readonly description: "Single permits at most one selected value; multiple toggles each activation.";
|
|
52
|
+
};
|
|
53
|
+
readonly selectedValues: {
|
|
54
|
+
readonly type: "reference";
|
|
55
|
+
readonly reference: "ListboxValues";
|
|
56
|
+
readonly options: readonly ["empty", "apple", "cherry", "apple-cherry"];
|
|
57
|
+
readonly description: "Controlled selected values, including an empty array. Activation only proposes changes until the owner updates this prop. Missing collection values are retained, not automatically selected or removed.";
|
|
58
|
+
};
|
|
59
|
+
readonly defaultSelectedValues: {
|
|
60
|
+
readonly type: "reference";
|
|
61
|
+
readonly reference: "ListboxValues";
|
|
62
|
+
readonly options: readonly ["empty", "apple", "cherry", "apple-cherry"];
|
|
63
|
+
readonly example: "empty";
|
|
64
|
+
readonly description: "Initial autonomous selected values (empty by default). Later changes do not reset selection.";
|
|
65
|
+
};
|
|
66
|
+
readonly variant: {
|
|
67
|
+
readonly type: "enum";
|
|
68
|
+
readonly values: readonly ["plain", "outlined"];
|
|
69
|
+
readonly default: "plain";
|
|
70
|
+
readonly reflect: true;
|
|
71
|
+
readonly description: "Plain composes inside a panel; outlined adds a standalone container boundary.";
|
|
72
|
+
};
|
|
73
|
+
readonly size: {
|
|
74
|
+
readonly type: "union";
|
|
75
|
+
readonly variants: readonly [{
|
|
76
|
+
readonly type: "enum";
|
|
77
|
+
readonly values: readonly ["sm", "md", "lg"];
|
|
78
|
+
}, {
|
|
79
|
+
readonly type: "number";
|
|
80
|
+
}];
|
|
81
|
+
readonly default: "md";
|
|
82
|
+
readonly reflect: true;
|
|
83
|
+
readonly description: "Semantic size or a positive finite minimum option height in CSS pixels/native logical units. Content may grow; native touch targets remain at least 44.";
|
|
84
|
+
};
|
|
85
|
+
readonly disabled: {
|
|
86
|
+
readonly type: "boolean";
|
|
87
|
+
readonly default: false;
|
|
88
|
+
readonly reflect: true;
|
|
89
|
+
readonly description: "Prevents interaction and removes the list from keyboard navigation.";
|
|
90
|
+
};
|
|
91
|
+
readonly readOnly: {
|
|
92
|
+
readonly type: "boolean";
|
|
93
|
+
readonly default: false;
|
|
94
|
+
readonly reflect: true;
|
|
95
|
+
readonly description: "Allows exploring options without proposing or committing selection changes.";
|
|
96
|
+
};
|
|
97
|
+
readonly locale: {
|
|
98
|
+
readonly type: "string";
|
|
99
|
+
readonly description: "BCP 47 locale for typeahead. Web inherits the nearest language; native uses the runtime locale when omitted. Invalid locale identifiers are rejected.";
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
readonly events: {
|
|
103
|
+
readonly selectionChange: {
|
|
104
|
+
readonly description: "Proposes the next selectedValues for an enabled activation. Autonomous selection commits; controlled selection waits for the owner. Arrows and typeahead never select.";
|
|
105
|
+
readonly detail: "ListboxSelectionChangeDetail";
|
|
106
|
+
readonly names: {
|
|
107
|
+
readonly dom: "cosm-selection-change";
|
|
108
|
+
readonly react: "onSelectionChange";
|
|
109
|
+
readonly angular: "selectionChange";
|
|
110
|
+
readonly native: "onSelectionChange";
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
readonly states: readonly [{
|
|
115
|
+
readonly prop: "selectedValues";
|
|
116
|
+
readonly event: "selectionChange";
|
|
117
|
+
readonly defaultProp: "defaultSelectedValues";
|
|
118
|
+
}];
|
|
119
|
+
readonly slots: {};
|
|
120
|
+
readonly parts: {
|
|
121
|
+
readonly base: "Outer container.";
|
|
122
|
+
readonly label: "Visible or visually hidden accessible label.";
|
|
123
|
+
readonly list: "Scrollable listbox.";
|
|
124
|
+
readonly group: "Named option group.";
|
|
125
|
+
readonly 'group-label': "Noninteractive group heading.";
|
|
126
|
+
readonly option: "Selectable row; selected, disabled and active states are exposed on the row.";
|
|
127
|
+
readonly icon: "Decorative option icon.";
|
|
128
|
+
readonly content: "Text content wrapper.";
|
|
129
|
+
readonly 'option-label': "Primary option text.";
|
|
130
|
+
readonly description: "Optional supporting text.";
|
|
131
|
+
readonly indicator: "Decorative selected-state indicator.";
|
|
132
|
+
};
|
|
133
|
+
readonly cssProperties: {
|
|
134
|
+
readonly '--cosm-listbox-background': "Container background.";
|
|
135
|
+
readonly '--cosm-listbox-color': "Primary foreground.";
|
|
136
|
+
readonly '--cosm-listbox-border': "Outlined container border color.";
|
|
137
|
+
readonly '--cosm-listbox-radius': "Container and option corner radius.";
|
|
138
|
+
readonly '--cosm-listbox-option-height': "Minimum option height.";
|
|
139
|
+
readonly '--cosm-listbox-option-padding': "Option padding.";
|
|
140
|
+
readonly '--cosm-listbox-gap': "Space between icon, content and selection indicator.";
|
|
141
|
+
readonly '--cosm-listbox-font-size': "Primary option text size.";
|
|
142
|
+
readonly '--cosm-listbox-description-color': "Supporting text color.";
|
|
143
|
+
readonly '--cosm-listbox-selected-background': "Selected option background.";
|
|
144
|
+
readonly '--cosm-listbox-selected-color': "Selected option foreground.";
|
|
145
|
+
readonly '--cosm-listbox-focus': "Visible keyboard focus outline color.";
|
|
146
|
+
readonly '--cosm-listbox-max-height': "Maximum scrollable list height.";
|
|
147
|
+
};
|
|
148
|
+
readonly keyboard: readonly [{
|
|
149
|
+
readonly keys: readonly ["Tab", "Shift+Tab"];
|
|
150
|
+
readonly action: "Enters or leaves the list as one Tab stop.";
|
|
151
|
+
}, {
|
|
152
|
+
readonly keys: readonly ["ArrowDown", "ArrowUp", "Home", "End"];
|
|
153
|
+
readonly action: "Moves focus among enabled options without changing selection; stops at the ends.";
|
|
154
|
+
}, {
|
|
155
|
+
readonly keys: readonly ["Enter", "Space"];
|
|
156
|
+
readonly action: "Selects the focused option; multiple mode toggles it. Read-only never changes selection.";
|
|
157
|
+
}, {
|
|
158
|
+
readonly keys: readonly ["Printable characters"];
|
|
159
|
+
readonly action: "Moves focus to a matching option using locale-aware typeahead without filtering.";
|
|
160
|
+
}];
|
|
161
|
+
};
|
|
162
|
+
//# sourceMappingURL=listbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listbox.d.ts","sourceRoot":"","sources":["../../src/specs/listbox.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa,CAAC,IAAI,GAAG,OAAO;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,YAAY,CAAC,IAAI,GAAG,OAAO;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,SAAS,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;CACzC;AAED,MAAM,MAAM,WAAW,CAAC,IAAI,GAAG,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;AACnF,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,UAAU,CAAC;AAEzD,MAAM,WAAW,4BAA4B;IAC3C,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,SAAS,GAAG,UAAU,CAAC;CAChC;AAED,qGAAqG;AACrG,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoJ1B,CAAC"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { defineContract } from '../contract.js';
|
|
2
|
+
/** Vertical selection with independent active focus and controlled or autonomous selected values. */
|
|
3
|
+
export const listboxContract = defineContract({
|
|
4
|
+
name: 'listbox',
|
|
5
|
+
tag: 'cosm-listbox',
|
|
6
|
+
description: 'Selects one or more values from a named vertical collection, with groups, descriptions, icons and independent keyboard focus.',
|
|
7
|
+
role: 'listbox',
|
|
8
|
+
pattern: 'https://www.w3.org/WAI/ARIA/apg/patterns/listbox/',
|
|
9
|
+
props: {
|
|
10
|
+
label: {
|
|
11
|
+
type: 'string',
|
|
12
|
+
required: true,
|
|
13
|
+
description: 'Required nonempty accessible label, visible unless labelHidden is true.',
|
|
14
|
+
},
|
|
15
|
+
labelHidden: {
|
|
16
|
+
type: 'boolean',
|
|
17
|
+
default: false,
|
|
18
|
+
reflect: true,
|
|
19
|
+
description: 'Visually hides the label without removing its accessible name.',
|
|
20
|
+
},
|
|
21
|
+
items: {
|
|
22
|
+
type: 'reference',
|
|
23
|
+
reference: 'ListboxItems',
|
|
24
|
+
required: true,
|
|
25
|
+
options: ['flat', 'grouped'],
|
|
26
|
+
example: 'grouped',
|
|
27
|
+
description: 'Readonly collection of options or named groups. Options have globally unique nonempty value and label strings, optional description, decorative IconDefinition and disabled. Groups have a nonempty label and options array.',
|
|
28
|
+
},
|
|
29
|
+
selectionMode: {
|
|
30
|
+
type: 'enum',
|
|
31
|
+
values: ['single', 'multiple'],
|
|
32
|
+
default: 'single',
|
|
33
|
+
reflect: true,
|
|
34
|
+
description: 'Single permits at most one selected value; multiple toggles each activation.',
|
|
35
|
+
},
|
|
36
|
+
selectedValues: {
|
|
37
|
+
type: 'reference',
|
|
38
|
+
reference: 'ListboxValues',
|
|
39
|
+
options: ['empty', 'apple', 'cherry', 'apple-cherry'],
|
|
40
|
+
description: 'Controlled selected values, including an empty array. Activation only proposes changes until the owner updates this prop. Missing collection values are retained, not automatically selected or removed.',
|
|
41
|
+
},
|
|
42
|
+
defaultSelectedValues: {
|
|
43
|
+
type: 'reference',
|
|
44
|
+
reference: 'ListboxValues',
|
|
45
|
+
options: ['empty', 'apple', 'cherry', 'apple-cherry'],
|
|
46
|
+
example: 'empty',
|
|
47
|
+
description: 'Initial autonomous selected values (empty by default). Later changes do not reset selection.',
|
|
48
|
+
},
|
|
49
|
+
variant: {
|
|
50
|
+
type: 'enum',
|
|
51
|
+
values: ['plain', 'outlined'],
|
|
52
|
+
default: 'plain',
|
|
53
|
+
reflect: true,
|
|
54
|
+
description: 'Plain composes inside a panel; outlined adds a standalone container boundary.',
|
|
55
|
+
},
|
|
56
|
+
size: {
|
|
57
|
+
type: 'union',
|
|
58
|
+
variants: [{ type: 'enum', values: ['sm', 'md', 'lg'] }, { type: 'number' }],
|
|
59
|
+
default: 'md',
|
|
60
|
+
reflect: true,
|
|
61
|
+
description: 'Semantic size or a positive finite minimum option height in CSS pixels/native logical units. Content may grow; native touch targets remain at least 44.',
|
|
62
|
+
},
|
|
63
|
+
disabled: {
|
|
64
|
+
type: 'boolean',
|
|
65
|
+
default: false,
|
|
66
|
+
reflect: true,
|
|
67
|
+
description: 'Prevents interaction and removes the list from keyboard navigation.',
|
|
68
|
+
},
|
|
69
|
+
readOnly: {
|
|
70
|
+
type: 'boolean',
|
|
71
|
+
default: false,
|
|
72
|
+
reflect: true,
|
|
73
|
+
description: 'Allows exploring options without proposing or committing selection changes.',
|
|
74
|
+
},
|
|
75
|
+
locale: {
|
|
76
|
+
type: 'string',
|
|
77
|
+
description: 'BCP 47 locale for typeahead. Web inherits the nearest language; native uses the runtime locale when omitted. Invalid locale identifiers are rejected.',
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
events: {
|
|
81
|
+
selectionChange: {
|
|
82
|
+
description: 'Proposes the next selectedValues for an enabled activation. Autonomous selection commits; controlled selection waits for the owner. Arrows and typeahead never select.',
|
|
83
|
+
detail: 'ListboxSelectionChangeDetail',
|
|
84
|
+
names: {
|
|
85
|
+
dom: 'cosm-selection-change',
|
|
86
|
+
react: 'onSelectionChange',
|
|
87
|
+
angular: 'selectionChange',
|
|
88
|
+
native: 'onSelectionChange',
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
states: [
|
|
93
|
+
{
|
|
94
|
+
prop: 'selectedValues',
|
|
95
|
+
event: 'selectionChange',
|
|
96
|
+
defaultProp: 'defaultSelectedValues',
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
slots: {},
|
|
100
|
+
parts: {
|
|
101
|
+
base: 'Outer container.',
|
|
102
|
+
label: 'Visible or visually hidden accessible label.',
|
|
103
|
+
list: 'Scrollable listbox.',
|
|
104
|
+
group: 'Named option group.',
|
|
105
|
+
'group-label': 'Noninteractive group heading.',
|
|
106
|
+
option: 'Selectable row; selected, disabled and active states are exposed on the row.',
|
|
107
|
+
icon: 'Decorative option icon.',
|
|
108
|
+
content: 'Text content wrapper.',
|
|
109
|
+
'option-label': 'Primary option text.',
|
|
110
|
+
description: 'Optional supporting text.',
|
|
111
|
+
indicator: 'Decorative selected-state indicator.',
|
|
112
|
+
},
|
|
113
|
+
cssProperties: {
|
|
114
|
+
'--cosm-listbox-background': 'Container background.',
|
|
115
|
+
'--cosm-listbox-color': 'Primary foreground.',
|
|
116
|
+
'--cosm-listbox-border': 'Outlined container border color.',
|
|
117
|
+
'--cosm-listbox-radius': 'Container and option corner radius.',
|
|
118
|
+
'--cosm-listbox-option-height': 'Minimum option height.',
|
|
119
|
+
'--cosm-listbox-option-padding': 'Option padding.',
|
|
120
|
+
'--cosm-listbox-gap': 'Space between icon, content and selection indicator.',
|
|
121
|
+
'--cosm-listbox-font-size': 'Primary option text size.',
|
|
122
|
+
'--cosm-listbox-description-color': 'Supporting text color.',
|
|
123
|
+
'--cosm-listbox-selected-background': 'Selected option background.',
|
|
124
|
+
'--cosm-listbox-selected-color': 'Selected option foreground.',
|
|
125
|
+
'--cosm-listbox-focus': 'Visible keyboard focus outline color.',
|
|
126
|
+
'--cosm-listbox-max-height': 'Maximum scrollable list height.',
|
|
127
|
+
},
|
|
128
|
+
keyboard: [
|
|
129
|
+
{ keys: ['Tab', 'Shift+Tab'], action: 'Enters or leaves the list as one Tab stop.' },
|
|
130
|
+
{
|
|
131
|
+
keys: ['ArrowDown', 'ArrowUp', 'Home', 'End'],
|
|
132
|
+
action: 'Moves focus among enabled options without changing selection; stops at the ends.',
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
keys: ['Enter', 'Space'],
|
|
136
|
+
action: 'Selects the focused option; multiple mode toggles it. Read-only never changes selection.',
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
keys: ['Printable characters'],
|
|
140
|
+
action: 'Moves focus to a matching option using locale-aware typeahead without filtering.',
|
|
141
|
+
},
|
|
142
|
+
],
|
|
143
|
+
});
|
|
144
|
+
//# sourceMappingURL=listbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listbox.js","sourceRoot":"","sources":["../../src/specs/listbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAwBhD,qGAAqG;AACrG,MAAM,CAAC,MAAM,eAAe,GAAG,cAAc,CAAC;IAC5C,IAAI,EAAE,SAAS;IACf,GAAG,EAAE,cAAc;IACnB,WAAW,EACT,+HAA+H;IACjI,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,mDAAmD;IAC5D,KAAK,EAAE;QACL,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,yEAAyE;SACvF;QACD,WAAW,EAAE;YACX,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,KAAK;YACd,OAAO,EAAE,IAAI;YACb,WAAW,EAAE,gEAAgE;SAC9E;QACD,KAAK,EAAE;YACL,IAAI,EAAE,WAAW;YACjB,SAAS,EAAE,cAAc;YACzB,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC;YAC5B,OAAO,EAAE,SAAS;YAClB,WAAW,EACT,8NAA8N;SACjO;QACD,aAAa,EAAE;YACb,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE,CAAC,QAAQ,EAAE,UAAU,CAAC;YAC9B,OAAO,EAAE,QAAQ;YACjB,OAAO,EAAE,IAAI;YACb,WAAW,EAAE,8EAA8E;SAC5F;QACD,cAAc,EAAE;YACd,IAAI,EAAE,WAAW;YACjB,SAAS,EAAE,eAAe;YAC1B,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc,CAAC;YACrD,WAAW,EACT,0MAA0M;SAC7M;QACD,qBAAqB,EAAE;YACrB,IAAI,EAAE,W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'../contract.js';
|
|
2
|
+
import type { ListboxItem } from './listbox.js';
|
|
3
|
+
export type ListboxAction = {
|
|
4
|
+
type: 'activate';
|
|
5
|
+
value: string;
|
|
6
|
+
source: 'pointer' | 'keyboard';
|
|
7
|
+
} | {
|
|
8
|
+
type: 'sync';
|
|
9
|
+
selectedValues: readonly string[];
|
|
10
|
+
} | {
|
|
11
|
+
type: 'key';
|
|
12
|
+
key: string;
|
|
13
|
+
};
|
|
14
|
+
export interface ListboxScenario {
|
|
15
|
+
name: string;
|
|
16
|
+
props: {
|
|
17
|
+
label: string;
|
|
18
|
+
items: readonly ListboxItem<never>[];
|
|
19
|
+
selectionMode?: 'single' | 'multiple';
|
|
20
|
+
selectedValues?: readonly string[];
|
|
21
|
+
defaultSelectedValues?: readonly string[];
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
readOnly?: boolean;
|
|
24
|
+
};
|
|
25
|
+
actions: readonly ListboxAction[];
|
|
26
|
+
expected: {
|
|
27
|
+
selectedValues: readonly string[];
|
|
28
|
+
changes: readonly (readonly string[])[];
|
|
29
|
+
activeValue?: string;
|
|
30
|
+
};
|
|
31
|
+
platforms?: readonly Platform[];
|
|
32
|
+
}
|
|
33
|
+
export declare const listboxScenarioItems: readonly ListboxItem<never>[];
|
|
34
|
+
/** Normative selection cases shared by platform drivers; keyboard cases are browser-only. */
|
|
35
|
+
export declare const listboxScenarios: readonly ListboxScenario[];
|
|
36
|
+
export declare const listboxScenariosFor: (platform: Platform) => ListboxScenario[];
|
|
37
|
+
//# sourceMappingURL=listbox.scenarios.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listbox.scenarios.d.ts","sourceRoot":"","sources":["../../src/specs/listbox.scenarios.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,MAAM,aAAa,G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
+
label: 'Fruit',
|
|
4
|
+
options: [
|
|
5
|
+
{ value: 'apple', label: 'Apple' },
|
|
6
|
+
{ value: 'apricot', label: 'Apricot' },
|
|
7
|
+
{ value: 'banana', label: 'Banana', disabled: true },
|
|
8
|
+
{ value: 'cherry', label: 'Cherry', description: 'Seasonal' },
|
|
9
|
+
],
|
|
10
|
+
},
|
|
11
|
+
];
|
|
12
|
+
const fixture = { label: 'Choose fruit', items: listboxScenarioItems };
|
|
13
|
+
/** Normative selection cases shared by platform drivers; keyboard cases are browser-only. */
|
|
14
|
+
export const listboxScenarios = [
|
|
15
|
+
{
|
|
16
|
+
name: 'starts empty without a proposal',
|
|
17
|
+
props: fixture,
|
|
18
|
+
actions: [],
|
|
19
|
+
expected: { selectedValues: [], changes: [] },
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: 'single activation selects without toggling the selected value off',
|
|
23
|
+
props: fixture,
|
|
24
|
+
actions: [
|
|
25
|
+
{ type: 'activate', value: 'apple', source: 'pointer' },
|
|
26
|
+
{ type: 'activate', value: 'apple', source: 'pointer' },
|
|
27
|
+
],
|
|
28
|
+
expected: { selectedValues: ['apple'], changes: [['apple']] },
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'multiple selection toggles individual values',
|
|
32
|
+
props: { ...fixture, selectionMode: 'multiple', defaultSelectedValues: ['apple'] },
|
|
33
|
+
actions: [
|
|
34
|
+
{ type: 'activate', value: 'cherry', source: 'pointer' },
|
|
35
|
+
{ type: 'activate', value: 'apple', source: 'pointer' },
|
|
36
|
+
],
|
|
37
|
+
expected: { selectedValues: ['cherry'], changes: [['apple', 'cherry'], ['cherry']] },
|
|
38
|
+
},
|
|
39
|
+
...['disabled', 'readOnly'].map((state) => ({
|
|
40
|
+
name: `${state} does not propose selection`,
|
|
41
|
+
props: { ...fixture, [state]: true, defaultSelectedValues: ['apple'] },
|
|
42
|
+
actions: [{ type: 'activate', value: 'cherry', source: 'pointer' }],
|
|
43
|
+
expected: { selectedValues: ['apple'], changes: [] },
|
|
44
|
+
})),
|
|
45
|
+
{
|
|
46
|
+
name: 'disabled options cannot be activated',
|
|
47
|
+
props: fixture,
|
|
48
|
+
actions: [{ type: 'activate', value: 'banana', source: 'pointer' }],
|
|
49
|
+
expected: { selectedValues: [], changes: [] },
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'a controlled empty array refuses proposals without self-committing',
|
|
53
|
+
props: { ...fixture, selectedValues: [] },
|
|
54
|
+
actions: [
|
|
55
|
+
{ type: 'activate', value: 'apple', source: 'pointer' },
|
|
56
|
+
{ type: 'activate', value: 'apple', source: 'pointer' },
|
|
57
|
+
],
|
|
58
|
+
expected: { selectedValues: [], changes: [['apple'], ['apple']] },
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'controlled selection uses the value accepted by the owner',
|
|
62
|
+
props: { ...fixture, selectedValues: [] },
|
|
63
|
+
actions: [
|
|
64
|
+
{ type: 'activate', value: 'apple', source: 'pointer' },
|
|
65
|
+
{ type: 'sync', selectedValues: ['apple'] },
|
|
66
|
+
{ type: 'activate', value: 'cherry', source: 'pointer' },
|
|
67
|
+
],
|
|
68
|
+
expected: { selectedValues: ['apple'], changes: [['apple'], ['cherry']] },
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: 'arrows skip disabled options without selecting',
|
|
72
|
+
props: fixture,
|
|
73
|
+
actions: [
|
|
74
|
+
{ type: 'key', key: 'Home' },
|
|
75
|
+
{ type: 'key', key: 'ArrowDown' },
|
|
76
|
+
{ type: 'key', key: 'ArrowDown' },
|
|
77
|
+
],
|
|
78
|
+
expected: { selectedValues: [], changes: [], activeValue: 'cherry' },
|
|
79
|
+
platforms: ['web', 'react', 'angular'],
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: 'keyboard confirmation selects the focused option',
|
|
83
|
+
props: fixture,
|
|
84
|
+
actions: [
|
|
85
|
+
{ type: 'key', key: 'End' },
|
|
86
|
+
{ type: 'key', key: 'Enter' },
|
|
87
|
+
],
|
|
88
|
+
expected: { selectedValues: ['cherry'], changes: [['cherry']], activeValue: 'cherry' },
|
|
89
|
+
platforms: ['web', 'react', 'angular'],
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: 'typeahead navigates without filtering or selecting',
|
|
93
|
+
props: fixture,
|
|
94
|
+
actions: [{ type: 'key', key: 'c' }],
|
|
95
|
+
expected: { selectedValues: [], changes: [], activeValue: 'cherry' },
|
|
96
|
+
platforms: ['web', 'react', 'angular'],
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: 'read-only still permits keyboard exploration',
|
|
100
|
+
props: { ...fixture, readOnly: true },
|
|
101
|
+
actions: [
|
|
102
|
+
{ type: 'key', key: 'End' },
|
|
103
|
+
{ type: 'key', key: ' ' },
|
|
104
|
+
],
|
|
105
|
+
expected: { selectedValues: [], changes: [], activeValue: 'cherry' },
|
|
106
|
+
platforms: ['web', 'react', 'angular'],
|
|
107
|
+
},
|
|
108
|
+
];
|
|
109
|
+
export const listboxScenariosFor = (platform) => listboxScenarios.filter(scenario => !scenario.platforms || scenario.platforms.includes(platform));
|
|
110
|
+
//# sourceMappingURL=listbox.scenarios.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listbox.scenarios.js","sourceRoot":"","sources":["../../src/specs/listbox.scenarios.ts"],"names":[],"mappings":"AA4BA,MAAM,CAAC,MAAM,oBAAoB,GAAkC;IACjE;QACE,KAAK,EAAE,OAAO;QACd,OAAO,EAAE;YACP,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;YAClC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;YACtC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;YACpD,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,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