@birdapi/velinstyle 1.2.1 → 1.3.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 (156) hide show
  1. package/README.de.md +148 -11
  2. package/README.md +174 -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 +441 -161
  17. package/cli/docgen/extract-cli.js +2 -1
  18. package/cli/docs-generate.js +9 -0
  19. package/cli/experience.js +173 -0
  20. package/cli/index.js +1384 -361
  21. package/cli/motion.js +738 -0
  22. package/cli/production/component-graph.json +166 -0
  23. package/cli/production/explain.js +52 -0
  24. package/cli/production/extract.js +278 -0
  25. package/cli/production/graph.js +102 -0
  26. package/cli/production/report.js +168 -0
  27. package/cli/production/run.js +355 -0
  28. package/cli/production/trim-css.js +177 -0
  29. package/cli/production/trim-fonts.js +23 -0
  30. package/cli/production/trim-icons.js +38 -0
  31. package/cli/production/trim-js.js +48 -0
  32. package/cli/production/trim-motion.js +22 -0
  33. package/cli/production/trim-themes.js +50 -0
  34. package/cli/production/watch.js +38 -0
  35. package/cli/review.js +48 -1
  36. package/cli/scripts/write-atelier-fixtures.mjs +33 -0
  37. package/cli/security.js +190 -0
  38. package/cli/skills.js +53 -10
  39. package/cli/transparency.js +140 -41
  40. package/cli/workflow.js +32 -17
  41. package/components/index.js +3 -0
  42. package/components/runtime/component-loaders.js +3 -0
  43. package/components/velin-drawer.js +43 -4
  44. package/components/velin-empty-state.js +83 -0
  45. package/components/velin-modal.js +76 -15
  46. package/components/velin-otp-input.js +220 -0
  47. package/components/velin-password-strength.js +147 -0
  48. package/components/velin-sheet.js +49 -4
  49. package/components/velin-theme-toggle.js +15 -1
  50. package/core/a11y/component-contracts.json +391 -255
  51. package/core/attributes/registry.js +1 -1
  52. package/core/meta/knowledge/components.json +75 -3
  53. package/core/motion/analyze.js +38 -0
  54. package/core/motion/blueprint.js +51 -0
  55. package/core/motion/composer.js +114 -0
  56. package/core/motion/data/registry.json +352 -0
  57. package/core/motion/effects.js +17 -1
  58. package/core/motion/index.js +112 -9
  59. package/core/motion/optimize.js +44 -0
  60. package/core/motion/policy.js +77 -0
  61. package/core/motion/registry.js +131 -0
  62. package/core/motion/review.js +59 -0
  63. package/core/motion/scan.js +150 -0
  64. package/core/motion/timeline.js +68 -0
  65. package/core/motion/transitions.js +49 -0
  66. package/core/motion/triggers.js +168 -0
  67. package/core/security/checks/fs.js +92 -0
  68. package/core/security/detect.js +35 -0
  69. package/core/security/engine.js +116 -0
  70. package/core/security/index.js +18 -0
  71. package/core/security/registry.js +85 -0
  72. package/core/security/report/report.js +113 -0
  73. package/core/security/rules/ci/index.js +146 -0
  74. package/core/security/rules/consumer/index.js +174 -0
  75. package/core/security/rules/deps/index.js +182 -0
  76. package/core/security/rules/index.js +24 -0
  77. package/core/security/rules/publish/index.js +230 -0
  78. package/core/security/rules/repo/index.js +143 -0
  79. package/core/security/rules/secrets/index.js +133 -0
  80. package/core/security/score/dependency-health.js +53 -0
  81. package/core/security/score/release-health.js +66 -0
  82. package/core/security/score/score.js +102 -0
  83. package/core/security/timeline/timeline.js +76 -0
  84. package/dist/chunks/attributes-2ORR27KA.js +404 -0
  85. package/dist/chunks/attributes-HK7VIOLA.js +1080 -0
  86. package/dist/chunks/attributes-VRHHVNDO.js +1080 -0
  87. package/dist/chunks/chunk-MYKUI364.js +116 -0
  88. package/dist/chunks/chunk-NEVBPD5T.js +116 -0
  89. package/dist/chunks/chunk-Y6HN7HWX.js +116 -0
  90. package/dist/chunks/runtime-entry.js +1 -1
  91. package/dist/chunks/velin-drawer-A7Q7EBOS.js +162 -0
  92. package/dist/chunks/velin-empty-state-3NTUH2RF.js +81 -0
  93. package/dist/chunks/velin-modal-3MV4FYBK.js +231 -0
  94. package/dist/chunks/velin-otp-input-PSK42MM6.js +207 -0
  95. package/dist/chunks/velin-password-strength-TAXMLSED.js +136 -0
  96. package/dist/chunks/velin-sheet-N2VVYXFP.js +157 -0
  97. package/dist/chunks/velin-theme-toggle-J2NHC7IM.js +304 -0
  98. package/dist/llms.txt +4 -4
  99. package/dist/search-index.json +232 -5
  100. package/dist/velin-agent.json +433 -46
  101. package/dist/velinstyle-components.iife.js +3695 -2272
  102. package/dist/velinstyle-components.js +3698 -2271
  103. package/dist/velinstyle-components.min.js +262 -120
  104. package/dist/velinstyle.css +96 -13
  105. package/dist/velinstyle.d.ts +3 -0
  106. package/dist/velinstyle.min.css +1 -1
  107. package/package.json +19 -4
  108. package/packages/velinstyle-cli-core/package.json +11 -0
  109. package/packages/velinstyle-cli-core/src/config.js +84 -0
  110. package/packages/velinstyle-cli-core/src/contract.js +56 -0
  111. package/packages/velinstyle-cli-core/src/event-bus.js +50 -0
  112. package/packages/velinstyle-cli-core/src/index.js +18 -0
  113. package/packages/velinstyle-cli-core/src/lifecycle.js +33 -0
  114. package/packages/velinstyle-cli-core/src/runner.js +129 -0
  115. package/packages/velinstyle-cli-registry/data/commands.json +1216 -0
  116. package/packages/velinstyle-cli-registry/data/layouts.json +33 -0
  117. package/packages/velinstyle-cli-registry/data/widgets.json +35 -0
  118. package/packages/velinstyle-cli-registry/package.json +13 -0
  119. package/packages/velinstyle-cli-registry/src/index.js +88 -0
  120. package/packages/velinstyle-cli-renderer/package.json +8 -0
  121. package/packages/velinstyle-cli-renderer/src/index.js +286 -0
  122. package/packages/velinstyle-cli-theme/package.json +8 -0
  123. package/packages/velinstyle-cli-theme/src/index.js +84 -0
  124. package/packages/velinstyle-cli-ui/package.json +8 -0
  125. package/packages/velinstyle-cli-ui/src/index.js +34 -0
  126. package/packages/velinstyle-motion/README.md +81 -0
  127. package/packages/velinstyle-motion/package.json +37 -0
  128. package/packages/velinstyle-motion/src/ai/mini-prompt.js +119 -0
  129. package/packages/velinstyle-motion/src/ai/provider.js +59 -0
  130. package/packages/velinstyle-motion/src/ai/providers/pixverse-setup.js +402 -0
  131. package/packages/velinstyle-motion/src/ai/providers/pixverse.js +245 -0
  132. package/packages/velinstyle-motion/src/config.js +257 -0
  133. package/packages/velinstyle-motion/src/export/html-clip.js +141 -0
  134. package/packages/velinstyle-motion/src/index.js +304 -0
  135. package/packages/velinstyle-motion/src/jobs/cache.js +30 -0
  136. package/packages/velinstyle-motion/src/jobs/queue.js +69 -0
  137. package/packages/velinstyle-motion/src/jobs/usage.js +53 -0
  138. package/packages/velinstyle-motion/src/local/effects.js +139 -0
  139. package/packages/velinstyle-motion/src/local/engine.js +96 -0
  140. package/packages/velinstyle-motion/src/providers-catalog.js +44 -0
  141. package/packages/velinstyle-motion/src/registry/presets.js +25 -0
  142. package/packages/velinstyle-motion/src/registry/presets.json +85 -0
  143. package/packages/velinstyle-motion/src/ux/cost-gate.js +37 -0
  144. package/packages/velinstyle-motion/src/ux/pixverse-gate.js +153 -0
  145. package/packages/velinstyle-motion/src/ux/wizard.js +171 -0
  146. package/packages/velinstyle-motion/src/validate-image.js +91 -0
  147. package/packages/velinstyle-skills/catalog.json +1 -1
  148. package/packages/velinstyle-skills/registry.json +1 -142
  149. package/packages/velinstyle-skills/skills/velin-motion-reduced-safe/SKILL.md +1 -1
  150. package/packages/velinstyle-skills/skills/velin-motion-reveal-feedback/SKILL.md +1 -1
  151. package/src/components/data-table.css +19 -0
  152. package/src/components/empty-auth.css +33 -0
  153. package/src/components/table.css +16 -6
  154. package/src/tokens/motion.css +7 -0
  155. package/src/utilities/scroll-animation.css +66 -0
  156. package/src/velinstyle.css +1 -0
@@ -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
+ };