@companix/uikit 0.0.52 → 0.0.54

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