@companix/uikit 0.0.9 → 0.0.12

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 (44) hide show
  1. package/README.md +16 -0
  2. package/dist/DatePicker/index.d.ts +1 -1
  3. package/dist/FormGroup/FormGroup.scss +32 -0
  4. package/dist/FormGroup/index.d.ts +10 -0
  5. package/dist/{Form → Input}/index.d.ts +1 -1
  6. package/dist/NumberInput/index.d.ts +1 -1
  7. package/dist/Select/index.d.ts +1 -1
  8. package/dist/bundle.es.js +18 -16
  9. package/dist/bundle.es10.js +1 -1
  10. package/dist/bundle.es11.js +7 -7
  11. package/dist/bundle.es14.js +1 -1
  12. package/dist/bundle.es19.js +1 -1
  13. package/dist/bundle.es20.js +1 -1
  14. package/dist/bundle.es23.js +1 -1
  15. package/dist/bundle.es24.js +2 -2
  16. package/dist/bundle.es25.js +14 -14
  17. package/dist/bundle.es27.js +11 -10
  18. package/dist/bundle.es28.js +10 -24
  19. package/dist/bundle.es29.js +17 -28
  20. package/dist/bundle.es30.js +32 -20
  21. package/dist/bundle.es31.js +24 -81
  22. package/dist/bundle.es32.js +81 -18
  23. package/dist/bundle.es33.js +17 -13
  24. package/dist/bundle.es34.js +14 -22
  25. package/dist/bundle.es35.js +22 -5
  26. package/dist/bundle.es36.js +5 -21
  27. package/dist/bundle.es37.js +20 -13
  28. package/dist/bundle.es38.js +13 -69
  29. package/dist/bundle.es39.js +68 -66
  30. package/dist/bundle.es40.js +67 -31
  31. package/dist/bundle.es41.js +23 -59
  32. package/dist/bundle.es42.js +63 -38
  33. package/dist/bundle.es43.js +42 -30
  34. package/dist/bundle.es44.js +30 -74
  35. package/dist/bundle.es45.js +71 -45
  36. package/dist/bundle.es46.js +51 -0
  37. package/dist/bundle.es8.js +3 -3
  38. package/dist/bundle.es9.js +26 -24
  39. package/dist/index.d.ts +2 -1
  40. package/dist/index.scss +3 -2
  41. package/package.json +4 -3
  42. package/dist/normalize.css +0 -376
  43. /package/dist/{Form → Input}/Form.scss +0 -0
  44. /package/dist/{Form → Input}/Input.scss +0 -0
package/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # Unset browser styles
2
+
3
+ If you're not using @tailwind with preflighting, you'll need to override the browser's default styles using the `modern-normalize` package.
4
+ Tailwind's preflighting is actually built on top of the `modern-normalize` package.
5
+
6
+ ## Install
7
+
8
+ ```sh
9
+ npm i modern-normalize
10
+ ```
11
+
12
+ ## Usage
13
+
14
+ ```css
15
+ @import 'node_modules/modern-normalize/modern-normalize.css';
16
+ ```
@@ -1,4 +1,4 @@
1
- import { FormProps } from '../Form';
1
+ import { FormProps } from '../Input';
2
2
  import { CalendarProps } from './Calendar';
3
3
  interface DatePickerProps extends Omit<CalendarProps, 'onChange'>, Omit<FormProps, 'value' | 'onChange' | 'rightElement'> {
4
4
  onChange?: (value: Date | null) => void;
@@ -0,0 +1,32 @@
1
+ @use '../mixins.scss';
2
+
3
+ .form-group {
4
+ display: flex;
5
+ flex-direction: column;
6
+
7
+ &[data-fill] {
8
+ width: 100%;
9
+ }
10
+
11
+ &-label {
12
+ @include mixins.truncate-text();
13
+ @include mixins.use-styles(form-group, label);
14
+ }
15
+
16
+ &-caption {
17
+ @include mixins.truncate-text();
18
+ @include mixins.use-styles(form-group, caption);
19
+
20
+ &[data-appearance='neutral'] {
21
+ @include mixins.use-styles(form-group, caption, neutral);
22
+ }
23
+
24
+ &[data-appearance='positive'] {
25
+ @include mixins.use-styles(form-group, caption, positive);
26
+ }
27
+
28
+ &[data-appearance='negative'] {
29
+ @include mixins.use-styles(form-group, caption, negative);
30
+ }
31
+ }
32
+ }
@@ -0,0 +1,10 @@
1
+ interface FormLabelProps {
2
+ label: React.ReactNode;
3
+ children: React.ReactNode;
4
+ caption?: React.ReactNode;
5
+ apperance?: 'neutral' | 'positive' | 'negative';
6
+ fill?: boolean;
7
+ className?: string;
8
+ }
9
+ export declare const FormGroup: (props: FormLabelProps) => import("react/jsx-runtime").JSX.Element;
10
+ export {};
@@ -14,4 +14,4 @@ export interface FormProps extends React.HTMLAttributes<HTMLDivElement> {
14
14
  mask?: string;
15
15
  maskChar?: string;
16
16
  }
17
- export declare const Form: import('react').ForwardRefExoticComponent<FormProps & import('react').RefAttributes<HTMLDivElement>>;
17
+ export declare const Input: import('react').ForwardRefExoticComponent<FormProps & import('react').RefAttributes<HTMLDivElement>>;
@@ -1,4 +1,4 @@
1
- import { FormProps } from '../Form';
1
+ import { FormProps } from '../Input';
2
2
  export interface NumberInputProps extends Omit<FormProps, 'value' | 'onChange'> {
3
3
  value: number | null;
4
4
  onChange: (value: number | null) => void;
@@ -1,4 +1,4 @@
1
- import { FormProps } from '../Form';
1
+ import { FormProps } from '../Input';
2
2
  import { Option } from '../types';
3
3
  interface SelectProps<T> extends Omit<FormProps, 'value' | 'onChange' | 'rightElement'> {
4
4
  options: Option<T>[];
package/dist/bundle.es.js CHANGED
@@ -5,16 +5,16 @@ import { ImitateScroll as a } from "./bundle.es5.js";
5
5
  import { Popover as i } from "./bundle.es6.js";
6
6
  import { Tooltip as c } from "./bundle.es7.js";
7
7
  import { Select as S } from "./bundle.es8.js";
8
- import { Form as g } from "./bundle.es9.js";
8
+ import { Input as g } from "./bundle.es9.js";
9
9
  import { OptionItem as b } from "./bundle.es10.js";
10
10
  import { NumberInput as D } from "./bundle.es11.js";
11
- import { OptionsList as w } from "./bundle.es12.js";
12
- import { ButtonGroup as I } from "./bundle.es13.js";
11
+ import { OptionsList as d } from "./bundle.es12.js";
12
+ import { ButtonGroup as B } from "./bundle.es13.js";
13
13
  import { Checkbox as O } from "./bundle.es14.js";
14
14
  import { Switch as k } from "./bundle.es15.js";
15
15
  import { Radio as C } from "./bundle.es16.js";
16
- import { Drawer as P } from "./bundle.es17.js";
17
- import { Dialog as G } from "./bundle.es18.js";
16
+ import { Drawer as G } from "./bundle.es17.js";
17
+ import { Dialog as y } from "./bundle.es18.js";
18
18
  import { AlertDialog as R } from "./bundle.es19.js";
19
19
  import { LoadButton as q } from "./bundle.es20.js";
20
20
  import { Tabs as E } from "./bundle.es21.js";
@@ -23,25 +23,27 @@ import { TextArea as M } from "./bundle.es23.js";
23
23
  import { SelectTags as U } from "./bundle.es24.js";
24
24
  import { DatePicker as W } from "./bundle.es25.js";
25
25
  import { FileOverlay as Y } from "./bundle.es26.js";
26
- import { useLocalStorage as _ } from "./bundle.es27.js";
27
- import { createAlertAgent as oo } from "./bundle.es28.js";
28
- import { createToaster as eo } from "./bundle.es29.js";
26
+ import { FormGroup as _ } from "./bundle.es27.js";
27
+ import { useLocalStorage as oo } from "./bundle.es28.js";
28
+ import { createAlertAgent as eo } from "./bundle.es29.js";
29
+ import { createToaster as po } from "./bundle.es30.js";
29
30
  export {
30
31
  R as AlertDialog,
31
32
  e as Button,
32
- I as ButtonGroup,
33
+ B as ButtonGroup,
33
34
  O as Checkbox,
34
35
  J as Countdown,
35
36
  W as DatePicker,
36
- G as Dialog,
37
- P as Drawer,
37
+ y as Dialog,
38
+ G as Drawer,
38
39
  Y as FileOverlay,
39
- g as Form,
40
+ _ as FormGroup,
40
41
  a as ImitateScroll,
42
+ g as Input,
41
43
  q as LoadButton,
42
44
  D as NumberInput,
43
45
  b as OptionItem,
44
- w as OptionsList,
46
+ d as OptionsList,
45
47
  i as Popover,
46
48
  C as Radio,
47
49
  x as Scrollable,
@@ -52,7 +54,7 @@ export {
52
54
  E as Tabs,
53
55
  M as TextArea,
54
56
  c as Tooltip,
55
- oo as createAlertAgent,
56
- eo as createToaster,
57
- _ as useLocalStorage
57
+ eo as createAlertAgent,
58
+ po as createToaster,
59
+ oo as useLocalStorage
58
60
  };
@@ -1,6 +1,6 @@
1
1
  import { jsxs as i, jsx as o } from "react/jsx-runtime";
2
2
  import N from "classnames";
3
- import { Icon as v } from "./bundle.es34.js";
3
+ import { Icon as v } from "./bundle.es35.js";
4
4
  import { attr as t } from "@companix/utils-browser";
5
5
  import { forwardRef as k } from "react";
6
6
  import { faCheck as x } from "@fortawesome/free-solid-svg-icons";
@@ -1,15 +1,15 @@
1
1
  import { jsx as f } from "react/jsx-runtime";
2
- import { useState as m, useRef as p } from "react";
3
- import { Form as l } from "./bundle.es9.js";
2
+ import { useState as p, useRef as m } from "react";
3
+ import { Input as l } from "./bundle.es9.js";
4
4
  const N = ({ value: r, onChange: u, ...e }) => {
5
- const [, t] = m([]), n = p(o(r));
6
- return +n.current !== r && (n.current = o(r)), /* @__PURE__ */ f(
5
+ const [, t] = p([]), n = m(i(r));
6
+ return +n.current !== r && (n.current = i(r)), /* @__PURE__ */ f(
7
7
  l,
8
8
  {
9
9
  ...e,
10
10
  value: n.current,
11
- onChange: (i) => {
12
- const s = i.currentTarget.value.trim();
11
+ onChange: (o) => {
12
+ const s = o.currentTarget.value.trim();
13
13
  if (s === "")
14
14
  return n.current = "", u(null);
15
15
  if (!(s.startsWith(".") || s.replace(".", "").split("").some((c) => isNaN(parseInt(c))))) {
@@ -20,7 +20,7 @@ const N = ({ value: r, onChange: u, ...e }) => {
20
20
  }
21
21
  }
22
22
  );
23
- }, o = (r) => r === null ? "" : r.toString(), a = (r) => {
23
+ }, i = (r) => r === null ? "" : r.toString(), a = (r) => {
24
24
  const u = [...r], e = [...r];
25
25
  if (e.every((t) => t === "0"))
26
26
  return "0";
@@ -1,6 +1,6 @@
1
1
  import { jsxs as x, jsx as o } from "react/jsx-runtime";
2
2
  import * as t from "@radix-ui/react-checkbox";
3
- import { Icon as h } from "./bundle.es34.js";
3
+ import { Icon as h } from "./bundle.es35.js";
4
4
  import { faCheck as l } from "@fortawesome/free-solid-svg-icons";
5
5
  import { useId as n } from "react";
6
6
  import { attr as c } from "@companix/utils-browser";
@@ -1,7 +1,7 @@
1
1
  import { jsxs as a, jsx as e } from "react/jsx-runtime";
2
2
  import * as r from "@radix-ui/react-alert-dialog";
3
3
  import { Button as c } from "./bundle.es2.js";
4
- import { RemoveListener as N } from "./bundle.es35.js";
4
+ import { RemoveListener as N } from "./bundle.es36.js";
5
5
  import { VisuallyHidden as u } from "@radix-ui/react-visually-hidden";
6
6
  const C = ({
7
7
  open: d,
@@ -1,6 +1,6 @@
1
1
  import { jsx as e } from "react/jsx-runtime";
2
2
  import { Button as m } from "./bundle.es2.js";
3
- import { useLoading as p } from "./bundle.es36.js";
3
+ import { useLoading as p } from "./bundle.es37.js";
4
4
  const g = ({ onClick: o, appearance: r = "primary", ...i }) => {
5
5
  const { isLoading: n, isError: t, handleClick: a } = p({ onClick: o });
6
6
  return /* @__PURE__ */ e(
@@ -1,5 +1,5 @@
1
1
  import { jsx as f } from "react/jsx-runtime";
2
- import { useResizeTextarea as p } from "./bundle.es37.js";
2
+ import { useResizeTextarea as p } from "./bundle.es38.js";
3
3
  import { attr as e, callMultiple as x } from "@companix/utils-browser";
4
4
  import { useEffect as u } from "react";
5
5
  const R = ({
@@ -1,10 +1,10 @@
1
1
  import { jsx as o, jsxs as c } from "react/jsx-runtime";
2
- import { useFroozeClosing as F } from "./bundle.es30.js";
2
+ import { useFroozeClosing as F } from "./bundle.es31.js";
3
3
  import { Popover as I } from "./bundle.es6.js";
4
4
  import { OptionItem as L } from "./bundle.es10.js";
5
5
  import { OptionsList as M } from "./bundle.es12.js";
6
6
  import { useState as j, useRef as d, useMemo as h } from "react";
7
- import { Icon as g } from "./bundle.es34.js";
7
+ import { Icon as g } from "./bundle.es35.js";
8
8
  import { faClose as V, faChevronDown as B } from "@fortawesome/free-solid-svg-icons";
9
9
  import { attr as H, getActiveElementByAnotherElement as Q, contains as q } from "@companix/utils-browser";
10
10
  const ee = (v) => {
@@ -1,19 +1,19 @@
1
1
  import { jsx as l, jsxs as O, Fragment as R } from "react/jsx-runtime";
2
2
  import { Popover as z } from "./bundle.es6.js";
3
- import { Form as Y } from "./bundle.es9.js";
3
+ import { Input as Y } from "./bundle.es9.js";
4
4
  import { faClose as E, faChevronDown as S } from "@fortawesome/free-solid-svg-icons";
5
- import { Icon as F } from "./bundle.es34.js";
5
+ import { Icon as k } from "./bundle.es35.js";
6
6
  import { useState as _, useRef as q } from "react";
7
- import { Calendar as G } from "./bundle.es38.js";
8
- import { useDayDisableCheker as H } from "./bundle.es39.js";
9
- import { formatTime as I, getNum as d } from "@companix/utils-js";
7
+ import { Calendar as G } from "./bundle.es39.js";
8
+ import { useDayDisableCheker as H } from "./bundle.es40.js";
9
+ import { formatTime as y, getNum as d } from "@companix/utils-js";
10
10
  const h = (t, i = "-") => {
11
11
  if (t) {
12
- const n = I(t.getDate()), r = I(t.getMonth() + 1), s = t.getFullYear();
12
+ const n = y(t.getDate()), r = y(t.getMonth() + 1), s = t.getFullYear();
13
13
  return [n, r, s].join(i);
14
14
  }
15
15
  return "";
16
- }, y = (t, i = "-") => {
16
+ }, F = (t, i = "-") => {
17
17
  const n = t.split(i);
18
18
  if (n.length === 3) {
19
19
  const [r, s, a] = [d(n[0]), d(n[1]), d(n[2])];
@@ -45,7 +45,7 @@ const h = (t, i = "-") => {
45
45
  maxDateTime: x,
46
46
  // input props
47
47
  ...T
48
- } = t, [m, c] = _(() => h(o ?? null)), p = q(null), k = H({
48
+ } = t, [m, c] = _(() => h(o ?? null)), p = q(null), I = H({
49
49
  disableFuture: C,
50
50
  disablePast: D,
51
51
  shouldDisableDate: g,
@@ -57,11 +57,11 @@ const h = (t, i = "-") => {
57
57
  e.stopPropagation(), c(""), u?.(null);
58
58
  }, V = (e) => {
59
59
  c(e);
60
- const f = y(e);
61
- f && !k(f) && u?.(f);
60
+ const f = F(e);
61
+ f && !I(f) && u?.(f);
62
62
  }, j = () => {
63
- const e = y(m);
64
- (!e || k(e)) && c(h(o ?? null));
63
+ const e = F(m);
64
+ (!e || I(e)) && c(h(o ?? null));
65
65
  }, M = (e) => {
66
66
  u?.(e), c(h(e));
67
67
  };
@@ -101,8 +101,8 @@ const h = (t, i = "-") => {
101
101
  onBlur: j,
102
102
  mask: "99-99-9999",
103
103
  rightElement: /* @__PURE__ */ O(R, { children: [
104
- n && J(m) && /* @__PURE__ */ l("button", { className: "select-close-button", onClick: B, children: r ?? /* @__PURE__ */ l(F, { className: "select-close-icon", icon: E, size: "xxxs" }) }),
105
- /* @__PURE__ */ l(F, { className: "expand-icon select-expand", icon: S, size: "xxxs" })
104
+ n && J(m) && /* @__PURE__ */ l("button", { className: "select-close-button", onClick: B, children: r ?? /* @__PURE__ */ l(k, { className: "select-close-icon", icon: E, size: "xxxs" }) }),
105
+ /* @__PURE__ */ l(k, { className: "expand-icon select-expand", icon: S, size: "xxxs" })
106
106
  ] })
107
107
  }
108
108
  )
@@ -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,13 @@
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.es40.js";
5
- const h = (t = {}) => {
6
- const e = {
7
- emit: (r) => {
8
- console.error("uninitialized", r);
9
- }
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 });
22
- }
23
- };
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];
24
10
  };
25
11
  export {
26
- h as createAlertAgent
12
+ l as useLocalStorage
27
13
  };
@@ -1,38 +1,27 @@
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.es41.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);
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);
9
9
  }
10
10
  };
11
11
  return {
12
- send: (e) => {
13
- t.emit({ ...e, id: d() });
12
+ show: (r) => {
13
+ e.emit({ ...r, id: m() });
14
14
  },
15
- Viewport: (e = {}) => {
16
- const n = c(null);
17
- return l(() => {
18
- t.emit = (r) => {
19
- n.current && n.current.addToast(r);
15
+ Viewport: () => {
16
+ const r = n(null);
17
+ return s(() => {
18
+ e.emit = (o) => {
19
+ r.current && r.current.showAlert(o);
20
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
- );
21
+ }, []), /* @__PURE__ */ i(u, { ref: r, ...t });
33
22
  }
34
23
  };
35
24
  };
36
25
  export {
37
- f as createToaster
26
+ h as createAlertAgent
38
27
  };
@@ -1,26 +1,38 @@
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 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);
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
+ 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
+ }
22
34
  };
23
35
  };
24
36
  export {
25
- p as useFroozeClosing
37
+ f as createToaster
26
38
  };
@@ -1,83 +1,26 @@
1
- import { jsxs as n, jsx as c } from "react/jsx-runtime";
2
- import b from "classnames";
3
- import { attr as r } from "@companix/utils-browser";
4
- import { forwardRef as g, useRef as w, useCallback as y } from "react";
5
- import { Icon as a } from "./bundle.es34.js";
6
- import { faClose as D, faChevronDown as R } from "@fortawesome/free-solid-svg-icons";
7
- import { VisuallyHidden as T } from "@radix-ui/react-visually-hidden";
8
- const V = g(
9
- ({
10
- required: u,
11
- size: d,
12
- fill: m,
13
- leftElement: l,
14
- className: p,
15
- value: o,
16
- clearButton: f,
17
- placeholder: C,
18
- clearButtonIcon: h,
19
- disabled: s,
20
- onClear: I,
21
- ...i
22
- }, N) => {
23
- const e = w(null), k = y(
24
- (t) => {
25
- if (!e.current || !document)
26
- return;
27
- t.target !== e.current && (e.current.click(), document.activeElement !== e.current && e.current.focus());
28
- },
29
- [e]
30
- ), x = (t) => {
31
- document && document.activeElement === e.current && t.preventDefault();
32
- }, v = (t) => {
33
- s || k(t);
34
- }, F = (t) => {
35
- x(t);
36
- }, z = (t) => {
37
- e.current && e.current.focus(), I?.(t);
38
- };
39
- return /* @__PURE__ */ n(
40
- "div",
41
- {
42
- ref: N,
43
- className: b("form select", p),
44
- "data-size": d ?? "md",
45
- "data-fill": r(m),
46
- "data-required": r(u),
47
- "data-disabled": r(s),
48
- onMouseDown: F,
49
- ...i,
50
- onClick: v,
51
- children: [
52
- /* @__PURE__ */ n("div", { className: "select-layout form-input", children: [
53
- l && /* @__PURE__ */ c("div", { className: "select-element", children: l }),
54
- /* @__PURE__ */ c("div", { className: "select-content", children: /* @__PURE__ */ n("div", { className: "select-content-text", "aria-disabled": s, children: [
55
- !o && /* @__PURE__ */ c("span", { className: "select-placeholder", children: C }),
56
- o
57
- ] }) }),
58
- /* @__PURE__ */ n("div", { className: "select-element", children: [
59
- f && o && /* @__PURE__ */ c("button", { className: "select-close-button", onClick: z, children: h ?? /* @__PURE__ */ c(a, { className: "select-close-icon", icon: D, size: "xxxs" }) }),
60
- /* @__PURE__ */ c(a, { className: "expand-icon select-expand", icon: R, size: "xxxs" })
61
- ] })
62
- ] }),
63
- /* @__PURE__ */ c(T, { asChild: !0, children: /* @__PURE__ */ c(
64
- "input",
65
- {
66
- ref: e,
67
- autoComplete: "off",
68
- autoCapitalize: "none",
69
- autoCorrect: "off",
70
- spellCheck: "false",
71
- "aria-autocomplete": "none",
72
- onClick: i.onClick,
73
- readOnly: !0
74
- }
75
- ) })
76
- ]
77
- }
78
- );
79
- }
80
- );
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
+ };
23
+ };
81
24
  export {
82
- V as SelectInput
25
+ p as useFroozeClosing
83
26
  };