@companix/uikit 0.0.41 → 0.0.43

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.
@@ -14,6 +14,9 @@
14
14
  @include mixins.use-styles(option);
15
15
 
16
16
  &-icon {
17
+ display: flex;
18
+ align-items: center;
19
+
17
20
  @include mixins.use-styles(option, icon);
18
21
 
19
22
  svg {
@@ -23,10 +26,10 @@
23
26
 
24
27
  &-content {
25
28
  display: flex;
26
- flex-direction: column;
27
29
  flex-grow: 1;
28
30
  min-width: 0;
29
31
  max-width: 100%;
32
+ gap: 8px;
30
33
 
31
34
  &-inner {
32
35
  @include mixins.use-styles(option, content, layout);
@@ -36,6 +36,24 @@
36
36
  }
37
37
  }
38
38
 
39
+ &-add-option {
40
+ color: #2d81e0;
41
+
42
+ &:not([data-disabled]):hover {
43
+ background-color: #2d80e02b !important;
44
+ }
45
+
46
+ &:not([data-disabled]):active {
47
+ background-color: #2d80e042 !important;
48
+ }
49
+
50
+ svg {
51
+ width: 18px;
52
+ min-width: 18px;
53
+ height: 18px;
54
+ }
55
+ }
56
+
39
57
  &-element {
40
58
  height: 100%;
41
59
  display: flex;
@@ -7,6 +7,12 @@ interface SelectPopoverProps<T> {
7
7
  active?: T | null;
8
8
  onSelect?: (value: T) => void;
9
9
  onOpened?: () => void;
10
+ close: () => void;
11
+ addOption?: {
12
+ text: string;
13
+ closeOnClick?: boolean;
14
+ onClick: () => void;
15
+ };
10
16
  }
11
17
  export declare const SelectOptions: <T>(props: SelectPopoverProps<T>) => import("react/jsx-runtime").JSX.Element;
12
18
  export {};
@@ -19,6 +19,10 @@ export type SelectProps<T> = Omit<SelectFormProps, 'value' | 'onChange' | 'close
19
19
  scrollRef?: React.Ref<{
20
20
  scrollTo: (index: number) => void;
21
21
  }>;
22
+ addOption?: {
23
+ text: string;
24
+ onClick: () => void;
25
+ };
22
26
  };
23
27
  export declare const Select: <T>(props: SelectProps<T>) => import("react/jsx-runtime").JSX.Element;
24
28
  export {};
@@ -1,57 +1,58 @@
1
- import { jsxs as t, jsx as r } from "react/jsx-runtime";
1
+ import { jsxs as a, jsx as r } from "react/jsx-runtime";
2
2
  import * as o from "@radix-ui/react-popover";
3
3
  import { attr as B } from "@companix/utils-browser";
4
4
  import M from "classnames";
5
5
  import { forwardRef as j, useRef as k } from "react";
6
- const D = j((a, i) => {
6
+ const D = j((i, n) => {
7
7
  const {
8
- children: n,
9
- sideOffset: s,
10
- matchTarget: l,
11
- onAnimationEnd: c,
12
- onAnimationStart: m,
13
- onOpenAutoFocus: d,
8
+ children: s,
9
+ sideOffset: l,
10
+ matchTarget: c,
11
+ onAnimationEnd: m,
12
+ onAnimationStart: d,
13
+ onOpenAutoFocus: p,
14
14
  onCloseAutoFocus: f,
15
- triggerRef: p,
16
- triggerProps: h,
17
- open: g,
18
- content: u,
19
- onOpenChange: v,
20
- align: C,
21
- disabled: x,
22
- minimal: w,
23
- className: L,
24
- fitMaxHeight: N = !0,
25
- zIndex: O = 100,
15
+ triggerRef: h,
16
+ triggerProps: g,
17
+ open: u,
18
+ content: v,
19
+ onOpenChange: C,
20
+ align: x,
21
+ disabled: w,
22
+ minimal: L,
23
+ className: N,
24
+ fitMaxHeight: O = !0,
25
+ zIndex: P = 9999,
26
26
  side: A,
27
- showArrows: P
28
- } = a, e = k(null), b = () => {
27
+ showArrows: b
28
+ } = i, e = k(null), y = () => {
29
29
  e.current && e.current.click();
30
- }, y = (R) => {
31
- x && R.preventDefault();
30
+ }, R = (t) => {
31
+ w && t.preventDefault();
32
32
  };
33
- return /* @__PURE__ */ t(o.Root, { open: g, onOpenChange: v, children: [
34
- /* @__PURE__ */ r(o.Trigger, { ref: p, ...h, onClick: y, asChild: !0, children: n }),
35
- /* @__PURE__ */ r(o.Portal, { children: /* @__PURE__ */ t(
33
+ return /* @__PURE__ */ a(o.Root, { open: u, onOpenChange: C, children: [
34
+ /* @__PURE__ */ r(o.Trigger, { ref: h, ...g, onClick: R, asChild: !0, children: s }),
35
+ /* @__PURE__ */ r(o.Portal, { children: /* @__PURE__ */ a(
36
36
  o.Content,
37
37
  {
38
- ref: i,
39
- className: M("popover", L),
38
+ ref: n,
39
+ className: M("popover", N),
40
40
  side: A,
41
- align: C,
42
- "data-appearance": w ? "minimal" : "default",
43
- "data-match-target": l,
44
- sideOffset: s ?? 6,
41
+ align: x,
42
+ "data-appearance": L ? "minimal" : "default",
43
+ "data-match-target": c,
44
+ sideOffset: l ?? 6,
45
45
  avoidCollisions: !0,
46
46
  arrowPadding: 10,
47
- style: { zIndex: O },
48
- onAnimationStart: m,
49
- onAnimationEnd: c,
50
- onOpenAutoFocus: d,
47
+ style: { zIndex: P },
48
+ onAnimationStart: d,
49
+ onAnimationEnd: m,
50
+ onOpenAutoFocus: p,
51
51
  onCloseAutoFocus: f,
52
+ onWheel: (t) => t.stopPropagation(),
52
53
  children: [
53
54
  /* @__PURE__ */ r(o.Close, { ref: e, style: { display: "none" } }),
54
- P && /* @__PURE__ */ r(o.Arrow, { width: 30, height: 11, asChild: !0, children: /* @__PURE__ */ r("div", { className: "popover-arrow", children: /* @__PURE__ */ t("svg", { className: "popover-arrow-icon", viewBox: "0 0 30 11", width: 30, height: 11, children: [
55
+ b && /* @__PURE__ */ r(o.Arrow, { width: 30, height: 11, asChild: !0, children: /* @__PURE__ */ r("div", { className: "popover-arrow", children: /* @__PURE__ */ a("svg", { className: "popover-arrow-icon", viewBox: "0 0 30 11", width: 30, height: 11, children: [
55
56
  /* @__PURE__ */ r(
56
57
  "path",
57
58
  {
@@ -71,7 +72,7 @@ const D = j((a, i) => {
71
72
  }
72
73
  )
73
74
  ] }) }) }),
74
- /* @__PURE__ */ r("div", { className: "popover-content", "data-fit-max-height": B(N), children: u({ close: b }) })
75
+ /* @__PURE__ */ r("div", { className: "popover-content", "data-fit-max-height": B(O), children: v({ close: y }) })
75
76
  ]
76
77
  }
77
78
  ) })
@@ -1,77 +1,82 @@
1
1
  import { jsx as l } from "react/jsx-runtime";
2
- import { useMemo as F, useImperativeHandle as I } from "react";
3
- import { Popover as T } from "./bundle.es10.js";
4
- import { useFroozeClosing as b } from "./bundle.es45.js";
5
- import { SelectInput as z } from "./bundle.es46.js";
6
- import { useScrollListController as B } from "./bundle.es47.js";
7
- import { SelectOptions as D } from "./bundle.es48.js";
8
- import { mergeRefs as j } from "react-merge-refs";
9
- const G = (a) => {
2
+ import { useMemo as T, useImperativeHandle as b } from "react";
3
+ import { Popover as z } from "./bundle.es10.js";
4
+ import { useFroozeClosing as B } from "./bundle.es45.js";
5
+ import { SelectInput as D } from "./bundle.es46.js";
6
+ import { useScrollListController as j } from "./bundle.es47.js";
7
+ import { SelectOptions as w } from "./bundle.es48.js";
8
+ import { mergeRefs as H } from "react-merge-refs";
9
+ const K = (m) => {
10
10
  const {
11
11
  options: n,
12
12
  onChange: i,
13
13
  value: r,
14
- minimalOptions: m,
15
- matchTarget: f = "width",
16
- children: u,
14
+ minimalOptions: f,
15
+ matchTarget: u = "width",
16
+ children: d,
17
17
  disabled: p,
18
- scrollRef: d,
19
- popoverRef: v,
18
+ scrollRef: v,
19
+ popoverRef: h,
20
20
  clearButton: s,
21
- ...h
22
- } = a, t = F(() => {
21
+ addOption: x,
22
+ ...C
23
+ } = m, t = T(() => {
23
24
  const o = r === null ? -1 : n.findIndex((e) => e.value === r);
24
25
  return {
25
26
  index: o,
26
27
  option: n[o]
27
28
  };
28
- }, [n, r]), x = t.option?.value ?? null, { popoverRef: R, froozePopoverPosition: C, handleAnimationEnd: g } = b(), { scrollToElement: c, optionsWrapperRef: O, scrollBoxRef: P } = B();
29
- I(d, () => ({
30
- scrollTo: (o) => c(o, "top")
29
+ }, [n, r]), R = t.option?.value ?? null, { popoverRef: O, froozePopoverPosition: c, handleAnimationEnd: g } = B(), { scrollToElement: a, optionsWrapperRef: P, scrollBoxRef: S } = j();
30
+ b(v, () => ({
31
+ scrollTo: (o) => a(o, "top")
31
32
  }));
32
- const S = (o, e) => {
33
- C(), i(o), e();
34
- }, A = (o) => {
33
+ const A = (o, e) => {
34
+ c(), i(o), e();
35
+ }, E = (o) => {
36
+ c(), o();
37
+ }, F = (o) => {
35
38
  o.stopPropagation(), s && i(null);
36
- }, E = () => {
37
- t.index !== -1 && c(t.index, "center");
39
+ }, I = () => {
40
+ t.index !== -1 && a(t.index, "center");
38
41
  };
39
42
  return /* @__PURE__ */ l(
40
- T,
43
+ z,
41
44
  {
42
45
  minimal: !0,
43
- ref: j([R, v]),
46
+ ref: H([O, h]),
44
47
  sideOffset: 0,
45
- matchTarget: f,
48
+ matchTarget: u,
46
49
  onAnimationEnd: g,
47
50
  onOpenAutoFocus: (o) => o.preventDefault(),
48
51
  onCloseAutoFocus: (o) => o.preventDefault(),
49
52
  disabled: p,
50
53
  content: ({ close: o }) => /* @__PURE__ */ l(
51
- D,
54
+ w,
52
55
  {
53
56
  options: n,
54
- active: x,
55
- scrollboxRef: P,
56
- optionsWrapperRef: O,
57
- minimalOptions: m,
58
- onOpened: E,
59
- onSelect: (e) => S(e, o)
57
+ active: R,
58
+ scrollboxRef: S,
59
+ optionsWrapperRef: P,
60
+ minimalOptions: f,
61
+ close: () => E(o),
62
+ addOption: x,
63
+ onOpened: I,
64
+ onSelect: (e) => A(e, o)
60
65
  }
61
66
  ),
62
- children: u ?? /* @__PURE__ */ l(
63
- z,
67
+ children: d ?? /* @__PURE__ */ l(
68
+ D,
64
69
  {
65
- ...h,
70
+ ...C,
66
71
  disabled: p,
67
72
  clearButton: s,
68
73
  value: t.option?.title ?? "",
69
- onClear: A
74
+ onClear: F
70
75
  }
71
76
  )
72
77
  }
73
78
  );
74
79
  };
75
80
  export {
76
- G as Select
81
+ K as Select
77
82
  };
@@ -1,22 +1,47 @@
1
- import { jsx as o } from "react/jsx-runtime";
2
- import { useEffect as a } from "react";
3
- import { OptionItem as f } from "./bundle.es14.js";
4
- import { OptionsList as O } from "./bundle.es16.js";
5
- const h = (t) => {
6
- const { active: i, onOpened: m, scrollboxRef: n, optionsWrapperRef: r, options: p, onSelect: s, minimalOptions: c } = t;
7
- return a(() => {
8
- m?.();
9
- }, []), /* @__PURE__ */ o(O, { scrollboxRef: n, optionsWrapperRef: r, maxHeight: 300, children: p.map((e, l) => /* @__PURE__ */ o(
10
- f,
11
- {
12
- active: i === e.value,
13
- onClick: () => s?.(e.value),
14
- minimal: c,
15
- ...e
16
- },
17
- `select-option-${l}`
18
- )) });
1
+ import { jsxs as d, jsx as e } from "react/jsx-runtime";
2
+ import { useEffect as u } from "react";
3
+ import { OptionItem as i } from "./bundle.es14.js";
4
+ import { OptionsList as x } from "./bundle.es16.js";
5
+ import { Icon as k } from "./bundle.es33.js";
6
+ import { faPlus as v } from "@companix/icons-solid";
7
+ const b = (n) => {
8
+ const {
9
+ active: c,
10
+ onOpened: l,
11
+ addOption: o,
12
+ scrollboxRef: m,
13
+ optionsWrapperRef: r,
14
+ options: s,
15
+ onSelect: p,
16
+ close: a,
17
+ minimalOptions: f
18
+ } = n;
19
+ return u(() => {
20
+ l?.();
21
+ }, []), /* @__PURE__ */ d(x, { scrollboxRef: m, optionsWrapperRef: r, maxHeight: 300, children: [
22
+ o && /* @__PURE__ */ e(
23
+ i,
24
+ {
25
+ className: "select-add-option",
26
+ icon: /* @__PURE__ */ e(k, { icon: v }),
27
+ title: o.text,
28
+ onClick: () => {
29
+ (o.closeOnClick ?? !0) && a(), o.onClick();
30
+ }
31
+ }
32
+ ),
33
+ s.map((t, O) => /* @__PURE__ */ e(
34
+ i,
35
+ {
36
+ active: c === t.value,
37
+ onClick: () => p?.(t.value),
38
+ minimal: f,
39
+ ...t
40
+ },
41
+ `select-option-${O}`
42
+ ))
43
+ ] });
19
44
  };
20
45
  export {
21
- h as SelectOptions
46
+ b as SelectOptions
22
47
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@companix/uikit",
3
- "version": "0.0.41",
3
+ "version": "0.0.43",
4
4
  "main": "./dist/bundle.es.js",
5
5
  "module": "./dist/bundle.es.js",
6
6
  "types": "./dist/index.d.ts",