@lindle/linoardo 1.0.13 → 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 +57 -7
- 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 +58 -8
- package/dist/index.js.map +1 -1
- package/dist/styles.css +0 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -466,6 +466,15 @@ interface ExpansionPanelMultipleProps extends ExpansionPanelSharedProps {
|
|
|
466
466
|
onChange?: (value: ExpansionPanelValue[]) => void;
|
|
467
467
|
}
|
|
468
468
|
type ExpansionPanelProps = ExpansionPanelSingleProps | ExpansionPanelMultipleProps;
|
|
469
|
+
interface ExpansionPanelContextValue {
|
|
470
|
+
expandedValues: ExpansionPanelValue[];
|
|
471
|
+
toggle: (value: ExpansionPanelValue, disabled?: boolean) => void;
|
|
472
|
+
density: ExpansionPanelDensity;
|
|
473
|
+
color: Palette;
|
|
474
|
+
divider: boolean;
|
|
475
|
+
rounded: ExpansionPanelRounded;
|
|
476
|
+
variant: ExpansionPanelVariant;
|
|
477
|
+
}
|
|
469
478
|
interface ExpansionPanelItemProps extends Omit<DivAttributes, 'title'> {
|
|
470
479
|
value?: ExpansionPanelValue;
|
|
471
480
|
title?: react.ReactNode;
|
|
@@ -480,6 +489,8 @@ interface ExpansionPanelItemProps extends Omit<DivAttributes, 'title'> {
|
|
|
480
489
|
headerClassName?: string;
|
|
481
490
|
contentClassName?: string;
|
|
482
491
|
color?: Palette;
|
|
492
|
+
/** @internal */
|
|
493
|
+
__expansionPanelContext?: ExpansionPanelContextValue | null;
|
|
483
494
|
}
|
|
484
495
|
|
|
485
496
|
declare const ExpansionPanelItem: react.ForwardRefExoticComponent<ExpansionPanelItemProps & react.RefAttributes<HTMLDivElement>>;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React3 from 'react';
|
|
2
|
-
import { forwardRef, Component } from 'react';
|
|
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
|
|
|
@@ -702,7 +702,55 @@ var Menu = React3.forwardRef((props, ref) => {
|
|
|
702
702
|
});
|
|
703
703
|
Menu.displayName = "Menu";
|
|
704
704
|
var Menu_default = Menu;
|
|
705
|
-
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
|
+
};
|
|
706
754
|
var densityClasses2 = {
|
|
707
755
|
comfortable: "py-5",
|
|
708
756
|
default: "py-4",
|
|
@@ -736,12 +784,13 @@ var generateId = (prefix) => `${prefix}-${++uniqueIdCounter}`;
|
|
|
736
784
|
var ExpansionPanelItemInner = class extends Component {
|
|
737
785
|
constructor(props) {
|
|
738
786
|
super(props);
|
|
787
|
+
this.getContext = () => this.props.__expansionPanelContext ?? null;
|
|
739
788
|
this.handleToggle = () => {
|
|
740
789
|
const { disabled = false } = this.props;
|
|
741
790
|
if (disabled) {
|
|
742
791
|
return;
|
|
743
792
|
}
|
|
744
|
-
const context = this.
|
|
793
|
+
const context = this.getContext();
|
|
745
794
|
const panelValue = this.props.value ?? this.generatedValue;
|
|
746
795
|
if (context) {
|
|
747
796
|
context.toggle(panelValue, disabled);
|
|
@@ -774,7 +823,7 @@ var ExpansionPanelItemInner = class extends Component {
|
|
|
774
823
|
forwardedRef,
|
|
775
824
|
...rest
|
|
776
825
|
} = this.props;
|
|
777
|
-
const context = this.
|
|
826
|
+
const context = this.getContext();
|
|
778
827
|
const panelValue = value ?? this.generatedValue;
|
|
779
828
|
const density = context?.density ?? "default";
|
|
780
829
|
const color = colorOverride ?? context?.color ?? "primary";
|
|
@@ -871,9 +920,9 @@ var ExpansionPanelItemInner = class extends Component {
|
|
|
871
920
|
);
|
|
872
921
|
}
|
|
873
922
|
};
|
|
874
|
-
ExpansionPanelItemInner.contextType = ExpansionPanelContext;
|
|
875
923
|
var ExpansionPanelItem = forwardRef((props, ref) => /* @__PURE__ */ jsx(ExpansionPanelItemInner, { ...props, forwardedRef: ref }));
|
|
876
924
|
ExpansionPanelItem.displayName = "ExpansionPanelItem";
|
|
925
|
+
markExpansionPanelItem(ExpansionPanelItem);
|
|
877
926
|
var ExpansionPanelItem_default = ExpansionPanelItem;
|
|
878
927
|
var variantContainerClasses = {
|
|
879
928
|
elevated: "bg-white border border-gray-200 shadow-lg shadow-gray-900/10",
|
|
@@ -980,15 +1029,16 @@ var ExpansionPanelInner = class extends Component {
|
|
|
980
1029
|
const variantClass = divider ? variantContainerClasses[variant] : "bg-transparent border border-transparent shadow-none";
|
|
981
1030
|
const shapeClass = roundedClasses2[rounded] ?? roundedClasses2.lg;
|
|
982
1031
|
const layoutClass = divider ? "divide-y divide-gray-100 overflow-hidden" : "gap-4";
|
|
983
|
-
|
|
1032
|
+
const enhancedChildren = injectExpansionPanelContext(children, providerValue);
|
|
1033
|
+
return /* @__PURE__ */ jsx(
|
|
984
1034
|
"div",
|
|
985
1035
|
{
|
|
986
1036
|
...rest,
|
|
987
1037
|
ref: forwardedRef,
|
|
988
1038
|
className: twMerge("expansion-panel flex w-full flex-col text-gray-900", variantClass, shapeClass, layoutClass, className),
|
|
989
|
-
children
|
|
1039
|
+
children: enhancedChildren
|
|
990
1040
|
}
|
|
991
|
-
)
|
|
1041
|
+
);
|
|
992
1042
|
}
|
|
993
1043
|
};
|
|
994
1044
|
var ExpansionPanel = forwardRef((props, ref) => /* @__PURE__ */ jsx(ExpansionPanelInner, { ...props, forwardedRef: ref }));
|