@joralvmel/cosmos-elements 0.3.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.
Files changed (70) hide show
  1. package/README.md +9 -4
  2. package/dist/components/badge/cosm-badge.d.ts +64 -0
  3. package/dist/components/badge/cosm-badge.d.ts.map +1 -0
  4. package/dist/components/badge/cosm-badge.js +162 -0
  5. package/dist/components/badge/cosm-badge.js.map +1 -0
  6. package/dist/components/button/cosm-button.d.ts.map +1 -1
  7. package/dist/components/button/cosm-button.js +2 -0
  8. package/dist/components/button/cosm-button.js.map +1 -1
  9. package/dist/components/calendar/cosm-calendar.d.ts +77 -0
  10. package/dist/components/calendar/cosm-calendar.d.ts.map +1 -0
  11. package/dist/components/calendar/cosm-calendar.js +696 -0
  12. package/dist/components/calendar/cosm-calendar.js.map +1 -0
  13. package/dist/components/checkbox/cosm-checkbox.d.ts +122 -0
  14. package/dist/components/checkbox/cosm-checkbox.d.ts.map +1 -0
  15. package/dist/components/checkbox/cosm-checkbox.js +433 -0
  16. package/dist/components/checkbox/cosm-checkbox.js.map +1 -0
  17. package/dist/components/dialog/cosm-dialog.d.ts +103 -0
  18. package/dist/components/dialog/cosm-dialog.d.ts.map +1 -0
  19. package/dist/components/dialog/cosm-dialog.js +497 -0
  20. package/dist/components/dialog/cosm-dialog.js.map +1 -0
  21. package/dist/components/icon/cosm-icon.d.ts +7 -15
  22. package/dist/components/icon/cosm-icon.d.ts.map +1 -1
  23. package/dist/components/icon/cosm-icon.js +29 -30
  24. package/dist/components/icon/cosm-icon.js.map +1 -1
  25. package/dist/components/icon-button/cosm-icon-button.d.ts.map +1 -1
  26. package/dist/components/icon-button/cosm-icon-button.js +6 -0
  27. package/dist/components/icon-button/cosm-icon-button.js.map +1 -1
  28. package/dist/components/listbox/cosm-listbox.d.ts +1 -5
  29. package/dist/components/listbox/cosm-listbox.d.ts.map +1 -1
  30. package/dist/components/listbox/cosm-listbox.js +3 -18
  31. package/dist/components/listbox/cosm-listbox.js.map +1 -1
  32. package/dist/components/pagination/cosm-pagination.d.ts +118 -0
  33. package/dist/components/pagination/cosm-pagination.d.ts.map +1 -0
  34. package/dist/components/pagination/cosm-pagination.js +315 -0
  35. package/dist/components/pagination/cosm-pagination.js.map +1 -0
  36. package/dist/components/popover/cosm-popover.d.ts +0 -22
  37. package/dist/components/popover/cosm-popover.d.ts.map +1 -1
  38. package/dist/components/popover/cosm-popover.js +21 -54
  39. package/dist/components/popover/cosm-popover.js.map +1 -1
  40. package/dist/components/radio-group/cosm-radio-group.d.ts +111 -0
  41. package/dist/components/radio-group/cosm-radio-group.d.ts.map +1 -0
  42. package/dist/components/radio-group/cosm-radio-group.js +478 -0
  43. package/dist/components/radio-group/cosm-radio-group.js.map +1 -0
  44. package/dist/components/select/cosm-select.d.ts +126 -0
  45. package/dist/components/select/cosm-select.d.ts.map +1 -0
  46. package/dist/components/select/cosm-select.js +682 -0
  47. package/dist/components/select/cosm-select.js.map +1 -0
  48. package/dist/components/switch/cosm-switch.d.ts +103 -0
  49. package/dist/components/switch/cosm-switch.d.ts.map +1 -0
  50. package/dist/components/switch/cosm-switch.js +359 -0
  51. package/dist/components/switch/cosm-switch.js.map +1 -0
  52. package/dist/components/text-field/cosm-text-field.d.ts +8 -18
  53. package/dist/components/text-field/cosm-text-field.d.ts.map +1 -1
  54. package/dist/components/text-field/cosm-text-field.js +30 -67
  55. package/dist/components/text-field/cosm-text-field.js.map +1 -1
  56. package/dist/components/textarea/cosm-textarea.d.ts +131 -0
  57. package/dist/components/textarea/cosm-textarea.d.ts.map +1 -0
  58. package/dist/components/textarea/cosm-textarea.js +445 -0
  59. package/dist/components/textarea/cosm-textarea.js.map +1 -0
  60. package/dist/custom-elements.json +5915 -1330
  61. package/dist/index.d.ts +10 -1
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +9 -0
  64. package/dist/index.js.map +1 -1
  65. package/dist/internal/current-page.d.ts +7 -0
  66. package/dist/internal/current-page.d.ts.map +1 -0
  67. package/dist/internal/current-page.js +18 -0
  68. package/dist/internal/current-page.js.map +1 -0
  69. package/llms.md +306 -20
  70. package/package.json +39 -3
@@ -0,0 +1,103 @@
1
+ import { type ContractProps, type DialogReferences, dialogContract } from '@joralvmel/cosmos-core';
2
+ import '../../components/icon/cosm-icon.js';
3
+ import '../../components/icon-button/cosm-icon-button.js';
4
+ import { CosmElement } from '../../internal/cosm-element.js';
5
+ type Props = ContractProps<typeof dialogContract, 'web', DialogReferences<HTMLElement | null>>;
6
+ /**
7
+ * Modal dialog with consumer-composed content and cancelable close requests.
8
+ * Slotted forms using method="dialog" propose an action close instead of bypassing ownership.
9
+ * The internal native dialog is not a public handle; unexpected native closes are recovered
10
+ * when its close event fires. Use requestClose() for a synchronously cancelable request.
11
+ * @tag cosm-dialog
12
+ * @slot title - Accessible title.
13
+ * @slot description - Optional short description.
14
+ * @slot - Scrollable body.
15
+ * @slot actions - Consumer actions.
16
+ * @csspart backdrop - Backdrop.
17
+ * @csspart base - Dialog surface.
18
+ * @csspart header - Title and close area.
19
+ * @csspart title - Title container.
20
+ * @csspart description - Description container.
21
+ * @csspart body - Scrollable body.
22
+ * @csspart actions - Actions container.
23
+ * @csspart close - Close IconButton.
24
+ * @fires {CustomEvent<DialogOpenChangeDetail>} cosm-open-change - Visibility proposal.
25
+ * @cssprop --cosm-dialog-z-index - Modal stacking level.
26
+ * @cssprop --cosm-dialog-max-width - Maximum standard width; defaults to the semantic size.
27
+ * @cssprop --cosm-dialog-backdrop - Backdrop color.
28
+ * @cssprop --cosm-dialog-surface - Surface color.
29
+ * @cssprop --cosm-dialog-border - Surface border color.
30
+ * @cssprop --cosm-dialog-radius - Surface radius.
31
+ * @cssprop --cosm-dialog-shadow - Surface shadow.
32
+ * @cssprop --cosm-dialog-padding - Section spacing.
33
+ */
34
+ export declare class CosmDialog extends CosmElement {
35
+ #private;
36
+ static shadowRootOptions: ShadowRootInit;
37
+ static properties: {
38
+ open: {
39
+ type: BooleanConstructor;
40
+ reflect: boolean;
41
+ noAccessor: boolean;
42
+ };
43
+ defaultOpen: {
44
+ type: BooleanConstructor;
45
+ attribute: string;
46
+ };
47
+ presentation: {
48
+ reflect: boolean;
49
+ };
50
+ size: {
51
+ reflect: boolean;
52
+ };
53
+ responsiveFullscreen: {
54
+ type: BooleanConstructor;
55
+ attribute: string;
56
+ };
57
+ closeLabel: {
58
+ attribute: string;
59
+ };
60
+ closeOnEscape: {
61
+ type: BooleanConstructor;
62
+ attribute: string;
63
+ };
64
+ closeOnBackdropPress: {
65
+ type: BooleanConstructor;
66
+ attribute: string;
67
+ };
68
+ initialFocusTarget: {
69
+ attribute: boolean;
70
+ };
71
+ returnFocusTarget: {
72
+ attribute: boolean;
73
+ };
74
+ };
75
+ static styles: import("lit").CSSResult[];
76
+ defaultOpen: boolean;
77
+ presentation: NonNullable<Props['presentation']>;
78
+ size: NonNullable<Props['size']>;
79
+ responsiveFullscreen: boolean;
80
+ closeLabel: string;
81
+ closeOnEscape: boolean;
82
+ closeOnBackdropPress: boolean;
83
+ initialFocusTarget: HTMLElement | null | undefined;
84
+ returnFocusTarget: HTMLElement | null | undefined;
85
+ openControlled: boolean;
86
+ constructor();
87
+ get open(): boolean;
88
+ set open(value: boolean | undefined);
89
+ connectedCallback(): void;
90
+ disconnectedCallback(): void;
91
+ protected willUpdate(): void;
92
+ protected updated(changed: Map<PropertyKey, unknown>): void;
93
+ requestOpen(): void;
94
+ requestClose(): void;
95
+ protected render(): import("lit-html").TemplateResult<1>;
96
+ }
97
+ declare global {
98
+ interface HTMLElementTagNameMap {
99
+ 'cosm-dialog': CosmDialog;
100
+ }
101
+ }
102
+ export {};
103
+ //# sourceMappingURL=cosm-dialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cosm-dialog.d.ts","sourceRoot":"","sources":["../../../src/components/dialog/cosm-dialog.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAGlB,KAAK,gBAAgB,EAC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AAID,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,aAAa,EAAE,UAAU,CAAC;KAC3B;CACF"}
@@ -0,0 +1,497 @@
1
+ import { dialogContract, } from '@joralvmel/cosmos-core';
2
+ import { x } from '@joralvmel/cosmos-icons/x';
3
+ import { css, html, LitElement, nothing } from 'lit';
4
+ import '../../components/icon/cosm-icon.js';
5
+ import '../../components/icon-button/cosm-icon-button.js';
6
+ import { CosmElement } from '../../internal/cosm-element.js';
7
+ import { define } from '../../internal/define.js';
8
+ import { boxSizing, focusRing } from '../../internal/styles.js';
9
+ const styles = css `
10
+ :host {
11
+ color: var(--cosm-fg, oklch(0.24 0.01 268));
12
+ font-family: var(--cosm-font-sans, system-ui, sans-serif);
13
+ }
14
+ dialog {
15
+ position: fixed;
16
+ inset: 0;
17
+ width: 100%;
18
+ height: 100%;
19
+ max-width: none;
20
+ max-height: none;
21
+ margin: 0;
22
+ padding: 0;
23
+ border: 0;
24
+ background: transparent;
25
+ color: inherit;
26
+ overflow: hidden;
27
+ z-index: var(--cosm-dialog-z-index, 1000);
28
+ }
29
+ dialog:not([open]) { display: none; }
30
+ dialog::backdrop { background: transparent; }
31
+ .backdrop {
32
+ position: absolute;
33
+ inset: 0;
34
+ background: var(--cosm-dialog-backdrop, var(--cosm-overlay, oklch(0 0 0 / 55%)));
35
+ }
36
+ .layout {
37
+ position: absolute;
38
+ inset: 0;
39
+ display: flex;
40
+ align-items: center;
41
+ justify-content: center;
42
+ padding: var(--cosm-space-lg, 1rem);
43
+ pointer-events: none;
44
+ }
45
+ .base {
46
+ pointer-events: auto;
47
+ display: flex;
48
+ flex-direction: column;
49
+ width: max-content;
50
+ max-width: min(100%, var(--_cosm-dialog-viewport-width, 100vw), var(--_cosm-dialog-max-width, 640px));
51
+ max-height: min(100%, var(--_cosm-dialog-viewport-height, 100vh));
52
+ min-height: 0;
53
+ border: 1px solid var(--cosm-dialog-border, var(--cosm-border, oklch(0.88 0.01 268)));
54
+ border-radius: var(--cosm-dialog-radius, var(--cosm-radius-lg, 0.75rem));
55
+ background: var(--cosm-dialog-surface, var(--cosm-surface, oklch(1 0 0)));
56
+ font-size: var(--cosm-text-md, 1rem);
57
+ line-height: var(--cosm-leading-normal, 1.5);
58
+ box-shadow: var(--cosm-dialog-shadow, var(--cosm-shadow-lg, 0 8px 24px oklch(0 0 0 / 16%)));
59
+ }
60
+ dialog[data-fullscreen] .layout { padding: 0; }
61
+ dialog[data-fullscreen] .base {
62
+ width: 100%;
63
+ height: 100%;
64
+ max-width: none;
65
+ max-height: none;
66
+ border: 0;
67
+ border-radius: 0;
68
+ box-shadow: none;
69
+ }
70
+ .header {
71
+ display: flex;
72
+ flex-wrap: wrap;
73
+ align-items: center;
74
+ gap: var(--cosm-space-sm, 0.5rem);
75
+ flex: none;
76
+ padding: var(--cosm-dialog-padding, var(--cosm-space-xl, 1.5rem));
77
+ padding-bottom: var(--cosm-space-sm, 0.5rem);
78
+ border-top: var(--cosm-space-xs, 0.25rem) solid var(--cosm-primary, oklch(0.55 0.2 268));
79
+ border-start-start-radius: inherit;
80
+ border-start-end-radius: inherit;
81
+ }
82
+ .title {
83
+ flex: 1;
84
+ min-width: 0;
85
+ font-size: var(--cosm-text-xl, 1.25rem);
86
+ font-weight: var(--cosm-weight-semibold, 600);
87
+ line-height: var(--cosm-leading-tight, 1.25);
88
+ overflow-wrap: anywhere;
89
+ }
90
+ .description {
91
+ padding-inline: var(--cosm-dialog-padding, var(--cosm-space-xl, 1.5rem));
92
+ padding-bottom: var(--cosm-space-sm, 0.5rem);
93
+ color: var(--cosm-fg-muted, oklch(0.47 0.018 268));
94
+ font-size: var(--cosm-text-sm, 0.875rem);
95
+ }
96
+ .body {
97
+ overflow: auto;
98
+ min-height: 0;
99
+ flex: 1 1 auto;
100
+ padding: var(--cosm-dialog-padding, var(--cosm-space-xl, 1.5rem));
101
+ padding-top: var(--cosm-space-lg, 1rem);
102
+ }
103
+ .actions {
104
+ flex: none;
105
+ display: flex;
106
+ flex-wrap: wrap;
107
+ align-items: center;
108
+ justify-content: flex-end;
109
+ gap: var(--cosm-space-sm, 0.5rem);
110
+ padding: var(--cosm-space-lg, 1rem) var(--cosm-dialog-padding, var(--cosm-space-xl, 1.5rem));
111
+ border-top: 1px solid var(--cosm-border, oklch(0.88 0.01 268));
112
+ }
113
+ .description[hidden] { display: none; }
114
+ @media (prefers-reduced-motion: reduce) { dialog { scroll-behavior: auto; } }
115
+ `;
116
+ /**
117
+ * Modal dialog with consumer-composed content and cancelable close requests.
118
+ * Slotted forms using method="dialog" propose an action close instead of bypassing ownership.
119
+ * The internal native dialog is not a public handle; unexpected native closes are recovered
120
+ * when its close event fires. Use requestClose() for a synchronously cancelable request.
121
+ * @tag cosm-dialog
122
+ * @slot title - Accessible title.
123
+ * @slot description - Optional short description.
124
+ * @slot - Scrollable body.
125
+ * @slot actions - Consumer actions.
126
+ * @csspart backdrop - Backdrop.
127
+ * @csspart base - Dialog surface.
128
+ * @csspart header - Title and close area.
129
+ * @csspart title - Title container.
130
+ * @csspart description - Description container.
131
+ * @csspart body - Scrollable body.
132
+ * @csspart actions - Actions container.
133
+ * @csspart close - Close IconButton.
134
+ * @fires {CustomEvent<DialogOpenChangeDetail>} cosm-open-change - Visibility proposal.
135
+ * @cssprop --cosm-dialog-z-index - Modal stacking level.
136
+ * @cssprop --cosm-dialog-max-width - Maximum standard width; defaults to the semantic size.
137
+ * @cssprop --cosm-dialog-backdrop - Backdrop color.
138
+ * @cssprop --cosm-dialog-surface - Surface color.
139
+ * @cssprop --cosm-dialog-border - Surface border color.
140
+ * @cssprop --cosm-dialog-radius - Surface radius.
141
+ * @cssprop --cosm-dialog-shadow - Surface shadow.
142
+ * @cssprop --cosm-dialog-padding - Section spacing.
143
+ */
144
+ export class CosmDialog extends CosmElement {
145
+ static shadowRootOptions = {
146
+ ...LitElement.shadowRootOptions,
147
+ delegatesFocus: true,
148
+ };
149
+ static properties = {
150
+ open: { type: Boolean, reflect: true, noAccessor: true },
151
+ defaultOpen: { type: Boolean, attribute: 'default-open' },
152
+ presentation: { reflect: true },
153
+ size: { reflect: true },
154
+ responsiveFullscreen: { type: Boolean, attribute: 'responsive-fullscreen' },
155
+ closeLabel: { attribute: 'close-label' },
156
+ closeOnEscape: { type: Boolean, attribute: 'close-on-escape' },
157
+ closeOnBackdropPress: { type: Boolean, attribute: 'close-on-backdrop-press' },
158
+ initialFocusTarget: { attribute: false },
159
+ returnFocusTarget: { attribute: false },
160
+ };
161
+ static styles = [boxSizing, focusRing, styles];
162
+ openControlled = false;
163
+ #open = false;
164
+ #initialized = false;
165
+ #edited = false;
166
+ #descriptionPresent = false;
167
+ #returnTarget = null;
168
+ #lastFocused = null;
169
+ #fallbackInert = new Map();
170
+ constructor() {
171
+ super();
172
+ const props = dialogContract.props;
173
+ this.defaultOpen = props.defaultOpen.default;
174
+ this.presentation = props.presentation.default;
175
+ this.size = props.size.default;
176
+ this.responsiveFullscreen = props.responsiveFullscreen.default;
177
+ this.closeLabel = props.closeLabel.default;
178
+ this.closeOnEscape = props.closeOnEscape.default;
179
+ this.closeOnBackdropPress = props.closeOnBackdropPress.default;
180
+ this.initialFocusTarget = undefined;
181
+ this.returnFocusTarget = undefined;
182
+ }
183
+ get open() {
184
+ return this.#open;
185
+ }
186
+ set open(value) {
187
+ this.openControlled = value !== undefined;
188
+ if (value !== undefined)
189
+ this.#setOpen(Boolean(value));
190
+ }
191
+ connectedCallback() {
192
+ super.connectedCallback();
193
+ this.addEventListener('submit', this.#onSubmit);
194
+ this.ownerDocument.defaultView?.addEventListener('resize', this.#onViewportChange);
195
+ this.ownerDocument.defaultView?.visualViewport?.addEventListener('resize', this.#onViewportChange);
196
+ this.ownerDocument.defaultView?.visualViewport?.addEventListener('scroll', this.#onViewportChange);
197
+ this.#syncViewportSize();
198
+ if (this.open)
199
+ void this.updateComplete.then(() => {
200
+ if (this.isConnected && this.open)
201
+ this.#show();
202
+ });
203
+ }
204
+ disconnectedCallback() {
205
+ this.removeEventListener('submit', this.#onSubmit);
206
+ this.ownerDocument.defaultView?.removeEventListener('resize', this.#onViewportChange);
207
+ this.ownerDocument.defaultView?.visualViewport?.removeEventListener('resize', this.#onViewportChange);
208
+ this.ownerDocument.defaultView?.visualViewport?.removeEventListener('scroll', this.#onViewportChange);
209
+ this.#hide(false);
210
+ super.disconnectedCallback();
211
+ }
212
+ willUpdate() {
213
+ if (this.size == null)
214
+ this.size = dialogContract.props.size.default;
215
+ if (this.responsiveFullscreen == null)
216
+ this.responsiveFullscreen = dialogContract.props.responsiveFullscreen.default;
217
+ if (!['sm', 'md', 'lg'].includes(this.size))
218
+ throw new TypeError('cosm-dialog size must be sm, md or lg.');
219
+ if (!this.closeLabel?.trim())
220
+ throw new Error('cosm-dialog requires a non-empty closeLabel.');
221
+ if (!this.#initialized) {
222
+ this.#initialized = true;
223
+ if (!this.openControlled && !this.#edited)
224
+ this.#setOpen(this.defaultOpen);
225
+ }
226
+ const sizes = { sm: 400, md: 640, lg: 960 };
227
+ this.style.setProperty('--_cosm-dialog-max-width', `var(--cosm-dialog-max-width, ${sizes[this.size]}px)`);
228
+ }
229
+ updated(changed) {
230
+ if (changed.has('open')) {
231
+ if (this.open && this.isConnected)
232
+ this.#show();
233
+ else if (!this.open)
234
+ this.#hide(true);
235
+ }
236
+ }
237
+ requestOpen() {
238
+ if (!this.open)
239
+ this.#propose(true, 'action');
240
+ }
241
+ requestClose() {
242
+ if (this.open)
243
+ this.#propose(false, 'action');
244
+ }
245
+ #setOpen(value) {
246
+ if (value === this.#open)
247
+ return;
248
+ const old = this.#open;
249
+ if (value) {
250
+ const active = this.ownerDocument.activeElement;
251
+ this.#returnTarget = active instanceof HTMLElement ? active : null;
252
+ }
253
+ this.#open = value;
254
+ this.requestUpdate('open', old);
255
+ }
256
+ #propose(open, reason) {
257
+ if (open === this.open)
258
+ return;
259
+ this.#edited = true;
260
+ let event;
261
+ if (open) {
262
+ event = new CustomEvent('cosm-open-change', {
263
+ detail: { open: true, reason: 'action' },
264
+ bubbles: true,
265
+ composed: true,
266
+ });
267
+ }
268
+ else {
269
+ const detail = {
270
+ open: false,
271
+ reason,
272
+ get defaultPrevented() {
273
+ return event.defaultPrevented;
274
+ },
275
+ preventDefault() {
276
+ event.preventDefault();
277
+ },
278
+ };
279
+ event = new CustomEvent('cosm-open-change', {
280
+ detail,
281
+ bubbles: true,
282
+ composed: true,
283
+ cancelable: true,
284
+ });
285
+ }
286
+ this.dispatchEvent(event);
287
+ if (!event.defaultPrevented && !this.openControlled)
288
+ this.#setOpen(open);
289
+ }
290
+ #show(recover = false) {
291
+ const dialog = this.renderRoot.querySelector('dialog');
292
+ if (!dialog || dialog.open)
293
+ return;
294
+ const recoveryTarget = recover ? this.#lastFocused : null;
295
+ const active = this.ownerDocument.activeElement;
296
+ if (!recover &&
297
+ (!this.#returnTarget || this.#returnTarget === this.ownerDocument.body) &&
298
+ active instanceof HTMLElement &&
299
+ active !== this) {
300
+ this.#returnTarget = active;
301
+ }
302
+ if (typeof dialog.showModal === 'function')
303
+ dialog.showModal();
304
+ else {
305
+ dialog.setAttribute('open', '');
306
+ this.#setFallbackInert();
307
+ }
308
+ const target = recover ? recoveryTarget : this.initialFocusTarget;
309
+ if (target && this.#containsComposed(target) && target.isConnected)
310
+ target.focus();
311
+ else {
312
+ const close = this.renderRoot.querySelector('cosm-icon-button[part="close"]');
313
+ const first = this.#focusableElements().find(element => !close || !this.#inside(element, close));
314
+ (first ?? this.renderRoot.querySelector('[part="base"]'))?.focus();
315
+ }
316
+ }
317
+ #hide(restore) {
318
+ const dialog = this.renderRoot.querySelector('dialog');
319
+ const wasOpen = Boolean(dialog?.open);
320
+ if (dialog?.open) {
321
+ if (typeof dialog.close === 'function')
322
+ dialog.close();
323
+ else
324
+ dialog.removeAttribute('open');
325
+ }
326
+ for (const [element, inert] of this.#fallbackInert)
327
+ element.inert = inert;
328
+ this.#fallbackInert.clear();
329
+ if (restore && wasOpen) {
330
+ const target = [this.returnFocusTarget, this.#returnTarget].find(candidate => candidate?.isConnected && !candidate.matches(':disabled, [inert]'));
331
+ if (target)
332
+ target.focus();
333
+ else
334
+ this.ownerDocument.body.focus();
335
+ }
336
+ }
337
+ #setFallbackInert() {
338
+ for (let node = this; node?.parentElement; node = node.parentElement) {
339
+ for (const sibling of node.parentElement.children) {
340
+ if (sibling !== node && sibling instanceof HTMLElement) {
341
+ if (!this.#fallbackInert.has(sibling))
342
+ this.#fallbackInert.set(sibling, sibling.inert);
343
+ sibling.inert = true;
344
+ }
345
+ }
346
+ }
347
+ }
348
+ #inside(target, ancestor) {
349
+ let node = target;
350
+ while (node) {
351
+ if (node === ancestor)
352
+ return true;
353
+ node = node.parentNode ?? (node instanceof ShadowRoot ? node.host : null);
354
+ }
355
+ return false;
356
+ }
357
+ #containsComposed(target) {
358
+ return this.#inside(target, this);
359
+ }
360
+ #isFullscreen() {
361
+ return (this.presentation === 'fullscreen' ||
362
+ (this.responsiveFullscreen && (this.ownerDocument.defaultView?.innerWidth ?? 1024) < 640));
363
+ }
364
+ #syncViewportSize() {
365
+ const view = this.ownerDocument.defaultView;
366
+ const viewport = view?.visualViewport;
367
+ if (view) {
368
+ this.style.setProperty('--_cosm-dialog-viewport-width', `${viewport?.width ?? view.innerWidth}px`);
369
+ this.style.setProperty('--_cosm-dialog-viewport-height', `${viewport?.height ?? view.innerHeight}px`);
370
+ }
371
+ }
372
+ #onViewportChange = () => {
373
+ this.#syncViewportSize();
374
+ this.requestUpdate();
375
+ };
376
+ #focusableElements() {
377
+ const result = [];
378
+ const selector = 'button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])';
379
+ const visit = (element) => {
380
+ if (element.matches('[hidden], [inert], [aria-hidden="true"]'))
381
+ return;
382
+ if (element instanceof HTMLElement) {
383
+ const style = this.ownerDocument.defaultView?.getComputedStyle(element);
384
+ if (style?.display === 'none' || style?.visibility === 'hidden')
385
+ return;
386
+ if (element.matches(selector) && element.tabIndex >= 0)
387
+ result.push(element);
388
+ }
389
+ if (element instanceof HTMLSlotElement) {
390
+ for (const assigned of element.assignedElements({ flatten: true }))
391
+ visit(assigned);
392
+ }
393
+ else {
394
+ const root = element.shadowRoot ?? element;
395
+ for (const child of root.children)
396
+ visit(child);
397
+ }
398
+ };
399
+ const dialog = this.renderRoot.querySelector('dialog');
400
+ if (dialog)
401
+ visit(dialog);
402
+ return result;
403
+ }
404
+ #onKeydown = (event) => {
405
+ if (event.defaultPrevented)
406
+ return;
407
+ if (event.key === 'Escape') {
408
+ event.preventDefault();
409
+ if (this.closeOnEscape)
410
+ this.#propose(false, 'escape');
411
+ }
412
+ else if (event.key === 'Tab') {
413
+ const candidates = this.#focusableElements();
414
+ if (!candidates.length) {
415
+ event.preventDefault();
416
+ this.renderRoot.querySelector('[part="base"]')?.focus();
417
+ return;
418
+ }
419
+ let active = this.ownerDocument.activeElement;
420
+ while (active?.shadowRoot?.activeElement)
421
+ active = active.shadowRoot.activeElement;
422
+ const index = candidates.findIndex(candidate => candidate === active || candidate.contains(active));
423
+ if ((!event.shiftKey && (index === candidates.length - 1 || index < 0)) ||
424
+ (event.shiftKey && index <= 0)) {
425
+ event.preventDefault();
426
+ (event.shiftKey ? candidates[candidates.length - 1] : candidates[0])?.focus();
427
+ }
428
+ }
429
+ };
430
+ #onCancel = (event) => {
431
+ event.preventDefault();
432
+ if (this.closeOnEscape)
433
+ this.#propose(false, 'escape');
434
+ };
435
+ #onSubmit = (event) => {
436
+ if (event.defaultPrevented || !this.open || !(event.target instanceof HTMLFormElement))
437
+ return;
438
+ const form = event.target;
439
+ // A consumer-owned nested native dialog owns its own dialog-method submission.
440
+ if (form.closest('dialog'))
441
+ return;
442
+ const submitter = event instanceof SubmitEvent ? event.submitter : null;
443
+ const override = submitter?.getAttribute('formmethod');
444
+ const method = override === null || override === undefined ? form.method : override;
445
+ if (method.trim().toLowerCase() !== 'dialog')
446
+ return;
447
+ event.preventDefault();
448
+ this.#propose(false, 'action');
449
+ };
450
+ #onFocusIn = (event) => {
451
+ const focused = event.composedPath().find(node => node instanceof HTMLElement);
452
+ if (focused instanceof HTMLElement && this.#containsComposed(focused))
453
+ this.#lastFocused = focused;
454
+ };
455
+ #onNativeClose = () => {
456
+ const dialog = this.renderRoot.querySelector('dialog');
457
+ if (this.isConnected && this.open && dialog && !dialog.open)
458
+ this.#show(true);
459
+ };
460
+ #onDescriptionChange = (event) => {
461
+ const slot = event.currentTarget;
462
+ const present = slot
463
+ .assignedNodes({ flatten: true })
464
+ .some(node => node.nodeType === Node.ELEMENT_NODE || Boolean(node.textContent?.trim()));
465
+ if (present !== this.#descriptionPresent) {
466
+ this.#descriptionPresent = present;
467
+ this.requestUpdate();
468
+ }
469
+ };
470
+ render() {
471
+ return html `
472
+ <dialog aria-labelledby="dialog-title" aria-describedby=${this.#descriptionPresent ? 'dialog-description' : nothing}
473
+ aria-modal="true" ?data-fullscreen=${this.#isFullscreen()} @cancel=${this.#onCancel} @close=${this.#onNativeClose}
474
+ @focusin=${this.#onFocusIn} @keydown=${this.#onKeydown}>
475
+ <div part="backdrop" class="backdrop" @click=${() => {
476
+ if (this.closeOnBackdropPress)
477
+ this.#propose(false, 'backdrop');
478
+ }}></div>
479
+ <div class="layout">
480
+ <div part="base" class="base" tabindex="-1">
481
+ <div part="header" class="header">
482
+ <div part="title" class="title" id="dialog-title"><slot name="title"></slot></div>
483
+ <cosm-icon-button part="close" .label=${this.closeLabel} variant="ghost" tone="neutral"
484
+ @cosm-press=${() => this.#propose(false, 'close-button')}>
485
+ <cosm-icon .icon=${x}></cosm-icon>
486
+ </cosm-icon-button>
487
+ </div>
488
+ <div part="description" class="description" id="dialog-description" ?hidden=${!this.#descriptionPresent}><slot name="description" @slotchange=${this.#onDescriptionChange}></slot></div>
489
+ <div part="body" class="body"><slot></slot></div>
490
+ <div part="actions" class="actions"><slot name="actions"></slot></div>
491
+ </div>
492
+ </div>
493
+ </dialog>`;
494
+ }
495
+ }
496
+ define('cosm-dialog', CosmDialog);
497
+ //# sourceMappingURL=cosm-dialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cosm-dialog.js","sourceRoot":"","sources":["../../../src/components/dialog/cosm-dialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,cAAc,GACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,CAAC,EAAE,MAAM,2BAA2B,CAAC;AAC9C,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,oCAAoC,CAAC;AAC5C,OAAO,kDAAkD,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAIhE,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0GjB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,OAAO,UAAW,SAAQ,WAAW;IACzC,MAAM,CAAU,iBAAiB,GAAmB;QAClD,GAAG,UAAU,CAAC,iBAAiB;QAC/B,cAAc,EAAE,IAAI;KACrB,CAAC;IACF,MAAM,CAAU,UAAU,GAAG;QAC3B,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE;QACxD,WAAW,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE;QACzD,YAAY,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;QAC/B,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;QACvB,oBAAoB,EAAE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AI,CAAC,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;mCACrC,CAAC;;;0FAGsD,CAAC,IAAI,CAAC,mBAAmB,yCAAyC,IAAI,CAAC,oBAAoB;;;;;gBAKrK,CAAC;IACf,CAAC;;AAGH,MAAM,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC"}
@@ -5,8 +5,9 @@ type Props = ContractProps<typeof iconContract, 'web', {
5
5
  IconDefinition: IconDefinition;
6
6
  }>;
7
7
  export type CosmIconSize = Exclude<Props['size'], undefined>;
8
+ export type CosmIconVariant = Exclude<Props['variant'], undefined>;
8
9
  /**
9
- * Renders a structured SVG icon as a decorative graphic or a named informative image.
10
+ * Renders a structured SVG icon as a decorative graphic or, with a nonempty `label`, a named image.
10
11
  *
11
12
  * @tag cosm-icon
12
13
  * @csspart icon - The rendered SVG image.
@@ -25,32 +26,23 @@ export declare class CosmIcon extends CosmElement {
25
26
  toAttribute: (value: CosmIconSize) => string;
26
27
  };
27
28
  };
28
- stroke: {
29
+ variant: {
29
30
  type: StringConstructor;
31
+ reflect: boolean;
30
32
  };
31
- fill: {
33
+ color: {
32
34
  type: StringConstructor;
33
35
  };
34
- strokeWidth: {
35
- type: NumberConstructor;
36
- attribute: string;
37
- };
38
36
  label: {
39
37
  type: StringConstructor;
40
38
  };
41
- decorative: {
42
- type: BooleanConstructor;
43
- reflect: boolean;
44
- };
45
39
  };
46
40
  static styles: import("lit").CSSResult[];
47
41
  icon: Props['icon'];
48
42
  size: CosmIconSize;
49
- stroke: string;
50
- fill: string;
51
- strokeWidth: number;
43
+ variant: CosmIconVariant;
44
+ color: string;
52
45
  label: string | undefined;
53
- decorative: boolean;
54
46
  constructor();
55
47
  protected updated(): void;
56
48
  protected willUpdate(): void;