@solibo/solibo-ui 1.0.15 → 1.0.16

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 (120) hide show
  1. package/dist/assets/index.css +1 -1
  2. package/dist/assets/index10.css +1 -1
  3. package/dist/assets/index12.css +1 -1
  4. package/dist/assets/index13.css +1 -1
  5. package/dist/assets/index14.css +1 -1
  6. package/dist/assets/index15.css +1 -1
  7. package/dist/assets/index18.css +1 -1
  8. package/dist/assets/index23.css +1 -1
  9. package/dist/assets/index24.css +1 -1
  10. package/dist/assets/index25.css +1 -1
  11. package/dist/assets/index26.css +1 -1
  12. package/dist/assets/index27.css +1 -1
  13. package/dist/assets/index29.css +1 -1
  14. package/dist/assets/index3.css +1 -1
  15. package/dist/assets/index30.css +1 -1
  16. package/dist/assets/index31.css +1 -1
  17. package/dist/assets/index33.css +1 -1
  18. package/dist/assets/index34.css +1 -1
  19. package/dist/assets/index35.css +1 -1
  20. package/dist/assets/index36.css +1 -1
  21. package/dist/assets/index37.css +1 -1
  22. package/dist/assets/index39.css +1 -1
  23. package/dist/assets/index4.css +1 -1
  24. package/dist/assets/index43.css +1 -1
  25. package/dist/assets/index44.css +1 -1
  26. package/dist/assets/index45.css +1 -1
  27. package/dist/assets/index47.css +1 -1
  28. package/dist/assets/index48.css +1 -1
  29. package/dist/assets/index49.css +1 -1
  30. package/dist/assets/index6.css +1 -1
  31. package/dist/assets/index8.css +1 -1
  32. package/dist/assets/index9.css +1 -1
  33. package/dist/assets/menu-popover.css +1 -1
  34. package/dist/components/app-link/index.cjs +1 -1
  35. package/dist/components/app-link/index.js +8 -8
  36. package/dist/components/aside/index.cjs +1 -1
  37. package/dist/components/aside/index.js +11 -11
  38. package/dist/components/avatar/index.cjs +1 -1
  39. package/dist/components/avatar/index.cjs.map +1 -1
  40. package/dist/components/avatar/index.js +58 -58
  41. package/dist/components/badge/index.cjs +1 -1
  42. package/dist/components/badge/index.js +27 -27
  43. package/dist/components/banner/index.cjs +1 -1
  44. package/dist/components/banner/index.js +14 -14
  45. package/dist/components/button/index.cjs +1 -1
  46. package/dist/components/button/index.js +18 -18
  47. package/dist/components/card/index.cjs +1 -1
  48. package/dist/components/card/index.js +46 -46
  49. package/dist/components/checkbox/index.cjs +1 -1
  50. package/dist/components/checkbox/index.js +7 -7
  51. package/dist/components/collapsible/index.cjs +1 -1
  52. package/dist/components/collapsible/index.cjs.map +1 -1
  53. package/dist/components/collapsible/index.js +18 -37
  54. package/dist/components/collapsible/index.js.map +1 -1
  55. package/dist/components/controls/index.cjs +1 -1
  56. package/dist/components/controls/index.cjs.map +1 -1
  57. package/dist/components/controls/index.js +110 -90
  58. package/dist/components/controls/index.js.map +1 -1
  59. package/dist/components/croppable/index.cjs +1 -1
  60. package/dist/components/croppable/index.js +181 -181
  61. package/dist/components/dialog/index.cjs +1 -1
  62. package/dist/components/dialog/index.js +31 -31
  63. package/dist/components/dropdown/index.cjs +1 -1
  64. package/dist/components/dropdown/index.js +80 -80
  65. package/dist/components/editor/index.cjs +16 -16
  66. package/dist/components/editor/index.cjs.map +1 -1
  67. package/dist/components/editor/index.js +196 -196
  68. package/dist/components/file/index.cjs +1 -1
  69. package/dist/components/file/index.js +24 -24
  70. package/dist/components/header/index.cjs +1 -1
  71. package/dist/components/header/index.cjs.map +1 -1
  72. package/dist/components/header/index.js +14 -14
  73. package/dist/components/icon/index.cjs +1 -1
  74. package/dist/components/icon/index.js +20 -20
  75. package/dist/components/input/index.cjs +1 -1
  76. package/dist/components/input/index.js +1 -1
  77. package/dist/components/list/index.cjs +1 -1
  78. package/dist/components/list/index.js +24 -24
  79. package/dist/components/loading/index.cjs +1 -1
  80. package/dist/components/loading/index.js +11 -11
  81. package/dist/components/menu/index.cjs +1 -1
  82. package/dist/components/menu/index.js +1 -1
  83. package/dist/components/message/index.cjs +1 -1
  84. package/dist/components/message/index.cjs.map +1 -1
  85. package/dist/components/message/index.js +26 -26
  86. package/dist/components/messages/index.cjs +1 -1
  87. package/dist/components/messages/index.js +20 -20
  88. package/dist/components/nav/index.cjs +1 -1
  89. package/dist/components/nav/index.js +12 -12
  90. package/dist/components/popover/index.cjs +1 -1
  91. package/dist/components/popover/index.js +38 -38
  92. package/dist/components/portal/index.cjs +1 -1
  93. package/dist/components/portal/index.js +7 -7
  94. package/dist/components/search/index.cjs +1 -1
  95. package/dist/components/search/index.cjs.map +1 -1
  96. package/dist/components/search/index.js +36 -36
  97. package/dist/components/sortable/index.cjs +1 -1
  98. package/dist/components/sortable/index.js +74 -74
  99. package/dist/components/textarea/index.cjs +1 -1
  100. package/dist/components/textarea/index.js +15 -15
  101. package/dist/components/toasts/index.cjs +1 -1
  102. package/dist/components/toasts/index.js +4 -4
  103. package/dist/components/toggle/index.cjs +1 -1
  104. package/dist/components/toggle/index.js +6 -6
  105. package/dist/components/tooltip/index.cjs +1 -1
  106. package/dist/components/tooltip/index.js +1 -1
  107. package/dist/{index-DE2nzqL5.js → index-BIV5OwVJ.js} +23 -23
  108. package/dist/{index-DE2nzqL5.js.map → index-BIV5OwVJ.js.map} +1 -1
  109. package/dist/index-CQNlYa2P.cjs +2 -0
  110. package/dist/{index-DF8JisYI.cjs.map → index-CQNlYa2P.cjs.map} +1 -1
  111. package/dist/index.cjs +1 -1
  112. package/dist/index.d.ts +3 -1
  113. package/dist/index.js +1 -1
  114. package/dist/{menu-popover-jTTxzTGZ.cjs → menu-popover-D1ALaiV5.cjs} +2 -2
  115. package/dist/{menu-popover-jTTxzTGZ.cjs.map → menu-popover-D1ALaiV5.cjs.map} +1 -1
  116. package/dist/{menu-popover-SiOOwab-.js → menu-popover-DQHDIw-8.js} +12 -12
  117. package/dist/{menu-popover-SiOOwab-.js.map → menu-popover-DQHDIw-8.js.map} +1 -1
  118. package/dist/tokens.json +1 -1
  119. package/package.json +1 -1
  120. package/dist/index-DF8JisYI.cjs +0 -2
@@ -1,24 +1,24 @@
1
- import { jsx as L } from "react/jsx-runtime";
2
- import { t as $ } from "../../classix-DG18itHa.js";
3
- import N, { createContext as K, useMemo as q, useRef as u, useState as U, useEffect as Q, useContext as tt } from "react";
1
+ import { jsx as j } from "react/jsx-runtime";
2
+ import { t as W } from "../../classix-DG18itHa.js";
3
+ import L, { createContext as K, useMemo as $, useRef as u, useState as q, useEffect as Q, useContext as tt } from "react";
4
4
  import { List as et } from "../list/index.js";
5
- import '../../assets/index8.css';const rt = "_sortable_iw0r0_1", nt = "_dragging_iw0r0_13", ot = "_columns_iw0r0_38", ct = "_pseudo_iw0r0_47", w = {
6
- sortable: rt,
7
- dragging: nt,
5
+ import '../../assets/index8.css';const nt = "_sortable_5vbjc_1", rt = "_dragging_5vbjc_13", ot = "_columns_5vbjc_38", ct = "_pseudo_5vbjc_47", b = {
6
+ sortable: nt,
7
+ dragging: rt,
8
8
  columns: ot,
9
9
  pseudo: ct,
10
- "target-above": "_target-above_iw0r0_62",
11
- "target-below": "_target-below_iw0r0_63"
12
- }, V = K(null);
10
+ "target-above": "_target-above_5vbjc_62",
11
+ "target-below": "_target-below_5vbjc_63"
12
+ }, U = K(null);
13
13
  function dt() {
14
- return tt(V);
14
+ return tt(U);
15
15
  }
16
16
  const h = (s) => Number.parseFloat(s) || 0, lt = (s) => {
17
- const b = s.firstElementChild, i = s.getBoundingClientRect();
18
- if (b) {
19
- const y = b.getBoundingClientRect();
17
+ const v = s.firstElementChild, i = s.getBoundingClientRect();
18
+ if (v) {
19
+ const y = v.getBoundingClientRect();
20
20
  return {
21
- borderRadius: window.getComputedStyle(b).borderRadius,
21
+ borderRadius: window.getComputedStyle(v).borderRadius,
22
22
  height: y.height,
23
23
  width: y.width,
24
24
  wrapperHeight: i.height
@@ -34,18 +34,18 @@ const h = (s) => Number.parseFloat(s) || 0, lt = (s) => {
34
34
  };
35
35
  function ht({
36
36
  children: s,
37
- className: b,
37
+ className: v,
38
38
  columns: i = 1,
39
39
  isRearranging: l = !1,
40
40
  onChangeOrder: A,
41
41
  ...S
42
42
  }) {
43
- const y = Number.isFinite(i) ? Math.max(1, Math.floor(i)) : 1, _ = q(() => N.Children.toArray(s), [s]), a = u(-1), P = q(() => typeof window < "u" && (navigator.maxTouchPoints > 0 || window.matchMedia("(pointer: coarse)").matches), []), p = u(!1), C = u(null), v = u(null), x = u(null), I = u(0), E = u(null), m = u(null), M = u((o) => o.preventDefault()).current, [R, O] = U({
43
+ const y = Number.isFinite(i) ? Math.max(1, Math.floor(i)) : 1, _ = $(() => L.Children.toArray(s), [s]), a = u(-1), N = $(() => typeof window < "u" && (navigator.maxTouchPoints > 0 || window.matchMedia("(pointer: coarse)").matches), []), p = u(!1), C = u(null), w = u(null), x = u(null), I = u(0), E = u(null), m = u(null), M = u((o) => o.preventDefault()).current, [R, V] = q({
44
44
  borderRadius: "0px",
45
45
  height: 0,
46
46
  width: 0,
47
47
  wrapperHeight: 0
48
- }), [g, D] = U(null), j = {
48
+ }), [g, D] = q(null), O = {
49
49
  ...S.style,
50
50
  "--sortable-placeholder-height": `${R.height}px`,
51
51
  "--sortable-placeholder-radius": R.borderRadius,
@@ -53,12 +53,12 @@ function ht({
53
53
  }, H = (o, t) => {
54
54
  if (t < 0 || t >= _.length || o === t) return;
55
55
  const c = _.slice(), [e] = c.splice(o, 1);
56
- c.splice(t, 0, e), A(c.map((r, n) => ({
57
- id: String(N.isValidElement(r) ? r.props["data-id"] ?? `idx-${n}` : `idx-${n}`),
58
- weight: c.length - 1 - n
56
+ c.splice(t, 0, e), A(c.map((n, r) => ({
57
+ id: String(L.isValidElement(n) ? n.props["data-id"] ?? `idx-${r}` : `idx-${r}`),
58
+ weight: c.length - 1 - r
59
59
  })));
60
60
  }, T = () => {
61
- v.current !== null && (clearTimeout(v.current), v.current = null);
61
+ w.current !== null && (clearTimeout(w.current), w.current = null);
62
62
  }, B = () => {
63
63
  m.current !== null && (cancelAnimationFrame(m.current), m.current = null);
64
64
  }, Z = (o) => {
@@ -71,32 +71,32 @@ function ht({
71
71
  t = t.parentElement;
72
72
  }
73
73
  return document.scrollingElement instanceof HTMLElement ? document.scrollingElement : null;
74
- }, Y = (o = !1) => {
74
+ }, P = (o = !1) => {
75
75
  T(), B(), window.removeEventListener("touchmove", M), E.current = null, p.current = !1, C.current = null, x.current = null, I.current = o ? Date.now() + 500 : 0, a.current = -1, D(null);
76
- }, z = (o, t) => {
77
- a.current = o, O(lt(t)), D(o);
78
- }, G = (o) => o instanceof Element && !!o.closest('button, a, input, textarea, select, option, [role="button"], [contenteditable="true"]'), X = (o, t, c) => {
76
+ }, Y = (o, t) => {
77
+ a.current = o, V(lt(t)), D(o);
78
+ }, G = (o) => o instanceof Element && !!o.closest('button, a, input, textarea, select, option, [role="button"], [contenteditable="true"]'), z = (o, t, c) => {
79
79
  const e = a.current;
80
80
  if (!Number.isInteger(t) || e < 0 || t === e) return null;
81
- const r = o.getBoundingClientRect(), n = t === e + 1 ? R.wrapperHeight : r.height, d = c > r.top + n / 2 ? t + 1 : t;
81
+ const n = o.getBoundingClientRect(), r = t === e + 1 ? R.wrapperHeight : n.height, d = c > n.top + r / 2 ? t + 1 : t;
82
82
  return d > e ? d - 1 : d;
83
- }, k = (o, t) => {
84
- var r;
85
- const c = (r = document.elementFromPoint(o, t)) == null ? void 0 : r.closest("[data-sortable-index]");
83
+ }, X = (o, t) => {
84
+ var n;
85
+ const c = (n = document.elementFromPoint(o, t)) == null ? void 0 : n.closest("[data-sortable-index]");
86
86
  if (!c) return;
87
- const e = X(c, Number(c.dataset.sortableIndex), t);
87
+ const e = z(c, Number(c.dataset.sortableIndex), t);
88
88
  e !== null && (C.current = e, D(e));
89
89
  }, J = (o) => {
90
90
  const t = Z(o);
91
91
  if (!t) return;
92
- const c = 72, e = 18, r = () => {
92
+ const c = 72, e = 18, n = () => {
93
93
  if (!p.current) {
94
94
  m.current = null;
95
95
  return;
96
96
  }
97
- const n = E.current;
98
- if (!n) {
99
- m.current = requestAnimationFrame(r);
97
+ const r = E.current;
98
+ if (!r) {
99
+ m.current = requestAnimationFrame(n);
100
100
  return;
101
101
  }
102
102
  const f = t === document.scrollingElement ? {
@@ -104,60 +104,60 @@ function ht({
104
104
  bottom: window.innerHeight
105
105
  } : t.getBoundingClientRect();
106
106
  let d = 0;
107
- if (n.y < f.top + c) {
108
- const F = Math.max(0, n.y - f.top);
107
+ if (r.y < f.top + c) {
108
+ const F = Math.max(0, r.y - f.top);
109
109
  d = -e * (1 - F / c);
110
- } else if (n.y > f.bottom - c) {
111
- const F = Math.max(0, f.bottom - n.y);
110
+ } else if (r.y > f.bottom - c) {
111
+ const F = Math.max(0, f.bottom - r.y);
112
112
  d = e * (1 - F / c);
113
113
  }
114
114
  d !== 0 && (t.scrollBy({
115
115
  top: d,
116
116
  behavior: "auto"
117
- }), k(n.x, n.y)), m.current = requestAnimationFrame(r);
117
+ }), X(r.x, r.y)), m.current = requestAnimationFrame(n);
118
118
  };
119
- B(), m.current = requestAnimationFrame(r);
120
- }, W = () => {
119
+ B(), m.current = requestAnimationFrame(n);
120
+ }, k = () => {
121
121
  a.current = -1, D(null);
122
122
  };
123
123
  return Q(() => () => {
124
124
  T(), B(), window.removeEventListener("touchmove", M);
125
- }, [M]), /* @__PURE__ */ L(et, { className: $(b, w.sortable, y > 1 && w.columns), columns: i, ordered: !0, style: j, ...S, "data-component": "sortable", children: _.map((o, t) => {
126
- const c = N.isValidElement(o) ? o.key : null;
127
- return /* @__PURE__ */ L("li", { "data-sortable-index": t, onClickCapture: (e) => {
125
+ }, [M]), /* @__PURE__ */ j(et, { className: W(v, b.sortable, y > 1 && b.columns), columns: i, ordered: !0, style: O, ...S, "data-component": "sortable", children: _.map((o, t) => {
126
+ const c = L.isValidElement(o) ? o.key : null;
127
+ return /* @__PURE__ */ j("li", { "data-sortable-index": t, onClickCapture: (e) => {
128
128
  I.current <= Date.now() || (e.preventDefault(), e.stopPropagation(), I.current = 0);
129
- }, className: $(g !== null && g > t - 10 && g < t + 10 && w.pseudo, g === t && a.current < t && w["target-below"], g === t && a.current > t && w["target-above"], a.current === t && w.dragging), onContextMenu: (e) => {
130
- (p.current || v.current !== null) && e.preventDefault();
129
+ }, className: W(g !== null && g > t - 10 && g < t + 10 && b.pseudo, g === t && a.current < t && b["target-below"], g === t && a.current > t && b["target-above"], a.current === t && b.dragging), onContextMenu: (e) => {
130
+ (p.current || w.current !== null) && e.preventDefault();
131
131
  }, onTouchStart: (e) => {
132
132
  if (l || G(e.target)) return;
133
133
  I.current = 0;
134
- const r = e.touches[0];
135
- if (!r) return;
136
- const n = e.currentTarget;
134
+ const n = e.touches[0];
135
+ if (!n) return;
136
+ const r = e.currentTarget;
137
137
  x.current = {
138
- x: r.clientX,
139
- y: r.clientY
140
- }, T(), v.current = setTimeout(() => {
141
- z(t, n), p.current = !0, C.current = t, E.current = {
142
- x: r.clientX,
143
- y: r.clientY
138
+ x: n.clientX,
139
+ y: n.clientY
140
+ }, T(), w.current = setTimeout(() => {
141
+ Y(t, r), p.current = !0, C.current = t, E.current = {
142
+ x: n.clientX,
143
+ y: n.clientY
144
144
  }, window.addEventListener("touchmove", M, {
145
145
  passive: !1
146
- }), J(n);
146
+ }), J(r);
147
147
  }, 350);
148
148
  }, onTouchMove: (e) => {
149
- const r = e.touches[0];
150
- if (r) {
149
+ const n = e.touches[0];
150
+ if (n) {
151
151
  if (E.current = {
152
- x: r.clientX,
153
- y: r.clientY
152
+ x: n.clientX,
153
+ y: n.clientY
154
154
  }, !p.current) {
155
- const n = x.current;
156
- if (!n) return;
157
- Math.hypot(r.clientX - n.x, r.clientY - n.y) > 8 && (T(), x.current = null);
155
+ const r = x.current;
156
+ if (!r) return;
157
+ Math.hypot(n.clientX - r.x, n.clientY - r.y) > 8 && (T(), x.current = null);
158
158
  return;
159
159
  }
160
- k(r.clientX, r.clientY);
160
+ X(n.clientX, n.clientY);
161
161
  }
162
162
  }, onTouchEnd: (e) => {
163
163
  if (T(), !p.current) {
@@ -165,23 +165,23 @@ function ht({
165
165
  return;
166
166
  }
167
167
  e.preventDefault();
168
- const r = a.current, n = C.current;
169
- r >= 0 && n !== null && r !== n && H(r, n), Y(!0);
170
- }, onTouchCancel: () => Y(), draggable: !l && !P, onDragEnd: () => W(), onDragOver: (e) => {
168
+ const n = a.current, r = C.current;
169
+ n >= 0 && r !== null && n !== r && H(n, r), P(!0);
170
+ }, onTouchCancel: () => P(), draggable: !l && !N, onDragEnd: () => k(), onDragOver: (e) => {
171
171
  e.preventDefault(), e.dataTransfer.dropEffect = "move";
172
- const r = X(e.currentTarget, t, e.clientY);
173
- r !== null && D(r);
172
+ const n = z(e.currentTarget, t, e.clientY);
173
+ n !== null && D(n);
174
174
  }, onDragStart: (e) => {
175
- if (P) {
175
+ if (N) {
176
176
  e.preventDefault();
177
177
  return;
178
178
  }
179
- z(t, e.currentTarget), e.dataTransfer.setData("text/plain", ""), e.dataTransfer.effectAllowed = "move";
179
+ Y(t, e.currentTarget), e.dataTransfer.setData("text/plain", ""), e.dataTransfer.effectAllowed = "move";
180
180
  }, onDrop: (e) => {
181
181
  e.preventDefault();
182
- const r = a.current, n = g;
183
- r < 0 || n === null || r === n || (H(r, n), W());
184
- }, "data-component": "sortable", children: /* @__PURE__ */ L(V.Provider, { value: {
182
+ const n = a.current, r = g;
183
+ n < 0 || r === null || n === r || (H(n, r), k());
184
+ }, "data-component": "sortable", children: /* @__PURE__ */ j(U.Provider, { value: {
185
185
  canMoveDown: t < _.length - 1,
186
186
  canMoveUp: t > 0,
187
187
  index: t,
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index6.css');const e=require("react/jsx-runtime"),_=require("../../classix-5H4IWnMA.cjs"),r=require("../../use-touched-Bq5Gjbpz.cjs"),m="_label_ah8yz_3",y="_textarea_ah8yz_11",b="_touched_ah8yz_30",t={label:m,textarea:y,touched:b},j=({className:c,label:a,maxRows:n=12,minRows:l=3,onBlur:u,required:s,style:d,value:o,...x})=>{const{touched:h,onBlur:i}=r.useTouched(o==="");return e.jsxs("label",{className:t.label,"data-component":"textarea",children:[a&&e.jsx("span",{"data-required":s||void 0,children:a}),e.jsx("textarea",{...x,className:_.t(t.textarea,c,h&&t.touched),onBlur:r.composeEventHandlers(i,u),required:s,style:{...d,"--min-rows":l,"--max-rows":n},value:o})]})};exports.Textarea=j;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index6.css');const e=require("react/jsx-runtime"),_=require("../../classix-5H4IWnMA.cjs"),r=require("../../use-touched-Bq5Gjbpz.cjs"),m="_label_123ts_3",b="_textarea_123ts_11",j="_touched_123ts_30",t={label:m,textarea:b,touched:j},T=({className:c,label:s,maxRows:n=12,minRows:l=3,onBlur:u,required:a,style:d,value:o,...x})=>{const{touched:i,onBlur:h}=r.useTouched(o==="");return e.jsxs("label",{className:t.label,"data-component":"textarea",children:[s&&e.jsx("span",{"data-required":a||void 0,children:s}),e.jsx("textarea",{...x,className:_.t(t.textarea,c,i&&t.touched),onBlur:r.composeEventHandlers(h,u),required:a,style:{...d,"--min-rows":l,"--max-rows":n},value:o})]})};exports.Textarea=T;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,13 +1,13 @@
1
- import { jsxs as x, jsx as r } from "react/jsx-runtime";
2
- import { t as _ } from "../../classix-DG18itHa.js";
1
+ import { jsxs as _, jsx as s } from "react/jsx-runtime";
2
+ import { t as h } from "../../classix-DG18itHa.js";
3
3
  import { u as i, c as p } from "../../use-touched-B999bBr8.js";
4
- import '../../assets/index6.css';const y = "_label_ah8yz_3", b = "_textarea_ah8yz_11", f = "_touched_ah8yz_30", e = {
5
- label: y,
6
- textarea: b,
7
- touched: f
8
- }, w = ({
9
- className: s,
10
- label: t,
4
+ import '../../assets/index6.css';const b = "_label_123ts_3", f = "_textarea_123ts_11", B = "_touched_123ts_30", t = {
5
+ label: b,
6
+ textarea: f,
7
+ touched: B
8
+ }, N = ({
9
+ className: r,
10
+ label: e,
11
11
  maxRows: c = 12,
12
12
  minRows: n = 3,
13
13
  onBlur: l,
@@ -17,12 +17,12 @@ import '../../assets/index6.css';const y = "_label_ah8yz_3", b = "_textarea_ah8y
17
17
  ...m
18
18
  }) => {
19
19
  const {
20
- touched: h,
21
- onBlur: u
20
+ touched: u,
21
+ onBlur: x
22
22
  } = i(o === "");
23
- return /* @__PURE__ */ x("label", { className: e.label, "data-component": "textarea", children: [
24
- t && /* @__PURE__ */ r("span", { "data-required": a || void 0, children: t }),
25
- /* @__PURE__ */ r("textarea", { ...m, className: _(e.textarea, s, h && e.touched), onBlur: p(u, l), required: a, style: {
23
+ return /* @__PURE__ */ _("label", { className: t.label, "data-component": "textarea", children: [
24
+ e && /* @__PURE__ */ s("span", { "data-required": a || void 0, children: e }),
25
+ /* @__PURE__ */ s("textarea", { ...m, className: h(t.textarea, r, u && t.touched), onBlur: p(x, l), required: a, style: {
26
26
  ...d,
27
27
  "--min-rows": n,
28
28
  "--max-rows": c
@@ -30,6 +30,6 @@ import '../../assets/index6.css';const y = "_label_ah8yz_3", b = "_textarea_ah8y
30
30
  ] });
31
31
  };
32
32
  export {
33
- w as Textarea
33
+ N as Textarea
34
34
  };
35
35
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index4.css');const u=require("react/jsx-runtime"),i=require("react"),p=require("../toast/index.cjs"),w="_toasts_7pnpz_1",h={toasts:w},T=({defaultDurationMs:r=5e3,onRemove:m,toasts:n})=>{const d=i.useRef(new Map),[c,l]=i.useState(new Set),a=i.useCallback(e=>{l(s=>s.has(e)?s:new Set(s).add(e))},[]);return i.useEffect(()=>{const e=d.current,s=new Set(n.map(t=>t.id));l(t=>{const o=new Set([...t].filter(f=>s.has(f)));return o.size===t.size?t:o});for(const t of n){if(c.has(t.id)||e.has(t.id))continue;const o=t.durationMs??r;e.set(t.id,window.setTimeout(()=>{a(t.id)},o))}for(const[t,o]of e)s.has(t)&&!c.has(t)||(window.clearTimeout(o),e.delete(t))},[c,r,a,n]),i.useEffect(()=>{const e=d.current;return()=>{for(const s of e.values())window.clearTimeout(s);e.clear()}},[]),n.length?u.jsx("div",{className:h.toasts,"data-component":"toasts",children:n.map(e=>u.jsx(p.Toast,{label:e.label,onClick:()=>a(e.id),onExitComplete:()=>m(e.id),open:!c.has(e.id),type:e.type},e.id))}):null};exports.Toasts=T;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index4.css');const u=require("react/jsx-runtime"),i=require("react"),w=require("../toast/index.cjs"),p="_toasts_i467j_1",h={toasts:p},T=({defaultDurationMs:r=5e3,onRemove:m,toasts:n})=>{const d=i.useRef(new Map),[c,l]=i.useState(new Set),a=i.useCallback(e=>{l(s=>s.has(e)?s:new Set(s).add(e))},[]);return i.useEffect(()=>{const e=d.current,s=new Set(n.map(t=>t.id));l(t=>{const o=new Set([...t].filter(f=>s.has(f)));return o.size===t.size?t:o});for(const t of n){if(c.has(t.id)||e.has(t.id))continue;const o=t.durationMs??r;e.set(t.id,window.setTimeout(()=>{a(t.id)},o))}for(const[t,o]of e)s.has(t)&&!c.has(t)||(window.clearTimeout(o),e.delete(t))},[c,r,a,n]),i.useEffect(()=>{const e=d.current;return()=>{for(const s of e.values())window.clearTimeout(s);e.clear()}},[]),n.length?u.jsx("div",{className:h.toasts,"data-component":"toasts",children:n.map(e=>u.jsx(w.Toast,{label:e.label,onClick:()=>a(e.id),onExitComplete:()=>m(e.id),open:!c.has(e.id),type:e.type},e.id))}):null};exports.Toasts=T;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,20 +1,20 @@
1
1
  import { jsx as l } from "react/jsx-runtime";
2
- import { useRef as u, useState as w, useCallback as h, useEffect as m } from "react";
2
+ import { useRef as p, useState as w, useCallback as h, useEffect as m } from "react";
3
3
  import { Toast as T } from "../toast/index.js";
4
- import '../../assets/index4.css';const v = "_toasts_7pnpz_1", S = {
4
+ import '../../assets/index4.css';const v = "_toasts_i467j_1", S = {
5
5
  toasts: v
6
6
  }, g = ({
7
7
  defaultDurationMs: c = 5e3,
8
8
  onRemove: f,
9
9
  toasts: i
10
10
  }) => {
11
- const r = u(/* @__PURE__ */ new Map()), [n, d] = w(/* @__PURE__ */ new Set()), a = h((e) => {
11
+ const r = p(/* @__PURE__ */ new Map()), [n, d] = w(/* @__PURE__ */ new Set()), a = h((e) => {
12
12
  d((s) => s.has(e) ? s : new Set(s).add(e));
13
13
  }, []);
14
14
  return m(() => {
15
15
  const e = r.current, s = new Set(i.map((t) => t.id));
16
16
  d((t) => {
17
- const o = new Set([...t].filter((p) => s.has(p)));
17
+ const o = new Set([...t].filter((u) => s.has(u)));
18
18
  return o.size === t.size ? t : o;
19
19
  });
20
20
  for (const t of i) {
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index3.css');const t=require("react/jsx-runtime"),i=require("../loading/index.cjs"),g="_toggle_7uv10_1",u="_thumb_7uv10_15",d="_track_7uv10_26",e={toggle:g,thumb:u,track:d},m=({checked:s,disabled:c,isLoading:o,label:n,onChange:a})=>{const l=s!==void 0&&a===void 0;return t.jsxs("label",{className:e.toggle,onClick:r=>r.stopPropagation(),"data-component":"toggle",children:[t.jsx("input",{checked:s,disabled:c||o,onChange:a,readOnly:l,type:"checkbox"}),t.jsx("span",{"aria-hidden":"true",className:e.track,children:o?t.jsx(i.Loading,{size:24}):t.jsx("span",{className:e.thumb})}),n&&t.jsx("span",{className:"toggle",children:n})]})};exports.Toggle=m;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index3.css');const t=require("react/jsx-runtime"),i=require("../loading/index.cjs"),g="_toggle_1cuao_1",u="_thumb_1cuao_10",d="_track_1cuao_21",e={toggle:g,thumb:u,track:d},m=({checked:s,disabled:c,isLoading:o,label:a,onChange:n})=>{const l=s!==void 0&&n===void 0;return t.jsxs("label",{className:e.toggle,onClick:r=>r.stopPropagation(),"data-component":"toggle",children:[t.jsx("input",{checked:s,disabled:c||o,onChange:n,readOnly:l,type:"checkbox"}),t.jsx("span",{"aria-hidden":"true",className:e.track,children:o?t.jsx(i.Loading,{size:24}):t.jsx("span",{className:e.thumb})}),a&&t.jsx("span",{className:"toggle",children:a})]})};exports.Toggle=m;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,20 +1,20 @@
1
1
  import { jsxs as g, jsx as t } from "react/jsx-runtime";
2
2
  import { Loading as i } from "../loading/index.js";
3
- import '../../assets/index3.css';const m = "_toggle_7uv10_1", d = "_thumb_7uv10_15", p = "_track_7uv10_26", o = {
3
+ import '../../assets/index3.css';const m = "_toggle_1cuao_1", d = "_thumb_1cuao_10", p = "_track_1cuao_21", o = {
4
4
  toggle: m,
5
5
  thumb: d,
6
6
  track: p
7
7
  }, h = ({
8
- checked: s,
8
+ checked: a,
9
9
  disabled: l,
10
- isLoading: a,
10
+ isLoading: s,
11
11
  label: e,
12
12
  onChange: c
13
13
  }) => {
14
- const n = s !== void 0 && c === void 0;
14
+ const n = a !== void 0 && c === void 0;
15
15
  return /* @__PURE__ */ g("label", { className: o.toggle, onClick: (r) => r.stopPropagation(), "data-component": "toggle", children: [
16
- /* @__PURE__ */ t("input", { checked: s, disabled: l || a, onChange: c, readOnly: n, type: "checkbox" }),
17
- /* @__PURE__ */ t("span", { "aria-hidden": "true", className: o.track, children: a ? /* @__PURE__ */ t(i, { size: 24 }) : /* @__PURE__ */ t("span", { className: o.thumb }) }),
16
+ /* @__PURE__ */ t("input", { checked: a, disabled: l || s, onChange: c, readOnly: n, type: "checkbox" }),
17
+ /* @__PURE__ */ t("span", { "aria-hidden": "true", className: o.track, children: s ? /* @__PURE__ */ t(i, { size: 24 }) : /* @__PURE__ */ t("span", { className: o.thumb }) }),
18
18
  e && /* @__PURE__ */ t("span", { className: "toggle", children: e })
19
19
  ] });
20
20
  };
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index14.css');const s=require("react/jsx-runtime"),c=require("../../classix-5H4IWnMA.cjs"),a=require("../icon/index.cjs"),t={static:"_static_jn98v_1"},l={default:t.default,static:t.static},r=({variant:o="default",children:i,iconName:e,...n})=>s.jsxs("div",{className:c.t(t.tooltip,l[o]),...n,"data-component":"tooltip",children:[e&&s.jsx(a.Icon,{fill:!0,gap:"right",name:e}),i]});exports.Tooltip=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index14.css');const s=require("react/jsx-runtime"),c=require("../../classix-5H4IWnMA.cjs"),a=require("../icon/index.cjs"),t={static:"_static_r8l1k_1"},l={default:t.default,static:t.static},r=({variant:o="default",children:i,iconName:e,...n})=>s.jsxs("div",{className:c.t(t.tooltip,l[o]),...n,"data-component":"tooltip",children:[e&&s.jsx(a.Icon,{fill:!0,gap:"right",name:e}),i]});exports.Tooltip=r;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -2,7 +2,7 @@ import { jsxs as r, jsx as l } from "react/jsx-runtime";
2
2
  import { t as c } from "../../classix-DG18itHa.js";
3
3
  import { Icon as e } from "../icon/index.js";
4
4
  import '../../assets/index14.css';const t = {
5
- static: "_static_jn98v_1"
5
+ static: "_static_r8l1k_1"
6
6
  }, n = {
7
7
  default: t.default,
8
8
  static: t.static
@@ -1,6 +1,6 @@
1
- import { jsxs as E, Fragment as G, jsx as a } from "react/jsx-runtime";
1
+ import { jsxs as $, Fragment as G, jsx as a } from "react/jsx-runtime";
2
2
  import { t as p } from "./classix-DG18itHa.js";
3
- import { useState as F, useEffect as P } from "react";
3
+ import { useState as E, useEffect as F } from "react";
4
4
  import { i as H } from "./icons-Dj0vEOCB.js";
5
5
  import { u as U, c as W } from "./use-touched-B999bBr8.js";
6
6
  import './assets/index45.css';function k(t) {
@@ -10,7 +10,7 @@ function A(t) {
10
10
  const e = k(t);
11
11
  return e && !e.endsWith(":") ? `${e}:` : e;
12
12
  }
13
- const D = "_input_151j9_3", J = "_touched_151j9_43", K = "_label_151j9_48", M = "_inline_151j9_57", O = "_code_151j9_86", o = {
13
+ const D = "_input_p0mz8_3", J = "_touched_p0mz8_43", K = "_label_p0mz8_48", M = "_inline_p0mz8_69", O = "_code_p0mz8_86", o = {
14
14
  input: D,
15
15
  touched: J,
16
16
  label: K,
@@ -22,30 +22,30 @@ function q({
22
22
  defaultCountryCode: e = "+47",
23
23
  disabled: c = !1,
24
24
  icon: _,
25
- label: d,
26
- onBlur: S,
25
+ label: m,
26
+ onBlur: P,
27
27
  placeholder: f,
28
28
  ref: g,
29
- required: m,
29
+ required: d,
30
30
  style: v,
31
31
  type: n = "text",
32
- variant: j = "default",
33
- ...x
32
+ variant: x = "default",
33
+ ...z
34
34
  }) {
35
- const [h, L] = F(""), [s, b] = F(""), {
35
+ const [h, L] = E(""), [s, b] = E(""), {
36
36
  name: B,
37
37
  onChange: l,
38
- pattern: T,
38
+ pattern: S,
39
39
  value: r,
40
- ...V
41
- } = x, {
40
+ ...T
41
+ } = z, {
42
42
  touched: I,
43
- onBlur: w
44
- } = U(r === ""), u = _ && n !== "radio" && n !== "datetime-local" ? _ : void 0, N = d && j === "inline" ? A(d) : d, C = u ? {
43
+ onBlur: V
44
+ } = U(r === ""), u = _ && n !== "radio" && n !== "datetime-local" ? _ : void 0, N = m && x === "inline" ? A(m) : m, j = u ? {
45
45
  ...v,
46
46
  "--icon-svg": H(u, !0)
47
- } : v, $ = W(w, S);
48
- P(() => {
47
+ } : v, C = W(V, P);
48
+ F(() => {
49
49
  if (l && n === "tel") {
50
50
  const i = {
51
51
  name: B,
@@ -56,21 +56,21 @@ function q({
56
56
  currentTarget: i
57
57
  });
58
58
  }
59
- }, [h, e, B, l, s, n]), P(() => {
59
+ }, [h, e, B, l, s, n]), F(() => {
60
60
  n === "tel" && !r && (b(""), L(""));
61
61
  }, [n, r]);
62
- const z = /* @__PURE__ */ E(G, { children: [
62
+ const w = /* @__PURE__ */ $(G, { children: [
63
63
  /* @__PURE__ */ a("input", { disabled: c, hidden: !0, onChange: l, pattern: void 0, placeholder: f, ref: g, type: n, value: r }),
64
64
  /* @__PURE__ */ a("input", { type: "text", className: p(o.code, o.input), disabled: c, maxLength: 5, onChange: (i) => L(i.target.value), placeholder: e, value: h }),
65
- /* @__PURE__ */ a("input", { ...V, type: "tel", className: p(o.input, t, I && o.touched), "data-icon": u ? "true" : void 0, disabled: c, maxLength: 14, name: void 0, onChange: (i) => b(i.target.value), onBlur: $, pattern: T, required: m, style: C, value: s })
65
+ /* @__PURE__ */ a("input", { ...T, type: "tel", className: p(o.input, t, I && o.touched), "data-icon": u ? "true" : void 0, disabled: c, maxLength: 14, name: void 0, onChange: (i) => b(i.target.value), onBlur: C, pattern: S, required: d, style: j, value: s })
66
66
  ] });
67
- return /* @__PURE__ */ E("label", { className: p(o.label, j === "inline" && o.inline), "data-component": "input", children: [
68
- N && /* @__PURE__ */ a("span", { "data-required": m || void 0, children: N }),
69
- n === "tel" ? z : /* @__PURE__ */ a("input", { ...x, ref: g, className: p(o.input, t, I && o.touched), "data-icon": u ? "true" : void 0, disabled: c, onBlur: $, placeholder: f, required: m, style: C, type: n })
67
+ return /* @__PURE__ */ $("label", { className: p(o.label, x === "inline" && o.inline), "data-component": "input", children: [
68
+ N && /* @__PURE__ */ a("span", { "data-required": d || void 0, children: N }),
69
+ n === "tel" ? w : /* @__PURE__ */ a("input", { ...z, ref: g, className: p(o.input, t, I && o.touched), "data-icon": u ? "true" : void 0, disabled: c, onBlur: C, placeholder: f, required: d, style: j, type: n })
70
70
  ] });
71
71
  }
72
72
  export {
73
73
  q as I,
74
74
  A as f
75
75
  };
76
- //# sourceMappingURL=index-DE2nzqL5.js.map
76
+ //# sourceMappingURL=index-BIV5OwVJ.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-DE2nzqL5.js","sources":["../src/lib/text.ts","../src/components/input/index.tsx"],"sourcesContent":["export function capitalizeFirstLetter(value: string): string {\n return value ? `${value[0].toLocaleUpperCase()}${value.slice(1)}` : value;\n}\n\nexport function formatInlineLabel(value: string): string {\n const label = capitalizeFirstLetter(value);\n return label && !label.endsWith(':') ? `${label}:` : label;\n}\n","import cx from 'classix';\nimport { useEffect, useState } from 'react';\n\nimport { IconName, iconSVG } from '@/components/icon/icons.ts';\nimport { composeEventHandlers } from '@/lib/compose-event-handlers';\nimport { formatInlineLabel } from '@/lib/text';\nimport { useTouched } from '@/lib/use-touched';\n\nimport styles from './styles.module.css';\n\nexport type InputProps = React.ComponentPropsWithRef<'input'> & {\n defaultCountryCode?: string;\n disabled?: boolean;\n icon?: IconName;\n label?: string;\n onClick?: React.MouseEventHandler<HTMLInputElement>;\n placeholder?: string;\n variant?: 'default' | 'inline';\n type?:\n | 'date'\n | 'datetime-local'\n | 'email'\n | 'number'\n | 'password'\n | 'radio'\n | 'search'\n | 'tel'\n | 'text';\n};\n\nexport function Input({\n className,\n defaultCountryCode = '+47',\n disabled = false,\n icon,\n label,\n onBlur: onBlurProp,\n placeholder,\n ref,\n required,\n style,\n type = 'text',\n variant = 'default',\n ...props\n}: InputProps) {\n const [countryCode, setCountryCode] = useState('');\n const [phoneNumber, setPhoneNumber] = useState('');\n const { name, onChange, pattern, value, ...restProps } = props;\n const { touched, onBlur } = useTouched(value === '');\n const inputIcon = icon && type !== 'radio' && type !== 'datetime-local' ? icon : undefined;\n const displayLabel = label && variant === 'inline' ? formatInlineLabel(label) : label;\n\n type withVars =\n | (React.CSSProperties & {\n '--icon-svg'?: string;\n })\n | undefined;\n\n const withVars: withVars = inputIcon\n ? {\n ...style,\n '--icon-svg': iconSVG(inputIcon, true),\n }\n : style;\n const handleBlur = composeEventHandlers(onBlur, onBlurProp);\n\n useEffect(() => {\n if (onChange && type === 'tel') {\n const target = {\n name,\n value: phoneNumber\n ? (countryCode || defaultCountryCode).split(' ').join('') +\n phoneNumber.split(' ').join('')\n : undefined,\n } as unknown as HTMLInputElement;\n\n onChange({ target, currentTarget: target } as React.ChangeEvent<HTMLInputElement>);\n }\n }, [countryCode, defaultCountryCode, name, onChange, phoneNumber, type]);\n\n useEffect(() => {\n if (type === 'tel' && !value) {\n setPhoneNumber('');\n setCountryCode('');\n }\n }, [type, value]);\n\n const telephoneInput = (\n <>\n <input\n disabled={disabled}\n hidden\n onChange={onChange}\n pattern={undefined}\n placeholder={placeholder}\n ref={ref}\n type={type}\n value={value}\n />\n <input\n type='text'\n className={cx(styles.code, styles.input)}\n disabled={disabled}\n maxLength={5}\n onChange={(e) => setCountryCode(e.target.value)}\n placeholder={defaultCountryCode}\n value={countryCode}\n />\n <input\n {...restProps}\n type='tel'\n className={cx(styles.input, className, touched && styles.touched)}\n data-icon={inputIcon ? 'true' : undefined}\n disabled={disabled}\n maxLength={14}\n name={undefined}\n onChange={(e) => setPhoneNumber(e.target.value)}\n onBlur={handleBlur}\n pattern={pattern}\n required={required}\n style={withVars}\n value={phoneNumber}\n />\n </>\n );\n\n return (\n <label className={cx(styles.label, variant === 'inline' && styles.inline)}>\n {displayLabel && <span data-required={required || undefined}>{displayLabel}</span>}\n {type === 'tel' ? (\n telephoneInput\n ) : (\n <input\n {...props}\n ref={ref}\n className={cx(styles.input, className, touched && styles.touched)}\n data-icon={inputIcon ? 'true' : undefined}\n disabled={disabled}\n onBlur={handleBlur}\n placeholder={placeholder}\n required={required}\n style={withVars}\n type={type}\n />\n )}\n </label>\n );\n}\n"],"names":["capitalizeFirstLetter","value","toLocaleUpperCase","slice","formatInlineLabel","label","endsWith","Input","className","defaultCountryCode","disabled","icon","onBlur","onBlurProp","placeholder","ref","required","style","type","variant","props","countryCode","setCountryCode","useState","phoneNumber","setPhoneNumber","name","onChange","pattern","restProps","touched","useTouched","inputIcon","undefined","displayLabel","withVars","iconSVG","handleBlur","composeEventHandlers","useEffect","target","split","join","currentTarget","telephoneInput","jsxs","Fragment","jsx","cx","styles","code","input","e","inline"],"mappings":";;;;;AAAO,SAASA,EAAsBC,GAAuB;AAC3D,SAAOA,KAAQ,GAAGA,EAAM,CAAC,EAAEC,mBAAmB,GAAGD,EAAME,MAAM,CAAC,CAAC;AACjE;AAEO,SAAS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SACvEnB,UAAAA;AAAAA,IAAAA,KAAgB,gBAAAa,EAAC,QAAA,EAAK,iBAAe/B,KAAYiB,QAAYC,UAAAA,GAAa;AAAA,IAC1EhB,MAAS,QACR0B,IAEA,gBAAAG,EAAC,SAAA,EACC,GAAI3B,GACJ,KAAAL,GACA,WAAWiC,EAAGC,EAAOE,OAAO3C,GAAWsB,KAAWmB,EAAOnB,OAAO,GAChE,aAAWE,IAAY,SAASC,QAChC,UAAAvB,GACA,QAAQ2B,GACR,aAAAvB,GACA,UAAAE,GACA,OAAOmB,GACP,MAAAjB,EAAA,CAAW;AAAA,EAAA,GAGjB;AAEJ;"}
1
+ {"version":3,"file":"index-BIV5OwVJ.js","sources":["../src/lib/text.ts","../src/components/input/index.tsx"],"sourcesContent":["export function capitalizeFirstLetter(value: string): string {\n return value ? `${value[0].toLocaleUpperCase()}${value.slice(1)}` : value;\n}\n\nexport function formatInlineLabel(value: string): string {\n const label = capitalizeFirstLetter(value);\n return label && !label.endsWith(':') ? `${label}:` : label;\n}\n","import cx from 'classix';\nimport { useEffect, useState } from 'react';\n\nimport { IconName, iconSVG } from '@/components/icon/icons.ts';\nimport { composeEventHandlers } from '@/lib/compose-event-handlers';\nimport { formatInlineLabel } from '@/lib/text';\nimport { useTouched } from '@/lib/use-touched';\n\nimport styles from './styles.module.css';\n\nexport type InputProps = React.ComponentPropsWithRef<'input'> & {\n defaultCountryCode?: string;\n disabled?: boolean;\n icon?: IconName;\n label?: string;\n onClick?: React.MouseEventHandler<HTMLInputElement>;\n placeholder?: string;\n variant?: 'default' | 'inline';\n type?:\n | 'date'\n | 'datetime-local'\n | 'email'\n | 'number'\n | 'password'\n | 'radio'\n | 'search'\n | 'tel'\n | 'text';\n};\n\nexport function Input({\n className,\n defaultCountryCode = '+47',\n disabled = false,\n icon,\n label,\n onBlur: onBlurProp,\n placeholder,\n ref,\n required,\n style,\n type = 'text',\n variant = 'default',\n ...props\n}: InputProps) {\n const [countryCode, setCountryCode] = useState('');\n const [phoneNumber, setPhoneNumber] = useState('');\n const { name, onChange, pattern, value, ...restProps } = props;\n const { touched, onBlur } = useTouched(value === '');\n const inputIcon = icon && type !== 'radio' && type !== 'datetime-local' ? icon : undefined;\n const displayLabel = label && variant === 'inline' ? formatInlineLabel(label) : label;\n\n type withVars =\n | (React.CSSProperties & {\n '--icon-svg'?: string;\n })\n | undefined;\n\n const withVars: withVars = inputIcon\n ? {\n ...style,\n '--icon-svg': iconSVG(inputIcon, true),\n }\n : style;\n const handleBlur = composeEventHandlers(onBlur, onBlurProp);\n\n useEffect(() => {\n if (onChange && type === 'tel') {\n const target = {\n name,\n value: phoneNumber\n ? (countryCode || defaultCountryCode).split(' ').join('') +\n phoneNumber.split(' ').join('')\n : undefined,\n } as unknown as HTMLInputElement;\n\n onChange({ target, currentTarget: target } as React.ChangeEvent<HTMLInputElement>);\n }\n }, [countryCode, defaultCountryCode, name, onChange, phoneNumber, type]);\n\n useEffect(() => {\n if (type === 'tel' && !value) {\n setPhoneNumber('');\n setCountryCode('');\n }\n }, [type, value]);\n\n const telephoneInput = (\n <>\n <input\n disabled={disabled}\n hidden\n onChange={onChange}\n pattern={undefined}\n placeholder={placeholder}\n ref={ref}\n type={type}\n value={value}\n />\n <input\n type='text'\n className={cx(styles.code, styles.input)}\n disabled={disabled}\n maxLength={5}\n onChange={(e) => setCountryCode(e.target.value)}\n placeholder={defaultCountryCode}\n value={countryCode}\n />\n <input\n {...restProps}\n type='tel'\n className={cx(styles.input, className, touched && styles.touched)}\n data-icon={inputIcon ? 'true' : undefined}\n disabled={disabled}\n maxLength={14}\n name={undefined}\n onChange={(e) => setPhoneNumber(e.target.value)}\n onBlur={handleBlur}\n pattern={pattern}\n required={required}\n style={withVars}\n value={phoneNumber}\n />\n </>\n );\n\n return (\n <label className={cx(styles.label, variant === 'inline' && styles.inline)}>\n {displayLabel && <span data-required={required || undefined}>{displayLabel}</span>}\n {type === 'tel' ? (\n telephoneInput\n ) : (\n <input\n {...props}\n ref={ref}\n className={cx(styles.input, className, touched && styles.touched)}\n data-icon={inputIcon ? 'true' : undefined}\n disabled={disabled}\n onBlur={handleBlur}\n placeholder={placeholder}\n required={required}\n style={withVars}\n type={type}\n />\n )}\n </label>\n );\n}\n"],"names":["capitalizeFirstLetter","value","toLocaleUpperCase","slice","formatInlineLabel","label","endsWith","Input","className","defaultCountryCode","disabled","icon","onBlur","onBlurProp","placeholder","ref","required","style","type","variant","props","countryCode","setCountryCode","useState","phoneNumber","setPhoneNumber","name","onChange","pattern","restProps","touched","useTouched","inputIcon","undefined","displayLabel","withVars","iconSVG","handleBlur","composeEventHandlers","useEffect","target","split","join","currentTarget","telephoneInput","jsxs","Fragment","jsx","cx","styles","code","input","e","inline"],"mappings":";;;;;AAAO,SAASA,EAAsBC,GAAuB;AAC3D,SAAOA,KAAQ,GAAGA,EAAM,CAAC,EAAEC,mBAAmB,GAAGD,EAAME,MAAM,CAAC,CAAC;AACjE;AAEO,SAASC,EAAkBH,GAAuB;AACvD,QAAMI,IAAQL,EAAsBC,CAAK;AACzC,SAAOI,KAAS,CAACA,EAAMC,SAAS,GAAG,IAAI,GAAGD,CAAK,MAAMA;AACvD;;;;;;;;ACuBO,SAASE,EAAM;AAAA,EACpBC,WAAAA;AAAAA,EACAC,oBAAAA,IAAqB;AAAA,EACrBC,UAAAA,IAAW;AAAA,EACXC,MAAAA;AAAAA,EACAN,OAAAA;AAAAA,EACAO,QAAQC;AAAAA,EACRC,aAAAA;AAAAA,EACAC,KAAAA;AAAAA,EACAC,UAAAA;AAAAA,EACAC,OAAAA;AAAAA,EACAC,MAAAA,IAAO;AAAA,EACPC,SAAAA,IAAU;AAAA,EACV,GAAGC;AACO,GAAG;AACb,QAAM,CAACC,GAAaC,CAAc,IAAIC,EAAS,EAAE,GAC3C,CAACC,GAAaC,CAAc,IAAIF,EAAS,EAAE,GAC3C;AAAA,IAAEG,MAAAA;AAAAA,IAAMC,UAAAA;AAAAA,IAAUC,SAAAA;AAAAA,IAAS3B,OAAAA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MD,EAAOE,KAAK,GACvC,UAAAzC,GACA,WAAW,GACX,UAAW0C,CAAAA,MAAM9B,EAAe8B,EAAEZ,OAAOvC,KAAK,GAC9C,aAAaQ,GACb,OAAOY,EAAAA,CAAY;AAAA,sBAEpB,SAAA,EACC,GAAIQ,GACJ,MAAK,OACL,WAAWmB,EAAGC,EAAOE,OAAO3C,GAAWsB,KAAWmB,EAAOnB,OAAO,GAChE,aAAWE,IAAY,SAASC,QAChC,UAAAvB,GACA,WAAW,IACX,MAAMuB,QACN,UAAWmB,CAAAA,MAAM3B,EAAe2B,EAAEZ,OAAOvC,KAAK,GAC9C,QAAQoC,GACR,SAAAT,GACA,UAAAZ,GACA,OAAOmB,GACP,OAAOX,EAAAA,CAAY;AAAA,EAAA,GAEvB;AAGF,SACE,gBAAAqB,EAAC,SAAA,EAAM,WAAWG,EAAGC,EAAO5C,OAAOc,MAAY,YAAY8B,EAAOI,MAAM,GAAE,kBAAA,SACvEnB,UAAAA;AAAAA,IAAAA,KAAgB,gBAAAa,EAAC,QAAA,EAAK,iBAAe/B,KAAYiB,QAAYC,UAAAA,GAAa;AAAA,IAC1EhB,MAAS,QACR0B,IAEA,gBAAAG,EAAC,SAAA,EACC,GAAI3B,GACJ,KAAAL,GACA,WAAWiC,EAAGC,EAAOE,OAAO3C,GAAWsB,KAAWmB,EAAOnB,OAAO,GAChE,aAAWE,IAAY,SAASC,QAChC,UAAAvB,GACA,QAAQ2B,GACR,aAAAvB,GACA,UAAAE,GACA,OAAOmB,GACP,MAAAjB,EAAA,CAAW;AAAA,EAAA,GAGjB;AAEJ;"}
@@ -0,0 +1,2 @@
1
+ "use strict";require('./assets/index45.css');const o=require("react/jsx-runtime"),d=require("./classix-5H4IWnMA.cjs"),p=require("react"),V=require("./icons-DaZGJzI0.cjs"),E=require("./use-touched-Bq5Gjbpz.cjs");function w(t){return t&&`${t[0].toLocaleUpperCase()}${t.slice(1)}`}function S(t){const n=w(t);return n&&!n.endsWith(":")?`${n}:`:n}const G="_input_p0mz8_3",H="_touched_p0mz8_43",U="_label_p0mz8_48",W="_inline_p0mz8_69",k="_code_p0mz8_86",s={input:G,touched:H,label:U,inline:W,code:k};function A({className:t,defaultCountryCode:n="+47",disabled:c=!1,icon:x,label:h,onBlur:T,placeholder:g,ref:v,required:m,style:f,type:e="text",variant:j="default",...L}){const[_,b]=p.useState(""),[u,z]=p.useState(""),{name:I,onChange:a,pattern:$,value:l,...F}=L,{touched:B,onBlur:P}=E.useTouched(l===""),r=x&&e!=="radio"&&e!=="datetime-local"?x:void 0,N=h&&j==="inline"?S(h):h,q=r?{...f,"--icon-svg":V.iconSVG(r,!0)}:f,C=E.composeEventHandlers(P,T);p.useEffect(()=>{if(a&&e==="tel"){const i={name:I,value:u?(_||n).split(" ").join("")+u.split(" ").join(""):void 0};a({target:i,currentTarget:i})}},[_,n,I,a,u,e]),p.useEffect(()=>{e==="tel"&&!l&&(z(""),b(""))},[e,l]);const R=o.jsxs(o.Fragment,{children:[o.jsx("input",{disabled:c,hidden:!0,onChange:a,pattern:void 0,placeholder:g,ref:v,type:e,value:l}),o.jsx("input",{type:"text",className:d.t(s.code,s.input),disabled:c,maxLength:5,onChange:i=>b(i.target.value),placeholder:n,value:_}),o.jsx("input",{...F,type:"tel",className:d.t(s.input,t,B&&s.touched),"data-icon":r?"true":void 0,disabled:c,maxLength:14,name:void 0,onChange:i=>z(i.target.value),onBlur:C,pattern:$,required:m,style:q,value:u})]});return o.jsxs("label",{className:d.t(s.label,j==="inline"&&s.inline),"data-component":"input",children:[N&&o.jsx("span",{"data-required":m||void 0,children:N}),e==="tel"?R:o.jsx("input",{...L,ref:v,className:d.t(s.input,t,B&&s.touched),"data-icon":r?"true":void 0,disabled:c,onBlur:C,placeholder:g,required:m,style:q,type:e})]})}exports.Input=A;exports.formatInlineLabel=S;
2
+ //# sourceMappingURL=index-CQNlYa2P.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-DF8JisYI.cjs","sources":["../src/lib/text.ts","../src/components/input/index.tsx"],"sourcesContent":["export function capitalizeFirstLetter(value: string): string {\n return value ? `${value[0].toLocaleUpperCase()}${value.slice(1)}` : value;\n}\n\nexport function formatInlineLabel(value: string): string {\n const label = capitalizeFirstLetter(value);\n return label && !label.endsWith(':') ? `${label}:` : label;\n}\n","import cx from 'classix';\nimport { useEffect, useState } from 'react';\n\nimport { IconName, iconSVG } from '@/components/icon/icons.ts';\nimport { composeEventHandlers } from '@/lib/compose-event-handlers';\nimport { formatInlineLabel } from '@/lib/text';\nimport { useTouched } from '@/lib/use-touched';\n\nimport styles from './styles.module.css';\n\nexport type InputProps = React.ComponentPropsWithRef<'input'> & {\n defaultCountryCode?: string;\n disabled?: boolean;\n icon?: IconName;\n label?: string;\n onClick?: React.MouseEventHandler<HTMLInputElement>;\n placeholder?: string;\n variant?: 'default' | 'inline';\n type?:\n | 'date'\n | 'datetime-local'\n | 'email'\n | 'number'\n | 'password'\n | 'radio'\n | 'search'\n | 'tel'\n | 'text';\n};\n\nexport function Input({\n className,\n defaultCountryCode = '+47',\n disabled = false,\n icon,\n label,\n onBlur: onBlurProp,\n placeholder,\n ref,\n required,\n style,\n type = 'text',\n variant = 'default',\n ...props\n}: InputProps) {\n const [countryCode, setCountryCode] = useState('');\n const [phoneNumber, setPhoneNumber] = useState('');\n const { name, onChange, pattern, value, ...restProps } = props;\n const { touched, onBlur } = useTouched(value === '');\n const inputIcon = icon && type !== 'radio' && type !== 'datetime-local' ? icon : undefined;\n const displayLabel = label && variant === 'inline' ? formatInlineLabel(label) : label;\n\n type withVars =\n | (React.CSSProperties & {\n '--icon-svg'?: string;\n })\n | undefined;\n\n const withVars: withVars = inputIcon\n ? {\n ...style,\n '--icon-svg': iconSVG(inputIcon, true),\n }\n : style;\n const handleBlur = composeEventHandlers(onBlur, onBlurProp);\n\n useEffect(() => {\n if (onChange && type === 'tel') {\n const target = {\n name,\n value: phoneNumber\n ? (countryCode || defaultCountryCode).split(' ').join('') +\n phoneNumber.split(' ').join('')\n : undefined,\n } as unknown as HTMLInputElement;\n\n onChange({ target, currentTarget: target } as React.ChangeEvent<HTMLInputElement>);\n }\n }, [countryCode, defaultCountryCode, name, onChange, phoneNumber, type]);\n\n useEffect(() => {\n if (type === 'tel' && !value) {\n setPhoneNumber('');\n setCountryCode('');\n }\n }, [type, value]);\n\n const telephoneInput = (\n <>\n <input\n disabled={disabled}\n hidden\n onChange={onChange}\n pattern={undefined}\n placeholder={placeholder}\n ref={ref}\n type={type}\n value={value}\n />\n <input\n type='text'\n className={cx(styles.code, styles.input)}\n disabled={disabled}\n maxLength={5}\n onChange={(e) => setCountryCode(e.target.value)}\n placeholder={defaultCountryCode}\n value={countryCode}\n />\n <input\n {...restProps}\n type='tel'\n className={cx(styles.input, className, touched && styles.touched)}\n data-icon={inputIcon ? 'true' : undefined}\n disabled={disabled}\n maxLength={14}\n name={undefined}\n onChange={(e) => setPhoneNumber(e.target.value)}\n onBlur={handleBlur}\n pattern={pattern}\n required={required}\n style={withVars}\n value={phoneNumber}\n />\n </>\n );\n\n return (\n <label className={cx(styles.label, variant === 'inline' && styles.inline)}>\n {displayLabel && <span data-required={required || undefined}>{displayLabel}</span>}\n {type === 'tel' ? (\n telephoneInput\n ) : (\n <input\n {...props}\n ref={ref}\n className={cx(styles.input, className, touched && styles.touched)}\n data-icon={inputIcon ? 'true' : undefined}\n disabled={disabled}\n onBlur={handleBlur}\n placeholder={placeholder}\n required={required}\n style={withVars}\n type={type}\n />\n )}\n </label>\n );\n}\n"],"names":["capitalizeFirstLetter","value","toLocaleUpperCase","slice","formatInlineLabel","label","endsWith","Input","className","defaultCountryCode","disabled","icon","onBlur","onBlurProp","placeholder","ref","required","style","type","variant","props","countryCode","setCountryCode","useState","phoneNumber","setPhoneNumber","name","onChange","pattern","restProps","touched","useTouched","inputIcon","undefined","displayLabel","withVars","iconSVG","handleBlur","composeEventHandlers","useEffect","target","split","join","currentTarget","telephoneInput","jsxs","Fragment","jsx","cx","styles","code","input","e","inline"],"mappings":"m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a,EAC1EhB,IAAS,MACR0B,EAEAG,EAAAA,IAAC,QAAA,CACC,GAAI3B,EACJ,IAAAL,EACA,UAAWiC,EAAAA,EAAGC,EAAOE,MAAO3C,EAAWsB,GAAWmB,EAAOnB,OAAO,EAChE,YAAWE,EAAY,OAASC,OAChC,SAAAvB,EACA,OAAQ2B,EACR,YAAAvB,EACA,SAAAE,EACA,MAAOmB,EACP,KAAAjB,CAAA,CAAW,CAAA,EAGjB,CAEJ"}
1
+ {"version":3,"file":"index-CQNlYa2P.cjs","sources":["../src/lib/text.ts","../src/components/input/index.tsx"],"sourcesContent":["export function capitalizeFirstLetter(value: string): string {\n return value ? `${value[0].toLocaleUpperCase()}${value.slice(1)}` : value;\n}\n\nexport function formatInlineLabel(value: string): string {\n const label = capitalizeFirstLetter(value);\n return label && !label.endsWith(':') ? `${label}:` : label;\n}\n","import cx from 'classix';\nimport { useEffect, useState } from 'react';\n\nimport { IconName, iconSVG } from '@/components/icon/icons.ts';\nimport { composeEventHandlers } from '@/lib/compose-event-handlers';\nimport { formatInlineLabel } from '@/lib/text';\nimport { useTouched } from '@/lib/use-touched';\n\nimport styles from './styles.module.css';\n\nexport type InputProps = React.ComponentPropsWithRef<'input'> & {\n defaultCountryCode?: string;\n disabled?: boolean;\n icon?: IconName;\n label?: string;\n onClick?: React.MouseEventHandler<HTMLInputElement>;\n placeholder?: string;\n variant?: 'default' | 'inline';\n type?:\n | 'date'\n | 'datetime-local'\n | 'email'\n | 'number'\n | 'password'\n | 'radio'\n | 'search'\n | 'tel'\n | 'text';\n};\n\nexport function Input({\n className,\n defaultCountryCode = '+47',\n disabled = false,\n icon,\n label,\n onBlur: onBlurProp,\n placeholder,\n ref,\n required,\n style,\n type = 'text',\n variant = 'default',\n ...props\n}: InputProps) {\n const [countryCode, setCountryCode] = useState('');\n const [phoneNumber, setPhoneNumber] = useState('');\n const { name, onChange, pattern, value, ...restProps } = props;\n const { touched, onBlur } = useTouched(value === '');\n const inputIcon = icon && type !== 'radio' && type !== 'datetime-local' ? icon : undefined;\n const displayLabel = label && variant === 'inline' ? formatInlineLabel(label) : label;\n\n type withVars =\n | (React.CSSProperties & {\n '--icon-svg'?: string;\n })\n | undefined;\n\n const withVars: withVars = inputIcon\n ? {\n ...style,\n '--icon-svg': iconSVG(inputIcon, true),\n }\n : style;\n const handleBlur = composeEventHandlers(onBlur, onBlurProp);\n\n useEffect(() => {\n if (onChange && type === 'tel') {\n const target = {\n name,\n value: phoneNumber\n ? (countryCode || defaultCountryCode).split(' ').join('') +\n phoneNumber.split(' ').join('')\n : undefined,\n } as unknown as HTMLInputElement;\n\n onChange({ target, currentTarget: target } as React.ChangeEvent<HTMLInputElement>);\n }\n }, [countryCode, defaultCountryCode, name, onChange, phoneNumber, type]);\n\n useEffect(() => {\n if (type === 'tel' && !value) {\n setPhoneNumber('');\n setCountryCode('');\n }\n }, [type, value]);\n\n const telephoneInput = (\n <>\n <input\n disabled={disabled}\n hidden\n onChange={onChange}\n pattern={undefined}\n placeholder={placeholder}\n ref={ref}\n type={type}\n value={value}\n />\n <input\n type='text'\n className={cx(styles.code, styles.input)}\n disabled={disabled}\n maxLength={5}\n onChange={(e) => setCountryCode(e.target.value)}\n placeholder={defaultCountryCode}\n value={countryCode}\n />\n <input\n {...restProps}\n type='tel'\n className={cx(styles.input, className, touched && styles.touched)}\n data-icon={inputIcon ? 'true' : undefined}\n disabled={disabled}\n maxLength={14}\n name={undefined}\n onChange={(e) => setPhoneNumber(e.target.value)}\n onBlur={handleBlur}\n pattern={pattern}\n required={required}\n style={withVars}\n value={phoneNumber}\n />\n </>\n );\n\n return (\n <label className={cx(styles.label, variant === 'inline' && styles.inline)}>\n {displayLabel && <span data-required={required || undefined}>{displayLabel}</span>}\n {type === 'tel' ? (\n telephoneInput\n ) : (\n <input\n {...props}\n ref={ref}\n className={cx(styles.input, className, touched && styles.touched)}\n data-icon={inputIcon ? 'true' : undefined}\n disabled={disabled}\n onBlur={handleBlur}\n placeholder={placeholder}\n required={required}\n style={withVars}\n type={type}\n />\n )}\n </label>\n );\n}\n"],"names":["capitalizeFirstLetter","value","toLocaleUpperCase","slice","formatInlineLabel","label","endsWith","Input","className","defaultCountryCode","disabled","icon","onBlur","onBlurProp","placeholder","ref","required","style","type","variant","props","countryCode","setCountryCode","useState","phoneNumber","setPhoneNumber","name","onChange","pattern","restProps","touched","useTouched","inputIcon","undefined","displayLabel","withVars","iconSVG","handleBlur","composeEventHandlers","useEffect","target","split","join","currentTarget","telephoneInput","jsxs","Fragment","jsx","cx","styles","code","input","e","inline"],"mappings":"mLAAO,SAASA,EAAsBC,EAAuB,CAC3D,OAAOA,GAAQ,GAAGA,EAAM,CAAC,EAAEC,mBAAmB,GAAGD,EAAME,MAAM,CAAC,CAAC,EACjE,CAEO,SAASC,EAAkBH,EAAuB,CACvD,MAAMI,EAAQL,EAAsBC,CAAK,EACzC,OAAOI,GAAS,CAACA,EAAMC,SAAS,GAAG,EAAI,GAAGD,CAAK,IAAMA,CACvD,0JCuBO,SAASE,EAAM,CACpBC,UAAAA,EACAC,mBAAAA,EAAqB,MACrBC,SAAAA,EAAW,GACXC,KAAAA,EACAN,MAAAA,EACAO,OAAQC,EACRC,YAAAA,EACAC,IAAAA,EACAC,SAAAA,EACAC,MAAAA,EACAC,KAAAA,EAAO,OACPC,QAAAA,EAAU,UACV,GAAGC,CACO,EAAG,CACb,KAAM,CAACC,EAAaC,CAAc,EAAIC,EAAAA,SAAS,EAAE,EAC3C,CAACC,EAAaC,CAAc,EAAIF,EAAAA,SAAS,EAAE,EAC3C,CAAEG,KAAAA,EAAMC,SAAAA,EAAUC,QAAAA,EAAS3B,MAAAA,EAAO,GAAG4B,CAAAA,EAAcT,EACnD,CAAEU,QAAAA,EAASlB,OAAAA,CAAAA,EAAWmB,EAAAA,WAAW9B,IAAU,EAAE,EAC7C+B,EAAYrB,GAAQO,IAAS,SAAWA,IAAS,iBAAmBP,EAAOsB,OAC3EC,EAAe7B,GAASc,IAAY,SAAWf,EAAkBC,C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AAWmB,GAAM3B,EAAe2B,EAAEZ,OAAOvC,KAAK,EAC9C,OAAQoC,EACR,QAAAT,EACA,SAAAZ,EACA,MAAOmB,EACP,MAAOX,CAAAA,CAAY,CAAA,EAEvB,EAGF,OACEqB,EAAAA,KAAC,QAAA,CAAM,UAAWG,EAAAA,EAAGC,EAAO5C,MAAOc,IAAY,UAAY8B,EAAOI,MAAM,EAAE,iBAAA,QACvEnB,SAAAA,CAAAA,GAAgBa,EAAAA,IAAC,OAAA,CAAK,gBAAe/B,GAAYiB,OAAYC,SAAAA,EAAa,EAC1EhB,IAAS,MACR0B,EAEAG,EAAAA,IAAC,QAAA,CACC,GAAI3B,EACJ,IAAAL,EACA,UAAWiC,EAAAA,EAAGC,EAAOE,MAAO3C,EAAWsB,GAAWmB,EAAOnB,OAAO,EAChE,YAAWE,EAAY,OAASC,OAChC,SAAAvB,EACA,OAAQ2B,EACR,YAAAvB,EACA,SAAAE,EACA,MAAOmB,EACP,KAAAjB,CAAA,CAAW,CAAA,EAGjB,CAEJ"}
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./assets/index.css');const o=require("./components/app-link/index.cjs"),t=require("./components/aside/index.cjs"),r=require("./components/avatar/index.cjs"),i=require("./components/badge/index.cjs"),s=require("./components/banner/index.cjs"),c=require("./components/branding/index.cjs"),_=require("./components/button/index.cjs"),p=require("./components/card/index.cjs"),a=require("./components/checkbox/index.cjs"),d=require("./components/chip/index.cjs"),u=require("./components/collapsible/index.cjs"),m=require("./components/controls/index.cjs"),l=require("./components/croppable/index.cjs"),x=require("./components/dialog/index.cjs"),q=require("./components/dropdown/index.cjs"),g=require("./components/dropzone/index.cjs"),b=require("./components/editor/index.cjs"),T=require("./components/empty-state/index.cjs"),h=require("./components/fieldset/index.cjs"),S=require("./components/figure/index.cjs"),v=require("./components/file/index.cjs"),C=require("./components/footer/index.cjs"),L=require("./components/form/index.cjs"),F=require("./components/graph/index.cjs"),I=require("./components/group/index.cjs"),f=require("./components/header/index.cjs"),k=require("./components/icon/index.cjs"),B=require("./components/iframe/index.cjs"),M=require("./components/image/index.cjs"),A=require("./index-DF8JisYI.cjs"),D=require("./components/link/index.cjs"),y=require("./components/list/index.cjs"),O=require("./components/loading/index.cjs"),P=require("./components/menu/index.cjs"),j=require("./components/message/index.cjs"),w=require("./components/messages/index.cjs"),e=require("./components/nav/index.cjs"),E=require("./components/object/index.cjs"),G=require("./components/popover/index.cjs"),N=require("./components/portal/index.cjs"),z=require("./components/search/index.cjs"),H=require("./index-Dn1v0qm6.cjs"),n=require("./components/sortable/index.cjs"),W=require("./components/table/index.cjs"),J=require("./components/textarea/index.cjs"),K=require("./components/toast/index.cjs"),Q=require("./components/toasts/index.cjs"),R=require("./components/toggle/index.cjs"),U=require("./components/toolbar/index.cjs"),V=require("./components/tooltip/index.cjs"),X=require("./components/widget/index.cjs");exports.AppLink=o.AppLink;exports.Aside=t.Aside;exports.Avatar=r.Avatar;exports.Badge=i.Badge;exports.Banner=s.Banner;exports.Branding=c.Branding;exports.Button=_.Button;exports.Card=p.Card;exports.Checkbox=a.Checkbox;exports.Chip=d.Chip;exports.Collapsible=u.Collapsible;exports.Controls=m.Controls;exports.Croppable=l.Croppable;exports.Dialog=x.Dialog;exports.Dropdown=q.Dropdown;exports.Dropzone=g.Dropzone;exports.Editor=b.Editor;exports.EmptyState=T.EmptyState;exports.Fieldset=h.Fieldset;exports.Figure=S.Figure;exports.File=v.File;exports.Footer=C.Footer;exports.Form=L.Form;exports.Graph=F.Graph;exports.Group=I.Group;exports.Header=f.Header;exports.Icon=k.Icon;exports.Iframe=B.Iframe;exports.Image=M.Image;exports.Input=A.Input;exports.Link=D.Link;exports.List=y.List;exports.Loading=O.Loading;exports.Menu=P.Menu;exports.Message=j.Message;exports.Messages=w.Messages;exports.Nav=e.Nav;exports.NavLabel=e.NavLabel;exports.Object=E.Object;exports.Popover=G.Popover;exports.Portal=N.Portal;exports.Search=z.Search;exports.Select=H.Select;exports.Sortable=n.Sortable;exports.useOptionalSortableItem=n.useOptionalSortableItem;exports.Table=W.Table;exports.Textarea=J.Textarea;exports.Toast=K.Toast;exports.Toasts=Q.Toasts;exports.Toggle=R.Toggle;exports.Toolbar=U.Toolbar;exports.Tooltip=V.Tooltip;exports.Widget=X.Widget;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./assets/index.css');const o=require("./components/app-link/index.cjs"),t=require("./components/aside/index.cjs"),r=require("./components/avatar/index.cjs"),i=require("./components/badge/index.cjs"),s=require("./components/banner/index.cjs"),c=require("./components/branding/index.cjs"),_=require("./components/button/index.cjs"),p=require("./components/card/index.cjs"),a=require("./components/checkbox/index.cjs"),d=require("./components/chip/index.cjs"),u=require("./components/collapsible/index.cjs"),m=require("./components/controls/index.cjs"),l=require("./components/croppable/index.cjs"),x=require("./components/dialog/index.cjs"),q=require("./components/dropdown/index.cjs"),g=require("./components/dropzone/index.cjs"),b=require("./components/editor/index.cjs"),T=require("./components/empty-state/index.cjs"),h=require("./components/fieldset/index.cjs"),S=require("./components/figure/index.cjs"),v=require("./components/file/index.cjs"),C=require("./components/footer/index.cjs"),L=require("./components/form/index.cjs"),F=require("./components/graph/index.cjs"),I=require("./components/group/index.cjs"),f=require("./components/header/index.cjs"),k=require("./components/icon/index.cjs"),B=require("./components/iframe/index.cjs"),M=require("./components/image/index.cjs"),A=require("./index-CQNlYa2P.cjs"),D=require("./components/link/index.cjs"),y=require("./components/list/index.cjs"),O=require("./components/loading/index.cjs"),P=require("./components/menu/index.cjs"),j=require("./components/message/index.cjs"),w=require("./components/messages/index.cjs"),e=require("./components/nav/index.cjs"),E=require("./components/object/index.cjs"),G=require("./components/popover/index.cjs"),N=require("./components/portal/index.cjs"),z=require("./components/search/index.cjs"),H=require("./index-Dn1v0qm6.cjs"),n=require("./components/sortable/index.cjs"),W=require("./components/table/index.cjs"),J=require("./components/textarea/index.cjs"),K=require("./components/toast/index.cjs"),Q=require("./components/toasts/index.cjs"),R=require("./components/toggle/index.cjs"),U=require("./components/toolbar/index.cjs"),V=require("./components/tooltip/index.cjs"),X=require("./components/widget/index.cjs");exports.AppLink=o.AppLink;exports.Aside=t.Aside;exports.Avatar=r.Avatar;exports.Badge=i.Badge;exports.Banner=s.Banner;exports.Branding=c.Branding;exports.Button=_.Button;exports.Card=p.Card;exports.Checkbox=a.Checkbox;exports.Chip=d.Chip;exports.Collapsible=u.Collapsible;exports.Controls=m.Controls;exports.Croppable=l.Croppable;exports.Dialog=x.Dialog;exports.Dropdown=q.Dropdown;exports.Dropzone=g.Dropzone;exports.Editor=b.Editor;exports.EmptyState=T.EmptyState;exports.Fieldset=h.Fieldset;exports.Figure=S.Figure;exports.File=v.File;exports.Footer=C.Footer;exports.Form=L.Form;exports.Graph=F.Graph;exports.Group=I.Group;exports.Header=f.Header;exports.Icon=k.Icon;exports.Iframe=B.Iframe;exports.Image=M.Image;exports.Input=A.Input;exports.Link=D.Link;exports.List=y.List;exports.Loading=O.Loading;exports.Menu=P.Menu;exports.Message=j.Message;exports.Messages=w.Messages;exports.Nav=e.Nav;exports.NavLabel=e.NavLabel;exports.Object=E.Object;exports.Popover=G.Popover;exports.Portal=N.Portal;exports.Search=z.Search;exports.Select=H.Select;exports.Sortable=n.Sortable;exports.useOptionalSortableItem=n.useOptionalSortableItem;exports.Table=W.Table;exports.Textarea=J.Textarea;exports.Toast=K.Toast;exports.Toasts=Q.Toasts;exports.Toggle=R.Toggle;exports.Toolbar=U.Toolbar;exports.Tooltip=V.Tooltip;exports.Widget=X.Widget;
2
2
  //# sourceMappingURL=index.cjs.map