@plitzi/plitzi-ui 1.6.3 → 1.6.4

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.
@@ -17,7 +17,7 @@ export type ContainerFloatingProps = {
17
17
  } & useThemeSharedProps<typeof ContainerFloatingStyles, typeof variantKeys>;
18
18
  declare const ContainerFloating: {
19
19
  ({ ref, children, containerTopOffset, containerLeftOffset, open: openProp, disabled, loading, closeOnClick, testId, placement, container, onOpenChange }: ContainerFloatingProps): import("react/jsx-runtime").JSX.Element;
20
- Trigger: ({ children, className, testId, ref, onClick }: ContainerFloatingTriggerProps) => import("react/jsx-runtime").JSX.Element;
21
- Content: ({ ref, children, className, placement, testId, ...props }: ContainerFloatingContentProps) => import("react/jsx-runtime").JSX.Element;
20
+ Trigger: ({ children, className, testId, ref, placement, disabled, onClick }: ContainerFloatingTriggerProps) => import("react/jsx-runtime").JSX.Element;
21
+ Content: ({ ref, children, className, placement, testId, disabled, ...props }: ContainerFloatingContentProps) => import("react/jsx-runtime").JSX.Element;
22
22
  };
23
23
  export default ContainerFloating;
@@ -23,6 +23,8 @@ var m = ({ ref: m, children: h, containerTopOffset: g = 0, containerLeftOffset:
23
23
  e.trigger = o(t, {
24
24
  testId: S ? `${S}-trigger` : void 0,
25
25
  onClick: k,
26
+ disabled: y || b,
27
+ placement: C,
26
28
  ...n,
27
29
  ref: A
28
30
  });
@@ -30,6 +32,8 @@ var m = ({ ref: m, children: h, containerTopOffset: g = 0, containerLeftOffset:
30
32
  let n = t.props;
31
33
  e.content = o(t, {
32
34
  testId: S ? `${S}-content` : void 0,
35
+ disabled: y || b,
36
+ placement: C,
33
37
  ...n,
34
38
  onClick: j(n.onClick)
35
39
  });
@@ -38,10 +42,13 @@ var m = ({ ref: m, children: h, containerTopOffset: g = 0, containerLeftOffset:
38
42
  }), e;
39
43
  }, [
40
44
  h,
41
- k,
42
- j,
43
45
  S,
44
- A
46
+ k,
47
+ y,
48
+ b,
49
+ C,
50
+ A,
51
+ j
45
52
  ]);
46
53
  return /* @__PURE__ */ p(d, { children: [M, /* @__PURE__ */ f(e, {
47
54
  value: l(() => ({
@@ -6,7 +6,9 @@ export declare const variantKeys: {
6
6
  export declare const STYLES_COMPONENT_NAME = "ContainerFloating";
7
7
  declare const _default: {
8
8
  root: (props?: ({} & import('class-variance-authority/types').ClassProp) | undefined) => string;
9
- trigger: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
9
+ trigger: (props?: ({
10
+ disabled?: boolean | null | undefined;
11
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
10
12
  content: (props?: ({
11
13
  intent?: "custom" | "dropdown" | null | undefined;
12
14
  disabled?: boolean | null | undefined;
@@ -5,7 +5,14 @@ var t = {
5
5
  compoundVariants: [],
6
6
  defaultVariants: {}
7
7
  }),
8
- trigger: e("cursor-pointer"),
8
+ trigger: e("", {
9
+ variants: { disabled: {
10
+ true: "cursor-not-allowed",
11
+ false: "cursor-pointer"
12
+ } },
13
+ compoundVariants: [],
14
+ defaultVariants: { disabled: !1 }
15
+ }),
9
16
  content: e("flex w-full h-full", {
10
17
  variants: {
11
18
  intent: {
@@ -7,5 +7,5 @@ export type ContainerFloatingContentProps = {
7
7
  className?: string;
8
8
  testId?: string;
9
9
  } & HTMLAttributes<HTMLDivElement> & useThemeSharedProps<typeof ContainerFloatingStyles, typeof variantKeys>;
10
- declare const ContainerFloatingContent: ({ ref, children, className, placement, testId, ...props }: ContainerFloatingContentProps) => import("react/jsx-runtime").JSX.Element;
10
+ declare const ContainerFloatingContent: ({ ref, children, className, placement, testId, disabled, ...props }: ContainerFloatingContentProps) => import("react/jsx-runtime").JSX.Element;
11
11
  export default ContainerFloatingContent;
@@ -1,12 +1,15 @@
1
1
  import e from "../../hooks/useTheme/index.js";
2
2
  import { jsx as t } from "react/jsx-runtime";
3
3
  //#region src/components/ContainerFloating/ContainerFloatingContent.tsx
4
- var n = ({ ref: n, children: r, className: i, placement: a, testId: o, ...s }) => (i = e("ContainerFloating", {
4
+ var n = ({ ref: n, children: r, className: i, placement: a, testId: o, disabled: s, ...c }) => (i = e("ContainerFloating", {
5
5
  className: i,
6
6
  componentKey: "content",
7
- variants: { placement: a }
7
+ variants: {
8
+ placement: a,
9
+ disabled: s
10
+ }
8
11
  }), /* @__PURE__ */ t("div", {
9
- ...s,
12
+ ...c,
10
13
  ref: n,
11
14
  className: i,
12
15
  "data-testid": o,
@@ -7,5 +7,5 @@ export type ContainerFloatingTriggerProps = {
7
7
  testId?: string;
8
8
  onClick?: (e: MouseEvent<HTMLDivElement>) => void;
9
9
  } & useThemeSharedProps<typeof ContainerFloatingStyles, typeof variantKeys>;
10
- declare const ContainerFloatingTrigger: ({ children, className, testId, ref, onClick }: ContainerFloatingTriggerProps) => import("react/jsx-runtime").JSX.Element;
10
+ declare const ContainerFloatingTrigger: ({ children, className, testId, ref, placement, disabled, onClick }: ContainerFloatingTriggerProps) => import("react/jsx-runtime").JSX.Element;
11
11
  export default ContainerFloatingTrigger;
@@ -1,13 +1,17 @@
1
1
  import e from "../../hooks/useTheme/index.js";
2
2
  import { jsx as t } from "react/jsx-runtime";
3
3
  //#region src/components/ContainerFloating/ContainerFloatingTrigger.tsx
4
- var n = ({ children: n, className: r, testId: i, ref: a, onClick: o }) => (r = e("ContainerFloating", {
4
+ var n = ({ children: n, className: r, testId: i, ref: a, placement: o, disabled: s, onClick: c }) => (r = e("ContainerFloating", {
5
5
  className: r,
6
- componentKey: "trigger"
6
+ componentKey: "trigger",
7
+ variants: {
8
+ placement: o,
9
+ disabled: s
10
+ }
7
11
  }), /* @__PURE__ */ t("div", {
8
12
  ref: a,
9
13
  className: r,
10
- onClick: o,
14
+ onClick: c,
11
15
  "data-testid": i,
12
16
  children: n
13
17
  }));
@@ -29,6 +29,7 @@ type Select2PropsBase = {
29
29
  autoClose?: boolean;
30
30
  clearable?: boolean;
31
31
  open?: boolean;
32
+ loading?: boolean;
32
33
  allowRemoveOptions?: boolean;
33
34
  searchAutoFocus?: boolean;
34
35
  };
@@ -1,19 +1,19 @@
1
1
  import e from "../../hooks/useTheme/index.js";
2
2
  import t from "../Flex/index.js";
3
3
  import n from "../Icon/index.js";
4
- import ee from "../Input/InputContainer.js";
5
- import r from "../ContainerFloating/index.js";
6
- import { isOptionGroup as i } from "./helpers/utils.js";
7
- import a from "./ListItem.js";
8
- import o from "./SelectInput.js";
9
- import te from "./SelectList.js";
10
- import { memo as s, useCallback as c, useEffect as l, useImperativeHandle as u, useMemo as d, useRef as f, useState as p } from "react";
11
- import { jsx as m, jsxs as h } from "react/jsx-runtime";
12
- import ne from "clsx";
4
+ import r from "../Input/InputContainer.js";
5
+ import i from "../ContainerFloating/index.js";
6
+ import { isOptionGroup as a } from "./helpers/utils.js";
7
+ import o from "./ListItem.js";
8
+ import s from "./SelectInput.js";
9
+ import ee from "./SelectList.js";
10
+ import { memo as c, useCallback as l, useEffect as u, useImperativeHandle as d, useMemo as f, useRef as p, useState as m } from "react";
11
+ import { jsx as h, jsxs as g } from "react/jsx-runtime";
12
+ import _ from "clsx";
13
13
  //#region src/components/Select2/Select2.tsx
14
- var g = [], _ = s((s) => {
15
- let { ref: _, className: v = "", id: y, name: b, value: x, options: S = g, placeholder: C = "Select...", label: w = "", size: T, disabled: E = !1, error: D = !1, allowCreateOptions: O = !1, isSearchable: k = !0, clearable: A = !0, allowRemoveOptions: j = !1, open: M, searchAutoFocus: N = !0, autoClose: P = !0, onChange: F } = s, [I, L] = p(M), R = e("Select2", {
16
- className: v,
14
+ var v = [], y = c((c) => {
15
+ let { ref: y, className: b = "", id: te, name: ne, value: x, options: S = v, placeholder: C = "Select...", label: w = "", size: T, disabled: E = !1, error: D = !1, allowCreateOptions: O = !1, isSearchable: k = !0, clearable: A = !0, allowRemoveOptions: j = !1, open: M, searchAutoFocus: re = !0, autoClose: N = !0, loading: ie = !1, onChange: P } = c, [F, ae] = m(M), [I, L] = m(S instanceof Promise), R = I || ie, z = e("Select2", {
16
+ className: b,
17
17
  componentKey: [
18
18
  "root",
19
19
  "listPopup",
@@ -25,12 +25,12 @@ var g = [], _ = s((s) => {
25
25
  "value"
26
26
  ],
27
27
  variants: { size: T }
28
- }), z = f(null), [B, V] = p(), [H, U] = p(S instanceof Promise), [W, G] = p(() => !H && Array.isArray(S) ? S : []), [K, q] = p([]);
29
- u(_, () => z.current, [z]);
30
- let J = d(() => {
28
+ }), B = p(null), [V, H] = m(), [U, W] = m(() => !I && Array.isArray(S) ? S : []), [G, K] = m([]);
29
+ d(y, () => B.current, [B]);
30
+ let q = f(() => {
31
31
  if (typeof x == "string") {
32
- let e = W.find((e) => i(e) ? e.options.find((e) => e.value === x) : e.value === x);
33
- return i(e) ? e.options.find((e) => e.value === x) : !e && x && O ? {
32
+ let e = U.find((e) => a(e) ? e.options.find((e) => e.value === x) : e.value === x);
33
+ return a(e) ? e.options.find((e) => e.value === x) : !e && x && O ? {
34
34
  label: x,
35
35
  value: x
36
36
  } : e;
@@ -38,151 +38,151 @@ var g = [], _ = s((s) => {
38
38
  return x;
39
39
  }, [
40
40
  O,
41
- W,
41
+ U,
42
42
  x
43
- ]), [Y, X] = p(""), re = c((e) => {
44
- !I && z.current && z.current.click(), X(e);
43
+ ]), [J, Y] = m(""), oe = l((e) => {
44
+ !F && B.current && B.current.click(), Y(e);
45
45
  }, [
46
- X,
47
- I,
48
- z
49
- ]), ie = c((e) => {
50
- L(e), e || X("");
51
- }, []), Z = c((e) => {
52
- E || (s.valueAsString ? s.onChange?.(e?.value) : s.onChange?.(e), X(""), P && z.current && z.current.click());
46
+ Y,
47
+ F,
48
+ B
49
+ ]), se = l((e) => {
50
+ ae(e), e || Y("");
51
+ }, []), X = l((e) => {
52
+ E || (c.valueAsString ? c.onChange?.(e?.value) : c.onChange?.(e), Y(""), N && B.current && B.current.click());
53
53
  }, [
54
54
  E,
55
- s.valueAsString,
56
- s.onChange,
57
- P
58
- ]), ae = c((e) => {
59
- j && (e.value === x && F?.(void 0), s.valueAsString ? s.onRemove?.(e.value) : s.onRemove?.(e));
55
+ c.valueAsString,
56
+ c.onChange,
57
+ N
58
+ ]), ce = l((e) => {
59
+ j && (e.value === x && P?.(void 0), c.valueAsString ? c.onRemove?.(e.value) : c.onRemove?.(e));
60
60
  }, [
61
61
  j,
62
- s.valueAsString,
63
- s.onRemove
64
- ]), Q = c(async () => {
62
+ c.valueAsString,
63
+ c.onRemove
64
+ ]), Z = l(async () => {
65
65
  let e = S;
66
- e instanceof Promise && (U(!0), e = await e, U(!1)), G(e);
66
+ e instanceof Promise && (L(!0), W([]), e = await e, L(!1)), W(e);
67
67
  }, [S]);
68
- l(() => {
69
- Q();
70
- }, [S, Q]), l(() => {
71
- V(I ? z.current?.getBoundingClientRect() : void 0);
72
- }, [I]), l(() => {
73
- if (!(!O || !J || i(J))) return J.value && !W.find((e) => "value" in e && e.value === J.value) && q((e) => {
74
- if (e.find((e) => "value" in e && e.value === J.value)) return e;
68
+ u(() => {
69
+ Z();
70
+ }, [S, Z]), u(() => {
71
+ H(F ? B.current?.getBoundingClientRect() : void 0);
72
+ }, [F]), u(() => {
73
+ if (!(!O || !q || a(q))) return q.value && !U.find((e) => "value" in e && e.value === q.value) && K((e) => {
74
+ if (e.find((e) => "value" in e && e.value === q.value)) return e;
75
75
  let t = [...e];
76
76
  return t.push({
77
- label: J.label,
78
- value: J.value
77
+ label: q.label,
78
+ value: q.value
79
79
  }), t;
80
80
  }), () => {
81
- J.value && !W.find((e) => "value" in e && e.value === J.value) && q([]);
81
+ q.value && !U.find((e) => "value" in e && e.value === q.value) && K([]);
82
82
  };
83
83
  }, [
84
84
  O,
85
- J,
86
- W,
85
+ q,
86
+ U,
87
87
  x
88
88
  ]);
89
- let $ = d(() => {
90
- let e = (e) => (e.label ? e.label : "").toLowerCase().indexOf(Y.toLowerCase()) > -1, t = [...K, ...W].map((t) => i(t) ? {
89
+ let Q = f(() => {
90
+ let e = (e) => (e.label ? e.label : "").toLowerCase().indexOf(J.toLowerCase()) > -1, t = [...G, ...U].map((t) => a(t) ? {
91
91
  icon: t.icon,
92
92
  label: t.label,
93
93
  options: t.options.filter(e)
94
94
  } : t);
95
- return t = t.filter((t) => i(t) ? t.options.length > 0 : e(t)), t;
95
+ return t = t.filter((t) => a(t) ? t.options.length > 0 : e(t)), t;
96
96
  }, [
97
- W,
98
- K,
99
- Y
100
- ]), oe = c((e) => {
101
- e.stopPropagation(), F?.(void 0);
102
- }, [F]), se = d(() => ({ width: B?.width }), [B]);
103
- return /* @__PURE__ */ h(r, {
104
- ref: z,
97
+ U,
98
+ G,
99
+ J
100
+ ]), le = l((e) => {
101
+ e.stopPropagation(), P?.(void 0);
102
+ }, [P]), $ = f(() => ({ width: V?.width }), [V]);
103
+ return /* @__PURE__ */ g(i, {
104
+ ref: B,
105
105
  containerTopOffset: D ? -26 : 4,
106
106
  containerLeftOffset: 0,
107
- onOpenChange: ie,
107
+ onOpenChange: se,
108
108
  open: M,
109
- loading: H,
109
+ loading: R,
110
110
  disabled: E,
111
- children: [/* @__PURE__ */ m(r.Trigger, {
112
- className: R.trigger,
113
- children: /* @__PURE__ */ h(ee, {
114
- id: y,
111
+ children: [/* @__PURE__ */ h(i.Trigger, {
112
+ className: z.trigger,
113
+ children: /* @__PURE__ */ g(r, {
114
+ id: te,
115
115
  size: T,
116
116
  clearable: A,
117
117
  disabled: E,
118
118
  label: w,
119
119
  error: D,
120
- loading: H,
121
- onClear: oe,
122
- className: { iconFloatingContainer: R.inputContainer },
120
+ loading: R,
121
+ onClear: le,
122
+ className: { iconFloatingContainer: z.inputContainer },
123
123
  value: x,
124
- children: [/* @__PURE__ */ m("input", {
124
+ children: [/* @__PURE__ */ h("input", {
125
125
  type: "hidden",
126
- name: b,
126
+ name: ne,
127
127
  className: "hidden invisible"
128
- }), /* @__PURE__ */ h(t, {
128
+ }), /* @__PURE__ */ g(t, {
129
129
  justify: "between",
130
130
  items: "center",
131
131
  className: "min-w-0",
132
132
  grow: !0,
133
133
  children: [
134
- /* @__PURE__ */ m("div", {
135
- className: ne("truncate select-none", {
136
- "mr-8": !!D || H,
137
- [R.placeholder]: !J?.label,
138
- [R.value]: !!J?.label
134
+ /* @__PURE__ */ h("div", {
135
+ className: _("truncate select-none", {
136
+ "mr-8": !!D || R,
137
+ [z.placeholder]: !q?.label,
138
+ [z.value]: !!q?.label
139
139
  }),
140
- title: J?.label ?? C,
141
- children: J?.label ?? C
140
+ title: q?.label ?? C,
141
+ children: q?.label ?? C
142
142
  }),
143
- !I && /* @__PURE__ */ m(n, { icon: "fa-solid fa-chevron-down" }),
144
- I && /* @__PURE__ */ m(n, { icon: "fa-solid fa-chevron-up" })
143
+ !F && /* @__PURE__ */ h(n, { icon: "fa-solid fa-chevron-down" }),
144
+ F && /* @__PURE__ */ h(n, { icon: "fa-solid fa-chevron-up" })
145
145
  ]
146
146
  })]
147
147
  })
148
- }), B && /* @__PURE__ */ h(r.Content, {
149
- className: R.listPopup,
150
- style: se,
148
+ }), V && /* @__PURE__ */ g(i.Content, {
149
+ className: z.listPopup,
150
+ style: $,
151
151
  children: [
152
- !H && /* @__PURE__ */ h("div", {
153
- className: R.listPopupInner,
154
- children: [k && I && /* @__PURE__ */ m(o, {
152
+ !R && /* @__PURE__ */ g("div", {
153
+ className: z.listPopupInner,
154
+ children: [k && F && /* @__PURE__ */ h(s, {
155
155
  size: T,
156
- value: Y,
156
+ value: J,
157
157
  placeholder: "Search...",
158
158
  disabled: E,
159
- autoFocus: N,
159
+ autoFocus: re,
160
160
  allowCreateOptions: O,
161
- onChange: re,
162
- onSelect: Z
163
- }), $.length > 0 && /* @__PURE__ */ m(te, {
164
- value: J?.value,
165
- options: $,
161
+ onChange: oe,
162
+ onSelect: X
163
+ }), Q.length > 0 && /* @__PURE__ */ h(ee, {
164
+ value: q?.value,
165
+ options: Q,
166
166
  size: T,
167
167
  allowRemoveOptions: j,
168
- onChange: Z,
169
- onRemove: ae
168
+ onChange: X,
169
+ onRemove: ce
170
170
  })]
171
171
  }),
172
- !H && O && Y && /* @__PURE__ */ m(a, {
172
+ !R && O && J && /* @__PURE__ */ h(o, {
173
173
  className: "bg-slate-100 text-blue-500 dark:bg-zinc-700 dark:text-blue-400",
174
174
  prefix: "Create:",
175
175
  size: T,
176
- label: Y,
177
- value: Y,
178
- onChange: Z
176
+ label: J,
177
+ value: J,
178
+ onChange: X
179
179
  }),
180
- H && /* @__PURE__ */ m("div", {
181
- className: R.listMessage,
180
+ R && /* @__PURE__ */ h("div", {
181
+ className: z.listMessage,
182
182
  children: "Loading..."
183
183
  }),
184
- !H && $.length === 0 && /* @__PURE__ */ m("div", {
185
- className: R.listMessage,
184
+ !R && Q.length === 0 && /* @__PURE__ */ h("div", {
185
+ className: z.listMessage,
186
186
  children: "No Options"
187
187
  })
188
188
  ]
@@ -190,4 +190,4 @@ var g = [], _ = s((s) => {
190
190
  });
191
191
  });
192
192
  //#endregion
193
- export { _ as default };
193
+ export { y as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plitzi/plitzi-ui",
3
- "version": "1.6.3",
3
+ "version": "1.6.4",
4
4
  "homepage": "./",
5
5
  "license": "Apache-2.0",
6
6
  "files": [