@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
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,UAAU,EACV,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,OAAO,EACP,YAAY,GACb,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,UAAU,EACf,WAAW,EACX,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,wBAAwB,EACxB,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,UAAU,EACV,KAAK,YAAY,EAC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AK,aAAa,EAClB,KAAK,4BAA4B,EACjC,KAAK,oBAAoB,EACzB,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,uBAAuB,EAC5B,KAAK,WAAW,EAChB,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,wBAAwB,EAC7B,KAAK,eAAe,EACpB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,iCAAiC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
import { iconContract } from './specs/icon.js';
|
|
2
|
+
import { iconButtonContract } from './specs/icon-button.js';
|
|
3
|
+
import { listboxContract } from './specs/listbox.js';
|
|
4
|
+
import { popoverContract } from './specs/popover.js';
|
|
5
|
+
import { textFieldContract } from './specs/text-field.js';
|
|
1
6
|
export { buildOrder, catalog, catalogEntry, } from './catalog.js';
|
|
2
|
-
export { activeProps, generateSnippets, pascalCase, snippetTargets, supportsTarget, toAttribute, } from './codegen.js';
|
|
7
|
+
export { activeProps, generateComposedSnippets, generateSnippets, listboxItemExamples, listboxValueExamples, pascalCase, snippetTargets, supportsTarget, toAttribute, } from './codegen.js';
|
|
3
8
|
export { defaults, defineContract, eventNames, platforms, propNames, supports, } from './contract.js';
|
|
9
|
+
export { findListboxMatch, getListboxInitialActive, getListboxOptions, getListboxSelection, moveListboxActive, validateListboxSize, validateListboxValues, } from './headless/listbox.js';
|
|
4
10
|
export { getPressableState, } from './headless/pressable.js';
|
|
11
|
+
export { getTextFieldState, } from './headless/text-field.js';
|
|
5
12
|
export { componentReference, contractMarkdown, eventsMarkdown, propsMarkdown, propType, snippetsMarkdown, snippetTitles, } from './markdown.js';
|
|
6
13
|
export { aiRules, DOCS_URL, isStack, setupGuide, setupMarkdown, stacks, } from './setup.js';
|
|
7
14
|
export { buttonContract } from './specs/button.js';
|
|
@@ -10,5 +17,20 @@ import { buttonContract } from './specs/button.js';
|
|
|
10
17
|
/** Every component contract, keyed by name. Used by docs, AI references and drift tests. */
|
|
11
18
|
export const contracts = {
|
|
12
19
|
button: buttonContract,
|
|
20
|
+
icon: iconContract,
|
|
21
|
+
'text-field': textFieldContract,
|
|
22
|
+
'icon-button': iconButtonContract,
|
|
23
|
+
popover: popoverContract,
|
|
24
|
+
listbox: listboxContract,
|
|
13
25
|
};
|
|
26
|
+
export { iconContract } from './specs/icon.js';
|
|
27
|
+
export { iconScenarios, iconScenariosFor, } from './specs/icon.scenarios.js';
|
|
28
|
+
export { iconButtonContract, } from './specs/icon-button.js';
|
|
29
|
+
export { iconButtonScenarios, iconButtonScenariosFor, } from './specs/icon-button.scenarios.js';
|
|
30
|
+
export { listboxContract, } from './specs/listbox.js';
|
|
31
|
+
export { listboxScenarioItems, listboxScenarios, listboxScenariosFor, } from './specs/listbox.scenarios.js';
|
|
32
|
+
export { popoverContract, } from './specs/popover.js';
|
|
33
|
+
export { popoverScenarios, popoverScenariosFor, } from './specs/popover.scenarios.js';
|
|
34
|
+
export { textFieldContract, } from './specs/text-field.js';
|
|
35
|
+
export { textFieldScenarios, textFieldScenariosFor, } from './specs/text-field.scenarios.js';
|
|
14
36
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAIV,OAAO,EACP,YAAY,GACb,MAAM,cAAc,CAAC;AACtB,OAAO,EAEL,WAAW,EAGX,gBAAgB,EAChB,UAAU,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EACL,UAAU,EAIV,OAAO,EACP,YAAY,GACb,MAAM,cAAc,CAAC;AACtB,OAAO,EAEL,WAAW,EAGX,wBAAwB,EACxB,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,UAAU,EAGV,cAAc,EACd,cAAc,EACd,WAAW,GACZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAGL,QAAQ,EACR,cAAc,EAEd,UAAU,EAIV,SAAS,EACT,SAAS,EAET,QAAQ,GACT,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,iBAAiB,GAGlB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,iBAAiB,GAGlB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,QAAQ,EACR,gBAAgB,EAChB,aAAa,GACd,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,OAAO,EACP,QAAQ,EACR,OAAO,EAIP,UAAU,EACV,aAAa,EACb,MAAM,GACP,MAAM,YAAY,CAAC;AACpB,OAAO,EAA0B,cAAc,EAAoB,MAAM,mBAAmB,CAAC;AAC7F,OAAO,EAGL,eAAe,EACf,kBAAkB,GACnB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,4FAA4F;AAC5F,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,MAAM,EAAE,cAAc;IACtB,IAAI,EAAE,YAAY;IAClB,YAAY,EAAE,iBAAiB;IAC/B,aAAa,EAAE,kBAAkB;IACjC,OAAO,EAAE,eAAe;IACxB,OAAO,EAAE,eAAe;CAChB,CAAC;AACX,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAEL,aAAa,EACb,gBAAgB,GACjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAGL,kBAAkB,GACnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAGL,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAML,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAGL,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAML,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAIL,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAGL,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAGL,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,iCAAiC,CAAC"}
|
package/dist/markdown.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,aAAa,EAEnB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,aAAa,EAEnB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAS3E,eAAO,MAAM,QAAQ,GAAI,MAAM,QAAQ,WAapB,CAAC;AASpB,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,aAAa,EAAE,MAAM,CAKvD,CAAC;AAEF,uFAAuF;AACvF,wBAAgB,aAAa,CAAC,QAAQ,EAAE,iBAAiB,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM,CAkBtF;AAED,gDAAgD;AAChD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,iBAAiB,GAAG,MAAM,CAWlE;AAcD,mGAAmG;AACnG,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GACjC,MAAM,CAuBR;AAED,gGAAgG;AAChG,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,SAA4B,EACnC,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAM,GACjE,MAAM,CAQR;AAED,8FAA8F;AAC9F,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,iBAAiB,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAmC1F"}
|
package/dist/markdown.js
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
|
-
import { activeProps,
|
|
1
|
+
import { activeProps, generateComposedSnippets, pascalCase, toAttribute, } from './codegen.js';
|
|
2
|
+
import { iconContract } from './specs/icon.js';
|
|
2
3
|
const cell = (value) => value.replaceAll('|', '\\|').replaceAll('\n', ' ');
|
|
3
|
-
|
|
4
|
+
const exampleChild = (contract) => contract.name === 'icon-button'
|
|
5
|
+
? { contract: iconContract, values: { icon: 'heart' } }
|
|
6
|
+
: undefined;
|
|
7
|
+
export const propType = (spec) => spec.type === 'enum'
|
|
8
|
+
? spec.values.map(value => `'${value}'`).join(' \\| ')
|
|
9
|
+
: spec.type === 'union'
|
|
10
|
+
? spec.variants
|
|
11
|
+
.map(variant => variant.type === 'enum'
|
|
12
|
+
? variant.values.map(value => `'${value}'`).join(' \\| ')
|
|
13
|
+
: 'number')
|
|
14
|
+
.join(' \\| ')
|
|
15
|
+
: spec.type === 'reference'
|
|
16
|
+
? spec.reference
|
|
17
|
+
: spec.type;
|
|
4
18
|
const snippetLanguage = {
|
|
5
19
|
html: 'html',
|
|
6
20
|
react: 'tsx',
|
|
@@ -19,7 +33,12 @@ export function propsMarkdown(contract, platform) {
|
|
|
19
33
|
.filter(([, spec]) => !platform || !spec.platforms || spec.platforms.includes(platform))
|
|
20
34
|
.map(([name, spec]) => {
|
|
21
35
|
const attribute = platform === 'web' && toAttribute(name) !== name ? ` (\`${toAttribute(name)}\`)` : '';
|
|
22
|
-
const
|
|
36
|
+
const defaultValue = 'default' in spec ? spec.default : undefined;
|
|
37
|
+
const value = defaultValue === undefined
|
|
38
|
+
? 'required' in spec && spec.required
|
|
39
|
+
? 'Required'
|
|
40
|
+
: '—'
|
|
41
|
+
: `\`${String(defaultValue)}\``;
|
|
23
42
|
return `| \`${name}\`${attribute} | ${propType(spec)} | ${value} | ${cell(spec.description)} |`;
|
|
24
43
|
});
|
|
25
44
|
return ['| Prop | Type | Default | Description |', '| --- | --- | --- | --- |', ...rows].join('\n');
|
|
@@ -71,7 +90,7 @@ export function contractMarkdown(contract, options = {}) {
|
|
|
71
90
|
}
|
|
72
91
|
/** Usage snippets (default values) as fenced code blocks, one per platform of the component. */
|
|
73
92
|
export function snippetsMarkdown(contract, content = pascalCase(contract.name), values = {}) {
|
|
74
|
-
const snippets =
|
|
93
|
+
const snippets = generateComposedSnippets(contract, values, content, exampleChild(contract));
|
|
75
94
|
return Object.entries(snippets)
|
|
76
95
|
.map(([target, code]) => `**${snippetTitles[target]}**\n\n\`\`\`${snippetLanguage[target]}\n${code}\n\`\`\``)
|
|
77
96
|
.join('\n\n');
|
|
@@ -94,7 +113,7 @@ export function componentReference(contract, platform) {
|
|
|
94
113
|
return `\`${names[platform]}\` → \`${event.detail}\``;
|
|
95
114
|
});
|
|
96
115
|
const target = platform === 'web' ? 'html' : platform;
|
|
97
|
-
const example =
|
|
116
|
+
const example = generateComposedSnippets(contract, Object.fromEntries(activeProps(contract, {}, platform).map(prop => [prop.name, prop.value])), pascalCase(contract.name), exampleChild(contract))[target];
|
|
98
117
|
return [
|
|
99
118
|
`### ${heading}`,
|
|
100
119
|
'',
|
package/dist/markdown.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,
|
|
1
|
+
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,wBAAwB,EACxB,UAAU,EAEV,WAAW,GACZ,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AACnF,MAAM,YAAY,GAAG,CAAC,QAA2B,EAAE,EAAE,CACnD,QAAQ,CAAC,IAAI,KAAK,aAAa;IAC7B,CAAC,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE;IACvD,CAAC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AC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG;QAC5D,EAAE;QACF,SAAS,eAAe,CAAC,MAAM,CAAC,KAAK,OAAO,IAAI,EAAE,UAAU;KAC7D,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import type { ButtonPressDetail } from './button.js';
|
|
2
|
+
/** Activation source, shared with Button. */
|
|
3
|
+
export type IconButtonPressDetail = ButtonPressDetail;
|
|
4
|
+
/** The proposed toggle state. */
|
|
5
|
+
export interface IconButtonPressedChangeDetail {
|
|
6
|
+
pressed: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* An icon-only action or toggle with a required accessible name.
|
|
10
|
+
*
|
|
11
|
+
* | State | Autonomous | Controlled | Event |
|
|
12
|
+
* | --- | --- | --- | --- |
|
|
13
|
+
* | pressed | Starts at defaultPressed and commits each toggle | A supplied pressed, including false, stays unchanged until the owner updates it | pressedChange proposes the opposite value |
|
|
14
|
+
*
|
|
15
|
+
* Controlled ownership is determined by whether pressed is supplied, not its default value.
|
|
16
|
+
* Toggle mode exposes the pressed state (aria-pressed on web); action mode does not expose or change it.
|
|
17
|
+
*
|
|
18
|
+
* | Event | DOM | React | Angular | Native |
|
|
19
|
+
* | --- | --- | --- | --- | --- |
|
|
20
|
+
* | press | cosm-press | onPress | press | onPress |
|
|
21
|
+
* | pressedChange | cosm-pressed-change | onPressedChange | pressedChange | onPressedChange |
|
|
22
|
+
* See ADR 0003 and the WAI-ARIA APG button pattern.
|
|
23
|
+
*/
|
|
24
|
+
export declare const iconButtonContract: {
|
|
25
|
+
readonly name: "icon-button";
|
|
26
|
+
readonly tag: "cosm-icon-button";
|
|
27
|
+
readonly description: "Activates an action or toggles a boolean state using a labeled icon.";
|
|
28
|
+
readonly role: "button";
|
|
29
|
+
readonly pattern: "https://www.w3.org/WAI/ARIA/apg/patterns/button/";
|
|
30
|
+
readonly props: {
|
|
31
|
+
readonly label: {
|
|
32
|
+
readonly type: "string";
|
|
33
|
+
readonly required: true;
|
|
34
|
+
readonly description: "Required localized accessible name. Missing, empty or whitespace-only labels are rejected.";
|
|
35
|
+
};
|
|
36
|
+
readonly mode: {
|
|
37
|
+
readonly type: "enum";
|
|
38
|
+
readonly values: readonly ["action", "toggle"];
|
|
39
|
+
readonly default: "action";
|
|
40
|
+
readonly reflect: true;
|
|
41
|
+
readonly description: "Action activates without toggle state; toggle exposes and changes pressed state.";
|
|
42
|
+
};
|
|
43
|
+
readonly variant: {
|
|
44
|
+
readonly type: "enum";
|
|
45
|
+
readonly values: readonly ["solid", "soft", "outline", "ghost"];
|
|
46
|
+
readonly default: "solid";
|
|
47
|
+
readonly reflect: true;
|
|
48
|
+
readonly description: "Visual emphasis, from highest (solid) to lowest (ghost).";
|
|
49
|
+
};
|
|
50
|
+
readonly tone: {
|
|
51
|
+
readonly type: "enum";
|
|
52
|
+
readonly values: readonly ["primary", "neutral", "danger"];
|
|
53
|
+
readonly default: "primary";
|
|
54
|
+
readonly reflect: true;
|
|
55
|
+
readonly description: "Color role. Use danger for destructive actions.";
|
|
56
|
+
};
|
|
57
|
+
readonly size: {
|
|
58
|
+
readonly type: "enum";
|
|
59
|
+
readonly values: readonly ["sm", "md", "lg"];
|
|
60
|
+
readonly default: "md";
|
|
61
|
+
readonly reflect: true;
|
|
62
|
+
readonly description: "Size of the square visual control.";
|
|
63
|
+
};
|
|
64
|
+
readonly disabled: {
|
|
65
|
+
readonly type: "boolean";
|
|
66
|
+
readonly default: false;
|
|
67
|
+
readonly reflect: true;
|
|
68
|
+
readonly description: "Prevents activation and removes the web button from the tab order.";
|
|
69
|
+
};
|
|
70
|
+
readonly type: {
|
|
71
|
+
readonly type: "enum";
|
|
72
|
+
readonly values: readonly ["button", "submit", "reset"];
|
|
73
|
+
readonly default: "button";
|
|
74
|
+
readonly platforms: readonly ["web", "react", "angular"];
|
|
75
|
+
readonly description: "Native web button form behavior.";
|
|
76
|
+
};
|
|
77
|
+
readonly pressed: {
|
|
78
|
+
readonly type: "boolean";
|
|
79
|
+
readonly default: false;
|
|
80
|
+
readonly description: "Toggle state. If supplied, including false, activation proposes changes without committing them until the owner updates this prop.";
|
|
81
|
+
};
|
|
82
|
+
readonly defaultPressed: {
|
|
83
|
+
readonly type: "boolean";
|
|
84
|
+
readonly default: false;
|
|
85
|
+
readonly description: "Initial toggle state when pressed is not supplied; it does not control later changes.";
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
readonly events: {
|
|
89
|
+
readonly press: {
|
|
90
|
+
readonly description: "Reports each enabled activation by pointer, keyboard or programmatically.";
|
|
91
|
+
readonly detail: "IconButtonPressDetail";
|
|
92
|
+
readonly names: {
|
|
93
|
+
readonly dom: "cosm-press";
|
|
94
|
+
readonly react: "onPress";
|
|
95
|
+
readonly angular: "press";
|
|
96
|
+
readonly native: "onPress";
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
readonly pressedChange: {
|
|
100
|
+
readonly description: "Reports the proposed next pressed state on toggle activation; controlled state waits for the owner.";
|
|
101
|
+
readonly detail: "IconButtonPressedChangeDetail";
|
|
102
|
+
readonly names: {
|
|
103
|
+
readonly dom: "cosm-pressed-change";
|
|
104
|
+
readonly react: "onPressedChange";
|
|
105
|
+
readonly angular: "pressedChange";
|
|
106
|
+
readonly native: "onPressedChange";
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
readonly states: readonly [{
|
|
111
|
+
readonly prop: "pressed";
|
|
112
|
+
readonly event: "pressedChange";
|
|
113
|
+
readonly defaultProp: "defaultPressed";
|
|
114
|
+
}];
|
|
115
|
+
readonly slots: {
|
|
116
|
+
readonly '': "Decorative icon content; the label supplies the accessible name.";
|
|
117
|
+
};
|
|
118
|
+
readonly parts: {
|
|
119
|
+
readonly base: "The native button element.";
|
|
120
|
+
};
|
|
121
|
+
readonly cssProperties: {
|
|
122
|
+
readonly '--cosm-icon-button-background': "Control background.";
|
|
123
|
+
readonly '--cosm-icon-button-color': "Icon foreground color.";
|
|
124
|
+
readonly '--cosm-icon-button-border': "Control border color.";
|
|
125
|
+
readonly '--cosm-icon-button-radius': "Control corner radius.";
|
|
126
|
+
readonly '--cosm-icon-button-focus': "Visible focus indicator color.";
|
|
127
|
+
};
|
|
128
|
+
readonly keyboard: readonly [{
|
|
129
|
+
readonly keys: readonly ["Tab", "Shift+Tab"];
|
|
130
|
+
readonly action: "Moves focus to or from the enabled button.";
|
|
131
|
+
}, {
|
|
132
|
+
readonly keys: readonly ["Enter", "Space"];
|
|
133
|
+
readonly action: "Activates the button; toggle mode also proposes a change.";
|
|
134
|
+
}];
|
|
135
|
+
};
|
|
136
|
+
//# sourceMappingURL=icon-button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon-button.d.ts","sourceRoot":"","sources":["../../src/specs/icon-button.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,6CAA6C;AAC7C,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,CAAC;AAEtD,iCAAiC;AACjC,MAAM,WAAW,6BAA6B;IAC5C,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyG7B,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { defineContract } from '../contract.js';
|
|
2
|
+
/**
|
|
3
|
+
* An icon-only action or toggle with a required accessible name.
|
|
4
|
+
*
|
|
5
|
+
* | State | Autonomous | Controlled | Event |
|
|
6
|
+
* | --- | --- | --- | --- |
|
|
7
|
+
* | pressed | Starts at defaultPressed and commits each toggle | A supplied pressed, including false, stays unchanged until the owner updates it | pressedChange proposes the opposite value |
|
|
8
|
+
*
|
|
9
|
+
* Controlled ownership is determined by whether pressed is supplied, not its default value.
|
|
10
|
+
* Toggle mode exposes the pressed state (aria-pressed on web); action mode does not expose or change it.
|
|
11
|
+
*
|
|
12
|
+
* | Event | DOM | React | Angular | Native |
|
|
13
|
+
* | --- | --- | --- | --- | --- |
|
|
14
|
+
* | press | cosm-press | onPress | press | onPress |
|
|
15
|
+
* | pressedChange | cosm-pressed-change | onPressedChange | pressedChange | onPressedChange |
|
|
16
|
+
* See ADR 0003 and the WAI-ARIA APG button pattern.
|
|
17
|
+
*/
|
|
18
|
+
export const iconButtonContract = defineContract({
|
|
19
|
+
name: 'icon-button',
|
|
20
|
+
tag: 'cosm-icon-button',
|
|
21
|
+
description: 'Activates an action or toggles a boolean state using a labeled icon.',
|
|
22
|
+
role: 'button',
|
|
23
|
+
pattern: 'https://www.w3.org/WAI/ARIA/apg/patterns/button/',
|
|
24
|
+
props: {
|
|
25
|
+
label: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
required: true,
|
|
28
|
+
description: 'Required localized accessible name. Missing, empty or whitespace-only labels are rejected.',
|
|
29
|
+
},
|
|
30
|
+
mode: {
|
|
31
|
+
type: 'enum',
|
|
32
|
+
values: ['action', 'toggle'],
|
|
33
|
+
default: 'action',
|
|
34
|
+
reflect: true,
|
|
35
|
+
description: 'Action activates without toggle state; toggle exposes and changes pressed state.',
|
|
36
|
+
},
|
|
37
|
+
variant: {
|
|
38
|
+
type: 'enum',
|
|
39
|
+
values: ['solid', 'soft', 'outline', 'ghost'],
|
|
40
|
+
default: 'solid',
|
|
41
|
+
reflect: true,
|
|
42
|
+
description: 'Visual emphasis, from highest (solid) to lowest (ghost).',
|
|
43
|
+
},
|
|
44
|
+
tone: {
|
|
45
|
+
type: 'enum',
|
|
46
|
+
values: ['primary', 'neutral', 'danger'],
|
|
47
|
+
default: 'primary',
|
|
48
|
+
reflect: true,
|
|
49
|
+
description: 'Color role. Use danger for destructive actions.',
|
|
50
|
+
},
|
|
51
|
+
size: {
|
|
52
|
+
type: 'enum',
|
|
53
|
+
values: ['sm', 'md', 'lg'],
|
|
54
|
+
default: 'md',
|
|
55
|
+
reflect: true,
|
|
56
|
+
description: 'Size of the square visual control.',
|
|
57
|
+
},
|
|
58
|
+
disabled: {
|
|
59
|
+
type: 'boolean',
|
|
60
|
+
default: false,
|
|
61
|
+
reflect: true,
|
|
62
|
+
description: 'Prevents activation and removes the web button from the tab order.',
|
|
63
|
+
},
|
|
64
|
+
type: {
|
|
65
|
+
type: 'enum',
|
|
66
|
+
values: ['button', 'submit', 'reset'],
|
|
67
|
+
default: 'button',
|
|
68
|
+
platforms: ['web', 'react', 'angular'],
|
|
69
|
+
description: 'Native web button form behavior.',
|
|
70
|
+
},
|
|
71
|
+
pressed: {
|
|
72
|
+
type: 'boolean',
|
|
73
|
+
default: false,
|
|
74
|
+
description: 'Toggle state. If supplied, including false, activation proposes changes without committing them until the owner updates this prop.',
|
|
75
|
+
},
|
|
76
|
+
defaultPressed: {
|
|
77
|
+
type: 'boolean',
|
|
78
|
+
default: false,
|
|
79
|
+
description: 'Initial toggle state when pressed is not supplied; it does not control later changes.',
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
events: {
|
|
83
|
+
press: {
|
|
84
|
+
description: 'Reports each enabled activation by pointer, keyboard or programmatically.',
|
|
85
|
+
detail: 'IconButtonPressDetail',
|
|
86
|
+
names: { dom: 'cosm-press', react: 'onPress', angular: 'press', native: 'onPress' },
|
|
87
|
+
},
|
|
88
|
+
pressedChange: {
|
|
89
|
+
description: 'Reports the proposed next pressed state on toggle activation; controlled state waits for the owner.',
|
|
90
|
+
detail: 'IconButtonPressedChangeDetail',
|
|
91
|
+
names: {
|
|
92
|
+
dom: 'cosm-pressed-change',
|
|
93
|
+
react: 'onPressedChange',
|
|
94
|
+
angular: 'pressedChange',
|
|
95
|
+
native: 'onPressedChange',
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
states: [{ prop: 'pressed', event: 'pressedChange', defaultProp: 'defaultPressed' }],
|
|
100
|
+
slots: {
|
|
101
|
+
'': 'Decorative icon content; the label supplies the accessible name.',
|
|
102
|
+
},
|
|
103
|
+
parts: { base: 'The native button element.' },
|
|
104
|
+
cssProperties: {
|
|
105
|
+
'--cosm-icon-button-background': 'Control background.',
|
|
106
|
+
'--cosm-icon-button-color': 'Icon foreground color.',
|
|
107
|
+
'--cosm-icon-button-border': 'Control border color.',
|
|
108
|
+
'--cosm-icon-button-radius': 'Control corner radius.',
|
|
109
|
+
'--cosm-icon-button-focus': 'Visible focus indicator color.',
|
|
110
|
+
},
|
|
111
|
+
keyboard: [
|
|
112
|
+
{ keys: ['Tab', 'Shift+Tab'], action: 'Moves focus to or from the enabled button.' },
|
|
113
|
+
{
|
|
114
|
+
keys: ['Enter', 'Space'],
|
|
115
|
+
action: 'Activates the button; toggle mode also proposes a change.',
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
});
|
|
119
|
+
//# sourceMappingURL=icon-button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon-button.js","sourceRoot":"","sources":["../../src/specs/icon-button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAWhD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,cAAc,CAAC;IAC/C,IAAI,EAAE,aAAa;IACnB,GAAG,EAAE,kBAAkB;IACvB,WAAW,EAAE,sEAAsE;IACnF,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,kDAAkD;IAC3D,KAAK,EAAE;QACL,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,WAAW,EACT,4FAA4F;SAC/F;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,MAAM;YACZ,MAAM,EAA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AE;YACL,WAAW,EAAE,2EAA2E;YACxF,MAAM,EAAE,uBAAuB;YAC/B,KAAK,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE;SACpF;QACD,aAAa,EAAE;YACb,WAAW,EACT,qGAAqG;YACvG,MAAM,EAAE,+BAA+B;YACvC,KAAK,EAAE;gBACL,GAAG,EAAE,qBAAqB;gBAC1B,KAAK,EAAE,iBAAiB;gBACxB,OAAO,EAAE,eAAe;gBACxB,MAAM,EAAE,iBAAiB;aAC1B;SACF;KACF;IACD,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC;IACpF,KAAK,EAAE;QACL,EAAE,EAAE,kEAAkE;KACvE;IACD,KAAK,EAAE,EAAE,IAAI,EAAE,4BAA4B,EAAE;IAC7C,aAAa,EAAE;QACb,+BAA+B,EAAE,qBAAqB;QACtD,0BAA0B,EAAE,wBAAwB;QACpD,2BAA2B,EAAE,uBAAuB;QACpD,2BAA2B,EAAE,wBAAwB;QACrD,0BAA0B,EAAE,gCAAgC;KAC7D;IACD,QAAQ,EAAE;QACR,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,4CAA4C,EAAE;QACpF;YACE,IAAI,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC;YACxB,MAAM,EAAE,2DAA2D;SACpE;KACF;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ContractProps, Platform } from '../contract.js';
|
|
2
|
+
import type { PressSource } from './button.js';
|
|
3
|
+
import type { ButtonAction } from './button.scenarios.js';
|
|
4
|
+
import type { iconButtonContract } from './icon-button.js';
|
|
5
|
+
/** A sync action simulates the owner supplying a new controlled pressed prop. */
|
|
6
|
+
export type IconButtonAction = ButtonAction | {
|
|
7
|
+
type: 'sync';
|
|
8
|
+
pressed: boolean;
|
|
9
|
+
};
|
|
10
|
+
export interface IconButtonScenario {
|
|
11
|
+
name: string;
|
|
12
|
+
props: ContractProps<typeof iconButtonContract, 'web'>;
|
|
13
|
+
actions: readonly IconButtonAction[];
|
|
14
|
+
expected: {
|
|
15
|
+
disabled: boolean;
|
|
16
|
+
presses: number;
|
|
17
|
+
sources: readonly PressSource[];
|
|
18
|
+
/** Ordered pressed-change detail values. */
|
|
19
|
+
changes: readonly boolean[];
|
|
20
|
+
/** Exposed toggle state; null means action mode has no pressed semantics. */
|
|
21
|
+
pressed: boolean | null;
|
|
22
|
+
};
|
|
23
|
+
platforms?: readonly Platform[];
|
|
24
|
+
}
|
|
25
|
+
/** Shared state and interaction expectations for platform drivers. */
|
|
26
|
+
export declare const iconButtonScenarios: readonly IconButtonScenario[];
|
|
27
|
+
export declare const iconButtonScenariosFor: (platform: Platform) => IconButtonScenario[];
|
|
28
|
+
//# sourceMappingURL=icon-button.scenarios.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon-button.scenarios.d.ts","sourceRoot":"","sources":["../../src/specs/icon-button.scenarios.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,iFAAiF;AACjF,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC;AAEjF,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,aAAa,CAAC,OAAO,kBAAkB,EAAE,KAAK,CAAC,CAAC;IACvD,OAAO,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACrC,QAAQ,EAAE;QACR,QAAQ,EAAE,OAAO,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,SAAS,WAAW,EAAE,CAAC;QAChC,4CAA4C;QAC5C,OAAO,EAAE,SAAS,OAAO,EAAE,CAAC;QAC5B,6EAA6E;QAC7E,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;KACzB,CAAC;IACF,SAAS,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAC;CACjC;AAED,sEAAsE;AACtE,eAAO,MAAM,mBAAmB,EAAE,SAAS,kBAAkB,EA2F5D,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,UAAU,QAAQ,yBAGtD,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/** Shared state and interaction expectations for platform drivers. */
|
|
2
|
+
export const iconButtonScenarios = [
|
|
3
|
+
{
|
|
4
|
+
name: 'action activation reports a press without toggle state',
|
|
5
|
+
props: { label: 'Favorite', pressed: true },
|
|
6
|
+
actions: [{ type: 'press', source: 'pointer' }],
|
|
7
|
+
expected: { disabled: false, presses: 1, sources: ['pointer'], changes: [], pressed: null },
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
name: 'disabled toggle ignores activation',
|
|
11
|
+
props: { label: 'Favorite', mode: 'toggle', disabled: true, defaultPressed: true },
|
|
12
|
+
actions: [{ type: 'press', source: 'pointer' }],
|
|
13
|
+
expected: { disabled: true, presses: 0, sources: [], changes: [], pressed: true },
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: 'autonomous toggle commits each activation',
|
|
17
|
+
props: { label: 'Favorite', mode: 'toggle' },
|
|
18
|
+
actions: [
|
|
19
|
+
{ type: 'press', source: 'pointer' },
|
|
20
|
+
{ type: 'press', source: 'pointer' },
|
|
21
|
+
],
|
|
22
|
+
expected: {
|
|
23
|
+
disabled: false,
|
|
24
|
+
presses: 2,
|
|
25
|
+
sources: ['pointer', 'pointer'],
|
|
26
|
+
changes: [true, false],
|
|
27
|
+
pressed: false,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'controlled false stays false when the owner refuses repeated proposals',
|
|
32
|
+
props: { label: 'Favorite', mode: 'toggle', pressed: false, defaultPressed: true },
|
|
33
|
+
actions: [
|
|
34
|
+
{ type: 'press', source: 'pointer' },
|
|
35
|
+
{ type: 'press', source: 'pointer' },
|
|
36
|
+
],
|
|
37
|
+
expected: {
|
|
38
|
+
disabled: false,
|
|
39
|
+
presses: 2,
|
|
40
|
+
sources: ['pointer', 'pointer'],
|
|
41
|
+
changes: [true, true],
|
|
42
|
+
pressed: false,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'controlled toggle uses the value accepted by the owner',
|
|
47
|
+
props: { label: 'Favorite', mode: 'toggle', pressed: false },
|
|
48
|
+
actions: [
|
|
49
|
+
{ type: 'press', source: 'pointer' },
|
|
50
|
+
{ type: 'sync', pressed: true },
|
|
51
|
+
{ type: 'press', source: 'pointer' },
|
|
52
|
+
],
|
|
53
|
+
expected: {
|
|
54
|
+
disabled: false,
|
|
55
|
+
presses: 2,
|
|
56
|
+
sources: ['pointer', 'pointer'],
|
|
57
|
+
changes: [true, false],
|
|
58
|
+
pressed: true,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: 'defaultPressed initializes an autonomous toggle',
|
|
63
|
+
props: { label: 'Favorite', mode: 'toggle', defaultPressed: true },
|
|
64
|
+
actions: [{ type: 'press', source: 'pointer' }],
|
|
65
|
+
expected: {
|
|
66
|
+
disabled: false,
|
|
67
|
+
presses: 1,
|
|
68
|
+
sources: ['pointer'],
|
|
69
|
+
changes: [false],
|
|
70
|
+
pressed: false,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: 'Enter activates an action button',
|
|
75
|
+
props: { label: 'Favorite' },
|
|
76
|
+
actions: [{ type: 'key', key: 'Enter' }],
|
|
77
|
+
expected: { disabled: false, presses: 1, sources: ['keyboard'], changes: [], pressed: null },
|
|
78
|
+
platforms: ['web', 'react', 'angular'],
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: 'Space activates a toggle button',
|
|
82
|
+
props: { label: 'Favorite', mode: 'toggle' },
|
|
83
|
+
actions: [{ type: 'key', key: ' ' }],
|
|
84
|
+
expected: {
|
|
85
|
+
disabled: false,
|
|
86
|
+
presses: 1,
|
|
87
|
+
sources: ['keyboard'],
|
|
88
|
+
changes: [true],
|
|
89
|
+
pressed: true,
|
|
90
|
+
},
|
|
91
|
+
platforms: ['web', 'react', 'angular'],
|
|
92
|
+
},
|
|
93
|
+
];
|
|
94
|
+
export const iconButtonScenariosFor = (platform) => iconButtonScenarios.filter(scenario => !scenario.platforms || scenario.platforms.includes(platform));
|
|
95
|
+
//# sourceMappingURL=icon-button.scenarios.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon-button.scenarios.js","sourceRoot":"","sources":["../../src/specs/icon-button.scenarios.ts"],"names":[],"mappings":"AAwBA,sEAAsE;AACtE,MAAM,CAAC,MAAM,mBAAmB,GAAkC;IAChE;QACE,IAAI,EAAE,wDAAwD;QAC9D,KAAK,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE;QAC3C,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;QAC/C,QAAQ,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;KAC5F;IACD;QACE,IAAI,EAAE,oCAAoC;QAC1C,KAAK,EAAE,EAAE,KA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AE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;QAC5F,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,CAAC;KACvC;IACD;QACE,IAAI,EAAE,iCAAiC;QACvC,KAAK,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC5C,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;QACpC,QAAQ,EAAE;YACR,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,CAAC;YACV,OAAO,EAAE,CAAC,UAAU,CAAC;YACrB,OAAO,EAAE,CAAC,IAAI,CAAC;YACf,OAAO,EAAE,IAAI;SACd;QACD,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,CAAC;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,66 @@
|
|
|
1
|
+
/** A non-interactive vector icon with decorative or informative semantics. */
|
|
2
|
+
export declare const iconContract: {
|
|
3
|
+
readonly name: "icon";
|
|
4
|
+
readonly tag: "cosm-icon";
|
|
5
|
+
readonly description: "Renders a structured SVG icon. Decorative icons are hidden from assistive technology; informative icons require a text label.";
|
|
6
|
+
readonly role: "img";
|
|
7
|
+
readonly pattern: "https://www.w3.org/WAI/WCAG22/Techniques/aria/ARIA24";
|
|
8
|
+
readonly props: {
|
|
9
|
+
readonly icon: {
|
|
10
|
+
readonly type: "reference";
|
|
11
|
+
readonly reference: "IconDefinition";
|
|
12
|
+
readonly required: true;
|
|
13
|
+
readonly options: readonly ["house", "heart", "search", "star"];
|
|
14
|
+
readonly example: "house";
|
|
15
|
+
readonly description: "Structured icon definition, commonly imported from @joralvmel/cosmos-icons.";
|
|
16
|
+
};
|
|
17
|
+
readonly size: {
|
|
18
|
+
readonly type: "union";
|
|
19
|
+
readonly variants: readonly [{
|
|
20
|
+
readonly type: "enum";
|
|
21
|
+
readonly values: readonly ["sm", "md", "lg"];
|
|
22
|
+
}, {
|
|
23
|
+
readonly type: "number";
|
|
24
|
+
}];
|
|
25
|
+
readonly default: "md";
|
|
26
|
+
readonly reflect: true;
|
|
27
|
+
readonly description: "Semantic size (16, 20 or 24) or a positive finite number in pixels / native units.";
|
|
28
|
+
};
|
|
29
|
+
readonly stroke: {
|
|
30
|
+
readonly type: "string";
|
|
31
|
+
readonly default: "currentColor";
|
|
32
|
+
readonly description: "Stroke paint; currentColor inherits on web and resolves to the theme foreground on native.";
|
|
33
|
+
};
|
|
34
|
+
readonly fill: {
|
|
35
|
+
readonly type: "string";
|
|
36
|
+
readonly default: "none";
|
|
37
|
+
readonly description: "Root fill paint. Explicit node fills take precedence.";
|
|
38
|
+
};
|
|
39
|
+
readonly strokeWidth: {
|
|
40
|
+
readonly type: "number";
|
|
41
|
+
readonly default: 2;
|
|
42
|
+
readonly description: "Finite nonnegative stroke width in SVG viewBox units.";
|
|
43
|
+
};
|
|
44
|
+
readonly label: {
|
|
45
|
+
readonly type: "string";
|
|
46
|
+
readonly description: "Accessible name required when decorative is false.";
|
|
47
|
+
};
|
|
48
|
+
readonly decorative: {
|
|
49
|
+
readonly type: "boolean";
|
|
50
|
+
readonly default: true;
|
|
51
|
+
readonly reflect: true;
|
|
52
|
+
readonly description: "Hides the icon from assistive technology when true.";
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
readonly events: {};
|
|
56
|
+
readonly states: readonly [];
|
|
57
|
+
readonly slots: {};
|
|
58
|
+
readonly parts: {
|
|
59
|
+
readonly icon: "Rendered SVG image.";
|
|
60
|
+
};
|
|
61
|
+
readonly cssProperties: {
|
|
62
|
+
readonly '--cosm-icon-size': "Override the rendered icon width and height.";
|
|
63
|
+
};
|
|
64
|
+
readonly keyboard: readonly [];
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=icon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../src/specs/icon.ts"],"names":[],"mappings":"AAEA,8EAA8E;AAC9E,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyDvB,CAAC"}
|