solid-uix 0.4.0 → 0.5.1

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.
package/dist/main.js CHANGED
@@ -1,629 +1,426 @@
1
- import { createMemo as w, createRenderEffect as $, untrack as ne, sharedConfig as m, splitProps as A, mergeProps as g, createUniqueId as B, createContext as Q, useContext as W, createSignal as F, createComponent as I, createEffect as U, children as Z, Show as se } from "solid-js";
2
- const ie = ["allowfullscreen", "async", "autofocus", "autoplay", "checked", "controls", "default", "disabled", "formnovalidate", "hidden", "indeterminate", "inert", "ismap", "loop", "multiple", "muted", "nomodule", "novalidate", "open", "playsinline", "readonly", "required", "reversed", "seamless", "selected"], oe = /* @__PURE__ */ new Set(["className", "value", "readOnly", "noValidate", "formNoValidate", "isMap", "noModule", "playsInline", ...ie]), le = /* @__PURE__ */ new Set(["innerHTML", "textContent", "innerText", "children"]), re = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(null), {
3
- className: "class",
4
- htmlFor: "for"
5
- }), ce = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(null), {
6
- class: "className",
7
- novalidate: {
8
- $: "noValidate",
9
- FORM: 1
10
- },
11
- formnovalidate: {
12
- $: "formNoValidate",
13
- BUTTON: 1,
14
- INPUT: 1
15
- },
16
- ismap: {
17
- $: "isMap",
18
- IMG: 1
19
- },
20
- nomodule: {
21
- $: "noModule",
22
- SCRIPT: 1
23
- },
24
- playsinline: {
25
- $: "playsInline",
26
- VIDEO: 1
27
- },
28
- readonly: {
29
- $: "readOnly",
30
- INPUT: 1,
31
- TEXTAREA: 1
32
- }
33
- });
34
- function ae(n, e) {
35
- const t = ce[n];
36
- return typeof t == "object" ? t[e] ? t.$ : void 0 : t;
37
- }
38
- const fe = /* @__PURE__ */ new Set(["beforeinput", "click", "dblclick", "contextmenu", "focusin", "focusout", "input", "keydown", "keyup", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointermove", "pointerout", "pointerover", "pointerup", "touchend", "touchmove", "touchstart"]), q = (n) => w(() => n());
39
- function de(n, e, t) {
40
- let s = t.length, i = e.length, l = s, c = 0, o = 0, r = e[i - 1].nextSibling, a = null;
41
- for (; c < i || o < l; ) {
42
- if (e[c] === t[o]) {
43
- c++, o++;
44
- continue;
45
- }
46
- for (; e[i - 1] === t[l - 1]; )
47
- i--, l--;
48
- if (i === c) {
49
- const f = l < s ? o ? t[o - 1].nextSibling : t[l - o] : r;
50
- for (; o < l; ) n.insertBefore(t[o++], f);
51
- } else if (l === o)
52
- for (; c < i; )
53
- (!a || !a.has(e[c])) && e[c].remove(), c++;
54
- else if (e[c] === t[l - 1] && t[o] === e[i - 1]) {
55
- const f = e[--i].nextSibling;
56
- n.insertBefore(t[o++], e[c++].nextSibling), n.insertBefore(t[--l], f), e[i] = t[l];
57
- } else {
58
- if (!a) {
59
- a = /* @__PURE__ */ new Map();
60
- let u = o;
61
- for (; u < l; ) a.set(t[u], u++);
62
- }
63
- const f = a.get(e[c]);
64
- if (f != null)
65
- if (o < f && f < l) {
66
- let u = c, d = 1, C;
67
- for (; ++u < i && u < l && !((C = a.get(e[u])) == null || C !== f + d); )
68
- d++;
69
- if (d > f - o) {
70
- const V = e[c];
71
- for (; o < f; ) n.insertBefore(t[o++], V);
72
- } else n.replaceChild(t[o++], e[c++]);
73
- } else c++;
74
- else e[c++].remove();
75
- }
76
- }
77
- }
78
- const G = "_$DX_DELEGATE";
79
- function h(n, e, t, s) {
80
- let i;
81
- const l = () => {
82
- const o = document.createElement("template");
83
- return o.innerHTML = n, o.content.firstChild;
84
- }, c = () => (i || (i = l())).cloneNode(!0);
85
- return c.cloneNode = c, c;
86
- }
87
- function ue(n, e = window.document) {
88
- const t = e[G] || (e[G] = /* @__PURE__ */ new Set());
89
- for (let s = 0, i = n.length; s < i; s++) {
90
- const l = n[s];
91
- t.has(l) || (t.add(l), e.addEventListener(l, $e));
92
- }
93
- }
94
- function S(n, e, t) {
95
- M(n) || (t == null ? n.removeAttribute(e) : n.setAttribute(e, t));
96
- }
97
- function ge(n, e, t) {
98
- M(n) || (t ? n.setAttribute(e, "") : n.removeAttribute(e));
99
- }
100
- function P(n, e) {
101
- M(n) || (e == null ? n.removeAttribute("class") : n.className = e);
102
- }
103
- function he(n, e, t, s) {
104
- if (s)
105
- Array.isArray(t) ? (n[`$$${e}`] = t[0], n[`$$${e}Data`] = t[1]) : n[`$$${e}`] = t;
106
- else if (Array.isArray(t)) {
107
- const i = t[0];
108
- n.addEventListener(e, t[0] = (l) => i.call(n, t[1], l));
109
- } else n.addEventListener(e, t, typeof t != "function" && t);
110
- }
111
- function ye(n, e, t = {}) {
112
- const s = Object.keys(e || {}), i = Object.keys(t);
113
- let l, c;
114
- for (l = 0, c = i.length; l < c; l++) {
115
- const o = i[l];
116
- !o || o === "undefined" || e[o] || (K(n, o, !1), delete t[o]);
117
- }
118
- for (l = 0, c = s.length; l < c; l++) {
119
- const o = s[l], r = !!e[o];
120
- !o || o === "undefined" || t[o] === r || !r || (K(n, o, !0), t[o] = r);
121
- }
122
- return t;
123
- }
124
- function be(n, e, t) {
125
- if (!e) return t ? S(n, "style") : e;
126
- const s = n.style;
127
- if (typeof e == "string") return s.cssText = e;
128
- typeof t == "string" && (s.cssText = t = void 0), t || (t = {}), e || (e = {});
129
- let i, l;
130
- for (l in t)
131
- e[l] == null && s.removeProperty(l), delete t[l];
132
- for (l in e)
133
- i = e[l], i !== t[l] && (s.setProperty(l, i), t[l] = i);
134
- return t;
135
- }
136
- function b(n, e = {}, t, s) {
137
- const i = {};
138
- return s || $(() => i.children = N(n, e.children, i.children)), $(() => typeof e.ref == "function" && z(e.ref, n)), $(() => _e(n, e, t, !0, i, !0)), i;
139
- }
140
- function z(n, e, t) {
141
- return ne(() => n(e, t));
142
- }
143
- function y(n, e, t, s) {
144
- if (t !== void 0 && !s && (s = []), typeof e != "function") return N(n, e, s, t);
145
- $((i) => N(n, e(), i, t), s);
146
- }
147
- function _e(n, e, t, s, i = {}, l = !1) {
148
- e || (e = {});
149
- for (const c in i)
150
- if (!(c in e)) {
151
- if (c === "children") continue;
152
- i[c] = R(n, c, null, i[c], t, l, e);
153
- }
154
- for (const c in e) {
155
- if (c === "children")
156
- continue;
157
- const o = e[c];
158
- i[c] = R(n, c, o, i[c], t, l, e);
159
- }
160
- }
161
- function M(n) {
162
- return !!m.context && !m.done && (!n || n.isConnected);
163
- }
164
- function me(n) {
165
- return n.toLowerCase().replace(/-([a-z])/g, (e, t) => t.toUpperCase());
166
- }
167
- function K(n, e, t) {
168
- const s = e.trim().split(/\s+/);
169
- for (let i = 0, l = s.length; i < l; i++) n.classList.toggle(s[i], t);
170
- }
171
- function R(n, e, t, s, i, l, c) {
172
- let o, r, a, f, u;
173
- if (e === "style") return be(n, t, s);
174
- if (e === "classList") return ye(n, t, s);
175
- if (t === s) return s;
176
- if (e === "ref")
177
- l || t(n);
178
- else if (e.slice(0, 3) === "on:") {
179
- const d = e.slice(3);
180
- s && n.removeEventListener(d, s, typeof s != "function" && s), t && n.addEventListener(d, t, typeof t != "function" && t);
181
- } else if (e.slice(0, 10) === "oncapture:") {
182
- const d = e.slice(10);
183
- s && n.removeEventListener(d, s, !0), t && n.addEventListener(d, t, !0);
184
- } else if (e.slice(0, 2) === "on") {
185
- const d = e.slice(2).toLowerCase(), C = fe.has(d);
186
- if (!C && s) {
187
- const V = Array.isArray(s) ? s[0] : s;
188
- n.removeEventListener(d, V);
189
- }
190
- (C || t) && (he(n, d, t, C), C && ue([d]));
191
- } else if (e.slice(0, 5) === "attr:")
192
- S(n, e.slice(5), t);
193
- else if (e.slice(0, 5) === "bool:")
194
- ge(n, e.slice(5), t);
195
- else if ((u = e.slice(0, 5) === "prop:") || (a = le.has(e)) || (f = ae(e, n.tagName)) || (r = oe.has(e)) || (o = n.nodeName.includes("-") || "is" in c)) {
196
- if (u)
197
- e = e.slice(5), r = !0;
198
- else if (M(n)) return t;
199
- e === "class" || e === "className" ? P(n, t) : o && !r && !a ? n[me(e)] = t : n[f || e] = t;
200
- } else
201
- S(n, re[e] || e, t);
202
- return t;
203
- }
204
- function $e(n) {
205
- if (m.registry && m.events && m.events.find(([r, a]) => a === n))
206
- return;
207
- let e = n.target;
208
- const t = `$$${n.type}`, s = n.target, i = n.currentTarget, l = (r) => Object.defineProperty(n, "target", {
209
- configurable: !0,
210
- value: r
211
- }), c = () => {
212
- const r = e[t];
213
- if (r && !e.disabled) {
214
- const a = e[`${t}Data`];
215
- if (a !== void 0 ? r.call(e, a, n) : r.call(e, n), n.cancelBubble) return;
216
- }
217
- return e.host && typeof e.host != "string" && !e.host._$host && e.contains(n.target) && l(e.host), !0;
218
- }, o = () => {
219
- for (; c() && (e = e._$host || e.parentNode || e.host); ) ;
220
- };
221
- if (Object.defineProperty(n, "currentTarget", {
222
- configurable: !0,
223
- get() {
224
- return e || document;
225
- }
226
- }), m.registry && !m.done && (m.done = _$HY.done = !0), n.composedPath) {
227
- const r = n.composedPath();
228
- l(r[0]);
229
- for (let a = 0; a < r.length - 2 && (e = r[a], !!c()); a++) {
230
- if (e._$host) {
231
- e = e._$host, o();
232
- break;
233
- }
234
- if (e.parentNode === i)
235
- break;
236
- }
237
- } else o();
238
- l(s);
239
- }
240
- function N(n, e, t, s, i) {
241
- const l = M(n);
242
- if (l) {
243
- !t && (t = [...n.childNodes]);
244
- let r = [];
245
- for (let a = 0; a < t.length; a++) {
246
- const f = t[a];
247
- f.nodeType === 8 && f.data.slice(0, 2) === "!$" ? f.remove() : r.push(f);
248
- }
249
- t = r;
250
- }
251
- for (; typeof t == "function"; ) t = t();
252
- if (e === t) return t;
253
- const c = typeof e, o = s !== void 0;
254
- if (n = o && t[0] && t[0].parentNode || n, c === "string" || c === "number") {
255
- if (l || c === "number" && (e = e.toString(), e === t))
256
- return t;
257
- if (o) {
258
- let r = t[0];
259
- r && r.nodeType === 3 ? r.data !== e && (r.data = e) : r = document.createTextNode(e), t = x(n, t, s, r);
260
- } else
261
- t !== "" && typeof t == "string" ? t = n.firstChild.data = e : t = n.textContent = e;
262
- } else if (e == null || c === "boolean") {
263
- if (l) return t;
264
- t = x(n, t, s);
265
- } else {
266
- if (c === "function")
267
- return $(() => {
268
- let r = e();
269
- for (; typeof r == "function"; ) r = r();
270
- t = N(n, r, t, s);
271
- }), () => t;
272
- if (Array.isArray(e)) {
273
- const r = [], a = t && Array.isArray(t);
274
- if (H(r, e, t, i))
275
- return $(() => t = N(n, r, t, s, !0)), () => t;
276
- if (l) {
277
- if (!r.length) return t;
278
- if (s === void 0) return t = [...n.childNodes];
279
- let f = r[0];
280
- if (f.parentNode !== n) return t;
281
- const u = [f];
282
- for (; (f = f.nextSibling) !== s; ) u.push(f);
283
- return t = u;
284
- }
285
- if (r.length === 0) {
286
- if (t = x(n, t, s), o) return t;
287
- } else a ? t.length === 0 ? X(n, r, s) : de(n, t, r) : (t && x(n), X(n, r));
288
- t = r;
289
- } else if (e.nodeType) {
290
- if (l && e.parentNode) return t = o ? [e] : e;
291
- if (Array.isArray(t)) {
292
- if (o) return t = x(n, t, s, e);
293
- x(n, t, null, e);
294
- } else t == null || t === "" || !n.firstChild ? n.appendChild(e) : n.replaceChild(e, n.firstChild);
295
- t = e;
296
- }
297
- }
298
- return t;
299
- }
300
- function H(n, e, t, s) {
301
- let i = !1;
302
- for (let l = 0, c = e.length; l < c; l++) {
303
- let o = e[l], r = t && t[n.length], a;
304
- if (!(o == null || o === !0 || o === !1)) if ((a = typeof o) == "object" && o.nodeType)
305
- n.push(o);
306
- else if (Array.isArray(o))
307
- i = H(n, o, r) || i;
308
- else if (a === "function")
309
- if (s) {
310
- for (; typeof o == "function"; ) o = o();
311
- i = H(n, Array.isArray(o) ? o : [o], Array.isArray(r) ? r : [r]) || i;
312
- } else
313
- n.push(o), i = !0;
314
- else {
315
- const f = String(o);
316
- r && r.nodeType === 3 && r.data === f ? n.push(r) : n.push(document.createTextNode(f));
317
- }
318
- }
319
- return i;
320
- }
321
- function X(n, e, t = null) {
322
- for (let s = 0, i = e.length; s < i; s++) n.insertBefore(e[s], t);
323
- }
324
- function x(n, e, t, s) {
325
- if (t === void 0) return n.textContent = "";
326
- const i = s || document.createTextNode("");
327
- if (e.length) {
328
- let l = !1;
329
- for (let c = e.length - 1; c >= 0; c--) {
330
- const o = e[c];
331
- if (i !== o) {
332
- const r = o.parentNode === n;
333
- !l && !c ? r ? n.replaceChild(i, o) : n.insertBefore(i, t) : r && o.remove();
334
- } else l = !0;
335
- }
336
- } else n.insertBefore(i, t);
337
- return [i];
338
- }
339
- const Ce = "_button_12jrf_1", xe = {
340
- button: Ce
341
- }, _ = (...n) => n.filter(Boolean).join(" ");
342
- var Ae = /* @__PURE__ */ h("<button type=button>");
343
- const ct = (n) => {
344
- const [e, t] = A(n, ["variant"]);
1
+ import { template, spread, mergeProps as mergeProps$1, insert, memo, setAttribute, effect, className, createComponent, use } from 'solid-js/web';
2
+ import { createContext, mergeProps, splitProps, createUniqueId, useContext, createSignal, createMemo, createEffect, children, Show } from 'solid-js';
3
+ import sx from './button.module.css';
4
+ export { default as buttonSx } from './button.module.css';
5
+ import sx2 from './link.module.css';
6
+ import sx3 from './checkbox.module.css';
7
+ import sx4 from './text_input.module.css';
8
+ import sx5 from './dialog.module.css';
9
+ import sx6 from './field.module.css';
10
+
11
+ // src/main.ts
12
+
13
+ // src/utils/cls.ts
14
+ var cls = (...classes) => {
15
+ return classes.filter(Boolean).join(" ");
16
+ };
17
+ var _tmpl$ = /* @__PURE__ */ template(`<button type=button>`);
18
+ var defaultProps = {
19
+ variant: "solid"
20
+ };
21
+ var Button = (props) => {
22
+ const merged = mergeProps(defaultProps, props);
23
+ const [local, rest] = splitProps(merged, ["class", "variant"]);
345
24
  return (() => {
346
- var s = Ae();
347
- return b(s, g(t, {
348
- get class() {
349
- return _(xe.button, t.class, e.variant || "solid");
25
+ var _el$ = _tmpl$();
26
+ spread(_el$, mergeProps$1(rest, {
27
+ get ["class"]() {
28
+ return cls(sx.button, local.class, local.variant === "solid" && sx.solid, local.variant === "outlined" && sx.outlined);
350
29
  }
351
- }), !1, !0), y(s, () => n.children), s;
30
+ }), false, true);
31
+ insert(_el$, () => rest.children);
32
+ return _el$;
352
33
  })();
353
- }, Te = "_checkbox_1npj4_1", Ee = "_input_1npj4_8", De = "_indicator_1npj4_18", we = "_label_1npj4_37", Le = "_disabled_1npj4_46", E = {
354
- checkbox: Te,
355
- input: Ee,
356
- indicator: De,
357
- label: we,
358
- disabled: Le
359
34
  };
360
- var Ne = /* @__PURE__ */ h("<span><input><span>"), Be = /* @__PURE__ */ h("<label>");
361
- const at = (n) => {
362
- const [e, t] = A(n, ["label", "error", "class"]), s = B();
35
+ var _tmpl$2 = /* @__PURE__ */ template(`<a>`);
36
+ var Link = (props) => {
37
+ const [local, rest] = splitProps(props, ["class", "reset", "disabled", "color", "underline"]);
363
38
  return (() => {
364
- var i = Ne(), l = i.firstChild, c = l.nextSibling;
365
- return b(l, g(t, {
366
- id: s,
367
- type: "checkbox",
368
- get class() {
369
- return E.input;
39
+ var _el$ = _tmpl$2();
40
+ spread(_el$, mergeProps$1(rest, {
41
+ get ["class"]() {
42
+ return cls(!local.reset && sx2.link, local.class, local.disabled && sx2.disabled, local.color === "secondary" && sx2.secondary, local.underline === "always" && sx2.underline);
370
43
  },
371
- get "aria-invalid"() {
372
- return !!e.error;
44
+ get ["aria-disabled"]() {
45
+ return local.disabled;
373
46
  }
374
- }), !1, !1), y(i, (() => {
375
- var o = q(() => !!e.label);
376
- return () => o() && (() => {
377
- var r = Be();
378
- return S(r, "for", s), y(r, () => e.label), $(() => P(r, E.label)), r;
379
- })();
380
- })(), null), $((o) => {
381
- var r = _(E.checkbox, e.class, t.disabled && E.disabled), a = E.indicator;
382
- return r !== o.e && P(i, o.e = r), a !== o.t && P(c, o.t = a), o;
383
- }, {
384
- e: void 0,
385
- t: void 0
386
- }), i;
47
+ }), false, true);
48
+ insert(_el$, () => rest.children);
49
+ return _el$;
387
50
  })();
388
- }, Ie = (n) => n.level === "error", Y = (n) => {
389
- if (n.length)
390
- return n.map((e) => e.id).join(" ");
391
- }, D = () => {
392
- }, L = (n) => () => n, J = () => () => {
393
- }, Me = {
394
- fieldId: "",
395
- error: L(!1),
396
- ariaDescribedBy: L(void 0),
397
- ariaErrorMessage: L(void 0),
398
- setMessage: D
399
- }, p = Q(Me, {}), v = () => W(p), je = (n) => {
400
- const e = B(), [t, s] = F([]), i = w(() => n.error), l = w(() => Y(t())), c = w(() => Y(t().filter(Ie))), o = (r) => {
401
- s((a) => [...a, r]);
51
+ };
52
+
53
+ // src/utils/message.ts
54
+ var isError = (message) => {
55
+ return message.level === "error";
56
+ };
57
+ var getMessageIds = (messages) => {
58
+ if (!messages.length) {
59
+ return void 0;
60
+ }
61
+ return messages.map((message) => message.id).join(" ");
62
+ };
63
+
64
+ // src/utils/noop.ts
65
+ var noop = () => {
66
+ };
67
+ var noopAccessor = (value) => {
68
+ return () => value;
69
+ };
70
+ var noopSetter = () => {
71
+ return () => {
402
72
  };
403
- return I(p.Provider, {
73
+ };
74
+
75
+ // src/field/field.context.tsx
76
+ var defaultValue = {
77
+ fieldId: void 0,
78
+ error: noopAccessor(false),
79
+ ariaDescribedBy: noopAccessor(void 0),
80
+ ariaErrorMessage: noopAccessor(void 0),
81
+ setMessage: noop
82
+ };
83
+ var FieldContext = createContext(defaultValue, {});
84
+ var useFieldContext = () => {
85
+ return useContext(FieldContext);
86
+ };
87
+ var FieldProvider = (props) => {
88
+ const fieldId = createUniqueId();
89
+ const [messages, setMessages] = createSignal([]);
90
+ const error = createMemo(() => {
91
+ return props.error;
92
+ });
93
+ const ariaDescribedBy = createMemo(() => {
94
+ return getMessageIds(messages());
95
+ });
96
+ const ariaErrorMessage = createMemo(() => {
97
+ return getMessageIds(messages().filter(isError));
98
+ });
99
+ const setMessage = (message) => {
100
+ setMessages((prev) => [...prev, message]);
101
+ };
102
+ return createComponent(FieldContext.Provider, {
404
103
  value: {
405
- fieldId: e,
406
- error: i,
407
- setMessage: o,
408
- ariaDescribedBy: l,
409
- ariaErrorMessage: c
104
+ fieldId,
105
+ error,
106
+ setMessage,
107
+ ariaDescribedBy,
108
+ ariaErrorMessage
410
109
  },
411
110
  get children() {
412
- return n.children;
111
+ return props.children;
413
112
  }
414
113
  });
415
- }, Pe = "_input_1nlce_1", Se = {
416
- input: Pe
417
114
  };
418
- var Oe = /* @__PURE__ */ h("<input>");
419
- const ft = (n) => {
420
- const [e, t] = A(n, ["error", "class"]), s = v();
115
+
116
+ // src/checkbox/checkbox.tsx
117
+ var _tmpl$3 = /* @__PURE__ */ template(`<span><input><span>`);
118
+ var _tmpl$22 = /* @__PURE__ */ template(`<label>`);
119
+ var Checkbox = (props) => {
120
+ const [local, rest] = splitProps(props, ["label", "error", "class"]);
121
+ const context = useFieldContext();
122
+ const id = createUniqueId();
421
123
  return (() => {
422
- var i = Oe();
423
- return b(i, g(t, {
424
- get class() {
425
- return _(Se.input, e.class);
124
+ var _el$ = _tmpl$3(), _el$2 = _el$.firstChild, _el$3 = _el$2.nextSibling;
125
+ spread(_el$2, mergeProps$1(rest, {
126
+ "id": id,
127
+ "type": "checkbox",
128
+ get ["class"]() {
129
+ return sx3.input;
130
+ },
131
+ get ["aria-describedby"]() {
132
+ return context.ariaDescribedBy();
133
+ },
134
+ get ["aria-invalid"]() {
135
+ return context.error() || !!local.error;
136
+ },
137
+ get ["aria-errormessage"]() {
138
+ return context.ariaErrorMessage();
139
+ }
140
+ }), false, false);
141
+ insert(_el$, (() => {
142
+ var _c$ = memo(() => !!local.label);
143
+ return () => _c$() && (() => {
144
+ var _el$4 = _tmpl$22();
145
+ setAttribute(_el$4, "for", id);
146
+ insert(_el$4, () => local.label);
147
+ effect(() => className(_el$4, sx3.label));
148
+ return _el$4;
149
+ })();
150
+ })(), null);
151
+ effect((_p$) => {
152
+ var _v$ = cls(sx3.checkbox, local.class, rest.disabled && sx3.disabled), _v$2 = sx3.indicator;
153
+ _v$ !== _p$.e && className(_el$, _p$.e = _v$);
154
+ _v$2 !== _p$.t && className(_el$3, _p$.t = _v$2);
155
+ return _p$;
156
+ }, {
157
+ e: void 0,
158
+ t: void 0
159
+ });
160
+ return _el$;
161
+ })();
162
+ };
163
+ var _tmpl$4 = /* @__PURE__ */ template(`<input>`);
164
+ var TextInput = (props) => {
165
+ const [local, rest] = splitProps(props, ["error", "class"]);
166
+ const context = useFieldContext();
167
+ return (() => {
168
+ var _el$ = _tmpl$4();
169
+ spread(_el$, mergeProps$1(rest, {
170
+ get ["class"]() {
171
+ return cls(sx4.input, local.class);
426
172
  },
427
173
  get id() {
428
- return s.fieldId;
174
+ return context.fieldId;
429
175
  },
430
- get "aria-describedby"() {
431
- return s.ariaDescribedBy();
176
+ get ["aria-describedby"]() {
177
+ return context.ariaDescribedBy();
432
178
  },
433
- get "aria-invalid"() {
434
- return s.error() || !!e.error;
179
+ get ["aria-invalid"]() {
180
+ return context.error() || !!local.error;
435
181
  },
436
- get "aria-errormessage"() {
437
- return s.ariaErrorMessage();
182
+ get ["aria-errormessage"]() {
183
+ return context.ariaErrorMessage();
438
184
  }
439
- }), !1, !1), i;
185
+ }), false, false);
186
+ return _el$;
440
187
  })();
441
- }, ke = {
188
+ };
189
+ var defaultValue2 = {
442
190
  setDialogRef() {
443
191
  },
444
- ariaLabelledBy: L(void 0),
445
- ariaDescribedBy: L(void 0),
446
- setTitleId: J(),
447
- setDescriptionId: J(),
448
- openDialog: D,
449
- closeDialog: D,
450
- onOpenChange: D,
451
- onBeforeClose: D
452
- }, ee = Q(ke), j = () => W(ee), Ve = (n) => {
453
- let e;
454
- const t = (f) => {
455
- e = f;
456
- }, [s, i] = F(), [l, c] = F(), o = w(() => n.isOpen), r = () => {
457
- var f;
458
- e == null || e.showModal(), (f = n.onOpenChange) == null || f.call(n, !0);
459
- }, a = () => {
460
- e == null || e.requestClose();
192
+ ariaLabelledBy: noopAccessor(void 0),
193
+ ariaDescribedBy: noopAccessor(void 0),
194
+ setTitleId: noopSetter(),
195
+ setDescriptionId: noopSetter(),
196
+ openDialog: noop,
197
+ closeDialog: noop,
198
+ onOpenChange: noop,
199
+ onBeforeClose: noop
200
+ };
201
+ var DialogContext = createContext(defaultValue2);
202
+ var useDialogContext = () => {
203
+ return useContext(DialogContext);
204
+ };
205
+
206
+ // src/dialog/provider/provider.tsx
207
+ var DialogProvider = (props) => {
208
+ let dialogRef;
209
+ const setDialogRef = (element) => {
210
+ dialogRef = element;
461
211
  };
462
- return U(() => {
463
- o() ? r() : a();
464
- }), I(ee.Provider, {
212
+ const [ariaLabelledBy, setTitleId] = createSignal();
213
+ const [ariaDescribedBy, setDescriptionId] = createSignal();
214
+ const isOpen = createMemo(() => {
215
+ return props.isOpen;
216
+ });
217
+ const openDialog = () => {
218
+ dialogRef?.showModal();
219
+ props.onOpenChange?.(true);
220
+ };
221
+ const closeDialog = () => {
222
+ dialogRef?.requestClose();
223
+ };
224
+ createEffect(() => {
225
+ if (isOpen()) {
226
+ openDialog();
227
+ } else {
228
+ closeDialog();
229
+ }
230
+ });
231
+ return createComponent(DialogContext.Provider, {
465
232
  get value() {
466
233
  return {
467
- ariaLabelledBy: s,
468
- ariaDescribedBy: l,
469
- setDialogRef: t,
470
- setTitleId: i,
471
- setDescriptionId: c,
472
- openDialog: r,
473
- closeDialog: a,
474
- onOpenChange: n.onOpenChange,
475
- onBeforeClose: n.onBeforeClose
234
+ ariaLabelledBy,
235
+ ariaDescribedBy,
236
+ setDialogRef,
237
+ setTitleId,
238
+ setDescriptionId,
239
+ openDialog,
240
+ closeDialog,
241
+ onOpenChange: props.onOpenChange,
242
+ onBeforeClose: props.onBeforeClose
476
243
  };
477
244
  },
478
245
  get children() {
479
- return n.children;
246
+ return props.children;
480
247
  }
481
248
  });
482
- }, Fe = "_dialog_1klsa_1", He = "_title_1klsa_16", Ue = "_description_1klsa_26", qe = "_actions_1klsa_37", k = {
483
- dialog: Fe,
484
- title: He,
485
- description: Ue,
486
- actions: qe
487
249
  };
488
- var ve = /* @__PURE__ */ h("<dialog>"), Ge = /* @__PURE__ */ h("<h2>"), Ke = /* @__PURE__ */ h("<p>"), Re = /* @__PURE__ */ h("<div>");
489
- const T = (n) => I(Ve, g(n, {
490
- get children() {
491
- return n.children;
492
- }
493
- })), Xe = (n) => {
494
- const e = j(), t = Z(() => n.children);
495
- return U(() => {
496
- const s = t();
497
- s instanceof HTMLElement && (s.onclick = e.openDialog);
498
- }), q(t);
499
- }, Ye = (n) => {
500
- const e = j();
250
+ var _tmpl$5 = /* @__PURE__ */ template(`<dialog>`);
251
+ var _tmpl$23 = /* @__PURE__ */ template(`<h2>`);
252
+ var _tmpl$32 = /* @__PURE__ */ template(`<p>`);
253
+ var _tmpl$42 = /* @__PURE__ */ template(`<div>`);
254
+ var Dialog = (props) => {
255
+ return createComponent(DialogProvider, mergeProps$1(props, {
256
+ get children() {
257
+ return props.children;
258
+ }
259
+ }));
260
+ };
261
+ var Trigger = (props) => {
262
+ const context = useDialogContext();
263
+ const child = children(() => props.children);
264
+ createEffect(() => {
265
+ const element = child();
266
+ if (element instanceof HTMLElement) {
267
+ element.onclick = context.openDialog;
268
+ }
269
+ });
270
+ return memo(child);
271
+ };
272
+ var Content = (props) => {
273
+ const context = useDialogContext();
501
274
  return (() => {
502
- var t = ve();
503
- return z((s) => {
504
- n.ref = s, e.setDialogRef(s);
505
- }, t), b(t, g(n, {
506
- get class() {
507
- return _(k.dialog, n.class);
508
- },
509
- get "aria-labelledby"() {
510
- return e.ariaLabelledBy();
275
+ var _el$ = _tmpl$5();
276
+ use((element) => {
277
+ props.ref = element;
278
+ context.setDialogRef(element);
279
+ }, _el$);
280
+ spread(_el$, mergeProps$1(props, {
281
+ get ["class"]() {
282
+ return cls(sx5.dialog, props.class);
511
283
  },
512
- get "aria-describedby"() {
513
- return e.ariaDescribedBy();
284
+ get ["aria-labelledby"]() {
285
+ return context.ariaLabelledBy();
514
286
  },
515
- onClose: () => {
516
- var s;
517
- return (s = e.onOpenChange) == null ? void 0 : s.call(e, !1);
287
+ get ["aria-describedby"]() {
288
+ return context.ariaDescribedBy();
518
289
  },
290
+ "onClose": () => context.onOpenChange?.(false),
519
291
  get onCancel() {
520
- return e.onBeforeClose;
292
+ return context.onBeforeClose;
521
293
  }
522
- }), !1, !0), y(t, () => n.children), t;
294
+ }), false, true);
295
+ insert(_el$, () => props.children);
296
+ return _el$;
523
297
  })();
524
- }, Je = (n) => {
525
- const e = j(), t = B();
526
- return e.setTitleId(t), (() => {
527
- var s = Ge();
528
- return b(s, g(n, {
529
- id: t,
530
- get class() {
531
- return _(k.title, n.class);
298
+ };
299
+ var Title = (props) => {
300
+ const context = useDialogContext();
301
+ const titleId = createUniqueId();
302
+ context.setTitleId(titleId);
303
+ return (() => {
304
+ var _el$2 = _tmpl$23();
305
+ spread(_el$2, mergeProps$1(props, {
306
+ "id": titleId,
307
+ get ["class"]() {
308
+ return cls(sx5.title, props.class);
532
309
  }
533
- }), !1, !0), y(s, () => n.children), s;
310
+ }), false, true);
311
+ insert(_el$2, () => props.children);
312
+ return _el$2;
534
313
  })();
535
- }, Qe = (n) => {
536
- const e = j(), t = B();
537
- return e.setDescriptionId(t), (() => {
538
- var s = Ke();
539
- return b(s, g(n, {
540
- id: t,
541
- get class() {
542
- return _(k.description, n.class);
314
+ };
315
+ var Description = (props) => {
316
+ const context = useDialogContext();
317
+ const descriptionId = createUniqueId();
318
+ context.setDescriptionId(descriptionId);
319
+ return (() => {
320
+ var _el$3 = _tmpl$32();
321
+ spread(_el$3, mergeProps$1(props, {
322
+ "id": descriptionId,
323
+ get ["class"]() {
324
+ return cls(sx5.description, props.class);
543
325
  }
544
- }), !1, !0), y(s, () => n.children), s;
326
+ }), false, true);
327
+ insert(_el$3, () => props.children);
328
+ return _el$3;
545
329
  })();
546
- }, We = (n) => {
547
- const e = j(), t = Z(() => n.children);
548
- return U(() => {
549
- const s = t();
550
- s instanceof HTMLElement && (s.onclick = e.closeDialog);
551
- }), q(t);
552
- }, Ze = (n) => (() => {
553
- var e = Re();
554
- return b(e, g(n, {
555
- get class() {
556
- return _(k.actions, n.class);
330
+ };
331
+ var Close = (props) => {
332
+ const context = useDialogContext();
333
+ const child = children(() => props.children);
334
+ createEffect(() => {
335
+ const element = child();
336
+ if (element instanceof HTMLElement) {
337
+ element.onclick = context.closeDialog;
557
338
  }
558
- }), !1, !0), y(e, () => n.children), e;
559
- })();
560
- T.Trigger = Xe;
561
- T.Content = Ye;
562
- T.Title = Je;
563
- T.Description = Qe;
564
- T.Close = We;
565
- T.Actions = Ze;
566
- const ze = "_field_1ijme_1", pe = "_label_1ijme_7", et = "_message_1ijme_19", tt = "_error_1ijme_31", O = {
567
- field: ze,
568
- label: pe,
569
- message: et,
570
- error: tt
339
+ });
340
+ return memo(child);
571
341
  };
572
- var nt = /* @__PURE__ */ h("<div>"), st = /* @__PURE__ */ h("<label>"), it = /* @__PURE__ */ h("<p>");
573
- const te = (n) => {
574
- const [e, t] = A(n, ["class", "error"]);
575
- return I(je, {
342
+ var Actions = (props) => {
343
+ return (() => {
344
+ var _el$4 = _tmpl$42();
345
+ spread(_el$4, mergeProps$1(props, {
346
+ get ["class"]() {
347
+ return cls(sx5.actions, props.class);
348
+ }
349
+ }), false, true);
350
+ insert(_el$4, () => props.children);
351
+ return _el$4;
352
+ })();
353
+ };
354
+ Dialog.Trigger = Trigger;
355
+ Dialog.Content = Content;
356
+ Dialog.Title = Title;
357
+ Dialog.Description = Description;
358
+ Dialog.Close = Close;
359
+ Dialog.Actions = Actions;
360
+ var _tmpl$6 = /* @__PURE__ */ template(`<div>`);
361
+ var _tmpl$24 = /* @__PURE__ */ template(`<label>`);
362
+ var _tmpl$33 = /* @__PURE__ */ template(`<p>`);
363
+ var Field = (props) => {
364
+ const [local, rest] = splitProps(props, ["class", "error"]);
365
+ return createComponent(FieldProvider, {
576
366
  get error() {
577
- return !!e.error;
367
+ return !!local.error;
578
368
  },
579
369
  get children() {
580
- var s = nt();
581
- return b(s, g(t, {
582
- get class() {
583
- return _(O.field, e.class);
370
+ var _el$ = _tmpl$6();
371
+ spread(_el$, mergeProps$1(rest, {
372
+ get ["class"]() {
373
+ return cls(sx6.field, local.class);
584
374
  }
585
- }), !1, !0), y(s, () => n.children), s;
375
+ }), false, true);
376
+ insert(_el$, () => props.children);
377
+ return _el$;
586
378
  }
587
379
  });
588
- }, ot = (n) => {
589
- const [e, t] = A(n, ["class"]), s = v();
380
+ };
381
+ var FieldLabel = (props) => {
382
+ const [local, rest] = splitProps(props, ["class"]);
383
+ const context = useFieldContext();
590
384
  return (() => {
591
- var i = st();
592
- return b(i, g(t, {
593
- get for() {
594
- return s.fieldId;
385
+ var _el$2 = _tmpl$24();
386
+ spread(_el$2, mergeProps$1(rest, {
387
+ get ["for"]() {
388
+ return context.fieldId;
595
389
  },
596
- get class() {
597
- return _(O.label, e.class);
390
+ get ["class"]() {
391
+ return cls(sx6.label, local.class);
598
392
  }
599
- }), !1, !0), y(i, () => t.children), i;
393
+ }), false, true);
394
+ insert(_el$2, () => rest.children);
395
+ return _el$2;
600
396
  })();
601
- }, lt = (n) => {
602
- const [e, t] = A(n, ["class", "level"]), s = v(), i = B();
603
- return s.setMessage({
604
- level: e.level || "info",
605
- id: i
606
- }), I(se, {
397
+ };
398
+ var FieldMessage = (props) => {
399
+ const [local, rest] = splitProps(props, ["class", "level"]);
400
+ const context = useFieldContext();
401
+ const messageId = createUniqueId();
402
+ context.setMessage({
403
+ level: local.level || "info",
404
+ id: messageId
405
+ });
406
+ return createComponent(Show, {
607
407
  get when() {
608
- return t.children;
408
+ return rest.children;
609
409
  },
610
410
  get children() {
611
- var l = it();
612
- return b(l, g(t, {
613
- id: i,
614
- get class() {
615
- return _(O.message, e.class, e.level === "error" && O.error);
411
+ var _el$3 = _tmpl$33();
412
+ spread(_el$3, mergeProps$1(rest, {
413
+ "id": messageId,
414
+ get ["class"]() {
415
+ return cls(sx6.message, local.class, local.level === "error" && sx6.error);
616
416
  }
617
- }), !1, !0), y(l, () => t.children), l;
417
+ }), false, true);
418
+ insert(_el$3, () => rest.children);
419
+ return _el$3;
618
420
  }
619
421
  });
620
422
  };
621
- te.Label = ot;
622
- te.Message = lt;
623
- export {
624
- ct as Button,
625
- at as Checkbox,
626
- T as Dialog,
627
- te as Field,
628
- ft as TextInput
629
- };
423
+ Field.Label = FieldLabel;
424
+ Field.Message = FieldMessage;
425
+
426
+ export { Button, Checkbox, Dialog, Field, Link, TextInput, cls };