@lindle/linoardo 1.0.14 → 1.0.15
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 +78 -82
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +79 -83
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -487,20 +487,20 @@ var ListItem = React3__namespace.forwardRef((props, ref) => {
|
|
|
487
487
|
const sharp = sharpOverride ?? false;
|
|
488
488
|
const accent = accentClasses[color] ?? accentClasses.primary;
|
|
489
489
|
const shapeClass = divided || sharp ? "rounded-none" : "rounded-lg";
|
|
490
|
-
const
|
|
491
|
-
const interactive = typeof rest.onClick === "function" ||
|
|
490
|
+
const Component2 = component ?? (href ? "a" : "div");
|
|
491
|
+
const interactive = typeof rest.onClick === "function" || Component2 === "a" || Component2 === "button";
|
|
492
492
|
const resolvedRole = role ?? "listitem";
|
|
493
|
-
const resolvedTabIndex = disabled ? -1 : tabIndex ?? (interactive &&
|
|
494
|
-
const resolvedRel =
|
|
495
|
-
const resolvedTarget =
|
|
496
|
-
const resolvedHref =
|
|
497
|
-
const resolvedType =
|
|
493
|
+
const resolvedTabIndex = disabled ? -1 : tabIndex ?? (interactive && Component2 === "div" ? 0 : void 0);
|
|
494
|
+
const resolvedRel = Component2 === "a" ? rel : void 0;
|
|
495
|
+
const resolvedTarget = Component2 === "a" ? target : void 0;
|
|
496
|
+
const resolvedHref = Component2 === "a" ? href : void 0;
|
|
497
|
+
const resolvedType = Component2 === "button" ? type ?? "button" : void 0;
|
|
498
498
|
const disabledClass = disabled ? "pointer-events-none opacity-60" : "cursor-pointer";
|
|
499
499
|
const navPaddingClass = nav ? "pl-5" : void 0;
|
|
500
500
|
const insetClass = inset ? "pl-12" : void 0;
|
|
501
501
|
const activeClasses = active ? accent.bg : void 0;
|
|
502
502
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
503
|
-
|
|
503
|
+
Component2,
|
|
504
504
|
{
|
|
505
505
|
...rest,
|
|
506
506
|
ref,
|
|
@@ -970,22 +970,41 @@ var normalizeValues = (value, allowMultiple) => {
|
|
|
970
970
|
return normalized.length ? [normalized[0]] : [];
|
|
971
971
|
};
|
|
972
972
|
var clampValues = (values, allowMultiple) => allowMultiple ? uniqueValues(values) : values.length ? [values[0]] : [];
|
|
973
|
-
var ExpansionPanelInner =
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
973
|
+
var ExpansionPanelInner = (props, forwardedRef) => {
|
|
974
|
+
const {
|
|
975
|
+
variant = "elevated",
|
|
976
|
+
rounded = "lg",
|
|
977
|
+
density = "default",
|
|
978
|
+
color = "primary",
|
|
979
|
+
divider = true,
|
|
980
|
+
multiple = false,
|
|
981
|
+
className,
|
|
982
|
+
children,
|
|
983
|
+
value,
|
|
984
|
+
defaultValue,
|
|
985
|
+
onChange,
|
|
986
|
+
...rest
|
|
987
|
+
} = props;
|
|
988
|
+
const allowMultiple = multiple ?? false;
|
|
989
|
+
const isControlled = value !== void 0;
|
|
990
|
+
const [internalValues, setInternalValues] = React3.useState(
|
|
991
|
+
() => normalizeValues(defaultValue, allowMultiple)
|
|
992
|
+
);
|
|
993
|
+
const prevAllowMultipleRef = React3.useRef(allowMultiple);
|
|
994
|
+
const prevIsControlledRef = React3.useRef(isControlled);
|
|
995
|
+
React3.useEffect(() => {
|
|
996
|
+
const prevAllowMultiple = prevAllowMultipleRef.current;
|
|
997
|
+
const wasControlled = prevIsControlledRef.current;
|
|
998
|
+
if (!isControlled && (allowMultiple !== prevAllowMultiple || wasControlled !== isControlled)) {
|
|
999
|
+
setInternalValues((prev) => clampValues(prev, allowMultiple));
|
|
1000
|
+
}
|
|
1001
|
+
prevAllowMultipleRef.current = allowMultiple;
|
|
1002
|
+
prevIsControlledRef.current = isControlled;
|
|
1003
|
+
}, [allowMultiple, isControlled]);
|
|
1004
|
+
const handleValueChange = React3.useCallback(
|
|
1005
|
+
(next) => {
|
|
987
1006
|
if (!isControlled) {
|
|
988
|
-
|
|
1007
|
+
setInternalValues(next);
|
|
989
1008
|
}
|
|
990
1009
|
if (onChange) {
|
|
991
1010
|
if (allowMultiple) {
|
|
@@ -994,75 +1013,52 @@ var ExpansionPanelInner = class extends React3.Component {
|
|
|
994
1013
|
onChange(next[0] ?? null);
|
|
995
1014
|
}
|
|
996
1015
|
}
|
|
997
|
-
}
|
|
998
|
-
|
|
1016
|
+
},
|
|
1017
|
+
[allowMultiple, isControlled, onChange]
|
|
1018
|
+
);
|
|
1019
|
+
const handleToggle = React3.useCallback(
|
|
1020
|
+
(panelValue, disabled) => {
|
|
999
1021
|
if (disabled) {
|
|
1000
1022
|
return;
|
|
1001
1023
|
}
|
|
1002
|
-
const
|
|
1003
|
-
const
|
|
1004
|
-
const
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
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
|
-
}));
|
|
1022
|
-
}
|
|
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 = {
|
|
1024
|
+
const expandedValues2 = isControlled ? normalizeValues(value, allowMultiple) : internalValues;
|
|
1025
|
+
const isActive = expandedValues2.includes(panelValue);
|
|
1026
|
+
const next = allowMultiple ? isActive ? expandedValues2.filter((v) => v !== panelValue) : [...expandedValues2, panelValue] : isActive ? [] : [panelValue];
|
|
1027
|
+
handleValueChange(next);
|
|
1028
|
+
},
|
|
1029
|
+
[allowMultiple, handleValueChange, internalValues, isControlled, value]
|
|
1030
|
+
);
|
|
1031
|
+
const expandedValues = React3.useMemo(
|
|
1032
|
+
() => isControlled ? normalizeValues(value, allowMultiple) : internalValues,
|
|
1033
|
+
[allowMultiple, internalValues, isControlled, value]
|
|
1034
|
+
);
|
|
1035
|
+
const providerValue = React3.useMemo(
|
|
1036
|
+
() => ({
|
|
1042
1037
|
expandedValues,
|
|
1043
|
-
toggle:
|
|
1038
|
+
toggle: handleToggle,
|
|
1044
1039
|
density,
|
|
1045
1040
|
color,
|
|
1046
1041
|
divider,
|
|
1047
1042
|
rounded,
|
|
1048
1043
|
variant
|
|
1049
|
-
}
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1044
|
+
}),
|
|
1045
|
+
[color, density, divider, expandedValues, handleToggle, rounded, variant]
|
|
1046
|
+
);
|
|
1047
|
+
const variantClass = divider ? variantContainerClasses[variant] : "bg-transparent border border-transparent shadow-none";
|
|
1048
|
+
const shapeClass = roundedClasses2[rounded] ?? roundedClasses2.lg;
|
|
1049
|
+
const layoutClass = divider ? "divide-y divide-gray-100 overflow-hidden" : "gap-4";
|
|
1050
|
+
const enhancedChildren = injectExpansionPanelContext(children, providerValue);
|
|
1051
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1052
|
+
"div",
|
|
1053
|
+
{
|
|
1054
|
+
...rest,
|
|
1055
|
+
ref: forwardedRef,
|
|
1056
|
+
className: tailwindMerge.twMerge("expansion-panel flex w-full flex-col text-gray-900", variantClass, shapeClass, layoutClass, className),
|
|
1057
|
+
children: enhancedChildren
|
|
1058
|
+
}
|
|
1059
|
+
);
|
|
1064
1060
|
};
|
|
1065
|
-
var ExpansionPanel = React3.forwardRef(
|
|
1061
|
+
var ExpansionPanel = React3.forwardRef(ExpansionPanelInner);
|
|
1066
1062
|
ExpansionPanel.displayName = "ExpansionPanel";
|
|
1067
1063
|
var ExpansionPanel_default = ExpansionPanel;
|
|
1068
1064
|
var containerBaseClasses = "fixed inset-0 z-[70] flex items-center justify-center p-4 sm:p-8 data-[state=closed]:pointer-events-none";
|