@lindle/linoardo 1.0.12 → 1.0.14
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/index.cjs +306 -234
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +307 -235
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -354,46 +354,37 @@ var Chip = React3.forwardRef(
|
|
|
354
354
|
const appendIconClassName = resolveIconClassName2(appendIcon);
|
|
355
355
|
const closeIconClassName = resolveIconClassName2(closeIcon);
|
|
356
356
|
const filterIconClassName = filter && selected ? resolveIconClassName2(filterIcon) : void 0;
|
|
357
|
-
const handleClick =
|
|
358
|
-
(
|
|
359
|
-
|
|
360
|
-
event.preventDefault();
|
|
361
|
-
event.stopPropagation();
|
|
362
|
-
return;
|
|
363
|
-
}
|
|
364
|
-
onClick?.(event);
|
|
365
|
-
},
|
|
366
|
-
[disabled, onClick]
|
|
367
|
-
);
|
|
368
|
-
const handleKeyDown = React3.useCallback(
|
|
369
|
-
(event) => {
|
|
370
|
-
onKeyDown?.(event);
|
|
371
|
-
if (event.defaultPrevented || disabled || !interactive) {
|
|
372
|
-
return;
|
|
373
|
-
}
|
|
374
|
-
if (event.key === "Enter" || event.key === " ") {
|
|
375
|
-
event.preventDefault();
|
|
376
|
-
event.currentTarget.click();
|
|
377
|
-
}
|
|
378
|
-
},
|
|
379
|
-
[disabled, interactive, onKeyDown]
|
|
380
|
-
);
|
|
381
|
-
const handleCloseClick = React3.useCallback(
|
|
382
|
-
(event) => {
|
|
357
|
+
const handleClick = (event) => {
|
|
358
|
+
if (disabled) {
|
|
359
|
+
event.preventDefault();
|
|
383
360
|
event.stopPropagation();
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
onClick?.(event);
|
|
364
|
+
};
|
|
365
|
+
const handleKeyDown = (event) => {
|
|
366
|
+
onKeyDown?.(event);
|
|
367
|
+
if (event.defaultPrevented || disabled || !interactive) {
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
371
|
+
event.preventDefault();
|
|
372
|
+
event.currentTarget.click();
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
const handleCloseClick = (event) => {
|
|
376
|
+
event.stopPropagation();
|
|
377
|
+
if (disabled) {
|
|
378
|
+
event.preventDefault();
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
onClose?.(event);
|
|
382
|
+
};
|
|
383
|
+
const handleCloseKeyDown = (event) => {
|
|
393
384
|
if (event.key === " " || event.key === "Enter") {
|
|
394
385
|
event.stopPropagation();
|
|
395
386
|
}
|
|
396
|
-
}
|
|
387
|
+
};
|
|
397
388
|
const renderableChildren = typeof children === "string" || typeof children === "number" ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children }) : children;
|
|
398
389
|
const filterAdornment = filter ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
399
390
|
"span",
|
|
@@ -496,20 +487,20 @@ var ListItem = React3__namespace.forwardRef((props, ref) => {
|
|
|
496
487
|
const sharp = sharpOverride ?? false;
|
|
497
488
|
const accent = accentClasses[color] ?? accentClasses.primary;
|
|
498
489
|
const shapeClass = divided || sharp ? "rounded-none" : "rounded-lg";
|
|
499
|
-
const
|
|
500
|
-
const interactive = typeof rest.onClick === "function" ||
|
|
490
|
+
const Component3 = component ?? (href ? "a" : "div");
|
|
491
|
+
const interactive = typeof rest.onClick === "function" || Component3 === "a" || Component3 === "button";
|
|
501
492
|
const resolvedRole = role ?? "listitem";
|
|
502
|
-
const resolvedTabIndex = disabled ? -1 : tabIndex ?? (interactive &&
|
|
503
|
-
const resolvedRel =
|
|
504
|
-
const resolvedTarget =
|
|
505
|
-
const resolvedHref =
|
|
506
|
-
const resolvedType =
|
|
493
|
+
const resolvedTabIndex = disabled ? -1 : tabIndex ?? (interactive && Component3 === "div" ? 0 : void 0);
|
|
494
|
+
const resolvedRel = Component3 === "a" ? rel : void 0;
|
|
495
|
+
const resolvedTarget = Component3 === "a" ? target : void 0;
|
|
496
|
+
const resolvedHref = Component3 === "a" ? href : void 0;
|
|
497
|
+
const resolvedType = Component3 === "button" ? type ?? "button" : void 0;
|
|
507
498
|
const disabledClass = disabled ? "pointer-events-none opacity-60" : "cursor-pointer";
|
|
508
499
|
const navPaddingClass = nav ? "pl-5" : void 0;
|
|
509
500
|
const insetClass = inset ? "pl-12" : void 0;
|
|
510
501
|
const activeClasses = active ? accent.bg : void 0;
|
|
511
502
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
512
|
-
|
|
503
|
+
Component3,
|
|
513
504
|
{
|
|
514
505
|
...rest,
|
|
515
506
|
ref,
|
|
@@ -732,7 +723,55 @@ var Menu = React3__namespace.forwardRef((props, ref) => {
|
|
|
732
723
|
});
|
|
733
724
|
Menu.displayName = "Menu";
|
|
734
725
|
var Menu_default = Menu;
|
|
735
|
-
var
|
|
726
|
+
var EXPANSION_PANEL_CONTEXT_PROP = "__expansionPanelContext";
|
|
727
|
+
var EXPANSION_PANEL_ITEM_MARKER = "__isExpansionPanelItem";
|
|
728
|
+
var hasMarker = (type) => {
|
|
729
|
+
if (!type || typeof type !== "function" && typeof type !== "object") {
|
|
730
|
+
return false;
|
|
731
|
+
}
|
|
732
|
+
if (type[EXPANSION_PANEL_ITEM_MARKER]) {
|
|
733
|
+
return true;
|
|
734
|
+
}
|
|
735
|
+
const innerType = type.type;
|
|
736
|
+
if (innerType && innerType !== type) {
|
|
737
|
+
return hasMarker(innerType);
|
|
738
|
+
}
|
|
739
|
+
return false;
|
|
740
|
+
};
|
|
741
|
+
var traverseNode = (node, value) => {
|
|
742
|
+
if (Array.isArray(node)) {
|
|
743
|
+
let changed = false;
|
|
744
|
+
const nextArray = node.map((child) => {
|
|
745
|
+
const result = traverseNode(child, value);
|
|
746
|
+
if (result.changed) {
|
|
747
|
+
changed = true;
|
|
748
|
+
}
|
|
749
|
+
return result.node;
|
|
750
|
+
});
|
|
751
|
+
return { node: changed ? nextArray : node, changed };
|
|
752
|
+
}
|
|
753
|
+
if (node === null || node === void 0 || typeof node === "boolean" || typeof node === "string" || typeof node === "number") {
|
|
754
|
+
return { node, changed: false };
|
|
755
|
+
}
|
|
756
|
+
if (!React3.isValidElement(node)) {
|
|
757
|
+
return { node, changed: false };
|
|
758
|
+
}
|
|
759
|
+
const { node: mappedChildren, changed: childrenChanged } = traverseNode(node.props.children, value);
|
|
760
|
+
const shouldInject = hasMarker(node.type);
|
|
761
|
+
if (!shouldInject && !childrenChanged) {
|
|
762
|
+
return { node, changed: false };
|
|
763
|
+
}
|
|
764
|
+
const injectedProps = shouldInject ? { [EXPANSION_PANEL_CONTEXT_PROP]: value } : void 0;
|
|
765
|
+
const cloned = mappedChildren === void 0 ? React3.cloneElement(node, injectedProps) : React3.cloneElement(node, injectedProps, mappedChildren);
|
|
766
|
+
return { node: cloned, changed: true };
|
|
767
|
+
};
|
|
768
|
+
var injectExpansionPanelContext = (children, value) => traverseNode(children, value).node;
|
|
769
|
+
var markExpansionPanelItem = (component) => {
|
|
770
|
+
if (typeof component !== "function" && (typeof component !== "object" || component === null)) {
|
|
771
|
+
return;
|
|
772
|
+
}
|
|
773
|
+
component[EXPANSION_PANEL_ITEM_MARKER] = true;
|
|
774
|
+
};
|
|
736
775
|
var densityClasses2 = {
|
|
737
776
|
comfortable: "py-5",
|
|
738
777
|
default: "py-4",
|
|
@@ -761,136 +800,150 @@ var accentClasses2 = {
|
|
|
761
800
|
surface: { text: "text-gray-900", bg: "bg-gray-100", border: "border-gray-200" },
|
|
762
801
|
bw: { text: "text-gray-900", bg: "bg-gray-100", border: "border-gray-200" }
|
|
763
802
|
};
|
|
764
|
-
var
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
"
|
|
823
|
-
{
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
"
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
"aria-expanded": isExpanded,
|
|
843
|
-
"aria-controls": hasContent ? contentId : void 0,
|
|
844
|
-
className: tailwindMerge.twMerge(
|
|
845
|
-
"flex w-full items-center gap-4 px-4 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40",
|
|
846
|
-
densityPadding,
|
|
847
|
-
disabledClass,
|
|
848
|
-
isExpanded ? accent.bg : void 0,
|
|
849
|
-
headerClassName
|
|
850
|
-
),
|
|
851
|
-
"data-state": isExpanded ? "open" : "closed",
|
|
852
|
-
children: [
|
|
853
|
-
prepend && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex h-10 w-10 items-center justify-center text-gray-500", children: prepend }),
|
|
854
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-0.5 text-left", children: [
|
|
855
|
-
title && /* @__PURE__ */ jsxRuntime.jsx("span", { className: tailwindMerge.twMerge("truncate font-medium text-gray-900", titleClass), children: title }),
|
|
856
|
-
subtitle && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-gray-500", children: subtitle })
|
|
857
|
-
] }),
|
|
858
|
-
append && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-auto flex items-center gap-2 text-sm text-gray-500", children: append }),
|
|
859
|
-
!hideToggleIcon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: toggleWrapperClass, children: toggleIconNode })
|
|
860
|
-
]
|
|
861
|
-
}
|
|
803
|
+
var uniqueIdCounter = 0;
|
|
804
|
+
var generateId = (prefix) => `${prefix}-${++uniqueIdCounter}`;
|
|
805
|
+
var ExpansionPanelItemInner = class extends React3.Component {
|
|
806
|
+
constructor(props) {
|
|
807
|
+
super(props);
|
|
808
|
+
this.getContext = () => this.props.__expansionPanelContext ?? null;
|
|
809
|
+
this.handleToggle = () => {
|
|
810
|
+
const { disabled = false } = this.props;
|
|
811
|
+
if (disabled) {
|
|
812
|
+
return;
|
|
813
|
+
}
|
|
814
|
+
const context = this.getContext();
|
|
815
|
+
const panelValue = this.props.value ?? this.generatedValue;
|
|
816
|
+
if (context) {
|
|
817
|
+
context.toggle(panelValue, disabled);
|
|
818
|
+
return;
|
|
819
|
+
}
|
|
820
|
+
this.setState((prev) => ({ standaloneExpanded: !prev.standaloneExpanded }));
|
|
821
|
+
};
|
|
822
|
+
this.state = { standaloneExpanded: false };
|
|
823
|
+
this.generatedValue = generateId("expansion-panel-value");
|
|
824
|
+
this.headerId = generateId("expansion-panel-header");
|
|
825
|
+
this.contentId = generateId("expansion-panel-content");
|
|
826
|
+
}
|
|
827
|
+
render() {
|
|
828
|
+
const {
|
|
829
|
+
value,
|
|
830
|
+
title,
|
|
831
|
+
subtitle,
|
|
832
|
+
text,
|
|
833
|
+
prepend,
|
|
834
|
+
append,
|
|
835
|
+
expandIcon,
|
|
836
|
+
collapseIcon,
|
|
837
|
+
hideToggleIcon = false,
|
|
838
|
+
headerClassName,
|
|
839
|
+
contentClassName,
|
|
840
|
+
className,
|
|
841
|
+
disabled = false,
|
|
842
|
+
children,
|
|
843
|
+
color: colorOverride,
|
|
844
|
+
forwardedRef,
|
|
845
|
+
...rest
|
|
846
|
+
} = this.props;
|
|
847
|
+
const context = this.getContext();
|
|
848
|
+
const panelValue = value ?? this.generatedValue;
|
|
849
|
+
const density = context?.density ?? "default";
|
|
850
|
+
const color = colorOverride ?? context?.color ?? "primary";
|
|
851
|
+
const divider = context?.divider ?? true;
|
|
852
|
+
const variant = context?.variant ?? "elevated";
|
|
853
|
+
const rounded = context?.rounded ?? "lg";
|
|
854
|
+
const accent = accentClasses2[color] ?? accentClasses2.primary;
|
|
855
|
+
const isExpanded = context ? context.expandedValues.includes(panelValue) : this.state.standaloneExpanded;
|
|
856
|
+
const rootSurface = divider ? "bg-transparent border-0 shadow-none" : itemVariantClasses[variant];
|
|
857
|
+
const shapeClass = divider ? void 0 : roundedClasses[rounded] ?? roundedClasses.lg;
|
|
858
|
+
const densityPadding = densityClasses2[density] ?? densityClasses2.default;
|
|
859
|
+
const disabledClass = disabled ? "cursor-not-allowed opacity-60" : "cursor-pointer";
|
|
860
|
+
const titleClass = isExpanded ? accent.text : void 0;
|
|
861
|
+
const activeBorderClass = tailwindMerge.twMerge("border-l-2 border-transparent", isExpanded ? accent.border : void 0);
|
|
862
|
+
const defaultToggleIcon = /* @__PURE__ */ jsxRuntime.jsx("i", { className: "mdi mdi-chevron-down text-lg leading-none transition-transform duration-200", "aria-hidden": true });
|
|
863
|
+
const hasContent = Boolean(children ?? text);
|
|
864
|
+
const contentAnimationClass = isExpanded ? "pb-5 opacity-100" : "pb-0 opacity-0";
|
|
865
|
+
const toggleIconNode = hideToggleIcon ? null : isExpanded && collapseIcon ? collapseIcon : expandIcon ?? defaultToggleIcon;
|
|
866
|
+
const shouldRotateDefaultIcon = !expandIcon && !collapseIcon && !hideToggleIcon;
|
|
867
|
+
const toggleWrapperClass = tailwindMerge.twMerge(
|
|
868
|
+
"ml-3 flex h-6 w-6 items-center justify-center text-gray-500 transition-transform duration-200",
|
|
869
|
+
shouldRotateDefaultIcon && isExpanded ? "rotate-180" : void 0
|
|
870
|
+
);
|
|
871
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
872
|
+
"div",
|
|
873
|
+
{
|
|
874
|
+
...rest,
|
|
875
|
+
ref: forwardedRef,
|
|
876
|
+
className: tailwindMerge.twMerge(
|
|
877
|
+
"expansion-panel-item flex flex-col overflow-hidden transition-colors duration-200",
|
|
878
|
+
rootSurface,
|
|
879
|
+
shapeClass,
|
|
880
|
+
className
|
|
862
881
|
),
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
"
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
}
|
|
882
|
+
"data-state": isExpanded ? "open" : "closed",
|
|
883
|
+
"data-disabled": disabled || void 0,
|
|
884
|
+
children: [
|
|
885
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
886
|
+
"button",
|
|
887
|
+
{
|
|
888
|
+
type: "button",
|
|
889
|
+
id: this.headerId,
|
|
890
|
+
onClick: this.handleToggle,
|
|
891
|
+
disabled,
|
|
892
|
+
"aria-expanded": isExpanded,
|
|
893
|
+
"aria-controls": hasContent ? this.contentId : void 0,
|
|
894
|
+
className: tailwindMerge.twMerge(
|
|
895
|
+
"flex w-full items-center gap-4 px-4 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40",
|
|
896
|
+
densityPadding,
|
|
897
|
+
disabledClass,
|
|
898
|
+
isExpanded ? accent.bg : void 0,
|
|
899
|
+
headerClassName
|
|
900
|
+
),
|
|
901
|
+
"data-state": isExpanded ? "open" : "closed",
|
|
902
|
+
children: [
|
|
903
|
+
prepend && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex h-10 w-10 items-center justify-center text-gray-500", children: prepend }),
|
|
904
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-0.5 text-left", children: [
|
|
905
|
+
title && /* @__PURE__ */ jsxRuntime.jsx("span", { className: tailwindMerge.twMerge("truncate font-medium text-gray-900", titleClass), children: title }),
|
|
906
|
+
subtitle && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-gray-500", children: subtitle })
|
|
907
|
+
] }),
|
|
908
|
+
append && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-auto flex items-center gap-2 text-sm text-gray-500", children: append }),
|
|
909
|
+
!hideToggleIcon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: toggleWrapperClass, children: toggleIconNode })
|
|
910
|
+
]
|
|
911
|
+
}
|
|
912
|
+
),
|
|
913
|
+
hasContent && /* @__PURE__ */ jsxRuntime.jsx(
|
|
914
|
+
"div",
|
|
915
|
+
{
|
|
916
|
+
className: "grid overflow-hidden border-t border-gray-100 transition-all duration-200 ease-in-out",
|
|
917
|
+
style: { gridTemplateRows: isExpanded ? "1fr" : "0fr" },
|
|
918
|
+
"aria-hidden": isExpanded ? void 0 : true,
|
|
919
|
+
"data-state": isExpanded ? "open" : "closed",
|
|
920
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
921
|
+
"div",
|
|
922
|
+
{
|
|
923
|
+
id: this.contentId,
|
|
924
|
+
role: "region",
|
|
925
|
+
"aria-labelledby": this.headerId,
|
|
926
|
+
"data-state": isExpanded ? "open" : "closed",
|
|
927
|
+
className: tailwindMerge.twMerge(
|
|
928
|
+
"min-h-0 px-4 pt-0 text-sm text-gray-600 transition-all duration-200",
|
|
929
|
+
activeBorderClass,
|
|
930
|
+
contentAnimationClass,
|
|
931
|
+
isExpanded ? "pointer-events-auto" : "pointer-events-none",
|
|
932
|
+
contentClassName
|
|
933
|
+
),
|
|
934
|
+
children: children ?? text
|
|
935
|
+
}
|
|
936
|
+
)
|
|
937
|
+
}
|
|
938
|
+
)
|
|
939
|
+
]
|
|
940
|
+
}
|
|
941
|
+
);
|
|
942
|
+
}
|
|
943
|
+
};
|
|
944
|
+
var ExpansionPanelItem = React3.forwardRef((props, ref) => /* @__PURE__ */ jsxRuntime.jsx(ExpansionPanelItemInner, { ...props, forwardedRef: ref }));
|
|
893
945
|
ExpansionPanelItem.displayName = "ExpansionPanelItem";
|
|
946
|
+
markExpansionPanelItem(ExpansionPanelItem);
|
|
894
947
|
var ExpansionPanelItem_default = ExpansionPanelItem;
|
|
895
948
|
var variantContainerClasses = {
|
|
896
949
|
elevated: "bg-white border border-gray-200 shadow-lg shadow-gray-900/10",
|
|
@@ -917,80 +970,99 @@ var normalizeValues = (value, allowMultiple) => {
|
|
|
917
970
|
return normalized.length ? [normalized[0]] : [];
|
|
918
971
|
};
|
|
919
972
|
var clampValues = (values, allowMultiple) => allowMultiple ? uniqueValues(values) : values.length ? [values[0]] : [];
|
|
920
|
-
var
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
} = props;
|
|
935
|
-
const isControlled = value !== void 0;
|
|
936
|
-
const controlledValues = React3.useMemo(() => {
|
|
937
|
-
if (!isControlled) {
|
|
938
|
-
return void 0;
|
|
939
|
-
}
|
|
940
|
-
return normalizeValues(value, multiple);
|
|
941
|
-
}, [isControlled, value, multiple]);
|
|
942
|
-
const [internalValues, setInternalValues] = React3.useState(
|
|
943
|
-
() => normalizeValues(defaultValue, multiple)
|
|
944
|
-
);
|
|
945
|
-
const expandedValues = controlledValues ?? internalValues;
|
|
946
|
-
React3.useEffect(() => {
|
|
947
|
-
if (!isControlled) {
|
|
948
|
-
setInternalValues((prev) => clampValues(prev, multiple));
|
|
949
|
-
}
|
|
950
|
-
}, [multiple, isControlled]);
|
|
951
|
-
const handleValueChange = React3.useCallback(
|
|
952
|
-
(next) => {
|
|
973
|
+
var ExpansionPanelInner = class extends React3.Component {
|
|
974
|
+
constructor(props) {
|
|
975
|
+
super(props);
|
|
976
|
+
this.isControlled = () => this.props.value !== void 0;
|
|
977
|
+
this.getExpandedValues = (allowMultiple = this.props.multiple ?? false) => {
|
|
978
|
+
if (this.isControlled()) {
|
|
979
|
+
return normalizeValues(this.props.value, allowMultiple);
|
|
980
|
+
}
|
|
981
|
+
return this.state.internalValues;
|
|
982
|
+
};
|
|
983
|
+
this.handleValueChange = (next) => {
|
|
984
|
+
const { onChange } = this.props;
|
|
985
|
+
const allowMultiple = this.props.multiple ?? false;
|
|
986
|
+
const isControlled = this.isControlled();
|
|
953
987
|
if (!isControlled) {
|
|
954
|
-
|
|
988
|
+
this.setState({ internalValues: next });
|
|
955
989
|
}
|
|
956
990
|
if (onChange) {
|
|
957
|
-
if (
|
|
991
|
+
if (allowMultiple) {
|
|
958
992
|
onChange(next);
|
|
959
993
|
} else {
|
|
960
994
|
onChange(next[0] ?? null);
|
|
961
995
|
}
|
|
962
996
|
}
|
|
963
|
-
}
|
|
964
|
-
|
|
965
|
-
);
|
|
966
|
-
const toggle = React3.useCallback(
|
|
967
|
-
(panelValue, disabled) => {
|
|
997
|
+
};
|
|
998
|
+
this.handleToggle = (panelValue, disabled) => {
|
|
968
999
|
if (disabled) {
|
|
969
1000
|
return;
|
|
970
1001
|
}
|
|
1002
|
+
const allowMultiple = this.props.multiple ?? false;
|
|
1003
|
+
const expandedValues = this.getExpandedValues(allowMultiple);
|
|
971
1004
|
const isActive = expandedValues.includes(panelValue);
|
|
972
|
-
const next =
|
|
973
|
-
handleValueChange(next);
|
|
974
|
-
}
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
)
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
className: tailwindMerge.twMerge("expansion-panel flex w-full flex-col text-gray-900", variantClass, shapeClass, layoutClass, className),
|
|
990
|
-
children
|
|
1005
|
+
const next = allowMultiple ? isActive ? expandedValues.filter((v) => v !== panelValue) : [...expandedValues, panelValue] : isActive ? [] : [panelValue];
|
|
1006
|
+
this.handleValueChange(next);
|
|
1007
|
+
};
|
|
1008
|
+
const allowMultiple = props.multiple ?? false;
|
|
1009
|
+
this.state = {
|
|
1010
|
+
internalValues: normalizeValues(props.defaultValue, allowMultiple)
|
|
1011
|
+
};
|
|
1012
|
+
}
|
|
1013
|
+
componentDidUpdate(prevProps) {
|
|
1014
|
+
const allowMultiple = this.props.multiple ?? false;
|
|
1015
|
+
const prevAllowMultiple = prevProps.multiple ?? false;
|
|
1016
|
+
const isControlled = this.isControlled();
|
|
1017
|
+
const wasControlled = prevProps.value !== void 0;
|
|
1018
|
+
if (!isControlled && (allowMultiple !== prevAllowMultiple || wasControlled !== isControlled)) {
|
|
1019
|
+
this.setState((prevState) => ({
|
|
1020
|
+
internalValues: clampValues(prevState.internalValues, allowMultiple)
|
|
1021
|
+
}));
|
|
991
1022
|
}
|
|
992
|
-
|
|
993
|
-
|
|
1023
|
+
}
|
|
1024
|
+
render() {
|
|
1025
|
+
const {
|
|
1026
|
+
variant = "elevated",
|
|
1027
|
+
rounded = "lg",
|
|
1028
|
+
density = "default",
|
|
1029
|
+
color = "primary",
|
|
1030
|
+
divider = true,
|
|
1031
|
+
multiple = false,
|
|
1032
|
+
className,
|
|
1033
|
+
children,
|
|
1034
|
+
forwardedRef,
|
|
1035
|
+
value: _value,
|
|
1036
|
+
defaultValue: _defaultValue,
|
|
1037
|
+
onChange: _onChange,
|
|
1038
|
+
...rest
|
|
1039
|
+
} = this.props;
|
|
1040
|
+
const expandedValues = this.getExpandedValues(multiple);
|
|
1041
|
+
const providerValue = {
|
|
1042
|
+
expandedValues,
|
|
1043
|
+
toggle: this.handleToggle,
|
|
1044
|
+
density,
|
|
1045
|
+
color,
|
|
1046
|
+
divider,
|
|
1047
|
+
rounded,
|
|
1048
|
+
variant
|
|
1049
|
+
};
|
|
1050
|
+
const variantClass = divider ? variantContainerClasses[variant] : "bg-transparent border border-transparent shadow-none";
|
|
1051
|
+
const shapeClass = roundedClasses2[rounded] ?? roundedClasses2.lg;
|
|
1052
|
+
const layoutClass = divider ? "divide-y divide-gray-100 overflow-hidden" : "gap-4";
|
|
1053
|
+
const enhancedChildren = injectExpansionPanelContext(children, providerValue);
|
|
1054
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1055
|
+
"div",
|
|
1056
|
+
{
|
|
1057
|
+
...rest,
|
|
1058
|
+
ref: forwardedRef,
|
|
1059
|
+
className: tailwindMerge.twMerge("expansion-panel flex w-full flex-col text-gray-900", variantClass, shapeClass, layoutClass, className),
|
|
1060
|
+
children: enhancedChildren
|
|
1061
|
+
}
|
|
1062
|
+
);
|
|
1063
|
+
}
|
|
1064
|
+
};
|
|
1065
|
+
var ExpansionPanel = React3.forwardRef((props, ref) => /* @__PURE__ */ jsxRuntime.jsx(ExpansionPanelInner, { ...props, forwardedRef: ref }));
|
|
994
1066
|
ExpansionPanel.displayName = "ExpansionPanel";
|
|
995
1067
|
var ExpansionPanel_default = ExpansionPanel;
|
|
996
1068
|
var containerBaseClasses = "fixed inset-0 z-[70] flex items-center justify-center p-4 sm:p-8 data-[state=closed]:pointer-events-none";
|