@companix/uikit 0.0.50 → 0.0.51

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.
@@ -13,5 +13,6 @@ export interface SelectTagsProps<T> {
13
13
  fill?: boolean;
14
14
  inputRef?: React.Ref<HTMLInputElement>;
15
15
  required?: boolean;
16
+ isLoading?: boolean;
16
17
  }
17
18
  export declare const SelectTags: <T extends string | number>(props: SelectTagsProps<T>) => import("react/jsx-runtime").JSX.Element;
@@ -1,15 +1,16 @@
1
1
  import { jsx as o, jsxs as s } from "react/jsx-runtime";
2
- import { useFroozeClosing as j } from "./bundle.es45.js";
3
- import { Popover as q } from "./bundle.es10.js";
4
- import { OptionItem as V } from "./bundle.es14.js";
5
- import { OptionsList as B } from "./bundle.es16.js";
2
+ import { useFroozeClosing as q } from "./bundle.es45.js";
3
+ import { Spinner as L } from "./bundle.es6.js";
4
+ import { Popover as V } from "./bundle.es10.js";
5
+ import { OptionItem as B } from "./bundle.es14.js";
6
+ import { OptionsList as H } from "./bundle.es16.js";
6
7
  import { Icon as d } from "./bundle.es33.js";
7
- import { useState as H, useRef as h, useMemo as g } from "react";
8
- import { attr as v, getActiveElementByAnotherElement as L, contains as X } from "@companix/utils-browser";
9
- import { mergeRefs as G } from "react-merge-refs";
10
- import { faXmark as J, faChevronDown as K } from "@companix/icons-solid";
11
- import { matchPattern as Q } from "@companix/utils-js";
12
- const ie = (x) => {
8
+ import { useState as X, useRef as h, useMemo as g } from "react";
9
+ import { attr as v, getActiveElementByAnotherElement as G, contains as J } from "@companix/utils-browser";
10
+ import { mergeRefs as K } from "react-merge-refs";
11
+ import { faXmark as Q, faChevronDown as U } from "@companix/icons-solid";
12
+ import { matchPattern as W } from "@companix/utils-js";
13
+ const le = (x) => {
13
14
  const {
14
15
  options: r,
15
16
  closeAfterSelect: C,
@@ -17,49 +18,50 @@ const ie = (x) => {
17
18
  onChange: c,
18
19
  emptyText: R = "Ничего не найдено",
19
20
  readOnly: l,
20
- size: A = "md",
21
+ size: z = "md",
21
22
  value: n,
22
- inputRef: z,
23
- disabled: f,
24
- required: D
25
- } = x, [a, P] = H(""), i = h(null), b = h(null), { popoverRef: m, froozePopoverPosition: k, handleAnimationEnd: y } = j(), E = g(() => {
23
+ inputRef: A,
24
+ isLoading: D,
25
+ disabled: p,
26
+ required: P
27
+ } = x, [i, b] = X(""), a = h(null), k = h(null), { popoverRef: m, froozePopoverPosition: y, handleAnimationEnd: E } = q(), O = g(() => {
26
28
  const e = {};
27
29
  return r.forEach((t) => {
28
30
  e[t.value] = t;
29
31
  }), e;
30
- }, [r]), O = (e) => n.includes(e) ? [...n] : [...n, e], T = (e) => n.filter((t) => e !== t), w = (e, t) => {
31
- C ? (k(), c(e), t()) : c(e);
32
- }, p = g(() => a.trim() ? r.filter(({ title: e }) => Q(e, a)) : r, [a, r]), I = (e) => {
33
- if (f) return;
32
+ }, [r]), S = (e) => n.includes(e) ? [...n] : [...n, e], T = (e) => n.filter((t) => e !== t), w = (e, t) => {
33
+ C ? (y(), c(e), t()) : c(e);
34
+ }, f = g(() => i.trim() ? r.filter(({ title: e }) => W(e, i)) : r, [i, r]), I = (e) => {
35
+ if (p) return;
34
36
  m.current && m.current.getAttribute("data-state") === "open" && e.preventDefault();
35
- const t = L(e.currentTarget);
36
- e.defaultPrevented || X(e.currentTarget, t) || i.current && i.current.focus();
37
- }, S = (e) => {
38
- e.target !== i.current && e.preventDefault();
39
- }, $ = (e, t) => {
37
+ const t = G(e.currentTarget);
38
+ e.defaultPrevented || J(e.currentTarget, t) || a.current && a.current.focus();
39
+ }, $ = (e) => {
40
+ e.target !== a.current && e.preventDefault();
41
+ }, F = (e, t) => {
40
42
  e.stopPropagation(), c(T(t));
41
43
  };
42
44
  return /* @__PURE__ */ o(
43
- q,
45
+ V,
44
46
  {
45
47
  minimal: !0,
46
48
  ref: m,
47
49
  sideOffset: 0,
48
50
  matchTarget: "width",
49
- onAnimationEnd: y,
51
+ onAnimationEnd: E,
50
52
  onOpenAutoFocus: (e) => e.preventDefault(),
51
53
  onCloseAutoFocus: (e) => e.preventDefault(),
52
- content: ({ close: e }) => /* @__PURE__ */ s(B, { maxHeight: 300, children: [
53
- p.length === 0 && /* @__PURE__ */ o("div", { className: "select-tags-empty", children: R }),
54
- p.map(({ value: t, title: u, icon: F }, M) => /* @__PURE__ */ o(
55
- V,
54
+ content: ({ close: e }) => D ? /* @__PURE__ */ o("div", { className: "select-popover-loading", children: /* @__PURE__ */ o(L, { size: 24 }) }) : /* @__PURE__ */ s(H, { maxHeight: 300, children: [
55
+ f.length === 0 && /* @__PURE__ */ o("div", { className: "select-tags-empty", children: R }),
56
+ f.map(({ value: t, title: u, icon: M }, j) => /* @__PURE__ */ o(
57
+ B,
56
58
  {
57
59
  active: n.includes(t),
58
- onClick: () => w(O(t), e),
60
+ onClick: () => w(S(t), e),
59
61
  title: u,
60
- icon: F
62
+ icon: M
61
63
  },
62
- `option-item-${t}-${M}`
64
+ `option-item-${t}-${j}`
63
65
  ))
64
66
  ] }),
65
67
  children: /* @__PURE__ */ o(
@@ -67,43 +69,43 @@ const ie = (x) => {
67
69
  {
68
70
  className: "form",
69
71
  onClick: I,
70
- onMouseDown: S,
71
- "data-size": A,
72
- "data-required": v(D),
72
+ onMouseDown: $,
73
+ "data-size": z,
74
+ "data-required": v(P),
73
75
  children: /* @__PURE__ */ s("div", { className: "select-tags-container", children: [
74
76
  /* @__PURE__ */ s("div", { className: "select-tags", children: [
75
77
  n.length > 0 && /* @__PURE__ */ o(
76
78
  "div",
77
79
  {
78
80
  className: "tag-container",
79
- ref: b,
81
+ ref: k,
80
82
  role: "listbox",
81
83
  "data-readonly": v(l),
82
84
  children: n.map((e, t) => /* @__PURE__ */ s("div", { className: "tag", children: [
83
- /* @__PURE__ */ o("span", { className: "tag-name", children: E[e].title }),
84
- /* @__PURE__ */ o("button", { className: "tag-close-button", onClick: (u) => $(u, e), children: /* @__PURE__ */ o(d, { className: "tag-close-icon", icon: J, size: "xxxs" }) })
85
+ /* @__PURE__ */ o("span", { className: "tag-name", children: O[e].title }),
86
+ /* @__PURE__ */ o("button", { className: "tag-close-button", onClick: (u) => F(u, e), children: /* @__PURE__ */ o(d, { className: "tag-close-icon", icon: Q, size: "xxxs" }) })
85
87
  ] }, `tag-option-${e}-${t}`))
86
88
  }
87
89
  ),
88
90
  (!l || n.length === 0) && /* @__PURE__ */ o(
89
91
  "input",
90
92
  {
91
- ref: G([z, i]),
93
+ ref: K([A, a]),
92
94
  type: "text",
93
95
  autoCapitalize: "none",
94
96
  autoComplete: "off",
95
97
  autoCorrect: "off",
96
98
  className: "form-input",
97
99
  spellCheck: !1,
98
- value: a,
99
- disabled: f,
100
+ value: i,
101
+ disabled: p,
100
102
  readOnly: l,
101
103
  placeholder: N,
102
- onChange: ({ target: e }) => P(e.value)
104
+ onChange: ({ target: e }) => b(e.value)
103
105
  }
104
106
  )
105
107
  ] }),
106
- /* @__PURE__ */ o(d, { className: "expand-icon", icon: K, size: "xxxs" })
108
+ /* @__PURE__ */ o(d, { className: "expand-icon", icon: U, size: "xxxs" })
107
109
  ] })
108
110
  }
109
111
  )
@@ -111,5 +113,5 @@ const ie = (x) => {
111
113
  );
112
114
  };
113
115
  export {
114
- ie as SelectTags
116
+ le as SelectTags
115
117
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@companix/uikit",
3
- "version": "0.0.50",
3
+ "version": "0.0.51",
4
4
  "main": "./dist/bundle.es.js",
5
5
  "module": "./dist/bundle.es.js",
6
6
  "types": "./dist/index.d.ts",