coles-solid-library 0.3.8 → 0.3.10
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.esm.js +27 -35
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -599,8 +599,15 @@ const Carousel = ({
|
|
|
599
599
|
const [internalIndex, setInternalIndex] = createSignal(startingIndex);
|
|
600
600
|
const [propIndex, other] = splitProps(props, ["currentIndex"]);
|
|
601
601
|
const [, setCarouselBodyRef] = createSignal(null);
|
|
602
|
+
// Unified read/write for controlled vs uncontrolled usage
|
|
602
603
|
const getPropIndex = () => propIndex.currentIndex ? propIndex.currentIndex[0]() : internalIndex();
|
|
603
|
-
const setPropIndex = index =>
|
|
604
|
+
const setPropIndex = index => {
|
|
605
|
+
if (propIndex.currentIndex) {
|
|
606
|
+
propIndex.currentIndex[1](index);
|
|
607
|
+
} else {
|
|
608
|
+
setInternalIndex(index);
|
|
609
|
+
}
|
|
610
|
+
};
|
|
604
611
|
const [currSlideName] = useContext(carouselTitleContext);
|
|
605
612
|
// ----- Memoized Values -----
|
|
606
613
|
const getElementsLength = createMemo(() => {
|
|
@@ -625,12 +632,8 @@ const Carousel = ({
|
|
|
625
632
|
return [theProps.children];
|
|
626
633
|
}
|
|
627
634
|
});
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
return getPropIndex();
|
|
631
|
-
}
|
|
632
|
-
return internalIndex();
|
|
633
|
-
});
|
|
635
|
+
// The active index should always come from external control if provided
|
|
636
|
+
const currentIndex = createMemo(() => getPropIndex());
|
|
634
637
|
const slideName = createMemo(() => {
|
|
635
638
|
if (Object.keys(props).includes('elements') && getElementsLength() > 0) {
|
|
636
639
|
return getElementsArray()[currentIndex()]?.name;
|
|
@@ -659,23 +662,20 @@ const Carousel = ({
|
|
|
659
662
|
});
|
|
660
663
|
// ----- Functions -----
|
|
661
664
|
const nextSlide = () => {
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
} else {
|
|
665
|
-
setInternalIndex(0);
|
|
666
|
-
}
|
|
665
|
+
const next = currentIndex() !== getElementsLength() - 1 ? currentIndex() + 1 : 0;
|
|
666
|
+
setPropIndex(next);
|
|
667
667
|
};
|
|
668
668
|
const prevSlide = () => {
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
} else {
|
|
672
|
-
setInternalIndex(getElementsLength() - 1);
|
|
673
|
-
}
|
|
669
|
+
const prev = currentIndex() !== 0 ? currentIndex() - 1 : getElementsLength() - 1;
|
|
670
|
+
setPropIndex(prev);
|
|
674
671
|
};
|
|
675
672
|
// ----- Effects -----
|
|
673
|
+
// Keep internal signal in sync when switching from uncontrolled to controlled or external changes
|
|
676
674
|
createRenderEffect(() => {
|
|
677
|
-
if (
|
|
678
|
-
|
|
675
|
+
if (!propIndex.currentIndex) return; // controlled only
|
|
676
|
+
// Mirror external index into internal for consistency (e.g., if component logic elsewhere reads internalIndex)
|
|
677
|
+
if (internalIndex() !== propIndex.currentIndex[0]()) {
|
|
678
|
+
setInternalIndex(propIndex.currentIndex[0]());
|
|
679
679
|
}
|
|
680
680
|
});
|
|
681
681
|
// ----- TSX -----
|
|
@@ -1637,31 +1637,24 @@ function Checkbox(props) {
|
|
|
1637
1637
|
const target = e.currentTarget;
|
|
1638
1638
|
const newChecked = target.checked;
|
|
1639
1639
|
if (props.checked !== undefined) {
|
|
1640
|
-
// controlled:
|
|
1641
|
-
|
|
1642
|
-
queueMicrotask(() => {
|
|
1643
|
-
target.checked = !!props.checked;
|
|
1644
|
-
});
|
|
1640
|
+
// controlled: emit change; parent should update props.checked.
|
|
1641
|
+
// After microtask (allow parent reactive update) sync DOM to current checkedState
|
|
1645
1642
|
props.onChange?.(newChecked);
|
|
1646
|
-
} else {
|
|
1647
|
-
commitValue(newChecked);
|
|
1648
|
-
}
|
|
1649
|
-
};
|
|
1650
|
-
const handleClick = e => {
|
|
1651
|
-
if (props.checked !== undefined) {
|
|
1652
|
-
e.preventDefault();
|
|
1653
|
-
const target = e.currentTarget;
|
|
1654
1643
|
queueMicrotask(() => {
|
|
1655
|
-
|
|
1644
|
+
// checkedState() reflects latest props / form context
|
|
1645
|
+
const desired = checkedState();
|
|
1646
|
+
if (target.checked !== desired) target.checked = desired;
|
|
1656
1647
|
});
|
|
1648
|
+
return;
|
|
1657
1649
|
}
|
|
1650
|
+
// uncontrolled / form-managed
|
|
1651
|
+
commitValue(newChecked);
|
|
1658
1652
|
};
|
|
1659
1653
|
return (() => {
|
|
1660
1654
|
var _el$ = _tmpl$$h(),
|
|
1661
1655
|
_el$2 = _el$.firstChild,
|
|
1662
1656
|
_el$3 = _el$2.nextSibling;
|
|
1663
1657
|
_el$2.addEventListener("change", handleChange);
|
|
1664
|
-
_el$2.$$click = handleClick;
|
|
1665
1658
|
insert(_el$, (() => {
|
|
1666
1659
|
var _c$ = createMemo(() => !!props.label);
|
|
1667
1660
|
return () => _c$() && (() => {
|
|
@@ -1700,7 +1693,6 @@ function Checkbox(props) {
|
|
|
1700
1693
|
return _el$;
|
|
1701
1694
|
})();
|
|
1702
1695
|
}
|
|
1703
|
-
delegateEvents(["click"]);
|
|
1704
1696
|
|
|
1705
1697
|
var css_248z$c = ".selectStyles-module_solid_select__placeholder__VO5-- {\n opacity: var(--text-emphasis-medium, 87%);\n transition: all 0.7s ease;\n}\n\n.selectStyles-module_solid_select__transparent__nOpvm {\n background-color: transparent;\n}\n\n.selectStyles-module_solid_select__3plh1 {\n display: inline-block;\n position: relative;\n background-color: var(--container-color, #ffffff);\n color: var(--on-container-color, #000);\n text-align: left;\n border-radius: 8px;\n width: 100%;\n margin: 0px 6px;\n}\n\n.selectStyles-module_solid_select__control__Wmmpg {\n display: flex;\n align-items: center;\n width: 100%;\n max-height: 48px;\n border-radius: 8px;\n background-color: var(--container-color, #ffffff);\n color: var(--on-container-color, #000);\n cursor: pointer;\n transition: border 0.7s ease, padding 0.7s ease;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.selectStyles-module_solid_select__control__Wmmpg:first-child {\n flex-grow: 1;\n}\n.selectStyles-module_solid_select__control__Wmmpg:last-child {\n padding: 0px 6px;\n margin: 0px;\n}\n\n.selectStyles-module_solid_select__control_no_form__Cq9Sc {\n display: flex;\n align-items: center;\n width: 100%;\n height: 48px;\n border-radius: 8px;\n width: 200px;\n margin-top: 2px;\n cursor: pointer;\n}\n.selectStyles-module_solid_select__control_no_form__Cq9Sc:first-child {\n flex-grow: 1;\n}\n.selectStyles-module_solid_select__control_no_form__Cq9Sc:last-child {\n padding: 0px 6px;\n margin: 0px;\n}\n\n.selectStyles-module_solid_select__arrow__OPCZo {\n font-size: 0.7em;\n}\n\n.selectStyles-module_solid_select__value__rNtqF {\n flex-grow: 1;\n transition: all 0.3s ease;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n display: block;\n}\n\n.selectStyles-module_multiselect-value__UUhhP {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n max-width: 100%;\n}\n\n.selectStyles-module_solid_select__dropdown__UCt-N {\n position: absolute;\n background-color: var(--surface-color, #EEEEEE);\n top: 100%;\n left: 0;\n z-index: 999999999999999;\n max-height: 200px;\n border-radius: 8px;\n overflow-x: hidden;\n overflow-y: auto;\n box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);\n transform-origin: top;\n transform: scaleY(0);\n transition: transform 0.3s ease-out, opacity 0.3s ease-out;\n opacity: 0;\n}\n\n.selectStyles-module_dropTop__IVz9p {\n transform-origin: bottom;\n}\n\n.selectStyles-module_dropBottom__cYJF0 {\n transform-origin: top;\n}\n\n.selectStyles-module_open__f8zLA {\n transform: scaleY(1);\n opacity: 1;\n}\n\n.selectStyles-module_solid_select__option__47WMY {\n padding: 8px;\n cursor: pointer;\n display: flex;\n align-items: center;\n min-height: 32px;\n background-color: var(--container-color, #ffffff);\n color: var(--on-container-color, #000);\n border-radius: 8px;\n}\n.selectStyles-module_solid_select__option__47WMY:hover {\n border: 2px inset var(--primary-color-varient, #43A047);\n}\n.selectStyles-module_solid_select__option__47WMY:has(.selectStyles-module_selected__1-CKm) {\n font-weight: bold;\n}\n\n.selectStyles-module_checkmark__UWcbd {\n display: inline-block;\n width: 1.2em;\n margin-right: 4px;\n text-align: center;\n}\n\n.selectStyles-module_option-label__bBFSW {\n width: -moz-max-content;\n width: max-content;\n height: -moz-max-content;\n height: max-content;\n}";
|
|
1706
1698
|
var styles$7 = {"solid_select__placeholder":"selectStyles-module_solid_select__placeholder__VO5--","solid_select__transparent":"selectStyles-module_solid_select__transparent__nOpvm","solid_select":"selectStyles-module_solid_select__3plh1","solid_select__control":"selectStyles-module_solid_select__control__Wmmpg","solid_select__control_no_form":"selectStyles-module_solid_select__control_no_form__Cq9Sc","solid_select__arrow":"selectStyles-module_solid_select__arrow__OPCZo","solid_select__value":"selectStyles-module_solid_select__value__rNtqF","multiselect-value":"selectStyles-module_multiselect-value__UUhhP","solid_select__dropdown":"selectStyles-module_solid_select__dropdown__UCt-N","dropTop":"selectStyles-module_dropTop__IVz9p","dropBottom":"selectStyles-module_dropBottom__cYJF0","open":"selectStyles-module_open__f8zLA","solid_select__option":"selectStyles-module_solid_select__option__47WMY","selected":"selectStyles-module_selected__1-CKm","checkmark":"selectStyles-module_checkmark__UWcbd","option-label":"selectStyles-module_option-label__bBFSW"};
|