analytica-frontend-lib 1.0.50 → 1.0.52
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/Radio/index.js +4 -4
- package/dist/Radio/index.js.map +1 -1
- package/dist/Radio/index.mjs +4 -4
- package/dist/Radio/index.mjs.map +1 -1
- package/dist/Select/index.d.mts +10 -3
- package/dist/Select/index.d.ts +10 -3
- package/dist/Select/index.js +72 -24
- package/dist/Select/index.js.map +1 -1
- package/dist/Select/index.mjs +75 -26
- package/dist/Select/index.mjs.map +1 -1
- package/dist/index.css +11 -4
- package/dist/index.css.map +1 -1
- package/dist/index.js +76 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +79 -30
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +11 -4
- package/dist/styles.css.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -844,7 +844,7 @@ var SIZE_CLASSES4 = {
|
|
|
844
844
|
textSize: "sm",
|
|
845
845
|
spacing: "gap-1.5",
|
|
846
846
|
borderWidth: "border-2",
|
|
847
|
-
dotSize: "w-2 h-2",
|
|
847
|
+
dotSize: "w-2.5 h-2.5",
|
|
848
848
|
labelHeight: "h-5"
|
|
849
849
|
},
|
|
850
850
|
medium: {
|
|
@@ -852,7 +852,7 @@ var SIZE_CLASSES4 = {
|
|
|
852
852
|
textSize: "md",
|
|
853
853
|
spacing: "gap-2",
|
|
854
854
|
borderWidth: "border-2",
|
|
855
|
-
dotSize: "w-
|
|
855
|
+
dotSize: "w-3 h-3",
|
|
856
856
|
labelHeight: "h-6"
|
|
857
857
|
},
|
|
858
858
|
large: {
|
|
@@ -860,7 +860,7 @@ var SIZE_CLASSES4 = {
|
|
|
860
860
|
textSize: "lg",
|
|
861
861
|
spacing: "gap-2",
|
|
862
862
|
borderWidth: "border-2",
|
|
863
|
-
dotSize: "w-3 h-3",
|
|
863
|
+
dotSize: "w-3.5 h-3.5",
|
|
864
864
|
labelHeight: "h-7"
|
|
865
865
|
},
|
|
866
866
|
extraLarge: {
|
|
@@ -868,7 +868,7 @@ var SIZE_CLASSES4 = {
|
|
|
868
868
|
textSize: "xl",
|
|
869
869
|
spacing: "gap-3",
|
|
870
870
|
borderWidth: "border-2",
|
|
871
|
-
dotSize: "w-
|
|
871
|
+
dotSize: "w-4 h-4",
|
|
872
872
|
labelHeight: "h-8"
|
|
873
873
|
}
|
|
874
874
|
};
|
|
@@ -3353,14 +3353,27 @@ var import_react12 = require("react");
|
|
|
3353
3353
|
var import_phosphor_react10 = require("phosphor-react");
|
|
3354
3354
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
3355
3355
|
var VARIANT_CLASSES4 = {
|
|
3356
|
-
outlined: "border rounded-
|
|
3356
|
+
outlined: "border rounded-lg focus:border-primary-950",
|
|
3357
3357
|
underlined: "border-b focus:border-primary-950",
|
|
3358
|
-
rounded: "border rounded-
|
|
3358
|
+
rounded: "border rounded-full focus:border-primary-950"
|
|
3359
3359
|
};
|
|
3360
3360
|
var SIZE_CLASSES11 = {
|
|
3361
3361
|
small: "text-sm",
|
|
3362
3362
|
medium: "text-md",
|
|
3363
|
-
large: "text-lg"
|
|
3363
|
+
large: "text-lg",
|
|
3364
|
+
"extra-large": "text-lg"
|
|
3365
|
+
};
|
|
3366
|
+
var HEIGHT_CLASSES = {
|
|
3367
|
+
small: "h-8",
|
|
3368
|
+
medium: "h-9",
|
|
3369
|
+
large: "h-10",
|
|
3370
|
+
"extra-large": "h-12"
|
|
3371
|
+
};
|
|
3372
|
+
var PADDING_CLASSES = {
|
|
3373
|
+
small: "px-2 py-1",
|
|
3374
|
+
medium: "px-3 py-2",
|
|
3375
|
+
large: "px-4 py-3",
|
|
3376
|
+
"extra-large": "px-5 py-4"
|
|
3364
3377
|
};
|
|
3365
3378
|
var SIDE_CLASSES2 = {
|
|
3366
3379
|
top: "bottom-full -translate-y-1",
|
|
@@ -3373,14 +3386,15 @@ var ALIGN_CLASSES2 = {
|
|
|
3373
3386
|
center: "left-1/2 -translate-x-1/2",
|
|
3374
3387
|
end: "right-0"
|
|
3375
3388
|
};
|
|
3376
|
-
function createSelectStore() {
|
|
3389
|
+
function createSelectStore(onValueChange) {
|
|
3377
3390
|
return (0, import_zustand3.create)((set) => ({
|
|
3378
3391
|
open: false,
|
|
3379
3392
|
setOpen: (open) => set({ open }),
|
|
3380
3393
|
value: "",
|
|
3381
3394
|
setValue: (value) => set({ value }),
|
|
3382
3395
|
selectedLabel: "",
|
|
3383
|
-
setSelectedLabel: (label) => set({ selectedLabel: label })
|
|
3396
|
+
setSelectedLabel: (label) => set({ selectedLabel: label }),
|
|
3397
|
+
onValueChange
|
|
3384
3398
|
}));
|
|
3385
3399
|
}
|
|
3386
3400
|
var useSelectStore = (externalStore) => {
|
|
@@ -3399,15 +3413,24 @@ function getLabelAsNode(children) {
|
|
|
3399
3413
|
if (flattened.length === 1) return flattened[0];
|
|
3400
3414
|
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children: flattened });
|
|
3401
3415
|
}
|
|
3402
|
-
var injectStore2 = (children, store) => {
|
|
3416
|
+
var injectStore2 = (children, store, size, selectId) => {
|
|
3403
3417
|
return import_react12.Children.map(children, (child) => {
|
|
3404
3418
|
if ((0, import_react12.isValidElement)(child)) {
|
|
3405
3419
|
const typedChild = child;
|
|
3406
3420
|
const newProps = {
|
|
3407
3421
|
store
|
|
3408
3422
|
};
|
|
3423
|
+
if (typedChild.type === SelectTrigger) {
|
|
3424
|
+
newProps.size = size;
|
|
3425
|
+
newProps.selectId = selectId;
|
|
3426
|
+
}
|
|
3409
3427
|
if (typedChild.props.children) {
|
|
3410
|
-
newProps.children = injectStore2(
|
|
3428
|
+
newProps.children = injectStore2(
|
|
3429
|
+
typedChild.props.children,
|
|
3430
|
+
store,
|
|
3431
|
+
size,
|
|
3432
|
+
selectId
|
|
3433
|
+
);
|
|
3411
3434
|
}
|
|
3412
3435
|
return (0, import_react12.cloneElement)(typedChild, newProps);
|
|
3413
3436
|
}
|
|
@@ -3419,16 +3442,19 @@ var Select = ({
|
|
|
3419
3442
|
defaultValue = "",
|
|
3420
3443
|
value: propValue,
|
|
3421
3444
|
onValueChange,
|
|
3422
|
-
size = "small"
|
|
3445
|
+
size = "small",
|
|
3446
|
+
label,
|
|
3447
|
+
helperText,
|
|
3448
|
+
errorMessage,
|
|
3449
|
+
id
|
|
3423
3450
|
}) => {
|
|
3424
3451
|
const storeRef = (0, import_react12.useRef)(null);
|
|
3425
|
-
storeRef.current ??= createSelectStore();
|
|
3452
|
+
storeRef.current ??= createSelectStore(onValueChange);
|
|
3426
3453
|
const store = storeRef.current;
|
|
3427
3454
|
const selectRef = (0, import_react12.useRef)(null);
|
|
3428
|
-
const { open, setOpen, setValue,
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
);
|
|
3455
|
+
const { open, setOpen, setValue, selectedLabel } = (0, import_zustand3.useStore)(store, (s) => s);
|
|
3456
|
+
const generatedId = (0, import_react12.useId)();
|
|
3457
|
+
const selectId = id ?? `select-${generatedId}`;
|
|
3432
3458
|
const findLabelForValue = (children2, targetValue) => {
|
|
3433
3459
|
let found = null;
|
|
3434
3460
|
const search = (nodes) => {
|
|
@@ -3448,8 +3474,8 @@ var Select = ({
|
|
|
3448
3474
|
};
|
|
3449
3475
|
(0, import_react12.useEffect)(() => {
|
|
3450
3476
|
if (!selectedLabel && defaultValue) {
|
|
3451
|
-
const
|
|
3452
|
-
if (
|
|
3477
|
+
const label2 = findLabelForValue(children, defaultValue);
|
|
3478
|
+
if (label2) store.setState({ selectedLabel: label2 });
|
|
3453
3479
|
}
|
|
3454
3480
|
}, [children, defaultValue, selectedLabel]);
|
|
3455
3481
|
(0, import_react12.useEffect)(() => {
|
|
@@ -3487,19 +3513,33 @@ var Select = ({
|
|
|
3487
3513
|
document.removeEventListener("keydown", handleArrowKeys);
|
|
3488
3514
|
};
|
|
3489
3515
|
}, [open]);
|
|
3490
|
-
(0, import_react12.useEffect)(() => {
|
|
3491
|
-
setValue(value);
|
|
3492
|
-
onValueChange?.(value);
|
|
3493
|
-
}, [value, onValueChange]);
|
|
3494
3516
|
(0, import_react12.useEffect)(() => {
|
|
3495
3517
|
if (propValue) {
|
|
3496
3518
|
setValue(propValue);
|
|
3497
|
-
const
|
|
3498
|
-
if (
|
|
3519
|
+
const label2 = findLabelForValue(children, propValue);
|
|
3520
|
+
if (label2) store.setState({ selectedLabel: label2 });
|
|
3499
3521
|
}
|
|
3500
3522
|
}, [propValue]);
|
|
3501
3523
|
const sizeClasses = SIZE_CLASSES11[size];
|
|
3502
|
-
return /* @__PURE__ */ (0, import_jsx_runtime24.
|
|
3524
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "w-full", children: [
|
|
3525
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3526
|
+
"label",
|
|
3527
|
+
{
|
|
3528
|
+
htmlFor: selectId,
|
|
3529
|
+
className: `block font-bold text-text-900 mb-1.5 ${sizeClasses}`,
|
|
3530
|
+
children: label
|
|
3531
|
+
}
|
|
3532
|
+
),
|
|
3533
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: `relative ${sizeClasses}`, ref: selectRef, children: injectStore2(children, store, size, selectId) }),
|
|
3534
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "mt-1.5 gap-1.5", children: [
|
|
3535
|
+
helperText && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { className: "text-sm text-text-500", children: helperText }),
|
|
3536
|
+
errorMessage && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("p", { className: "flex gap-1 items-center text-sm text-indicator-error", children: [
|
|
3537
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_phosphor_react10.WarningCircle, { size: 16 }),
|
|
3538
|
+
" ",
|
|
3539
|
+
errorMessage
|
|
3540
|
+
] })
|
|
3541
|
+
] })
|
|
3542
|
+
] });
|
|
3503
3543
|
};
|
|
3504
3544
|
var SelectValue = ({
|
|
3505
3545
|
placeholder,
|
|
@@ -3517,18 +3557,24 @@ var SelectTrigger = (0, import_react12.forwardRef)(
|
|
|
3517
3557
|
variant = "outlined",
|
|
3518
3558
|
store: externalStore,
|
|
3519
3559
|
disabled,
|
|
3560
|
+
size = "medium",
|
|
3561
|
+
selectId,
|
|
3520
3562
|
...props
|
|
3521
3563
|
}, ref) => {
|
|
3522
3564
|
const store = useSelectStore(externalStore);
|
|
3523
3565
|
const open = (0, import_zustand3.useStore)(store, (s) => s.open);
|
|
3524
3566
|
const toggleOpen = () => store.setState({ open: !open });
|
|
3525
3567
|
const variantClasses = VARIANT_CLASSES4[variant];
|
|
3568
|
+
const heightClasses = HEIGHT_CLASSES[size];
|
|
3569
|
+
const paddingClasses = PADDING_CLASSES[size];
|
|
3526
3570
|
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
3527
3571
|
"button",
|
|
3528
3572
|
{
|
|
3529
3573
|
ref,
|
|
3574
|
+
id: selectId,
|
|
3530
3575
|
className: `
|
|
3531
|
-
flex
|
|
3576
|
+
flex min-w-[220px] w-full items-center justify-between border-border-300
|
|
3577
|
+
${heightClasses} ${paddingClasses}
|
|
3532
3578
|
${invalid && `${variant == "underlined" ? "border-b-2" : "border-2"} border-indicator-error text-text-600`}
|
|
3533
3579
|
${disabled ? "cursor-not-allowed text-text-400 pointer-events-none opacity-50" : "cursor-pointer hover:bg-background-50 focus:bg-accent focus:text-accent-foreground hover:bg-accent hover:text-accent-foreground"}
|
|
3534
3580
|
${!invalid && !disabled ? "text-text-700" : ""}
|
|
@@ -3594,7 +3640,8 @@ var SelectItem = (0, import_react12.forwardRef)(
|
|
|
3594
3640
|
value: selectedValue,
|
|
3595
3641
|
setValue,
|
|
3596
3642
|
setOpen,
|
|
3597
|
-
setSelectedLabel
|
|
3643
|
+
setSelectedLabel,
|
|
3644
|
+
onValueChange
|
|
3598
3645
|
} = (0, import_zustand3.useStore)(store, (s) => s);
|
|
3599
3646
|
const handleClick = (e) => {
|
|
3600
3647
|
const labelNode = getLabelAsNode(children);
|
|
@@ -3602,6 +3649,7 @@ var SelectItem = (0, import_react12.forwardRef)(
|
|
|
3602
3649
|
setValue(value);
|
|
3603
3650
|
setSelectedLabel(labelNode);
|
|
3604
3651
|
setOpen(false);
|
|
3652
|
+
onValueChange?.(value);
|
|
3605
3653
|
}
|
|
3606
3654
|
props.onClick?.(e);
|
|
3607
3655
|
};
|