@birdapi/velinstyle 1.2.0 → 1.2.2

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 (89) hide show
  1. package/README.de.md +150 -24
  2. package/README.md +155 -33
  3. package/cli/__fixtures__/atelier-library/showcases/01-login/app.css +1 -0
  4. package/cli/__fixtures__/atelier-library/showcases/01-login/app.js +2 -0
  5. package/cli/__fixtures__/atelier-library/showcases/01-login/index.html +5 -0
  6. package/cli/__fixtures__/atelier-library/showcases/04-pricing/app.css +1 -0
  7. package/cli/__fixtures__/atelier-library/showcases/04-pricing/app.js +2 -0
  8. package/cli/__fixtures__/atelier-library/showcases/04-pricing/index.html +5 -0
  9. package/cli/__fixtures__/atelier-library/showcases/36-calendar/app.css +1 -0
  10. package/cli/__fixtures__/atelier-library/showcases/36-calendar/app.js +2 -0
  11. package/cli/__fixtures__/atelier-library/showcases/36-calendar/index.html +5 -0
  12. package/cli/atelier-catalog.json +1267 -0
  13. package/cli/atelier-formats.js +159 -0
  14. package/cli/atelier.js +382 -0
  15. package/cli/blueprints/empty-state.html +3 -5
  16. package/cli/cli-manifest.json +23 -10
  17. package/cli/docgen/extract-attributes.js +2 -0
  18. package/cli/docgen/extract-cli.js +1 -1
  19. package/cli/index.js +181 -6
  20. package/cli/production/component-graph.json +166 -0
  21. package/cli/production/explain.js +52 -0
  22. package/cli/production/extract.js +238 -0
  23. package/cli/production/graph.js +102 -0
  24. package/cli/production/report.js +78 -0
  25. package/cli/production/run.js +312 -0
  26. package/cli/production/trim-css.js +177 -0
  27. package/cli/production/trim-fonts.js +23 -0
  28. package/cli/production/trim-icons.js +38 -0
  29. package/cli/production/trim-js.js +48 -0
  30. package/cli/production/trim-motion.js +22 -0
  31. package/cli/production/trim-themes.js +50 -0
  32. package/cli/production/watch.js +38 -0
  33. package/cli/review.js +48 -1
  34. package/cli/scripts/write-atelier-fixtures.mjs +33 -0
  35. package/cli/transparency.js +221 -0
  36. package/components/index.js +3 -0
  37. package/components/runtime/component-loaders.js +3 -0
  38. package/components/velin-drawer.js +43 -4
  39. package/components/velin-empty-state.js +83 -0
  40. package/components/velin-modal.js +76 -15
  41. package/components/velin-otp-input.js +220 -0
  42. package/components/velin-password-strength.js +147 -0
  43. package/components/velin-sheet.js +49 -4
  44. package/core/a11y/component-contracts.json +23 -4
  45. package/core/attributes/registry.js +14 -0
  46. package/core/meta/knowledge/components.json +75 -3
  47. package/core/meta/schema.js +10 -0
  48. package/core/transparency/attach.js +74 -0
  49. package/core/transparency/claims.js +97 -0
  50. package/core/transparency/doctor.js +142 -0
  51. package/core/transparency/engine.js +75 -0
  52. package/core/transparency/export.js +98 -0
  53. package/core/transparency/index.js +30 -0
  54. package/core/transparency/migrate.js +130 -0
  55. package/core/transparency/normalize.js +125 -0
  56. package/core/transparency/policy.js +105 -0
  57. package/core/transparency/providers.js +235 -0
  58. package/core/transparency/registry.js +104 -0
  59. package/core/transparency/renderer.js +111 -0
  60. package/core/transparency/reporter.js +113 -0
  61. package/core/transparency/validator.js +112 -0
  62. package/dist/chunks/attach-H2ZSEAE6.js +365 -0
  63. package/dist/chunks/attributes-2ORR27KA.js +404 -0
  64. package/dist/chunks/attributes-DZCXX2RZ.js +404 -0
  65. package/dist/chunks/chunk-CQMTCEI6.js +113 -0
  66. package/dist/chunks/chunk-Y6HN7HWX.js +116 -0
  67. package/dist/chunks/runtime-entry.js +1 -1
  68. package/dist/chunks/velin-drawer-A7Q7EBOS.js +162 -0
  69. package/dist/chunks/velin-empty-state-3NTUH2RF.js +81 -0
  70. package/dist/chunks/velin-modal-3MV4FYBK.js +231 -0
  71. package/dist/chunks/velin-otp-input-PSK42MM6.js +207 -0
  72. package/dist/chunks/velin-password-strength-TAXMLSED.js +136 -0
  73. package/dist/chunks/velin-sheet-N2VVYXFP.js +157 -0
  74. package/dist/llms.txt +5 -4
  75. package/dist/search-index.json +94 -5
  76. package/dist/velin-agent.json +290 -23
  77. package/dist/velinstyle-components.iife.js +3189 -2202
  78. package/dist/velinstyle-components.js +3187 -2196
  79. package/dist/velinstyle-components.min.js +261 -119
  80. package/dist/velinstyle.css +214 -6
  81. package/dist/velinstyle.d.ts +3 -0
  82. package/dist/velinstyle.min.css +1 -1
  83. package/package.json +143 -142
  84. package/packages/velinstyle-skills/catalog.json +1 -1
  85. package/src/components/data-table.css +19 -0
  86. package/src/components/empty-auth.css +33 -0
  87. package/src/components/table.css +16 -6
  88. package/src/components/transparency.css +138 -0
  89. package/src/velinstyle.css +2 -0
@@ -0,0 +1,162 @@
1
+ import {
2
+ clearBackgroundInert,
3
+ getFocusableElements,
4
+ restoreFocus,
5
+ saveFocus,
6
+ setBackgroundInert,
7
+ trapFocus
8
+ } from "./chunk-42VVPW6N.js";
9
+ import "./chunk-L7ZGUU4D.js";
10
+
11
+ // components/velin-drawer.js
12
+ var styles = `
13
+ :host { display: contents; }
14
+ .overlay {
15
+ position: fixed;
16
+ inset: 0;
17
+ z-index: var(--velin-z-overlay, 400);
18
+ background: var(--velin-color-overlay, rgba(0,0,0,0.4));
19
+ opacity: 0;
20
+ visibility: hidden;
21
+ transition: opacity 200ms ease, visibility 200ms ease;
22
+ }
23
+ :host([open]) .overlay { opacity: 1; visibility: visible; }
24
+ .drawer {
25
+ position: fixed;
26
+ z-index: var(--velin-z-modal, 500);
27
+ background: var(--velin-color-surface-bright, #fff);
28
+ box-shadow: var(--velin-shadow-xl, 0 20px 25px rgba(0,0,0,0.1));
29
+ display: flex;
30
+ flex-direction: column;
31
+ transition: transform 250ms ease;
32
+ overflow: hidden;
33
+ }
34
+ /* Side positioning -- default = start */
35
+ .drawer { inset-block: 0; inset-inline-start: 0; inset-inline-end: auto; inline-size: min(20rem, 85vw); transform: translateX(-100%); }
36
+ :host([open]) .drawer, :host([open][side="start"]) .drawer { transform: translateX(0); }
37
+ :host([side="end"]) .drawer { inset-inline-start: auto; inset-inline-end: 0; transform: translateX(100%); }
38
+ :host([open][side="end"]) .drawer { transform: translateX(0); }
39
+ :host([side="top"]) .drawer { inset-inline: 0; inset-inline-start: 0; inset-block-start: 0; inset-block-end: auto; block-size: min(50vh, 24rem); inline-size: 100%; transform: translateY(-100%); }
40
+ :host([open][side="top"]) .drawer { transform: translateY(0); }
41
+ :host([side="bottom"]) .drawer { inset-inline: 0; inset-inline-start: 0; inset-block-start: auto; inset-block-end: 0; block-size: min(50vh, 24rem); inline-size: 100%; transform: translateY(100%); }
42
+ :host([open][side="bottom"]) .drawer { transform: translateY(0); }
43
+ .header {
44
+ display: flex; align-items: center; justify-content: space-between;
45
+ padding: var(--velin-space-4, 1rem) var(--velin-space-5, 1.25rem);
46
+ border-bottom: 1px solid var(--velin-color-border, #ddd);
47
+ }
48
+ .title { font-size: var(--velin-text-lg, 1.25rem); font-weight: var(--velin-weight-semibold, 600); margin: 0; }
49
+ .close-btn {
50
+ min-width: 2.75rem; min-height: 2.75rem; display: inline-flex; align-items: center; justify-content: center;
51
+ background: none; border: none; border-radius: var(--velin-radius-md, 0.5rem); cursor: pointer;
52
+ color: var(--velin-color-text-muted, #666); font-size: 1.5rem; line-height: 1;
53
+ }
54
+ .close-btn:hover { background: var(--velin-color-surface-dim, #eee); color: var(--velin-color-text, #111); }
55
+ .body { flex: 1; padding: var(--velin-space-5, 1.25rem); overflow-y: auto; }
56
+ @media (prefers-reduced-motion: reduce) { .overlay, .drawer { transition: none; } }
57
+ `;
58
+ var VelinDrawer = class extends HTMLElement {
59
+ static get observedAttributes() {
60
+ return ["open", "title"];
61
+ }
62
+ constructor() {
63
+ super();
64
+ this.attachShadow({ mode: "open", delegatesFocus: true });
65
+ this._prev = null;
66
+ this._onKey = this._onKey.bind(this);
67
+ this._onTitleSlot = this._onTitleSlot.bind(this);
68
+ }
69
+ connectedCallback() {
70
+ if (this.shadowRoot.querySelector(".drawer")) return;
71
+ const titleId = "velin-drawer-title";
72
+ this.shadowRoot.innerHTML = `
73
+ <style>${styles}</style>
74
+ <div class="overlay" part="overlay"></div>
75
+ <div class="drawer" role="dialog" aria-modal="true" aria-labelledby="${titleId}" part="drawer">
76
+ <div class="header" part="header">
77
+ <h2 class="title" id="${titleId}" part="title">
78
+ <slot name="title"></slot>
79
+ <span class="title-fallback"></span>
80
+ </h2>
81
+ <button class="close-btn" aria-label="Close" part="close">&#215;</button>
82
+ </div>
83
+ <div class="body" part="body"><slot></slot></div>
84
+ </div>
85
+ `;
86
+ this.shadowRoot.querySelector(".close-btn").addEventListener("click", () => this.close());
87
+ this.shadowRoot.querySelector(".overlay").addEventListener("click", () => this.close());
88
+ this.shadowRoot.querySelector('slot[name="title"]').addEventListener("slotchange", this._onTitleSlot);
89
+ this._syncTitle();
90
+ }
91
+ attributeChangedCallback(name) {
92
+ if (name === "open") this.hasAttribute("open") ? this._open() : this._close();
93
+ if (name === "title") this._syncTitle();
94
+ }
95
+ open() {
96
+ this.setAttribute("open", "");
97
+ }
98
+ close() {
99
+ this.removeAttribute("open");
100
+ this.dispatchEvent(new CustomEvent("velin-close", { bubbles: true }));
101
+ }
102
+ _syncTitle() {
103
+ const fallback = this.shadowRoot?.querySelector(".title-fallback");
104
+ if (!fallback) return;
105
+ fallback.textContent = this.getAttribute("title") || "";
106
+ }
107
+ _hasTitleSlot() {
108
+ const slot = this.shadowRoot?.querySelector('slot[name="title"]');
109
+ if (!slot) return false;
110
+ return slot.assignedNodes({ flatten: true }).some((n) => {
111
+ if (n.nodeType === Node.TEXT_NODE) return Boolean(n.textContent.trim());
112
+ return n.nodeType === Node.ELEMENT_NODE;
113
+ });
114
+ }
115
+ _onTitleSlot() {
116
+ const dialog = this.shadowRoot?.querySelector('[role="dialog"]');
117
+ const fallback = this.shadowRoot?.querySelector(".title-fallback");
118
+ if (!dialog || !fallback) return;
119
+ if (this._hasTitleSlot()) {
120
+ fallback.hidden = true;
121
+ dialog.removeAttribute("aria-labelledby");
122
+ const slot = this.shadowRoot.querySelector('slot[name="title"]');
123
+ const label = slot.assignedNodes({ flatten: true }).map((n) => n.textContent || "").join(" ").trim();
124
+ if (label) dialog.setAttribute("aria-label", label);
125
+ } else {
126
+ fallback.hidden = false;
127
+ dialog.removeAttribute("aria-label");
128
+ dialog.setAttribute("aria-labelledby", "velin-drawer-title");
129
+ this._syncTitle();
130
+ }
131
+ }
132
+ _open() {
133
+ this._prev = saveFocus();
134
+ setBackgroundInert(this);
135
+ document.addEventListener("keydown", this._onKey);
136
+ requestAnimationFrame(() => {
137
+ const f = getFocusableElements(this.shadowRoot);
138
+ if (f.length) f[0].focus();
139
+ });
140
+ }
141
+ _close() {
142
+ document.removeEventListener("keydown", this._onKey);
143
+ clearBackgroundInert(this);
144
+ restoreFocus(this._prev);
145
+ }
146
+ _onKey(e) {
147
+ if (e.key === "Escape") {
148
+ this.close();
149
+ return;
150
+ }
151
+ trapFocus(this.shadowRoot, e);
152
+ }
153
+ disconnectedCallback() {
154
+ document.removeEventListener("keydown", this._onKey);
155
+ clearBackgroundInert(this);
156
+ }
157
+ };
158
+ customElements.define("velin-drawer", VelinDrawer);
159
+ var velin_drawer_default = VelinDrawer;
160
+ export {
161
+ velin_drawer_default as default
162
+ };
@@ -0,0 +1,81 @@
1
+ // components/velin-empty-state.js
2
+ var styles = `
3
+ :host {
4
+ display: block;
5
+ text-align: center;
6
+ padding: var(--velin-space-8, 2rem) var(--velin-space-4, 1rem);
7
+ }
8
+ .illustration {
9
+ display: flex;
10
+ justify-content: center;
11
+ margin-block-end: var(--velin-space-4, 1rem);
12
+ color: var(--velin-color-text-muted, #666);
13
+ }
14
+ .title {
15
+ margin: 0 0 var(--velin-space-2, 0.5rem);
16
+ font-size: var(--velin-text-xl, 1.25rem);
17
+ font-weight: var(--velin-weight-bold, 700);
18
+ color: var(--velin-color-text, #111);
19
+ }
20
+ .description {
21
+ margin: 0 0 var(--velin-space-4, 1rem);
22
+ color: var(--velin-color-text-muted, #666);
23
+ max-inline-size: 36rem;
24
+ margin-inline: auto;
25
+ }
26
+ .actions {
27
+ display: flex;
28
+ flex-wrap: wrap;
29
+ gap: var(--velin-space-3, 0.75rem);
30
+ justify-content: center;
31
+ }
32
+ `;
33
+ var VelinEmptyState = class extends HTMLElement {
34
+ static get observedAttributes() {
35
+ return ["heading", "description"];
36
+ }
37
+ constructor() {
38
+ super();
39
+ this.attachShadow({ mode: "open" });
40
+ }
41
+ connectedCallback() {
42
+ if (this.shadowRoot.querySelector(".root")) {
43
+ this._syncText();
44
+ return;
45
+ }
46
+ const titleId = "velin-empty-title";
47
+ this.shadowRoot.innerHTML = `
48
+ <style>${styles}</style>
49
+ <section class="root" part="root" role="status" aria-labelledby="${titleId}">
50
+ <div class="illustration" part="illustration"><slot name="illustration"></slot></div>
51
+ <h2 class="title" id="${titleId}" part="title">
52
+ <slot name="title"><span class="heading-fallback"></span></slot>
53
+ </h2>
54
+ <div class="description" part="description">
55
+ <slot name="description"><span class="description-fallback"></span></slot>
56
+ </div>
57
+ <div class="actions" part="actions"><slot name="actions"></slot></div>
58
+ <slot></slot>
59
+ </section>
60
+ `;
61
+ this._syncText();
62
+ }
63
+ attributeChangedCallback() {
64
+ this._syncText();
65
+ }
66
+ _syncText() {
67
+ const heading = this.shadowRoot?.querySelector(".heading-fallback");
68
+ const description = this.shadowRoot?.querySelector(".description-fallback");
69
+ if (heading) heading.textContent = this.getAttribute("heading") || "Nothing here yet";
70
+ if (description) {
71
+ const text = this.getAttribute("description") || "";
72
+ description.textContent = text;
73
+ description.hidden = !text;
74
+ }
75
+ }
76
+ };
77
+ customElements.define("velin-empty-state", VelinEmptyState);
78
+ var velin_empty_state_default = VelinEmptyState;
79
+ export {
80
+ velin_empty_state_default as default
81
+ };
@@ -0,0 +1,231 @@
1
+ import {
2
+ clearBackgroundInert,
3
+ getFocusableElements,
4
+ restoreFocus,
5
+ saveFocus,
6
+ setBackgroundInert,
7
+ trapFocus
8
+ } from "./chunk-42VVPW6N.js";
9
+
10
+ // components/velin-modal.js
11
+ var styles = `
12
+ :host {
13
+ display: contents;
14
+ }
15
+ .sr-only {
16
+ position: absolute;
17
+ inline-size: 1px;
18
+ block-size: 1px;
19
+ padding: 0;
20
+ margin: -1px;
21
+ overflow: hidden;
22
+ clip: rect(0, 0, 0, 0);
23
+ white-space: nowrap;
24
+ border: 0;
25
+ }
26
+ .overlay {
27
+ position: fixed;
28
+ inset: 0;
29
+ z-index: var(--velin-z-modal, 500);
30
+ display: flex;
31
+ align-items: center;
32
+ justify-content: center;
33
+ padding: var(--velin-space-4, 1rem);
34
+ background: var(--velin-color-overlay, rgba(0,0,0,0.4));
35
+ opacity: 0;
36
+ visibility: hidden;
37
+ transition: opacity 200ms ease, visibility 200ms ease;
38
+ }
39
+ :host([open]) .overlay {
40
+ opacity: 1;
41
+ visibility: visible;
42
+ }
43
+ .dialog {
44
+ position: relative;
45
+ inline-size: min(90vw, 32rem);
46
+ max-block-size: 85vh;
47
+ background: var(--velin-color-surface-bright, #fff);
48
+ border-radius: var(--velin-radius-lg, 0.75rem);
49
+ box-shadow: var(--velin-shadow-xl, 0 20px 25px rgba(0,0,0,0.1));
50
+ overflow: hidden;
51
+ display: flex;
52
+ flex-direction: column;
53
+ transform: scale(0.95) translateY(1rem);
54
+ transition: transform 200ms ease;
55
+ }
56
+ :host([open]) .dialog {
57
+ transform: scale(1) translateY(0);
58
+ }
59
+ .header {
60
+ display: flex;
61
+ align-items: center;
62
+ justify-content: space-between;
63
+ padding: var(--velin-space-4, 1rem) var(--velin-space-6, 1.5rem);
64
+ border-bottom: 1px solid var(--velin-color-border, #ddd);
65
+ }
66
+ .title {
67
+ font-size: var(--velin-text-lg, 1.25rem);
68
+ font-weight: var(--velin-weight-semibold, 600);
69
+ margin: 0;
70
+ }
71
+ .close-btn {
72
+ min-width: 2.75rem;
73
+ min-height: 2.75rem;
74
+ display: inline-flex;
75
+ align-items: center;
76
+ justify-content: center;
77
+ background: none;
78
+ border: none;
79
+ border-radius: var(--velin-radius-md, 0.5rem);
80
+ cursor: pointer;
81
+ color: var(--velin-color-text-muted, #666);
82
+ font-size: 1.5rem;
83
+ line-height: 1;
84
+ }
85
+ .close-btn:hover {
86
+ background: var(--velin-color-surface-dim, #eee);
87
+ color: var(--velin-color-text, #111);
88
+ }
89
+ .body {
90
+ padding: var(--velin-space-6, 1.5rem);
91
+ overflow-y: auto;
92
+ flex-grow: 1;
93
+ }
94
+ .footer {
95
+ display: flex;
96
+ justify-content: flex-end;
97
+ gap: var(--velin-space-3, 0.75rem);
98
+ padding: var(--velin-space-4, 1rem) var(--velin-space-6, 1.5rem);
99
+ border-top: 1px solid var(--velin-color-border, #ddd);
100
+ }
101
+ @media (prefers-reduced-motion: reduce) {
102
+ .overlay, .dialog { transition: none; }
103
+ }
104
+ `;
105
+ var VelinModal = class extends HTMLElement {
106
+ static get observedAttributes() {
107
+ return ["open", "title"];
108
+ }
109
+ constructor() {
110
+ super();
111
+ this.attachShadow({ mode: "open", delegatesFocus: true });
112
+ this._previouslyFocused = null;
113
+ this._onKeydown = this._onKeydown.bind(this);
114
+ this._onTitleSlot = this._onTitleSlot.bind(this);
115
+ }
116
+ connectedCallback() {
117
+ if (this.shadowRoot.querySelector(".dialog")) return;
118
+ this.shadowRoot.innerHTML = `
119
+ <style>${styles}</style>
120
+ <div class="overlay" part="overlay">
121
+ <div class="dialog" role="dialog" aria-modal="true" part="dialog">
122
+ <div class="header" part="header">
123
+ <h2 class="title" id="velin-modal-title" part="title">
124
+ <slot name="title"></slot>
125
+ <span class="title-fallback"></span>
126
+ </h2>
127
+ <button class="close-btn" aria-label="Close" part="close">&#215;</button>
128
+ </div>
129
+ <div class="body" part="body"><slot></slot></div>
130
+ <div class="footer" part="footer"><slot name="footer"></slot></div>
131
+ </div>
132
+ </div>
133
+ `;
134
+ this.shadowRoot.querySelector(".close-btn").addEventListener("click", () => this.close());
135
+ this.shadowRoot.querySelector(".overlay").addEventListener("click", (e) => {
136
+ if (e.target === e.currentTarget) this.close();
137
+ });
138
+ this.shadowRoot.querySelector('slot[name="title"]').addEventListener("slotchange", this._onTitleSlot);
139
+ this._syncTitle();
140
+ }
141
+ attributeChangedCallback(name) {
142
+ if (name === "open") {
143
+ if (this.hasAttribute("open")) this._open();
144
+ else this._close();
145
+ }
146
+ if (name === "title") this._syncTitle();
147
+ }
148
+ open() {
149
+ this.setAttribute("open", "");
150
+ }
151
+ close() {
152
+ this.removeAttribute("open");
153
+ this.dispatchEvent(new CustomEvent("velin-close", { bubbles: true }));
154
+ }
155
+ _syncTitle() {
156
+ const fallback = this.shadowRoot?.querySelector(".title-fallback");
157
+ const heading = this.shadowRoot?.querySelector(".title");
158
+ const dialog = this.shadowRoot?.querySelector('[role="dialog"]');
159
+ if (!fallback || !heading || !dialog) return;
160
+ if (this._hasTitleSlot()) {
161
+ fallback.hidden = true;
162
+ heading.classList.remove("sr-only");
163
+ return;
164
+ }
165
+ fallback.hidden = false;
166
+ const title = (this.getAttribute("title") || "").trim();
167
+ fallback.textContent = title || "Dialog";
168
+ heading.classList.toggle("sr-only", !title);
169
+ if (title) {
170
+ dialog.setAttribute("aria-labelledby", "velin-modal-title");
171
+ dialog.removeAttribute("aria-label");
172
+ } else {
173
+ dialog.removeAttribute("aria-labelledby");
174
+ dialog.setAttribute("aria-label", this.getAttribute("aria-label") || "Dialog");
175
+ }
176
+ }
177
+ _hasTitleSlot() {
178
+ const slot = this.shadowRoot?.querySelector('slot[name="title"]');
179
+ if (!slot) return false;
180
+ return slot.assignedNodes({ flatten: true }).some((n) => {
181
+ if (n.nodeType === Node.TEXT_NODE) return Boolean(n.textContent.trim());
182
+ return n.nodeType === Node.ELEMENT_NODE;
183
+ });
184
+ }
185
+ _onTitleSlot() {
186
+ const slot = this.shadowRoot?.querySelector('slot[name="title"]');
187
+ const dialog = this.shadowRoot?.querySelector('[role="dialog"]');
188
+ const heading = this.shadowRoot?.querySelector(".title");
189
+ const fallback = this.shadowRoot?.querySelector(".title-fallback");
190
+ if (!slot || !dialog || !heading || !fallback) return;
191
+ if (this._hasTitleSlot()) {
192
+ fallback.hidden = true;
193
+ heading.classList.remove("sr-only");
194
+ dialog.removeAttribute("aria-labelledby");
195
+ const label = slot.assignedNodes({ flatten: true }).map((n) => n.textContent || "").join(" ").trim();
196
+ if (label) dialog.setAttribute("aria-label", label);
197
+ } else {
198
+ this._syncTitle();
199
+ }
200
+ }
201
+ _open() {
202
+ this._previouslyFocused = saveFocus();
203
+ setBackgroundInert(this);
204
+ document.addEventListener("keydown", this._onKeydown);
205
+ requestAnimationFrame(() => {
206
+ const focusable = getFocusableElements(this.shadowRoot);
207
+ if (focusable.length > 0) focusable[0].focus();
208
+ });
209
+ }
210
+ _close() {
211
+ document.removeEventListener("keydown", this._onKeydown);
212
+ clearBackgroundInert(this);
213
+ restoreFocus(this._previouslyFocused);
214
+ }
215
+ _onKeydown(event) {
216
+ if (event.key === "Escape") {
217
+ this.close();
218
+ return;
219
+ }
220
+ trapFocus(this.shadowRoot, event);
221
+ }
222
+ disconnectedCallback() {
223
+ document.removeEventListener("keydown", this._onKeydown);
224
+ clearBackgroundInert(this);
225
+ }
226
+ };
227
+ customElements.define("velin-modal", VelinModal);
228
+ var velin_modal_default = VelinModal;
229
+ export {
230
+ velin_modal_default as default
231
+ };
@@ -0,0 +1,207 @@
1
+ import {
2
+ SHADOW_A11Y_STYLES
3
+ } from "./chunk-F7OLHTGX.js";
4
+ import {
5
+ escapeHTML
6
+ } from "./chunk-L7ZGUU4D.js";
7
+
8
+ // components/velin-otp-input.js
9
+ var styles = `
10
+ ${SHADOW_A11Y_STYLES}
11
+ :host { display: block; }
12
+ .group {
13
+ display: inline-flex;
14
+ flex-wrap: wrap;
15
+ gap: var(--velin-space-2, 0.5rem);
16
+ }
17
+ input {
18
+ inline-size: 2.75rem;
19
+ block-size: 2.75rem;
20
+ text-align: center;
21
+ font: inherit;
22
+ font-size: var(--velin-text-lg, 1.25rem);
23
+ font-weight: var(--velin-weight-semibold, 600);
24
+ color: var(--velin-color-text, #111);
25
+ background: var(--velin-color-surface-bright, #fff);
26
+ border: 1px solid var(--velin-color-border, #ddd);
27
+ border-radius: var(--velin-radius-md, 0.5rem);
28
+ padding: 0;
29
+ }
30
+ input:focus-visible {
31
+ outline: 3px solid var(--velin-color-focus, #2563eb);
32
+ outline-offset: 2px;
33
+ }
34
+ input:disabled {
35
+ opacity: 0.55;
36
+ cursor: not-allowed;
37
+ }
38
+ @media (forced-colors: active) {
39
+ input { border: 1px solid ButtonText; }
40
+ }
41
+ `;
42
+ function digitsOnly(value) {
43
+ return String(value || "").replace(/\D/g, "");
44
+ }
45
+ var VelinOtpInput = class extends HTMLElement {
46
+ static get observedAttributes() {
47
+ return ["length", "value", "disabled", "name", "autocomplete", "label"];
48
+ }
49
+ constructor() {
50
+ super();
51
+ this.attachShadow({ mode: "open" });
52
+ this._onInput = this._onInput.bind(this);
53
+ this._onKeydown = this._onKeydown.bind(this);
54
+ this._onPaste = this._onPaste.bind(this);
55
+ this._onFocus = this._onFocus.bind(this);
56
+ }
57
+ connectedCallback() {
58
+ if (!this.shadowRoot.querySelector(".group")) this._render();
59
+ }
60
+ attributeChangedCallback(name, oldVal, newVal) {
61
+ if (oldVal === newVal) return;
62
+ if (!this.shadowRoot.querySelector(".group")) return;
63
+ if (name === "length") this._render();
64
+ else if (name === "value") this._applyValue(this.getAttribute("value") || "", false);
65
+ else if (name === "disabled") this._syncDisabled();
66
+ else if (name === "label" || name === "autocomplete" || name === "name") this._syncMeta();
67
+ }
68
+ get value() {
69
+ return this._readValue();
70
+ }
71
+ set value(v) {
72
+ this.setAttribute("value", digitsOnly(v).slice(0, this._length()));
73
+ }
74
+ focus() {
75
+ const inputs = this._inputs();
76
+ const firstEmpty = inputs.find((i) => !i.value) || inputs[0];
77
+ firstEmpty?.focus();
78
+ }
79
+ _length() {
80
+ const n = parseInt(this.getAttribute("length") || "6", 10);
81
+ return Number.isFinite(n) && n > 0 ? Math.min(n, 12) : 6;
82
+ }
83
+ _inputs() {
84
+ return [...this.shadowRoot?.querySelectorAll("input") || []];
85
+ }
86
+ _readValue() {
87
+ return this._inputs().map((i) => i.value).join("");
88
+ }
89
+ _render() {
90
+ const len = this._length();
91
+ const label = escapeHTML(this.getAttribute("label") || "One-time password");
92
+ this.shadowRoot.innerHTML = `
93
+ <style>${styles}</style>
94
+ <div class="group" role="group" aria-label="${label}" part="group"></div>
95
+ `;
96
+ const group = this.shadowRoot.querySelector(".group");
97
+ for (let i = 0; i < len; i++) {
98
+ const input = document.createElement("input");
99
+ input.type = "text";
100
+ input.inputMode = "numeric";
101
+ input.pattern = "[0-9]*";
102
+ input.maxLength = 1;
103
+ input.setAttribute("aria-label", `Digit ${i + 1} of ${len}`);
104
+ input.dataset.index = String(i);
105
+ input.part = "digit";
106
+ input.addEventListener("input", this._onInput);
107
+ input.addEventListener("keydown", this._onKeydown);
108
+ input.addEventListener("paste", this._onPaste);
109
+ input.addEventListener("focus", this._onFocus);
110
+ group.appendChild(input);
111
+ }
112
+ this._syncMeta();
113
+ this._syncDisabled();
114
+ this._applyValue(this.getAttribute("value") || "", false);
115
+ }
116
+ _syncMeta() {
117
+ const group = this.shadowRoot?.querySelector(".group");
118
+ if (!group) return;
119
+ group.setAttribute("aria-label", this.getAttribute("label") || "One-time password");
120
+ const autocomplete = this.getAttribute("autocomplete") || "one-time-code";
121
+ const name = this.getAttribute("name") || "";
122
+ this._inputs().forEach((input, i) => {
123
+ input.autocomplete = i === 0 ? autocomplete : "off";
124
+ input.name = name ? `${name}-${i + 1}` : "";
125
+ });
126
+ }
127
+ _syncDisabled() {
128
+ const disabled = this.hasAttribute("disabled");
129
+ this._inputs().forEach((input) => {
130
+ input.disabled = disabled;
131
+ });
132
+ }
133
+ _applyValue(raw, emit) {
134
+ const digits = digitsOnly(raw).slice(0, this._length()).split("");
135
+ const inputs = this._inputs();
136
+ inputs.forEach((input, i) => {
137
+ input.value = digits[i] || "";
138
+ });
139
+ if (emit) this._emit();
140
+ }
141
+ _emit() {
142
+ const value = this._readValue();
143
+ if (this.getAttribute("value") !== value) {
144
+ this.setAttribute("value", value);
145
+ }
146
+ this.dispatchEvent(new CustomEvent("velin-change", {
147
+ bubbles: true,
148
+ composed: true,
149
+ detail: { value }
150
+ }));
151
+ if (value.length === this._length()) {
152
+ this.dispatchEvent(new CustomEvent("velin-complete", {
153
+ bubbles: true,
154
+ composed: true,
155
+ detail: { value }
156
+ }));
157
+ }
158
+ }
159
+ _onInput(e) {
160
+ const input = e.target;
161
+ const cleaned = digitsOnly(input.value).slice(-1);
162
+ input.value = cleaned;
163
+ const index = Number(input.dataset.index);
164
+ const inputs = this._inputs();
165
+ if (cleaned && index < inputs.length - 1) inputs[index + 1].focus();
166
+ this._emit();
167
+ }
168
+ _onKeydown(e) {
169
+ const input = e.target;
170
+ const index = Number(input.dataset.index);
171
+ const inputs = this._inputs();
172
+ if (e.key === "Backspace" && !input.value && index > 0) {
173
+ inputs[index - 1].focus();
174
+ inputs[index - 1].value = "";
175
+ this._emit();
176
+ e.preventDefault();
177
+ } else if (e.key === "ArrowLeft" && index > 0) {
178
+ inputs[index - 1].focus();
179
+ e.preventDefault();
180
+ } else if (e.key === "ArrowRight" && index < inputs.length - 1) {
181
+ inputs[index + 1].focus();
182
+ e.preventDefault();
183
+ }
184
+ }
185
+ _onPaste(e) {
186
+ e.preventDefault();
187
+ const text = digitsOnly(e.clipboardData?.getData("text") || "");
188
+ if (!text) return;
189
+ const index = Number(e.target.dataset.index);
190
+ const inputs = this._inputs();
191
+ const chars = text.split("");
192
+ for (let i = 0; i < chars.length && index + i < inputs.length; i++) {
193
+ inputs[index + i].value = chars[i];
194
+ }
195
+ const next = Math.min(index + chars.length, inputs.length - 1);
196
+ inputs[next]?.focus();
197
+ this._emit();
198
+ }
199
+ _onFocus(e) {
200
+ e.target.select?.();
201
+ }
202
+ };
203
+ customElements.define("velin-otp-input", VelinOtpInput);
204
+ var velin_otp_input_default = VelinOtpInput;
205
+ export {
206
+ velin_otp_input_default as default
207
+ };