@andrilla/mado-ui 1.1.0 → 1.1.2
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/README.md +23 -1
- package/dist/client/components/index.js +347 -192
- package/dist/client.js +353 -200
- package/dist/components/index.js +347 -192
- package/dist/components/search.d.ts +46 -4
- package/dist/components/select.d.ts +17 -7
- package/dist/hooks/create-fast-context.d.ts +8 -9
- package/dist/hooks/index.js +30 -35
- package/dist/hooks/use-form-status.d.ts +8 -10
- package/dist/index.js +353 -200
- package/package.json +1 -1
package/dist/components/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { extendTailwindMerge, twJoin } from "tailwind-merge";
|
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Button as Button$1, Checkbox as Checkbox$1, Combobox, ComboboxButton, ComboboxInput, ComboboxOption, ComboboxOptions, Description, Dialog, DialogBackdrop, DialogPanel, DialogTitle, Disclosure, DisclosureButton, DisclosurePanel, Field, Fieldset as Fieldset$1, Input as Input$1, Label, Legend, Listbox, ListboxButton, ListboxOption, ListboxOptions, ListboxSelectedOption, Menu, MenuButton, MenuHeading, MenuItem, MenuItems, MenuSection, MenuSeparator, Textarea as Textarea$1 } from "@headlessui/react";
|
|
4
4
|
import * as React from "react";
|
|
5
|
-
import { Children, cloneElement, createContext, isValidElement, useContext, useEffect, useEffectEvent, useId, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
|
|
5
|
+
import { Children, cloneElement, createContext, isValidElement, useCallback, useContext, useEffect, useEffectEvent, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
6
6
|
import * as ReactDOM from "react-dom";
|
|
7
7
|
import { createPortal } from "react-dom";
|
|
8
8
|
//#region src/utils/custom-tailwind-merge.ts
|
|
@@ -6223,46 +6223,43 @@ function Input({ children, className, description, descriptionProps: { className
|
|
|
6223
6223
|
}
|
|
6224
6224
|
//#endregion
|
|
6225
6225
|
//#region src/hooks/create-fast-context.tsx
|
|
6226
|
-
function createFastContext(
|
|
6227
|
-
function useStoreData(
|
|
6228
|
-
const store = useRef(initialState)
|
|
6229
|
-
const
|
|
6230
|
-
|
|
6231
|
-
else store.current = value;
|
|
6232
|
-
subscribers.current.forEach((callback) => callback());
|
|
6233
|
-
};
|
|
6234
|
-
const subscribe = (callback) => {
|
|
6235
|
-
subscribers.current.add(callback);
|
|
6236
|
-
return () => subscribers.current.delete(callback);
|
|
6237
|
-
};
|
|
6226
|
+
function createFastContext(initialState) {
|
|
6227
|
+
function useStoreData() {
|
|
6228
|
+
const store = useRef(initialState);
|
|
6229
|
+
const get = useCallback(() => store.current, []);
|
|
6230
|
+
const subscribers = useRef(/* @__PURE__ */ new Set());
|
|
6238
6231
|
return {
|
|
6239
6232
|
get,
|
|
6240
|
-
set
|
|
6241
|
-
|
|
6233
|
+
set: useCallback((value) => {
|
|
6234
|
+
store.current = {
|
|
6235
|
+
...store.current,
|
|
6236
|
+
...value
|
|
6237
|
+
};
|
|
6238
|
+
subscribers.current.forEach((callback) => callback());
|
|
6239
|
+
}, []),
|
|
6240
|
+
subscribe: useCallback((callback) => {
|
|
6241
|
+
subscribers.current.add(callback);
|
|
6242
|
+
return () => subscribers.current.delete(callback);
|
|
6243
|
+
}, [])
|
|
6242
6244
|
};
|
|
6243
6245
|
}
|
|
6244
6246
|
const StoreContext = createContext(null);
|
|
6245
|
-
function Provider({
|
|
6247
|
+
function Provider({ children }) {
|
|
6246
6248
|
return /* @__PURE__ */ jsx(StoreContext.Provider, {
|
|
6247
|
-
value: useStoreData(
|
|
6248
|
-
|
|
6249
|
+
value: useStoreData(),
|
|
6250
|
+
children
|
|
6249
6251
|
});
|
|
6250
6252
|
}
|
|
6251
|
-
function useStore(selector
|
|
6253
|
+
function useStore(selector) {
|
|
6252
6254
|
const store = useContext(StoreContext);
|
|
6253
|
-
if (!store)
|
|
6254
|
-
|
|
6255
|
-
const noOpSet = () => console.warn("Attempting to set store value outside of Provider");
|
|
6256
|
-
return [selectedValue, noOpSet];
|
|
6257
|
-
}
|
|
6258
|
-
return [useSyncExternalStore(store.subscribe, () => selector(store.get()), () => selector(initialValue !== void 0 ? initialValue : defaultInitialState)), store.set];
|
|
6255
|
+
if (!store) throw new Error("Store not found");
|
|
6256
|
+
return [useSyncExternalStore(store.subscribe, () => selector(store.get()), () => selector(initialState)), store.set];
|
|
6259
6257
|
}
|
|
6260
6258
|
return {
|
|
6261
6259
|
Provider,
|
|
6262
6260
|
useStore
|
|
6263
6261
|
};
|
|
6264
6262
|
}
|
|
6265
|
-
const { Provider, useStore } = createFastContext("incomplete");
|
|
6266
6263
|
//#endregion
|
|
6267
6264
|
//#region src/hooks/use-mobile-device.ts
|
|
6268
6265
|
function useMobileDevice() {
|
|
@@ -6396,17 +6393,11 @@ function ModalDialog({ dialogPanelProps: { className: dialogPanelClassName, styl
|
|
|
6396
6393
|
if (!setModalControls) return;
|
|
6397
6394
|
if (progressY >= DRAG_TO_CLOSE_PROGRESS && !readyToCloseRef.current) {
|
|
6398
6395
|
readyToCloseRef.current = true;
|
|
6399
|
-
setModalControls(
|
|
6400
|
-
...prev,
|
|
6401
|
-
readyToClose: true
|
|
6402
|
-
}));
|
|
6396
|
+
setModalControls({ readyToClose: true });
|
|
6403
6397
|
}
|
|
6404
6398
|
if (progressY < DRAG_TO_CLOSE_PROGRESS && readyToCloseRef.current) {
|
|
6405
6399
|
readyToCloseRef.current = false;
|
|
6406
|
-
setModalControls(
|
|
6407
|
-
...prev,
|
|
6408
|
-
readyToClose: false
|
|
6409
|
-
}));
|
|
6400
|
+
setModalControls({ readyToClose: false });
|
|
6410
6401
|
}
|
|
6411
6402
|
},
|
|
6412
6403
|
trigger: draggableTrigger
|
|
@@ -6531,23 +6522,18 @@ function ModalClose({ as, onClick, ...props }) {
|
|
|
6531
6522
|
}
|
|
6532
6523
|
function ModalDisplay({ children, className, onClose, onOpen, place = "bottom" }) {
|
|
6533
6524
|
const [modalControls, setModalControls] = useModalControls((store) => store), isMobileDevice = useMobileDevice();
|
|
6534
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
6535
6525
|
const localDialogPanelRef = useRef(null);
|
|
6536
6526
|
const openModal = () => {
|
|
6537
|
-
|
|
6538
|
-
|
|
6539
|
-
onOpen?.();
|
|
6540
|
-
return true;
|
|
6541
|
-
});
|
|
6527
|
+
setModalControls({ isOpen: true });
|
|
6528
|
+
onOpen?.();
|
|
6542
6529
|
};
|
|
6543
6530
|
const closeFunctions = () => {
|
|
6544
6531
|
onClose?.();
|
|
6545
6532
|
modalControls?.pseudoContainerRef?.current?.remove();
|
|
6546
|
-
setModalControls?.(
|
|
6547
|
-
...previous,
|
|
6533
|
+
setModalControls?.({
|
|
6548
6534
|
pseudoContainerRef: { current: null },
|
|
6549
6535
|
readyToClose: false
|
|
6550
|
-
})
|
|
6536
|
+
});
|
|
6551
6537
|
};
|
|
6552
6538
|
const mobileAnimation = {
|
|
6553
6539
|
y: "100%",
|
|
@@ -6569,30 +6555,21 @@ function ModalDisplay({ children, className, onClose, onOpen, place = "bottom" }
|
|
|
6569
6555
|
});
|
|
6570
6556
|
};
|
|
6571
6557
|
const closeModal = () => {
|
|
6572
|
-
|
|
6573
|
-
|
|
6574
|
-
handleClose();
|
|
6575
|
-
return false;
|
|
6576
|
-
});
|
|
6558
|
+
setModalControls({ isOpen: false });
|
|
6559
|
+
handleClose();
|
|
6577
6560
|
};
|
|
6578
|
-
|
|
6579
|
-
setModalControls?.(
|
|
6580
|
-
...previous,
|
|
6581
|
-
isOpen,
|
|
6561
|
+
const onVisible = () => {
|
|
6562
|
+
setModalControls?.({
|
|
6582
6563
|
place,
|
|
6583
6564
|
className,
|
|
6584
6565
|
openModal,
|
|
6585
6566
|
closeModal,
|
|
6586
6567
|
dialogPanelRef: localDialogPanelRef
|
|
6587
|
-
})
|
|
6588
|
-
}
|
|
6589
|
-
|
|
6590
|
-
|
|
6591
|
-
|
|
6592
|
-
openModal,
|
|
6593
|
-
place,
|
|
6594
|
-
setModalControls
|
|
6595
|
-
]);
|
|
6568
|
+
});
|
|
6569
|
+
};
|
|
6570
|
+
useEffect(() => {
|
|
6571
|
+
onVisible();
|
|
6572
|
+
}, []);
|
|
6596
6573
|
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
6597
6574
|
}
|
|
6598
6575
|
function Modal(props) {
|
|
@@ -6651,6 +6628,10 @@ function ChevronUpChevronDown({ weight = "regular", ...props }) {
|
|
|
6651
6628
|
}
|
|
6652
6629
|
//#endregion
|
|
6653
6630
|
//#region src/components/select.tsx
|
|
6631
|
+
const { Provider: SelectContextProvider, useStore: useSelectContext } = createFastContext({
|
|
6632
|
+
multiple: false,
|
|
6633
|
+
selectedOptionDisplayProps: {}
|
|
6634
|
+
});
|
|
6654
6635
|
/**
|
|
6655
6636
|
* ## Select Section Title
|
|
6656
6637
|
*
|
|
@@ -6665,48 +6646,32 @@ function SelectSectionTitle({ className, ...props }) {
|
|
|
6665
6646
|
/**
|
|
6666
6647
|
* ## SelectOption
|
|
6667
6648
|
*
|
|
6668
|
-
* @prop children - This is what is displayed in the drop down menu
|
|
6669
|
-
* @prop name - This is displayed in the trigger button
|
|
6670
|
-
* @prop value - This is used for FormData
|
|
6671
|
-
|
|
6672
|
-
|
|
6649
|
+
* @prop children - This is what is displayed in the drop down menu.
|
|
6650
|
+
* @prop name - This is displayed in the trigger button.
|
|
6651
|
+
* @prop value - This is used for FormData.
|
|
6652
|
+
* @prop selectedDisplayProps - This is used to customize the display of the selected option (takes priority over selectedOptionDisplayProps).
|
|
6653
|
+
*/
|
|
6654
|
+
function SelectOption({ children, className, name, selectedDisplayProps: { children: selectedDisplayChildren, className: selectedDisplayClassName, ...selectedDisplayProps } = {}, ...props }) {
|
|
6655
|
+
const [selectContext] = useSelectContext((store) => store), { multiple, selectedOptionDisplayProps } = selectContext || {};
|
|
6656
|
+
const { children: selectedOptionDisplayChildren, className: selectedOptionDisplayClassName } = selectedOptionDisplayProps || {};
|
|
6673
6657
|
return /* @__PURE__ */ jsx(ListboxOption, {
|
|
6674
6658
|
className: "group/option contents",
|
|
6675
6659
|
...props,
|
|
6676
6660
|
children: (bag) => bag.selectedOption ? /* @__PURE__ */ jsx("span", {
|
|
6677
|
-
|
|
6678
|
-
|
|
6661
|
+
...selectedOptionDisplayProps,
|
|
6662
|
+
...selectedDisplayProps,
|
|
6663
|
+
className: twMerge(!selectedDisplayClassName && !selectedOptionDisplayClassName && multiple && `before:content-[',_'] group-first-of-type/option:before:content-['']`, selectedOptionDisplayClassName, selectedDisplayClassName),
|
|
6664
|
+
children: selectedDisplayChildren ? typeof selectedDisplayChildren === "function" ? selectedDisplayChildren(name) : selectedDisplayChildren : selectedOptionDisplayChildren ? typeof selectedOptionDisplayChildren === "function" ? selectedOptionDisplayChildren(name) : selectedOptionDisplayChildren : name
|
|
6679
6665
|
}) : /* @__PURE__ */ jsxs("div", {
|
|
6680
|
-
className: twMerge("flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1 transition-[background-color] duration-200 ease-exponential select-none [--theme-color:var(--base-theme-color)] corner-super-1.5 group-disabled/option:opacity-50 group-data-focus/option:bg-(--theme-color)/15 group-data-selected/option:
|
|
6681
|
-
children: [/* @__PURE__ */ jsx(Checkmark, { className: "
|
|
6666
|
+
className: twMerge("flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1 transition-[background-color,color] duration-200 ease-exponential select-none [--theme-color:var(--base-theme-color)] corner-super-1.5 group-disabled/option:opacity-50 group-data-focus/option:bg-(--theme-color)/15 group-data-selected/option:text-(--theme-color) dark:group-data-focus/option:bg-(--theme-color)/15", !multiple && "group-data-selected/option:cursor-default group-data-focus/option:group-data-selected/option:bg-transparent", className),
|
|
6667
|
+
children: [/* @__PURE__ */ jsx(Checkmark, { className: "size-3.5 scale-70 opacity-0 transition-[opacity,scale] duration-200 ease-exponential group-data-selected/option:scale-100 group-data-selected/option:opacity-100" }), typeof children === "function" ? children(bag) : children]
|
|
6682
6668
|
})
|
|
6683
6669
|
});
|
|
6684
6670
|
}
|
|
6685
|
-
|
|
6686
|
-
* # Select
|
|
6687
|
-
*
|
|
6688
|
-
* A customizable select component intended to work very similar to HTML's `<select>` element.
|
|
6689
|
-
*
|
|
6690
|
-
* Use the `SelectOption` component to define the options.
|
|
6691
|
-
*
|
|
6692
|
-
* Use the `SelectSectionTitle` component to define titles.
|
|
6693
|
-
*
|
|
6694
|
-
* @prop label - The label for the select component.
|
|
6695
|
-
* @prop description - The description for the select component.
|
|
6696
|
-
* @prop placeholder - The placeholder for the select component.
|
|
6697
|
-
* @prop required - Whether the select component is required.
|
|
6698
|
-
* @prop invalid - Whether the select component is invalid.
|
|
6699
|
-
* @prop multiple - Whether the select component allows multiple selections.
|
|
6700
|
-
* @prop optionsProps - The props to be passed to each SelectOption component.
|
|
6701
|
-
* @prop selectedOptionProps - The props to be passed to the selected option component.
|
|
6702
|
-
* @prop fieldProps - The props to be passed to the parent field component.
|
|
6703
|
-
* @prop labelProps - The props to be passed to the label component.
|
|
6704
|
-
* @prop descriptionProps - The props to be passed to the description component.
|
|
6705
|
-
* @prop anchor - The anchor point for the drop down menu.
|
|
6706
|
-
*/
|
|
6707
|
-
function Select({ buttonProps, children, className, description, descriptionProps: { className: descriptionClassName, ...descriptionProps } = {}, fieldProps: { className: fieldClassName, ...fieldProps } = {}, invalid, label, labelProps: { className: labelClassName, ...labelProps } = {}, onChange, optionsProps: { anchor, className: optionsClassName, transition, ...optionsProps } = {}, placeholder, required, selectedOptionProps: { ...selectedOptionProps } = {}, ...props }) {
|
|
6671
|
+
function SelectField({ buttonProps, children, className, description, descriptionProps: { className: descriptionClassName, ...descriptionProps } = {}, fieldProps: { className: fieldClassName, ...fieldProps } = {}, invalid, label, labelProps: { className: labelClassName, ...labelProps } = {}, onChange, optionsProps: { anchor, className: optionsClassName, transition, ...optionsProps } = {}, placeholder, required, selectedOptionProps, selectedOptionDisplayProps, ...props }) {
|
|
6708
6672
|
const uniqueId = useId();
|
|
6709
|
-
const multiple = props.multiple;
|
|
6673
|
+
const multiple = Boolean(props.multiple);
|
|
6674
|
+
const [, setSelectContext] = useSelectContext((store) => store);
|
|
6710
6675
|
const selectOptionList = Children.toArray(children).filter((child) => isValidElement(child) && child.props && typeof child.props === "object" && "name" in child.props && "value" in child.props && "children" in child.props);
|
|
6711
6676
|
const listboxButtonRef = useRef(null);
|
|
6712
6677
|
const [isInvalid, setIsInvalid] = useState(invalid);
|
|
@@ -6718,6 +6683,15 @@ function Select({ buttonProps, children, className, description, descriptionProp
|
|
|
6718
6683
|
};
|
|
6719
6684
|
const handleInvalid = () => setIsInvalid(true);
|
|
6720
6685
|
const refocus = () => listboxButtonRef.current?.focus();
|
|
6686
|
+
const onVisible = useEffectEvent(() => {
|
|
6687
|
+
setSelectContext?.({
|
|
6688
|
+
multiple,
|
|
6689
|
+
selectedOptionDisplayProps
|
|
6690
|
+
});
|
|
6691
|
+
});
|
|
6692
|
+
useEffect(() => {
|
|
6693
|
+
onVisible();
|
|
6694
|
+
}, []);
|
|
6721
6695
|
return /* @__PURE__ */ jsxs(Field, {
|
|
6722
6696
|
...fieldProps,
|
|
6723
6697
|
className: (bag) => twMerge("grid gap-1", typeof fieldClassName === "function" ? fieldClassName(bag) : fieldClassName),
|
|
@@ -6774,6 +6748,32 @@ function Select({ buttonProps, children, className, description, descriptionProp
|
|
|
6774
6748
|
]
|
|
6775
6749
|
});
|
|
6776
6750
|
}
|
|
6751
|
+
/**
|
|
6752
|
+
* # Select
|
|
6753
|
+
*
|
|
6754
|
+
* A customizable select component intended to work very similar to HTML's `<select>` element.
|
|
6755
|
+
*
|
|
6756
|
+
* Use the `SelectOption` component to define the options.
|
|
6757
|
+
*
|
|
6758
|
+
* Use the `SelectSectionTitle` component to define titles.
|
|
6759
|
+
*
|
|
6760
|
+
* @prop label - The label for the select component.
|
|
6761
|
+
* @prop description - The description for the select component.
|
|
6762
|
+
* @prop placeholder - The placeholder for the select component.
|
|
6763
|
+
* @prop required - Whether the select component is required.
|
|
6764
|
+
* @prop invalid - Whether the select component is invalid.
|
|
6765
|
+
* @prop multiple - Whether the select component allows multiple selections.
|
|
6766
|
+
* @prop optionsProps - The props to be passed to each SelectOption component.
|
|
6767
|
+
* @prop selectedOptionProps - The props to be passed to the selected option component.
|
|
6768
|
+
* @prop selectedOptionDisplayProps - The props to be passed to each selected option in the selected option component.
|
|
6769
|
+
* @prop fieldProps - The props to be passed to the parent field component.
|
|
6770
|
+
* @prop labelProps - The props to be passed to the label component.
|
|
6771
|
+
* @prop descriptionProps - The props to be passed to the description component.
|
|
6772
|
+
* @prop anchor - The anchor point for the drop down menu.
|
|
6773
|
+
*/
|
|
6774
|
+
function Select(props) {
|
|
6775
|
+
return /* @__PURE__ */ jsx(SelectContextProvider, { children: /* @__PURE__ */ jsx(SelectField, { ...props }) });
|
|
6776
|
+
}
|
|
6777
6777
|
//#endregion
|
|
6778
6778
|
//#region src/symbols/plus.tsx
|
|
6779
6779
|
function Plus({ weight = "regular", ...props }) {
|
|
@@ -6827,6 +6827,23 @@ function Plus({ weight = "regular", ...props }) {
|
|
|
6827
6827
|
}
|
|
6828
6828
|
//#endregion
|
|
6829
6829
|
//#region src/components/search.tsx
|
|
6830
|
+
const { Provider: SearchContextProvider, useStore: useSearchContext } = createFastContext({
|
|
6831
|
+
multiple: false,
|
|
6832
|
+
query: "",
|
|
6833
|
+
selectedOptionDisplayProps: {},
|
|
6834
|
+
selectedOptionList: []
|
|
6835
|
+
});
|
|
6836
|
+
/**
|
|
6837
|
+
* ## Search Section Title
|
|
6838
|
+
*
|
|
6839
|
+
* Displays a simple title.
|
|
6840
|
+
*/
|
|
6841
|
+
function SearchSectionTitle({ className, ...props }) {
|
|
6842
|
+
return /* @__PURE__ */ jsx("div", {
|
|
6843
|
+
className: twMerge("sticky -top-1 z-10 -mx-1 bg-inherit mask-t-from-transparent mask-t-from-0 mask-t-to-white mask-t-to-1.5 ps-2 font-bold text-neutral-500/50 backdrop-blur-[2px] backdrop-brightness-101", className),
|
|
6844
|
+
...props
|
|
6845
|
+
});
|
|
6846
|
+
}
|
|
6830
6847
|
/**
|
|
6831
6848
|
* ## SearchOption
|
|
6832
6849
|
*
|
|
@@ -6834,8 +6851,17 @@ function Plus({ weight = "regular", ...props }) {
|
|
|
6834
6851
|
* @prop name - This is used for filtering by default
|
|
6835
6852
|
* @prop value - This is used as selected value and for FormData
|
|
6836
6853
|
*/
|
|
6837
|
-
function SearchOption({ children, className, name, value, ...props }) {
|
|
6838
|
-
|
|
6854
|
+
function SearchOption({ children, className, isInDisplay, name, selectedDisplayProps: { children: selectedDisplayChildren, className: selectedDisplayClassName, ...selectedDisplayProps } = {}, value, ...props }) {
|
|
6855
|
+
const [searchContext] = useSearchContext((store) => store);
|
|
6856
|
+
const { multiple, query, selectedOptionDisplayProps } = searchContext || {};
|
|
6857
|
+
if (!((query || "").trim() === "" || name.toLowerCase().includes((query || "").toLowerCase()) || isInDisplay)) return /* @__PURE__ */ jsx(Fragment, {});
|
|
6858
|
+
const { children: selectedOptionDisplayChildren, className: selectedOptionDisplayClassName } = selectedOptionDisplayProps || {};
|
|
6859
|
+
return isInDisplay ? /* @__PURE__ */ jsx("span", {
|
|
6860
|
+
...selectedOptionDisplayProps,
|
|
6861
|
+
...selectedDisplayProps,
|
|
6862
|
+
className: twMerge(!selectedDisplayClassName && !selectedOptionDisplayClassName && multiple && `after:content-[',_'] last-of-type:after:content-['']`, selectedOptionDisplayClassName, selectedDisplayClassName),
|
|
6863
|
+
children: selectedDisplayChildren ? typeof selectedDisplayChildren === "function" ? selectedDisplayChildren(name) : selectedDisplayChildren : selectedOptionDisplayChildren ? typeof selectedOptionDisplayChildren === "function" ? selectedOptionDisplayChildren(name) : selectedOptionDisplayChildren : name
|
|
6864
|
+
}) : /* @__PURE__ */ jsx(ComboboxOption, {
|
|
6839
6865
|
className: "group/option contents",
|
|
6840
6866
|
value: {
|
|
6841
6867
|
id: value,
|
|
@@ -6843,46 +6869,130 @@ function SearchOption({ children, className, name, value, ...props }) {
|
|
|
6843
6869
|
},
|
|
6844
6870
|
...props,
|
|
6845
6871
|
children: (bag) => /* @__PURE__ */ jsxs("div", {
|
|
6846
|
-
className: twMerge("flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1 transition-[background-color] duration-200 ease-exponential select-none [--theme-color:var(--base-theme-color)] corner-super-1.5 group-disabled/option:opacity-50 group-data-focus/option:bg-(--theme-color)/15 group-data-selected/option:
|
|
6847
|
-
children: [/* @__PURE__ */ jsx(Checkmark, { className: "
|
|
6872
|
+
className: twMerge("flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1 transition-[background-color,color] duration-200 ease-exponential select-none [--theme-color:var(--base-theme-color)] corner-super-1.5 group-disabled/option:opacity-50 group-data-focus/option:bg-(--theme-color)/15 group-data-selected/option:text-(--theme-color) dark:group-data-focus/option:bg-(--theme-color)/15", !multiple && "group-data-selected/option:cursor-default group-data-focus/option:group-data-selected/option:bg-transparent", className),
|
|
6873
|
+
children: [/* @__PURE__ */ jsx(Checkmark, { className: "size-3.5 scale-70 opacity-0 transition-[opacity,scale] duration-200 ease-exponential group-data-selected/option:scale-100 group-data-selected/option:opacity-100" }), typeof children === "function" ? children(bag) : children ?? name]
|
|
6848
6874
|
})
|
|
6849
6875
|
});
|
|
6850
6876
|
}
|
|
6851
|
-
|
|
6852
|
-
|
|
6853
|
-
|
|
6854
|
-
|
|
6855
|
-
|
|
6856
|
-
|
|
6857
|
-
|
|
6858
|
-
|
|
6877
|
+
function checkEquality(aOptionList, bOptionList) {
|
|
6878
|
+
if (aOptionList.length !== bOptionList.length) return false;
|
|
6879
|
+
for (let i = 0; i < aOptionList.length; i += 1) {
|
|
6880
|
+
const aOption = aOptionList[i], bOption = bOptionList[i];
|
|
6881
|
+
if (aOption?.id !== bOption?.id || aOption?.name !== bOption?.name) return false;
|
|
6882
|
+
}
|
|
6883
|
+
return true;
|
|
6884
|
+
}
|
|
6885
|
+
function SearchField({ allowCustom, buttonProps, children, className, defaultValue, description, descriptionProps: { className: descriptionClassName, ...descriptionProps } = {}, fieldProps: { className: fieldClassName, ...fieldProps } = {}, inputProps, invalid, label, labelProps: { className: labelClassName, ...labelProps } = {}, multiple, onChange, optionsProps: { anchor, className: optionsClassName, transition, ...optionsProps } = {}, placeholder, required = true, shelfProps: { className: shelfClassName, ...shelfProps } = {}, selectedOptionDisplayProps, singleDisplay, ...props }) {
|
|
6859
6886
|
const uniqueId = useId();
|
|
6860
|
-
const
|
|
6861
|
-
if (!isValidElement(child)) return [];
|
|
6862
|
-
const candidate = child;
|
|
6863
|
-
if (typeof candidate.props?.name !== "string") return [];
|
|
6864
|
-
if (typeof candidate.props?.value !== "string") return [];
|
|
6865
|
-
return [{
|
|
6866
|
-
name: candidate.props.name,
|
|
6867
|
-
value: candidate.props.value,
|
|
6868
|
-
element: child
|
|
6869
|
-
}];
|
|
6870
|
-
});
|
|
6871
|
-
const [query, setQuery] = useState("");
|
|
6887
|
+
const [searchContext, setSearchContext] = useSearchContext((store) => store), { query } = searchContext || {};
|
|
6872
6888
|
const [isInvalid, setIsInvalid] = useState(invalid);
|
|
6873
6889
|
const [selectedOptionSync, setSelectedOptionSync] = useState(() => {
|
|
6874
6890
|
if (multiple) return Array.isArray(defaultValue) ? defaultValue : [];
|
|
6875
6891
|
return typeof defaultValue === "string" ? defaultValue : null;
|
|
6876
6892
|
});
|
|
6877
6893
|
const comboboxInputRef = useRef(null);
|
|
6878
|
-
const
|
|
6894
|
+
const childOptionList = useMemo(() => Children.toArray(children).filter((child) => isValidElement(child) && !!child.props && "value" in child.props && "name" in child.props), [children]);
|
|
6895
|
+
const staticOptionList = useMemo(() => childOptionList.map((child) => ({
|
|
6896
|
+
id: child.props.value,
|
|
6897
|
+
name: child.props.name,
|
|
6898
|
+
selectedDisplayProps: child.props.selectedDisplayProps
|
|
6899
|
+
})), [childOptionList]);
|
|
6900
|
+
const [addedOptionList, setAddedOptionList] = useState([]);
|
|
6901
|
+
const customOptionFromQuery = useMemo(() => {
|
|
6902
|
+
const trimmedQuery = query.trim();
|
|
6903
|
+
if (!allowCustom || trimmedQuery.length === 0) return null;
|
|
6904
|
+
return {
|
|
6905
|
+
id: props.customOptionParams?.formatID?.(trimmedQuery) ?? toLowerCase(trimmedQuery, [" ", "_"]),
|
|
6906
|
+
name: trimmedQuery
|
|
6907
|
+
};
|
|
6908
|
+
}, [
|
|
6909
|
+
allowCustom,
|
|
6910
|
+
props.customOptionParams,
|
|
6911
|
+
query
|
|
6912
|
+
]);
|
|
6913
|
+
const optionLookupMap = useMemo(() => {
|
|
6914
|
+
const lookupMap = /* @__PURE__ */ new Map();
|
|
6915
|
+
for (const option of staticOptionList) lookupMap.set(option.id, option.name);
|
|
6916
|
+
for (const option of addedOptionList) lookupMap.set(option.id, option.name);
|
|
6917
|
+
return lookupMap;
|
|
6918
|
+
}, [addedOptionList, staticOptionList]);
|
|
6919
|
+
const saveCustomOption = useEffectEvent((option) => {
|
|
6920
|
+
if (!multiple) return;
|
|
6921
|
+
setAddedOptionList((prevOptionList) => {
|
|
6922
|
+
if (prevOptionList.some((prevOption) => prevOption.id === option.id)) return prevOptionList;
|
|
6923
|
+
return [...prevOptionList, option];
|
|
6924
|
+
});
|
|
6925
|
+
});
|
|
6879
6926
|
const handleChange = (selected) => {
|
|
6880
6927
|
setIsInvalid(false);
|
|
6928
|
+
if (multiple && Array.isArray(selected)) {
|
|
6929
|
+
const selectedValueList = selected.map((selectedValue) => {
|
|
6930
|
+
if (selectedValue && typeof selectedValue === "object" && "id" in selectedValue && "name" in selectedValue) {
|
|
6931
|
+
const option = {
|
|
6932
|
+
id: String(selectedValue.id),
|
|
6933
|
+
name: String(selectedValue.name)
|
|
6934
|
+
};
|
|
6935
|
+
saveCustomOption(option);
|
|
6936
|
+
return option.id;
|
|
6937
|
+
}
|
|
6938
|
+
return String(selectedValue);
|
|
6939
|
+
});
|
|
6940
|
+
setSelectedOptionSync(selectedValueList);
|
|
6941
|
+
onChange?.(selectedValueList);
|
|
6942
|
+
return;
|
|
6943
|
+
}
|
|
6944
|
+
if (!multiple) {
|
|
6945
|
+
const normalizedSelected = selected && typeof selected === "object" && !Array.isArray(selected) ? String(selected.id) : selected;
|
|
6946
|
+
setSelectedOptionSync(normalizedSelected);
|
|
6947
|
+
onChange?.(normalizedSelected);
|
|
6948
|
+
return;
|
|
6949
|
+
}
|
|
6881
6950
|
setSelectedOptionSync(selected);
|
|
6882
|
-
|
|
6951
|
+
};
|
|
6952
|
+
const formatSelectedDisplay = (name) => {
|
|
6953
|
+
const selectedOptionDisplayChildren = selectedOptionDisplayProps?.children;
|
|
6954
|
+
if (!selectedOptionDisplayChildren) return name;
|
|
6955
|
+
const selectedOptionDisplayValue = typeof selectedOptionDisplayChildren === "function" ? selectedOptionDisplayChildren(name) : selectedOptionDisplayChildren;
|
|
6956
|
+
return typeof selectedOptionDisplayValue === "string" ? selectedOptionDisplayValue : name;
|
|
6883
6957
|
};
|
|
6884
6958
|
const handleInvalid = () => setIsInvalid(true);
|
|
6885
6959
|
const refocus = () => comboboxInputRef.current?.focus();
|
|
6960
|
+
const onVisible = useEffectEvent(() => {
|
|
6961
|
+
setSearchContext?.({
|
|
6962
|
+
multiple,
|
|
6963
|
+
query: "",
|
|
6964
|
+
selectedOptionDisplayProps
|
|
6965
|
+
});
|
|
6966
|
+
});
|
|
6967
|
+
useEffect(() => {
|
|
6968
|
+
onVisible();
|
|
6969
|
+
}, []);
|
|
6970
|
+
useEffect(() => {
|
|
6971
|
+
const selectedOptionList = (Array.isArray(selectedOptionSync) ? selectedOptionSync : typeof selectedOptionSync === "string" ? [selectedOptionSync] : []).map((selectedId) => ({
|
|
6972
|
+
id: selectedId,
|
|
6973
|
+
name: optionLookupMap.get(selectedId) ?? selectedId
|
|
6974
|
+
}));
|
|
6975
|
+
if (!checkEquality(searchContext?.selectedOptionList ?? [], selectedOptionList)) setSearchContext?.({ selectedOptionList });
|
|
6976
|
+
}, [
|
|
6977
|
+
optionLookupMap,
|
|
6978
|
+
searchContext?.selectedOptionList,
|
|
6979
|
+
selectedOptionSync,
|
|
6980
|
+
setSearchContext
|
|
6981
|
+
]);
|
|
6982
|
+
const queryChange = (e) => {
|
|
6983
|
+
const { currentTarget } = e, { value } = currentTarget;
|
|
6984
|
+
setSearchContext?.({ query: value });
|
|
6985
|
+
};
|
|
6986
|
+
const handleClose = () => {
|
|
6987
|
+
setSearchContext?.({ query: "" });
|
|
6988
|
+
};
|
|
6989
|
+
const updateDisplayValue = (value) => {
|
|
6990
|
+
if (multiple && Array.isArray(value)) {
|
|
6991
|
+
if (singleDisplay) return value.map((v) => formatSelectedDisplay(v.name)).join(", ");
|
|
6992
|
+
}
|
|
6993
|
+
if (!multiple && value) return formatSelectedDisplay(value.name);
|
|
6994
|
+
return "";
|
|
6995
|
+
};
|
|
6886
6996
|
return /* @__PURE__ */ jsxs(Field, {
|
|
6887
6997
|
...fieldProps,
|
|
6888
6998
|
className: (bag) => twMerge("grid gap-1", typeof fieldClassName === "function" ? fieldClassName(bag) : fieldClassName),
|
|
@@ -6897,64 +7007,88 @@ function Search({ allowCustom, buttonProps, children, className, defaultValue, d
|
|
|
6897
7007
|
invalid: isInvalid || invalid,
|
|
6898
7008
|
multiple,
|
|
6899
7009
|
onChange: handleChange,
|
|
6900
|
-
onClose:
|
|
6901
|
-
value: selectedOptionSync || "",
|
|
7010
|
+
onClose: handleClose,
|
|
6902
7011
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
6903
|
-
|
|
6904
|
-
|
|
6905
|
-
|
|
6906
|
-
|
|
6907
|
-
|
|
6908
|
-
|
|
6909
|
-
|
|
6910
|
-
|
|
6911
|
-
|
|
6912
|
-
|
|
6913
|
-
|
|
6914
|
-
|
|
6915
|
-
|
|
6916
|
-
|
|
6917
|
-
|
|
6918
|
-
|
|
6919
|
-
|
|
6920
|
-
|
|
6921
|
-
|
|
6922
|
-
|
|
6923
|
-
|
|
6924
|
-
|
|
6925
|
-
|
|
6926
|
-
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
|
|
6930
|
-
|
|
6931
|
-
|
|
6932
|
-
|
|
6933
|
-
|
|
7012
|
+
...multiple ? { "data-multiple": "" } : {},
|
|
7013
|
+
className: "isolate contents data-multiple:grid",
|
|
7014
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
7015
|
+
className: "relative",
|
|
7016
|
+
children: [
|
|
7017
|
+
/* @__PURE__ */ jsx(ComboboxInput, {
|
|
7018
|
+
...inputProps,
|
|
7019
|
+
"aria-label": typeof label === "string" ? label : props.name,
|
|
7020
|
+
className: (bag) => twMerge("inline-block w-full overflow-clip rounded-xl border border-neutral-500/50 bg-neutral-100 py-1 ps-2 pe-8 text-left text-neutral-950 outline-offset-1 outline-blue-400/95 transition-[background-color] duration-300 ease-exponential corner-super-1.5 dark:bg-neutral-700 dark:text-neutral-50", "focus:outline-3 focus-visible:bg-neutral-50 focus-visible:outline-3 active:bg-neutral-200 dark:focus-visible:bg-neutral-600 dark:active:bg-neutral-800 pointer-fine:hover:bg-neutral-50 pointer-fine:active:bg-neutral-200 dark:pointer-fine:hover:bg-neutral-600 dark:pointer-fine:active:bg-neutral-800", "data-invalid:border-red-500 data-invalid:bg-[color-mix(in_oklch,var(--color-red-500)_5%,var(--color-neutral-100)_5%)] data-invalid:focus-visible:bg-[color-mix(in_oklch,var(--color-red-500)_1%,var(--color-neutral-100))] data-invalid:active:bg-[color-mix(in_oklch,var(--color-red-500)_5%,var(--color-neutral-100))] dark:data-invalid:bg-[color-mix(in_oklch,var(--color-red-500)_5%,var(--color-neutral-800)_5%)] dark:data-invalid:focus-visible:bg-[color-mix(in_oklch,var(--color-red-500)_1%,var(--color-neutral-800))] dark:data-invalid:active:bg-[color-mix(in_oklch,var(--color-red-500)_5%,var(--color-neutral-800)_5%)] data-invalid:pointer-fine:hover:bg-[color-mix(in_oklch,var(--color-red-500)_10%,var(--color-neutral-500)_5%)] data-invalid:pointer-fine:focus-visible:bg-[color-mix(in_oklch,var(--color-red-500)_1%,var(--color-neutral-100))] data-invalid:pointer-fine:active:bg-[color-mix(in_oklch,var(--color-red-500)_5%,var(--color-neutral-100))] dark:data-invalid:pointer-fine:hover:bg-[color-mix(in_oklch,var(--color-red-500)_10%,var(--color-neutral-800)_5%)] dark:data-invalid:pointer-fine:focus-visible:bg-[color-mix(in_oklch,var(--color-red-500)_1%,var(--color-neutral-800))] dark:data-invalid:pointer-fine:active:bg-[color-mix(in_oklch,var(--color-red-500)_5%,var(--color-neutral-800)_5%)]", typeof className === "function" ? className(bag) : className),
|
|
7021
|
+
displayValue: updateDisplayValue,
|
|
7022
|
+
name: props.name,
|
|
7023
|
+
onChange: queryChange,
|
|
7024
|
+
placeholder: placeholder || `${multiple ? "Choose Any" : "Choose One"}${allowCustom ? " or Create Your Own" : ""}`,
|
|
7025
|
+
ref: comboboxInputRef,
|
|
7026
|
+
required
|
|
7027
|
+
}),
|
|
7028
|
+
/* @__PURE__ */ jsx("input", {
|
|
7029
|
+
"aria-hidden": "true",
|
|
7030
|
+
className: "sr-only top-0 left-1/2",
|
|
7031
|
+
id: props.name + ":input:id" + uniqueId,
|
|
7032
|
+
name: props.name,
|
|
7033
|
+
onChange: () => {},
|
|
7034
|
+
onFocus: refocus,
|
|
7035
|
+
onInvalid: handleInvalid,
|
|
7036
|
+
required,
|
|
7037
|
+
tabIndex: -1,
|
|
7038
|
+
value: Array.isArray(selectedOptionSync) ? selectedOptionSync.join(", ") : selectedOptionSync ?? ""
|
|
7039
|
+
}),
|
|
7040
|
+
/* @__PURE__ */ jsx(ComboboxButton, {
|
|
7041
|
+
...buttonProps,
|
|
7042
|
+
className: "absolute top-1/2 right-1.5 -translate-y-1/2 rounded p-0.5",
|
|
7043
|
+
children: /* @__PURE__ */ jsx(ChevronUpChevronDown, { className: "size-3 fill-current/50" })
|
|
7044
|
+
})
|
|
7045
|
+
]
|
|
7046
|
+
}), multiple && !singleDisplay && /* @__PURE__ */ jsx("div", {
|
|
7047
|
+
...shelfProps,
|
|
7048
|
+
className: twMerge("flex min-h-8 flex-wrap gap-1 p-2 before:absolute before:inset-x-0 before:-top-4 before:bottom-0 before:-z-10 before:rounded-b-xl before:border before:border-t-0 before:border-neutral-500/50", shelfClassName),
|
|
7049
|
+
children: searchContext?.selectedOptionList?.length > 0 && [...staticOptionList, ...addedOptionList].filter((option, optionIndex, optionList) => {
|
|
7050
|
+
return optionList.findIndex((innerOption) => innerOption.id === option.id) === optionIndex;
|
|
7051
|
+
}).map((option) => {
|
|
7052
|
+
if (!searchContext.selectedOptionList.some(({ id }) => id === option.id)) return null;
|
|
7053
|
+
return /* @__PURE__ */ jsx(SearchOption, {
|
|
7054
|
+
name: option.name,
|
|
7055
|
+
value: option.id,
|
|
7056
|
+
selectedDisplayProps: option.selectedDisplayProps,
|
|
7057
|
+
isInDisplay: true,
|
|
7058
|
+
children: option.name
|
|
7059
|
+
}, option.id);
|
|
7060
|
+
}).filter(Boolean)
|
|
7061
|
+
})]
|
|
6934
7062
|
}), /* @__PURE__ */ jsxs(ComboboxOptions, {
|
|
6935
7063
|
...optionsProps,
|
|
6936
7064
|
anchor: anchor || "bottom start",
|
|
6937
|
-
className: (bag) => twMerge("z-50 w-(--input-width) origin-top rounded-xl border border-neutral-500/50 bg-neutral-50/95 p-1 backdrop-blur-sm backdrop-brightness-110 transition-[opacity,scale,translate] duration-300 ease-exponential
|
|
7065
|
+
className: (bag) => twMerge("z-50 w-(--input-width) origin-top rounded-xl border border-neutral-500/50 bg-neutral-50/95 p-1 backdrop-blur-sm backdrop-brightness-110 transition-[opacity,scale,translate] duration-300 ease-exponential corner-super-1.5 empty:invisible focus:outline-none data-closed:-translate-y-0.5 data-closed:scale-y-0 data-closed:opacity-0 data-[anchor*=top]:origin-bottom dark:bg-neutral-800/95", multiple && !singleDisplay ? "[--anchor-gap:--spacing(8)]" : "[--anchor-gap:--spacing(1)]", typeof optionsClassName === "function" ? optionsClassName(bag) : optionsClassName),
|
|
6938
7066
|
transition: transition ?? true,
|
|
6939
|
-
children: [
|
|
6940
|
-
|
|
6941
|
-
|
|
6942
|
-
|
|
6943
|
-
|
|
6944
|
-
|
|
6945
|
-
|
|
6946
|
-
|
|
6947
|
-
|
|
6948
|
-
|
|
6949
|
-
|
|
6950
|
-
|
|
6951
|
-
|
|
6952
|
-
|
|
6953
|
-
|
|
6954
|
-
|
|
6955
|
-
|
|
6956
|
-
|
|
6957
|
-
|
|
7067
|
+
children: [
|
|
7068
|
+
allowCustom && query.length > 0 && customOptionFromQuery && !addedOptionList.some((addedOption) => addedOption.id === customOptionFromQuery.id) && /* @__PURE__ */ jsx(ComboboxOption, {
|
|
7069
|
+
value: customOptionFromQuery,
|
|
7070
|
+
className: "group/option contents",
|
|
7071
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
7072
|
+
className: "flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1 transition-[background-color] duration-200 ease-exponential select-none [--theme-color:var(--base-theme-color)] corner-super-1.5 group-disabled/option:opacity-50 group-data-focus/option:bg-(--theme-color)/15 dark:group-data-focus/option:bg-(--theme-color)/15",
|
|
7073
|
+
children: [
|
|
7074
|
+
/* @__PURE__ */ jsx(Plus, { className: "size-3.5" }),
|
|
7075
|
+
"Use ",
|
|
7076
|
+
/* @__PURE__ */ jsxs("b", { children: [
|
|
7077
|
+
"\"",
|
|
7078
|
+
query,
|
|
7079
|
+
"\""
|
|
7080
|
+
] })
|
|
7081
|
+
]
|
|
7082
|
+
})
|
|
7083
|
+
}),
|
|
7084
|
+
children,
|
|
7085
|
+
multiple && addedOptionList.filter((addedOption) => !staticOptionList.some((staticOption) => staticOption.id === addedOption.id)).map((addedOption) => /* @__PURE__ */ jsx(SearchOption, {
|
|
7086
|
+
name: addedOption.name,
|
|
7087
|
+
value: addedOption.id,
|
|
7088
|
+
selectedDisplayProps: addedOption.selectedDisplayProps,
|
|
7089
|
+
children: addedOption.name
|
|
7090
|
+
}, "added:" + addedOption.id))
|
|
7091
|
+
]
|
|
6958
7092
|
})]
|
|
6959
7093
|
}),
|
|
6960
7094
|
description && /* @__PURE__ */ jsx(Description, {
|
|
@@ -6965,6 +7099,31 @@ function Search({ allowCustom, buttonProps, children, className, defaultValue, d
|
|
|
6965
7099
|
]
|
|
6966
7100
|
});
|
|
6967
7101
|
}
|
|
7102
|
+
/**
|
|
7103
|
+
* # Search
|
|
7104
|
+
*
|
|
7105
|
+
* A searchable select component built on top of Headless UI's `Combobox`.
|
|
7106
|
+
*
|
|
7107
|
+
* Use the `SearchOption` component to define options.
|
|
7108
|
+
*
|
|
7109
|
+
* Use the `SearchSectionTitle` component to define titles.
|
|
7110
|
+
*
|
|
7111
|
+
* @prop label - The label for the select component.
|
|
7112
|
+
* @prop description - The description for the select component.
|
|
7113
|
+
* @prop placeholder - The placeholder for the select component.
|
|
7114
|
+
* @prop required - Whether the select component is required.
|
|
7115
|
+
* @prop invalid - Whether the select component is invalid.
|
|
7116
|
+
* @prop multiple - Whether the select component allows multiple selections.
|
|
7117
|
+
* @prop optionsProps - The props to be passed to each SearchOption component.
|
|
7118
|
+
* @prop selectedOptionDisplayProps - The props to be passed to each selected option in the selected option component.
|
|
7119
|
+
* @prop fieldProps - The props to be passed to the parent field component.
|
|
7120
|
+
* @prop labelProps - The props to be passed to the label component.
|
|
7121
|
+
* @prop descriptionProps - The props to be passed to the description component.
|
|
7122
|
+
* @prop anchor - The anchor point for the drop down menu.
|
|
7123
|
+
*/
|
|
7124
|
+
function Search(props) {
|
|
7125
|
+
return /* @__PURE__ */ jsx(SearchContextProvider, { children: /* @__PURE__ */ jsx(SearchField, { ...props }) });
|
|
7126
|
+
}
|
|
6968
7127
|
//#endregion
|
|
6969
7128
|
//#region src/symbols/circle.fill.tsx
|
|
6970
7129
|
function CircleFill({ weight = "regular", ...props }) {
|
|
@@ -8967,25 +9126,21 @@ function TooltipDisplay({ anchor = "top", arrow: arrow$4, arrowClassName, childr
|
|
|
8967
9126
|
clearTimeout(timeoutRef.current);
|
|
8968
9127
|
};
|
|
8969
9128
|
}, []);
|
|
8970
|
-
const [, setTooltipContext] = useTooltipContext(() =>
|
|
9129
|
+
const [tooltipContext, setTooltipContext] = useTooltipContext(() => defaultTooltipContext);
|
|
8971
9130
|
useEffect(() => {
|
|
8972
|
-
|
|
8973
|
-
|
|
8974
|
-
|
|
8975
|
-
|
|
8976
|
-
|
|
8977
|
-
|
|
8978
|
-
|
|
8979
|
-
|
|
8980
|
-
|
|
8981
|
-
|
|
8982
|
-
|
|
8983
|
-
|
|
8984
|
-
|
|
8985
|
-
arrowRef,
|
|
8986
|
-
arrow: nextArrow,
|
|
8987
|
-
arrowClassName: nextArrowClassName
|
|
8988
|
-
};
|
|
9131
|
+
const nextArrow = arrow$4 || false, nextArrowClassName = arrowClassName || "";
|
|
9132
|
+
if (tooltipContext && tooltipContext.isOpen !== isOpen || tooltipContext.openTooltip !== openTooltip || tooltipContext.closeTooltip !== closeTooltip || tooltipContext.refs !== refs || tooltipContext.floatingStyles !== floatingStyles || tooltipContext.isPositioned !== isPositioned || tooltipContext.placement !== placement || tooltipContext.middlewareData !== middlewareData || tooltipContext.arrowRef !== arrowRef || tooltipContext.arrow !== nextArrow || tooltipContext.arrowClassName !== nextArrowClassName) setTooltipContext?.({
|
|
9133
|
+
isOpen,
|
|
9134
|
+
openTooltip,
|
|
9135
|
+
closeTooltip,
|
|
9136
|
+
refs,
|
|
9137
|
+
floatingStyles,
|
|
9138
|
+
isPositioned,
|
|
9139
|
+
placement,
|
|
9140
|
+
middlewareData,
|
|
9141
|
+
arrowRef,
|
|
9142
|
+
arrow: nextArrow,
|
|
9143
|
+
arrowClassName: nextArrowClassName
|
|
8989
9144
|
});
|
|
8990
9145
|
}, [
|
|
8991
9146
|
arrow$4,
|
|
@@ -9046,4 +9201,4 @@ function ArrowSvg({ className, ...props }) {
|
|
|
9046
9201
|
});
|
|
9047
9202
|
}
|
|
9048
9203
|
//#endregion
|
|
9049
|
-
export { Anchor, Button, Checkbox, Details, DetailsBody, DetailsSummary, DropDown, DropDownButton, DropDownItem, DropDownItems, DropDownSection, DropDownSeparator, Fieldset, Form, Ghost, Heading, HumanVerification, IFrame, Input, Link, Modal, ModalClose, ModalDialog, ModalTitle, ModalTrigger, Search, SearchOption, Select, SelectOption, SelectSectionTitle, SubmitButton, Textarea, Time, Tooltip, TooltipPanel, TooltipTrigger, generateHumanValidationToken, getLinkClasses, validateHuman };
|
|
9204
|
+
export { Anchor, Button, Checkbox, Details, DetailsBody, DetailsSummary, DropDown, DropDownButton, DropDownItem, DropDownItems, DropDownSection, DropDownSeparator, Fieldset, Form, Ghost, Heading, HumanVerification, IFrame, Input, Link, Modal, ModalClose, ModalDialog, ModalTitle, ModalTrigger, Search, SearchOption, SearchSectionTitle, Select, SelectOption, SelectSectionTitle, SubmitButton, Textarea, Time, Tooltip, TooltipPanel, TooltipTrigger, generateHumanValidationToken, getLinkClasses, validateHuman };
|