@companix/uikit 0.0.15 → 0.0.16

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