framepexls-ui-lib 0.1.8 → 0.1.10
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.
- package/dist/Badge.d.mts +3 -1
- package/dist/Badge.d.ts +3 -1
- package/dist/Badge.js +12 -2
- package/dist/Badge.mjs +12 -2
- package/dist/Button.d.mts +5 -1
- package/dist/Button.d.ts +5 -1
- package/dist/Button.js +29 -5
- package/dist/Button.mjs +29 -5
- package/dist/ComboSelect.js +0 -1
- package/dist/ComboSelect.mjs +0 -1
- package/dist/DateTimeField.js +2 -1
- package/dist/DateTimeField.mjs +2 -1
- package/dist/Input.js +3 -1
- package/dist/Input.mjs +3 -1
- package/dist/MultiComboSelect.d.mts +23 -0
- package/dist/MultiComboSelect.d.ts +23 -0
- package/dist/MultiComboSelect.js +152 -0
- package/dist/MultiComboSelect.mjs +122 -0
- package/dist/ReviewHistory.d.mts +23 -0
- package/dist/ReviewHistory.d.ts +23 -0
- package/dist/ReviewHistory.js +137 -0
- package/dist/ReviewHistory.mjs +103 -0
- package/dist/Sidebar.d.mts +35 -0
- package/dist/Sidebar.d.ts +35 -0
- package/dist/Sidebar.js +407 -0
- package/dist/Sidebar.mjs +377 -0
- package/dist/TimePopover.js +2 -2
- package/dist/TimePopover.mjs +2 -2
- package/dist/TimeRangeField.d.mts +20 -0
- package/dist/TimeRangeField.d.ts +20 -0
- package/dist/TimeRangeField.js +268 -0
- package/dist/TimeRangeField.mjs +238 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +15 -0
- package/dist/index.mjs +18 -8
- package/package.json +1 -1
package/dist/Badge.d.mts
CHANGED
|
@@ -2,8 +2,10 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
|
|
4
4
|
type Tone = "emerald" | "indigo" | "amber" | "slate" | "rose" | "sky" | "violet" | "cyan" | "teal" | "pink" | "orange" | "lime";
|
|
5
|
-
|
|
5
|
+
type Size = "sm" | "md" | "lg";
|
|
6
|
+
declare function Badge({ tone, size, children, onClick, title, className, }: {
|
|
6
7
|
tone?: Tone;
|
|
8
|
+
size?: Size;
|
|
7
9
|
children: React__default.ReactNode;
|
|
8
10
|
onClick?: (e: React__default.MouseEvent) => void;
|
|
9
11
|
title?: string;
|
package/dist/Badge.d.ts
CHANGED
|
@@ -2,8 +2,10 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
|
|
4
4
|
type Tone = "emerald" | "indigo" | "amber" | "slate" | "rose" | "sky" | "violet" | "cyan" | "teal" | "pink" | "orange" | "lime";
|
|
5
|
-
|
|
5
|
+
type Size = "sm" | "md" | "lg";
|
|
6
|
+
declare function Badge({ tone, size, children, onClick, title, className, }: {
|
|
6
7
|
tone?: Tone;
|
|
8
|
+
size?: Size;
|
|
7
9
|
children: React__default.ReactNode;
|
|
8
10
|
onClick?: (e: React__default.MouseEvent) => void;
|
|
9
11
|
title?: string;
|
package/dist/Badge.js
CHANGED
|
@@ -37,27 +37,37 @@ const tones = {
|
|
|
37
37
|
orange: "bg-orange-100 text-orange-700 ring-1 ring-orange-200",
|
|
38
38
|
lime: "bg-lime-100 text-lime-700 ring-1 ring-lime-200"
|
|
39
39
|
};
|
|
40
|
+
const sizeClasses = {
|
|
41
|
+
sm: { wrap: "px-2 py-0.5 text-[11px]", dot: "h-1.5 w-1.5", gap: "gap-1.5" },
|
|
42
|
+
md: { wrap: "px-2.5 py-1 text-xs", dot: "h-1.5 w-1.5", gap: "gap-2" },
|
|
43
|
+
lg: { wrap: "px-3 py-1.5 text-sm", dot: "h-2 w-2", gap: "gap-2" }
|
|
44
|
+
};
|
|
40
45
|
function Badge({
|
|
41
46
|
tone = "slate",
|
|
47
|
+
size = "md",
|
|
42
48
|
children,
|
|
43
49
|
onClick,
|
|
44
50
|
title,
|
|
45
51
|
className = ""
|
|
46
52
|
}) {
|
|
53
|
+
var _a;
|
|
47
54
|
const clickable = typeof onClick === "function";
|
|
55
|
+
const sz = (_a = sizeClasses[size]) != null ? _a : sizeClasses.md;
|
|
48
56
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
49
57
|
"span",
|
|
50
58
|
{
|
|
51
59
|
title,
|
|
52
60
|
onClick,
|
|
53
61
|
className: [
|
|
54
|
-
"inline-flex items-center
|
|
62
|
+
"inline-flex items-center rounded-full font-semibold truncate",
|
|
55
63
|
tones[tone],
|
|
64
|
+
sz.wrap,
|
|
65
|
+
sz.gap,
|
|
56
66
|
clickable ? "cursor-pointer hover:opacity-90 active:scale-[0.98]" : "",
|
|
57
67
|
className
|
|
58
68
|
].join(" "),
|
|
59
69
|
children: [
|
|
60
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "inline-block
|
|
70
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: ["inline-block rounded-full bg-current opacity-70", sz.dot].join(" ") }),
|
|
61
71
|
children
|
|
62
72
|
]
|
|
63
73
|
}
|
package/dist/Badge.mjs
CHANGED
|
@@ -14,27 +14,37 @@ const tones = {
|
|
|
14
14
|
orange: "bg-orange-100 text-orange-700 ring-1 ring-orange-200",
|
|
15
15
|
lime: "bg-lime-100 text-lime-700 ring-1 ring-lime-200"
|
|
16
16
|
};
|
|
17
|
+
const sizeClasses = {
|
|
18
|
+
sm: { wrap: "px-2 py-0.5 text-[11px]", dot: "h-1.5 w-1.5", gap: "gap-1.5" },
|
|
19
|
+
md: { wrap: "px-2.5 py-1 text-xs", dot: "h-1.5 w-1.5", gap: "gap-2" },
|
|
20
|
+
lg: { wrap: "px-3 py-1.5 text-sm", dot: "h-2 w-2", gap: "gap-2" }
|
|
21
|
+
};
|
|
17
22
|
function Badge({
|
|
18
23
|
tone = "slate",
|
|
24
|
+
size = "md",
|
|
19
25
|
children,
|
|
20
26
|
onClick,
|
|
21
27
|
title,
|
|
22
28
|
className = ""
|
|
23
29
|
}) {
|
|
30
|
+
var _a;
|
|
24
31
|
const clickable = typeof onClick === "function";
|
|
32
|
+
const sz = (_a = sizeClasses[size]) != null ? _a : sizeClasses.md;
|
|
25
33
|
return /* @__PURE__ */ jsxs(
|
|
26
34
|
"span",
|
|
27
35
|
{
|
|
28
36
|
title,
|
|
29
37
|
onClick,
|
|
30
38
|
className: [
|
|
31
|
-
"inline-flex items-center
|
|
39
|
+
"inline-flex items-center rounded-full font-semibold truncate",
|
|
32
40
|
tones[tone],
|
|
41
|
+
sz.wrap,
|
|
42
|
+
sz.gap,
|
|
33
43
|
clickable ? "cursor-pointer hover:opacity-90 active:scale-[0.98]" : "",
|
|
34
44
|
className
|
|
35
45
|
].join(" "),
|
|
36
46
|
children: [
|
|
37
|
-
/* @__PURE__ */ jsx("span", { className: "inline-block
|
|
47
|
+
/* @__PURE__ */ jsx("span", { className: ["inline-block rounded-full bg-current opacity-70", sz.dot].join(" ") }),
|
|
38
48
|
children
|
|
39
49
|
]
|
|
40
50
|
}
|
package/dist/Button.d.mts
CHANGED
|
@@ -11,7 +11,11 @@ type ButtonProps = {
|
|
|
11
11
|
className?: string;
|
|
12
12
|
active?: boolean;
|
|
13
13
|
inverted?: boolean;
|
|
14
|
+
iconOnly?: boolean;
|
|
15
|
+
icon?: React__default.ReactNode;
|
|
16
|
+
noPaddingX?: boolean;
|
|
17
|
+
unstyled?: boolean;
|
|
14
18
|
} & React__default.ButtonHTMLAttributes<HTMLButtonElement>;
|
|
15
|
-
declare function Button({ children, variant, size, loading, disabled, leftIcon, rightIcon, block, className, type, active, inverted, ...rest }: ButtonProps): react_jsx_runtime.JSX.Element;
|
|
19
|
+
declare function Button({ children, variant, size, loading, disabled, leftIcon, rightIcon, block, className, type, active, inverted, iconOnly, icon, noPaddingX, unstyled, ...rest }: ButtonProps): react_jsx_runtime.JSX.Element;
|
|
16
20
|
|
|
17
21
|
export { Button as default };
|
package/dist/Button.d.ts
CHANGED
|
@@ -11,7 +11,11 @@ type ButtonProps = {
|
|
|
11
11
|
className?: string;
|
|
12
12
|
active?: boolean;
|
|
13
13
|
inverted?: boolean;
|
|
14
|
+
iconOnly?: boolean;
|
|
15
|
+
icon?: React__default.ReactNode;
|
|
16
|
+
noPaddingX?: boolean;
|
|
17
|
+
unstyled?: boolean;
|
|
14
18
|
} & React__default.ButtonHTMLAttributes<HTMLButtonElement>;
|
|
15
|
-
declare function Button({ children, variant, size, loading, disabled, leftIcon, rightIcon, block, className, type, active, inverted, ...rest }: ButtonProps): react_jsx_runtime.JSX.Element;
|
|
19
|
+
declare function Button({ children, variant, size, loading, disabled, leftIcon, rightIcon, block, className, type, active, inverted, iconOnly, icon, noPaddingX, unstyled, ...rest }: ButtonProps): react_jsx_runtime.JSX.Element;
|
|
16
20
|
|
|
17
21
|
export { Button as default };
|
package/dist/Button.js
CHANGED
|
@@ -36,10 +36,27 @@ function Button({
|
|
|
36
36
|
type = "button",
|
|
37
37
|
active = false,
|
|
38
38
|
inverted = false,
|
|
39
|
+
iconOnly = false,
|
|
40
|
+
icon,
|
|
41
|
+
noPaddingX = false,
|
|
42
|
+
unstyled = false,
|
|
39
43
|
...rest
|
|
40
44
|
}) {
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
if (unstyled) {
|
|
46
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
47
|
+
"button",
|
|
48
|
+
{
|
|
49
|
+
type,
|
|
50
|
+
disabled: disabled || loading,
|
|
51
|
+
"aria-pressed": active ? true : void 0,
|
|
52
|
+
className,
|
|
53
|
+
...rest,
|
|
54
|
+
children
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
const base = "inline-flex items-center justify-center rounded-xl font-medium transition focus:outline-none focus-visible:ring-2 disabled:opacity-60 disabled:cursor-not-allowed";
|
|
59
|
+
const sizes = size === "sm" ? `h-9 ${noPaddingX ? "" : "px-3"} text-sm` : size === "lg" ? `h-11 ${noPaddingX ? "" : "px-5"} text-base` : `h-10 ${noPaddingX ? "" : "px-4"} text-sm`;
|
|
43
60
|
const variantClass = (() => {
|
|
44
61
|
switch (variant) {
|
|
45
62
|
case "primary":
|
|
@@ -55,6 +72,12 @@ function Button({
|
|
|
55
72
|
}
|
|
56
73
|
})();
|
|
57
74
|
const activeClass = active ? variant === "primary" ? "ring-2 ring-slate-300/60 dark:ring-white/20" : variant === "ghost" ? inverted ? "bg-white/15 text-white shadow-sm" : "bg-slate-100 text-slate-900 shadow-sm" : variant === "outline" ? inverted ? "bg-white/10 text-white" : "bg-slate-50" : variant === "secondary" ? inverted ? "bg-white/15 text-white" : "bg-slate-100" : "" : "";
|
|
75
|
+
const hasChildren = children !== void 0 && children !== null && children !== false;
|
|
76
|
+
const showText = hasChildren && !iconOnly;
|
|
77
|
+
const iconLeft = !loading ? leftIcon != null ? leftIcon : iconOnly ? icon != null ? icon : children : void 0 : void 0;
|
|
78
|
+
const iconRight = !loading ? rightIcon : void 0;
|
|
79
|
+
const visibleParts = [iconLeft, showText ? true : null, iconRight].filter(Boolean).length;
|
|
80
|
+
const gapClass = visibleParts > 1 ? "gap-2" : "gap-0";
|
|
58
81
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
59
82
|
"button",
|
|
60
83
|
{
|
|
@@ -66,6 +89,7 @@ function Button({
|
|
|
66
89
|
sizes,
|
|
67
90
|
variantClass,
|
|
68
91
|
activeClass,
|
|
92
|
+
gapClass,
|
|
69
93
|
block ? "w-full" : "",
|
|
70
94
|
className
|
|
71
95
|
].join(" "),
|
|
@@ -75,9 +99,9 @@ function Button({
|
|
|
75
99
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "12", cy: "12", r: "9", className: "opacity-25" }),
|
|
76
100
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M21 12a9 9 0 0 0-9-9", className: "opacity-90" })
|
|
77
101
|
] }),
|
|
78
|
-
|
|
79
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "truncate", children }),
|
|
80
|
-
|
|
102
|
+
iconLeft,
|
|
103
|
+
showText && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "truncate", children }),
|
|
104
|
+
iconRight
|
|
81
105
|
]
|
|
82
106
|
}
|
|
83
107
|
);
|
package/dist/Button.mjs
CHANGED
|
@@ -13,10 +13,27 @@ function Button({
|
|
|
13
13
|
type = "button",
|
|
14
14
|
active = false,
|
|
15
15
|
inverted = false,
|
|
16
|
+
iconOnly = false,
|
|
17
|
+
icon,
|
|
18
|
+
noPaddingX = false,
|
|
19
|
+
unstyled = false,
|
|
16
20
|
...rest
|
|
17
21
|
}) {
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
if (unstyled) {
|
|
23
|
+
return /* @__PURE__ */ jsx(
|
|
24
|
+
"button",
|
|
25
|
+
{
|
|
26
|
+
type,
|
|
27
|
+
disabled: disabled || loading,
|
|
28
|
+
"aria-pressed": active ? true : void 0,
|
|
29
|
+
className,
|
|
30
|
+
...rest,
|
|
31
|
+
children
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
const base = "inline-flex items-center justify-center rounded-xl font-medium transition focus:outline-none focus-visible:ring-2 disabled:opacity-60 disabled:cursor-not-allowed";
|
|
36
|
+
const sizes = size === "sm" ? `h-9 ${noPaddingX ? "" : "px-3"} text-sm` : size === "lg" ? `h-11 ${noPaddingX ? "" : "px-5"} text-base` : `h-10 ${noPaddingX ? "" : "px-4"} text-sm`;
|
|
20
37
|
const variantClass = (() => {
|
|
21
38
|
switch (variant) {
|
|
22
39
|
case "primary":
|
|
@@ -32,6 +49,12 @@ function Button({
|
|
|
32
49
|
}
|
|
33
50
|
})();
|
|
34
51
|
const activeClass = active ? variant === "primary" ? "ring-2 ring-slate-300/60 dark:ring-white/20" : variant === "ghost" ? inverted ? "bg-white/15 text-white shadow-sm" : "bg-slate-100 text-slate-900 shadow-sm" : variant === "outline" ? inverted ? "bg-white/10 text-white" : "bg-slate-50" : variant === "secondary" ? inverted ? "bg-white/15 text-white" : "bg-slate-100" : "" : "";
|
|
52
|
+
const hasChildren = children !== void 0 && children !== null && children !== false;
|
|
53
|
+
const showText = hasChildren && !iconOnly;
|
|
54
|
+
const iconLeft = !loading ? leftIcon != null ? leftIcon : iconOnly ? icon != null ? icon : children : void 0 : void 0;
|
|
55
|
+
const iconRight = !loading ? rightIcon : void 0;
|
|
56
|
+
const visibleParts = [iconLeft, showText ? true : null, iconRight].filter(Boolean).length;
|
|
57
|
+
const gapClass = visibleParts > 1 ? "gap-2" : "gap-0";
|
|
35
58
|
return /* @__PURE__ */ jsxs(
|
|
36
59
|
"button",
|
|
37
60
|
{
|
|
@@ -43,6 +66,7 @@ function Button({
|
|
|
43
66
|
sizes,
|
|
44
67
|
variantClass,
|
|
45
68
|
activeClass,
|
|
69
|
+
gapClass,
|
|
46
70
|
block ? "w-full" : "",
|
|
47
71
|
className
|
|
48
72
|
].join(" "),
|
|
@@ -52,9 +76,9 @@ function Button({
|
|
|
52
76
|
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "9", className: "opacity-25" }),
|
|
53
77
|
/* @__PURE__ */ jsx("path", { d: "M21 12a9 9 0 0 0-9-9", className: "opacity-90" })
|
|
54
78
|
] }),
|
|
55
|
-
|
|
56
|
-
/* @__PURE__ */ jsx("span", { className: "truncate", children }),
|
|
57
|
-
|
|
79
|
+
iconLeft,
|
|
80
|
+
showText && /* @__PURE__ */ jsx("span", { className: "truncate", children }),
|
|
81
|
+
iconRight
|
|
58
82
|
]
|
|
59
83
|
}
|
|
60
84
|
);
|
package/dist/ComboSelect.js
CHANGED
package/dist/ComboSelect.mjs
CHANGED
package/dist/DateTimeField.js
CHANGED
|
@@ -361,11 +361,11 @@ function DateTimeField({
|
|
|
361
361
|
]
|
|
362
362
|
}
|
|
363
363
|
);
|
|
364
|
+
const isReadOnly = !htmlOnChange;
|
|
364
365
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ref: anchorRef, className: "relative", children: [
|
|
365
366
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
366
367
|
import_Input.default,
|
|
367
368
|
{
|
|
368
|
-
readOnly: true,
|
|
369
369
|
leftSlot: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CalendarIcon, {}),
|
|
370
370
|
rightSlot: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
371
371
|
"button",
|
|
@@ -386,6 +386,7 @@ function DateTimeField({
|
|
|
386
386
|
onClear: () => emit(null),
|
|
387
387
|
"aria-haspopup": "dialog",
|
|
388
388
|
"aria-expanded": open,
|
|
389
|
+
readOnly: isReadOnly,
|
|
389
390
|
...inputProps
|
|
390
391
|
}
|
|
391
392
|
),
|
package/dist/DateTimeField.mjs
CHANGED
|
@@ -328,11 +328,11 @@ function DateTimeField({
|
|
|
328
328
|
]
|
|
329
329
|
}
|
|
330
330
|
);
|
|
331
|
+
const isReadOnly = !htmlOnChange;
|
|
331
332
|
return /* @__PURE__ */ jsxs("div", { ref: anchorRef, className: "relative", children: [
|
|
332
333
|
/* @__PURE__ */ jsx(
|
|
333
334
|
Input,
|
|
334
335
|
{
|
|
335
|
-
readOnly: true,
|
|
336
336
|
leftSlot: /* @__PURE__ */ jsx(CalendarIcon, {}),
|
|
337
337
|
rightSlot: /* @__PURE__ */ jsx(
|
|
338
338
|
"button",
|
|
@@ -353,6 +353,7 @@ function DateTimeField({
|
|
|
353
353
|
onClear: () => emit(null),
|
|
354
354
|
"aria-haspopup": "dialog",
|
|
355
355
|
"aria-expanded": open,
|
|
356
|
+
readOnly: isReadOnly,
|
|
356
357
|
...inputProps
|
|
357
358
|
}
|
|
358
359
|
),
|
package/dist/Input.js
CHANGED
|
@@ -41,7 +41,8 @@ const baseControl = "w-full rounded-2xl border border-slate-200 bg-white px-3.5
|
|
|
41
41
|
const errorControl = "border-blue-300 focus:border-blue-300 focus:ring-blue-500/15";
|
|
42
42
|
const Input = import_react.default.forwardRef(
|
|
43
43
|
({ className, error, leftSlot, rightSlot, clearable, onClear, tone = "default", value, onChange, ...props }, ref) => {
|
|
44
|
-
const showClear = clearable && !!value && !props.
|
|
44
|
+
const showClear = clearable && !!value && !props.disabled;
|
|
45
|
+
const readOnly = !onChange;
|
|
45
46
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "relative content-center", children: [
|
|
46
47
|
leftSlot && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-slate-400", children: leftSlot }),
|
|
47
48
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -50,6 +51,7 @@ const Input = import_react.default.forwardRef(
|
|
|
50
51
|
ref,
|
|
51
52
|
value,
|
|
52
53
|
onChange,
|
|
54
|
+
readOnly,
|
|
53
55
|
"aria-invalid": error ? true : void 0,
|
|
54
56
|
className: cx(
|
|
55
57
|
baseControl,
|
package/dist/Input.mjs
CHANGED
|
@@ -8,7 +8,8 @@ const baseControl = "w-full rounded-2xl border border-slate-200 bg-white px-3.5
|
|
|
8
8
|
const errorControl = "border-blue-300 focus:border-blue-300 focus:ring-blue-500/15";
|
|
9
9
|
const Input = React.forwardRef(
|
|
10
10
|
({ className, error, leftSlot, rightSlot, clearable, onClear, tone = "default", value, onChange, ...props }, ref) => {
|
|
11
|
-
const showClear = clearable && !!value && !props.
|
|
11
|
+
const showClear = clearable && !!value && !props.disabled;
|
|
12
|
+
const readOnly = !onChange;
|
|
12
13
|
return /* @__PURE__ */ jsxs("div", { className: "relative content-center", children: [
|
|
13
14
|
leftSlot && /* @__PURE__ */ jsx("span", { className: "pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-slate-400", children: leftSlot }),
|
|
14
15
|
/* @__PURE__ */ jsx(
|
|
@@ -17,6 +18,7 @@ const Input = React.forwardRef(
|
|
|
17
18
|
ref,
|
|
18
19
|
value,
|
|
19
20
|
onChange,
|
|
21
|
+
readOnly,
|
|
20
22
|
"aria-invalid": error ? true : void 0,
|
|
21
23
|
className: cx(
|
|
22
24
|
baseControl,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ComboOption } from './ComboSelect.mjs';
|
|
3
|
+
import 'react';
|
|
4
|
+
|
|
5
|
+
type MultiComboOption = ComboOption & {
|
|
6
|
+
color?: string | null;
|
|
7
|
+
};
|
|
8
|
+
type MultiComboSelectProps = {
|
|
9
|
+
options: MultiComboOption[];
|
|
10
|
+
value: string[];
|
|
11
|
+
onChange: (next: string[]) => void;
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
loading?: boolean;
|
|
15
|
+
className?: string;
|
|
16
|
+
noResultsText?: string;
|
|
17
|
+
maxVisibleTags?: number;
|
|
18
|
+
enableDialog?: boolean;
|
|
19
|
+
dialogTitle?: string;
|
|
20
|
+
};
|
|
21
|
+
declare function MultiComboSelect({ options, value, onChange, placeholder, disabled, loading, className, noResultsText, maxVisibleTags, enableDialog, dialogTitle, }: MultiComboSelectProps): react_jsx_runtime.JSX.Element;
|
|
22
|
+
|
|
23
|
+
export { type MultiComboOption, type MultiComboSelectProps, MultiComboSelect as default };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ComboOption } from './ComboSelect.js';
|
|
3
|
+
import 'react';
|
|
4
|
+
|
|
5
|
+
type MultiComboOption = ComboOption & {
|
|
6
|
+
color?: string | null;
|
|
7
|
+
};
|
|
8
|
+
type MultiComboSelectProps = {
|
|
9
|
+
options: MultiComboOption[];
|
|
10
|
+
value: string[];
|
|
11
|
+
onChange: (next: string[]) => void;
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
loading?: boolean;
|
|
15
|
+
className?: string;
|
|
16
|
+
noResultsText?: string;
|
|
17
|
+
maxVisibleTags?: number;
|
|
18
|
+
enableDialog?: boolean;
|
|
19
|
+
dialogTitle?: string;
|
|
20
|
+
};
|
|
21
|
+
declare function MultiComboSelect({ options, value, onChange, placeholder, disabled, loading, className, noResultsText, maxVisibleTags, enableDialog, dialogTitle, }: MultiComboSelectProps): react_jsx_runtime.JSX.Element;
|
|
22
|
+
|
|
23
|
+
export { type MultiComboOption, type MultiComboSelectProps, MultiComboSelect as default };
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var MultiComboSelect_exports = {};
|
|
31
|
+
__export(MultiComboSelect_exports, {
|
|
32
|
+
default: () => MultiComboSelect
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(MultiComboSelect_exports);
|
|
35
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
+
var import_react = __toESM(require("react"));
|
|
37
|
+
var import_ComboSelect = __toESM(require("./ComboSelect"));
|
|
38
|
+
var import_Dialog = __toESM(require("./Dialog"));
|
|
39
|
+
var import_Badge = __toESM(require("./Badge"));
|
|
40
|
+
function MultiComboSelect({
|
|
41
|
+
options,
|
|
42
|
+
value,
|
|
43
|
+
onChange,
|
|
44
|
+
placeholder = "Selecciona\u2026",
|
|
45
|
+
disabled,
|
|
46
|
+
loading,
|
|
47
|
+
className,
|
|
48
|
+
noResultsText,
|
|
49
|
+
maxVisibleTags = 3,
|
|
50
|
+
enableDialog = true,
|
|
51
|
+
dialogTitle = "Seleccionadas"
|
|
52
|
+
}) {
|
|
53
|
+
const selectedSet = import_react.default.useMemo(() => new Set(value), [value]);
|
|
54
|
+
const [dialogOpen, setDialogOpen] = import_react.default.useState(false);
|
|
55
|
+
const toggle = import_react.default.useCallback(
|
|
56
|
+
(val) => {
|
|
57
|
+
if (val == null) return;
|
|
58
|
+
const next = new Set(selectedSet);
|
|
59
|
+
if (next.has(val)) next.delete(val);
|
|
60
|
+
else next.add(val);
|
|
61
|
+
onChange(Array.from(next));
|
|
62
|
+
},
|
|
63
|
+
[selectedSet, onChange]
|
|
64
|
+
);
|
|
65
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
66
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
67
|
+
import_ComboSelect.default,
|
|
68
|
+
{
|
|
69
|
+
options,
|
|
70
|
+
value: null,
|
|
71
|
+
onChange: (v) => toggle(v),
|
|
72
|
+
placeholder: value.length === 0 ? placeholder : "",
|
|
73
|
+
disabled,
|
|
74
|
+
loading,
|
|
75
|
+
className,
|
|
76
|
+
noResultsText,
|
|
77
|
+
closeOnSelect: false,
|
|
78
|
+
keepFocusOnSelect: true,
|
|
79
|
+
clearQueryOnSelect: false,
|
|
80
|
+
renderTags: null,
|
|
81
|
+
renderOption: (opt) => {
|
|
82
|
+
var _a;
|
|
83
|
+
const isSel = selectedSet.has(opt.value);
|
|
84
|
+
const color = (_a = opt.color) != null ? _a : void 0;
|
|
85
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center justify-between gap-3", children: [
|
|
86
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "min-w-0 flex items-center gap-3", children: [
|
|
87
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "inline-block h-2.5 w-2.5 rounded-full", style: { background: color } }),
|
|
88
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "truncate", children: opt.label })
|
|
89
|
+
] }),
|
|
90
|
+
isSel && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { viewBox: "0 0 24 24", className: "h-4 w-4", fill: "none", stroke: "currentColor", strokeWidth: 2, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m5 12 4 4L19 6" }) })
|
|
91
|
+
] });
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
),
|
|
95
|
+
value.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "mt-2 flex flex-wrap gap-1.5", children: [
|
|
96
|
+
value.slice(0, Math.max(0, maxVisibleTags)).map((v) => {
|
|
97
|
+
const opt = options.find((o) => o.value === v);
|
|
98
|
+
if (!opt) return null;
|
|
99
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Badge.default, { tone: "slate", size: "sm", onClick: () => toggle(v), title: "Quitar", children: opt.label }, v);
|
|
100
|
+
}),
|
|
101
|
+
enableDialog && value.length > maxVisibleTags && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
102
|
+
"button",
|
|
103
|
+
{
|
|
104
|
+
type: "button",
|
|
105
|
+
className: "inline-flex items-center gap-1 rounded-full border border-slate-200 bg-white px-2 py-0.5 text-xs text-slate-700 hover:bg-slate-50 active:scale-95 dark:border-white/10 dark:bg-white/10 dark:text-slate-200",
|
|
106
|
+
onClick: () => setDialogOpen(true),
|
|
107
|
+
title: "Ver todas",
|
|
108
|
+
children: [
|
|
109
|
+
"+",
|
|
110
|
+
value.length - Math.max(0, maxVisibleTags)
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
)
|
|
114
|
+
] }),
|
|
115
|
+
enableDialog && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_Dialog.default, { open: dialogOpen, onClose: () => setDialogOpen(false), size: "sm", children: [
|
|
116
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Dialog.default.Header, { title: dialogTitle, onClose: () => setDialogOpen(false) }),
|
|
117
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Dialog.default.Body, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "grid gap-2", children: [
|
|
118
|
+
value.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "text-sm text-muted", children: "Sin seleccionadas" }),
|
|
119
|
+
value.map((v) => {
|
|
120
|
+
var _a;
|
|
121
|
+
const opt = options.find((o) => o.value === v);
|
|
122
|
+
if (!opt) return null;
|
|
123
|
+
const color = (_a = opt.color) != null ? _a : void 0;
|
|
124
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center justify-between gap-3 rounded-xl border border-border bg-surface px-3 py-2 text-sm", children: [
|
|
125
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "min-w-0 flex items-center gap-2", children: [
|
|
126
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "inline-block h-2.5 w-2.5 rounded-full", style: { background: color } }),
|
|
127
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "truncate", children: opt.label })
|
|
128
|
+
] }),
|
|
129
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
130
|
+
"button",
|
|
131
|
+
{
|
|
132
|
+
type: "button",
|
|
133
|
+
className: "inline-flex h-8 items-center justify-center rounded-lg border border-slate-300/80 bg-white px-2 text-xs text-slate-700 hover:bg-slate-50 active:scale-95 dark:border-white/10 dark:bg-white/5 dark:text-slate-200 dark:hover:bg-white/10",
|
|
134
|
+
onClick: () => toggle(v),
|
|
135
|
+
children: "Quitar"
|
|
136
|
+
}
|
|
137
|
+
)
|
|
138
|
+
] }, v);
|
|
139
|
+
})
|
|
140
|
+
] }) }),
|
|
141
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Dialog.default.Footer, { align: "end", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
142
|
+
"button",
|
|
143
|
+
{
|
|
144
|
+
type: "button",
|
|
145
|
+
className: "inline-flex h-10 items-center gap-2 rounded-xl border border-slate-300/80 bg-white px-4 text-sm font-medium text-slate-700 shadow-sm hover:bg-slate-50 dark:border-white/10 dark:bg-white/5 dark:text-slate-200 dark:hover:bg-white/10",
|
|
146
|
+
onClick: () => setDialogOpen(false),
|
|
147
|
+
children: "Cerrar"
|
|
148
|
+
}
|
|
149
|
+
) })
|
|
150
|
+
] })
|
|
151
|
+
] });
|
|
152
|
+
}
|