@firstprateek/vastu 0.0.0-stage → 1.1.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 (149) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +52 -2
  3. package/custom-elements.json +3737 -0
  4. package/dist/dev/all.d.ts +12 -0
  5. package/dist/dev/all.d.ts.map +1 -0
  6. package/dist/dev/all.js +13 -0
  7. package/dist/dev/all.js.map +1 -0
  8. package/dist/dev/bar-chart/bar-chart.d.ts +63 -0
  9. package/dist/dev/bar-chart/bar-chart.d.ts.map +1 -0
  10. package/dist/dev/bar-chart/bar-chart.js +316 -0
  11. package/dist/dev/bar-chart/bar-chart.js.map +1 -0
  12. package/dist/dev/bar-chart/index.d.ts +3 -0
  13. package/dist/dev/bar-chart/index.d.ts.map +1 -0
  14. package/dist/dev/bar-chart/index.js +5 -0
  15. package/dist/dev/bar-chart/index.js.map +1 -0
  16. package/dist/dev/button/button.d.ts +98 -0
  17. package/dist/dev/button/button.d.ts.map +1 -0
  18. package/dist/dev/button/button.js +292 -0
  19. package/dist/dev/button/button.js.map +1 -0
  20. package/dist/dev/button/index.d.ts +4 -0
  21. package/dist/dev/button/index.d.ts.map +1 -0
  22. package/dist/dev/button/index.js +5 -0
  23. package/dist/dev/button/index.js.map +1 -0
  24. package/dist/dev/checkbox/checkbox.d.ts +71 -0
  25. package/dist/dev/checkbox/checkbox.d.ts.map +1 -0
  26. package/dist/dev/checkbox/checkbox.js +232 -0
  27. package/dist/dev/checkbox/checkbox.js.map +1 -0
  28. package/dist/dev/checkbox/index.d.ts +3 -0
  29. package/dist/dev/checkbox/index.d.ts.map +1 -0
  30. package/dist/dev/checkbox/index.js +5 -0
  31. package/dist/dev/checkbox/index.js.map +1 -0
  32. package/dist/dev/core/cssom.d.ts +15 -0
  33. package/dist/dev/core/cssom.d.ts.map +1 -0
  34. package/dist/dev/core/cssom.js +30 -0
  35. package/dist/dev/core/cssom.js.map +1 -0
  36. package/dist/dev/core/define.d.ts +3 -0
  37. package/dist/dev/core/define.d.ts.map +1 -0
  38. package/dist/dev/core/define.js +6 -0
  39. package/dist/dev/core/define.js.map +1 -0
  40. package/dist/dev/core/dev-mode.d.ts +6 -0
  41. package/dist/dev/core/dev-mode.d.ts.map +1 -0
  42. package/dist/dev/core/dev-mode.js +6 -0
  43. package/dist/dev/core/dev-mode.js.map +1 -0
  44. package/dist/dev/core/focus-ring.d.ts +3 -0
  45. package/dist/dev/core/focus-ring.d.ts.map +1 -0
  46. package/dist/dev/core/focus-ring.js +14 -0
  47. package/dist/dev/core/focus-ring.js.map +1 -0
  48. package/dist/dev/core/form-control.d.ts +47 -0
  49. package/dist/dev/core/form-control.d.ts.map +1 -0
  50. package/dist/dev/core/form-control.js +75 -0
  51. package/dist/dev/core/form-control.js.map +1 -0
  52. package/dist/dev/core/warn.d.ts +12 -0
  53. package/dist/dev/core/warn.d.ts.map +1 -0
  54. package/dist/dev/core/warn.js +35 -0
  55. package/dist/dev/core/warn.js.map +1 -0
  56. package/dist/dev/dialog/dialog.d.ts +77 -0
  57. package/dist/dev/dialog/dialog.d.ts.map +1 -0
  58. package/dist/dev/dialog/dialog.js +253 -0
  59. package/dist/dev/dialog/dialog.js.map +1 -0
  60. package/dist/dev/dialog/index.d.ts +4 -0
  61. package/dist/dev/dialog/index.d.ts.map +1 -0
  62. package/dist/dev/dialog/index.js +5 -0
  63. package/dist/dev/dialog/index.js.map +1 -0
  64. package/dist/dev/menu/index.d.ts +3 -0
  65. package/dist/dev/menu/index.d.ts.map +1 -0
  66. package/dist/dev/menu/index.js +5 -0
  67. package/dist/dev/menu/index.js.map +1 -0
  68. package/dist/dev/menu/menu.d.ts +71 -0
  69. package/dist/dev/menu/menu.d.ts.map +1 -0
  70. package/dist/dev/menu/menu.js +330 -0
  71. package/dist/dev/menu/menu.js.map +1 -0
  72. package/dist/dev/navbar/index.d.ts +3 -0
  73. package/dist/dev/navbar/index.d.ts.map +1 -0
  74. package/dist/dev/navbar/index.js +5 -0
  75. package/dist/dev/navbar/index.js.map +1 -0
  76. package/dist/dev/navbar/navbar.d.ts +69 -0
  77. package/dist/dev/navbar/navbar.d.ts.map +1 -0
  78. package/dist/dev/navbar/navbar.js +353 -0
  79. package/dist/dev/navbar/navbar.js.map +1 -0
  80. package/dist/dev/poll/index.d.ts +3 -0
  81. package/dist/dev/poll/index.d.ts.map +1 -0
  82. package/dist/dev/poll/index.js +5 -0
  83. package/dist/dev/poll/index.js.map +1 -0
  84. package/dist/dev/poll/poll.d.ts +67 -0
  85. package/dist/dev/poll/poll.d.ts.map +1 -0
  86. package/dist/dev/poll/poll.js +301 -0
  87. package/dist/dev/poll/poll.js.map +1 -0
  88. package/dist/dev/switch/index.d.ts +3 -0
  89. package/dist/dev/switch/index.d.ts.map +1 -0
  90. package/dist/dev/switch/index.js +5 -0
  91. package/dist/dev/switch/index.js.map +1 -0
  92. package/dist/dev/switch/switch.d.ts +69 -0
  93. package/dist/dev/switch/switch.d.ts.map +1 -0
  94. package/dist/dev/switch/switch.js +213 -0
  95. package/dist/dev/switch/switch.js.map +1 -0
  96. package/dist/dev/tabs/index.d.ts +3 -0
  97. package/dist/dev/tabs/index.d.ts.map +1 -0
  98. package/dist/dev/tabs/index.js +5 -0
  99. package/dist/dev/tabs/index.js.map +1 -0
  100. package/dist/dev/tabs/tabs.d.ts +64 -0
  101. package/dist/dev/tabs/tabs.d.ts.map +1 -0
  102. package/dist/dev/tabs/tabs.js +212 -0
  103. package/dist/dev/tabs/tabs.js.map +1 -0
  104. package/dist/dev/text-field/index.d.ts +3 -0
  105. package/dist/dev/text-field/index.d.ts.map +1 -0
  106. package/dist/dev/text-field/index.js +5 -0
  107. package/dist/dev/text-field/index.js.map +1 -0
  108. package/dist/dev/text-field/text-field.d.ts +91 -0
  109. package/dist/dev/text-field/text-field.d.ts.map +1 -0
  110. package/dist/dev/text-field/text-field.js +267 -0
  111. package/dist/dev/text-field/text-field.js.map +1 -0
  112. package/dist/dev/toast/index.d.ts +4 -0
  113. package/dist/dev/toast/index.d.ts.map +1 -0
  114. package/dist/dev/toast/index.js +5 -0
  115. package/dist/dev/toast/index.js.map +1 -0
  116. package/dist/dev/toast/toast.d.ts +71 -0
  117. package/dist/dev/toast/toast.d.ts.map +1 -0
  118. package/dist/dev/toast/toast.js +258 -0
  119. package/dist/dev/toast/toast.js.map +1 -0
  120. package/dist/prod/all.js +13 -0
  121. package/dist/prod/bar-chart/bar-chart.js +316 -0
  122. package/dist/prod/bar-chart/index.js +5 -0
  123. package/dist/prod/button/button.js +292 -0
  124. package/dist/prod/button/index.js +5 -0
  125. package/dist/prod/checkbox/checkbox.js +232 -0
  126. package/dist/prod/checkbox/index.js +5 -0
  127. package/dist/prod/core/cssom.js +30 -0
  128. package/dist/prod/core/define.js +6 -0
  129. package/dist/prod/core/dev-mode.js +1 -0
  130. package/dist/prod/core/focus-ring.js +14 -0
  131. package/dist/prod/core/form-control.js +75 -0
  132. package/dist/prod/core/warn.js +2 -0
  133. package/dist/prod/dialog/dialog.js +253 -0
  134. package/dist/prod/dialog/index.js +5 -0
  135. package/dist/prod/menu/index.js +5 -0
  136. package/dist/prod/menu/menu.js +330 -0
  137. package/dist/prod/navbar/index.js +5 -0
  138. package/dist/prod/navbar/navbar.js +353 -0
  139. package/dist/prod/poll/index.js +5 -0
  140. package/dist/prod/poll/poll.js +301 -0
  141. package/dist/prod/switch/index.js +5 -0
  142. package/dist/prod/switch/switch.js +213 -0
  143. package/dist/prod/tabs/index.js +5 -0
  144. package/dist/prod/tabs/tabs.js +212 -0
  145. package/dist/prod/text-field/index.js +5 -0
  146. package/dist/prod/text-field/text-field.js +267 -0
  147. package/dist/prod/toast/index.js +5 -0
  148. package/dist/prod/toast/toast.js +258 -0
  149. package/package.json +110 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkbox.js","sourceRoot":"","sources":["../../../src/checkbox/checkbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,IAA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;IACJ,CAAC;aAEe,WAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwF3B,CAAC","sourcesContent":["import { css, html, nothing, svg, type PropertyDeclarations } from 'lit';\nimport { FormControl } from '../core/form-control.js';\nimport { checkTokensLoaded, devWarn } from '../core/warn.js';\n\n/**\n * A checkbox for a choice that is submitted with a form.\n *\n * @tag va-checkbox\n * @summary Lets the user choose an option, or agree to something, as part of a form.\n *\n * @slot - The visible label. Clicking it toggles the checkbox.\n * @slot help-text - Optional help text under the label. It becomes the checkbox's description.\n *\n * @csspart control - The square box.\n * @csspart label - The label text.\n * @csspart help-text - The help text.\n *\n * @cssprop {<color>} --va-checkbox-border - Border colour of the box when unchecked.\n * @cssprop {<color>} --va-checkbox-bg-checked - Fill and border colour when checked or indeterminate.\n * @cssprop {<color>} --va-checkbox-mark-fg - Colour of the tick or dash.\n * @cssprop {<length>} --va-checkbox-size - Width and height of the box.\n *\n * @cssprop-applies --va-checkbox-border control:unchecked border-top-color\n * @cssprop-applies --va-checkbox-bg-checked control:checked background-color\n * @cssprop-applies --va-checkbox-mark-fg control:checked color\n * @cssprop-applies --va-checkbox-size control width\n *\n * @keyboard Space | toggles | Checks or unchecks the box.\n * @keyboard Tab | focus-next | Moves focus to the next control.\n *\n * @a11y-role checkbox\n * @a11y-name-from text, accessible-label\n * @replaces input[type=\"checkbox\"]\n * @a11y-name The slotted label text. Use `accessible-label` only when there is no visible label.\n * @a11y-note `indeterminate` is announced as \"mixed\", for a box that stands for a partly selected group.\n * @a11y-note Style states with `va-checkbox:state(checked)` and `:state(indeterminate)`; the `checked` attribute is the initial state only, as on a native checkbox.\n *\n * @guidance-use For an option submitted with a form, for agreeing to terms, or to select items in a list.\n * @guidance-avoid For a setting that should apply immediately.\n * @guidance-instead `va-switch` for settings that take effect immediately.\n *\n * @fires change - When the user checks or unchecks the box. Read `event.target.checked`.\n * @fires input - When the user checks or unchecks the box, just before `change`.\n * @event-trigger change | click\n * @event-trigger input | click\n */\nexport class VaCheckbox extends FormControl {\n static override shadowRootOptions: ShadowRootInit = { ...FormControl.shadowRootOptions, delegatesFocus: true };\n\n static override properties: PropertyDeclarations = {\n checked: { type: Boolean },\n indeterminate: { type: Boolean },\n value: {},\n accessibleLabel: { attribute: 'accessible-label' },\n };\n\n /** Whether the box is checked. The `checked` attribute sets the initial state, as on a native checkbox. */\n declare checked: boolean;\n /** Shows a dash for a partly selected group. Cleared when the user toggles the box. */\n declare indeterminate: boolean;\n /** Submitted with `name` while the box is checked. Defaults to `on`, as for a native checkbox. */\n declare value: string;\n /** Accessible name for a checkbox with no visible label, such as one selecting a table row. */\n declare accessibleLabel: string;\n\n #defaultChecked: boolean | undefined;\n\n constructor() {\n super();\n this.checked = false;\n this.indeterminate = false;\n this.value = 'on';\n this.accessibleLabel = '';\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n // The default is the initial attribute, read once: moving the element must not change it.\n this.#defaultChecked ??= this.hasAttribute('checked');\n checkTokensLoaded(this);\n }\n\n override firstUpdated(): void {\n requestAnimationFrame(() => {\n const text = this.#labelText();\n if (!text && !this.accessibleLabel) {\n devWarn('va-checkbox', 'This checkbox has no accessible name.', 'Put label text inside it, or add accessible-label=\"…\" when there is no room for one (e.g. accessible-label=\"Select row\").');\n } else if (text && this.accessibleLabel && !this.accessibleLabel.toLowerCase().includes(text.toLowerCase())) {\n devWarn('va-checkbox', `accessible-label=\"${this.accessibleLabel}\" replaces the visible label \"${text}\" for screen readers (WCAG 2.5.3).`, 'Remove accessible-label: the visible text is the name.');\n }\n });\n }\n\n /** The visible label: text not in the help-text slot. */\n #labelText(): string {\n return [...this.childNodes]\n .filter((n) => !(n instanceof Element && n.slot))\n .map((n) => n.textContent ?? '')\n .join('')\n .trim();\n }\n\n override updated(): void {\n this._setState('checked', this.checked);\n this._setState('indeterminate', this.indeterminate);\n this._internals.setFormValue(this.checked ? this.value : null);\n const missing = this.required && !this.checked;\n this._internals.setValidity(\n missing ? { valueMissing: true } : {},\n missing ? 'Check this box to continue.' : '',\n this.shadowRoot?.querySelector('input') ?? undefined\n );\n }\n\n /** @internal */\n override formResetCallback(): void {\n this.checked = this.#defaultChecked ?? false;\n }\n\n // The inner checkbox's native input event crosses the shadow root; the host fires its own instead.\n #stopNative(event: Event): void {\n event.stopPropagation();\n }\n\n #onChange(event: Event): void {\n const input = event.target as HTMLInputElement;\n this.checked = input.checked;\n this.indeterminate = false;\n this._emit('input');\n this._emit('change');\n }\n\n override render() {\n const mark = this.indeterminate\n ? svg`<path d=\"M4 8h8\" />`\n : this.checked\n ? svg`<path d=\"M3.5 8.5l3 3 6-7\" />`\n : nothing;\n return html`\n <label class=\"wrapper ${this._isDisabled ? 'disabled' : ''}\">\n <span class=\"control-wrap\">\n <input\n class=\"native\"\n type=\"checkbox\"\n .checked=${this.checked}\n .indeterminate=${this.indeterminate}\n ?disabled=${this._isDisabled}\n ?required=${this.required}\n aria-label=${this.accessibleLabel || nothing}\n aria-labelledby=${this.accessibleLabel ? nothing : 'label'}\n aria-describedby=\"help-text\"\n @input=${this.#stopNative}\n @change=${this.#onChange}\n />\n <span part=\"control\" class=\"box ${this.checked || this.indeterminate ? 'on' : ''}\" aria-hidden=\"true\">\n <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">${mark}</svg>\n </span>\n </span>\n <span class=\"text\">\n <span part=\"label\" id=\"label\" class=\"label\"><slot></slot></span>\n <span part=\"help-text\" id=\"help-text\" class=\"help-text\"><slot name=\"help-text\"></slot></span>\n </span>\n </label>\n `;\n }\n\n static override styles = css`\n :host {\n --_size: var(--va-checkbox-size, 1.125rem);\n display: inline-flex;\n font-family: var(--va-font-family-ui);\n font-size: var(--va-font-size-md);\n color: var(--va-color-text-default);\n vertical-align: middle;\n }\n :host([hidden]) {\n display: none;\n }\n .wrapper {\n display: inline-flex;\n align-items: flex-start;\n gap: var(--va-space-inline-sm);\n cursor: pointer;\n /* Keeps the whole row at least 24px high for the WCAG 2.2 target size. */\n min-height: 1.5rem;\n padding-block: 0.1875rem;\n box-sizing: border-box;\n }\n .control-wrap {\n position: relative;\n flex: none;\n display: inline-flex;\n }\n /* The real checkbox covers the visible box, invisibly, so pointers and automation hit it directly. */\n .native {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n margin: 0;\n opacity: 0;\n cursor: inherit;\n z-index: 1;\n }\n .box {\n flex: none;\n box-sizing: border-box;\n display: grid;\n place-items: center;\n width: var(--_size);\n height: var(--_size);\n margin-top: 0.1rem;\n border: 1.5px solid var(--va-checkbox-border, var(--va-color-border-control));\n border-radius: var(--va-radius-control);\n background-color: var(--va-color-surface-default);\n color: var(--va-checkbox-mark-fg, var(--va-color-text-on-accent));\n }\n .box svg {\n width: 100%;\n height: 100%;\n }\n .box.on {\n border-color: var(--va-checkbox-bg-checked, var(--va-color-accent-default));\n background-color: var(--va-checkbox-bg-checked, var(--va-color-accent-default));\n }\n .native:focus-visible + .box {\n outline: var(--va-size-focus-ring, 2px) solid var(--va-color-focus);\n outline-offset: 2px;\n }\n .wrapper.disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n .text {\n display: flex;\n flex-direction: column;\n }\n .help-text {\n color: var(--va-color-text-muted);\n font-size: var(--va-font-size-sm);\n }\n @media (forced-colors: active) {\n .box {\n border-color: ButtonText;\n }\n .box.on {\n background-color: Highlight;\n color: HighlightText;\n forced-color-adjust: none;\n }\n .native:focus-visible + .box {\n outline-color: Highlight;\n }\n }\n `;\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'va-checkbox': VaCheckbox;\n }\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import { VaCheckbox } from './checkbox.js';
2
+ export { VaCheckbox };
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/checkbox/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { define } from '../core/define.js';
2
+ import { VaCheckbox } from './checkbox.js';
3
+ export { VaCheckbox };
4
+ define('va-checkbox', VaCheckbox);
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/checkbox/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB,MAAM,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC","sourcesContent":["import { define } from '../core/define.js';\nimport { VaCheckbox } from './checkbox.js';\n\nexport { VaCheckbox };\n\ndefine('va-checkbox', VaCheckbox);\n"]}
@@ -0,0 +1,15 @@
1
+ import { Directive, type ElementPart, type PartInfo } from 'lit/directive.js';
2
+ /**
3
+ * Sets inline styles through the CSSOM (element.style), never through a style attribute, so a
4
+ * strict Content Security Policy allows them. Lit's styleMap writes a style attribute on the first
5
+ * render, which `style-src 'self'` blocks. Use it in an element position: <span ${cssom({ … })}>.
6
+ */
7
+ declare class CssomDirective extends Directive {
8
+ #private;
9
+ constructor(part: PartInfo);
10
+ render(styles: Record<string, string>): undefined;
11
+ update(part: ElementPart, [styles]: [Record<string, string>]): undefined;
12
+ }
13
+ export declare const cssom: (styles: Record<string, string>) => import("lit/directive.js").DirectiveResult<typeof CssomDirective>;
14
+ export {};
15
+ //# sourceMappingURL=cssom.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cssom.d.ts","sourceRoot":"","sources":["../../../src/core/cssom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAuB,KAAK,WAAW,EAAE,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEnG;;;;GAIG;AACH,cAAM,cAAe,SAAQ,SAAS;;gBAGxB,IAAI,EAAE,QAAQ;IAK1B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAK5B,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAOtE;AAED,eAAO,MAAM,KAAK,uGAA4B,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { Directive, directive, PartType } from 'lit/directive.js';
2
+ /**
3
+ * Sets inline styles through the CSSOM (element.style), never through a style attribute, so a
4
+ * strict Content Security Policy allows them. Lit's styleMap writes a style attribute on the first
5
+ * render, which `style-src 'self'` blocks. Use it in an element position: <span ${cssom({ … })}>.
6
+ */
7
+ class CssomDirective extends Directive {
8
+ #previous = new Set();
9
+ constructor(part) {
10
+ super(part);
11
+ if (part.type !== PartType.ELEMENT)
12
+ throw new Error('cssom() goes in an element position: <div ${cssom({…})}>.');
13
+ }
14
+ render(styles) {
15
+ void styles;
16
+ return undefined;
17
+ }
18
+ update(part, [styles]) {
19
+ const style = part.element.style;
20
+ for (const name of this.#previous)
21
+ if (!(name in styles))
22
+ style.removeProperty(name);
23
+ for (const [name, value] of Object.entries(styles))
24
+ style.setProperty(name, value);
25
+ this.#previous = new Set(Object.keys(styles));
26
+ return undefined;
27
+ }
28
+ }
29
+ export const cssom = directive(CssomDirective);
30
+ //# sourceMappingURL=cssom.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cssom.js","sourceRoot":"","sources":["../../../src/core/cssom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAmC,MAAM,kBAAkB,CAAC;AAEnG;;;;GAIG;AACH,MAAM,cAAe,SAAQ,SAAS;IACpC,SAAS,GAAG,IAAI,GAAG,EAAU,CAAC;IAE9B,YAAY,IAAc;QACxB,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;IACnH,CAAC;IAED,MAAM,CAAC,MAA8B;QACnC,KAAK,MAAM,CAAC;QACZ,OAAO,SAAS,CAAC;IACnB,CAAC;IAEQ,MAAM,CAAC,IAAiB,EAAE,CAAC,MAAM,CAA2B;QACnE,MAAM,KAAK,GAAI,IAAI,CAAC,OAAuB,CAAC,KAAK,CAAC;QAClD,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,SAAS;YAAE,IAAI,CAAC,CAAC,IAAI,IAAI,MAAM,CAAC;gBAAE,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QACrF,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;YAAE,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACnF,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAC9C,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC","sourcesContent":["import { Directive, directive, PartType, type ElementPart, type PartInfo } from 'lit/directive.js';\n\n/**\n * Sets inline styles through the CSSOM (element.style), never through a style attribute, so a\n * strict Content Security Policy allows them. Lit's styleMap writes a style attribute on the first\n * render, which `style-src 'self'` blocks. Use it in an element position: <span ${cssom({ … })}>.\n */\nclass CssomDirective extends Directive {\n #previous = new Set<string>();\n\n constructor(part: PartInfo) {\n super(part);\n if (part.type !== PartType.ELEMENT) throw new Error('cssom() goes in an element position: <div ${cssom({…})}>.');\n }\n\n render(styles: Record<string, string>) {\n void styles;\n return undefined;\n }\n\n override update(part: ElementPart, [styles]: [Record<string, string>]) {\n const style = (part.element as HTMLElement).style;\n for (const name of this.#previous) if (!(name in styles)) style.removeProperty(name);\n for (const [name, value] of Object.entries(styles)) style.setProperty(name, value);\n this.#previous = new Set(Object.keys(styles));\n return undefined;\n }\n}\n\nexport const cssom = directive(CssomDirective);\n"]}
@@ -0,0 +1,3 @@
1
+ /** Defines a custom element once. A second definition of the same tag is a no-op, not an error. */
2
+ export declare function define(tag: string, ctor: CustomElementConstructor): void;
3
+ //# sourceMappingURL=define.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../../../src/core/define.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,wBAAwB,GAAG,IAAI,CAExE"}
@@ -0,0 +1,6 @@
1
+ /** Defines a custom element once. A second definition of the same tag is a no-op, not an error. */
2
+ export function define(tag, ctor) {
3
+ if (!customElements.get(tag))
4
+ customElements.define(tag, ctor);
5
+ }
6
+ //# sourceMappingURL=define.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define.js","sourceRoot":"","sources":["../../../src/core/define.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,MAAM,UAAU,MAAM,CAAC,GAAW,EAAE,IAA8B;IAChE,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC;QAAE,cAAc,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AACjE,CAAC","sourcesContent":["/** Defines a custom element once. A second definition of the same tag is a no-op, not an error. */\nexport function define(tag: string, ctor: CustomElementConstructor): void {\n if (!customElements.get(tag)) customElements.define(tag, ctor);\n}\n"]}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * True in the development build, false in the production build.
3
+ * build.js rewrites this file in dist/prod so bundlers drop every dev-only branch.
4
+ */
5
+ export declare const DEV_MODE: boolean;
6
+ //# sourceMappingURL=dev-mode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev-mode.d.ts","sourceRoot":"","sources":["../../../src/core/dev-mode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,OAAc,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * True in the development build, false in the production build.
3
+ * build.js rewrites this file in dist/prod so bundlers drop every dev-only branch.
4
+ */
5
+ export const DEV_MODE = true;
6
+ //# sourceMappingURL=dev-mode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev-mode.js","sourceRoot":"","sources":["../../../src/core/dev-mode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAY,IAAI,CAAC","sourcesContent":["/**\n * True in the development build, false in the production build.\n * build.js rewrites this file in dist/prod so bundlers drop every dev-only branch.\n */\nexport const DEV_MODE: boolean = true;\n"]}
@@ -0,0 +1,3 @@
1
+ /** The shared keyboard focus ring: visible only for keyboard focus, drawn outside the control. */
2
+ export declare const focusRing: import("lit").CSSResult;
3
+ //# sourceMappingURL=focus-ring.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"focus-ring.d.ts","sourceRoot":"","sources":["../../../src/core/focus-ring.ts"],"names":[],"mappings":"AAEA,kGAAkG;AAClG,eAAO,MAAM,SAAS,yBAUrB,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { css } from 'lit';
2
+ /** The shared keyboard focus ring: visible only for keyboard focus, drawn outside the control. */
3
+ export const focusRing = css `
4
+ :focus-visible {
5
+ outline: var(--va-size-focus-ring, 2px) solid var(--va-color-focus, currentColor);
6
+ outline-offset: 2px;
7
+ }
8
+ @media (forced-colors: active) {
9
+ :focus-visible {
10
+ outline-color: Highlight;
11
+ }
12
+ }
13
+ `;
14
+ //# sourceMappingURL=focus-ring.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"focus-ring.js","sourceRoot":"","sources":["../../../src/core/focus-ring.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,kGAAkG;AAClG,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAA;;;;;;;;;;CAU3B,CAAC","sourcesContent":["import { css } from 'lit';\n\n/** The shared keyboard focus ring: visible only for keyboard focus, drawn outside the control. */\nexport const focusRing = css`\n :focus-visible {\n outline: var(--va-size-focus-ring, 2px) solid var(--va-color-focus, currentColor);\n outline-offset: 2px;\n }\n @media (forced-colors: active) {\n :focus-visible {\n outline-color: Highlight;\n }\n }\n`;\n"]}
@@ -0,0 +1,47 @@
1
+ import { LitElement, type PropertyDeclarations } from 'lit';
2
+ /**
3
+ * Base class for Vastu form controls. It joins the control to its `<form>` through
4
+ * ElementInternals, so the control submits, resets, disables and validates like a native one.
5
+ * Subclasses call `setFormValue()` and `setValidity()`; everything else is handled here.
6
+ */
7
+ export declare class FormControl extends LitElement {
8
+ /** @internal */
9
+ static formAssociated: boolean;
10
+ static properties: PropertyDeclarations;
11
+ /** Submitted with the form as `name=value`. */
12
+ name: string;
13
+ /** Disables the control. It can't be focused, changed or submitted. */
14
+ disabled: boolean;
15
+ /** The control must have a value before its form can be submitted. */
16
+ required: boolean;
17
+ /** @internal */
18
+ protected readonly _internals: ElementInternals;
19
+ /** Set while a disabled `<fieldset>` around the control disables it. Kept apart from `disabled`. */
20
+ protected _fieldsetDisabled: boolean;
21
+ constructor();
22
+ /** The form this control belongs to, if any. */
23
+ get form(): HTMLFormElement | null;
24
+ /** The control's validity state, as on native controls. */
25
+ get validity(): ValidityState;
26
+ /** The message the browser shows when the control is invalid, or an empty string. */
27
+ get validationMessage(): string;
28
+ /** Returns true if the control is valid; otherwise fires `invalid` and returns false. */
29
+ checkValidity(): boolean;
30
+ /** Like `checkValidity()`, but also shows the browser's message to the user. */
31
+ reportValidity(): boolean;
32
+ /**
33
+ * @internal Called by the browser when a `<fieldset disabled>` around the control changes.
34
+ * Like a native control, the author's own `disabled` is left alone: re-enabling the fieldset
35
+ * doesn't enable a control the author disabled.
36
+ */
37
+ formDisabledCallback(disabled: boolean): void;
38
+ /** Whether the control is disabled, by its own `disabled` or by a disabled fieldset. */
39
+ protected get _isDisabled(): boolean;
40
+ /** Sets or clears a custom state, for authors' :state(…) selectors. */
41
+ protected _setState(name: string, on: boolean): void;
42
+ /** @internal Called by the browser when the form resets. Subclasses restore their default. */
43
+ formResetCallback(): void;
44
+ /** Fires a bubbling event on the host, as a native control would. */
45
+ protected _emit(type: 'input' | 'change'): void;
46
+ }
47
+ //# sourceMappingURL=form-control.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-control.d.ts","sourceRoot":"","sources":["../../../src/core/form-control.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,oBAAoB,EAAE,MAAM,KAAK,CAAC;AAE5D;;;;GAIG;AACH,qBAAa,WAAY,SAAQ,UAAU;IACzC,gBAAgB;IAChB,MAAM,CAAC,cAAc,UAAQ;IAE7B,OAAgB,UAAU,EAAE,oBAAoB,CAK9C;IAEF,+CAA+C;IACvC,IAAI,EAAE,MAAM,CAAC;IACrB,uEAAuE;IAC/D,QAAQ,EAAE,OAAO,CAAC;IAC1B,sEAAsE;IAC9D,QAAQ,EAAE,OAAO,CAAC;IAE1B,gBAAgB;IAChB,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC;IAEhD,oGAAoG;IACpG,UAAkB,iBAAiB,EAAE,OAAO,CAAC;;IAW7C,gDAAgD;IAChD,IAAI,IAAI,IAAI,eAAe,GAAG,IAAI,CAEjC;IAED,2DAA2D;IAC3D,IAAI,QAAQ,IAAI,aAAa,CAE5B;IAED,qFAAqF;IACrF,IAAI,iBAAiB,IAAI,MAAM,CAE9B;IAED,yFAAyF;IACzF,aAAa,IAAI,OAAO;IAIxB,gFAAgF;IAChF,cAAc,IAAI,OAAO;IAIzB;;;;OAIG;IACH,oBAAoB,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;IAI7C,wFAAwF;IACxF,SAAS,KAAK,WAAW,IAAI,OAAO,CAEnC;IAED,uEAAuE;IACvE,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,GAAG,IAAI;IASpD,8FAA8F;IAC9F,iBAAiB,IAAI,IAAI;IAEzB,qEAAqE;IACrE,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,IAAI;CAGhD"}
@@ -0,0 +1,75 @@
1
+ import { LitElement } from 'lit';
2
+ /**
3
+ * Base class for Vastu form controls. It joins the control to its `<form>` through
4
+ * ElementInternals, so the control submits, resets, disables and validates like a native one.
5
+ * Subclasses call `setFormValue()` and `setValidity()`; everything else is handled here.
6
+ */
7
+ export class FormControl extends LitElement {
8
+ /** @internal */
9
+ static { this.formAssociated = true; }
10
+ static { this.properties = {
11
+ name: {},
12
+ disabled: { type: Boolean, reflect: true },
13
+ required: { type: Boolean, reflect: true },
14
+ _fieldsetDisabled: { state: true },
15
+ }; }
16
+ constructor() {
17
+ super();
18
+ this.name = '';
19
+ this.disabled = false;
20
+ this.required = false;
21
+ this._fieldsetDisabled = false;
22
+ this._internals = this.attachInternals();
23
+ }
24
+ /** The form this control belongs to, if any. */
25
+ get form() {
26
+ return this._internals.form;
27
+ }
28
+ /** The control's validity state, as on native controls. */
29
+ get validity() {
30
+ return this._internals.validity;
31
+ }
32
+ /** The message the browser shows when the control is invalid, or an empty string. */
33
+ get validationMessage() {
34
+ return this._internals.validationMessage;
35
+ }
36
+ /** Returns true if the control is valid; otherwise fires `invalid` and returns false. */
37
+ checkValidity() {
38
+ return this._internals.checkValidity();
39
+ }
40
+ /** Like `checkValidity()`, but also shows the browser's message to the user. */
41
+ reportValidity() {
42
+ return this._internals.reportValidity();
43
+ }
44
+ /**
45
+ * @internal Called by the browser when a `<fieldset disabled>` around the control changes.
46
+ * Like a native control, the author's own `disabled` is left alone: re-enabling the fieldset
47
+ * doesn't enable a control the author disabled.
48
+ */
49
+ formDisabledCallback(disabled) {
50
+ this._fieldsetDisabled = disabled;
51
+ }
52
+ /** Whether the control is disabled, by its own `disabled` or by a disabled fieldset. */
53
+ get _isDisabled() {
54
+ return this.disabled || this._fieldsetDisabled;
55
+ }
56
+ /** Sets or clears a custom state, for authors' :state(…) selectors. */
57
+ _setState(name, on) {
58
+ try {
59
+ if (on)
60
+ this._internals.states.add(name);
61
+ else
62
+ this._internals.states.delete(name);
63
+ }
64
+ catch {
65
+ // Browsers without CustomStateSet: the state is only for authors' styling.
66
+ }
67
+ }
68
+ /** @internal Called by the browser when the form resets. Subclasses restore their default. */
69
+ formResetCallback() { }
70
+ /** Fires a bubbling event on the host, as a native control would. */
71
+ _emit(type) {
72
+ this.dispatchEvent(new Event(type, { bubbles: true, composed: type === 'input' }));
73
+ }
74
+ }
75
+ //# sourceMappingURL=form-control.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-control.js","sourceRoot":"","sources":["../../../src/core/form-control.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA6B,MAAM,KAAK,CAAC;AAE5D;;;;GAIG;AACH,MAAM,OAAO,WAAY,SAAQ,UAAU;IACzC,gBAAgB;aACT,mBAAc,GAAG,IAAI,CAAC;aAEb,eAAU,GAAyB;QACjD,IAAI,EAAE,EAAE;QACR,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;QAC1C,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;QAC1C,iBAAiB,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE;KACnC,CAAC;IAeF;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;QACf,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,IAAI,CAAC,QAAQ,GAAG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CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,KAAK,OAAO,EAAE,CAAC,CAAC,CAAC;IACrF,CAAC","sourcesContent":["import { LitElement, type PropertyDeclarations } from 'lit';\n\n/**\n * Base class for Vastu form controls. It joins the control to its `<form>` through\n * ElementInternals, so the control submits, resets, disables and validates like a native one.\n * Subclasses call `setFormValue()` and `setValidity()`; everything else is handled here.\n */\nexport class FormControl extends LitElement {\n /** @internal */\n static formAssociated = true;\n\n static override properties: PropertyDeclarations = {\n name: {},\n disabled: { type: Boolean, reflect: true },\n required: { type: Boolean, reflect: true },\n _fieldsetDisabled: { state: true },\n };\n\n /** Submitted with the form as `name=value`. */\n declare name: string;\n /** Disables the control. It can't be focused, changed or submitted. */\n declare disabled: boolean;\n /** The control must have a value before its form can be submitted. */\n declare required: boolean;\n\n /** @internal */\n protected readonly _internals: ElementInternals;\n\n /** Set while a disabled `<fieldset>` around the control disables it. Kept apart from `disabled`. */\n declare protected _fieldsetDisabled: boolean;\n\n constructor() {\n super();\n this.name = '';\n this.disabled = false;\n this.required = false;\n this._fieldsetDisabled = false;\n this._internals = this.attachInternals();\n }\n\n /** The form this control belongs to, if any. */\n get form(): HTMLFormElement | null {\n return this._internals.form;\n }\n\n /** The control's validity state, as on native controls. */\n get validity(): ValidityState {\n return this._internals.validity;\n }\n\n /** The message the browser shows when the control is invalid, or an empty string. */\n get validationMessage(): string {\n return this._internals.validationMessage;\n }\n\n /** Returns true if the control is valid; otherwise fires `invalid` and returns false. */\n checkValidity(): boolean {\n return this._internals.checkValidity();\n }\n\n /** Like `checkValidity()`, but also shows the browser's message to the user. */\n reportValidity(): boolean {\n return this._internals.reportValidity();\n }\n\n /**\n * @internal Called by the browser when a `<fieldset disabled>` around the control changes.\n * Like a native control, the author's own `disabled` is left alone: re-enabling the fieldset\n * doesn't enable a control the author disabled.\n */\n formDisabledCallback(disabled: boolean): void {\n this._fieldsetDisabled = disabled;\n }\n\n /** Whether the control is disabled, by its own `disabled` or by a disabled fieldset. */\n protected get _isDisabled(): boolean {\n return this.disabled || this._fieldsetDisabled;\n }\n\n /** Sets or clears a custom state, for authors' :state(…) selectors. */\n protected _setState(name: string, on: boolean): void {\n try {\n if (on) this._internals.states.add(name);\n else this._internals.states.delete(name);\n } catch {\n // Browsers without CustomStateSet: the state is only for authors' styling.\n }\n }\n\n /** @internal Called by the browser when the form resets. Subclasses restore their default. */\n formResetCallback(): void {}\n\n /** Fires a bubbling event on the host, as a native control would. */\n protected _emit(type: 'input' | 'change'): void {\n this.dispatchEvent(new Event(type, { bubbles: true, composed: type === 'input' }));\n }\n}\n"]}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Logs a development-only warning written for people and agents alike:
3
+ * what is wrong, then the exact fix. Each message is shown once per page.
4
+ * Stripped from production builds.
5
+ */
6
+ export declare function devWarn(tag: string, problem: string, fix: string): void;
7
+ /**
8
+ * Warns once per page if no Vastu brand stylesheet is loaded. Waits for the page's load event,
9
+ * so a stylesheet that is still downloading doesn't cause a false warning.
10
+ */
11
+ export declare function checkTokensLoaded(host: HTMLElement): void;
12
+ //# sourceMappingURL=warn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"warn.d.ts","sourceRoot":"","sources":["../../../src/core/warn.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAMvE;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CAezD"}
@@ -0,0 +1,35 @@
1
+ import { DEV_MODE } from './dev-mode.js';
2
+ const shown = new Set();
3
+ /**
4
+ * Logs a development-only warning written for people and agents alike:
5
+ * what is wrong, then the exact fix. Each message is shown once per page.
6
+ * Stripped from production builds.
7
+ */
8
+ export function devWarn(tag, problem, fix) {
9
+ if (!DEV_MODE)
10
+ return;
11
+ const message = `<${tag}>: ${problem} Fix: ${fix} (https://firstprateek.github.io/vastu/components/${tag.replace(/^va-/, '')}/)`;
12
+ if (shown.has(message))
13
+ return;
14
+ shown.add(message);
15
+ console.warn(message);
16
+ }
17
+ /**
18
+ * Warns once per page if no Vastu brand stylesheet is loaded. Waits for the page's load event,
19
+ * so a stylesheet that is still downloading doesn't cause a false warning.
20
+ */
21
+ export function checkTokensLoaded(host) {
22
+ if (!DEV_MODE)
23
+ return;
24
+ if (document.readyState !== 'complete') {
25
+ window.addEventListener('load', () => checkTokensLoaded(host), { once: true });
26
+ return;
27
+ }
28
+ if (!host.isConnected)
29
+ return;
30
+ const value = getComputedStyle(host).getPropertyValue('--va-color-accent-default');
31
+ if (!value.trim()) {
32
+ devWarn(host.localName, 'No Vastu tokens are loaded, so it is unstyled.', 'import "@firstprateek/vastu-tokens/lekha.css" (or add it as a <link rel="stylesheet">) once per page.');
33
+ }
34
+ }
35
+ //# sourceMappingURL=warn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"warn.js","sourceRoot":"","sources":["../../../src/core/warn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;AAEhC;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,GAAW,EAAE,OAAe,EAAE,GAAW;IAC/D,IAAI,CAAC,QAAQ;QAAE,OAAO;IACtB,MAAM,OAAO,GAAG,IAAI,GAAG,MAAM,OAAO,SAAS,GAAG,qDAAqD,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC;IACjI,IAAI,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC;QAAE,OAAO;IAC/B,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACnB,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACxB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAiB;IACjD,IAAI,CAAC,QAAQ;QAAE,OAAO;IACtB,IAAI,QAAQ,CAAC,UAAU,KAAK,UAAU,EAAE,CAAC;QACvC,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/E,OAAO;IACT,CAAC;IACD,IAAI,CAAC,IAAI,CAAC,WAAW;QAAE,OAAO;IAC9B,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC,gBAAgB,CAAC,2BAA2B,CAAC,CAAC;IACnF,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;QAClB,OAAO,CACL,IAAI,CAAC,SAAS,EACd,gDAAgD,EAChD,uGAAuG,CACxG,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import { DEV_MODE } from './dev-mode.js';\n\nconst shown = new Set<string>();\n\n/**\n * Logs a development-only warning written for people and agents alike:\n * what is wrong, then the exact fix. Each message is shown once per page.\n * Stripped from production builds.\n */\nexport function devWarn(tag: string, problem: string, fix: string): void {\n if (!DEV_MODE) return;\n const message = `<${tag}>: ${problem} Fix: ${fix} (https://firstprateek.github.io/vastu/components/${tag.replace(/^va-/, '')}/)`;\n if (shown.has(message)) return;\n shown.add(message);\n console.warn(message);\n}\n\n/**\n * Warns once per page if no Vastu brand stylesheet is loaded. Waits for the page's load event,\n * so a stylesheet that is still downloading doesn't cause a false warning.\n */\nexport function checkTokensLoaded(host: HTMLElement): void {\n if (!DEV_MODE) return;\n if (document.readyState !== 'complete') {\n window.addEventListener('load', () => checkTokensLoaded(host), { once: true });\n return;\n }\n if (!host.isConnected) return;\n const value = getComputedStyle(host).getPropertyValue('--va-color-accent-default');\n if (!value.trim()) {\n devWarn(\n host.localName,\n 'No Vastu tokens are loaded, so it is unstyled.',\n 'import \"@firstprateek/vastu-tokens/lekha.css\" (or add it as a <link rel=\"stylesheet\">) once per page.'\n );\n }\n}\n"]}
@@ -0,0 +1,77 @@
1
+ import { LitElement, type PropertyDeclarations, type PropertyValues } from 'lit';
2
+ /** Why a dialog is closing, in the `va-close` event's `detail.reason`. */
3
+ export type DialogCloseReason = 'escape' | 'close-button' | 'command' | 'method' | 'property';
4
+ /**
5
+ * A modal dialog built on the native `<dialog>`: it sits in the top layer, makes the page behind it
6
+ * inert, keeps focus inside, closes with Escape and returns focus to where it came from.
7
+ *
8
+ * @tag va-dialog
9
+ * @summary Asks the user to confirm, decide or enter something before going back to the page.
10
+ *
11
+ * @slot - The dialog's content.
12
+ * @slot footer - Actions, such as Cancel and Confirm buttons. Put the primary action last.
13
+ *
14
+ * @csspart dialog - The native dialog element.
15
+ * @csspart header - The row with the heading and the close button.
16
+ * @csspart heading - The heading.
17
+ * @csspart close-button - The close button.
18
+ * @csspart body - The wrapper around the content.
19
+ * @csspart footer - The wrapper around the actions.
20
+ *
21
+ * @cssprop {<color>} --va-dialog-bg - Background colour.
22
+ * @cssprop {<length>} --va-dialog-width - Maximum width.
23
+ * @cssprop {<length>} --va-dialog-radius - Corner radius.
24
+ *
25
+ * @cssprop-applies --va-dialog-bg dialog:open background-color
26
+ * @cssprop-applies --va-dialog-width dialog:open max-width
27
+ * @cssprop-applies --va-dialog-radius dialog:open border-top-left-radius
28
+ *
29
+ * @keyboard open: Escape | closes | Closes the dialog and returns focus to the element that opened it.
30
+ *
31
+ * @a11y-role dialog
32
+ * @a11y-name-from heading, accessible-label
33
+ * @replaces dialog
34
+ * @a11y-name The `heading`, or `accessible-label` when there is no visible heading.
35
+ * @a11y-note The page behind is inert while the dialog is open, so focus and screen readers stay inside it.
36
+ * @a11y-note On open, focus goes to the first element with `autofocus`, else the first focusable control in the content, else the close button.
37
+ *
38
+ * @guidance-use For a decision the user must make before going on, such as confirming a deletion, or a short focused task.
39
+ * @guidance-avoid For information that doesn't need a response, or for long, multi-step flows.
40
+ * @guidance-instead `va-toast` for confirmations that need no response; a full page for long flows.
41
+ *
42
+ * @command --show | Opens the dialog.
43
+ * @command --close | Closes the dialog (fires `va-close` first).
44
+ * @fires va-open - After the dialog has opened.
45
+ * @fires {CustomEvent<{ reason: 'escape' | 'close-button' | 'command' | 'method' }>} va-close - Before the dialog closes, when the user or close() asks it to. Cancel it with `preventDefault()` to keep the dialog open.
46
+ * @fires {CustomEvent<{ reason: 'escape' | 'close-button' | 'command' | 'method' | 'property' }>} va-closed - After the dialog has closed, however it closed (`property` when `open` was set to false). Focus is back on the element that opened it.
47
+ * @event-trigger va-open | call show
48
+ * @event-trigger va-close | press Escape | open
49
+ * @event-trigger va-closed | press Escape | open
50
+ */
51
+ export declare class VaDialog extends LitElement {
52
+ #private;
53
+ static properties: PropertyDeclarations;
54
+ /** Whether the dialog is open. Prefer `show()` and `close()`, or `command="--show"` on a `va-button`. */
55
+ open: boolean;
56
+ /** The visible heading. It is also the dialog's accessible name. */
57
+ heading: string;
58
+ /** Accessible name, when there is no visible heading. Not shown. */
59
+ accessibleLabel: string;
60
+ /** Hides the close button in the header, for a dialog that needs an explicit choice. Escape still closes it. */
61
+ hideCloseButton: boolean;
62
+ constructor();
63
+ connectedCallback(): void;
64
+ /** Opens the dialog as a modal. */
65
+ show(): void;
66
+ /** Closes the dialog, unless a `va-close` listener cancels it. */
67
+ close(): void;
68
+ updated(changed: PropertyValues): Promise<void>;
69
+ render(): import("lit").TemplateResult<1>;
70
+ static styles: import("lit").CSSResult[];
71
+ }
72
+ declare global {
73
+ interface HTMLElementTagNameMap {
74
+ 'va-dialog': VaDialog;
75
+ }
76
+ }
77
+ //# sourceMappingURL=dialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../../../src/dialog/dialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,KAAK,oBAAoB,EAAE,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAIrG,0EAA0E;AAC1E,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,cAAc,GAAG,SAAS,GAAG,QAAQ,GAAG,UAAU,CAAC;AAE9F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,qBAAa,QAAS,SAAQ,UAAU;;IACtC,OAAgB,UAAU,EAAE,oBAAoB,CAK9C;IAEF,yGAAyG;IACjG,IAAI,EAAE,OAAO,CAAC;IACtB,oEAAoE;IAC5D,OAAO,EAAE,MAAM,CAAC;IACxB,oEAAoE;IAC5D,eAAe,EAAE,MAAM,CAAC;IAChC,gHAAgH;IACxG,eAAe,EAAE,OAAO,CAAC;;IAexB,iBAAiB,IAAI,IAAI;IASlC,mCAAmC;IACnC,IAAI,IAAI,IAAI;IAIZ,kEAAkE;IAClE,KAAK,IAAI,IAAI;IAqBE,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAkDrD,MAAM;IAuBf,OAAgB,MAAM,4BA2EpB;CACH;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,WAAW,EAAE,QAAQ,CAAC;KACvB;CACF"}