@lindle/linoardo 1.0.12 → 1.0.13
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 +255 -233
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +256 -234
- package/dist/index.js.map +1 -1
- package/dist/styles.css +3 -0
- 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 } 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,
|
|
@@ -740,135 +731,148 @@ var accentClasses2 = {
|
|
|
740
731
|
surface: { text: "text-gray-900", bg: "bg-gray-100", border: "border-gray-200" },
|
|
741
732
|
bw: { text: "text-gray-900", bg: "bg-gray-100", border: "border-gray-200" }
|
|
742
733
|
};
|
|
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
|
-
disabled,
|
|
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
|
-
}
|
|
734
|
+
var uniqueIdCounter = 0;
|
|
735
|
+
var generateId = (prefix) => `${prefix}-${++uniqueIdCounter}`;
|
|
736
|
+
var ExpansionPanelItemInner = class extends Component {
|
|
737
|
+
constructor(props) {
|
|
738
|
+
super(props);
|
|
739
|
+
this.handleToggle = () => {
|
|
740
|
+
const { disabled = false } = this.props;
|
|
741
|
+
if (disabled) {
|
|
742
|
+
return;
|
|
743
|
+
}
|
|
744
|
+
const context = this.context;
|
|
745
|
+
const panelValue = this.props.value ?? this.generatedValue;
|
|
746
|
+
if (context) {
|
|
747
|
+
context.toggle(panelValue, disabled);
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
this.setState((prev) => ({ standaloneExpanded: !prev.standaloneExpanded }));
|
|
751
|
+
};
|
|
752
|
+
this.state = { standaloneExpanded: false };
|
|
753
|
+
this.generatedValue = generateId("expansion-panel-value");
|
|
754
|
+
this.headerId = generateId("expansion-panel-header");
|
|
755
|
+
this.contentId = generateId("expansion-panel-content");
|
|
756
|
+
}
|
|
757
|
+
render() {
|
|
758
|
+
const {
|
|
759
|
+
value,
|
|
760
|
+
title,
|
|
761
|
+
subtitle,
|
|
762
|
+
text,
|
|
763
|
+
prepend,
|
|
764
|
+
append,
|
|
765
|
+
expandIcon,
|
|
766
|
+
collapseIcon,
|
|
767
|
+
hideToggleIcon = false,
|
|
768
|
+
headerClassName,
|
|
769
|
+
contentClassName,
|
|
770
|
+
className,
|
|
771
|
+
disabled = false,
|
|
772
|
+
children,
|
|
773
|
+
color: colorOverride,
|
|
774
|
+
forwardedRef,
|
|
775
|
+
...rest
|
|
776
|
+
} = this.props;
|
|
777
|
+
const context = this.context;
|
|
778
|
+
const panelValue = value ?? this.generatedValue;
|
|
779
|
+
const density = context?.density ?? "default";
|
|
780
|
+
const color = colorOverride ?? context?.color ?? "primary";
|
|
781
|
+
const divider = context?.divider ?? true;
|
|
782
|
+
const variant = context?.variant ?? "elevated";
|
|
783
|
+
const rounded = context?.rounded ?? "lg";
|
|
784
|
+
const accent = accentClasses2[color] ?? accentClasses2.primary;
|
|
785
|
+
const isExpanded = context ? context.expandedValues.includes(panelValue) : this.state.standaloneExpanded;
|
|
786
|
+
const rootSurface = divider ? "bg-transparent border-0 shadow-none" : itemVariantClasses[variant];
|
|
787
|
+
const shapeClass = divider ? void 0 : roundedClasses[rounded] ?? roundedClasses.lg;
|
|
788
|
+
const densityPadding = densityClasses2[density] ?? densityClasses2.default;
|
|
789
|
+
const disabledClass = disabled ? "cursor-not-allowed opacity-60" : "cursor-pointer";
|
|
790
|
+
const titleClass = isExpanded ? accent.text : void 0;
|
|
791
|
+
const activeBorderClass = twMerge("border-l-2 border-transparent", isExpanded ? accent.border : void 0);
|
|
792
|
+
const defaultToggleIcon = /* @__PURE__ */ jsx("i", { className: "mdi mdi-chevron-down text-lg leading-none transition-transform duration-200", "aria-hidden": true });
|
|
793
|
+
const hasContent = Boolean(children ?? text);
|
|
794
|
+
const contentAnimationClass = isExpanded ? "pb-5 opacity-100" : "pb-0 opacity-0";
|
|
795
|
+
const toggleIconNode = hideToggleIcon ? null : isExpanded && collapseIcon ? collapseIcon : expandIcon ?? defaultToggleIcon;
|
|
796
|
+
const shouldRotateDefaultIcon = !expandIcon && !collapseIcon && !hideToggleIcon;
|
|
797
|
+
const toggleWrapperClass = twMerge(
|
|
798
|
+
"ml-3 flex h-6 w-6 items-center justify-center text-gray-500 transition-transform duration-200",
|
|
799
|
+
shouldRotateDefaultIcon && isExpanded ? "rotate-180" : void 0
|
|
800
|
+
);
|
|
801
|
+
return /* @__PURE__ */ jsxs(
|
|
802
|
+
"div",
|
|
803
|
+
{
|
|
804
|
+
...rest,
|
|
805
|
+
ref: forwardedRef,
|
|
806
|
+
className: twMerge(
|
|
807
|
+
"expansion-panel-item flex flex-col overflow-hidden transition-colors duration-200",
|
|
808
|
+
rootSurface,
|
|
809
|
+
shapeClass,
|
|
810
|
+
className
|
|
841
811
|
),
|
|
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
|
-
}
|
|
812
|
+
"data-state": isExpanded ? "open" : "closed",
|
|
813
|
+
"data-disabled": disabled || void 0,
|
|
814
|
+
children: [
|
|
815
|
+
/* @__PURE__ */ jsxs(
|
|
816
|
+
"button",
|
|
817
|
+
{
|
|
818
|
+
type: "button",
|
|
819
|
+
id: this.headerId,
|
|
820
|
+
onClick: this.handleToggle,
|
|
821
|
+
disabled,
|
|
822
|
+
"aria-expanded": isExpanded,
|
|
823
|
+
"aria-controls": hasContent ? this.contentId : void 0,
|
|
824
|
+
className: twMerge(
|
|
825
|
+
"flex w-full items-center gap-4 px-4 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40",
|
|
826
|
+
densityPadding,
|
|
827
|
+
disabledClass,
|
|
828
|
+
isExpanded ? accent.bg : void 0,
|
|
829
|
+
headerClassName
|
|
830
|
+
),
|
|
831
|
+
"data-state": isExpanded ? "open" : "closed",
|
|
832
|
+
children: [
|
|
833
|
+
prepend && /* @__PURE__ */ jsx("span", { className: "flex h-10 w-10 items-center justify-center text-gray-500", children: prepend }),
|
|
834
|
+
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-0.5 text-left", children: [
|
|
835
|
+
title && /* @__PURE__ */ jsx("span", { className: twMerge("truncate font-medium text-gray-900", titleClass), children: title }),
|
|
836
|
+
subtitle && /* @__PURE__ */ jsx("span", { className: "text-sm text-gray-500", children: subtitle })
|
|
837
|
+
] }),
|
|
838
|
+
append && /* @__PURE__ */ jsx("span", { className: "ml-auto flex items-center gap-2 text-sm text-gray-500", children: append }),
|
|
839
|
+
!hideToggleIcon && /* @__PURE__ */ jsx("span", { className: toggleWrapperClass, children: toggleIconNode })
|
|
840
|
+
]
|
|
841
|
+
}
|
|
842
|
+
),
|
|
843
|
+
hasContent && /* @__PURE__ */ jsx(
|
|
844
|
+
"div",
|
|
845
|
+
{
|
|
846
|
+
className: "grid overflow-hidden border-t border-gray-100 transition-all duration-200 ease-in-out",
|
|
847
|
+
style: { gridTemplateRows: isExpanded ? "1fr" : "0fr" },
|
|
848
|
+
"aria-hidden": isExpanded ? void 0 : true,
|
|
849
|
+
"data-state": isExpanded ? "open" : "closed",
|
|
850
|
+
children: /* @__PURE__ */ jsx(
|
|
851
|
+
"div",
|
|
852
|
+
{
|
|
853
|
+
id: this.contentId,
|
|
854
|
+
role: "region",
|
|
855
|
+
"aria-labelledby": this.headerId,
|
|
856
|
+
"data-state": isExpanded ? "open" : "closed",
|
|
857
|
+
className: twMerge(
|
|
858
|
+
"min-h-0 px-4 pt-0 text-sm text-gray-600 transition-all duration-200",
|
|
859
|
+
activeBorderClass,
|
|
860
|
+
contentAnimationClass,
|
|
861
|
+
isExpanded ? "pointer-events-auto" : "pointer-events-none",
|
|
862
|
+
contentClassName
|
|
863
|
+
),
|
|
864
|
+
children: children ?? text
|
|
865
|
+
}
|
|
866
|
+
)
|
|
867
|
+
}
|
|
868
|
+
)
|
|
869
|
+
]
|
|
870
|
+
}
|
|
871
|
+
);
|
|
872
|
+
}
|
|
873
|
+
};
|
|
874
|
+
ExpansionPanelItemInner.contextType = ExpansionPanelContext;
|
|
875
|
+
var ExpansionPanelItem = forwardRef((props, ref) => /* @__PURE__ */ jsx(ExpansionPanelItemInner, { ...props, forwardedRef: ref }));
|
|
872
876
|
ExpansionPanelItem.displayName = "ExpansionPanelItem";
|
|
873
877
|
var ExpansionPanelItem_default = ExpansionPanelItem;
|
|
874
878
|
var variantContainerClasses = {
|
|
@@ -896,80 +900,98 @@ var normalizeValues = (value, allowMultiple) => {
|
|
|
896
900
|
return normalized.length ? [normalized[0]] : [];
|
|
897
901
|
};
|
|
898
902
|
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) => {
|
|
903
|
+
var ExpansionPanelInner = class extends Component {
|
|
904
|
+
constructor(props) {
|
|
905
|
+
super(props);
|
|
906
|
+
this.isControlled = () => this.props.value !== void 0;
|
|
907
|
+
this.getExpandedValues = (allowMultiple = this.props.multiple ?? false) => {
|
|
908
|
+
if (this.isControlled()) {
|
|
909
|
+
return normalizeValues(this.props.value, allowMultiple);
|
|
910
|
+
}
|
|
911
|
+
return this.state.internalValues;
|
|
912
|
+
};
|
|
913
|
+
this.handleValueChange = (next) => {
|
|
914
|
+
const { onChange } = this.props;
|
|
915
|
+
const allowMultiple = this.props.multiple ?? false;
|
|
916
|
+
const isControlled = this.isControlled();
|
|
932
917
|
if (!isControlled) {
|
|
933
|
-
|
|
918
|
+
this.setState({ internalValues: next });
|
|
934
919
|
}
|
|
935
920
|
if (onChange) {
|
|
936
|
-
if (
|
|
921
|
+
if (allowMultiple) {
|
|
937
922
|
onChange(next);
|
|
938
923
|
} else {
|
|
939
924
|
onChange(next[0] ?? null);
|
|
940
925
|
}
|
|
941
926
|
}
|
|
942
|
-
}
|
|
943
|
-
|
|
944
|
-
);
|
|
945
|
-
const toggle = useCallback(
|
|
946
|
-
(panelValue, disabled) => {
|
|
927
|
+
};
|
|
928
|
+
this.handleToggle = (panelValue, disabled) => {
|
|
947
929
|
if (disabled) {
|
|
948
930
|
return;
|
|
949
931
|
}
|
|
932
|
+
const allowMultiple = this.props.multiple ?? false;
|
|
933
|
+
const expandedValues = this.getExpandedValues(allowMultiple);
|
|
950
934
|
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
|
|
935
|
+
const next = allowMultiple ? isActive ? expandedValues.filter((v) => v !== panelValue) : [...expandedValues, panelValue] : isActive ? [] : [panelValue];
|
|
936
|
+
this.handleValueChange(next);
|
|
937
|
+
};
|
|
938
|
+
const allowMultiple = props.multiple ?? false;
|
|
939
|
+
this.state = {
|
|
940
|
+
internalValues: normalizeValues(props.defaultValue, allowMultiple)
|
|
941
|
+
};
|
|
942
|
+
}
|
|
943
|
+
componentDidUpdate(prevProps) {
|
|
944
|
+
const allowMultiple = this.props.multiple ?? false;
|
|
945
|
+
const prevAllowMultiple = prevProps.multiple ?? false;
|
|
946
|
+
const isControlled = this.isControlled();
|
|
947
|
+
const wasControlled = prevProps.value !== void 0;
|
|
948
|
+
if (!isControlled && (allowMultiple !== prevAllowMultiple || wasControlled !== isControlled)) {
|
|
949
|
+
this.setState((prevState) => ({
|
|
950
|
+
internalValues: clampValues(prevState.internalValues, allowMultiple)
|
|
951
|
+
}));
|
|
970
952
|
}
|
|
971
|
-
|
|
972
|
-
|
|
953
|
+
}
|
|
954
|
+
render() {
|
|
955
|
+
const {
|
|
956
|
+
variant = "elevated",
|
|
957
|
+
rounded = "lg",
|
|
958
|
+
density = "default",
|
|
959
|
+
color = "primary",
|
|
960
|
+
divider = true,
|
|
961
|
+
multiple = false,
|
|
962
|
+
className,
|
|
963
|
+
children,
|
|
964
|
+
forwardedRef,
|
|
965
|
+
value: _value,
|
|
966
|
+
defaultValue: _defaultValue,
|
|
967
|
+
onChange: _onChange,
|
|
968
|
+
...rest
|
|
969
|
+
} = this.props;
|
|
970
|
+
const expandedValues = this.getExpandedValues(multiple);
|
|
971
|
+
const providerValue = {
|
|
972
|
+
expandedValues,
|
|
973
|
+
toggle: this.handleToggle,
|
|
974
|
+
density,
|
|
975
|
+
color,
|
|
976
|
+
divider,
|
|
977
|
+
rounded,
|
|
978
|
+
variant
|
|
979
|
+
};
|
|
980
|
+
const variantClass = divider ? variantContainerClasses[variant] : "bg-transparent border border-transparent shadow-none";
|
|
981
|
+
const shapeClass = roundedClasses2[rounded] ?? roundedClasses2.lg;
|
|
982
|
+
const layoutClass = divider ? "divide-y divide-gray-100 overflow-hidden" : "gap-4";
|
|
983
|
+
return /* @__PURE__ */ jsx(ExpansionPanelContext.Provider, { value: providerValue, children: /* @__PURE__ */ jsx(
|
|
984
|
+
"div",
|
|
985
|
+
{
|
|
986
|
+
...rest,
|
|
987
|
+
ref: forwardedRef,
|
|
988
|
+
className: twMerge("expansion-panel flex w-full flex-col text-gray-900", variantClass, shapeClass, layoutClass, className),
|
|
989
|
+
children
|
|
990
|
+
}
|
|
991
|
+
) });
|
|
992
|
+
}
|
|
993
|
+
};
|
|
994
|
+
var ExpansionPanel = forwardRef((props, ref) => /* @__PURE__ */ jsx(ExpansionPanelInner, { ...props, forwardedRef: ref }));
|
|
973
995
|
ExpansionPanel.displayName = "ExpansionPanel";
|
|
974
996
|
var ExpansionPanel_default = ExpansionPanel;
|
|
975
997
|
var containerBaseClasses = "fixed inset-0 z-[70] flex items-center justify-center p-4 sm:p-8 data-[state=closed]:pointer-events-none";
|