@solibo/solibo-ui 0.4.10 → 0.5.3

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 (192) hide show
  1. package/README.md +1 -1
  2. package/dist/assets/index.css +1 -1
  3. package/dist/assets/index10.css +1 -1
  4. package/dist/assets/index11.css +1 -1
  5. package/dist/assets/index12.css +1 -1
  6. package/dist/assets/index13.css +1 -1
  7. package/dist/assets/index14.css +1 -1
  8. package/dist/assets/index15.css +1 -1
  9. package/dist/assets/index16.css +1 -1
  10. package/dist/assets/index17.css +1 -1
  11. package/dist/assets/index18.css +1 -1
  12. package/dist/assets/index19.css +1 -1
  13. package/dist/assets/index2.css +1 -1
  14. package/dist/assets/index20.css +1 -1
  15. package/dist/assets/index21.css +1 -1
  16. package/dist/assets/index22.css +1 -1
  17. package/dist/assets/index23.css +1 -1
  18. package/dist/assets/index24.css +1 -1
  19. package/dist/assets/index25.css +1 -1
  20. package/dist/assets/index26.css +1 -1
  21. package/dist/assets/index27.css +1 -1
  22. package/dist/assets/index29.css +1 -1
  23. package/dist/assets/index3.css +1 -1
  24. package/dist/assets/index30.css +1 -1
  25. package/dist/assets/index31.css +1 -1
  26. package/dist/assets/index32.css +1 -1
  27. package/dist/assets/index33.css +1 -1
  28. package/dist/assets/index34.css +1 -1
  29. package/dist/assets/index35.css +1 -1
  30. package/dist/assets/index36.css +1 -1
  31. package/dist/assets/index37.css +1 -1
  32. package/dist/assets/index38.css +1 -1
  33. package/dist/assets/index39.css +1 -1
  34. package/dist/assets/index4.css +1 -1
  35. package/dist/assets/index40.css +1 -1
  36. package/dist/assets/index41.css +1 -1
  37. package/dist/assets/index42.css +1 -1
  38. package/dist/assets/index43.css +1 -1
  39. package/dist/assets/index44.css +1 -1
  40. package/dist/assets/index5.css +1 -1
  41. package/dist/assets/index6.css +1 -1
  42. package/dist/assets/index8.css +1 -1
  43. package/dist/assets/index9.css +1 -1
  44. package/dist/assets/styles.css +1 -1
  45. package/dist/components/_avatar/index.cjs +1 -1
  46. package/dist/components/_avatar/index.cjs.map +1 -1
  47. package/dist/components/_avatar/index.js +9 -9
  48. package/dist/components/_avatar/index.js.map +1 -1
  49. package/dist/components/_card/index.cjs +1 -1
  50. package/dist/components/_card/index.js +12 -12
  51. package/dist/components/_collapsible/index.cjs +1 -1
  52. package/dist/components/_collapsible/index.js +1 -1
  53. package/dist/components/_croppable/index.cjs +1 -1
  54. package/dist/components/_croppable/index.js +175 -175
  55. package/dist/components/_dropdown/index.cjs +1 -1
  56. package/dist/components/_dropdown/index.cjs.map +1 -1
  57. package/dist/components/_dropdown/index.js +87 -87
  58. package/dist/components/_dropdown/index.js.map +1 -1
  59. package/dist/components/_dropzone/index.cjs +1 -1
  60. package/dist/components/_dropzone/index.js +34 -34
  61. package/dist/components/_editor/index.cjs +16 -16
  62. package/dist/components/_editor/index.cjs.map +1 -1
  63. package/dist/components/_editor/index.js +19 -19
  64. package/dist/components/_editor/index.js.map +1 -1
  65. package/dist/components/_messages/index.cjs +1 -1
  66. package/dist/components/_messages/index.cjs.map +1 -1
  67. package/dist/components/_messages/index.js +15 -15
  68. package/dist/components/_messages/index.js.map +1 -1
  69. package/dist/components/_portal/index.cjs +1 -1
  70. package/dist/components/_portal/index.cjs.map +1 -1
  71. package/dist/components/_portal/index.js +17 -16
  72. package/dist/components/_portal/index.js.map +1 -1
  73. package/dist/components/_sortable/index.cjs +1 -1
  74. package/dist/components/_sortable/index.cjs.map +1 -1
  75. package/dist/components/_sortable/index.js +64 -33
  76. package/dist/components/_sortable/index.js.map +1 -1
  77. package/dist/components/_widget/index.cjs +1 -1
  78. package/dist/components/_widget/index.js +3 -3
  79. package/dist/components/accordion/index.cjs +1 -1
  80. package/dist/components/accordion/index.cjs.map +1 -1
  81. package/dist/components/accordion/index.js +16 -10
  82. package/dist/components/accordion/index.js.map +1 -1
  83. package/dist/components/app-link/index.cjs +1 -1
  84. package/dist/components/app-link/index.cjs.map +1 -1
  85. package/dist/components/app-link/index.js +9 -9
  86. package/dist/components/app-link/index.js.map +1 -1
  87. package/dist/components/aside/index.cjs +1 -1
  88. package/dist/components/aside/index.js +6 -6
  89. package/dist/components/badge/index.cjs +1 -1
  90. package/dist/components/badge/index.cjs.map +1 -1
  91. package/dist/components/badge/index.js +19 -18
  92. package/dist/components/badge/index.js.map +1 -1
  93. package/dist/components/banner/index.cjs +1 -1
  94. package/dist/components/banner/index.js +9 -9
  95. package/dist/components/branding/index.cjs +1 -1
  96. package/dist/components/branding/index.js +12 -12
  97. package/dist/components/button/index.cjs +1 -1
  98. package/dist/components/button/index.js +12 -12
  99. package/dist/components/checkbox/index.cjs +1 -1
  100. package/dist/components/checkbox/index.js +7 -7
  101. package/dist/components/controls/index.cjs +1 -1
  102. package/dist/components/controls/index.cjs.map +1 -1
  103. package/dist/components/controls/index.js +21 -10
  104. package/dist/components/controls/index.js.map +1 -1
  105. package/dist/components/dialog/index.cjs +1 -1
  106. package/dist/components/dialog/index.js +3 -3
  107. package/dist/components/figure/index.cjs +1 -1
  108. package/dist/components/figure/index.cjs.map +1 -1
  109. package/dist/components/figure/index.js +11 -11
  110. package/dist/components/figure/index.js.map +1 -1
  111. package/dist/components/file/index.cjs +1 -1
  112. package/dist/components/file/index.cjs.map +1 -1
  113. package/dist/components/file/index.js +14 -13
  114. package/dist/components/file/index.js.map +1 -1
  115. package/dist/components/footer/index.cjs +1 -1
  116. package/dist/components/footer/index.js +3 -3
  117. package/dist/components/form/index.cjs +1 -1
  118. package/dist/components/form/index.js +11 -11
  119. package/dist/components/graph/index.cjs +1 -1
  120. package/dist/components/graph/index.cjs.map +1 -1
  121. package/dist/components/graph/index.js +31 -31
  122. package/dist/components/graph/index.js.map +1 -1
  123. package/dist/components/header/index.cjs +1 -1
  124. package/dist/components/header/index.js +3 -3
  125. package/dist/components/icon/index.cjs +1 -1
  126. package/dist/components/icon/index.cjs.map +1 -1
  127. package/dist/components/icon/index.js +26 -26
  128. package/dist/components/icon/index.js.map +1 -1
  129. package/dist/components/image/index.cjs +1 -1
  130. package/dist/components/image/index.js +9 -9
  131. package/dist/components/input/index.cjs +1 -1
  132. package/dist/components/input/index.cjs.map +1 -1
  133. package/dist/components/input/index.js +34 -33
  134. package/dist/components/input/index.js.map +1 -1
  135. package/dist/components/link/index.cjs +1 -1
  136. package/dist/components/link/index.js +11 -11
  137. package/dist/components/list/index.cjs +1 -1
  138. package/dist/components/list/index.js +7 -7
  139. package/dist/components/loading/index.cjs +1 -1
  140. package/dist/components/loading/index.js +13 -13
  141. package/dist/components/message/index.cjs +1 -1
  142. package/dist/components/message/index.js +7 -7
  143. package/dist/components/nav/index.cjs +1 -1
  144. package/dist/components/nav/index.js +23 -23
  145. package/dist/components/object/index.cjs +2 -0
  146. package/dist/components/object/index.cjs.map +1 -0
  147. package/dist/components/object/index.js +16 -0
  148. package/dist/components/object/index.js.map +1 -0
  149. package/dist/components/select/index.cjs +1 -1
  150. package/dist/components/select/index.js +1 -1
  151. package/dist/components/table/index.cjs +1 -1
  152. package/dist/components/table/index.cjs.map +1 -1
  153. package/dist/components/table/index.js +22 -22
  154. package/dist/components/table/index.js.map +1 -1
  155. package/dist/components/textarea/index.cjs +1 -1
  156. package/dist/components/textarea/index.cjs.map +1 -1
  157. package/dist/components/textarea/index.js +23 -23
  158. package/dist/components/textarea/index.js.map +1 -1
  159. package/dist/components/toast/index.cjs +1 -1
  160. package/dist/components/toast/index.cjs.map +1 -1
  161. package/dist/components/toast/index.js +23 -24
  162. package/dist/components/toast/index.js.map +1 -1
  163. package/dist/components/toggle/index.cjs +1 -1
  164. package/dist/components/toggle/index.js +1 -1
  165. package/dist/components/toolbar/index.cjs +1 -1
  166. package/dist/components/toolbar/index.js +9 -9
  167. package/dist/index-CiEbbnD6.js +42 -0
  168. package/dist/index-CiEbbnD6.js.map +1 -0
  169. package/dist/index-ClrKYsAQ.cjs +2 -0
  170. package/dist/index-ClrKYsAQ.cjs.map +1 -0
  171. package/dist/index.cjs +1 -1
  172. package/dist/index.d.ts +28 -22
  173. package/dist/index.js +33 -33
  174. package/dist/styles.module-BOTEBJ0C.js +9 -0
  175. package/dist/styles.module-BOTEBJ0C.js.map +1 -0
  176. package/dist/styles.module-BPvMQa_x.cjs +2 -0
  177. package/dist/styles.module-BPvMQa_x.cjs.map +1 -0
  178. package/dist/tokens.css +44 -12
  179. package/dist/tokens.json +541 -68
  180. package/package.json +1 -1
  181. package/dist/components/layout/index.cjs +0 -2
  182. package/dist/components/layout/index.cjs.map +0 -1
  183. package/dist/components/layout/index.js +0 -18
  184. package/dist/components/layout/index.js.map +0 -1
  185. package/dist/index-BpUboRfJ.cjs +0 -2
  186. package/dist/index-BpUboRfJ.cjs.map +0 -1
  187. package/dist/index-ChKhFyp8.js +0 -40
  188. package/dist/index-ChKhFyp8.js.map +0 -1
  189. package/dist/styles.module-DZXAP_eP.js +0 -8
  190. package/dist/styles.module-DZXAP_eP.js.map +0 -1
  191. package/dist/styles.module-Vt6mmlsz.cjs +0 -2
  192. package/dist/styles.module-Vt6mmlsz.cjs.map +0 -1
@@ -1,55 +1,56 @@
1
- import { jsxs as C, Fragment as T, jsx as a } from "react/jsx-runtime";
2
- import { t as s } from "../../classix-DG18itHa.js";
3
- import { useState as j, useEffect as S } from "react";
4
- import { i as V } from "../../icons-DfmpRbxE.js";
5
- import { u as w } from "../../utils--n2yqjCy.js";
6
- import { i as o } from "../../styles.module-DZXAP_eP.js";
7
- function y({
8
- className: q,
1
+ import { jsxs as N, Fragment as w, jsx as o } from "react/jsx-runtime";
2
+ import { t as j } from "../../classix-DG18itHa.js";
3
+ import { useState as S, useEffect as I } from "react";
4
+ import { i as B } from "../../icons-DfmpRbxE.js";
5
+ import { u as E } from "../../utils--n2yqjCy.js";
6
+ import { i as a } from "../../styles.module-BOTEBJ0C.js";
7
+ function A({
8
+ className: L,
9
9
  defaultCountryCode: c = "+47",
10
10
  disabled: u = !1,
11
11
  icon: i,
12
12
  label: m,
13
13
  placeholder: h,
14
- ref: d,
15
- type: e = "text",
16
- ...t
14
+ ref: v,
15
+ required: l,
16
+ type: t = "text",
17
+ ...e
17
18
  }) {
18
- const [l, v] = j(""), [r, g] = j(""), {
19
- onChange: I,
19
+ const [s, d] = S(""), [r, g] = S(""), {
20
+ onChange: P,
20
21
  value: f,
21
- ...L
22
- } = t, {
22
+ ...T
23
+ } = e, {
23
24
  touched: p,
24
25
  onBlur: x
25
- } = w(f === ""), N = i && e !== "radio" && e !== "datetime-local" ? {
26
- "--icon-svg": V(i, !0)
26
+ } = E(f === ""), C = i && t !== "radio" && t !== "datetime-local" ? {
27
+ "--icon-svg": B(i, !0)
27
28
  } : void 0;
28
- S(() => {
29
- if (typeof t.onChange == "function" && e === "tel") {
29
+ I(() => {
30
+ if (typeof e.onChange == "function" && t === "tel") {
30
31
  const n = {
31
- name: t.name,
32
- value: r ? (l || c).split(" ").join("") + r.split(" ").join("") : void 0
32
+ name: e.name,
33
+ value: r ? (s || c).split(" ").join("") + r.split(" ").join("") : void 0
33
34
  };
34
- t.onChange({
35
+ e.onChange({
35
36
  target: n,
36
37
  currentTarget: n
37
38
  });
38
39
  }
39
- }, [l, r]), S(() => {
40
- e === "tel" && !t.value && (g(""), v(""));
41
- }, [t.value, e]);
42
- const P = /* @__PURE__ */ C(T, { children: [
43
- /* @__PURE__ */ a("input", { disabled: u, hidden: !0, onChange: I, pattern: void 0, placeholder: h, ref: d, type: e, value: f }),
44
- /* @__PURE__ */ a("input", { type: "text", className: o.input, disabled: u, maxLength: 5, onChange: (n) => v(n.target.value), placeholder: c, value: l }),
45
- /* @__PURE__ */ a("input", { type: "tel", className: s(o.input, p && "touched"), "data-icon": i ? "true" : void 0, disabled: u, maxLength: 14, name: void 0, onChange: (n) => g(n.target.value), onBlur: x, pattern: t.pattern, style: N, value: r, ...L })
40
+ }, [s, r]), I(() => {
41
+ t === "tel" && !e.value && (g(""), d(""));
42
+ }, [e.value, t]);
43
+ const V = /* @__PURE__ */ N(w, { children: [
44
+ /* @__PURE__ */ o("input", { disabled: u, hidden: !0, onChange: P, pattern: void 0, placeholder: h, ref: v, type: t, value: f }),
45
+ /* @__PURE__ */ o("input", { type: "text", className: a.input, disabled: u, maxLength: 5, onChange: (n) => d(n.target.value), placeholder: c, value: s }),
46
+ /* @__PURE__ */ o("input", { type: "tel", className: j(a.input, p && a.touched), "data-icon": i ? "true" : void 0, disabled: u, maxLength: 14, name: void 0, onChange: (n) => g(n.target.value), onBlur: x, pattern: e.pattern, required: l, style: C, value: r, ...T })
46
47
  ] });
47
- return /* @__PURE__ */ C("label", { className: o.label, "data-component": "input", children: [
48
- m && /* @__PURE__ */ a("span", { className: s(t.required && o.required), children: m }),
49
- e === "tel" ? P : /* @__PURE__ */ a("input", { ref: d, className: s(o.input, q, p && "touched"), "data-icon": i ? "true" : void 0, disabled: u, onBlur: x, placeholder: h, style: N, type: e, ...t })
48
+ return /* @__PURE__ */ N("label", { className: a.label, "data-component": "input", children: [
49
+ m && /* @__PURE__ */ o("span", { "data-required": l || void 0, children: m }),
50
+ t === "tel" ? V : /* @__PURE__ */ o("input", { ref: v, className: j(a.input, L, p && a.touched), "data-icon": i ? "true" : void 0, disabled: u, onBlur: x, placeholder: h, required: l, style: C, type: t, ...e })
50
51
  ] });
51
52
  }
52
53
  export {
53
- y as Input
54
+ A as Input
54
55
  };
55
56
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/input/index.tsx"],"sourcesContent":["import cx from 'classix';\nimport { useEffect, useState } from 'react';\n\nimport { IconName, iconSVG } from '@/components/icon/icons.ts';\nimport { useTouched } from '@/utils.ts';\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 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 placeholder,\n ref,\n type = 'text',\n ...props\n}: InputProps) {\n const [countryCode, setCountryCode] = useState('');\n const [phoneNumber, setPhoneNumber] = useState('');\n const { onChange, value, ...restProps } = props;\n const { touched, onBlur } = useTouched(value === '');\n\n type withVars =\n | (React.CSSProperties & {\n '--icon-svg'?: string;\n })\n | undefined;\n\n const withVars: withVars =\n icon && type !== 'radio' && type !== 'datetime-local'\n ? {\n '--icon-svg': iconSVG(icon, true),\n }\n : undefined;\n\n useEffect(() => {\n if (typeof props.onChange === 'function' && type === 'tel') {\n const target = {\n name: props.name,\n value: phoneNumber\n ? (countryCode || defaultCountryCode).split(' ').join('') +\n phoneNumber.split(' ').join('')\n : undefined,\n } as unknown as HTMLInputElement;\n // eslint-disable-next-line\n (props.onChange as any)({ target, currentTarget: target });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [countryCode, phoneNumber]);\n\n useEffect(() => {\n if (type === 'tel' && !props.value) {\n setPhoneNumber('');\n setCountryCode('');\n }\n }, [props.value, type]);\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={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 type='tel'\n className={cx(styles.input, touched && 'touched')}\n data-icon={icon ? 'true' : undefined}\n disabled={disabled}\n maxLength={14}\n name={undefined}\n onChange={(e) => setPhoneNumber(e.target.value)}\n onBlur={onBlur}\n pattern={props.pattern}\n style={withVars}\n value={phoneNumber}\n {...restProps}\n />\n </>\n );\n\n return (\n <label className={styles.label}>\n {label && <span className={cx(props.required && styles.required)}>{label}</span>}\n {type === 'tel' ? (\n telephoneInput\n ) : (\n <input\n ref={ref}\n className={cx(styles.input, className, touched && 'touched')}\n data-icon={icon ? 'true' : undefined}\n disabled={disabled}\n onBlur={onBlur}\n placeholder={placeholder}\n style={withVars}\n type={type}\n {...props}\n />\n )}\n </label>\n );\n}\n"],"names":["Input","className","defaultCountryCode","disabled","icon","label","placeholder","ref","type","props","countryCode","setCountryCode","useState","phoneNumber","setPhoneNumber","onChange","value","restProps","touched","onBlur","useTouched","withVars","iconSVG","undefined","useEffect","target","name","split","join","currentTarget","telephoneInput","jsxs","Fragment","jsx","styles","input","e","cx","pattern","required"],"mappings":";;;;;;AA2BO,SAASA,EAAM;AAAA,EACpBC,WAAAA;AAAAA,EACAC,oBAAAA,IAAqB;AAAA,EACrBC,UAAAA,IAAW;AAAA,EACXC,MAAAA;AAAAA,EACAC,OAAAA;AAAAA,EACAC,aAAAA;AAAAA,EACAC,KAAAA;AAAAA,EACAC,MAAAA,IAAO;AAAA,EACP,GAAGC;AACO,GAAG;AACb,QAAM,CAACC,GAAaC,CAAc,IAAIC,EAAS,EAAE,GAC3C,CAACC,GAAaC,CAAc,IAAIF,EAAS,EAAE,GAC3C;AAAA,IAAEG,UAAAA;AAAAA,IAAUC,OAAAA;AAAAA,IAAO,GAAGC;AAAAA,EAAAA,IAAcR,GACpC;AAAA,IAAES,SAAAA;AAAAA,IAASC,QAAAA;AAAAA,EAAAA,IAAWC,EAAWJ,MAAU,EAAE,GAQ7CK,IACJjB,KAAQI,MAAS,WAAWA,MAAS,mBACjC;AAAA,IACE,cAAcc,EAAQlB,GAAM,EAAI;AAAA,EAAA,IAElCmB;AAENC,EAAAA,EAAU,MAAM;AACd,QAAI,OAAOf,EAAMM,YAAa,cAAcP,MAAS,OAAO;AAC1D,YAAMiB,IAAS;AAAA,QACbC,MAAMjB,EAAMiB;AAAAA,QACZV,OAAOH,KACFH,KAAeR,GAAoByB,MAAM,GAAG,EAAEC,KAAK,EAAE,IACtDf,EAAYc,MAAM,GAAG,EAAEC,KAAK,EAAE,IAC9BL;AAAAA,MAAAA;AAGLd,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AGH,EAAOC,OAAOlC,GAAWiB,KAAW,SAAS,GAC3D,aAAWd,IAAO,SAASmB,QAC3B,UAAApB,GACA,QAAAgB,GACA,aAAAb,GACA,OAAOe,GACP,MAAAb,GACA,GAAIC,EAAAA,CAAM;AAAA,EAAA,GAGhB;AAEJ;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/input/index.tsx"],"sourcesContent":["import cx from 'classix';\nimport { useEffect, useState } from 'react';\n\nimport { IconName, iconSVG } from '@/components/icon/icons.ts';\nimport { useTouched } from '@/utils.ts';\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 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 placeholder,\n ref,\n required,\n type = 'text',\n ...props\n}: InputProps) {\n const [countryCode, setCountryCode] = useState('');\n const [phoneNumber, setPhoneNumber] = useState('');\n const { onChange, value, ...restProps } = props;\n const { touched, onBlur } = useTouched(value === '');\n\n type withVars =\n | (React.CSSProperties & {\n '--icon-svg'?: string;\n })\n | undefined;\n\n const withVars: withVars =\n icon && type !== 'radio' && type !== 'datetime-local'\n ? {\n '--icon-svg': iconSVG(icon, true),\n }\n : undefined;\n\n useEffect(() => {\n if (typeof props.onChange === 'function' && type === 'tel') {\n const target = {\n name: props.name,\n value: phoneNumber\n ? (countryCode || defaultCountryCode).split(' ').join('') +\n phoneNumber.split(' ').join('')\n : undefined,\n } as unknown as HTMLInputElement;\n // eslint-disable-next-line\n (props.onChange as any)({ target, currentTarget: target });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [countryCode, phoneNumber]);\n\n useEffect(() => {\n if (type === 'tel' && !props.value) {\n setPhoneNumber('');\n setCountryCode('');\n }\n }, [props.value, type]);\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={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 type='tel'\n className={cx(styles.input, touched && styles.touched)}\n data-icon={icon ? 'true' : undefined}\n disabled={disabled}\n maxLength={14}\n name={undefined}\n onChange={(e) => setPhoneNumber(e.target.value)}\n onBlur={onBlur}\n pattern={props.pattern}\n required={required}\n style={withVars}\n value={phoneNumber}\n {...restProps}\n />\n </>\n );\n\n return (\n <label className={styles.label}>\n {label && <span data-required={required || undefined}>{label}</span>}\n {type === 'tel' ? (\n telephoneInput\n ) : (\n <input\n ref={ref}\n className={cx(styles.input, className, touched && styles.touched)}\n data-icon={icon ? 'true' : undefined}\n disabled={disabled}\n onBlur={onBlur}\n placeholder={placeholder}\n required={required}\n style={withVars}\n type={type}\n {...props}\n />\n )}\n </label>\n );\n}\n"],"names":["Input","className","defaultCountryCode","disabled","icon","label","placeholder","ref","required","type","props","countryCode","setCountryCode","useState","phoneNumber","setPhoneNumber","onChange","value","restProps","touched","onBlur","useTouched","withVars","iconSVG","undefined","useEffect","target","name","split","join","currentTarget","telephoneInput","jsxs","Fragment","jsx","styles","input","e","cx","pattern"],"mappings":";;;;;;AA2BO,SAASA,EAAM;AAAA,EACpBC,WAAAA;AAAAA,EACAC,oBAAAA,IAAqB;AAAA,EACrBC,UAAAA,IAAW;AAAA,EACXC,MAAAA;AAAAA,EACAC,OAAAA;AAAAA,EACAC,aAAAA;AAAAA,EACAC,KAAAA;AAAAA,EACAC,UAAAA;AAAAA,EACAC,MAAAA,IAAO;AAAA,EACP,GAAGC;AACO,GAAG;AACb,QAAM,CAACC,GAAaC,CAAc,IAAIC,EAAS,EAA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AAOT,KAAK,GAC9C,aAAaf,GACb,OAAOS,GAAY;AAAA,sBAEpB,SAAA,EACC,MAAK,OACL,WAAW2B,EAAGH,EAAOC,OAAOjB,KAAWgB,EAAOhB,OAAO,GACrD,aAAWf,IAAO,SAASoB,QAC3B,UAAArB,GACA,WAAW,IACX,MAAMqB,QACN,UAAWa,CAAAA,MAAMtB,EAAesB,EAAEX,OAAOT,KAAK,GAC9C,QAAAG,GACA,SAASV,EAAM6B,SACf,UAAA/B,GACA,OAAOc,GACP,OAAOR,GACP,GAAII,EAAAA,CAAU;AAAA,EAAA,GAElB;AAGF,2BACG,SAAA,EAAM,WAAWiB,EAAO9B,OAAM,kBAAA,SAC5BA,UAAAA;AAAAA,IAAAA,KAAS,gBAAA6B,EAAC,QAAA,EAAK,iBAAe1B,KAAYgB,QAAYnB,UAAAA,GAAM;AAAA,IAC5DI,MAAS,QACRsB,IAEA,gBAAAG,EAAC,SAAA,EACC,KAAA3B,GACA,WAAW+B,EAAGH,EAAOC,OAAOnC,GAAWkB,KAAWgB,EAAOhB,OAAO,GAChE,aAAWf,IAAO,SAASoB,QAC3B,UAAArB,GACA,QAAAiB,GACA,aAAAd,GACA,UAAAE,GACA,OAAOc,GACP,MAAAb,GACA,GAAIC,EAAAA,CAAM;AAAA,EAAA,GAGhB;AAEJ;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index37.css');const l=require("react/jsx-runtime"),s=require("../../classix-5H4IWnMA.cjs"),m="_link_8fl9a_1",o="_primary_8fl9a_7",c="_danger_8fl9a_13",_="_minimal_8fl9a_21",n={link:m,primary:o,danger:c,minimal:_},k=({children:i,className:a,to:r="#",variant:e="primary",...t})=>l.jsx("a",{className:s.t(a,n.link,n[e]),href:r,...t,"data-component":"link",children:i});exports.Link=k;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index37.css');const s=require("react/jsx-runtime"),l=require("../../classix-5H4IWnMA.cjs"),m="_link_xhd9q_1",o="_primary_xhd9q_7",c="_danger_xhd9q_13",_="_minimal_xhd9q_21",n={link:m,primary:o,danger:c,minimal:_},d=({children:i,className:r,to:e="#",variant:t="primary",...a})=>s.jsx("a",{className:l.t(r,n.link,n[t]),href:e,...a,"data-component":"link",children:i});exports.Link=d;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,17 +1,17 @@
1
- import { jsx as t } from "react/jsx-runtime";
2
- import { t as o } from "../../classix-DG18itHa.js";
3
- import '../../assets/index37.css';const _ = "_link_8fl9a_1", s = "_primary_8fl9a_7", e = "_danger_8fl9a_13", c = "_minimal_8fl9a_21", n = {
4
- link: _,
5
- primary: s,
1
+ import { jsx as o } from "react/jsx-runtime";
2
+ import { t as _ } from "../../classix-DG18itHa.js";
3
+ import '../../assets/index37.css';const s = "_link_xhd9q_1", l = "_primary_xhd9q_7", e = "_danger_xhd9q_13", c = "_minimal_xhd9q_21", n = {
4
+ link: s,
5
+ primary: l,
6
6
  danger: e,
7
7
  minimal: c
8
8
  }, k = ({
9
- children: a,
10
- className: r,
11
- to: i = "#",
12
- variant: m = "primary",
13
- ...l
14
- }) => /* @__PURE__ */ t("a", { className: o(r, n.link, n[m]), href: i, ...l, "data-component": "link", children: a });
9
+ children: r,
10
+ className: i,
11
+ to: m = "#",
12
+ variant: a = "primary",
13
+ ...t
14
+ }) => /* @__PURE__ */ o("a", { className: _(i, n.link, n[a]), href: m, ...t, "data-component": "link", children: r });
15
15
  export {
16
16
  k as Link
17
17
  };
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index38.css');const a=require("react/jsx-runtime"),_=require("../../classix-5H4IWnMA.cjs"),c=require("../../helpers-BD5fFZi-.cjs"),d="_horizontal_ham8z_1",z="_list_ham8z_12",x="_columns_ham8z_51",s={horizontal:d,list:z,columns:x};function y({children:t,className:r,columns:o=1,horizontal:m,ordered:u,style:h,...l}){const n=Number.isFinite(o)?Math.max(1,Math.floor(o)):1,e=_.t(r,s.list,n>1&&s.columns,m&&s.horizontal),i={...h,"--list-columns":n};return u?a.jsx("ol",{className:e,style:i,...l,"data-component":"list",children:c.wrapChildren(t)}):a.jsx("ul",{className:e,style:i,...l,"data-component":"list",children:c.wrapChildren(t)})}exports.List=y;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index38.css');const c=require("react/jsx-runtime"),_=require("../../classix-5H4IWnMA.cjs"),r=require("../../helpers-BD5fFZi-.cjs"),d="_horizontal_1w5i6_1",w="_list_1w5i6_12",x="_columns_1w5i6_53",s={horizontal:d,list:w,columns:x};function y({children:t,className:a,columns:o=1,horizontal:u,ordered:m,style:h,...l}){const i=Number.isFinite(o)?Math.max(1,Math.floor(o)):1,n=_.t(a,s.list,i>1&&s.columns,u&&s.horizontal),e={...h,"--list-columns":i};return m?c.jsx("ol",{className:n,style:e,...l,"data-component":"list",children:r.wrapChildren(t)}):c.jsx("ul",{className:n,style:e,...l,"data-component":"list",children:r.wrapChildren(t)})}exports.List=y;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,25 +1,25 @@
1
1
  import { jsx as c } from "react/jsx-runtime";
2
2
  import { t as u } from "../../classix-DG18itHa.js";
3
- import { w as m } from "../../helpers-D56OHkFI.js";
4
- import '../../assets/index38.css';const z = "_horizontal_ham8z_1", f = "_list_ham8z_12", p = "_columns_ham8z_51", t = {
5
- horizontal: z,
3
+ import { w as r } from "../../helpers-D56OHkFI.js";
4
+ import '../../assets/index38.css';const w = "_horizontal_1w5i6_1", f = "_list_1w5i6_12", p = "_columns_1w5i6_53", t = {
5
+ horizontal: w,
6
6
  list: f,
7
7
  columns: p
8
8
  };
9
9
  function y({
10
10
  children: o,
11
- className: r,
11
+ className: m,
12
12
  columns: s = 1,
13
13
  horizontal: e,
14
14
  ordered: h,
15
15
  style: _,
16
16
  ...l
17
17
  }) {
18
- const n = Number.isFinite(s) ? Math.max(1, Math.floor(s)) : 1, a = u(r, t.list, n > 1 && t.columns, e && t.horizontal), i = {
18
+ const i = Number.isFinite(s) ? Math.max(1, Math.floor(s)) : 1, n = u(m, t.list, i > 1 && t.columns, e && t.horizontal), a = {
19
19
  ..._,
20
- "--list-columns": n
20
+ "--list-columns": i
21
21
  };
22
- return h ? /* @__PURE__ */ c("ol", { className: a, style: i, ...l, "data-component": "list", children: m(o) }) : /* @__PURE__ */ c("ul", { className: a, style: i, ...l, "data-component": "list", children: m(o) });
22
+ return h ? /* @__PURE__ */ c("ol", { className: n, style: a, ...l, "data-component": "list", children: r(o) }) : /* @__PURE__ */ c("ul", { className: n, style: a, ...l, "data-component": "list", children: r(o) });
23
23
  }
24
24
  export {
25
25
  y as List
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index14.css');const n=require("react/jsx-runtime"),i=require("../../classix-5H4IWnMA.cjs"),c="_loading_1ytlq_23",d="_spin_1ytlq_1",_="_ping_1ytlq_39",r="_sticky_1ytlq_65",s={loading:c,default:"_default_1ytlq_28",spin:d,ping:_,sticky:r},g=({variant:o="default",size:t,sticky:l=!1,...a})=>{const e={"--border-size":t?t/8+"px":void 0,"--size":t?t+"px":void 0};return n.jsx("div",{className:i.t(s.loading,l&&s.sticky),"data-component":"loading",children:n.jsx("span",{className:i.t(s.loading,s[o]),style:e,...a})})};exports.Loading=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index14.css');const t=require("react/jsx-runtime"),i=require("../../classix-5H4IWnMA.cjs"),c="_loading_1nndz_23",l="_spin_1nndz_1",_="_ping_1nndz_39",r="_sticky_1nndz_65",s={loading:c,default:"_default_1nndz_28",spin:l,ping:_,sticky:r},g=({variant:o="default",size:n,sticky:d=!1,...a})=>{const e={"--border-size":n?n/8+"px":void 0,"--size":n?n+"px":void 0};return t.jsx("div",{className:i.t(s.loading,d&&s.sticky),"data-component":"loading",children:t.jsx("span",{className:i.t(s.loading,s[o]),style:e,...a})})};exports.Loading=g;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,24 +1,24 @@
1
- import { jsx as o } from "react/jsx-runtime";
2
- import { t as s } from "../../classix-DG18itHa.js";
3
- import '../../assets/index14.css';const c = "_loading_1ytlq_23", _ = "_spin_1ytlq_1", p = "_ping_1ytlq_39", e = "_sticky_1ytlq_65", n = {
4
- loading: c,
5
- default: "_default_1ytlq_28",
1
+ import { jsx as s } from "react/jsx-runtime";
2
+ import { t } from "../../classix-DG18itHa.js";
3
+ import '../../assets/index14.css';const l = "_loading_1nndz_23", _ = "_spin_1nndz_1", p = "_ping_1nndz_39", e = "_sticky_1nndz_65", o = {
4
+ loading: l,
5
+ default: "_default_1nndz_28",
6
6
  spin: _,
7
7
  ping: p,
8
8
  sticky: e
9
- }, g = ({
9
+ }, m = ({
10
10
  variant: i = "default",
11
- size: t,
12
- sticky: l = !1,
11
+ size: n,
12
+ sticky: d = !1,
13
13
  ...a
14
14
  }) => {
15
- const d = {
16
- "--border-size": t ? t / 8 + "px" : void 0,
17
- "--size": t ? t + "px" : void 0
15
+ const c = {
16
+ "--border-size": n ? n / 8 + "px" : void 0,
17
+ "--size": n ? n + "px" : void 0
18
18
  };
19
- return /* @__PURE__ */ o("div", { className: s(n.loading, l && n.sticky), "data-component": "loading", children: /* @__PURE__ */ o("span", { className: s(n.loading, n[i]), style: d, ...a }) });
19
+ return /* @__PURE__ */ s("div", { className: t(o.loading, d && o.sticky), "data-component": "loading", children: /* @__PURE__ */ s("span", { className: t(o.loading, o[i]), style: c, ...a }) });
20
20
  };
21
21
  export {
22
- g as Loading
22
+ m as Loading
23
23
  };
24
24
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index39.css');const s=require("react/jsx-runtime"),c=require("../../classix-5H4IWnMA.cjs"),o=require("../icon/index.cjs"),r="_message_1cg9n_1",g="_preview_1cg9n_38",t={message:r,preview:g},m=({content:n,id:a,preview:i,type:e="default"})=>s.jsxs("div",{className:c.t(t.message,i&&t.preview),"data-id":a,"data-type":e,"data-component":"message",children:[e=="system"&&s.jsx(o.Icon,{gap:"right",name:"info"}),n]});exports.Message=m;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index39.css');const s=require("react/jsx-runtime"),o=require("../../classix-5H4IWnMA.cjs"),r=require("../icon/index.cjs"),c="_message_k0j8z_1",m="_preview_k0j8z_40",t={message:c,preview:m},g=({content:a,id:n,preview:i,type:e="default"})=>s.jsxs("div",{className:o.t(t.message,i&&t.preview),"data-id":n,"data-type":e,"data-component":"message",children:[e=="system"&&s.jsx(r.Icon,{gap:"right",name:"info"}),a]});exports.Message=g;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,16 +1,16 @@
1
1
  import { jsxs as o, jsx as r } from "react/jsx-runtime";
2
- import { t as n } from "../../classix-DG18itHa.js";
3
- import { Icon as i } from "../icon/index.js";
4
- import '../../assets/index39.css';const c = "_message_1cg9n_1", g = "_preview_1cg9n_38", s = {
5
- message: c,
6
- preview: g
2
+ import { t as i } from "../../classix-DG18itHa.js";
3
+ import { Icon as n } from "../icon/index.js";
4
+ import '../../assets/index39.css';const p = "_message_k0j8z_1", c = "_preview_k0j8z_40", s = {
5
+ message: p,
6
+ preview: c
7
7
  }, f = ({
8
8
  content: t,
9
9
  id: a,
10
10
  preview: m,
11
11
  type: e = "default"
12
- }) => /* @__PURE__ */ o("div", { className: n(s.message, m && s.preview), "data-id": a, "data-type": e, "data-component": "message", children: [
13
- e == "system" && /* @__PURE__ */ r(i, { gap: "right", name: "info" }),
12
+ }) => /* @__PURE__ */ o("div", { className: i(s.message, m && s.preview), "data-id": a, "data-type": e, "data-component": "message", children: [
13
+ e == "system" && /* @__PURE__ */ r(n, { gap: "right", name: "info" }),
14
14
  t
15
15
  ] });
16
16
  export {
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index40.css');const p=require("react/jsx-runtime"),_=require("../../classix-5H4IWnMA.cjs"),f=require("react"),v=require("../../icons-C_cX1FYp.cjs"),h="_nav_joer2_1",b="_horizontal_joer2_7",j="_tabs_joer2_17",g="_pills_joer2_38",t={nav:h,horizontal:b,tabs:j,pills:g},m={default:t.default,pills:t.pills,tabs:t.tabs},w=({animation:o,children:i,className:r,horizontal:s=!1,variant:e="default",...l})=>{const[c,a]=f.useState(!1),u={"--icon-svg":v.iconSVG("chevron")};return p.jsx("nav",{className:_.t(r,s&&t.horizontal,t.nav,m[e]),"data-animation":o,"data-open":c?"true":"false","data-orientation":s?"horizontal":"vertical",onBlurCapture:n=>{if(e!=="pills"||window.innerWidth>960)return;const d=n.relatedTarget;n.currentTarget.contains(d)||a(!1)},onClick:()=>{e!=="pills"||window.innerWidth>960||a(n=>!n)},style:u,...l,"data-component":"nav",children:i})};exports.Nav=w;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index40.css');const p=require("react/jsx-runtime"),_=require("../../classix-5H4IWnMA.cjs"),f=require("react"),v=require("../../icons-C_cX1FYp.cjs"),h="_nav_2unxd_1",x="_horizontal_2unxd_7",b="_tabs_2unxd_17",g="_pills_2unxd_38",t={nav:h,horizontal:x,tabs:b,pills:g},m={default:t.default,pills:t.pills,tabs:t.tabs},w=({animation:o,children:i,className:l,horizontal:s=!1,variant:e="default",...r})=>{const[c,a]=f.useState(!1),u={"--icon-svg":v.iconSVG("chevron")};return p.jsx("nav",{className:_.t(l,s&&t.horizontal,t.nav,m[e]),"data-animation":o,"data-open":c?"true":"false","data-orientation":s?"horizontal":"vertical",onBlurCapture:n=>{if(e!=="pills"||window.innerWidth>960)return;const d=n.relatedTarget;n.currentTarget.contains(d)||a(!1)},onClick:()=>{e!=="pills"||window.innerWidth>960||a(n=>!n)},style:u,...r,"data-component":"nav",children:i})};exports.Nav=w;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,36 +1,36 @@
1
- import { jsx as d } from "react/jsx-runtime";
2
- import { t as _ } from "../../classix-DG18itHa.js";
3
- import { useState as m } from "react";
4
- import { i as u } from "../../icons-DfmpRbxE.js";
5
- import '../../assets/index40.css';const v = "_nav_joer2_1", h = "_horizontal_joer2_7", b = "_tabs_joer2_17", j = "_pills_joer2_38", t = {
1
+ import { jsx as u } from "react/jsx-runtime";
2
+ import { t as f } from "../../classix-DG18itHa.js";
3
+ import { useState as _ } from "react";
4
+ import { i as m } from "../../icons-DfmpRbxE.js";
5
+ import '../../assets/index40.css';const v = "_nav_2unxd_1", h = "_horizontal_2unxd_7", x = "_tabs_2unxd_17", b = "_pills_2unxd_38", t = {
6
6
  nav: v,
7
7
  horizontal: h,
8
- tabs: b,
9
- pills: j
8
+ tabs: x,
9
+ pills: b
10
10
  }, w = {
11
11
  default: t.default,
12
12
  pills: t.pills,
13
13
  tabs: t.tabs
14
- }, C = ({
15
- animation: e,
16
- children: r,
17
- className: i,
18
- horizontal: a = !1,
19
- variant: o = "default",
20
- ...l
14
+ }, N = ({
15
+ animation: i,
16
+ children: e,
17
+ className: l,
18
+ horizontal: o = !1,
19
+ variant: a = "default",
20
+ ...r
21
21
  }) => {
22
- const [c, s] = m(!1), p = {
23
- "--icon-svg": u("chevron")
22
+ const [c, s] = _(!1), p = {
23
+ "--icon-svg": m("chevron")
24
24
  };
25
- return /* @__PURE__ */ d("nav", { className: _(i, a && t.horizontal, t.nav, w[o]), "data-animation": e, "data-open": c ? "true" : "false", "data-orientation": a ? "horizontal" : "vertical", onBlurCapture: (n) => {
26
- if (o !== "pills" || window.innerWidth > 960) return;
27
- const f = n.relatedTarget;
28
- n.currentTarget.contains(f) || s(!1);
25
+ return /* @__PURE__ */ u("nav", { className: f(l, o && t.horizontal, t.nav, w[a]), "data-animation": i, "data-open": c ? "true" : "false", "data-orientation": o ? "horizontal" : "vertical", onBlurCapture: (n) => {
26
+ if (a !== "pills" || window.innerWidth > 960) return;
27
+ const d = n.relatedTarget;
28
+ n.currentTarget.contains(d) || s(!1);
29
29
  }, onClick: () => {
30
- o !== "pills" || window.innerWidth > 960 || s((n) => !n);
31
- }, style: p, ...l, "data-component": "nav", children: r });
30
+ a !== "pills" || window.innerWidth > 960 || s((n) => !n);
31
+ }, style: p, ...r, "data-component": "nav", children: e });
32
32
  };
33
33
  export {
34
- C as Nav
34
+ N as Nav
35
35
  };
36
36
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index4.css');const e=require("react/jsx-runtime"),n="_object_1esdj_1",s={object:n},a=({accessibleLabel:c,url:t,...o})=>e.jsx("object",{"aria-label":c,className:s.object,data:t,type:"application/pdf",...o,"data-component":"objectcomponent",children:t&&e.jsxs(e.Fragment,{children:["We cannot show this file. You can try accessing it directly:",e.jsx("br",{}),e.jsx("a",{href:t,children:t})]})});exports.Object=a;
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../../src/components/object/index.tsx"],"sourcesContent":["import type { ComponentPropsWithoutRef } from 'react';\n\nimport styles from './styles.module.css';\n\nexport type ObjectProps = Omit<ComponentPropsWithoutRef<'object'>, 'data' | 'type'> & {\n accessibleLabel: string;\n url: string;\n};\n\nconst ObjectComponent = ({ accessibleLabel, url, ...props }: ObjectProps) => {\n return (\n <object\n aria-label={accessibleLabel}\n className={styles.object}\n data={url}\n type={`application/pdf`}\n {...props}\n >\n {url && (\n <>\n We cannot show this file. You can try accessing it directly:\n <br />\n <a href={url}>{url}</a>\n </>\n )}\n </object>\n );\n};\n\nexport { ObjectComponent as Object };\n"],"names":["ObjectComponent","accessibleLabel","url","props","styles","object","jsxs","Fragment","jsx"],"mappings":"sJASMA,EAAkBA,CAAC,CAAEC,gBAAAA,EAAiBC,IAAAA,EAAK,GAAGC,CAAmB,UAElE,SAAA,CACC,aAAYF,EACZ,UAAWG,EAAOC,OAClB,KAAMH,EACN,KAAM,kBACN,GAAIC,EAAM,iBAAA,kBAETD,YACCI,EAAAA,KAAAC,WAAA,CAAA,SAAA,CAAA,qEAEG,KAAA,EAAE,EACHC,EAAAA,IAAC,IAAA,CAAE,KAAMN,EAAMA,SAAAA,CAAAA,CAAI,CAAA,CAAA,CACrB,CAAA,CAEJ"}
@@ -0,0 +1,16 @@
1
+ import { jsx as e, jsxs as n, Fragment as a } from "react/jsx-runtime";
2
+ import '../../assets/index4.css';const s = "_object_1esdj_1", i = {
3
+ object: s
4
+ }, r = ({
5
+ accessibleLabel: c,
6
+ url: t,
7
+ ...o
8
+ }) => /* @__PURE__ */ e("object", { "aria-label": c, className: i.object, data: t, type: "application/pdf", ...o, "data-component": "objectcomponent", children: t && /* @__PURE__ */ n(a, { children: [
9
+ "We cannot show this file. You can try accessing it directly:",
10
+ /* @__PURE__ */ e("br", {}),
11
+ /* @__PURE__ */ e("a", { href: t, children: t })
12
+ ] }) });
13
+ export {
14
+ r as Object
15
+ };
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/object/index.tsx"],"sourcesContent":["import type { ComponentPropsWithoutRef } from 'react';\n\nimport styles from './styles.module.css';\n\nexport type ObjectProps = Omit<ComponentPropsWithoutRef<'object'>, 'data' | 'type'> & {\n accessibleLabel: string;\n url: string;\n};\n\nconst ObjectComponent = ({ accessibleLabel, url, ...props }: ObjectProps) => {\n return (\n <object\n aria-label={accessibleLabel}\n className={styles.object}\n data={url}\n type={`application/pdf`}\n {...props}\n >\n {url && (\n <>\n We cannot show this file. You can try accessing it directly:\n <br />\n <a href={url}>{url}</a>\n </>\n )}\n </object>\n );\n};\n\nexport { ObjectComponent as Object };\n"],"names":["ObjectComponent","accessibleLabel","url","props","styles","object","jsxs","Fragment","jsx"],"mappings":";;;GASMA,IAAkBA,CAAC;AAAA,EAAEC,iBAAAA;AAAAA,EAAiBC,KAAAA;AAAAA,EAAK,GAAGC;AAAmB,wBAElE,UAAA,EACC,cAAYF,GACZ,WAAWG,EAAOC,QAClB,MAAMH,GACN,MAAM,mBACN,GAAIC,GAAM,kBAAA,mBAETD,eACC,gBAAAI,EAAAC,GAAA,EAAA,UAAA;AAAA,EAAA;AAAA,oBAEG,MAAA,EAAE;AAAA,EACH,gBAAAC,EAAC,KAAA,EAAE,MAAMN,GAAMA,UAAAA,EAAAA,CAAI;AAAA,EAAA,CACrB,EAAA,CAEJ;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("react/jsx-runtime");require("../../classix-5H4IWnMA.cjs");require("../../icons-C_cX1FYp.cjs");require("../../utils-DBzf7CFq.cjs");const e=require("../../index-BpUboRfJ.cjs");exports.Select=e.Select;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("react/jsx-runtime");require("../../classix-5H4IWnMA.cjs");require("../../icons-C_cX1FYp.cjs");require("../../utils-DBzf7CFq.cjs");const e=require("../../index-ClrKYsAQ.cjs");exports.Select=e.Select;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -2,7 +2,7 @@ import "react/jsx-runtime";
2
2
  import "../../classix-DG18itHa.js";
3
3
  import "../../icons-DfmpRbxE.js";
4
4
  import "../../utils--n2yqjCy.js";
5
- import { S as e } from "../../index-ChKhFyp8.js";
5
+ import { S as e } from "../../index-CiEbbnD6.js";
6
6
  export {
7
7
  e as Select
8
8
  };
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index3.css');const f=require("react/jsx-runtime"),i=require("react"),k=require("../icon/index.cjs"),z="_table_18uji_1",D="_sortable_18uji_27",j={table:z,sortable:D},m=r=>i.isValidElement(r),A=r=>i.Children.toArray(r).reduce((e,t)=>m(t)?e+(t.type==="td"||t.type==="th"?1:A(t.props.children)):e,0),v=r=>{for(const e of i.Children.toArray(r)){if(!m(e))continue;if(e.type==="tr")return A(e.props.children);const t=v(e.props.children);if(t!==null)return t}return null},S=(r,e)=>i.Children.map(r,t=>{if(!m(t))return t;let s=t.props.children===void 0?t.props.children:S(t.props.children,e),n;return t.type==="td"&&t.props["data-span"]==="all"&&(n={colSpan:e}),t.type==="th"&&t.props["data-type"]&&(s=f.jsxs("span",{className:j.sortable,children:[s,f.jsx(k.Icon,{"aria-hidden":"true",name:"updown",variant:"primary"})]})),n||s!==t.props.children?i.cloneElement(t,n,s):t}),I=(r,e,t,s,n=1)=>{if(t==="text")return r.localeCompare(e,s,{sensitivity:"base"})*n;const l=t==="date"?Date.parse(r):Number.parseFloat(r),c=t==="date"?Date.parse(e):Number.parseFloat(e);return Number.isNaN(l)&&Number.isNaN(c)?0:Number.isNaN(l)?1:Number.isNaN(c)?-1:(l-c)*n},P=({children:r,locale:e,...t})=>{const s=i.useRef(null),n=v(r),l=n&&n>0?S(r,n):r,c=(d,u,o)=>{d.querySelectorAll("th[data-type]").forEach(a=>{a===u?(a.dataset.dir=o,a.setAttribute("aria-sort",o==="asc"?"ascending":"descending")):(delete a.dataset.dir,a.setAttribute("aria-sort","none"))})},q=i.useCallback(d=>{var x,g;const u=s.current;if(!u)return;const o=(x=d.target)==null?void 0:x.closest("th");if(!o)return;const p=u.tHead;if(!p||!p.contains(o))return;const a=o.cellIndex;if(a<0)return;const b=(g=u.tBodies)==null?void 0:g[0];if(!b)return;const y=o.getAttribute("data-type");if(!y)return;const N=o.dataset.dir==="asc"?"desc":"asc";c(p,o,N);const w=N==="asc"?1:-1,C=Array.from(b.rows);C.sort((E,R)=>{var _,h;const T=(((_=E.cells[a])==null?void 0:_.textContent)??"").trim(),F=(((h=R.cells[a])==null?void 0:h.textContent)??"").trim();return I(T,F,y,e,w)}),b.append(...C)},[e]);return f.jsx("table",{className:j.table,onClick:q,ref:s,...t,"data-component":"table",children:l})};exports.Table=P;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index3.css');const f=require("react/jsx-runtime"),i=require("react"),k=require("../icon/index.cjs"),z="_table_1egqd_1",D="_sortable_1egqd_27",h={table:z,sortable:D},m=r=>i.isValidElement(r),q=r=>i.Children.toArray(r).reduce((e,t)=>m(t)?e+(t.type==="td"||t.type==="th"?1:q(t.props.children)):e,0),v=r=>{for(const e of i.Children.toArray(r)){if(!m(e))continue;if(e.type==="tr")return q(e.props.children);const t=v(e.props.children);if(t!==null)return t}return null},S=(r,e)=>i.Children.map(r,t=>{if(!m(t))return t;let s=t.props.children===void 0?t.props.children:S(t.props.children,e),n;return t.type==="td"&&t.props["data-span"]==="all"&&(n={colSpan:e}),t.type==="th"&&t.props["data-type"]&&(s=f.jsxs("span",{className:h.sortable,children:[s,f.jsx(k.Icon,{name:"updown",variant:"primary"})]})),n||s!==t.props.children?i.cloneElement(t,n,s):t}),I=(r,e,t,s,n=1)=>{if(t==="text")return r.localeCompare(e,s,{sensitivity:"base"})*n;const l=t==="date"?Date.parse(r):Number.parseFloat(r),c=t==="date"?Date.parse(e):Number.parseFloat(e);return Number.isNaN(l)&&Number.isNaN(c)?0:Number.isNaN(l)?1:Number.isNaN(c)?-1:(l-c)*n},P=({children:r,locale:e,...t})=>{const s=i.useRef(null),n=v(r),l=n&&n>0?S(r,n):r,c=(d,u,o)=>{d.querySelectorAll("th[data-type]").forEach(a=>{a===u?(a.dataset.dir=o,a.setAttribute("aria-sort",o==="asc"?"ascending":"descending")):(delete a.dataset.dir,a.setAttribute("aria-sort","none"))})},j=i.useCallback(d=>{var x,g;const u=s.current;if(!u)return;const o=(x=d.target)==null?void 0:x.closest("th");if(!o)return;const p=u.tHead;if(!p||!p.contains(o))return;const a=o.cellIndex;if(a<0)return;const b=(g=u.tBodies)==null?void 0:g[0];if(!b)return;const y=o.getAttribute("data-type");if(!y)return;const N=o.dataset.dir==="asc"?"desc":"asc";c(p,o,N);const w=N==="asc"?1:-1,C=Array.from(b.rows);C.sort((E,R)=>{var _,A;const T=(((_=E.cells[a])==null?void 0:_.textContent)??"").trim(),F=(((A=R.cells[a])==null?void 0:A.textContent)??"").trim();return I(T,F,y,e,w)}),b.append(...C)},[e]);return f.jsx("table",{className:h.table,onClick:j,ref:s,...t,"data-component":"table",children:l})};exports.Table=P;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../src/components/table/index.tsx"],"sourcesContent":["import { Children, cloneElement, isValidElement, useCallback, useRef } from 'react';\n\nimport { Icon } from '../icon';\nimport styles from './styles.module.css';\n\nexport type TableProps = React.TableHTMLAttributes<HTMLTableElement> & {\n children?: React.ReactNode;\n locale?: string | string[];\n};\n\ntype SortType = 'date' | 'number' | 'text';\n\ntype TableChildProps = {\n children?: React.ReactNode;\n colSpan?: number;\n 'data-span'?: string;\n 'data-type'?: SortType;\n};\n\nconst isTableElement = (child: React.ReactNode): child is React.ReactElement<TableChildProps> =>\n isValidElement<TableChildProps>(child);\n\nconst countCells = (children: React.ReactNode): number =>\n Children.toArray(children).reduce<number>((count, child) => {\n if (!isTableElement(child)) return count;\n return (\n count + (child.type === 'td' || child.type === 'th' ? 1 : countCells(child.props.children))\n );\n }, 0);\n\nconst getFirstRowCellCount = (children: React.ReactNode): number | null => {\n for (const child of Children.toArray(children)) {\n if (!isTableElement(child)) continue;\n\n if (child.type === 'tr') return countCells(child.props.children);\n\n const nestedCount = getFirstRowCellCount(child.props.children);\n if (nestedCount !== null) return nestedCount;\n }\n\n return null;\n};\n\nconst normalizeChildren = (children: React.ReactNode, columnCount: number): React.ReactNode =>\n Children.map(children, (child) => {\n if (!isTableElement(child)) return child;\n\n let nextChildren =\n child.props.children === undefined\n ? child.props.children\n : normalizeChildren(child.props.children, columnCount);\n let nextProps: Partial<TableChildProps> | undefined;\n\n if (child.type === 'td' && child.props['data-span'] === 'all') {\n nextProps = { colSpan: columnCount };\n }\n\n if (child.type === 'th' && child.props['data-type']) {\n nextChildren = (\n <span className={styles.sortable}>\n {nextChildren}\n <Icon\n aria-hidden='true'\n name='updown'\n variant='primary'\n />\n </span>\n );\n }\n\n return nextProps || nextChildren !== child.props.children\n ? cloneElement(child, nextProps, nextChildren)\n : child;\n });\n\n/**\n * Sortable columns must provide data-type (text, number, or date) in the `th` element.\n */\n\nconst compare = (a: string, b: string, type: SortType, locale?: string | string[], dir = 1) => {\n if (type === 'text') {\n return a.localeCompare(b, locale, { sensitivity: 'base' }) * dir;\n }\n\n const left = type === 'date' ? Date.parse(a) : Number.parseFloat(a);\n const right = type === 'date' ? Date.parse(b) : Number.parseFloat(b);\n\n if (Number.isNaN(left) && Number.isNaN(right)) return 0;\n if (Number.isNaN(left)) return 1;\n if (Number.isNaN(right)) return -1;\n return (left - right) * dir;\n};\n\nexport const Table = ({ children, locale, ...props }: TableProps) => {\n const ref = useRef<HTMLTableElement | null>(null);\n const columnCount = getFirstRowCellCount(children);\n const normalizedChildren =\n columnCount && columnCount > 0 ? normalizeChildren(children, columnCount) : children;\n\n const setSortState = (\n thead: HTMLTableSectionElement,\n active: HTMLTableCellElement,\n dir: 'asc' | 'desc'\n ) => {\n const ths = thead.querySelectorAll<HTMLTableCellElement>('th[data-type]');\n\n ths.forEach((th) => {\n if (th === active) {\n th.dataset.dir = dir;\n th.setAttribute('aria-sort', dir === 'asc' ? 'ascending' : 'descending');\n } else {\n delete th.dataset.dir;\n th.setAttribute('aria-sort', 'none');\n }\n });\n };\n\n const onClick = useCallback(\n (e: React.MouseEvent<HTMLTableElement>) => {\n const table = ref.current;\n if (!table) return;\n\n const th = (e.target as HTMLElement | null)?.closest('th');\n if (!th) return;\n\n const thead = table.tHead;\n if (!thead || !thead.contains(th)) return;\n\n const col = th.cellIndex;\n if (col < 0) return;\n\n const tbody = table.tBodies?.[0];\n if (!tbody) return;\n\n const type = th.getAttribute('data-type') as SortType | null;\n if (!type) return;\n\n const direction = th.dataset.dir === 'asc' ? 'desc' : 'asc';\n setSortState(thead, th, direction);\n const dir = direction === 'asc' ? 1 : -1;\n\n const rows = Array.from(tbody.rows);\n\n rows.sort((a, b) => {\n const av = (a.cells[col]?.textContent ?? '').trim();\n const bv = (b.cells[col]?.textContent ?? '').trim();\n return compare(av, bv, type, locale, dir);\n });\n\n tbody.append(...rows);\n },\n [locale]\n );\n\n return (\n <table\n className={styles.table}\n onClick={onClick}\n ref={ref}\n {...props}\n >\n {normalizedChildren}\n </table>\n );\n};\n"],"names":["isTableElement","child","isValidElement","countCells","children","Children","toArray","reduce","count","type","props","getFirstRowCellCount","nestedCount","normalizeChildren","columnCount","map","nextChildren","undefined","nextProps","colSpan","jsxs","styles","sortable","Icon","cloneElement","compare","a","b","locale","dir","localeCompare","sensitivity","left","Date","parse","Number","parseFloat","right","isNaN","Table","ref","useRef","normalizedChildren","setSortState","thead","active","querySelectorAll","forEach","th","dataset","setAttribute","onClick","useCallback","e","table","current","target","closest","tHead","contains","col","cellIndex","tbody","tBodies","getAttribute","direction","rows","Array","from","sort","av","cells","textContent","trim","bv","append","jsx"],"mappings":"wOAmBMA,EAAkBC,GACtBC,EAAAA,eAAgCD,CAAK,EAEjCE,EAAcC,GAClBC,EAAAA,SAASC,QAAQF,CAAQ,EAAEG,OAAe,CAACC,EAAOP,IAC3CD,EAAeC,CAAK,EAEvBO,GAASP,EAAMQ,OAAS,MAAQR,EAAMQ,OAAS,KAAO,EAAIN,EAAWF,EAAMS,MAAMN,QAAQ,GAFxDI,EAIlC,CAAC,EAEAG,EAAwBP,GAA6C,CACzE,UAAWH,KAASI,EAAAA,SAASC,QAAQF,CAAQ,EAAG,CAC9C,GAAI,CAACJ,EAAeC,CAAK,EAAG,SAE5B,GAAIA,EAAMQ,OAAS,YAAaN,EAAWF,EAAMS,MAAMN,QAAQ,EAE/D,MAAMQ,EAAcD,EAAqBV,EAAMS,MAAMN,QAAQ,EAC7D,GAAIQ,IAAgB,KAAM,OAAOA,CACnC,CAEA,OAAO,IACT,EAEMC,EAAoBA,CAACT,EAA2BU,IACpDT,EAAAA,SAASU,IAAIX,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,EAAMmB,EAAQC,CAAG,CAC1C,CAAC,EAEDiC,EAAMa,OAAO,GAAGT,CAAI,CACtB,EACA,CAACtC,CAAM,CACT,EAEA,OACEgD,EAAAA,IAAC,QAAA,CACC,UAAWvD,EAAOiC,MAClB,QAAAH,EACA,IAAAX,EACA,GAAI9B,EAAM,iBAAA,QAETgC,SAAAA,CAAAA,CACH,CAEJ"}
1
+ {"version":3,"file":"index.cjs","sources":["../../../src/components/table/index.tsx"],"sourcesContent":["import { Children, cloneElement, isValidElement, useCallback, useRef } from 'react';\n\nimport { Icon } from '../icon';\nimport styles from './styles.module.css';\n\nexport type TableProps = React.TableHTMLAttributes<HTMLTableElement> & {\n children?: React.ReactNode;\n locale?: string | string[];\n};\n\ntype SortType = 'date' | 'number' | 'text';\n\ntype TableChildProps = {\n children?: React.ReactNode;\n colSpan?: number;\n 'data-span'?: string;\n 'data-type'?: SortType;\n};\n\nconst isTableElement = (child: React.ReactNode): child is React.ReactElement<TableChildProps> =>\n isValidElement<TableChildProps>(child);\n\nconst countCells = (children: React.ReactNode): number =>\n Children.toArray(children).reduce<number>((count, child) => {\n if (!isTableElement(child)) return count;\n return (\n count + (child.type === 'td' || child.type === 'th' ? 1 : countCells(child.props.children))\n );\n }, 0);\n\nconst getFirstRowCellCount = (children: React.ReactNode): number | null => {\n for (const child of Children.toArray(children)) {\n if (!isTableElement(child)) continue;\n\n if (child.type === 'tr') return countCells(child.props.children);\n\n const nestedCount = getFirstRowCellCount(child.props.children);\n if (nestedCount !== null) return nestedCount;\n }\n\n return null;\n};\n\nconst normalizeChildren = (children: React.ReactNode, columnCount: number): React.ReactNode =>\n Children.map(children, (child) => {\n if (!isTableElement(child)) return child;\n\n let nextChildren =\n child.props.children === undefined\n ? child.props.children\n : normalizeChildren(child.props.children, columnCount);\n let nextProps: Partial<TableChildProps> | undefined;\n\n if (child.type === 'td' && child.props['data-span'] === 'all') {\n nextProps = { colSpan: columnCount };\n }\n\n if (child.type === 'th' && child.props['data-type']) {\n nextChildren = (\n <span className={styles.sortable}>\n {nextChildren}\n <Icon\n name='updown'\n variant='primary'\n />\n </span>\n );\n }\n\n return nextProps || nextChildren !== child.props.children\n ? cloneElement(child, nextProps, nextChildren)\n : child;\n });\n\n/**\n * Sortable columns must provide data-type (text, number, or date) in the `th` element.\n */\n\nconst compare = (a: string, b: string, type: SortType, locale?: string | string[], dir = 1) => {\n if (type === 'text') {\n return a.localeCompare(b, locale, { sensitivity: 'base' }) * dir;\n }\n\n const left = type === 'date' ? Date.parse(a) : Number.parseFloat(a);\n const right = type === 'date' ? Date.parse(b) : Number.parseFloat(b);\n\n if (Number.isNaN(left) && Number.isNaN(right)) return 0;\n if (Number.isNaN(left)) return 1;\n if (Number.isNaN(right)) return -1;\n return (left - right) * dir;\n};\n\nexport const Table = ({ children, locale, ...props }: TableProps) => {\n const ref = useRef<HTMLTableElement | null>(null);\n const columnCount = getFirstRowCellCount(children);\n const normalizedChildren =\n columnCount && columnCount > 0 ? normalizeChildren(children, columnCount) : children;\n\n const setSortState = (\n thead: HTMLTableSectionElement,\n active: HTMLTableCellElement,\n dir: 'asc' | 'desc'\n ) => {\n const ths = thead.querySelectorAll<HTMLTableCellElement>('th[data-type]');\n\n ths.forEach((th) => {\n if (th === active) {\n th.dataset.dir = dir;\n th.setAttribute('aria-sort', dir === 'asc' ? 'ascending' : 'descending');\n } else {\n delete th.dataset.dir;\n th.setAttribute('aria-sort', 'none');\n }\n });\n };\n\n const onClick = useCallback(\n (e: React.MouseEvent<HTMLTableElement>) => {\n const table = ref.current;\n if (!table) return;\n\n const th = (e.target as HTMLElement | null)?.closest('th');\n if (!th) return;\n\n const thead = table.tHead;\n if (!thead || !thead.contains(th)) return;\n\n const col = th.cellIndex;\n if (col < 0) return;\n\n const tbody = table.tBodies?.[0];\n if (!tbody) return;\n\n const type = th.getAttribute('data-type') as SortType | null;\n if (!type) return;\n\n const direction = th.dataset.dir === 'asc' ? 'desc' : 'asc';\n setSortState(thead, th, direction);\n const dir = direction === 'asc' ? 1 : -1;\n\n const rows = Array.from(tbody.rows);\n\n rows.sort((a, b) => {\n const av = (a.cells[col]?.textContent ?? '').trim();\n const bv = (b.cells[col]?.textContent ?? '').trim();\n return compare(av, bv, type, locale, dir);\n });\n\n tbody.append(...rows);\n },\n [locale]\n );\n\n return (\n <table\n className={styles.table}\n onClick={onClick}\n ref={ref}\n {...props}\n >\n {normalizedChildren}\n </table>\n );\n};\n"],"names":["isTableElement","child","isValidElement","countCells","children","Children","toArray","reduce","count","type","props","getFirstRowCellCount","nestedCount","normalizeChildren","columnCount","map","nextChildren","undefined","nextProps","colSpan","jsxs","styles","sortable","jsx","Icon","cloneElement","compare","a","b","locale","dir","localeCompare","sensitivity","left","Date","parse","Number","parseFloat","right","isNaN","Table","ref","useRef","normalizedChildren","setSortState","thead","active","querySelectorAll","forEach","th","dataset","setAttribute","onClick","useCallback","e","table","current","target","closest","tHead","contains","col","cellIndex","tbody","tBodies","getAttribute","direction","rows","Array","from","sort","av","cells","textContent","trim","bv","append"],"mappings":"wOAmBMA,EAAkBC,GACtBC,EAAAA,eAAgCD,CAAK,EAEjCE,EAAcC,GAClBC,EAAAA,SAASC,QAAQF,CAAQ,EAAEG,OAAe,CAACC,EAAOP,IAC3CD,EAAeC,CAAK,EAEvBO,GAASP,EAAMQ,OAAS,MAAQR,EAAMQ,OAAS,KAAO,EAAIN,EAAWF,EAAMS,MAAMN,QAAQ,GAFxDI,EAIlC,CAAC,EAEAG,EAAwBP,GAA6C,CACzE,UAAWH,KAASI,EAAAA,SAASC,QAAQF,CAAQ,EAAG,CAC9C,GAAI,CAACJ,EAAeC,CAAK,EAAG,SAE5B,GAAIA,EAAMQ,OAAS,YAAaN,EAAWF,EAAMS,MAAMN,QAAQ,EAE/D,MAAMQ,EAAcD,EAAqBV,EAAMS,MAAMN,QAAQ,EAC7D,GAAIQ,IAAgB,KAAM,OAAOA,CACnC,CAEA,OAAO,IACT,EAEMC,EAAoBA,CAACT,EAA2BU,IACpDT,EA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AQ6C,EAAII,EAAIlE,EAAMoB,EAAQC,CAAG,CAC1C,CAAC,EAEDiC,EAAMa,OAAO,GAAGT,CAAI,CACtB,EACA,CAACtC,CAAM,CACT,EAEA,OACEN,EAAAA,IAAC,QAAA,CACC,UAAWF,EAAOkC,MAClB,QAAAH,EACA,IAAAX,EACA,GAAI/B,EAAM,iBAAA,QAETiC,SAAAA,CAAAA,CACH,CAEJ"}
@@ -1,43 +1,43 @@
1
- import { jsx as _, jsxs as I } from "react/jsx-runtime";
2
- import { useRef as R, useCallback as T, Children as f, cloneElement as q, isValidElement as B } from "react";
1
+ import { jsx as _, jsxs as D } from "react/jsx-runtime";
2
+ import { useRef as I, useCallback as R, Children as f, cloneElement as T, isValidElement as B } from "react";
3
3
  import { Icon as H } from "../icon/index.js";
4
- import '../../assets/index3.css';const P = "_table_18uji_1", V = "_sortable_18uji_27", h = {
4
+ import '../../assets/index3.css';const P = "_table_1egqd_1", V = "_sortable_1egqd_27", v = {
5
5
  table: P,
6
6
  sortable: V
7
- }, m = (r) => B(r), v = (r) => f.toArray(r).reduce((e, t) => m(t) ? e + (t.type === "td" || t.type === "th" ? 1 : v(t.props.children)) : e, 0), j = (r) => {
7
+ }, m = (r) => B(r), h = (r) => f.toArray(r).reduce((e, t) => m(t) ? e + (t.type === "td" || t.type === "th" ? 1 : h(t.props.children)) : e, 0), w = (r) => {
8
8
  for (const e of f.toArray(r)) {
9
9
  if (!m(e)) continue;
10
- if (e.type === "tr") return v(e.props.children);
11
- const t = j(e.props.children);
10
+ if (e.type === "tr") return h(e.props.children);
11
+ const t = w(e.props.children);
12
12
  if (t !== null) return t;
13
13
  }
14
14
  return null;
15
- }, w = (r, e) => f.map(r, (t) => {
15
+ }, E = (r, e) => f.map(r, (t) => {
16
16
  if (!m(t)) return t;
17
- let s = t.props.children === void 0 ? t.props.children : w(t.props.children, e), n;
17
+ let s = t.props.children === void 0 ? t.props.children : E(t.props.children, e), n;
18
18
  return t.type === "td" && t.props["data-span"] === "all" && (n = {
19
19
  colSpan: e
20
- }), t.type === "th" && t.props["data-type"] && (s = /* @__PURE__ */ I("span", { className: h.sortable, children: [
20
+ }), t.type === "th" && t.props["data-type"] && (s = /* @__PURE__ */ D("span", { className: v.sortable, children: [
21
21
  s,
22
- /* @__PURE__ */ _(H, { "aria-hidden": "true", name: "updown", variant: "primary" })
23
- ] })), n || s !== t.props.children ? q(t, n, s) : t;
22
+ /* @__PURE__ */ _(H, { name: "updown", variant: "primary" })
23
+ ] })), n || s !== t.props.children ? T(t, n, s) : t;
24
24
  }), G = (r, e, t, s, n = 1) => {
25
25
  if (t === "text")
26
26
  return r.localeCompare(e, s, {
27
27
  sensitivity: "base"
28
28
  }) * n;
29
- const i = t === "date" ? Date.parse(r) : Number.parseFloat(r), l = t === "date" ? Date.parse(e) : Number.parseFloat(e);
30
- return Number.isNaN(i) && Number.isNaN(l) ? 0 : Number.isNaN(i) ? 1 : Number.isNaN(l) ? -1 : (i - l) * n;
29
+ const l = t === "date" ? Date.parse(r) : Number.parseFloat(r), i = t === "date" ? Date.parse(e) : Number.parseFloat(e);
30
+ return Number.isNaN(l) && Number.isNaN(i) ? 0 : Number.isNaN(l) ? 1 : Number.isNaN(i) ? -1 : (l - i) * n;
31
31
  }, M = ({
32
32
  children: r,
33
33
  locale: e,
34
34
  ...t
35
35
  }) => {
36
- const s = R(null), n = j(r), i = n && n > 0 ? w(r, n) : r, l = (u, c, o) => {
36
+ const s = I(null), n = w(r), l = n && n > 0 ? E(r, n) : r, i = (u, c, o) => {
37
37
  u.querySelectorAll("th[data-type]").forEach((a) => {
38
38
  a === c ? (a.dataset.dir = o, a.setAttribute("aria-sort", o === "asc" ? "ascending" : "descending")) : (delete a.dataset.dir, a.setAttribute("aria-sort", "none"));
39
39
  });
40
- }, E = T((u) => {
40
+ }, S = R((u) => {
41
41
  var C, x;
42
42
  const c = s.current;
43
43
  if (!c) return;
@@ -52,15 +52,15 @@ import '../../assets/index3.css';const P = "_table_18uji_1", V = "_sortable_18uj
52
52
  const b = o.getAttribute("data-type");
53
53
  if (!b) return;
54
54
  const N = o.dataset.dir === "asc" ? "desc" : "asc";
55
- l(p, o, N);
56
- const S = N === "asc" ? 1 : -1, y = Array.from(d.rows);
57
- y.sort((F, k) => {
58
- var A, g;
59
- const z = (((A = F.cells[a]) == null ? void 0 : A.textContent) ?? "").trim(), D = (((g = k.cells[a]) == null ? void 0 : g.textContent) ?? "").trim();
60
- return G(z, D, b, e, S);
55
+ i(p, o, N);
56
+ const q = N === "asc" ? 1 : -1, y = Array.from(d.rows);
57
+ y.sort((F, j) => {
58
+ var g, A;
59
+ const k = (((g = F.cells[a]) == null ? void 0 : g.textContent) ?? "").trim(), z = (((A = j.cells[a]) == null ? void 0 : A.textContent) ?? "").trim();
60
+ return G(k, z, b, e, q);
61
61
  }), d.append(...y);
62
62
  }, [e]);
63
- return /* @__PURE__ */ _("table", { className: h.table, onClick: E, ref: s, ...t, "data-component": "table", children: i });
63
+ return /* @__PURE__ */ _("table", { className: v.table, onClick: S, ref: s, ...t, "data-component": "table", children: l });
64
64
  };
65
65
  export {
66
66
  M as Table