@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.
Files changed (69) hide show
  1. package/dist/catalog.d.ts +3 -3
  2. package/dist/catalog.d.ts.map +1 -1
  3. package/dist/catalog.js +15 -3
  4. package/dist/catalog.js.map +1 -1
  5. package/dist/codegen.d.ts +10 -0
  6. package/dist/codegen.d.ts.map +1 -1
  7. package/dist/codegen.js +259 -29
  8. package/dist/codegen.js.map +1 -1
  9. package/dist/contract.d.ts +33 -4
  10. package/dist/contract.d.ts.map +1 -1
  11. package/dist/contract.js +2 -2
  12. package/dist/contract.js.map +1 -1
  13. package/dist/headless/listbox.d.ts +9 -0
  14. package/dist/headless/listbox.d.ts.map +1 -0
  15. package/dist/headless/listbox.js +107 -0
  16. package/dist/headless/listbox.js.map +1 -0
  17. package/dist/headless/text-field.d.ts +25 -0
  18. package/dist/headless/text-field.d.ts.map +1 -0
  19. package/dist/headless/text-field.js +12 -0
  20. package/dist/headless/text-field.js.map +1 -0
  21. package/dist/index.d.ts +702 -1
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +23 -1
  24. package/dist/index.js.map +1 -1
  25. package/dist/markdown.d.ts.map +1 -1
  26. package/dist/markdown.js +24 -5
  27. package/dist/markdown.js.map +1 -1
  28. package/dist/specs/icon-button.d.ts +136 -0
  29. package/dist/specs/icon-button.d.ts.map +1 -0
  30. package/dist/specs/icon-button.js +119 -0
  31. package/dist/specs/icon-button.js.map +1 -0
  32. package/dist/specs/icon-button.scenarios.d.ts +28 -0
  33. package/dist/specs/icon-button.scenarios.d.ts.map +1 -0
  34. package/dist/specs/icon-button.scenarios.js +95 -0
  35. package/dist/specs/icon-button.scenarios.js.map +1 -0
  36. package/dist/specs/icon.d.ts +66 -0
  37. package/dist/specs/icon.d.ts.map +1 -0
  38. package/dist/specs/icon.js +58 -0
  39. package/dist/specs/icon.js.map +1 -0
  40. package/dist/specs/icon.scenarios.d.ts +19 -0
  41. package/dist/specs/icon.scenarios.d.ts.map +1 -0
  42. package/dist/specs/icon.scenarios.js +25 -0
  43. package/dist/specs/icon.scenarios.js.map +1 -0
  44. package/dist/specs/listbox.d.ts +162 -0
  45. package/dist/specs/listbox.d.ts.map +1 -0
  46. package/dist/specs/listbox.js +144 -0
  47. package/dist/specs/listbox.js.map +1 -0
  48. package/dist/specs/listbox.scenarios.d.ts +37 -0
  49. package/dist/specs/listbox.scenarios.d.ts.map +1 -0
  50. package/dist/specs/listbox.scenarios.js +110 -0
  51. package/dist/specs/listbox.scenarios.js.map +1 -0
  52. package/dist/specs/popover.d.ts +213 -0
  53. package/dist/specs/popover.d.ts.map +1 -0
  54. package/dist/specs/popover.js +181 -0
  55. package/dist/specs/popover.js.map +1 -0
  56. package/dist/specs/popover.scenarios.d.ts +77 -0
  57. package/dist/specs/popover.scenarios.d.ts.map +1 -0
  58. package/dist/specs/popover.scenarios.js +368 -0
  59. package/dist/specs/popover.scenarios.js.map +1 -0
  60. package/dist/specs/text-field.d.ts +246 -0
  61. package/dist/specs/text-field.d.ts.map +1 -0
  62. package/dist/specs/text-field.js +229 -0
  63. package/dist/specs/text-field.js.map +1 -0
  64. package/dist/specs/text-field.scenarios.d.ts +49 -0
  65. package/dist/specs/text-field.scenarios.d.ts.map +1 -0
  66. package/dist/specs/text-field.scenarios.js +88 -0
  67. package/dist/specs/text-field.scenarios.js.map +1 -0
  68. package/llms.md +292 -0
  69. package/package.json +1 -1
@@ -0,0 +1,229 @@
1
+ import { defineContract } from '../contract.js';
2
+ /**
3
+ * Single-line text entry with an accessible label and native form semantics on the web.
4
+ * The editable value follows the controlled/autonomous ownership rules in ADR 0003.
5
+ */
6
+ export const textFieldContract = defineContract({
7
+ name: 'text-field',
8
+ tag: 'cosm-text-field',
9
+ description: 'Accepts a single line of text with an accessible label, optional help and error text, and native form validation on the web.',
10
+ role: 'textbox',
11
+ pattern: 'https://html.spec.whatwg.org/multipage/input.html',
12
+ props: {
13
+ label: {
14
+ type: 'string',
15
+ required: true,
16
+ description: 'Accessible name for the editable control. It is rendered above the control unless visually hidden.',
17
+ },
18
+ labelHidden: {
19
+ type: 'boolean',
20
+ default: false,
21
+ reflect: true,
22
+ description: 'Visually hides the label while keeping it available to assistive technology.',
23
+ },
24
+ value: {
25
+ type: 'string',
26
+ description: 'Current text. When bound, edits are proposals and the component waits for the owner to supply the accepted value.',
27
+ },
28
+ defaultValue: {
29
+ type: 'string',
30
+ default: '',
31
+ description: 'Initial value for autonomous use. Web form reset restores this value; it does not control subsequent edits.',
32
+ },
33
+ type: {
34
+ type: 'enum',
35
+ values: ['text', 'email', 'password', 'tel', 'url', 'search'],
36
+ default: 'text',
37
+ reflect: true,
38
+ description: 'Single-line input type. Native maps it to supported keyboard, autofill and secure-entry behavior.',
39
+ },
40
+ variant: {
41
+ type: 'enum',
42
+ values: ['outlined', 'filled'],
43
+ default: 'outlined',
44
+ reflect: true,
45
+ description: 'Visual treatment of the editable control.',
46
+ },
47
+ size: {
48
+ type: 'union',
49
+ variants: [{ type: 'enum', values: ['sm', 'md', 'lg'] }, { type: 'number' }],
50
+ default: 'md',
51
+ reflect: true,
52
+ description: 'Semantic size or a positive finite minimum editable-control height in CSS pixels on web and logical units on native.',
53
+ },
54
+ placeholder: {
55
+ type: 'string',
56
+ description: 'Short input hint; it never replaces the accessible label.',
57
+ },
58
+ helpText: {
59
+ type: 'string',
60
+ description: 'Optional supporting text associated with the editable control.',
61
+ },
62
+ error: {
63
+ type: 'string',
64
+ description: 'Optional externally supplied error text associated with the editable control.',
65
+ },
66
+ invalid: {
67
+ type: 'boolean',
68
+ default: false,
69
+ reflect: true,
70
+ description: 'External invalid state, independent of browser constraints or consumer business validation.',
71
+ },
72
+ required: {
73
+ type: 'boolean',
74
+ default: false,
75
+ reflect: true,
76
+ description: 'Exposes required semantics. On web, participates in native HTML constraint validation.',
77
+ },
78
+ disabled: {
79
+ type: 'boolean',
80
+ default: false,
81
+ reflect: true,
82
+ description: 'Disables editing and interaction. On web, follows disabled fieldsets and excludes the value from form submission.',
83
+ },
84
+ readOnly: {
85
+ type: 'boolean',
86
+ default: false,
87
+ reflect: true,
88
+ description: 'Prevents editing while remaining focusable and form-submittable on web; distinct from disabled.',
89
+ },
90
+ minLength: {
91
+ type: 'number',
92
+ description: 'Minimum number of characters. Web uses native HTML validity; native business validation remains the consumer’s responsibility.',
93
+ },
94
+ maxLength: {
95
+ type: 'number',
96
+ description: 'Maximum number of characters. Web uses native HTML validity and native applies supported input limits.',
97
+ },
98
+ pattern: {
99
+ type: 'string',
100
+ platforms: ['web', 'react', 'angular'],
101
+ description: 'Web-only HTML pattern constraint. Native does not emulate HTML regular-expression validation.',
102
+ },
103
+ name: {
104
+ type: 'string',
105
+ reflect: true,
106
+ platforms: ['web', 'react', 'angular'],
107
+ description: 'Form field name on web. React Native has no HTML form association or name-based submission.',
108
+ },
109
+ autoComplete: {
110
+ type: 'string',
111
+ description: 'Consumer-provided completion/autofill hint, mapped to attributes supported by each platform.',
112
+ },
113
+ inputMode: {
114
+ type: 'union',
115
+ variants: [
116
+ {
117
+ type: 'enum',
118
+ values: ['none', 'text', 'decimal', 'numeric', 'tel', 'search', 'email', 'url'],
119
+ },
120
+ ],
121
+ description: 'Input or keyboard hint (none, text, decimal, numeric, tel, search, email or url); it does not add numeric or multiline field behavior.',
122
+ },
123
+ startIcon: {
124
+ type: 'reference',
125
+ reference: 'IconDefinition',
126
+ options: ['search', 'house', 'heart', 'star'],
127
+ example: 'search',
128
+ description: 'Optional structured decorative icon before the editable text.',
129
+ },
130
+ endIcon: {
131
+ type: 'reference',
132
+ reference: 'IconDefinition',
133
+ options: ['search', 'house', 'heart', 'star'],
134
+ example: 'search',
135
+ description: 'Optional structured decorative icon after the editable text.',
136
+ },
137
+ iconFocusScope: {
138
+ type: 'enum',
139
+ values: ['control', 'input'],
140
+ default: 'control',
141
+ reflect: true,
142
+ description: 'When configured icon focus colors apply: control includes the input and clear/reveal buttons; input includes only the editable input. Does not change icons without a focus-color override.',
143
+ },
144
+ prefix: {
145
+ type: 'string',
146
+ description: 'Optional non-interactive text decoration before the editable text.',
147
+ },
148
+ suffix: {
149
+ type: 'string',
150
+ description: 'Optional non-interactive text decoration after the editable text.',
151
+ },
152
+ clearable: {
153
+ type: 'boolean',
154
+ default: false,
155
+ reflect: true,
156
+ description: 'Shows a clear action for non-empty editable fields. Supply clearLabel when enabled.',
157
+ },
158
+ clearLabel: {
159
+ type: 'string',
160
+ description: 'Consumer-supplied localized accessible name for the clear action.',
161
+ },
162
+ passwordReveal: {
163
+ type: 'boolean',
164
+ default: false,
165
+ reflect: true,
166
+ description: 'Opts into a reveal action for password fields. Supply both revealPasswordLabel and hidePasswordLabel when enabled.',
167
+ },
168
+ revealPasswordLabel: {
169
+ type: 'string',
170
+ description: 'Consumer-supplied localized accessible name while the password is concealed.',
171
+ },
172
+ hidePasswordLabel: {
173
+ type: 'string',
174
+ description: 'Consumer-supplied localized accessible name while the password is revealed.',
175
+ },
176
+ },
177
+ events: {
178
+ change: {
179
+ description: 'Proposes the current text after each user edit, including clear; this is not a blur/commit event.',
180
+ detail: 'TextFieldChangeDetail',
181
+ names: {
182
+ dom: 'cosm-change',
183
+ react: 'onChange',
184
+ angular: 'valueChange',
185
+ native: 'onValueChange',
186
+ },
187
+ },
188
+ submit: {
189
+ description: 'Reports the current text when the user invokes the field submit action (Enter/return).',
190
+ detail: 'TextFieldSubmitDetail',
191
+ names: {
192
+ dom: 'cosm-submit',
193
+ react: 'onSubmit',
194
+ angular: 'submit',
195
+ native: 'onSubmitEditing',
196
+ },
197
+ },
198
+ },
199
+ states: [{ prop: 'value', event: 'change', defaultProp: 'defaultValue' }],
200
+ slots: {},
201
+ parts: {
202
+ label: 'Accessible label above the control.',
203
+ control: 'Visual control containing the editable input and decorations.',
204
+ input: 'The single-line editable input.',
205
+ start: 'Start icon or prefix decoration.',
206
+ end: 'End icon, suffix decoration or clear/reveal action.',
207
+ help: 'Supporting text associated with the editable input.',
208
+ error: 'External or native-validity error text associated with the editable input.',
209
+ 'clear-button': 'Optional accessible clear action.',
210
+ 'reveal-button': 'Optional accessible password visibility action.',
211
+ },
212
+ cssProperties: {
213
+ '--cosm-text-field-background': 'Editable control background.',
214
+ '--cosm-text-field-color': 'Editable and decoration text color.',
215
+ '--cosm-text-field-placeholder': 'Placeholder text color.',
216
+ '--cosm-text-field-border': 'Editable control boundary color.',
217
+ '--cosm-text-field-focus': 'Visible focus indicator color.',
218
+ '--cosm-text-field-radius': 'Editable control corner radius.',
219
+ '--cosm-text-field-start-icon-color': 'Start icon color, independent of text and affixes.',
220
+ '--cosm-text-field-start-icon-focus-color': 'Start icon color within iconFocusScope; falls back to its normal color.',
221
+ '--cosm-text-field-end-icon-color': 'End icon color, independent of text and affixes.',
222
+ '--cosm-text-field-end-icon-focus-color': 'End icon color within iconFocusScope; falls back to its normal color.',
223
+ },
224
+ keyboard: [
225
+ { keys: ['Tab', 'Shift+Tab'], action: 'Moves focus to or from the enabled editable control.' },
226
+ { keys: ['Enter'], action: 'Invokes the submit action; web form behavior remains native.' },
227
+ ],
228
+ });
229
+ //# sourceMappingURL=text-field.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-field.js","sourceRoot":"","sources":["../../src/specs/text-field.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAYhD;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,cAAc,CAAC;IAC9C,IAAI,EAAE,YAAY;IAClB,GAAG,EAAE,iBAAiB;IACtB,WAAW,EACT,8HAA8H;IAChI,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,mDAAmD;IAC5D,KAAK,EAAE;QACL,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,WAAW,EACT,oGAAoG;SACvG;QACD,WAAW,EAAE;YACX,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,K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4
+ value: string;
5
+ selectionStart?: number;
6
+ composing?: boolean;
7
+ } | {
8
+ type: 'sync';
9
+ value: string;
10
+ } | {
11
+ type: 'clear';
12
+ } | {
13
+ type: 'reveal';
14
+ } | {
15
+ type: 'hide';
16
+ } | {
17
+ type: 'submit';
18
+ value?: string;
19
+ } | {
20
+ type: 'reset';
21
+ };
22
+ export interface TextFieldScenario {
23
+ name: string;
24
+ props: {
25
+ value?: string;
26
+ defaultValue?: string;
27
+ disabled?: boolean;
28
+ readOnly?: boolean;
29
+ clearable?: boolean;
30
+ passwordReveal?: boolean;
31
+ type?: 'text' | 'email' | 'password' | 'tel' | 'url' | 'search';
32
+ };
33
+ actions: readonly TextFieldAction[];
34
+ expected: {
35
+ value: string;
36
+ changes: readonly string[];
37
+ disabled: boolean;
38
+ submits?: readonly string[];
39
+ focused?: boolean;
40
+ selectionStart?: number;
41
+ compositionPreserved?: boolean;
42
+ passwordVisible?: boolean;
43
+ };
44
+ platforms?: readonly Platform[];
45
+ }
46
+ /** Shared state and interaction expectations for all text-field platform drivers. */
47
+ export declare const textFieldScenarios: readonly TextFieldScenario[];
48
+ export declare const textFieldScenariosFor: (platform: Platform) => TextFieldScenario[];
49
+ //# sourceMappingURL=text-field.scenarios.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-field.scenarios.d.ts","sourceRoot":"","sources":["../../src/specs/text-field.scenarios.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,MAAM,MAAM,eAAe,GACvB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,GAC7E;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GACjB;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export const textFieldScenarios = [
3
+ {
4
+ name: 'autonomous edits update the owned value and propose each edit',
5
+ props: { defaultValue: 'draft' },
6
+ actions: [{ type: 'edit', value: 'drafted' }],
7
+ expected: { value: 'drafted', changes: ['drafted'], disabled: false },
8
+ },
9
+ {
10
+ name: 'controlled edits wait for the owner to accept the proposal',
11
+ props: { value: 'before' },
12
+ actions: [
13
+ { type: 'edit', value: 'after' },
14
+ { type: 'sync', value: 'after' },
15
+ ],
16
+ expected: { value: 'after', changes: ['after'], disabled: false },
17
+ },
18
+ {
19
+ name: 'a refused controlled edit restores the value and preserves selection and composition',
20
+ props: { value: 'stable' },
21
+ actions: [{ type: 'edit', value: 'stablex', selectionStart: 6, composing: true }],
22
+ expected: {
23
+ value: 'stable',
24
+ changes: ['stablex'],
25
+ disabled: false,
26
+ selectionStart: 6,
27
+ compositionPreserved: true,
28
+ },
29
+ },
30
+ {
31
+ name: 'an empty controlled value remains controlled',
32
+ props: { value: '' },
33
+ actions: [{ type: 'edit', value: 'draft' }],
34
+ expected: { value: '', changes: ['draft'], disabled: false },
35
+ },
36
+ {
37
+ name: 'clear proposes an empty value and retains focus',
38
+ props: { defaultValue: 'draft', clearable: true },
39
+ actions: [{ type: 'clear' }],
40
+ expected: { value: '', changes: [''], disabled: false, focused: true },
41
+ },
42
+ {
43
+ name: 'a refused controlled clear restores its value and retains focus',
44
+ props: { value: 'draft', clearable: true },
45
+ actions: [{ type: 'clear' }],
46
+ expected: { value: 'draft', changes: [''], disabled: false, focused: true },
47
+ },
48
+ {
49
+ name: 'disabled fields ignore edits and clear requests',
50
+ props: { value: 'draft', disabled: true, clearable: true },
51
+ actions: [{ type: 'edit', value: 'changed' }, { type: 'clear' }],
52
+ expected: { value: 'draft', changes: [], disabled: true },
53
+ },
54
+ {
55
+ name: 'read-only fields ignore edits and clear requests',
56
+ props: { value: 'draft', readOnly: true, clearable: true },
57
+ actions: [{ type: 'edit', value: 'changed' }, { type: 'clear' }],
58
+ expected: { value: 'draft', changes: [], disabled: false },
59
+ },
60
+ {
61
+ name: 'password reveal toggles presentation without changing the value',
62
+ props: { value: 'secret', type: 'password', passwordReveal: true },
63
+ actions: [{ type: 'reveal' }, { type: 'hide' }],
64
+ expected: { value: 'secret', changes: [], disabled: false, passwordVisible: false },
65
+ },
66
+ {
67
+ name: 'submit reports the current value without proposing an edit',
68
+ props: { value: 'ready' },
69
+ actions: [{ type: 'submit' }],
70
+ expected: { value: 'ready', changes: [], disabled: false, submits: ['ready'] },
71
+ },
72
+ {
73
+ name: 'autonomous web form reset restores the default value',
74
+ props: { defaultValue: 'initial' },
75
+ actions: [{ type: 'edit', value: 'changed' }, { type: 'reset' }],
76
+ expected: { value: 'initial', changes: ['changed'], disabled: false },
77
+ platforms: ['web', 'react', 'angular'],
78
+ },
79
+ {
80
+ name: 'controlled web form reset proposes the default value',
81
+ props: { value: 'current', defaultValue: 'initial' },
82
+ actions: [{ type: 'reset' }],
83
+ expected: { value: 'current', changes: ['initial'], disabled: false },
84
+ platforms: ['web', 'react', 'angular'],
85
+ },
86
+ ];
87
+ export const textFieldScenariosFor = (platform) => textFieldScenarios.filter(scenario => !scenario.platforms || scenario.platforms.includes(platform));
88
+ //# sourceMappingURL=text-field.scenarios.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-field.scenarios.js","sourceRoot":"","sources":["../../src/specs/text-field.scenarios.ts"],"names":[],"mappings":"AAoCA,qFAAqF;AACrF,MAAM,CAAC,MAAM,kBAAkB,GAAiC;IAC9D;QACE,IAAI,EAAE,+DAA+D;QACrE,KAAK,EAAE,EAAE,YAAY,EAAE,OAAO,EAAE;QAChC,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;QAC7C,QAAQ,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE;KACtE;IACD;QACE,IAAI,EAAE,4DAA4D;Q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