@companix/uikit 0.1.17 → 0.1.19

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.
@@ -157,14 +157,19 @@
157
157
  cursor: progress;
158
158
  position: relative;
159
159
 
160
+ @include mixins.use-styles(button, loading);
161
+
160
162
  .button-text {
161
163
  visibility: hidden;
164
+ @include mixins.use-styles(button, loading, text);
162
165
  }
163
166
 
164
167
  .button-spinner {
165
168
  position: absolute;
166
169
  margin: 0;
167
170
  color: inherit;
171
+
172
+ @include mixins.use-styles(button, loading, spinner);
168
173
  }
169
174
  }
170
175
  }
@@ -31,12 +31,24 @@
31
31
  max-width: 100%;
32
32
  gap: 8px;
33
33
 
34
+ &-layout {
35
+ width: 100%;
36
+ }
37
+
34
38
  &-inner {
35
39
  @include mixins.use-styles(option, content, layout);
36
40
  }
37
41
  }
38
42
 
43
+ &-header {
44
+ align-items: center;
45
+ width: 100%;
46
+ display: flex;
47
+ overflow: hidden;
48
+ }
49
+
39
50
  &-title {
51
+ flex: 1;
40
52
  word-break: break-word;
41
53
  }
42
54
 
@@ -9,6 +9,7 @@ export interface SelectFormProps {
9
9
  fill?: boolean;
10
10
  clearButton?: boolean;
11
11
  clearButtonIcon?: boolean;
12
+ customElement?: React.ReactNode;
12
13
  inputRef?: React.Ref<HTMLInputElement>;
13
14
  onClear?: (event: React.MouseEvent<HTMLButtonElement>) => void;
14
15
  onClick?: () => void;
@@ -2,6 +2,7 @@ interface SelectRightElementsProps {
2
2
  onClear?: (event: React.MouseEvent<HTMLButtonElement>) => void;
3
3
  clearButton?: boolean;
4
4
  clearButtonIcon?: React.ReactNode;
5
+ customElement?: React.ReactNode;
5
6
  value: boolean;
6
7
  }
7
8
  export declare const SelectRightElements: (props: SelectRightElementsProps) => import("react/jsx-runtime").JSX.Element;
@@ -10,33 +10,33 @@ const Z = (t) => {
10
10
  const {
11
11
  onChange: i,
12
12
  value: n,
13
- matchTarget: u = "width",
14
- children: f,
15
- scrollRef: m,
16
- popoverRef: d,
13
+ matchTarget: f = "width",
14
+ children: m,
15
+ scrollRef: d,
16
+ popoverRef: v,
17
17
  clearButton: s,
18
18
  // select props
19
19
  disabled: a,
20
- required: v,
21
- className: h,
22
- clearButtonIcon: O,
23
- leftElement: R,
24
- inputRef: C,
20
+ required: h,
21
+ className: O,
22
+ clearButtonIcon: R,
23
+ leftElement: C,
24
+ inputRef: P,
25
25
  onClear: y,
26
- fill: P,
26
+ fill: E,
27
27
  size: g,
28
- placeholder: E,
29
- onClick: A,
28
+ placeholder: A,
29
+ onClick: S,
30
30
  // options popover
31
- ...S
31
+ ...x
32
32
  } = t, r = L({});
33
33
  j(() => {
34
34
  (t.options ?? t.defaultOptions ?? []).forEach((e) => {
35
35
  r.current[e.value] = e;
36
36
  });
37
37
  }, [t.options, t.defaultOptions]);
38
- const x = n === null ? null : r.current[n] ?? null, { popoverRef: z, froozePopoverPosition: B, handleAnimationEnd: F } = w(), { scrollToElement: p, optionsWrapperRef: I, scrollBoxRef: T } = M();
39
- k(m, () => ({
38
+ const c = n === null ? null : r.current[n] ?? null, { popoverRef: z, froozePopoverPosition: B, handleAnimationEnd: F } = w(), { scrollToElement: p, optionsWrapperRef: I, scrollBoxRef: T } = M();
39
+ k(d, () => ({
40
40
  scrollTo: (o) => p(o, "top")
41
41
  }));
42
42
  const b = (o, e) => {
@@ -48,9 +48,9 @@ const Z = (t) => {
48
48
  q,
49
49
  {
50
50
  minimal: !0,
51
- ref: W([z, d]),
51
+ ref: W([z, v]),
52
52
  sideOffset: 0,
53
- matchTarget: u,
53
+ matchTarget: f,
54
54
  onAnimationEnd: F,
55
55
  onOpenAutoFocus: (o) => o.preventDefault(),
56
56
  onCloseAutoFocus: (o) => o.preventDefault(),
@@ -58,7 +58,7 @@ const Z = (t) => {
58
58
  content: ({ close: o }) => /* @__PURE__ */ l(
59
59
  N,
60
60
  {
61
- ...S,
61
+ ...x,
62
62
  close: o,
63
63
  isActive: (e) => e === n,
64
64
  onSelect: (e) => b(e, o),
@@ -66,28 +66,29 @@ const Z = (t) => {
66
66
  optionsWrapperRef: I,
67
67
  onOpened: (e) => p(e, "center"),
68
68
  onOptionsLoaded: (e) => {
69
- e.forEach((c) => {
70
- r.current[c.value] = c;
69
+ e.forEach((u) => {
70
+ r.current[u.value] = u;
71
71
  });
72
72
  }
73
73
  }
74
74
  ),
75
- children: f ?? /* @__PURE__ */ l(
75
+ children: m ?? /* @__PURE__ */ l(
76
76
  H,
77
77
  {
78
- required: v,
79
- className: h,
80
- leftElement: R,
81
- inputRef: C,
78
+ required: h,
79
+ className: O,
80
+ leftElement: C,
81
+ inputRef: P,
82
82
  onClear: D,
83
- fill: P,
83
+ fill: E,
84
84
  size: g,
85
- placeholder: E,
86
- onClick: A,
85
+ placeholder: A,
86
+ onClick: S,
87
87
  disabled: a,
88
88
  clearButton: s,
89
- clearButtonIcon: O,
90
- value: x?.title ?? ""
89
+ customElement: c?.indicator,
90
+ clearButtonIcon: R,
91
+ value: c?.title ?? ""
91
92
  }
92
93
  )
93
94
  }
@@ -1,38 +1,41 @@
1
1
  import { jsxs as i, jsx as o } from "react/jsx-runtime";
2
- import N from "classnames";
3
- import { Icon as v } from "./bundle.es36.js";
2
+ import v from "classnames";
3
+ import { Icon as k } from "./bundle.es36.js";
4
4
  import { attr as t } from "@companix/utils-browser";
5
- import { forwardRef as k } from "react";
6
- import { faCheck as x } from "@companix/icons-solid";
7
- const O = k(
8
- ({ title: d, icon: n, active: c, label: e, disabled: r, minimal: a, onClick: l, className: m, ...s }, p) => {
9
- const f = (h) => {
10
- r || l?.(h);
5
+ import { forwardRef as x } from "react";
6
+ import { faCheck as C } from "@companix/icons-solid";
7
+ const R = x(
8
+ ({ title: d, icon: e, active: n, label: c, indicator: l, disabled: a, minimal: r, onClick: s, className: m, ...p }, h) => {
9
+ const f = (N) => {
10
+ a || s?.(N);
11
11
  };
12
12
  return /* @__PURE__ */ i(
13
13
  "div",
14
14
  {
15
- ref: p,
16
- ...s,
17
- className: N("option", m),
18
- "data-selected": t(c),
19
- "data-disabled": t(r),
20
- "data-minimal": t(a),
15
+ ref: h,
16
+ ...p,
17
+ className: v("option", m),
18
+ "data-selected": t(n),
19
+ "data-disabled": t(a),
20
+ "data-minimal": t(r),
21
21
  onClick: f,
22
22
  children: [
23
23
  /* @__PURE__ */ i("div", { className: "option-content", children: [
24
- n && /* @__PURE__ */ o("div", { className: "option-icon", children: n }),
24
+ e && /* @__PURE__ */ o("div", { className: "option-icon", children: e }),
25
25
  /* @__PURE__ */ i("div", { className: "option-content-layout", children: [
26
- /* @__PURE__ */ o("div", { className: "option-title", children: d }),
27
- e && /* @__PURE__ */ o("div", { className: "option-label", children: e })
26
+ /* @__PURE__ */ i("div", { className: "option-header", children: [
27
+ /* @__PURE__ */ o("div", { className: "option-title", children: d }),
28
+ l
29
+ ] }),
30
+ c && /* @__PURE__ */ o("div", { className: "option-label", children: c })
28
31
  ] })
29
32
  ] }),
30
- c && !a && /* @__PURE__ */ o("div", { className: "option-check", children: /* @__PURE__ */ o(v, { icon: x }) })
33
+ n && !r && /* @__PURE__ */ o("div", { className: "option-check", children: /* @__PURE__ */ o(k, { icon: C }) })
31
34
  ]
32
35
  }
33
36
  );
34
37
  }
35
38
  );
36
39
  export {
37
- O as OptionItem
40
+ R as OptionItem
38
41
  };
@@ -1,11 +1,11 @@
1
1
  import { jsxs as o, jsx as n } from "react/jsx-runtime";
2
- import w from "classnames";
2
+ import y from "classnames";
3
3
  import { attr as s } from "@companix/utils-browser";
4
- import { forwardRef as y, useRef as D, useCallback as S } from "react";
5
- import { VisuallyHidden as T } from "@radix-ui/react-visually-hidden";
6
- import { mergeRefs as j } from "react-merge-refs";
7
- import { SelectRightElements as z } from "./bundle.es73.js";
8
- const W = y(
4
+ import { forwardRef as D, useRef as S, useCallback as T } from "react";
5
+ import { VisuallyHidden as j } from "@radix-ui/react-visually-hidden";
6
+ import { mergeRefs as z } from "react-merge-refs";
7
+ import { SelectRightElements as B } from "./bundle.es73.js";
8
+ const G = D(
9
9
  ({
10
10
  required: a,
11
11
  size: i,
@@ -16,40 +16,41 @@ const W = y(
16
16
  clearButton: m,
17
17
  placeholder: p,
18
18
  clearButtonIcon: f,
19
+ customElement: h,
19
20
  disabled: r,
20
- onClear: h,
21
- inputRef: C,
22
- onClick: I,
23
- ...N
24
- }, k) => {
25
- const e = D(null), v = S(
21
+ onClear: C,
22
+ inputRef: I,
23
+ onClick: N,
24
+ ...k
25
+ }, v) => {
26
+ const e = S(null), F = T(
26
27
  (t) => {
27
28
  if (!e.current || !document)
28
29
  return;
29
30
  t.target !== e.current && (e.current.click(), document.activeElement !== e.current && e.current.focus());
30
31
  },
31
32
  [e]
32
- ), F = (t) => {
33
+ ), g = (t) => {
33
34
  document && document.activeElement === e.current && t.preventDefault();
34
- }, g = (t) => {
35
- r || v(t);
36
35
  }, R = (t) => {
37
- F(t);
36
+ r || F(t);
38
37
  }, x = (t) => {
39
- e.current && e.current.focus(), h?.(t);
38
+ g(t);
39
+ }, A = (t) => {
40
+ e.current && e.current.focus(), C?.(t);
40
41
  };
41
42
  return /* @__PURE__ */ o(
42
43
  "div",
43
44
  {
44
- ref: k,
45
- className: w("form select", d),
45
+ ref: v,
46
+ className: y("form select", d),
46
47
  "data-size": i ?? "md",
47
48
  "data-fill": s(u),
48
49
  "data-required": s(a),
49
50
  "data-disabled": s(r),
50
- onMouseDown: R,
51
- onClick: g,
52
- ...N,
51
+ onMouseDown: x,
52
+ onClick: R,
53
+ ...k,
53
54
  children: [
54
55
  /* @__PURE__ */ o("div", { className: "select-layout form-input", children: [
55
56
  l && /* @__PURE__ */ n("div", { className: "select-element", children: l }),
@@ -58,25 +59,26 @@ const W = y(
58
59
  c
59
60
  ] }) }),
60
61
  /* @__PURE__ */ n("div", { className: "select-element", children: /* @__PURE__ */ n(
61
- z,
62
+ B,
62
63
  {
64
+ customElement: h,
63
65
  clearButton: m,
64
66
  value: !!c,
65
67
  clearButtonIcon: f,
66
- onClear: x
68
+ onClear: A
67
69
  }
68
70
  ) })
69
71
  ] }),
70
- /* @__PURE__ */ n(T, { asChild: !0, children: /* @__PURE__ */ n(
72
+ /* @__PURE__ */ n(j, { asChild: !0, children: /* @__PURE__ */ n(
71
73
  "input",
72
74
  {
73
- ref: j([C, e]),
75
+ ref: z([I, e]),
74
76
  autoComplete: "off",
75
77
  autoCapitalize: "none",
76
78
  autoCorrect: "off",
77
79
  spellCheck: "false",
78
80
  "aria-autocomplete": "none",
79
- onClick: I,
81
+ onClick: N,
80
82
  readOnly: !0
81
83
  }
82
84
  ) })
@@ -86,5 +88,5 @@ const W = y(
86
88
  }
87
89
  );
88
90
  export {
89
- W as SelectInput
91
+ G as SelectInput
90
92
  };
@@ -1,16 +1,16 @@
1
- import { jsx as i, jsxs as k } from "react/jsx-runtime";
2
- import { useMemo as y, useEffect as C } from "react";
3
- import { Spinner as P } from "./bundle.es7.js";
1
+ import { jsx as i, jsxs as y } from "react/jsx-runtime";
2
+ import { useMemo as P, useEffect as C } from "react";
3
+ import { Spinner as T } from "./bundle.es7.js";
4
4
  import { OptionItem as L } from "./bundle.es16.js";
5
- import { OptionsList as T } from "./bundle.es18.js";
6
- import { Icon as R } from "./bundle.es36.js";
7
- import { faPlus as S } from "@companix/icons-solid";
8
- const b = () => ({ isLoading: !1, options: [] }), I = (e) => {
9
- const { onOptionsLoaded: n, useOptions: s = b, options: o } = e, t = s();
5
+ import { OptionsList as R } from "./bundle.es18.js";
6
+ import { Icon as S } from "./bundle.es36.js";
7
+ import { faPlus as b } from "@companix/icons-solid";
8
+ const I = () => ({ isLoading: !1, options: [] }), N = (e) => {
9
+ const { onOptionsLoaded: n, useOptions: s = I, options: o } = e, t = s();
10
10
  return C(() => {
11
11
  t.options.length > 0 && n?.(t.options);
12
12
  }, [t.options]), o ? { options: o, isLoading: !1 } : t;
13
- }, H = (e) => {
13
+ }, M = (e) => {
14
14
  const {
15
15
  isActive: n,
16
16
  emptyText: s,
@@ -25,9 +25,9 @@ const b = () => ({ isLoading: !1, options: [] }), I = (e) => {
25
25
  disableFiltering: l,
26
26
  close: c,
27
27
  ...m
28
- } = e, { emptyText: x, options: a, isLoading: g } = I(m), v = y(() => r && !l ? a.filter(r) : a, [a, r, l]);
29
- return g ?? o ? /* @__PURE__ */ i("div", { className: "select-popover-loading", children: /* @__PURE__ */ i(P, { size: 24 }) }) : /* @__PURE__ */ i(
30
- N,
28
+ } = e, { emptyText: x, options: a, isLoading: g } = N(m), v = P(() => r && !l ? a.filter(r) : a, [a, r, l]);
29
+ return g ?? o ? /* @__PURE__ */ i("div", { className: "select-popover-loading", children: /* @__PURE__ */ i(T, { size: 24 }) }) : /* @__PURE__ */ i(
30
+ j,
31
31
  {
32
32
  options: v,
33
33
  isActive: n,
@@ -41,7 +41,7 @@ const b = () => ({ isLoading: !1, options: [] }), I = (e) => {
41
41
  close: c
42
42
  }
43
43
  );
44
- }, N = (e) => {
44
+ }, j = (e) => {
45
45
  const {
46
46
  isActive: n,
47
47
  onOpened: s,
@@ -61,7 +61,7 @@ const b = () => ({ isLoading: !1, options: [] }), I = (e) => {
61
61
  L,
62
62
  {
63
63
  className: "select-add-option",
64
- icon: /* @__PURE__ */ i(R, { icon: S }),
64
+ icon: /* @__PURE__ */ i(S, { icon: b }),
65
65
  title: o.text,
66
66
  onClick: o.onClick,
67
67
  onClickCapture: () => {
@@ -69,10 +69,10 @@ const b = () => ({ isLoading: !1, options: [] }), I = (e) => {
69
69
  }
70
70
  }
71
71
  ) : void 0;
72
- return /* @__PURE__ */ k(T, { scrollboxRef: t, optionsWrapperRef: d, maxHeight: 300, children: [
72
+ return /* @__PURE__ */ y(R, { scrollboxRef: t, optionsWrapperRef: d, maxHeight: 300, children: [
73
73
  (o?.position === void 0 || o?.position === "first") && l,
74
74
  p.length === 0 && !o && /* @__PURE__ */ i("div", { className: "select-tags-noneresults", children: u }),
75
- p.map(({ title: c, value: m, className: x, icon: a, disabled: g, label: v }, h) => /* @__PURE__ */ i(
75
+ p.map(({ title: c, value: m, className: x, icon: a, disabled: g, indicator: v, label: h }, k) => /* @__PURE__ */ i(
76
76
  L,
77
77
  {
78
78
  active: n(m),
@@ -81,15 +81,16 @@ const b = () => ({ isLoading: !1, options: [] }), I = (e) => {
81
81
  disabled: g,
82
82
  className: x,
83
83
  title: c,
84
- label: v,
84
+ label: h,
85
+ indicator: v,
85
86
  icon: a
86
87
  },
87
- `select-option-${h}`
88
+ `select-option-${k}`
88
89
  )),
89
90
  o?.position === "last" && l
90
91
  ] });
91
92
  };
92
93
  export {
93
- H as OptionsPopover,
94
- N as SelectOptionsList
94
+ M as OptionsPopover,
95
+ j as SelectOptionsList
95
96
  };
@@ -1,13 +1,14 @@
1
- import { jsxs as r, Fragment as a, jsx as e } from "react/jsx-runtime";
2
- import { faXmark as i, faChevronDown as m } from "@companix/icons-solid";
1
+ import { jsxs as a, Fragment as m, jsx as e } from "react/jsx-runtime";
2
+ import { faXmark as i, faChevronDown as x } from "@companix/icons-solid";
3
3
  import { Icon as o } from "./bundle.es36.js";
4
- const f = (n) => {
5
- const { clearButton: c, clearButtonIcon: t, value: s, onClear: l } = n;
6
- return /* @__PURE__ */ r(a, { children: [
7
- c && s && /* @__PURE__ */ e("button", { className: "select-close-button", onClick: l, children: t ?? /* @__PURE__ */ e(o, { className: "select-close-icon", icon: i, size: "xxxs" }) }),
8
- /* @__PURE__ */ e(o, { className: "expand-icon select-expand", icon: m, size: "xxxs" })
4
+ const d = (n) => {
5
+ const { customElement: t, clearButton: c, clearButtonIcon: s, value: l, onClear: r } = n;
6
+ return /* @__PURE__ */ a(m, { children: [
7
+ t,
8
+ c && l && /* @__PURE__ */ e("button", { className: "select-close-button", onClick: r, children: s ?? /* @__PURE__ */ e(o, { className: "select-close-icon", icon: i, size: "xxxs" }) }),
9
+ /* @__PURE__ */ e(o, { className: "expand-icon select-expand", icon: x, size: "xxxs" })
9
10
  ] });
10
11
  };
11
12
  export {
12
- f as SelectRightElements
13
+ d as SelectRightElements
13
14
  };
package/dist/types.d.ts CHANGED
@@ -3,6 +3,7 @@ export interface Option<T> {
3
3
  value: T;
4
4
  icon?: React.ReactNode;
5
5
  label?: string;
6
+ indicator?: React.ReactNode;
6
7
  disabled?: boolean;
7
8
  className?: string;
8
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@companix/uikit",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
4
4
  "main": "./dist/bundle.es.js",
5
5
  "module": "./dist/bundle.es.js",
6
6
  "types": "./dist/index.d.ts",