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