@companix/uikit 0.1.16 → 0.1.18

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.
@@ -31,12 +31,24 @@
31
31
  max-width: 100%;
32
32
  gap: 8px;
33
33
 
34
+ &-layout {
35
+ width: 100%;
36
+ }
37
+
34
38
  &-inner {
35
39
  @include mixins.use-styles(option, content, layout);
36
40
  }
37
41
  }
38
42
 
43
+ &-header {
44
+ align-items: center;
45
+ width: 100%;
46
+ display: flex;
47
+ overflow: hidden;
48
+ }
49
+
39
50
  &-title {
51
+ flex: 1;
40
52
  word-break: break-word;
41
53
  }
42
54
 
@@ -9,6 +9,7 @@ export interface SelectFormProps {
9
9
  fill?: boolean;
10
10
  clearButton?: boolean;
11
11
  clearButtonIcon?: boolean;
12
+ customElement?: React.ReactNode;
12
13
  inputRef?: React.Ref<HTMLInputElement>;
13
14
  onClear?: (event: React.MouseEvent<HTMLButtonElement>) => void;
14
15
  onClick?: () => void;
@@ -2,6 +2,7 @@ interface SelectRightElementsProps {
2
2
  onClear?: (event: React.MouseEvent<HTMLButtonElement>) => void;
3
3
  clearButton?: boolean;
4
4
  clearButtonIcon?: React.ReactNode;
5
+ customElement?: React.ReactNode;
5
6
  value: boolean;
6
7
  }
7
8
  export declare const SelectRightElements: (props: SelectRightElementsProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,10 +1,10 @@
1
- export interface TabsProps {
1
+ export interface TabsProps<T extends string> {
2
2
  children: React.ReactNode;
3
- onChange: (value: string) => void;
4
- value: string;
3
+ onChange: (value: T) => void;
4
+ value: T;
5
5
  }
6
6
  export declare const Tabs: {
7
- ({ children, value, onChange }: TabsProps): import("react/jsx-runtime").JSX.Element;
7
+ <T extends string>({ children, value, onChange }: TabsProps<T>): import("react/jsx-runtime").JSX.Element;
8
8
  Tab: ({ children, value, ...restProps }: TabProps) => import("react/jsx-runtime").JSX.Element;
9
9
  };
10
10
  interface TabProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
@@ -10,33 +10,33 @@ const Z = (t) => {
10
10
  const {
11
11
  onChange: i,
12
12
  value: n,
13
- matchTarget: u = "width",
14
- children: f,
15
- scrollRef: m,
16
- popoverRef: d,
13
+ matchTarget: f = "width",
14
+ children: m,
15
+ scrollRef: d,
16
+ popoverRef: v,
17
17
  clearButton: s,
18
18
  // select props
19
19
  disabled: a,
20
- required: v,
21
- className: h,
22
- clearButtonIcon: O,
23
- leftElement: R,
24
- inputRef: C,
20
+ required: h,
21
+ className: O,
22
+ clearButtonIcon: R,
23
+ leftElement: C,
24
+ inputRef: P,
25
25
  onClear: y,
26
- fill: P,
26
+ fill: E,
27
27
  size: g,
28
- placeholder: E,
29
- onClick: A,
28
+ placeholder: A,
29
+ onClick: S,
30
30
  // options popover
31
- ...S
31
+ ...x
32
32
  } = t, r = L({});
33
33
  j(() => {
34
34
  (t.options ?? t.defaultOptions ?? []).forEach((e) => {
35
35
  r.current[e.value] = e;
36
36
  });
37
37
  }, [t.options, t.defaultOptions]);
38
- const x = n === null ? null : r.current[n] ?? null, { popoverRef: z, froozePopoverPosition: B, handleAnimationEnd: F } = w(), { scrollToElement: p, optionsWrapperRef: I, scrollBoxRef: T } = M();
39
- k(m, () => ({
38
+ const c = n === null ? null : r.current[n] ?? null, { popoverRef: z, froozePopoverPosition: B, handleAnimationEnd: F } = w(), { scrollToElement: p, optionsWrapperRef: I, scrollBoxRef: T } = M();
39
+ k(d, () => ({
40
40
  scrollTo: (o) => p(o, "top")
41
41
  }));
42
42
  const b = (o, e) => {
@@ -48,9 +48,9 @@ const Z = (t) => {
48
48
  q,
49
49
  {
50
50
  minimal: !0,
51
- ref: W([z, d]),
51
+ ref: W([z, v]),
52
52
  sideOffset: 0,
53
- matchTarget: u,
53
+ matchTarget: f,
54
54
  onAnimationEnd: F,
55
55
  onOpenAutoFocus: (o) => o.preventDefault(),
56
56
  onCloseAutoFocus: (o) => o.preventDefault(),
@@ -58,7 +58,7 @@ const Z = (t) => {
58
58
  content: ({ close: o }) => /* @__PURE__ */ l(
59
59
  N,
60
60
  {
61
- ...S,
61
+ ...x,
62
62
  close: o,
63
63
  isActive: (e) => e === n,
64
64
  onSelect: (e) => b(e, o),
@@ -66,28 +66,29 @@ const Z = (t) => {
66
66
  optionsWrapperRef: I,
67
67
  onOpened: (e) => p(e, "center"),
68
68
  onOptionsLoaded: (e) => {
69
- e.forEach((c) => {
70
- r.current[c.value] = c;
69
+ e.forEach((u) => {
70
+ r.current[u.value] = u;
71
71
  });
72
72
  }
73
73
  }
74
74
  ),
75
- children: f ?? /* @__PURE__ */ l(
75
+ children: m ?? /* @__PURE__ */ l(
76
76
  H,
77
77
  {
78
- required: v,
79
- className: h,
80
- leftElement: R,
81
- inputRef: C,
78
+ required: h,
79
+ className: O,
80
+ leftElement: C,
81
+ inputRef: P,
82
82
  onClear: D,
83
- fill: P,
83
+ fill: E,
84
84
  size: g,
85
- placeholder: E,
86
- onClick: A,
85
+ placeholder: A,
86
+ onClick: S,
87
87
  disabled: a,
88
88
  clearButton: s,
89
- clearButtonIcon: O,
90
- value: x?.title ?? ""
89
+ customElement: c?.indicator,
90
+ clearButtonIcon: R,
91
+ value: c?.title ?? ""
91
92
  }
92
93
  )
93
94
  }
@@ -1,38 +1,41 @@
1
1
  import { jsxs as i, jsx as o } from "react/jsx-runtime";
2
- import N from "classnames";
3
- import { Icon as v } from "./bundle.es36.js";
2
+ import v from "classnames";
3
+ import { Icon as k } from "./bundle.es36.js";
4
4
  import { attr as t } from "@companix/utils-browser";
5
- import { forwardRef as k } from "react";
6
- import { faCheck as x } from "@companix/icons-solid";
7
- const O = k(
8
- ({ title: d, icon: n, active: c, label: e, disabled: r, minimal: a, onClick: l, className: m, ...s }, p) => {
9
- const f = (h) => {
10
- r || l?.(h);
5
+ import { forwardRef as x } from "react";
6
+ import { faCheck as C } from "@companix/icons-solid";
7
+ const R = x(
8
+ ({ title: d, icon: e, active: n, label: c, indicator: l, disabled: a, minimal: r, onClick: s, className: m, ...p }, h) => {
9
+ const f = (N) => {
10
+ a || s?.(N);
11
11
  };
12
12
  return /* @__PURE__ */ i(
13
13
  "div",
14
14
  {
15
- ref: p,
16
- ...s,
17
- className: N("option", m),
18
- "data-selected": t(c),
19
- "data-disabled": t(r),
20
- "data-minimal": t(a),
15
+ ref: h,
16
+ ...p,
17
+ className: v("option", m),
18
+ "data-selected": t(n),
19
+ "data-disabled": t(a),
20
+ "data-minimal": t(r),
21
21
  onClick: f,
22
22
  children: [
23
23
  /* @__PURE__ */ i("div", { className: "option-content", children: [
24
- n && /* @__PURE__ */ o("div", { className: "option-icon", children: n }),
24
+ e && /* @__PURE__ */ o("div", { className: "option-icon", children: e }),
25
25
  /* @__PURE__ */ i("div", { className: "option-content-layout", children: [
26
- /* @__PURE__ */ o("div", { className: "option-title", children: d }),
27
- e && /* @__PURE__ */ o("div", { className: "option-label", children: e })
26
+ /* @__PURE__ */ i("div", { className: "option-header", children: [
27
+ /* @__PURE__ */ o("div", { className: "option-title", children: d }),
28
+ l
29
+ ] }),
30
+ c && /* @__PURE__ */ o("div", { className: "option-label", children: c })
28
31
  ] })
29
32
  ] }),
30
- c && !a && /* @__PURE__ */ o("div", { className: "option-check", children: /* @__PURE__ */ o(v, { icon: x }) })
33
+ n && !r && /* @__PURE__ */ o("div", { className: "option-check", children: /* @__PURE__ */ o(k, { icon: C }) })
31
34
  ]
32
35
  }
33
36
  );
34
37
  }
35
38
  );
36
39
  export {
37
- O as OptionItem
40
+ R as OptionItem
38
41
  };
@@ -1,21 +1,21 @@
1
- import { jsx as a, jsxs as d } from "react/jsx-runtime";
2
- import { useTabSlider as b, makeTabId as l } from "./bundle.es60.js";
1
+ import { jsx as a, jsxs as b } from "react/jsx-runtime";
2
+ import { useTabSlider as l, makeTabId as m } from "./bundle.es60.js";
3
3
  import * as n from "@radix-ui/react-tabs";
4
- import { useRef as m, useId as f, createContext as T, useContext as c } from "react";
5
- const o = T({ baseId: "", containerRef: {} }), u = ({ children: s, value: e, onChange: r }) => {
6
- const t = m(null), i = f().replaceAll(":", "");
7
- return /* @__PURE__ */ a(n.Root, { value: e, onValueChange: r, children: /* @__PURE__ */ a(o.Provider, { value: { baseId: i, containerRef: t }, children: /* @__PURE__ */ d(n.List, { className: "tabs", ref: t, children: [
8
- /* @__PURE__ */ a(x, { value: e }),
4
+ import { useRef as f, useId as T, createContext as u, useContext as c } from "react";
5
+ const o = u({ baseId: "", containerRef: {} }), x = ({ children: s, value: e, onChange: r }) => {
6
+ const t = f(null), i = T().replaceAll(":", "");
7
+ return /* @__PURE__ */ a(n.Root, { value: e, onValueChange: (d) => r(d), children: /* @__PURE__ */ a(o.Provider, { value: { baseId: i, containerRef: t }, children: /* @__PURE__ */ b(n.List, { className: "tabs", ref: t, children: [
8
+ /* @__PURE__ */ a(I, { value: e }),
9
9
  s
10
10
  ] }) }) });
11
- }, x = ({ value: s }) => {
12
- const { baseId: e, containerRef: r } = c(o), t = b({ baseId: e, value: s, containerRef: r });
11
+ }, I = ({ value: s }) => {
12
+ const { baseId: e, containerRef: r } = c(o), t = l({ baseId: e, value: s, containerRef: r });
13
13
  return /* @__PURE__ */ a("div", { className: "tab-indicator-container", style: t, children: /* @__PURE__ */ a("div", { className: "tab-indicator" }) });
14
- }, I = ({ children: s, value: e, ...r }) => {
14
+ }, p = ({ children: s, value: e, ...r }) => {
15
15
  const { baseId: t } = c(o);
16
- return /* @__PURE__ */ a(n.Trigger, { ...r, id: l(t, e), className: "tab", value: e, children: s });
16
+ return /* @__PURE__ */ a(n.Trigger, { ...r, id: m(t, e), className: "tab", value: e, children: s });
17
17
  };
18
- u.Tab = I;
18
+ x.Tab = p;
19
19
  export {
20
- u as Tabs
20
+ x as Tabs
21
21
  };
@@ -1,11 +1,11 @@
1
1
  import { jsxs as o, jsx as n } from "react/jsx-runtime";
2
- import w from "classnames";
2
+ import y from "classnames";
3
3
  import { attr as s } from "@companix/utils-browser";
4
- import { forwardRef as y, useRef as D, useCallback as S } from "react";
5
- import { VisuallyHidden as T } from "@radix-ui/react-visually-hidden";
6
- import { mergeRefs as j } from "react-merge-refs";
7
- import { SelectRightElements as z } from "./bundle.es73.js";
8
- const W = y(
4
+ import { forwardRef as D, useRef as S, useCallback as T } from "react";
5
+ import { VisuallyHidden as j } from "@radix-ui/react-visually-hidden";
6
+ import { mergeRefs as z } from "react-merge-refs";
7
+ import { SelectRightElements as B } from "./bundle.es73.js";
8
+ const G = D(
9
9
  ({
10
10
  required: a,
11
11
  size: i,
@@ -16,40 +16,41 @@ const W = y(
16
16
  clearButton: m,
17
17
  placeholder: p,
18
18
  clearButtonIcon: f,
19
+ customElement: h,
19
20
  disabled: r,
20
- onClear: h,
21
- inputRef: C,
22
- onClick: I,
23
- ...N
24
- }, k) => {
25
- const e = D(null), v = S(
21
+ onClear: C,
22
+ inputRef: I,
23
+ onClick: N,
24
+ ...k
25
+ }, v) => {
26
+ const e = S(null), F = T(
26
27
  (t) => {
27
28
  if (!e.current || !document)
28
29
  return;
29
30
  t.target !== e.current && (e.current.click(), document.activeElement !== e.current && e.current.focus());
30
31
  },
31
32
  [e]
32
- ), F = (t) => {
33
+ ), g = (t) => {
33
34
  document && document.activeElement === e.current && t.preventDefault();
34
- }, g = (t) => {
35
- r || v(t);
36
35
  }, R = (t) => {
37
- F(t);
36
+ r || F(t);
38
37
  }, x = (t) => {
39
- e.current && e.current.focus(), h?.(t);
38
+ g(t);
39
+ }, A = (t) => {
40
+ e.current && e.current.focus(), C?.(t);
40
41
  };
41
42
  return /* @__PURE__ */ o(
42
43
  "div",
43
44
  {
44
- ref: k,
45
- className: w("form select", d),
45
+ ref: v,
46
+ className: y("form select", d),
46
47
  "data-size": i ?? "md",
47
48
  "data-fill": s(u),
48
49
  "data-required": s(a),
49
50
  "data-disabled": s(r),
50
- onMouseDown: R,
51
- onClick: g,
52
- ...N,
51
+ onMouseDown: x,
52
+ onClick: R,
53
+ ...k,
53
54
  children: [
54
55
  /* @__PURE__ */ o("div", { className: "select-layout form-input", children: [
55
56
  l && /* @__PURE__ */ n("div", { className: "select-element", children: l }),
@@ -58,25 +59,26 @@ const W = y(
58
59
  c
59
60
  ] }) }),
60
61
  /* @__PURE__ */ n("div", { className: "select-element", children: /* @__PURE__ */ n(
61
- z,
62
+ B,
62
63
  {
64
+ customElement: h,
63
65
  clearButton: m,
64
66
  value: !!c,
65
67
  clearButtonIcon: f,
66
- onClear: x
68
+ onClear: A
67
69
  }
68
70
  ) })
69
71
  ] }),
70
- /* @__PURE__ */ n(T, { asChild: !0, children: /* @__PURE__ */ n(
72
+ /* @__PURE__ */ n(j, { asChild: !0, children: /* @__PURE__ */ n(
71
73
  "input",
72
74
  {
73
- ref: j([C, e]),
75
+ ref: z([I, e]),
74
76
  autoComplete: "off",
75
77
  autoCapitalize: "none",
76
78
  autoCorrect: "off",
77
79
  spellCheck: "false",
78
80
  "aria-autocomplete": "none",
79
- onClick: I,
81
+ onClick: N,
80
82
  readOnly: !0
81
83
  }
82
84
  ) })
@@ -86,5 +88,5 @@ const W = y(
86
88
  }
87
89
  );
88
90
  export {
89
- W as SelectInput
91
+ G as SelectInput
90
92
  };
@@ -1,16 +1,16 @@
1
- import { jsx as i, jsxs as k } from "react/jsx-runtime";
2
- import { useMemo as y, useEffect as C } from "react";
3
- import { Spinner as P } from "./bundle.es7.js";
1
+ import { jsx as i, jsxs as y } from "react/jsx-runtime";
2
+ import { useMemo as P, useEffect as C } from "react";
3
+ import { Spinner as T } from "./bundle.es7.js";
4
4
  import { OptionItem as L } from "./bundle.es16.js";
5
- import { OptionsList as T } from "./bundle.es18.js";
6
- import { Icon as R } from "./bundle.es36.js";
7
- import { faPlus as S } from "@companix/icons-solid";
8
- const b = () => ({ isLoading: !1, options: [] }), I = (e) => {
9
- const { onOptionsLoaded: n, useOptions: s = b, options: o } = e, t = s();
5
+ import { OptionsList as R } from "./bundle.es18.js";
6
+ import { Icon as S } from "./bundle.es36.js";
7
+ import { faPlus as b } from "@companix/icons-solid";
8
+ const I = () => ({ isLoading: !1, options: [] }), N = (e) => {
9
+ const { onOptionsLoaded: n, useOptions: s = I, options: o } = e, t = s();
10
10
  return C(() => {
11
11
  t.options.length > 0 && n?.(t.options);
12
12
  }, [t.options]), o ? { options: o, isLoading: !1 } : t;
13
- }, H = (e) => {
13
+ }, M = (e) => {
14
14
  const {
15
15
  isActive: n,
16
16
  emptyText: s,
@@ -25,9 +25,9 @@ const b = () => ({ isLoading: !1, options: [] }), I = (e) => {
25
25
  disableFiltering: l,
26
26
  close: c,
27
27
  ...m
28
- } = e, { emptyText: x, options: a, isLoading: g } = I(m), v = y(() => r && !l ? a.filter(r) : a, [a, r, l]);
29
- return g ?? o ? /* @__PURE__ */ i("div", { className: "select-popover-loading", children: /* @__PURE__ */ i(P, { size: 24 }) }) : /* @__PURE__ */ i(
30
- N,
28
+ } = e, { emptyText: x, options: a, isLoading: g } = N(m), v = P(() => r && !l ? a.filter(r) : a, [a, r, l]);
29
+ return g ?? o ? /* @__PURE__ */ i("div", { className: "select-popover-loading", children: /* @__PURE__ */ i(T, { size: 24 }) }) : /* @__PURE__ */ i(
30
+ j,
31
31
  {
32
32
  options: v,
33
33
  isActive: n,
@@ -41,7 +41,7 @@ const b = () => ({ isLoading: !1, options: [] }), I = (e) => {
41
41
  close: c
42
42
  }
43
43
  );
44
- }, N = (e) => {
44
+ }, j = (e) => {
45
45
  const {
46
46
  isActive: n,
47
47
  onOpened: s,
@@ -61,7 +61,7 @@ const b = () => ({ isLoading: !1, options: [] }), I = (e) => {
61
61
  L,
62
62
  {
63
63
  className: "select-add-option",
64
- icon: /* @__PURE__ */ i(R, { icon: S }),
64
+ icon: /* @__PURE__ */ i(S, { icon: b }),
65
65
  title: o.text,
66
66
  onClick: o.onClick,
67
67
  onClickCapture: () => {
@@ -69,10 +69,10 @@ const b = () => ({ isLoading: !1, options: [] }), I = (e) => {
69
69
  }
70
70
  }
71
71
  ) : void 0;
72
- return /* @__PURE__ */ k(T, { scrollboxRef: t, optionsWrapperRef: d, maxHeight: 300, children: [
72
+ return /* @__PURE__ */ y(R, { scrollboxRef: t, optionsWrapperRef: d, maxHeight: 300, children: [
73
73
  (o?.position === void 0 || o?.position === "first") && l,
74
74
  p.length === 0 && !o && /* @__PURE__ */ i("div", { className: "select-tags-noneresults", children: u }),
75
- p.map(({ title: c, value: m, className: x, icon: a, disabled: g, label: v }, h) => /* @__PURE__ */ i(
75
+ p.map(({ title: c, value: m, className: x, icon: a, disabled: g, indicator: v, label: h }, k) => /* @__PURE__ */ i(
76
76
  L,
77
77
  {
78
78
  active: n(m),
@@ -81,15 +81,16 @@ const b = () => ({ isLoading: !1, options: [] }), I = (e) => {
81
81
  disabled: g,
82
82
  className: x,
83
83
  title: c,
84
- label: v,
84
+ label: h,
85
+ indicator: v,
85
86
  icon: a
86
87
  },
87
- `select-option-${h}`
88
+ `select-option-${k}`
88
89
  )),
89
90
  o?.position === "last" && l
90
91
  ] });
91
92
  };
92
93
  export {
93
- H as OptionsPopover,
94
- N as SelectOptionsList
94
+ M as OptionsPopover,
95
+ j as SelectOptionsList
95
96
  };
@@ -2,7 +2,7 @@ import { jsxs as b, jsx as o } from "react/jsx-runtime";
2
2
  import h from "classnames";
3
3
  import { attr as e } from "@companix/utils-browser";
4
4
  import { forwardRef as x } from "react";
5
- import { useInputPadding as N } from "./bundle.es83.js";
5
+ import { useInputPadding as N } from "./bundle.es81.js";
6
6
  const v = x(
7
7
  ({
8
8
  required: s,
@@ -1,7 +1,7 @@
1
1
  import { jsxs as D, jsx as t } from "react/jsx-runtime";
2
2
  import { dateToFormat as $, weeks as g, createVoids as p, getDayIndex as b, getFirstDay as u, getMonthMaxDay as k } from "./bundle.es65.js";
3
- import { CalendarHeader as F } from "./bundle.es81.js";
4
- import { useCalendar as j } from "./bundle.es82.js";
3
+ import { CalendarHeader as F } from "./bundle.es82.js";
4
+ import { useCalendar as j } from "./bundle.es83.js";
5
5
  import { attr as m } from "@companix/utils-browser";
6
6
  import { isSameDate as f } from "./bundle.es59.js";
7
7
  import { useLayoutEffect as I } from "react";
@@ -1,13 +1,14 @@
1
- import { jsxs as r, Fragment as a, jsx as e } from "react/jsx-runtime";
2
- import { faXmark as i, faChevronDown as m } from "@companix/icons-solid";
1
+ import { jsxs as a, Fragment as m, jsx as e } from "react/jsx-runtime";
2
+ import { faXmark as i, faChevronDown as x } from "@companix/icons-solid";
3
3
  import { Icon as o } from "./bundle.es36.js";
4
- const f = (n) => {
5
- const { clearButton: c, clearButtonIcon: t, value: s, onClear: l } = n;
6
- return /* @__PURE__ */ r(a, { children: [
7
- c && s && /* @__PURE__ */ e("button", { className: "select-close-button", onClick: l, children: t ?? /* @__PURE__ */ e(o, { className: "select-close-icon", icon: i, size: "xxxs" }) }),
8
- /* @__PURE__ */ e(o, { className: "expand-icon select-expand", icon: m, size: "xxxs" })
4
+ const d = (n) => {
5
+ const { customElement: t, clearButton: c, clearButtonIcon: s, value: l, onClear: r } = n;
6
+ return /* @__PURE__ */ a(m, { children: [
7
+ t,
8
+ c && l && /* @__PURE__ */ e("button", { className: "select-close-button", onClick: r, children: s ?? /* @__PURE__ */ e(o, { className: "select-close-icon", icon: i, size: "xxxs" }) }),
9
+ /* @__PURE__ */ e(o, { className: "expand-icon select-expand", icon: x, size: "xxxs" })
9
10
  ] });
10
11
  };
11
12
  export {
12
- f as SelectRightElements
13
+ d as SelectRightElements
13
14
  };
@@ -1,77 +1,16 @@
1
- import { jsxs as d, jsx as o } from "react/jsx-runtime";
2
- import { useCallback as u, useMemo as h } from "react";
3
- import { Select as p } from "./bundle.es13.js";
4
- import { getMonths as k, getYears as z, DEFAULT_MAX_YEAR as f, DEFAULT_MIN_YEAR as g } from "./bundle.es65.js";
5
- import { Icon as C } from "./bundle.es36.js";
6
- import { faChevronLeft as E, faChevronRight as T } from "@companix/icons-solid";
7
- import { setMonth as _, setYear as F } from "./bundle.es59.js";
8
- const y = ({
9
- viewDate: n,
10
- onChange: c,
11
- isMonthDisabled: a,
12
- isYearDisabled: m,
13
- onNextMonth: N,
14
- onPrevMonth: v
15
- }) => {
16
- const e = n.getFullYear(), r = n.getMonth(), s = "ru", M = u(
17
- (t) => {
18
- c(_(n, t));
19
- },
20
- [c, n]
21
- ), x = u(
22
- (t) => {
23
- c(F(n, t));
24
- },
25
- [c, n]
26
- ), A = h(() => k(s).map((t) => ({
27
- ...t,
28
- className: "capitalize",
29
- disabled: a && a(t.value)
30
- })), [s, a]), Y = h(() => z(e, 100).map((t) => ({
31
- ...t,
32
- disabled: m && m(t.value)
33
- })), [e, m]);
34
- let l = r === 11 && e === f;
35
- a && !l && (l = a(
36
- r === 11 ? 0 : r + 1,
37
- r === 11 ? Math.min(e + 1, f) : e
38
- ));
39
- let i = r === 0 && e === g;
40
- return a && !i && (i = a(
41
- r === 0 ? 11 : r - 1,
42
- r === 0 ? Math.max(e - 1, g) : e
43
- )), /* @__PURE__ */ d("div", { className: "calendar-header", children: [
44
- !i && /* @__PURE__ */ o("button", { className: "calendar-navigation", "data-side": "left", onClick: v, children: /* @__PURE__ */ o(C, { icon: E }) }),
45
- /* @__PURE__ */ d("div", { className: "calendar-pickers", children: [
46
- /* @__PURE__ */ o(
47
- p,
48
- {
49
- fill: !0,
50
- options: Y,
51
- size: "sm",
52
- value: e,
53
- minimalOptions: !0,
54
- matchTarget: "min-width",
55
- onChange: (t) => x(t)
56
- }
57
- ),
58
- /* @__PURE__ */ o(
59
- p,
60
- {
61
- fill: !0,
62
- options: A,
63
- size: "sm",
64
- className: "capitalize",
65
- value: r,
66
- minimalOptions: !0,
67
- matchTarget: "min-width",
68
- onChange: (t) => M(t)
69
- }
70
- )
71
- ] }),
72
- !l && /* @__PURE__ */ o("button", { className: "calendar-navigation", "data-side": "right", onClick: N, children: /* @__PURE__ */ o(C, { icon: T }) })
73
- ] });
1
+ import { useRef as l, useCallback as p } from "react";
2
+ import { useEffectWithLayout as d } from "./bundle.es84.js";
3
+ const g = (r, f) => {
4
+ const c = l(null), i = l(null), o = { Right: c, Left: i }, u = p((t) => {
5
+ if (r.current) {
6
+ const n = r.current.style, e = o[t];
7
+ e.current && e.current.clientWidth ? n[`padding${t}`] !== `${e.current.clientWidth}px` && (n[`padding${t}`] = `${e.current.clientWidth}px`) : n[`padding${t}`] && (n[`padding${t}`] = "");
8
+ }
9
+ }, []);
10
+ return d(() => {
11
+ u("Left"), u("Right");
12
+ }, f), { rightRef: c, leftRef: i };
74
13
  };
75
14
  export {
76
- y as CalendarHeader
15
+ g as useInputPadding
77
16
  };
@@ -1,51 +1,77 @@
1
- import { subMonths as L, addMonths as N, useDayDisableCheker as R } from "./bundle.es59.js";
2
- import { DEFAULT_MIN_YEAR as w, DEFAULT_MAX_YEAR as A } from "./bundle.es65.js";
3
- import { useState as U, useCallback as M } from "react";
4
- const X = ({
5
- value: p,
6
- disablePast: r,
7
- disableFuture: c,
8
- shouldDisableDate: E,
9
- minDateTime: l,
10
- maxDateTime: s
1
+ import { jsxs as d, jsx as o } from "react/jsx-runtime";
2
+ import { useCallback as u, useMemo as h } from "react";
3
+ import { Select as p } from "./bundle.es13.js";
4
+ import { getMonths as k, getYears as z, DEFAULT_MAX_YEAR as f, DEFAULT_MIN_YEAR as g } from "./bundle.es65.js";
5
+ import { Icon as C } from "./bundle.es36.js";
6
+ import { faChevronLeft as E, faChevronRight as T } from "@companix/icons-solid";
7
+ import { setMonth as _, setYear as F } from "./bundle.es59.js";
8
+ const y = ({
9
+ viewDate: n,
10
+ onChange: c,
11
+ isMonthDisabled: a,
12
+ isYearDisabled: m,
13
+ onNextMonth: N,
14
+ onPrevMonth: v
11
15
  }) => {
12
- const [e, u] = U(p || /* @__PURE__ */ new Date()), _ = M(() => {
13
- u(L(e, 1));
14
- }, [e]), C = M(() => {
15
- u(N(e, 1));
16
- }, [e]), D = R({
17
- disableFuture: c,
18
- disablePast: r,
19
- shouldDisableDate: E,
20
- minDateTime: l,
21
- maxDateTime: s
22
- }), k = M(
23
- (o, t) => {
24
- const n = /* @__PURE__ */ new Date();
25
- t = t || e.getFullYear();
26
- const h = l ? l.getMonth() : 0, Y = s ? s.getMonth() : 11, F = l?.getFullYear() || w, f = s?.getFullYear() || A;
27
- let g = t >= F && t <= f ? t === F && h > o || t === f && o > Y : !0;
28
- return c && (g = g || (t === n.getFullYear() ? o > n.getMonth() : t > n.getFullYear())), r && (g = g || (t === n.getFullYear() ? o < n.getMonth() : t < n.getFullYear())), g;
16
+ const e = n.getFullYear(), r = n.getMonth(), s = "ru", M = u(
17
+ (t) => {
18
+ c(_(n, t));
29
19
  },
30
- [c, r, e, l, s]
31
- ), v = M(
32
- (o) => {
33
- const t = /* @__PURE__ */ new Date(), n = l?.getFullYear() || w, h = s?.getFullYear() || A;
34
- let Y = n > o || o > h;
35
- return c && (Y = Y || o > t.getFullYear()), r && (Y = Y || o < t.getFullYear()), Y;
20
+ [c, n]
21
+ ), x = u(
22
+ (t) => {
23
+ c(F(n, t));
36
24
  },
37
- [c, r, l, s]
38
- );
39
- return {
40
- viewDate: e,
41
- setViewDate: u,
42
- setPrevMonth: _,
43
- setNextMonth: C,
44
- isDayDisabled: D,
45
- isMonthDisabled: k,
46
- isYearDisabled: v
47
- };
25
+ [c, n]
26
+ ), A = h(() => k(s).map((t) => ({
27
+ ...t,
28
+ className: "capitalize",
29
+ disabled: a && a(t.value)
30
+ })), [s, a]), Y = h(() => z(e, 100).map((t) => ({
31
+ ...t,
32
+ disabled: m && m(t.value)
33
+ })), [e, m]);
34
+ let l = r === 11 && e === f;
35
+ a && !l && (l = a(
36
+ r === 11 ? 0 : r + 1,
37
+ r === 11 ? Math.min(e + 1, f) : e
38
+ ));
39
+ let i = r === 0 && e === g;
40
+ return a && !i && (i = a(
41
+ r === 0 ? 11 : r - 1,
42
+ r === 0 ? Math.max(e - 1, g) : e
43
+ )), /* @__PURE__ */ d("div", { className: "calendar-header", children: [
44
+ !i && /* @__PURE__ */ o("button", { className: "calendar-navigation", "data-side": "left", onClick: v, children: /* @__PURE__ */ o(C, { icon: E }) }),
45
+ /* @__PURE__ */ d("div", { className: "calendar-pickers", children: [
46
+ /* @__PURE__ */ o(
47
+ p,
48
+ {
49
+ fill: !0,
50
+ options: Y,
51
+ size: "sm",
52
+ value: e,
53
+ minimalOptions: !0,
54
+ matchTarget: "min-width",
55
+ onChange: (t) => x(t)
56
+ }
57
+ ),
58
+ /* @__PURE__ */ o(
59
+ p,
60
+ {
61
+ fill: !0,
62
+ options: A,
63
+ size: "sm",
64
+ className: "capitalize",
65
+ value: r,
66
+ minimalOptions: !0,
67
+ matchTarget: "min-width",
68
+ onChange: (t) => M(t)
69
+ }
70
+ )
71
+ ] }),
72
+ !l && /* @__PURE__ */ o("button", { className: "calendar-navigation", "data-side": "right", onClick: N, children: /* @__PURE__ */ o(C, { icon: T }) })
73
+ ] });
48
74
  };
49
75
  export {
50
- X as useCalendar
76
+ y as CalendarHeader
51
77
  };
@@ -1,16 +1,51 @@
1
- import { useRef as l, useCallback as p } from "react";
2
- import { useEffectWithLayout as d } from "./bundle.es84.js";
3
- const g = (r, f) => {
4
- const c = l(null), i = l(null), o = { Right: c, Left: i }, u = p((t) => {
5
- if (r.current) {
6
- const n = r.current.style, e = o[t];
7
- e.current && e.current.clientWidth ? n[`padding${t}`] !== `${e.current.clientWidth}px` && (n[`padding${t}`] = `${e.current.clientWidth}px`) : n[`padding${t}`] && (n[`padding${t}`] = "");
8
- }
9
- }, []);
10
- return d(() => {
11
- u("Left"), u("Right");
12
- }, f), { rightRef: c, leftRef: i };
1
+ import { subMonths as L, addMonths as N, useDayDisableCheker as R } from "./bundle.es59.js";
2
+ import { DEFAULT_MIN_YEAR as w, DEFAULT_MAX_YEAR as A } from "./bundle.es65.js";
3
+ import { useState as U, useCallback as M } from "react";
4
+ const X = ({
5
+ value: p,
6
+ disablePast: r,
7
+ disableFuture: c,
8
+ shouldDisableDate: E,
9
+ minDateTime: l,
10
+ maxDateTime: s
11
+ }) => {
12
+ const [e, u] = U(p || /* @__PURE__ */ new Date()), _ = M(() => {
13
+ u(L(e, 1));
14
+ }, [e]), C = M(() => {
15
+ u(N(e, 1));
16
+ }, [e]), D = R({
17
+ disableFuture: c,
18
+ disablePast: r,
19
+ shouldDisableDate: E,
20
+ minDateTime: l,
21
+ maxDateTime: s
22
+ }), k = M(
23
+ (o, t) => {
24
+ const n = /* @__PURE__ */ new Date();
25
+ t = t || e.getFullYear();
26
+ const h = l ? l.getMonth() : 0, Y = s ? s.getMonth() : 11, F = l?.getFullYear() || w, f = s?.getFullYear() || A;
27
+ let g = t >= F && t <= f ? t === F && h > o || t === f && o > Y : !0;
28
+ return c && (g = g || (t === n.getFullYear() ? o > n.getMonth() : t > n.getFullYear())), r && (g = g || (t === n.getFullYear() ? o < n.getMonth() : t < n.getFullYear())), g;
29
+ },
30
+ [c, r, e, l, s]
31
+ ), v = M(
32
+ (o) => {
33
+ const t = /* @__PURE__ */ new Date(), n = l?.getFullYear() || w, h = s?.getFullYear() || A;
34
+ let Y = n > o || o > h;
35
+ return c && (Y = Y || o > t.getFullYear()), r && (Y = Y || o < t.getFullYear()), Y;
36
+ },
37
+ [c, r, l, s]
38
+ );
39
+ return {
40
+ viewDate: e,
41
+ setViewDate: u,
42
+ setPrevMonth: _,
43
+ setNextMonth: C,
44
+ isDayDisabled: D,
45
+ isMonthDisabled: k,
46
+ isYearDisabled: v
47
+ };
13
48
  };
14
49
  export {
15
- g as useInputPadding
50
+ X as useCalendar
16
51
  };
package/dist/types.d.ts CHANGED
@@ -3,6 +3,7 @@ export interface Option<T> {
3
3
  value: T;
4
4
  icon?: React.ReactNode;
5
5
  label?: string;
6
+ indicator?: React.ReactNode;
6
7
  disabled?: boolean;
7
8
  className?: string;
8
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@companix/uikit",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "main": "./dist/bundle.es.js",
5
5
  "module": "./dist/bundle.es.js",
6
6
  "types": "./dist/index.d.ts",