@birdapi/velinstyle 1.2.1 → 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 (67) hide show
  1. package/README.de.md +134 -11
  2. package/README.md +139 -16
  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-cli.js +1 -1
  18. package/cli/index.js +149 -3
  19. package/cli/production/component-graph.json +166 -0
  20. package/cli/production/explain.js +52 -0
  21. package/cli/production/extract.js +238 -0
  22. package/cli/production/graph.js +102 -0
  23. package/cli/production/report.js +78 -0
  24. package/cli/production/run.js +312 -0
  25. package/cli/production/trim-css.js +177 -0
  26. package/cli/production/trim-fonts.js +23 -0
  27. package/cli/production/trim-icons.js +38 -0
  28. package/cli/production/trim-js.js +48 -0
  29. package/cli/production/trim-motion.js +22 -0
  30. package/cli/production/trim-themes.js +50 -0
  31. package/cli/production/watch.js +38 -0
  32. package/cli/review.js +48 -1
  33. package/cli/scripts/write-atelier-fixtures.mjs +33 -0
  34. package/components/index.js +3 -0
  35. package/components/runtime/component-loaders.js +3 -0
  36. package/components/velin-drawer.js +43 -4
  37. package/components/velin-empty-state.js +83 -0
  38. package/components/velin-modal.js +76 -15
  39. package/components/velin-otp-input.js +220 -0
  40. package/components/velin-password-strength.js +147 -0
  41. package/components/velin-sheet.js +49 -4
  42. package/core/a11y/component-contracts.json +23 -4
  43. package/core/meta/knowledge/components.json +75 -3
  44. package/dist/chunks/attributes-2ORR27KA.js +404 -0
  45. package/dist/chunks/chunk-Y6HN7HWX.js +116 -0
  46. package/dist/chunks/runtime-entry.js +1 -1
  47. package/dist/chunks/velin-drawer-A7Q7EBOS.js +162 -0
  48. package/dist/chunks/velin-empty-state-3NTUH2RF.js +81 -0
  49. package/dist/chunks/velin-modal-3MV4FYBK.js +231 -0
  50. package/dist/chunks/velin-otp-input-PSK42MM6.js +207 -0
  51. package/dist/chunks/velin-password-strength-TAXMLSED.js +136 -0
  52. package/dist/chunks/velin-sheet-N2VVYXFP.js +157 -0
  53. package/dist/llms.txt +3 -3
  54. package/dist/search-index.json +68 -5
  55. package/dist/velin-agent.json +283 -20
  56. package/dist/velinstyle-components.iife.js +2716 -2138
  57. package/dist/velinstyle-components.js +2772 -2190
  58. package/dist/velinstyle-components.min.js +254 -112
  59. package/dist/velinstyle.css +54 -6
  60. package/dist/velinstyle.d.ts +3 -0
  61. package/dist/velinstyle.min.css +1 -1
  62. package/package.json +143 -143
  63. package/packages/velinstyle-skills/catalog.json +1 -1
  64. package/src/components/data-table.css +19 -0
  65. package/src/components/empty-auth.css +33 -0
  66. package/src/components/table.css +16 -6
  67. package/src/velinstyle.css +1 -0
@@ -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
+ };
@@ -0,0 +1,136 @@
1
+ import {
2
+ SHADOW_A11Y_STYLES
3
+ } from "./chunk-F7OLHTGX.js";
4
+
5
+ // components/velin-password-strength.js
6
+ function scorePassword(pw) {
7
+ const value = String(pw || "");
8
+ let score = 0;
9
+ if (value.length >= 8) score += 1;
10
+ if (value.length >= 12) score += 1;
11
+ if (/[A-Z]/.test(value) && /[a-z]/.test(value)) score += 1;
12
+ if (/\d/.test(value)) score += 1;
13
+ if (/[^A-Za-z0-9]/.test(value)) score += 1;
14
+ const labels = ["Too weak", "Weak", "Okay", "Strong", "Excellent", "Excellent"];
15
+ return {
16
+ score,
17
+ label: labels[score] || "Too weak",
18
+ pct: Math.min(100, score * 20)
19
+ };
20
+ }
21
+ var styles = `
22
+ ${SHADOW_A11Y_STYLES}
23
+ :host { display: block; }
24
+ .wrap { display: grid; gap: var(--velin-space-2, 0.5rem); }
25
+ .meter {
26
+ inline-size: 100%;
27
+ block-size: 0.5rem;
28
+ background: var(--velin-color-surface-dim, #eee);
29
+ border-radius: var(--velin-radius-full, 999px);
30
+ overflow: hidden;
31
+ }
32
+ .bar {
33
+ block-size: 100%;
34
+ inline-size: 0%;
35
+ border-radius: inherit;
36
+ background: var(--velin-color-danger, #dc2626);
37
+ transition: inline-size 160ms ease, background-color 160ms ease;
38
+ }
39
+ :host([data-score="2"]) .bar,
40
+ :host([data-score="3"]) .bar { background: var(--velin-color-warning, #f59e0b); }
41
+ :host([data-score="4"]) .bar,
42
+ :host([data-score="5"]) .bar { background: var(--velin-color-success, #16a34a); }
43
+ .label {
44
+ margin: 0;
45
+ font-size: var(--velin-text-sm, 0.875rem);
46
+ color: var(--velin-color-text-muted, #666);
47
+ }
48
+ @media (prefers-reduced-motion: reduce) {
49
+ .bar { transition: none; }
50
+ }
51
+ `;
52
+ var VelinPasswordStrength = class extends HTMLElement {
53
+ static get observedAttributes() {
54
+ return ["for", "value", "label"];
55
+ }
56
+ constructor() {
57
+ super();
58
+ this.attachShadow({ mode: "open" });
59
+ this._onTargetInput = this._onTargetInput.bind(this);
60
+ this._target = null;
61
+ }
62
+ connectedCallback() {
63
+ if (!this.shadowRoot.querySelector(".wrap")) {
64
+ this.shadowRoot.innerHTML = `
65
+ <style>${styles}</style>
66
+ <div class="wrap" part="wrap">
67
+ <div class="meter" part="meter" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0">
68
+ <div class="bar" part="bar"></div>
69
+ </div>
70
+ <p class="label" part="label" aria-live="polite"></p>
71
+ </div>
72
+ `;
73
+ }
74
+ this._bindTarget();
75
+ this._render(this._currentValue());
76
+ }
77
+ disconnectedCallback() {
78
+ this._unbindTarget();
79
+ }
80
+ attributeChangedCallback(name, oldVal, newVal) {
81
+ if (oldVal === newVal) return;
82
+ if (name === "for") {
83
+ this._bindTarget();
84
+ this._render(this._currentValue());
85
+ } else if (name === "value" || name === "label") {
86
+ this._render(this._currentValue());
87
+ }
88
+ }
89
+ _currentValue() {
90
+ if (this._target) return this._target.value || "";
91
+ return this.getAttribute("value") || "";
92
+ }
93
+ _unbindTarget() {
94
+ if (this._target) {
95
+ this._target.removeEventListener("input", this._onTargetInput);
96
+ this._target = null;
97
+ }
98
+ }
99
+ _bindTarget() {
100
+ this._unbindTarget();
101
+ const id = this.getAttribute("for");
102
+ if (!id || typeof document === "undefined") return;
103
+ const el = document.getElementById(id);
104
+ if (el && "value" in el) {
105
+ this._target = el;
106
+ this._target.addEventListener("input", this._onTargetInput);
107
+ }
108
+ }
109
+ _onTargetInput(e) {
110
+ this._render(e.target.value || "");
111
+ }
112
+ _render(pw) {
113
+ const result = scorePassword(pw);
114
+ const meter = this.shadowRoot?.querySelector(".meter");
115
+ const bar = this.shadowRoot?.querySelector(".bar");
116
+ const label = this.shadowRoot?.querySelector(".label");
117
+ if (!meter || !bar || !label) return;
118
+ bar.style.inlineSize = `${result.pct}%`;
119
+ meter.setAttribute("aria-valuenow", String(result.pct));
120
+ meter.setAttribute("aria-valuetext", result.label);
121
+ const prefix = this.getAttribute("label");
122
+ label.textContent = prefix ? `${prefix}: ${result.label}` : result.label;
123
+ this.setAttribute("data-score", String(result.score));
124
+ this.dispatchEvent(new CustomEvent("velin-strength", {
125
+ bubbles: true,
126
+ composed: true,
127
+ detail: result
128
+ }));
129
+ }
130
+ };
131
+ customElements.define("velin-password-strength", VelinPasswordStrength);
132
+ var velin_password_strength_default = VelinPasswordStrength;
133
+ export {
134
+ velin_password_strength_default as default,
135
+ scorePassword
136
+ };