@joralvmel/cosmos-core 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/catalog.d.ts +3 -3
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +25 -6
- package/dist/catalog.js.map +1 -1
- package/dist/codegen.d.ts +16 -0
- package/dist/codegen.d.ts.map +1 -1
- package/dist/codegen.js +396 -57
- package/dist/codegen.js.map +1 -1
- package/dist/headless/calendar.d.ts +32 -0
- package/dist/headless/calendar.d.ts.map +1 -0
- package/dist/headless/calendar.js +242 -0
- package/dist/headless/calendar.js.map +1 -0
- package/dist/headless/listbox.d.ts +9 -0
- package/dist/headless/listbox.d.ts.map +1 -0
- package/dist/headless/listbox.js +103 -0
- package/dist/headless/listbox.js.map +1 -0
- package/dist/headless/pagination.d.ts +34 -0
- package/dist/headless/pagination.d.ts.map +1 -0
- package/dist/headless/pagination.js +92 -0
- package/dist/headless/pagination.js.map +1 -0
- package/dist/headless/radio-group.d.ts +10 -0
- package/dist/headless/radio-group.d.ts.map +1 -0
- package/dist/headless/radio-group.js +59 -0
- package/dist/headless/radio-group.js.map +1 -0
- package/dist/headless/select.d.ts +4 -0
- package/dist/headless/select.d.ts.map +1 -0
- package/dist/headless/select.js +7 -0
- package/dist/headless/select.js.map +1 -0
- package/dist/headless/size.d.ts +3 -0
- package/dist/headless/size.d.ts.map +1 -0
- package/dist/headless/size.js +7 -0
- package/dist/headless/size.js.map +1 -0
- package/dist/headless/text-field.d.ts +25 -0
- package/dist/headless/text-field.d.ts.map +1 -0
- package/dist/headless/text-field.js +12 -0
- package/dist/headless/text-field.js.map +1 -0
- package/dist/index.d.ts +1709 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +60 -1
- package/dist/index.js.map +1 -1
- package/dist/markdown.d.ts.map +1 -1
- package/dist/markdown.js +7 -3
- package/dist/markdown.js.map +1 -1
- package/dist/specs/badge.d.ts +65 -0
- package/dist/specs/badge.d.ts.map +1 -0
- package/dist/specs/badge.js +64 -0
- package/dist/specs/badge.js.map +1 -0
- package/dist/specs/badge.scenarios.d.ts +21 -0
- package/dist/specs/badge.scenarios.d.ts.map +1 -0
- package/dist/specs/badge.scenarios.js +35 -0
- package/dist/specs/badge.scenarios.js.map +1 -0
- package/dist/specs/calendar.d.ts +120 -0
- package/dist/specs/calendar.d.ts.map +1 -0
- package/dist/specs/calendar.js +121 -0
- package/dist/specs/calendar.js.map +1 -0
- package/dist/specs/calendar.scenarios.d.ts +39 -0
- package/dist/specs/calendar.scenarios.d.ts.map +1 -0
- package/dist/specs/calendar.scenarios.js +139 -0
- package/dist/specs/calendar.scenarios.js.map +1 -0
- package/dist/specs/checkbox.d.ts +139 -0
- package/dist/specs/checkbox.d.ts.map +1 -0
- package/dist/specs/checkbox.js +129 -0
- package/dist/specs/checkbox.js.map +1 -0
- package/dist/specs/checkbox.scenarios.d.ts +28 -0
- package/dist/specs/checkbox.scenarios.d.ts.map +1 -0
- package/dist/specs/checkbox.scenarios.js +54 -0
- package/dist/specs/checkbox.scenarios.js.map +1 -0
- package/dist/specs/dialog.d.ts +167 -0
- package/dist/specs/dialog.d.ts.map +1 -0
- package/dist/specs/dialog.js +136 -0
- package/dist/specs/dialog.js.map +1 -0
- package/dist/specs/dialog.scenarios.d.ts +42 -0
- package/dist/specs/dialog.scenarios.d.ts.map +1 -0
- package/dist/specs/dialog.scenarios.js +129 -0
- package/dist/specs/dialog.scenarios.js.map +1 -0
- package/dist/specs/icon-button.d.ts +136 -0
- package/dist/specs/icon-button.d.ts.map +1 -0
- package/dist/specs/icon-button.js +119 -0
- package/dist/specs/icon-button.js.map +1 -0
- package/dist/specs/icon-button.scenarios.d.ts +28 -0
- package/dist/specs/icon-button.scenarios.d.ts.map +1 -0
- package/dist/specs/icon-button.scenarios.js +95 -0
- package/dist/specs/icon-button.scenarios.js.map +1 -0
- package/dist/specs/icon.d.ts +11 -20
- package/dist/specs/icon.d.ts.map +1 -1
- package/dist/specs/icon.js +11 -20
- package/dist/specs/icon.js.map +1 -1
- package/dist/specs/icon.scenarios.d.ts +9 -1
- package/dist/specs/icon.scenarios.d.ts.map +1 -1
- package/dist/specs/icon.scenarios.js +70 -6
- package/dist/specs/icon.scenarios.js.map +1 -1
- package/dist/specs/listbox.d.ts +157 -0
- package/dist/specs/listbox.d.ts.map +1 -0
- package/dist/specs/listbox.js +144 -0
- package/dist/specs/listbox.js.map +1 -0
- package/dist/specs/listbox.scenarios.d.ts +37 -0
- package/dist/specs/listbox.scenarios.d.ts.map +1 -0
- package/dist/specs/listbox.scenarios.js +110 -0
- package/dist/specs/listbox.scenarios.js.map +1 -0
- package/dist/specs/pagination.d.ts +147 -0
- package/dist/specs/pagination.d.ts.map +1 -0
- package/dist/specs/pagination.js +122 -0
- package/dist/specs/pagination.js.map +1 -0
- package/dist/specs/pagination.scenarios.d.ts +15 -0
- package/dist/specs/pagination.scenarios.d.ts.map +1 -0
- package/dist/specs/pagination.scenarios.js +29 -0
- package/dist/specs/pagination.scenarios.js.map +1 -0
- package/dist/specs/popover.d.ts +201 -0
- package/dist/specs/popover.d.ts.map +1 -0
- package/dist/specs/popover.js +169 -0
- package/dist/specs/popover.js.map +1 -0
- package/dist/specs/popover.scenarios.d.ts +83 -0
- package/dist/specs/popover.scenarios.d.ts.map +1 -0
- package/dist/specs/popover.scenarios.js +368 -0
- package/dist/specs/popover.scenarios.js.map +1 -0
- package/dist/specs/radio-group.d.ts +154 -0
- package/dist/specs/radio-group.d.ts.map +1 -0
- package/dist/specs/radio-group.js +133 -0
- package/dist/specs/radio-group.js.map +1 -0
- package/dist/specs/radio-group.scenarios.d.ts +35 -0
- package/dist/specs/radio-group.scenarios.d.ts.map +1 -0
- package/dist/specs/radio-group.scenarios.js +67 -0
- package/dist/specs/radio-group.scenarios.js.map +1 -0
- package/dist/specs/select.d.ts +167 -0
- package/dist/specs/select.d.ts.map +1 -0
- package/dist/specs/select.js +148 -0
- package/dist/specs/select.js.map +1 -0
- package/dist/specs/select.scenarios.d.ts +37 -0
- package/dist/specs/select.scenarios.d.ts.map +1 -0
- package/dist/specs/select.scenarios.js +77 -0
- package/dist/specs/select.scenarios.js.map +1 -0
- package/dist/specs/switch.d.ts +123 -0
- package/dist/specs/switch.d.ts.map +1 -0
- package/dist/specs/switch.js +113 -0
- package/dist/specs/switch.js.map +1 -0
- package/dist/specs/switch.scenarios.d.ts +27 -0
- package/dist/specs/switch.scenarios.d.ts.map +1 -0
- package/dist/specs/switch.scenarios.js +54 -0
- package/dist/specs/switch.scenarios.js.map +1 -0
- package/dist/specs/text-field.d.ts +232 -0
- package/dist/specs/text-field.d.ts.map +1 -0
- package/dist/specs/text-field.js +220 -0
- package/dist/specs/text-field.js.map +1 -0
- package/dist/specs/text-field.scenarios.d.ts +52 -0
- package/dist/specs/text-field.scenarios.d.ts.map +1 -0
- package/dist/specs/text-field.scenarios.js +106 -0
- package/dist/specs/text-field.scenarios.js.map +1 -0
- package/dist/specs/textarea.d.ts +144 -0
- package/dist/specs/textarea.d.ts.map +1 -0
- package/dist/specs/textarea.js +134 -0
- package/dist/specs/textarea.js.map +1 -0
- package/dist/specs/textarea.scenarios.d.ts +33 -0
- package/dist/specs/textarea.scenarios.d.ts.map +1 -0
- package/dist/specs/textarea.scenarios.js +82 -0
- package/dist/specs/textarea.scenarios.js.map +1 -0
- package/llms.md +797 -6
- package/package.json +1 -1
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/** Source of a request to close the modal. */
|
|
2
|
+
export type DialogCloseReason = 'close-button' | 'escape' | 'back' | 'backdrop' | 'action';
|
|
3
|
+
/** Opening is not cancelable. Closing can be vetoed synchronously. */
|
|
4
|
+
export type DialogOpenChangeDetail = {
|
|
5
|
+
open: true;
|
|
6
|
+
reason: 'action';
|
|
7
|
+
} | {
|
|
8
|
+
open: false;
|
|
9
|
+
reason: DialogCloseReason;
|
|
10
|
+
readonly defaultPrevented: boolean;
|
|
11
|
+
preventDefault(): void;
|
|
12
|
+
};
|
|
13
|
+
/** Platform adapters supply their own focus-target type, never a DOM type in core. */
|
|
14
|
+
export type DialogReferences<T> = {
|
|
15
|
+
DialogFocusTarget: T;
|
|
16
|
+
};
|
|
17
|
+
/** Named standard maximum widths, in CSS pixels or native logical points. */
|
|
18
|
+
export type DialogSize = 'sm' | 'md' | 'lg';
|
|
19
|
+
/** Imperative proposals; neither method forces controlled state. */
|
|
20
|
+
export interface DialogHandle {
|
|
21
|
+
requestOpen(): void;
|
|
22
|
+
requestClose(): void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Modal dialog. A bound open prop (including false) controls visibility; otherwise defaultOpen
|
|
26
|
+
* initializes autonomous state once. Open-change events are proposals, not notifications of
|
|
27
|
+
* committed changes. Closing is synchronously cancelable using the event or detail on web and
|
|
28
|
+
* detail on native; a canceled request leaves the modal and focus intact.
|
|
29
|
+
*
|
|
30
|
+
* A committed opening moves focus inside; a committed close restores it to returnFocusTarget,
|
|
31
|
+
* the invoking control, or an available logical fallback. initialFocusTarget, if supplied and
|
|
32
|
+
* usable, takes precedence over the first focusable content. Targets are platform-specific.
|
|
33
|
+
* The title provides the accessible name; an optional short description describes the modal.
|
|
34
|
+
* Escape is web-only, Android Back is native-only, and backdrop dismissal defaults to off.
|
|
35
|
+
* Guaranteed nested-modal coordination and iOS swipe dismissal are excluded.
|
|
36
|
+
*
|
|
37
|
+
* Standard sizes cap width at sm=400, md=640, lg=960. Responsive fullscreen activates below 640
|
|
38
|
+
* viewport CSS pixels/native logical points; explicit fullscreen always wins. The dialog is
|
|
39
|
+
* always centered. Web consumers customize the standard maximum with --cosm-dialog-max-width and
|
|
40
|
+
* fill width through ::part(base); native consumers override the surface style.
|
|
41
|
+
*/
|
|
42
|
+
export declare const dialogContract: {
|
|
43
|
+
readonly name: "dialog";
|
|
44
|
+
readonly tag: "cosm-dialog";
|
|
45
|
+
readonly description: "Modal content with a title, actions and cancelable close requests.";
|
|
46
|
+
readonly role: "dialog";
|
|
47
|
+
readonly pattern: "https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/";
|
|
48
|
+
readonly props: {
|
|
49
|
+
readonly open: {
|
|
50
|
+
readonly type: "boolean";
|
|
51
|
+
readonly default: false;
|
|
52
|
+
readonly reflect: true;
|
|
53
|
+
readonly description: "Committed visibility; supplying this prop, including false, controls state.";
|
|
54
|
+
};
|
|
55
|
+
readonly defaultOpen: {
|
|
56
|
+
readonly type: "boolean";
|
|
57
|
+
readonly default: false;
|
|
58
|
+
readonly description: "Initial autonomous visibility; subsequent changes do not reset state.";
|
|
59
|
+
};
|
|
60
|
+
readonly presentation: {
|
|
61
|
+
readonly type: "enum";
|
|
62
|
+
readonly values: readonly ["standard", "fullscreen"];
|
|
63
|
+
readonly default: "standard";
|
|
64
|
+
readonly reflect: true;
|
|
65
|
+
readonly description: "Centered standard surface or fullscreen surface.";
|
|
66
|
+
};
|
|
67
|
+
readonly size: {
|
|
68
|
+
readonly type: "enum";
|
|
69
|
+
readonly values: readonly ["sm", "md", "lg"];
|
|
70
|
+
readonly default: "md";
|
|
71
|
+
readonly reflect: true;
|
|
72
|
+
readonly description: "Maximum standard width: sm 400, md 640, lg 960 pixels or logical points.";
|
|
73
|
+
};
|
|
74
|
+
readonly responsiveFullscreen: {
|
|
75
|
+
readonly type: "boolean";
|
|
76
|
+
readonly default: false;
|
|
77
|
+
readonly description: "Use fullscreen when available viewport width is below 640 pixels or logical points.";
|
|
78
|
+
};
|
|
79
|
+
readonly closeLabel: {
|
|
80
|
+
readonly type: "string";
|
|
81
|
+
readonly default: "Close";
|
|
82
|
+
readonly description: "Non-empty localized accessible name of the built-in close button.";
|
|
83
|
+
};
|
|
84
|
+
readonly closeOnEscape: {
|
|
85
|
+
readonly type: "boolean";
|
|
86
|
+
readonly default: true;
|
|
87
|
+
readonly platforms: readonly ["web", "react", "angular"];
|
|
88
|
+
readonly description: "Request closure on unhandled Escape on web.";
|
|
89
|
+
};
|
|
90
|
+
readonly closeOnAndroidBack: {
|
|
91
|
+
readonly type: "boolean";
|
|
92
|
+
readonly default: true;
|
|
93
|
+
readonly platforms: readonly ["native"];
|
|
94
|
+
readonly description: "Request closure on Android Back; consume Back even if the request is canceled.";
|
|
95
|
+
};
|
|
96
|
+
readonly closeOnBackdropPress: {
|
|
97
|
+
readonly type: "boolean";
|
|
98
|
+
readonly default: false;
|
|
99
|
+
readonly description: "Request closure when the backdrop itself is pressed.";
|
|
100
|
+
};
|
|
101
|
+
readonly initialFocusTarget: {
|
|
102
|
+
readonly type: "reference";
|
|
103
|
+
readonly reference: "DialogFocusTarget";
|
|
104
|
+
readonly description: "Optional platform focus target used on committed opening; it must be inside the dialog.";
|
|
105
|
+
};
|
|
106
|
+
readonly returnFocusTarget: {
|
|
107
|
+
readonly type: "reference";
|
|
108
|
+
readonly reference: "DialogFocusTarget";
|
|
109
|
+
readonly description: "Optional platform focus target used after committed closure.";
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
readonly events: {
|
|
113
|
+
readonly openChange: {
|
|
114
|
+
readonly description: "Proposes opening or closing; only closing is synchronously cancelable.";
|
|
115
|
+
readonly detail: "DialogOpenChangeDetail";
|
|
116
|
+
readonly cancelable: true;
|
|
117
|
+
readonly names: {
|
|
118
|
+
readonly dom: "cosm-open-change";
|
|
119
|
+
readonly react: "onOpenChange";
|
|
120
|
+
readonly angular: "openChange";
|
|
121
|
+
readonly native: "onOpenChange";
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
readonly states: readonly [{
|
|
126
|
+
readonly prop: "open";
|
|
127
|
+
readonly event: "openChange";
|
|
128
|
+
readonly defaultProp: "defaultOpen";
|
|
129
|
+
}];
|
|
130
|
+
readonly slots: {
|
|
131
|
+
readonly title: "Required accessible title content.";
|
|
132
|
+
readonly description: "Optional short accessible description.";
|
|
133
|
+
readonly '': "Scrollable body content.";
|
|
134
|
+
readonly actions: "Consumer-supplied actions.";
|
|
135
|
+
};
|
|
136
|
+
readonly parts: {
|
|
137
|
+
readonly backdrop: "Modal backdrop.";
|
|
138
|
+
readonly base: "Dialog surface.";
|
|
139
|
+
readonly header: "Title and close control area.";
|
|
140
|
+
readonly title: "Title container.";
|
|
141
|
+
readonly description: "Description container.";
|
|
142
|
+
readonly body: "Scrollable body.";
|
|
143
|
+
readonly actions: "Actions container.";
|
|
144
|
+
readonly close: "Close IconButton.";
|
|
145
|
+
};
|
|
146
|
+
readonly cssProperties: {
|
|
147
|
+
readonly '--cosm-dialog-z-index': "Modal stacking level.";
|
|
148
|
+
readonly '--cosm-dialog-max-width': "Standard surface maximum width.";
|
|
149
|
+
readonly '--cosm-dialog-backdrop': "Backdrop background.";
|
|
150
|
+
readonly '--cosm-dialog-surface': "Surface background.";
|
|
151
|
+
readonly '--cosm-dialog-border': "Surface border.";
|
|
152
|
+
readonly '--cosm-dialog-radius': "Surface radius.";
|
|
153
|
+
readonly '--cosm-dialog-shadow': "Surface shadow.";
|
|
154
|
+
readonly '--cosm-dialog-padding': "Section spacing.";
|
|
155
|
+
};
|
|
156
|
+
readonly keyboard: readonly [{
|
|
157
|
+
readonly keys: readonly ["Escape"];
|
|
158
|
+
readonly action: "On web request close unless handled by a child or disabled.";
|
|
159
|
+
}, {
|
|
160
|
+
readonly keys: readonly ["Tab", "Shift+Tab"];
|
|
161
|
+
readonly action: "Keep keyboard focus inside the modal.";
|
|
162
|
+
}, {
|
|
163
|
+
readonly keys: readonly ["Android Back"];
|
|
164
|
+
readonly action: "On Android request close unless disabled.";
|
|
165
|
+
}];
|
|
166
|
+
};
|
|
167
|
+
//# sourceMappingURL=dialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../../src/specs/dialog.ts"],"names":[],"mappings":"AAEA,8CAA8C;AAC9C,MAAM,MAAM,iBAAiB,GAAG,cAAc,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,CAAC;AAE3F,sEAAsE;AACtE,MAAM,MAAM,sBAAsB,GAC9B;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,QAAQ,CAAA;CAAE,GAChC;IACE,IAAI,EAAE,KAAK,CAAC;IACZ,MAAM,EAAE,iBAAiB,CAAC;IAC1B,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACnC,cAAc,IAAI,IAAI,CAAC;CACxB,CAAC;AAEN,sFAAsF;AACtF,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI;IAAE,iBAAiB,EAAE,CAAC,CAAA;CAAE,CAAC;AAE3D,6EAA6E;AAC7E,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE5C,oEAAoE;AACpE,MAAM,WAAW,YAAY;IAC3B,WAAW,IAAI,IAAI,CAAC;IACpB,YAAY,IAAI,IAAI,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqHzB,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { defineContract } from '../contract.js';
|
|
2
|
+
/**
|
|
3
|
+
* Modal dialog. A bound open prop (including false) controls visibility; otherwise defaultOpen
|
|
4
|
+
* initializes autonomous state once. Open-change events are proposals, not notifications of
|
|
5
|
+
* committed changes. Closing is synchronously cancelable using the event or detail on web and
|
|
6
|
+
* detail on native; a canceled request leaves the modal and focus intact.
|
|
7
|
+
*
|
|
8
|
+
* A committed opening moves focus inside; a committed close restores it to returnFocusTarget,
|
|
9
|
+
* the invoking control, or an available logical fallback. initialFocusTarget, if supplied and
|
|
10
|
+
* usable, takes precedence over the first focusable content. Targets are platform-specific.
|
|
11
|
+
* The title provides the accessible name; an optional short description describes the modal.
|
|
12
|
+
* Escape is web-only, Android Back is native-only, and backdrop dismissal defaults to off.
|
|
13
|
+
* Guaranteed nested-modal coordination and iOS swipe dismissal are excluded.
|
|
14
|
+
*
|
|
15
|
+
* Standard sizes cap width at sm=400, md=640, lg=960. Responsive fullscreen activates below 640
|
|
16
|
+
* viewport CSS pixels/native logical points; explicit fullscreen always wins. The dialog is
|
|
17
|
+
* always centered. Web consumers customize the standard maximum with --cosm-dialog-max-width and
|
|
18
|
+
* fill width through ::part(base); native consumers override the surface style.
|
|
19
|
+
*/
|
|
20
|
+
export const dialogContract = defineContract({
|
|
21
|
+
name: 'dialog',
|
|
22
|
+
tag: 'cosm-dialog',
|
|
23
|
+
description: 'Modal content with a title, actions and cancelable close requests.',
|
|
24
|
+
role: 'dialog',
|
|
25
|
+
pattern: 'https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/',
|
|
26
|
+
props: {
|
|
27
|
+
open: {
|
|
28
|
+
type: 'boolean',
|
|
29
|
+
default: false,
|
|
30
|
+
reflect: true,
|
|
31
|
+
description: 'Committed visibility; supplying this prop, including false, controls state.',
|
|
32
|
+
},
|
|
33
|
+
defaultOpen: {
|
|
34
|
+
type: 'boolean',
|
|
35
|
+
default: false,
|
|
36
|
+
description: 'Initial autonomous visibility; subsequent changes do not reset state.',
|
|
37
|
+
},
|
|
38
|
+
presentation: {
|
|
39
|
+
type: 'enum',
|
|
40
|
+
values: ['standard', 'fullscreen'],
|
|
41
|
+
default: 'standard',
|
|
42
|
+
reflect: true,
|
|
43
|
+
description: 'Centered standard surface or fullscreen surface.',
|
|
44
|
+
},
|
|
45
|
+
size: {
|
|
46
|
+
type: 'enum',
|
|
47
|
+
values: ['sm', 'md', 'lg'],
|
|
48
|
+
default: 'md',
|
|
49
|
+
reflect: true,
|
|
50
|
+
description: 'Maximum standard width: sm 400, md 640, lg 960 pixels or logical points.',
|
|
51
|
+
},
|
|
52
|
+
responsiveFullscreen: {
|
|
53
|
+
type: 'boolean',
|
|
54
|
+
default: false,
|
|
55
|
+
description: 'Use fullscreen when available viewport width is below 640 pixels or logical points.',
|
|
56
|
+
},
|
|
57
|
+
closeLabel: {
|
|
58
|
+
type: 'string',
|
|
59
|
+
default: 'Close',
|
|
60
|
+
description: 'Non-empty localized accessible name of the built-in close button.',
|
|
61
|
+
},
|
|
62
|
+
closeOnEscape: {
|
|
63
|
+
type: 'boolean',
|
|
64
|
+
default: true,
|
|
65
|
+
platforms: ['web', 'react', 'angular'],
|
|
66
|
+
description: 'Request closure on unhandled Escape on web.',
|
|
67
|
+
},
|
|
68
|
+
closeOnAndroidBack: {
|
|
69
|
+
type: 'boolean',
|
|
70
|
+
default: true,
|
|
71
|
+
platforms: ['native'],
|
|
72
|
+
description: 'Request closure on Android Back; consume Back even if the request is canceled.',
|
|
73
|
+
},
|
|
74
|
+
closeOnBackdropPress: {
|
|
75
|
+
type: 'boolean',
|
|
76
|
+
default: false,
|
|
77
|
+
description: 'Request closure when the backdrop itself is pressed.',
|
|
78
|
+
},
|
|
79
|
+
initialFocusTarget: {
|
|
80
|
+
type: 'reference',
|
|
81
|
+
reference: 'DialogFocusTarget',
|
|
82
|
+
description: 'Optional platform focus target used on committed opening; it must be inside the dialog.',
|
|
83
|
+
},
|
|
84
|
+
returnFocusTarget: {
|
|
85
|
+
type: 'reference',
|
|
86
|
+
reference: 'DialogFocusTarget',
|
|
87
|
+
description: 'Optional platform focus target used after committed closure.',
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
events: {
|
|
91
|
+
openChange: {
|
|
92
|
+
description: 'Proposes opening or closing; only closing is synchronously cancelable.',
|
|
93
|
+
detail: 'DialogOpenChangeDetail',
|
|
94
|
+
cancelable: true,
|
|
95
|
+
names: {
|
|
96
|
+
dom: 'cosm-open-change',
|
|
97
|
+
react: 'onOpenChange',
|
|
98
|
+
angular: 'openChange',
|
|
99
|
+
native: 'onOpenChange',
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
states: [{ prop: 'open', event: 'openChange', defaultProp: 'defaultOpen' }],
|
|
104
|
+
slots: {
|
|
105
|
+
title: 'Required accessible title content.',
|
|
106
|
+
description: 'Optional short accessible description.',
|
|
107
|
+
'': 'Scrollable body content.',
|
|
108
|
+
actions: 'Consumer-supplied actions.',
|
|
109
|
+
},
|
|
110
|
+
parts: {
|
|
111
|
+
backdrop: 'Modal backdrop.',
|
|
112
|
+
base: 'Dialog surface.',
|
|
113
|
+
header: 'Title and close control area.',
|
|
114
|
+
title: 'Title container.',
|
|
115
|
+
description: 'Description container.',
|
|
116
|
+
body: 'Scrollable body.',
|
|
117
|
+
actions: 'Actions container.',
|
|
118
|
+
close: 'Close IconButton.',
|
|
119
|
+
},
|
|
120
|
+
cssProperties: {
|
|
121
|
+
'--cosm-dialog-z-index': 'Modal stacking level.',
|
|
122
|
+
'--cosm-dialog-max-width': 'Standard surface maximum width.',
|
|
123
|
+
'--cosm-dialog-backdrop': 'Backdrop background.',
|
|
124
|
+
'--cosm-dialog-surface': 'Surface background.',
|
|
125
|
+
'--cosm-dialog-border': 'Surface border.',
|
|
126
|
+
'--cosm-dialog-radius': 'Surface radius.',
|
|
127
|
+
'--cosm-dialog-shadow': 'Surface shadow.',
|
|
128
|
+
'--cosm-dialog-padding': 'Section spacing.',
|
|
129
|
+
},
|
|
130
|
+
keyboard: [
|
|
131
|
+
{ keys: ['Escape'], action: 'On web request close unless handled by a child or disabled.' },
|
|
132
|
+
{ keys: ['Tab', 'Shift+Tab'], action: 'Keep keyboard focus inside the modal.' },
|
|
133
|
+
{ keys: ['Android Back'], action: 'On Android request close unless disabled.' },
|
|
134
|
+
],
|
|
135
|
+
});
|
|
136
|
+
//# sourceMappingURL=dialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../src/specs/dialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AA2BhD;;;;;;;;;;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AAE,iBAAiB;QACzC,sBAAsB,EAAE,iBAAiB;QACzC,uBAAuB,EAAE,kBAAkB;KAC5C;IACD,QAAQ,EAAE;QACR,EAAE,IAAI,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,6DAA6D,EAAE;QAC3F,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,uCAAuC,EAAE;QAC/E,EAAE,IAAI,EAAE,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,2CAA2C,EAAE;KAChF;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ContractProps, Platform } from '../contract.js';
|
|
2
|
+
import type { DialogCloseReason, DialogReferences, dialogContract } from './dialog.js';
|
|
3
|
+
export type DialogAction = {
|
|
4
|
+
type: 'open' | 'action' | 'close-button' | 'escape' | 'back' | 'backdrop';
|
|
5
|
+
cancel?: boolean;
|
|
6
|
+
} | {
|
|
7
|
+
type: 'sync';
|
|
8
|
+
open: boolean;
|
|
9
|
+
} | {
|
|
10
|
+
type: 'set-default';
|
|
11
|
+
defaultOpen: boolean;
|
|
12
|
+
};
|
|
13
|
+
export interface DialogScenario {
|
|
14
|
+
name: string;
|
|
15
|
+
props: ContractProps<typeof dialogContract, 'native', DialogReferences<unknown>> & ContractProps<typeof dialogContract, 'web', DialogReferences<unknown>>;
|
|
16
|
+
actions: readonly DialogAction[];
|
|
17
|
+
expected: {
|
|
18
|
+
openAfterEachAction: readonly boolean[];
|
|
19
|
+
changes: readonly {
|
|
20
|
+
open: boolean;
|
|
21
|
+
reason: DialogCloseReason;
|
|
22
|
+
canceled: boolean;
|
|
23
|
+
}[];
|
|
24
|
+
};
|
|
25
|
+
platforms?: readonly Platform[];
|
|
26
|
+
}
|
|
27
|
+
/** Platform-independent proposals and state ownership. Focus and modal semantics require platform tests. */
|
|
28
|
+
export declare const dialogScenarios: readonly DialogScenario[];
|
|
29
|
+
export declare const dialogScenariosFor: (platform: Platform) => DialogScenario[];
|
|
30
|
+
/** Layout expectations are independent of platform rendering and focus mechanics. */
|
|
31
|
+
export interface DialogLayoutScenario {
|
|
32
|
+
name: string;
|
|
33
|
+
props: Pick<DialogScenario['props'], 'size' | 'presentation' | 'responsiveFullscreen'>;
|
|
34
|
+
viewportWidth: number;
|
|
35
|
+
/** maxWidth is the effective standard maximum, or null when fullscreen. */
|
|
36
|
+
expected: {
|
|
37
|
+
fullscreen: boolean;
|
|
38
|
+
maxWidth: number | null;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export declare const dialogLayoutScenarios: readonly DialogLayoutScenario[];
|
|
42
|
+
//# sourceMappingURL=dialog.scenarios.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialog.scenarios.d.ts","sourceRoot":"","sources":["../../src/specs/dialog.scenarios.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEvF,MAAM,MAAM,YAAY,GACpB;IAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,cAAc,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAC/F;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,WAAW,EAAE,OAAO,CAAA;CAAE,CAAC;AAElD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,aAAa,CAAC,OAAO,cAAc,EAAE,QAAQ,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,GAC9E,aAAa,CAAC,OAAO,cAAc,EAAE,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;IACzE,OAAO,EAAE,SAAS,YAAY,EAAE,CAAC;IACjC,QAAQ,EAAE;QACR,mBAAmB,EAAE,SAAS,OAAO,EAAE,CAAC;QACxC,OAAO,EAAE,SAAS;YAAE,IAAI,EAAE,OAAO,CAAC;YAAC,MAAM,EAAE,iBAAiB,CAAC;YAAC,QAAQ,EAAE,OAAO,CAAA;SAAE,EAAE,CAAC;KACrF,CAAC;IACF,SAAS,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAC;CACjC;AAKD,4GAA4G;AAC5G,eAAO,MAAM,eAAe,EAAE,SAAS,cAAc,EA0FpD,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,UAAU,QAAQ,qBAC6C,CAAC;AAEnG,qFAAqF;AACrF,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,cAAc,GAAG,sBAAsB,CAAC,CAAC;IACvF,aAAa,EAAE,MAAM,CAAC;IACtB,2EAA2E;IAC3E,QAAQ,EAAE;QAAE,UAAU,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;CAC5D;AAED,eAAO,MAAM,qBAAqB,EAAE,SAAS,oBAAoB,EAqChE,CAAC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
const close = (reason, canceled = false) => ({ open: false, reason, canceled });
|
|
2
|
+
const opening = { open: true, reason: 'action', canceled: false };
|
|
3
|
+
/** Platform-independent proposals and state ownership. Focus and modal semantics require platform tests. */
|
|
4
|
+
export const dialogScenarios = [
|
|
5
|
+
{
|
|
6
|
+
name: 'closed by default',
|
|
7
|
+
props: {},
|
|
8
|
+
actions: [],
|
|
9
|
+
expected: { openAfterEachAction: [], changes: [] },
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
name: 'autonomous open and action close',
|
|
13
|
+
props: {},
|
|
14
|
+
actions: [{ type: 'open' }, { type: 'action' }],
|
|
15
|
+
expected: { openAfterEachAction: [true, false], changes: [opening, close('action')] },
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: 'default open only initializes once',
|
|
19
|
+
props: { defaultOpen: true },
|
|
20
|
+
actions: [{ type: 'set-default', defaultOpen: false }],
|
|
21
|
+
expected: { openAfterEachAction: [true], changes: [] },
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'controlled false is not overridden by defaultOpen',
|
|
25
|
+
props: { open: false, defaultOpen: true },
|
|
26
|
+
actions: [{ type: 'open' }],
|
|
27
|
+
expected: { openAfterEachAction: [false], changes: [opening] },
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'controlled acceptance requires owner sync',
|
|
31
|
+
props: { open: false },
|
|
32
|
+
actions: [
|
|
33
|
+
{ type: 'open' },
|
|
34
|
+
{ type: 'sync', open: true },
|
|
35
|
+
{ type: 'action' },
|
|
36
|
+
{ type: 'sync', open: false },
|
|
37
|
+
],
|
|
38
|
+
expected: {
|
|
39
|
+
openAfterEachAction: [false, true, true, false],
|
|
40
|
+
changes: [opening, close('action')],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
...['close-button', 'action'].flatMap(reason => [false, true].map(cancel => ({
|
|
44
|
+
name: `${reason} ${cancel ? 'canceled' : 'committed'}`,
|
|
45
|
+
props: { defaultOpen: true },
|
|
46
|
+
actions: [{ type: reason, cancel }],
|
|
47
|
+
expected: { openAfterEachAction: [cancel], changes: [close(reason, cancel)] },
|
|
48
|
+
}))),
|
|
49
|
+
{
|
|
50
|
+
name: 'backdrop does not dismiss by default',
|
|
51
|
+
props: { defaultOpen: true },
|
|
52
|
+
actions: [{ type: 'backdrop' }],
|
|
53
|
+
expected: { openAfterEachAction: [true], changes: [] },
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'enabled backdrop requests close',
|
|
57
|
+
props: { defaultOpen: true, closeOnBackdropPress: true },
|
|
58
|
+
actions: [{ type: 'backdrop' }],
|
|
59
|
+
expected: { openAfterEachAction: [false], changes: [close('backdrop')] },
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: 'Escape requests close',
|
|
63
|
+
props: { defaultOpen: true },
|
|
64
|
+
actions: [{ type: 'escape' }],
|
|
65
|
+
expected: { openAfterEachAction: [false], changes: [close('escape')] },
|
|
66
|
+
platforms: ['web', 'react', 'angular'],
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'disabled Escape does not close',
|
|
70
|
+
props: { defaultOpen: true, closeOnEscape: false },
|
|
71
|
+
actions: [{ type: 'escape' }],
|
|
72
|
+
expected: { openAfterEachAction: [true], changes: [] },
|
|
73
|
+
platforms: ['web', 'react', 'angular'],
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: 'Android Back requests close',
|
|
77
|
+
props: { defaultOpen: true },
|
|
78
|
+
actions: [{ type: 'back' }],
|
|
79
|
+
expected: { openAfterEachAction: [false], changes: [close('back')] },
|
|
80
|
+
platforms: ['native'],
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: 'disabled Android Back does not close',
|
|
84
|
+
props: { defaultOpen: true, closeOnAndroidBack: false },
|
|
85
|
+
actions: [{ type: 'back' }],
|
|
86
|
+
expected: { openAfterEachAction: [true], changes: [] },
|
|
87
|
+
platforms: ['native'],
|
|
88
|
+
},
|
|
89
|
+
];
|
|
90
|
+
export const dialogScenariosFor = (platform) => dialogScenarios.filter(scenario => !scenario.platforms || scenario.platforms.includes(platform));
|
|
91
|
+
export const dialogLayoutScenarios = [
|
|
92
|
+
{
|
|
93
|
+
name: 'default medium',
|
|
94
|
+
props: {},
|
|
95
|
+
viewportWidth: 1200,
|
|
96
|
+
expected: { fullscreen: false, maxWidth: 640 },
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: 'small maximum',
|
|
100
|
+
props: { size: 'sm' },
|
|
101
|
+
viewportWidth: 1200,
|
|
102
|
+
expected: { fullscreen: false, maxWidth: 400 },
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: 'large maximum',
|
|
106
|
+
props: { size: 'lg' },
|
|
107
|
+
viewportWidth: 1200,
|
|
108
|
+
expected: { fullscreen: false, maxWidth: 960 },
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: 'responsive fullscreen below boundary',
|
|
112
|
+
props: { responsiveFullscreen: true },
|
|
113
|
+
viewportWidth: 639,
|
|
114
|
+
expected: { fullscreen: true, maxWidth: null },
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: 'responsive boundary remains standard',
|
|
118
|
+
props: { responsiveFullscreen: true },
|
|
119
|
+
viewportWidth: 640,
|
|
120
|
+
expected: { fullscreen: false, maxWidth: 640 },
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: 'explicit fullscreen wins',
|
|
124
|
+
props: { presentation: 'fullscreen', size: 'sm' },
|
|
125
|
+
viewportWidth: 1200,
|
|
126
|
+
expected: { fullscreen: true, maxWidth: null },
|
|
127
|
+
},
|
|
128
|
+
];
|
|
129
|
+
//# sourceMappingURL=dialog.scenarios.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialog.scenarios.js","sourceRoot":"","sources":["../../src/specs/dialog.scenarios.ts"],"names":[],"mappings":"AAoBA,MAAM,KAAK,GAAG,CAAC,MAAyB,EAAE,QAAQ,GAAG,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;AACnG,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAW,CAAC;AAE3E,4GAA4G;AAC5G,MAAM,CAAC,MAAM,eAAe,GAA8B;IACxD;QACE,IAAI,EAAE,mBAAmB;QACzB,K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AK,EAAE,EAAE,YAAY,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE;QACjD,aAAa,EAAE,IAAI;QACnB,QAAQ,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE;KAC/C;CACF,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"}
|