@companix/uikit 0.0.73 → 0.0.75

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.
@@ -4,10 +4,11 @@ export interface DrawerProps {
4
4
  onOpenChange: (value: boolean) => void;
5
5
  children: React.ReactNode;
6
6
  direction?: 'bottom' | 'top' | 'left' | 'right';
7
+ onClosed?: () => void;
7
8
  className?: string;
8
9
  size?: string;
9
10
  }
10
11
  export declare const Drawer: {
11
- ({ open, onOpenChange, children, size, direction, className }: DrawerProps): import("react/jsx-runtime").JSX.Element;
12
+ ({ open, onClosed, onOpenChange, children, size, direction, className }: DrawerProps): import("react/jsx-runtime").JSX.Element;
12
13
  Close: import('react').ForwardRefExoticComponent<DialogPrimitive.DialogCloseProps & import('react').RefAttributes<HTMLButtonElement>>;
13
14
  };
@@ -20,13 +20,13 @@ export type OptionsSourceControl<T> = OptionsSource<T> & {
20
20
  };
21
21
  export interface SelectAddOption {
22
22
  text: string;
23
+ position?: 'first' | 'last';
23
24
  closeOnClick?: boolean;
24
25
  onClick: () => void;
25
26
  }
26
27
  export interface SelectOptionsPopoverParams {
27
28
  minimalOptions?: boolean;
28
29
  addOption?: SelectAddOption;
29
- addOptionPosition?: 'first' | 'last';
30
30
  emptyText?: string;
31
31
  isLoading?: boolean;
32
32
  }
@@ -1,25 +1,35 @@
1
- import { jsx as e, jsxs as o } from "react/jsx-runtime";
2
- import c from "classnames";
3
- import * as r from "@radix-ui/react-dialog";
1
+ import { jsx as r, jsxs as o } from "react/jsx-runtime";
2
+ import d from "classnames";
3
+ import * as e from "@radix-ui/react-dialog";
4
4
  import { VisuallyHidden as i } from "@radix-ui/react-visually-hidden";
5
- import { customCSS as d } from "@companix/utils-browser";
6
- const p = ({ open: t, onOpenChange: l, children: a, size: s, direction: m, className: n }) => /* @__PURE__ */ e(r.Root, { open: t, onOpenChange: l, children: /* @__PURE__ */ o(r.Portal, { children: [
7
- /* @__PURE__ */ e(r.Overlay, { className: "drawer-overlay" }),
5
+ import { customCSS as p } from "@companix/utils-browser";
6
+ import { RemoveListener as f } from "./bundle.es54.js";
7
+ const h = ({
8
+ open: t,
9
+ onClosed: l,
10
+ onOpenChange: a,
11
+ children: m,
12
+ size: s,
13
+ direction: c,
14
+ className: n
15
+ }) => /* @__PURE__ */ r(e.Root, { open: t, onOpenChange: a, children: /* @__PURE__ */ o(e.Portal, { children: [
16
+ /* @__PURE__ */ r(e.Overlay, { className: "drawer-overlay" }),
8
17
  /* @__PURE__ */ o(
9
- r.Content,
18
+ e.Content,
10
19
  {
11
- style: d({ "--drawer-size": s ?? "50%" }),
12
- className: c("drawer", n),
13
- "data-direction": m,
20
+ style: p({ "--drawer-size": s ?? "50%" }),
21
+ className: d("drawer", n),
22
+ "data-direction": c,
14
23
  children: [
15
- /* @__PURE__ */ e(i, { children: /* @__PURE__ */ e(r.Title, {}) }),
16
- /* @__PURE__ */ e(i, { children: /* @__PURE__ */ e(r.Description, {}) }),
17
- a
24
+ /* @__PURE__ */ r(f, { callback: l }),
25
+ /* @__PURE__ */ r(i, { children: /* @__PURE__ */ r(e.Title, {}) }),
26
+ /* @__PURE__ */ r(i, { children: /* @__PURE__ */ r(e.Description, {}) }),
27
+ m
18
28
  ]
19
29
  }
20
30
  )
21
31
  ] }) });
22
- p.Close = r.Close;
32
+ h.Close = e.Close;
23
33
  export {
24
- p as Drawer
34
+ h as Drawer
25
35
  };
@@ -1,96 +1,95 @@
1
- import { jsx as i, jsxs as P } from "react/jsx-runtime";
1
+ import { jsx as i, jsxs as y } from "react/jsx-runtime";
2
2
  import { useMemo as k, useEffect as C } from "react";
3
- import { Spinner as T } from "./bundle.es6.js";
4
- import { OptionItem as v } from "./bundle.es15.js";
5
- import { OptionsList as R } from "./bundle.es17.js";
6
- import { Icon as S } from "./bundle.es33.js";
7
- import { faPlus as b } from "@companix/icons-solid";
8
- const I = () => ({ isLoading: !1, options: [] }), N = (s) => {
9
- const { onOptionsLoaded: e, useOptions: p = I, options: o } = s, t = p();
3
+ import { Spinner as P } from "./bundle.es6.js";
4
+ import { OptionItem as L } from "./bundle.es15.js";
5
+ import { OptionsList as T } from "./bundle.es17.js";
6
+ import { Icon as R } from "./bundle.es33.js";
7
+ import { faPlus as S } from "@companix/icons-solid";
8
+ const b = () => ({ isLoading: !1, options: [] }), I = (n) => {
9
+ const { onOptionsLoaded: e, useOptions: s = b, options: o } = n, t = s();
10
10
  return C(() => {
11
11
  t.options.length > 0 && e?.(t.options);
12
12
  }, [t.options]), o ? { options: o, isLoading: !1 } : t;
13
- }, M = (s) => {
13
+ }, H = (n) => {
14
14
  const {
15
15
  isActive: e,
16
- emptyText: p,
16
+ emptyText: s,
17
17
  isLoading: o,
18
18
  scrollboxRef: t,
19
- optionsWrapperRef: f,
20
- addOption: r,
21
- onOpened: O,
22
- onSelect: u,
23
- minimalOptions: x,
24
- filterOptions: n,
25
- disableFiltering: a,
26
- close: m,
27
- ...l
28
- } = s, { emptyText: d, options: c, isLoading: g } = N(l), L = k(() => n && !a ? c.filter(n) : c, [c, n, a]);
29
- return g ?? o ? /* @__PURE__ */ i("div", { className: "select-popover-loading", children: /* @__PURE__ */ i(T, { size: 24 }) }) : /* @__PURE__ */ i(
30
- j,
19
+ optionsWrapperRef: d,
20
+ addOption: p,
21
+ onOpened: f,
22
+ onSelect: O,
23
+ minimalOptions: u,
24
+ filterOptions: r,
25
+ disableFiltering: l,
26
+ close: c,
27
+ ...a
28
+ } = n, { emptyText: x, options: m, isLoading: g } = I(a), v = k(() => r && !l ? m.filter(r) : m, [m, r, l]);
29
+ return g ?? o ? /* @__PURE__ */ i("div", { className: "select-popover-loading", children: /* @__PURE__ */ i(P, { size: 24 }) }) : /* @__PURE__ */ i(
30
+ N,
31
31
  {
32
- options: L,
32
+ options: v,
33
33
  isActive: e,
34
- emptyText: d ?? p,
34
+ emptyText: x ?? s,
35
35
  scrollboxRef: t,
36
- optionsWrapperRef: f,
37
- minimalOptions: x,
38
- addOption: r,
39
- onOpened: O,
40
- onSelect: u,
41
- close: m
36
+ optionsWrapperRef: d,
37
+ minimalOptions: u,
38
+ addOption: p,
39
+ onOpened: f,
40
+ onSelect: O,
41
+ close: c
42
42
  }
43
43
  );
44
- }, j = (s) => {
44
+ }, N = (n) => {
45
45
  const {
46
46
  isActive: e,
47
- onOpened: p,
47
+ onOpened: s,
48
48
  addOption: o,
49
49
  scrollboxRef: t,
50
- optionsWrapperRef: f,
51
- options: r,
52
- onSelect: O,
53
- minimalOptions: u,
54
- emptyText: x = "Ничего не найдено",
55
- addOptionPosition: n = "first",
56
- close: a
57
- } = s;
50
+ optionsWrapperRef: d,
51
+ options: p,
52
+ onSelect: f,
53
+ minimalOptions: O,
54
+ emptyText: u = "Ничего не найдено",
55
+ close: r
56
+ } = n;
58
57
  C(() => {
59
- p?.(r.findIndex(({ value: l }) => e(l)));
58
+ s?.(p.findIndex(({ value: c }) => e(c)));
60
59
  }, []);
61
- const m = o ? /* @__PURE__ */ i(
62
- v,
60
+ const l = o ? /* @__PURE__ */ i(
61
+ L,
63
62
  {
64
63
  className: "select-add-option",
65
- icon: /* @__PURE__ */ i(S, { icon: b }),
64
+ icon: /* @__PURE__ */ i(R, { icon: S }),
66
65
  title: o.text,
67
66
  onClick: o.onClick,
68
67
  onClickCapture: () => {
69
- o.closeOnClick && a();
68
+ o.closeOnClick && r();
70
69
  }
71
70
  }
72
71
  ) : void 0;
73
- return /* @__PURE__ */ P(R, { scrollboxRef: t, optionsWrapperRef: f, maxHeight: 300, children: [
74
- n === "first" && m,
75
- r.length === 0 && !o && /* @__PURE__ */ i("div", { className: "select-tags-empty", children: x }),
76
- r.map(({ title: l, value: d, className: c, icon: g, disabled: L, label: h }, y) => /* @__PURE__ */ i(
77
- v,
72
+ return /* @__PURE__ */ y(T, { scrollboxRef: t, optionsWrapperRef: d, maxHeight: 300, children: [
73
+ (o?.position === void 0 || o?.position === "first") && l,
74
+ p.length === 0 && !o && /* @__PURE__ */ i("div", { className: "select-tags-empty", children: u }),
75
+ p.map(({ title: c, value: a, className: x, icon: m, disabled: g, label: v }, h) => /* @__PURE__ */ i(
76
+ L,
78
77
  {
79
- active: e(d),
80
- onClick: () => O?.(d),
81
- minimal: u,
82
- disabled: L,
83
- className: c,
84
- title: l,
85
- label: h,
86
- icon: g
78
+ active: e(a),
79
+ onClick: () => f?.(a),
80
+ minimal: O,
81
+ disabled: g,
82
+ className: x,
83
+ title: c,
84
+ label: v,
85
+ icon: m
87
86
  },
88
- `select-option-${y}`
87
+ `select-option-${h}`
89
88
  )),
90
- n === "last" && m
89
+ o?.position === "last" && l
91
90
  ] });
92
91
  };
93
92
  export {
94
- M as OptionsPopover,
95
- j as SelectOptionsList
93
+ H as OptionsPopover,
94
+ N as SelectOptionsList
96
95
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@companix/uikit",
3
- "version": "0.0.73",
3
+ "version": "0.0.75",
4
4
  "main": "./dist/bundle.es.js",
5
5
  "module": "./dist/bundle.es.js",
6
6
  "types": "./dist/index.d.ts",
@@ -8,7 +8,7 @@
8
8
  "files": [
9
9
  "dist"
10
10
  ],
11
- "author": "Pavel Victorov",
11
+ "author": "Pavel Victorov.",
12
12
  "scripts": {
13
13
  "echo": "echo \"uikit\"",
14
14
  "dev": "vite --config vite.config.ts",