@lindle/linoardo 1.0.13 → 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 +131 -85
- 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 +132 -86
- package/dist/index.js.map +1 -1
- package/dist/styles.css +0 -3
- 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,
|
|
@@ -723,7 +723,55 @@ var Menu = React3__namespace.forwardRef((props, ref) => {
|
|
|
723
723
|
});
|
|
724
724
|
Menu.displayName = "Menu";
|
|
725
725
|
var Menu_default = Menu;
|
|
726
|
-
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
|
+
};
|
|
727
775
|
var densityClasses2 = {
|
|
728
776
|
comfortable: "py-5",
|
|
729
777
|
default: "py-4",
|
|
@@ -757,12 +805,13 @@ var generateId = (prefix) => `${prefix}-${++uniqueIdCounter}`;
|
|
|
757
805
|
var ExpansionPanelItemInner = class extends React3.Component {
|
|
758
806
|
constructor(props) {
|
|
759
807
|
super(props);
|
|
808
|
+
this.getContext = () => this.props.__expansionPanelContext ?? null;
|
|
760
809
|
this.handleToggle = () => {
|
|
761
810
|
const { disabled = false } = this.props;
|
|
762
811
|
if (disabled) {
|
|
763
812
|
return;
|
|
764
813
|
}
|
|
765
|
-
const context = this.
|
|
814
|
+
const context = this.getContext();
|
|
766
815
|
const panelValue = this.props.value ?? this.generatedValue;
|
|
767
816
|
if (context) {
|
|
768
817
|
context.toggle(panelValue, disabled);
|
|
@@ -795,7 +844,7 @@ var ExpansionPanelItemInner = class extends React3.Component {
|
|
|
795
844
|
forwardedRef,
|
|
796
845
|
...rest
|
|
797
846
|
} = this.props;
|
|
798
|
-
const context = this.
|
|
847
|
+
const context = this.getContext();
|
|
799
848
|
const panelValue = value ?? this.generatedValue;
|
|
800
849
|
const density = context?.density ?? "default";
|
|
801
850
|
const color = colorOverride ?? context?.color ?? "primary";
|
|
@@ -892,9 +941,9 @@ var ExpansionPanelItemInner = class extends React3.Component {
|
|
|
892
941
|
);
|
|
893
942
|
}
|
|
894
943
|
};
|
|
895
|
-
ExpansionPanelItemInner.contextType = ExpansionPanelContext;
|
|
896
944
|
var ExpansionPanelItem = React3.forwardRef((props, ref) => /* @__PURE__ */ jsxRuntime.jsx(ExpansionPanelItemInner, { ...props, forwardedRef: ref }));
|
|
897
945
|
ExpansionPanelItem.displayName = "ExpansionPanelItem";
|
|
946
|
+
markExpansionPanelItem(ExpansionPanelItem);
|
|
898
947
|
var ExpansionPanelItem_default = ExpansionPanelItem;
|
|
899
948
|
var variantContainerClasses = {
|
|
900
949
|
elevated: "bg-white border border-gray-200 shadow-lg shadow-gray-900/10",
|
|
@@ -921,22 +970,41 @@ var normalizeValues = (value, allowMultiple) => {
|
|
|
921
970
|
return normalized.length ? [normalized[0]] : [];
|
|
922
971
|
};
|
|
923
972
|
var clampValues = (values, allowMultiple) => allowMultiple ? uniqueValues(values) : values.length ? [values[0]] : [];
|
|
924
|
-
var ExpansionPanelInner =
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
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) => {
|
|
938
1006
|
if (!isControlled) {
|
|
939
|
-
|
|
1007
|
+
setInternalValues(next);
|
|
940
1008
|
}
|
|
941
1009
|
if (onChange) {
|
|
942
1010
|
if (allowMultiple) {
|
|
@@ -945,74 +1013,52 @@ var ExpansionPanelInner = class extends React3.Component {
|
|
|
945
1013
|
onChange(next[0] ?? null);
|
|
946
1014
|
}
|
|
947
1015
|
}
|
|
948
|
-
}
|
|
949
|
-
|
|
1016
|
+
},
|
|
1017
|
+
[allowMultiple, isControlled, onChange]
|
|
1018
|
+
);
|
|
1019
|
+
const handleToggle = React3.useCallback(
|
|
1020
|
+
(panelValue, disabled) => {
|
|
950
1021
|
if (disabled) {
|
|
951
1022
|
return;
|
|
952
1023
|
}
|
|
953
|
-
const
|
|
954
|
-
const
|
|
955
|
-
const
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
const prevAllowMultiple = prevProps.multiple ?? false;
|
|
967
|
-
const isControlled = this.isControlled();
|
|
968
|
-
const wasControlled = prevProps.value !== void 0;
|
|
969
|
-
if (!isControlled && (allowMultiple !== prevAllowMultiple || wasControlled !== isControlled)) {
|
|
970
|
-
this.setState((prevState) => ({
|
|
971
|
-
internalValues: clampValues(prevState.internalValues, allowMultiple)
|
|
972
|
-
}));
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
render() {
|
|
976
|
-
const {
|
|
977
|
-
variant = "elevated",
|
|
978
|
-
rounded = "lg",
|
|
979
|
-
density = "default",
|
|
980
|
-
color = "primary",
|
|
981
|
-
divider = true,
|
|
982
|
-
multiple = false,
|
|
983
|
-
className,
|
|
984
|
-
children,
|
|
985
|
-
forwardedRef,
|
|
986
|
-
value: _value,
|
|
987
|
-
defaultValue: _defaultValue,
|
|
988
|
-
onChange: _onChange,
|
|
989
|
-
...rest
|
|
990
|
-
} = this.props;
|
|
991
|
-
const expandedValues = this.getExpandedValues(multiple);
|
|
992
|
-
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
|
+
() => ({
|
|
993
1037
|
expandedValues,
|
|
994
|
-
toggle:
|
|
1038
|
+
toggle: handleToggle,
|
|
995
1039
|
density,
|
|
996
1040
|
color,
|
|
997
1041
|
divider,
|
|
998
1042
|
rounded,
|
|
999
1043
|
variant
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
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
|
+
);
|
|
1014
1060
|
};
|
|
1015
|
-
var ExpansionPanel = React3.forwardRef(
|
|
1061
|
+
var ExpansionPanel = React3.forwardRef(ExpansionPanelInner);
|
|
1016
1062
|
ExpansionPanel.displayName = "ExpansionPanel";
|
|
1017
1063
|
var ExpansionPanel_default = ExpansionPanel;
|
|
1018
1064
|
var containerBaseClasses = "fixed inset-0 z-[70] flex items-center justify-center p-4 sm:p-8 data-[state=closed]:pointer-events-none";
|