@companix/uikit 0.0.16 → 0.0.17

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 (59) hide show
  1. package/dist/DatePicker/index.d.ts +2 -3
  2. package/dist/Input/Form.scss +1 -4
  3. package/dist/Input/InlineInput.d.ts +0 -0
  4. package/dist/Input/{index.d.ts → Input.d.ts} +4 -8
  5. package/dist/Input/Input.scss +23 -0
  6. package/dist/Input/InputContainer.d.ts +11 -0
  7. package/dist/Input/InputElement.d.ts +7 -0
  8. package/dist/NumberInput/index.d.ts +2 -2
  9. package/dist/Select/SelectOptions.d.ts +12 -0
  10. package/dist/Select/SelectRight.d.ts +8 -0
  11. package/dist/Select/index.d.ts +5 -1
  12. package/dist/TimePicker/index.d.ts +10 -0
  13. package/dist/__hooks/use-input-padding.d.ts +5 -0
  14. package/dist/__hooks/use-scrollbox.d.ts +1 -1
  15. package/dist/__hooks/use-update.d.ts +1 -1
  16. package/dist/__utils/utils.d.ts +15 -1
  17. package/dist/bundle.es.js +30 -26
  18. package/dist/bundle.es10.js +1 -1
  19. package/dist/bundle.es14.js +1 -1
  20. package/dist/bundle.es19.js +1 -1
  21. package/dist/bundle.es20.js +1 -1
  22. package/dist/bundle.es23.js +1 -1
  23. package/dist/bundle.es24.js +2 -2
  24. package/dist/bundle.es25.js +93 -85
  25. package/dist/bundle.es26.js +67 -29
  26. package/dist/bundle.es27.js +34 -10
  27. package/dist/bundle.es28.js +11 -10
  28. package/dist/bundle.es29.js +82 -21
  29. package/dist/bundle.es30.js +10 -35
  30. package/dist/bundle.es31.js +21 -20
  31. package/dist/bundle.es32.js +36 -83
  32. package/dist/bundle.es33.js +23 -17
  33. package/dist/bundle.es34.js +87 -14
  34. package/dist/bundle.es35.js +18 -22
  35. package/dist/bundle.es36.js +20 -5
  36. package/dist/bundle.es37.js +24 -14
  37. package/dist/bundle.es38.js +39 -14
  38. package/dist/bundle.es39.js +20 -68
  39. package/dist/bundle.es40.js +5 -68
  40. package/dist/bundle.es41.js +13 -31
  41. package/dist/bundle.es42.js +14 -68
  42. package/dist/bundle.es43.js +66 -39
  43. package/dist/bundle.es44.js +67 -30
  44. package/dist/bundle.es45.js +69 -74
  45. package/dist/bundle.es46.js +10 -48
  46. package/dist/bundle.es47.js +45 -0
  47. package/dist/bundle.es48.js +34 -0
  48. package/dist/bundle.es49.js +70 -0
  49. package/dist/bundle.es50.js +16 -0
  50. package/dist/bundle.es51.js +45 -0
  51. package/dist/bundle.es52.js +77 -0
  52. package/dist/bundle.es53.js +51 -0
  53. package/dist/bundle.es54.js +16 -0
  54. package/dist/bundle.es8.js +54 -62
  55. package/dist/bundle.es9.js +35 -70
  56. package/dist/index.d.ts +3 -1
  57. package/dist/index.scss +2 -2
  58. package/dist/types.d.ts +4 -0
  59. package/package.json +2 -3
@@ -1,38 +1,76 @@
1
- import { jsxs as c, jsx as o } from "react/jsx-runtime";
2
- import { VisuallyHidden as s } from "@radix-ui/react-visually-hidden";
3
- import { useRef as p } from "react";
4
- const d = ({
5
- onChange: n,
1
+ import { jsxs as D, jsx as h } from "react/jsx-runtime";
2
+ import { useMemo as M, useEffect as C } from "react";
3
+ import { Select as c } from "./bundle.es8.js";
4
+ import { createDateValidation as O, getMonthMaxDay as T } from "./bundle.es45.js";
5
+ import { defaultMin as j, defaultMax as N, useCalendarOptions as V } from "./bundle.es47.js";
6
+ const B = ({
7
+ min: o = j,
8
+ max: e = N,
6
9
  disabled: r,
7
- mimes: l,
8
- children: a,
9
- multiple: i,
10
- className: f
10
+ value: a,
11
+ noDaySelect: g,
12
+ noYearSelect: u,
13
+ onChange: l,
14
+ required: m,
15
+ size: i
11
16
  }) => {
12
- const e = p(null), u = (t) => {
13
- r || (t.target.files && n?.(Array.from(t.target.files)), e.current && (e.current.value = ""));
17
+ const d = M(() => O({ min: o, max: e }), [o, e]);
18
+ C(() => {
19
+ const t = d(a);
20
+ t && l(t);
21
+ }, [d, a]);
22
+ const { years: p, months: w, days: f } = V({ min: o, max: e, now: a }), s = (t, x) => {
23
+ const n = { ...a };
24
+ n[t] = x;
25
+ const y = T(n.month, n.year);
26
+ n.day = n.day > y ? y : n.day, l(n);
14
27
  };
15
- return /* @__PURE__ */ c("label", { className: f, children: [
16
- a,
17
- /* @__PURE__ */ o(s, { asChild: !0, children: /* @__PURE__ */ o(
18
- "input",
28
+ return /* @__PURE__ */ D("div", { className: "data-input", children: [
29
+ !u && p.length > 0 && /* @__PURE__ */ h(
30
+ c,
19
31
  {
20
- ref: e,
21
- hidden: !0,
22
- type: "file",
23
- autoComplete: "off",
24
- autoCapitalize: "none",
25
- autoCorrect: "off",
26
- spellCheck: "false",
27
- "aria-autocomplete": "none",
28
- multiple: i,
29
- accept: (l ?? []).join(", "),
30
- onChange: u,
31
- disabled: r
32
+ placeholder: "Год",
33
+ options: p,
34
+ onChange: (t) => s("year", t),
35
+ value: a.year,
36
+ required: m,
37
+ disabled: r,
38
+ size: i,
39
+ minimalOptions: !0,
40
+ matchTarget: "min-width"
32
41
  }
33
- ) })
42
+ ),
43
+ /* @__PURE__ */ h(
44
+ c,
45
+ {
46
+ placeholder: "Месяц",
47
+ className: "w-full",
48
+ options: w,
49
+ onChange: (t) => s("month", t),
50
+ value: a.month,
51
+ disabled: r,
52
+ required: m,
53
+ size: i,
54
+ minimalOptions: !0,
55
+ matchTarget: "min-width"
56
+ }
57
+ ),
58
+ !g && /* @__PURE__ */ h(
59
+ c,
60
+ {
61
+ placeholder: "День",
62
+ options: f,
63
+ disabled: r || f.length === 0,
64
+ onChange: (t) => s("day", t),
65
+ value: a.day,
66
+ required: m,
67
+ size: i,
68
+ minimalOptions: !0,
69
+ matchTarget: "min-width"
70
+ }
71
+ )
34
72
  ] });
35
73
  };
36
74
  export {
37
- d as FileOverlay
75
+ B as DateInput
38
76
  };
@@ -1,14 +1,38 @@
1
- import { jsxs as p, jsx as a } from "react/jsx-runtime";
2
- import t from "classnames";
3
- import { attr as n } from "@companix/utils-browser";
4
- const u = (o) => {
5
- const { fill: e, className: l, label: c, children: i, caption: r, apperance: m = "neutral" } = o;
6
- return /* @__PURE__ */ p("div", { className: t("form-group", l), "data-fill": n(e), children: [
7
- /* @__PURE__ */ a("div", { className: "form-group-label", children: c }),
8
- i,
9
- r && /* @__PURE__ */ a("div", { className: "form-group-caption", "data-appearance": m, children: r })
1
+ import { jsxs as c, jsx as o } from "react/jsx-runtime";
2
+ import { VisuallyHidden as s } from "@radix-ui/react-visually-hidden";
3
+ import { useRef as p } from "react";
4
+ const d = ({
5
+ onChange: n,
6
+ disabled: r,
7
+ mimes: l,
8
+ children: a,
9
+ multiple: i,
10
+ className: f
11
+ }) => {
12
+ const e = p(null), u = (t) => {
13
+ r || (t.target.files && n?.(Array.from(t.target.files)), e.current && (e.current.value = ""));
14
+ };
15
+ return /* @__PURE__ */ c("label", { className: f, children: [
16
+ a,
17
+ /* @__PURE__ */ o(s, { asChild: !0, children: /* @__PURE__ */ o(
18
+ "input",
19
+ {
20
+ ref: e,
21
+ hidden: !0,
22
+ type: "file",
23
+ autoComplete: "off",
24
+ autoCapitalize: "none",
25
+ autoCorrect: "off",
26
+ spellCheck: "false",
27
+ "aria-autocomplete": "none",
28
+ multiple: i,
29
+ accept: (l ?? []).join(", "),
30
+ onChange: u,
31
+ disabled: r
32
+ }
33
+ ) })
10
34
  ] });
11
35
  };
12
36
  export {
13
- u as FormGroup
37
+ d as FileOverlay
14
38
  };
@@ -1,13 +1,14 @@
1
- import { useState as s, useEffect as c } from "react";
2
- const l = (e, a) => {
3
- const [t, o] = s(() => {
4
- const r = localStorage.getItem(e);
5
- return r ? JSON.parse(r) : a;
6
- });
7
- return c(() => {
8
- localStorage.setItem(e, JSON.stringify(t));
9
- }, [t]), [t, o];
1
+ import { jsxs as p, jsx as a } from "react/jsx-runtime";
2
+ import t from "classnames";
3
+ import { attr as n } from "@companix/utils-browser";
4
+ const u = (o) => {
5
+ const { fill: e, className: l, label: c, children: i, caption: r, apperance: m = "neutral" } = o;
6
+ return /* @__PURE__ */ p("div", { className: t("form-group", l), "data-fill": n(e), children: [
7
+ /* @__PURE__ */ a("div", { className: "form-group-label", children: c }),
8
+ i,
9
+ r && /* @__PURE__ */ a("div", { className: "form-group-caption", "data-appearance": m, children: r })
10
+ ] });
10
11
  };
11
12
  export {
12
- l as useLocalStorage
13
+ u as FormGroup
13
14
  };
@@ -1,27 +1,88 @@
1
- import { jsx as i } from "react/jsx-runtime";
2
- import { hash as m } from "@companix/utils-js";
3
- import { useRef as n, useMemo as s } from "react";
4
- import { Viewport as u } from "./bundle.es41.js";
5
- const h = (t = {}) => {
6
- const e = {
7
- emit: (r) => {
8
- console.error("uninitialized", r);
1
+ import { jsx as g } from "react/jsx-runtime";
2
+ import { useRef as _, useMemo as b, useState as P, useEffect as j } from "react";
3
+ import { getNum as v } from "@companix/utils-js";
4
+ import { getTimesOptions as D, getTimeValue as A, removeDigits as W, convertTimeToOption as q } from "./bundle.es45.js";
5
+ import { SelectRightElements as w } from "./bundle.es46.js";
6
+ import { Select as y } from "./bundle.es8.js";
7
+ import { Input as z } from "./bundle.es9.js";
8
+ const r = {
9
+ char: ":",
10
+ toString: (s) => s ? q(s, r.char) : "",
11
+ toValue: (s) => {
12
+ const n = s.split(r.char);
13
+ if (n.length === 2) {
14
+ const [e, i] = [v(n[0]), v(n[1])];
15
+ if (e !== null && i !== null && e < 24 && e >= 0 && i < 60 && i >= 0)
16
+ return { hours: e, minutes: i };
9
17
  }
10
- };
11
- return {
12
- show: (r) => {
13
- e.emit({ ...r, id: m() });
14
- },
15
- Viewport: () => {
16
- const r = n(null);
17
- return s(() => {
18
- e.emit = (o) => {
19
- r.current && r.current.showAlert(o);
20
- };
21
- }, []), /* @__PURE__ */ i(u, { ref: r, ...t });
18
+ return null;
19
+ }
20
+ }, U = (s) => {
21
+ const { value: n, onChange: e, clearButton: i, clearButtonIcon: I, disabled: a, ...T } = s, m = _(null), p = _(null), h = b(() => D(10), []), d = b(() => {
22
+ if (n && !n.minutes.toString().endsWith("0")) {
23
+ const t = n.hours * 6 + Math.trunc(n.minutes / 10), u = [...h];
24
+ return u.splice(t + 1, 0, A(n)), u;
22
25
  }
26
+ return h;
27
+ }, [h, n]), [o, l] = P(() => r.toString(n)), x = (t) => {
28
+ l(t);
29
+ const u = r.toValue(t);
30
+ u && e?.(u);
31
+ }, B = (t) => {
32
+ a || m.current && m.current.getAttribute("data-state") === "open" && t.preventDefault();
33
+ }, O = () => {
34
+ r.toValue(o) === null && l(r.toString(n ?? null));
35
+ }, R = (t) => {
36
+ e?.(r.toValue(t)), l(t);
37
+ }, k = (t) => {
38
+ t.stopPropagation(), l(""), e?.(null);
23
39
  };
40
+ return j(() => {
41
+ if (o && o !== "__:__") {
42
+ const [t, u] = o.split(":"), V = (c) => {
43
+ const [C, S] = c.split(""), [E, M] = [C === "_" ? "0" : C, S === "_" ? "0" : S];
44
+ return E + M;
45
+ }, N = [V(t), V(u)].join(":"), f = r.toValue(N);
46
+ if (f) {
47
+ const c = f.hours * 6 + Math.trunc(f.minutes / 10);
48
+ c !== -1 && p.current && p.current.scrollTo(c);
49
+ }
50
+ }
51
+ }, [d, o]), /* @__PURE__ */ g(
52
+ y,
53
+ {
54
+ minimalOptions: !0,
55
+ options: d,
56
+ onChange: R,
57
+ value: o,
58
+ popoverRef: m,
59
+ scrollRef: p,
60
+ disabled: a,
61
+ children: /* @__PURE__ */ g(
62
+ z,
63
+ {
64
+ ...T,
65
+ value: o,
66
+ disabled: a,
67
+ onClick: B,
68
+ onValueChange: x,
69
+ onBlur: O,
70
+ mask: "99:99",
71
+ placeholder: "00:00",
72
+ rightElement: /* @__PURE__ */ g(
73
+ w,
74
+ {
75
+ clearButton: i,
76
+ clearButtonIcon: I,
77
+ value: !!W(o, [":", "_"]),
78
+ onClear: k
79
+ }
80
+ )
81
+ }
82
+ )
83
+ }
84
+ );
24
85
  };
25
86
  export {
26
- h as createAlertAgent
87
+ U as TimePicker
27
88
  };
@@ -1,38 +1,13 @@
1
- import { jsx as a } from "react/jsx-runtime";
2
- import { hash as d } from "@companix/utils-js";
3
- import { Viewport as s } from "./bundle.es42.js";
4
- import { useRef as c, useMemo as l } from "react";
5
- const f = (i = {}) => {
6
- const t = {
7
- emit: (e) => {
8
- console.error("uninitialized", e);
9
- }
10
- };
11
- return {
12
- send: (e) => {
13
- t.emit({ ...e, id: d() });
14
- },
15
- Viewport: (e = {}) => {
16
- const n = c(null);
17
- return l(() => {
18
- t.emit = (r) => {
19
- n.current && n.current.addToast(r);
20
- };
21
- }, []), /* @__PURE__ */ a(
22
- s,
23
- {
24
- ref: n,
25
- align: e.align ?? i.align,
26
- closeIcon: e.closeIcon ?? i.closeIcon,
27
- duration: e.duration ?? i.duration,
28
- gap: e.gap ?? i.gap,
29
- side: e.side ?? i.side,
30
- swipeThreshold: e.swipeThreshold ?? i.swipeThreshold
31
- }
32
- );
33
- }
34
- };
1
+ import { useState as s, useEffect as c } from "react";
2
+ const l = (e, a) => {
3
+ const [t, o] = s(() => {
4
+ const r = localStorage.getItem(e);
5
+ return r ? JSON.parse(r) : a;
6
+ });
7
+ return c(() => {
8
+ localStorage.setItem(e, JSON.stringify(t));
9
+ }, [t]), [t, o];
35
10
  };
36
11
  export {
37
- f as createToaster
12
+ l as useLocalStorage
38
13
  };
@@ -1,26 +1,27 @@
1
- import { useRef as s, useCallback as c } from "react";
2
- const p = () => {
3
- const t = s(null), r = s({ cb: null }), i = c(() => {
4
- if (t.current && t.current.parentElement) {
5
- const e = t.current.parentElement, u = e.style.getPropertyValue("--radix-popper-anchor-width"), n = e.style.getPropertyValue("transform"), o = new MutationObserver(() => {
6
- e.style.transform !== n && e.style.setProperty("transform", n);
7
- });
8
- o.observe(e, {
9
- attributes: !0,
10
- attributeFilter: ["style"]
11
- }), r.current.cb = () => {
12
- o.disconnect();
13
- }, t.current.style.setProperty("--radix-popover-trigger-width", u);
1
+ import { jsx as i } from "react/jsx-runtime";
2
+ import { hash as m } from "@companix/utils-js";
3
+ import { useRef as n, useMemo as s } from "react";
4
+ import { Viewport as u } from "./bundle.es48.js";
5
+ const h = (t = {}) => {
6
+ const e = {
7
+ emit: (r) => {
8
+ console.error("uninitialized", r);
14
9
  }
15
- }, []), l = c(() => {
16
- r.current.cb && (r.current.cb(), r.current.cb = null);
17
- }, []);
10
+ };
18
11
  return {
19
- popoverRef: t,
20
- handleAnimationEnd: l,
21
- froozePopoverPosition: i
12
+ show: (r) => {
13
+ e.emit({ ...r, id: m() });
14
+ },
15
+ Viewport: () => {
16
+ const r = n(null);
17
+ return s(() => {
18
+ e.emit = (o) => {
19
+ r.current && r.current.showAlert(o);
20
+ };
21
+ }, []), /* @__PURE__ */ i(u, { ref: r, ...t });
22
+ }
22
23
  };
23
24
  };
24
25
  export {
25
- p as useFroozeClosing
26
+ h as createAlertAgent
26
27
  };
@@ -1,85 +1,38 @@
1
- import { jsxs as n, jsx as c } from "react/jsx-runtime";
2
- import R from "classnames";
3
- import { attr as r } from "@companix/utils-browser";
4
- import { forwardRef as b, useRef as w, useCallback as y } from "react";
5
- import { Icon as a } from "./bundle.es35.js";
6
- import { faClose as D, faChevronDown as T } from "@fortawesome/free-solid-svg-icons";
7
- import { VisuallyHidden as j } from "@radix-ui/react-visually-hidden";
8
- import { mergeRefs as O } from "react-merge-refs";
9
- const J = b(
10
- ({
11
- required: u,
12
- size: d,
13
- fill: m,
14
- leftElement: l,
15
- className: f,
16
- value: o,
17
- clearButton: p,
18
- placeholder: C,
19
- clearButtonIcon: h,
20
- disabled: s,
21
- onClear: I,
22
- inputRef: N,
23
- ...i
24
- }, k) => {
25
- const e = w(null), x = y(
26
- (t) => {
27
- if (!e.current || !document)
28
- return;
29
- t.target !== e.current && (e.current.click(), document.activeElement !== e.current && e.current.focus());
30
- },
31
- [e]
32
- ), v = (t) => {
33
- document && document.activeElement === e.current && t.preventDefault();
34
- }, F = (t) => {
35
- s || x(t);
36
- }, g = (t) => {
37
- v(t);
38
- }, z = (t) => {
39
- e.current && e.current.focus(), I?.(t);
40
- };
41
- return /* @__PURE__ */ n(
42
- "div",
43
- {
44
- ref: k,
45
- className: R("form select", f),
46
- "data-size": d ?? "md",
47
- "data-fill": r(m),
48
- "data-required": r(u),
49
- "data-disabled": r(s),
50
- onMouseDown: g,
51
- ...i,
52
- onClick: F,
53
- children: [
54
- /* @__PURE__ */ n("div", { className: "select-layout form-input", children: [
55
- l && /* @__PURE__ */ c("div", { className: "select-element", children: l }),
56
- /* @__PURE__ */ c("div", { className: "select-content", children: /* @__PURE__ */ n("div", { className: "select-content-text", "aria-disabled": s, children: [
57
- !o && /* @__PURE__ */ c("span", { className: "select-placeholder", children: C }),
58
- o
59
- ] }) }),
60
- /* @__PURE__ */ n("div", { className: "select-element", children: [
61
- p && o && /* @__PURE__ */ c("button", { className: "select-close-button", onClick: z, children: h ?? /* @__PURE__ */ c(a, { className: "select-close-icon", icon: D, size: "xxxs" }) }),
62
- /* @__PURE__ */ c(a, { className: "expand-icon select-expand", icon: T, size: "xxxs" })
63
- ] })
64
- ] }),
65
- /* @__PURE__ */ c(j, { asChild: !0, children: /* @__PURE__ */ c(
66
- "input",
67
- {
68
- ref: O([N, e]),
69
- autoComplete: "off",
70
- autoCapitalize: "none",
71
- autoCorrect: "off",
72
- spellCheck: "false",
73
- "aria-autocomplete": "none",
74
- onClick: i.onClick,
75
- readOnly: !0
76
- }
77
- ) })
78
- ]
79
- }
80
- );
81
- }
82
- );
1
+ import { jsx as a } from "react/jsx-runtime";
2
+ import { hash as d } from "@companix/utils-js";
3
+ import { Viewport as s } from "./bundle.es49.js";
4
+ import { useRef as c, useMemo as l } from "react";
5
+ const f = (i = {}) => {
6
+ const t = {
7
+ emit: (e) => {
8
+ console.error("uninitialized", e);
9
+ }
10
+ };
11
+ return {
12
+ send: (e) => {
13
+ t.emit({ ...e, id: d() });
14
+ },
15
+ Viewport: (e = {}) => {
16
+ const n = c(null);
17
+ return l(() => {
18
+ t.emit = (r) => {
19
+ n.current && n.current.addToast(r);
20
+ };
21
+ }, []), /* @__PURE__ */ a(
22
+ s,
23
+ {
24
+ ref: n,
25
+ align: e.align ?? i.align,
26
+ closeIcon: e.closeIcon ?? i.closeIcon,
27
+ duration: e.duration ?? i.duration,
28
+ gap: e.gap ?? i.gap,
29
+ side: e.side ?? i.side,
30
+ swipeThreshold: e.swipeThreshold ?? i.swipeThreshold
31
+ }
32
+ );
33
+ }
34
+ };
35
+ };
83
36
  export {
84
- J as SelectInput
37
+ f as createToaster
85
38
  };
@@ -1,20 +1,26 @@
1
- import { useRef as i, useCallback as T } from "react";
2
- const a = () => {
3
- const t = i(null), l = i(null);
4
- return { scrollToElement: T(
5
- (r, u = !1) => {
6
- const o = t.current, s = l.current;
7
- if (!o || !s || r < 0 || r > s.children.length)
8
- return;
9
- const n = s.children[r];
10
- if (!n)
11
- return;
12
- const c = o.offsetHeight, f = o.scrollTop, e = n.offsetTop, p = n.offsetHeight;
13
- u ? o.scrollTop = e - c / 2 + p / 2 : e + p > c + f ? o.scrollTop = e - c + p : e < f && (o.scrollTop = e);
14
- },
15
- [l, t]
16
- ), scrollBoxRef: t, optionsWrapperRef: l };
1
+ import { useRef as s, useCallback as c } from "react";
2
+ const p = () => {
3
+ const t = s(null), r = s({ cb: null }), i = c(() => {
4
+ if (t.current && t.current.parentElement) {
5
+ const e = t.current.parentElement, u = e.style.getPropertyValue("--radix-popper-anchor-width"), n = e.style.getPropertyValue("transform"), o = new MutationObserver(() => {
6
+ e.style.transform !== n && e.style.setProperty("transform", n);
7
+ });
8
+ o.observe(e, {
9
+ attributes: !0,
10
+ attributeFilter: ["style"]
11
+ }), r.current.cb = () => {
12
+ o.disconnect();
13
+ }, t.current.style.setProperty("--radix-popover-trigger-width", u);
14
+ }
15
+ }, []), l = c(() => {
16
+ r.current.cb && (r.current.cb(), r.current.cb = null);
17
+ }, []);
18
+ return {
19
+ popoverRef: t,
20
+ handleAnimationEnd: l,
21
+ froozePopoverPosition: i
22
+ };
17
23
  };
18
24
  export {
19
- a as useScrollListController
25
+ p as useFroozeClosing
20
26
  };
@@ -1,16 +1,89 @@
1
- import { useRef as u, useLayoutEffect as f, useEffect as s } from "react";
2
- const o = (t, r) => {
3
- const e = u(!1);
4
- f(() => {
5
- e.current = !0, t();
6
- }, []), s(() => {
7
- if (e.current) {
8
- e.current = !1;
9
- return;
10
- }
11
- t();
12
- }, r);
13
- };
1
+ import { jsxs as o, jsx as c } from "react/jsx-runtime";
2
+ import A from "classnames";
3
+ import { attr as l } from "@companix/utils-browser";
4
+ import { forwardRef as y, useRef as S, useCallback as T } from "react";
5
+ import { VisuallyHidden as j } from "@radix-ui/react-visually-hidden";
6
+ import { mergeRefs as w } from "react-merge-refs";
7
+ import { SelectRightElements as z } from "./bundle.es46.js";
8
+ const V = y(
9
+ ({
10
+ required: a,
11
+ size: u,
12
+ fill: d,
13
+ leftElement: s,
14
+ className: m,
15
+ value: n,
16
+ clearButton: f,
17
+ placeholder: p,
18
+ clearButtonIcon: h,
19
+ disabled: r,
20
+ onClear: C,
21
+ inputRef: I,
22
+ ...i
23
+ }, k) => {
24
+ const e = S(null), N = T(
25
+ (t) => {
26
+ if (!e.current || !document)
27
+ return;
28
+ t.target !== e.current && (e.current.click(), document.activeElement !== e.current && e.current.focus());
29
+ },
30
+ [e]
31
+ ), v = (t) => {
32
+ document && document.activeElement === e.current && t.preventDefault();
33
+ }, F = (t) => {
34
+ r || N(t);
35
+ }, g = (t) => {
36
+ v(t);
37
+ }, R = (t) => {
38
+ e.current && e.current.focus(), C?.(t);
39
+ };
40
+ return /* @__PURE__ */ o(
41
+ "div",
42
+ {
43
+ ref: k,
44
+ className: A("form select", m),
45
+ "data-size": u ?? "md",
46
+ "data-fill": l(d),
47
+ "data-required": l(a),
48
+ "data-disabled": l(r),
49
+ onMouseDown: g,
50
+ ...i,
51
+ onClick: F,
52
+ children: [
53
+ /* @__PURE__ */ o("div", { className: "select-layout form-input", children: [
54
+ s && /* @__PURE__ */ c("div", { className: "select-element", children: s }),
55
+ /* @__PURE__ */ c("div", { className: "select-content", children: /* @__PURE__ */ o("div", { className: "select-content-text", "aria-disabled": r, children: [
56
+ !n && /* @__PURE__ */ c("span", { className: "select-placeholder", children: p }),
57
+ n
58
+ ] }) }),
59
+ /* @__PURE__ */ c("div", { className: "select-element", children: /* @__PURE__ */ c(
60
+ z,
61
+ {
62
+ clearButton: f,
63
+ value: !!n,
64
+ clearButtonIcon: h,
65
+ onClear: R
66
+ }
67
+ ) })
68
+ ] }),
69
+ /* @__PURE__ */ c(j, { asChild: !0, children: /* @__PURE__ */ c(
70
+ "input",
71
+ {
72
+ ref: w([I, e]),
73
+ autoComplete: "off",
74
+ autoCapitalize: "none",
75
+ autoCorrect: "off",
76
+ spellCheck: "false",
77
+ "aria-autocomplete": "none",
78
+ onClick: i.onClick,
79
+ readOnly: !0
80
+ }
81
+ ) })
82
+ ]
83
+ }
84
+ );
85
+ }
86
+ );
14
87
  export {
15
- o as useLayoutAndUpdate
88
+ V as SelectInput
16
89
  };