@diniz/webcomponents 1.1.6 → 1.1.7

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.
@@ -0,0 +1,351 @@
1
+ import { B as d, c as l, h as p, v as u, g as f } from "./index-DiYekJaQ.js";
2
+ const g = `<section class="form-hero">
3
+ <div>
4
+ <h1>Form Elements</h1>
5
+ <p class="hero-subtitle">
6
+ Bring inputs, selects, checkboxes, uploads, and native fields together in one cohesive flow.
7
+ </p>
8
+ </div>
9
+ </section>
10
+
11
+ <section class="form-shell">
12
+ <form id="formLab" class="form-grid">
13
+ <div class="form-panel">
14
+ <h2>Project setup</h2>
15
+ <p>Collect the essentials to launch a workspace.</p>
16
+
17
+ <ui-input label="Workspace name" placeholder="Studio Atlas" name="workspace" required></ui-input>
18
+ <ui-input label="Owner email" type="email" placeholder="owner@company.com" name="ownerEmail" required></ui-input>
19
+
20
+ <div class="split">
21
+ <ui-select id="roleSelect" label="Default role" name="role"></ui-select>
22
+ <ui-select id="regionSelect" label="Region" name="region"></ui-select>
23
+
24
+ </div>
25
+ <ui-select id="categorySelect" label="Category" name="category"></ui-select>
26
+ <ui-date-picker label="Launch date" name="launchDate" placeholder="Select date" format="MM/DD/YYYY"></ui-date-picker>
27
+
28
+ <ui-upload
29
+ label="Brand assets"
30
+ helper="Upload logos or product shots. PNG, JPG, or SVG."
31
+ name="brandAssets"
32
+ accept=".png,.jpg,.jpeg,.svg"
33
+ multiple
34
+ ></ui-upload>
35
+ </div>
36
+
37
+ <div class="form-actions">
38
+ <ui-button type="submit" variant="primary" icon="check">Save form</ui-button>
39
+ <ui-button type="button" id="resetForm" variant="ghost">Reset</ui-button>
40
+ </div>
41
+ </form>
42
+
43
+ <div class="form-output">
44
+ <div class="output-head">
45
+ <h3>Helper output</h3>
46
+ <span>getFormValues()</span>
47
+ </div>
48
+ <pre id="formResult">Submit the form to see values.</pre>
49
+ </div>
50
+ </section>
51
+ `, h = `
52
+ :host {
53
+ display: block;
54
+ color: var(--color-ink);
55
+ }
56
+
57
+ .form-hero {
58
+ display: flex;
59
+ justify-content: space-between;
60
+ align-items: center;
61
+ gap: 1.5rem;
62
+ padding: 2rem;
63
+ border-radius: 20px;
64
+ background: radial-gradient(circle at top left, rgba(36, 236, 113, 0.2), transparent 45%),
65
+ linear-gradient(135deg, rgba(52, 168, 235, 0.12), rgba(255, 255, 255, 0.95));
66
+ border: 1px solid rgba(52, 168, 235, 0.2);
67
+ margin-bottom: 2rem;
68
+ flex-wrap: wrap;
69
+ }
70
+
71
+ .eyebrow {
72
+ text-transform: uppercase;
73
+ letter-spacing: 0.2em;
74
+ font-size: 0.7rem;
75
+ color: rgba(15, 23, 42, 0.55);
76
+ margin: 0 0 0.75rem;
77
+ font-weight: 700;
78
+ }
79
+
80
+ h1 {
81
+ font-size: 2.4rem;
82
+ margin: 0 0 0.5rem;
83
+ }
84
+
85
+ .hero-subtitle {
86
+ max-width: 520px;
87
+ margin: 0;
88
+ color: rgba(15, 23, 42, 0.65);
89
+ font-size: 1rem;
90
+ line-height: 1.6;
91
+ }
92
+
93
+ .hero-chip {
94
+ padding: 0.4rem 0.9rem;
95
+ border-radius: 999px;
96
+ font-size: 0.75rem;
97
+ font-weight: 700;
98
+ text-transform: uppercase;
99
+ letter-spacing: 0.14em;
100
+ background: #0f172a;
101
+ color: #ffffff;
102
+ box-shadow: 0 12px 24px rgba(15, 23, 42, 0.15);
103
+ }
104
+
105
+ .form-shell {
106
+ display: grid;
107
+ grid-template-columns: minmax(0, 1fr) 320px;
108
+ gap: 2rem;
109
+ }
110
+
111
+ .form-grid {
112
+ display: grid;
113
+ grid-template-columns: repeat(2, minmax(0, 1fr));
114
+ gap: 1.5rem;
115
+ align-items: start;
116
+ }
117
+
118
+ .form-panel {
119
+ padding: 1.5rem;
120
+ border-radius: 16px;
121
+ border: 1px solid rgba(148, 163, 184, 0.3);
122
+ background: #ffffff;
123
+ box-shadow: 0 18px 35px rgba(15, 23, 42, 0.08);
124
+ display: flex;
125
+ flex-direction: column;
126
+ gap: 1rem;
127
+ }
128
+
129
+ .form-panel h2 {
130
+ margin: 0;
131
+ font-size: 1.35rem;
132
+ }
133
+
134
+ .form-panel p {
135
+ margin: 0;
136
+ color: rgba(15, 23, 42, 0.6);
137
+ font-size: 0.95rem;
138
+ }
139
+
140
+ .split {
141
+ display: grid;
142
+ grid-template-columns: repeat(2, minmax(0, 1fr));
143
+ gap: 1rem;
144
+ }
145
+
146
+ textarea {
147
+ min-height: 120px;
148
+ padding: 0.75rem 0.85rem;
149
+ font-size: 0.95rem;
150
+ font-family: inherit;
151
+ border: 1.5px solid var(--color-border);
152
+ border-radius: 8px;
153
+ background: #ffffff;
154
+ color: var(--color-ink);
155
+ transition: border-color 0.2s ease, box-shadow 0.2s ease;
156
+ }
157
+
158
+ textarea:focus {
159
+ outline: none;
160
+ border-color: var(--color-primary);
161
+ box-shadow: 0 0 0 3px rgba(36, 236, 113, 0.15);
162
+ }
163
+
164
+ .native-group {
165
+ display: flex;
166
+ flex-direction: column;
167
+ gap: 0.4rem;
168
+ font-size: 0.9rem;
169
+ color: var(--color-ink);
170
+ }
171
+
172
+ .native-group select {
173
+ padding: 0.65rem 0.85rem;
174
+ border: 1.5px solid var(--color-border);
175
+ border-radius: 8px;
176
+ font-size: 0.95rem;
177
+ font-family: inherit;
178
+ background: #ffffff;
179
+ color: var(--color-ink);
180
+ }
181
+
182
+ .checkbox-stack {
183
+ display: grid;
184
+ gap: 0.75rem;
185
+ }
186
+
187
+ .checkbox-inline {
188
+ display: grid;
189
+ gap: 0.5rem;
190
+ font-size: 0.9rem;
191
+ color: var(--color-ink);
192
+ }
193
+
194
+ .inline-options {
195
+ display: flex;
196
+ gap: 1rem;
197
+ flex-wrap: wrap;
198
+ }
199
+
200
+ .inline-options label {
201
+ display: flex;
202
+ align-items: center;
203
+ gap: 0.4rem;
204
+ }
205
+
206
+ .form-actions {
207
+ grid-column: 1 / -1;
208
+ display: flex;
209
+ gap: 0.75rem;
210
+ align-items: center;
211
+ }
212
+
213
+ .form-output {
214
+ background: #0f172a;
215
+ color: #f8fafc;
216
+ border-radius: 16px;
217
+ padding: 1.5rem;
218
+ display: flex;
219
+ flex-direction: column;
220
+ gap: 1rem;
221
+ box-shadow: 0 16px 30px rgba(15, 23, 42, 0.2);
222
+ height: fit-content;
223
+ position: sticky;
224
+ top: 1.5rem;
225
+ }
226
+
227
+ .output-head {
228
+ display: flex;
229
+ justify-content: space-between;
230
+ align-items: center;
231
+ font-size: 0.85rem;
232
+ text-transform: uppercase;
233
+ letter-spacing: 0.14em;
234
+ color: rgba(248, 250, 252, 0.7);
235
+ }
236
+
237
+ .output-head h3 {
238
+ margin: 0;
239
+ font-size: 0.95rem;
240
+ color: #ffffff;
241
+ }
242
+
243
+ pre {
244
+ margin: 0;
245
+ white-space: pre-wrap;
246
+ font-family: "Cascadia Mono", "Fira Code", monospace;
247
+ font-size: 0.82rem;
248
+ line-height: 1.5;
249
+ background: rgba(15, 23, 42, 0.45);
250
+ padding: 1rem;
251
+ border-radius: 12px;
252
+ border: 1px solid rgba(255, 255, 255, 0.1);
253
+ }
254
+
255
+ @media (max-width: 1024px) {
256
+ .form-shell {
257
+ grid-template-columns: 1fr;
258
+ }
259
+
260
+ .form-output {
261
+ position: static;
262
+ }
263
+ }
264
+
265
+ @media (max-width: 720px) {
266
+ .form-grid {
267
+ grid-template-columns: 1fr;
268
+ }
269
+
270
+ .split {
271
+ grid-template-columns: 1fr;
272
+ }
273
+
274
+ h1 {
275
+ font-size: 2rem;
276
+ }
277
+ }
278
+ `, b = [
279
+ { value: "admin", label: "Administrator" },
280
+ { value: "manager", label: "Manager" },
281
+ { value: "developer", label: "Developer" },
282
+ { value: "designer", label: "Designer" }
283
+ ], x = [
284
+ { value: "us-east", label: "US East" },
285
+ { value: "us-west", label: "US West" },
286
+ { value: "eu-west", label: "EU West" },
287
+ { value: "apac", label: "APAC" }
288
+ ];
289
+ class y extends d {
290
+ async connectedCallback() {
291
+ super.connectedCallback(), await new Promise((t) => requestAnimationFrame(t)), await Promise.all([
292
+ customElements.whenDefined("ui-select"),
293
+ customElements.whenDefined("ui-upload"),
294
+ customElements.whenDefined("ui-input"),
295
+ customElements.whenDefined("ui-checkbox"),
296
+ customElements.whenDefined("ui-date-picker")
297
+ ]), await new Promise((t) => setTimeout(t, 50)), this.setupSelects(), this.setupForm();
298
+ }
299
+ async setupSelects() {
300
+ const t = l(this.shadowRoot, "#roleSelect"), r = l(this.shadowRoot, "#regionSelect"), s = l(this.shadowRoot, "#categorySelect"), o = await p.get("https://dummyjson.com/products/categories");
301
+ if (t && t.setAttribute("options", JSON.stringify(b)), r && r.setAttribute("options", JSON.stringify(x)), s && Array.isArray(o)) {
302
+ const a = o.map((i) => ({
303
+ value: i.slug,
304
+ label: i.name
305
+ }));
306
+ s.setAttribute("options", JSON.stringify(a));
307
+ }
308
+ }
309
+ setupForm() {
310
+ const t = l(this.shadowRoot, "#formLab"), r = l(this.shadowRoot, "#formResult"), s = l(this.shadowRoot, "#resetForm");
311
+ if (!t) {
312
+ console.error("Form not found");
313
+ return;
314
+ }
315
+ t.addEventListener("submit", (o) => {
316
+ if (o.preventDefault(), !r) return;
317
+ const a = u(t);
318
+ if (!a.isValid) {
319
+ const c = Object.entries(a.errors).map(([e, n]) => `${e}: ${n}`).join(`
320
+ `);
321
+ r.textContent = `Validation Errors:
322
+ ${c}`;
323
+ return;
324
+ }
325
+ const i = f(t, { includeEmpty: !1 }), m = JSON.stringify(i, (c, e) => e instanceof File ? `File: ${e.name} (${(e.size / 1024).toFixed(1)} KB)` : e, 2);
326
+ r.textContent = m;
327
+ }), s == null || s.addEventListener("click", () => {
328
+ var o, a, i, m, c;
329
+ t == null || t.reset(), r && (r.textContent = "Submit the form to see values."), (o = this.shadowRoot) == null || o.querySelectorAll("ui-input").forEach((e) => {
330
+ e.value = "";
331
+ }), (a = this.shadowRoot) == null || a.querySelectorAll("ui-select").forEach((e) => {
332
+ e.removeAttribute("value");
333
+ }), (i = this.shadowRoot) == null || i.querySelectorAll("ui-checkbox").forEach((e) => {
334
+ var n;
335
+ (n = e.setChecked) == null || n.call(e, !1);
336
+ }), (m = this.shadowRoot) == null || m.querySelectorAll("ui-date-picker").forEach((e) => {
337
+ e.removeAttribute("value");
338
+ }), (c = this.shadowRoot) == null || c.querySelectorAll("ui-upload").forEach((e) => {
339
+ var n;
340
+ (n = e.clear) == null || n.call(e);
341
+ });
342
+ });
343
+ }
344
+ render() {
345
+ this.shadowRoot.innerHTML = `
346
+ <style>${h}</style>
347
+ ${g}
348
+ `;
349
+ }
350
+ }
351
+ customElements.define("form-demo-page", y);