@companix/uikit 0.0.48 → 0.0.50

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