@companix/uikit 0.0.59 → 0.0.60

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