@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.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React3 from 'react';
|
|
2
|
-
import { forwardRef, Component, isValidElement, cloneElement } from 'react';
|
|
2
|
+
import { forwardRef, Component, useState, useRef, useEffect, useCallback, useMemo, isValidElement, cloneElement } from 'react';
|
|
3
3
|
import { twMerge } from 'tailwind-merge';
|
|
4
4
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
|
|
@@ -466,20 +466,20 @@ var ListItem = React3.forwardRef((props, ref) => {
|
|
|
466
466
|
const sharp = sharpOverride ?? false;
|
|
467
467
|
const accent = accentClasses[color] ?? accentClasses.primary;
|
|
468
468
|
const shapeClass = divided || sharp ? "rounded-none" : "rounded-lg";
|
|
469
|
-
const
|
|
470
|
-
const interactive = typeof rest.onClick === "function" ||
|
|
469
|
+
const Component2 = component ?? (href ? "a" : "div");
|
|
470
|
+
const interactive = typeof rest.onClick === "function" || Component2 === "a" || Component2 === "button";
|
|
471
471
|
const resolvedRole = role ?? "listitem";
|
|
472
|
-
const resolvedTabIndex = disabled ? -1 : tabIndex ?? (interactive &&
|
|
473
|
-
const resolvedRel =
|
|
474
|
-
const resolvedTarget =
|
|
475
|
-
const resolvedHref =
|
|
476
|
-
const resolvedType =
|
|
472
|
+
const resolvedTabIndex = disabled ? -1 : tabIndex ?? (interactive && Component2 === "div" ? 0 : void 0);
|
|
473
|
+
const resolvedRel = Component2 === "a" ? rel : void 0;
|
|
474
|
+
const resolvedTarget = Component2 === "a" ? target : void 0;
|
|
475
|
+
const resolvedHref = Component2 === "a" ? href : void 0;
|
|
476
|
+
const resolvedType = Component2 === "button" ? type ?? "button" : void 0;
|
|
477
477
|
const disabledClass = disabled ? "pointer-events-none opacity-60" : "cursor-pointer";
|
|
478
478
|
const navPaddingClass = nav ? "pl-5" : void 0;
|
|
479
479
|
const insetClass = inset ? "pl-12" : void 0;
|
|
480
480
|
const activeClasses = active ? accent.bg : void 0;
|
|
481
481
|
return /* @__PURE__ */ jsxs(
|
|
482
|
-
|
|
482
|
+
Component2,
|
|
483
483
|
{
|
|
484
484
|
...rest,
|
|
485
485
|
ref,
|
|
@@ -949,22 +949,41 @@ var normalizeValues = (value, allowMultiple) => {
|
|
|
949
949
|
return normalized.length ? [normalized[0]] : [];
|
|
950
950
|
};
|
|
951
951
|
var clampValues = (values, allowMultiple) => allowMultiple ? uniqueValues(values) : values.length ? [values[0]] : [];
|
|
952
|
-
var ExpansionPanelInner =
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
952
|
+
var ExpansionPanelInner = (props, forwardedRef) => {
|
|
953
|
+
const {
|
|
954
|
+
variant = "elevated",
|
|
955
|
+
rounded = "lg",
|
|
956
|
+
density = "default",
|
|
957
|
+
color = "primary",
|
|
958
|
+
divider = true,
|
|
959
|
+
multiple = false,
|
|
960
|
+
className,
|
|
961
|
+
children,
|
|
962
|
+
value,
|
|
963
|
+
defaultValue,
|
|
964
|
+
onChange,
|
|
965
|
+
...rest
|
|
966
|
+
} = props;
|
|
967
|
+
const allowMultiple = multiple ?? false;
|
|
968
|
+
const isControlled = value !== void 0;
|
|
969
|
+
const [internalValues, setInternalValues] = useState(
|
|
970
|
+
() => normalizeValues(defaultValue, allowMultiple)
|
|
971
|
+
);
|
|
972
|
+
const prevAllowMultipleRef = useRef(allowMultiple);
|
|
973
|
+
const prevIsControlledRef = useRef(isControlled);
|
|
974
|
+
useEffect(() => {
|
|
975
|
+
const prevAllowMultiple = prevAllowMultipleRef.current;
|
|
976
|
+
const wasControlled = prevIsControlledRef.current;
|
|
977
|
+
if (!isControlled && (allowMultiple !== prevAllowMultiple || wasControlled !== isControlled)) {
|
|
978
|
+
setInternalValues((prev) => clampValues(prev, allowMultiple));
|
|
979
|
+
}
|
|
980
|
+
prevAllowMultipleRef.current = allowMultiple;
|
|
981
|
+
prevIsControlledRef.current = isControlled;
|
|
982
|
+
}, [allowMultiple, isControlled]);
|
|
983
|
+
const handleValueChange = useCallback(
|
|
984
|
+
(next) => {
|
|
966
985
|
if (!isControlled) {
|
|
967
|
-
|
|
986
|
+
setInternalValues(next);
|
|
968
987
|
}
|
|
969
988
|
if (onChange) {
|
|
970
989
|
if (allowMultiple) {
|
|
@@ -973,75 +992,52 @@ var ExpansionPanelInner = class extends Component {
|
|
|
973
992
|
onChange(next[0] ?? null);
|
|
974
993
|
}
|
|
975
994
|
}
|
|
976
|
-
}
|
|
977
|
-
|
|
995
|
+
},
|
|
996
|
+
[allowMultiple, isControlled, onChange]
|
|
997
|
+
);
|
|
998
|
+
const handleToggle = useCallback(
|
|
999
|
+
(panelValue, disabled) => {
|
|
978
1000
|
if (disabled) {
|
|
979
1001
|
return;
|
|
980
1002
|
}
|
|
981
|
-
const
|
|
982
|
-
const
|
|
983
|
-
const
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
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
|
-
}));
|
|
1001
|
-
}
|
|
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 = {
|
|
1003
|
+
const expandedValues2 = isControlled ? normalizeValues(value, allowMultiple) : internalValues;
|
|
1004
|
+
const isActive = expandedValues2.includes(panelValue);
|
|
1005
|
+
const next = allowMultiple ? isActive ? expandedValues2.filter((v) => v !== panelValue) : [...expandedValues2, panelValue] : isActive ? [] : [panelValue];
|
|
1006
|
+
handleValueChange(next);
|
|
1007
|
+
},
|
|
1008
|
+
[allowMultiple, handleValueChange, internalValues, isControlled, value]
|
|
1009
|
+
);
|
|
1010
|
+
const expandedValues = useMemo(
|
|
1011
|
+
() => isControlled ? normalizeValues(value, allowMultiple) : internalValues,
|
|
1012
|
+
[allowMultiple, internalValues, isControlled, value]
|
|
1013
|
+
);
|
|
1014
|
+
const providerValue = useMemo(
|
|
1015
|
+
() => ({
|
|
1021
1016
|
expandedValues,
|
|
1022
|
-
toggle:
|
|
1017
|
+
toggle: handleToggle,
|
|
1023
1018
|
density,
|
|
1024
1019
|
color,
|
|
1025
1020
|
divider,
|
|
1026
1021
|
rounded,
|
|
1027
1022
|
variant
|
|
1028
|
-
}
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1023
|
+
}),
|
|
1024
|
+
[color, density, divider, expandedValues, handleToggle, rounded, variant]
|
|
1025
|
+
);
|
|
1026
|
+
const variantClass = divider ? variantContainerClasses[variant] : "bg-transparent border border-transparent shadow-none";
|
|
1027
|
+
const shapeClass = roundedClasses2[rounded] ?? roundedClasses2.lg;
|
|
1028
|
+
const layoutClass = divider ? "divide-y divide-gray-100 overflow-hidden" : "gap-4";
|
|
1029
|
+
const enhancedChildren = injectExpansionPanelContext(children, providerValue);
|
|
1030
|
+
return /* @__PURE__ */ jsx(
|
|
1031
|
+
"div",
|
|
1032
|
+
{
|
|
1033
|
+
...rest,
|
|
1034
|
+
ref: forwardedRef,
|
|
1035
|
+
className: twMerge("expansion-panel flex w-full flex-col text-gray-900", variantClass, shapeClass, layoutClass, className),
|
|
1036
|
+
children: enhancedChildren
|
|
1037
|
+
}
|
|
1038
|
+
);
|
|
1043
1039
|
};
|
|
1044
|
-
var ExpansionPanel = forwardRef(
|
|
1040
|
+
var ExpansionPanel = forwardRef(ExpansionPanelInner);
|
|
1045
1041
|
ExpansionPanel.displayName = "ExpansionPanel";
|
|
1046
1042
|
var ExpansionPanel_default = ExpansionPanel;
|
|
1047
1043
|
var containerBaseClasses = "fixed inset-0 z-[70] flex items-center justify-center p-4 sm:p-8 data-[state=closed]:pointer-events-none";
|