@allxsmith/bestax-bulma 5.27.0 → 5.27.1
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/bestax.css +1 -1
- package/dist/bestax.css.map +1 -1
- package/dist/esm/columns/Column.js +48 -0
- package/dist/esm/columns/Column.js.map +1 -0
- package/dist/esm/columns/Columns.js +53 -0
- package/dist/esm/columns/Columns.js.map +1 -0
- package/dist/esm/components/Avatar.js +299 -0
- package/dist/esm/components/Avatar.js.map +1 -0
- package/dist/esm/components/Avatars.js +81 -0
- package/dist/esm/components/Avatars.js.map +1 -0
- package/dist/esm/components/Badge.js +105 -0
- package/dist/esm/components/Badge.js.map +1 -0
- package/dist/esm/components/Breadcrumb.js +36 -0
- package/dist/esm/components/Breadcrumb.js.map +1 -0
- package/dist/esm/components/Card.js +252 -0
- package/dist/esm/components/Card.js.map +1 -0
- package/dist/esm/components/Carousel.js +351 -0
- package/dist/esm/components/Carousel.js.map +1 -0
- package/dist/esm/components/Collapse.js +193 -0
- package/dist/esm/components/Collapse.js.map +1 -0
- package/dist/esm/components/Collapses.js +99 -0
- package/dist/esm/components/Collapses.js.map +1 -0
- package/dist/esm/components/Dialog.js +230 -0
- package/dist/esm/components/Dialog.js.map +1 -0
- package/dist/esm/components/Dropdown.js +362 -0
- package/dist/esm/components/Dropdown.js.map +1 -0
- package/dist/esm/components/Loading.js +87 -0
- package/dist/esm/components/Loading.js.map +1 -0
- package/dist/esm/components/Menu.js +117 -0
- package/dist/esm/components/Menu.js.map +1 -0
- package/dist/esm/components/Message.js +56 -0
- package/dist/esm/components/Message.js.map +1 -0
- package/dist/esm/components/Modal.js +354 -0
- package/dist/esm/components/Modal.js.map +1 -0
- package/dist/esm/components/Navbar.js +287 -0
- package/dist/esm/components/Navbar.js.map +1 -0
- package/dist/esm/components/Pagination.js +191 -0
- package/dist/esm/components/Pagination.js.map +1 -0
- package/dist/esm/components/Panel.js +100 -0
- package/dist/esm/components/Panel.js.map +1 -0
- package/dist/esm/components/Popover.js +298 -0
- package/dist/esm/components/Popover.js.map +1 -0
- package/dist/esm/components/Reveal.js +157 -0
- package/dist/esm/components/Reveal.js.map +1 -0
- package/dist/esm/components/Sidebar.js +209 -0
- package/dist/esm/components/Sidebar.js.map +1 -0
- package/dist/esm/components/Steps.js +128 -0
- package/dist/esm/components/Steps.js.map +1 -0
- package/dist/esm/components/Tabs.js +335 -0
- package/dist/esm/components/Tabs.js.map +1 -0
- package/dist/esm/components/Toast.js +322 -0
- package/dist/esm/components/Toast.js.map +1 -0
- package/dist/esm/components/Tooltip.js +202 -0
- package/dist/esm/components/Tooltip.js.map +1 -0
- package/dist/esm/components/collapsesContext.js +12 -0
- package/dist/esm/components/collapsesContext.js.map +1 -0
- package/dist/esm/elements/Block.js +29 -0
- package/dist/esm/elements/Block.js.map +1 -0
- package/dist/esm/elements/Box.js +32 -0
- package/dist/esm/elements/Box.js.map +1 -0
- package/dist/esm/elements/Button.js +139 -0
- package/dist/esm/elements/Button.js.map +1 -0
- package/dist/esm/elements/Buttons.js +42 -0
- package/dist/esm/elements/Buttons.js.map +1 -0
- package/dist/esm/elements/Code.js +25 -0
- package/dist/esm/elements/Code.js.map +1 -0
- package/dist/esm/elements/Content.js +33 -0
- package/dist/esm/elements/Content.js.map +1 -0
- package/dist/esm/elements/Delete.js +35 -0
- package/dist/esm/elements/Delete.js.map +1 -0
- package/dist/esm/elements/Divider.js +27 -0
- package/dist/esm/elements/Divider.js.map +1 -0
- package/dist/esm/elements/Emphasis.js +25 -0
- package/dist/esm/elements/Emphasis.js.map +1 -0
- package/dist/esm/elements/Figure.js +58 -0
- package/dist/esm/elements/Figure.js.map +1 -0
- package/dist/esm/elements/Icon.js +256 -0
- package/dist/esm/elements/Icon.js.map +1 -0
- package/dist/esm/elements/IconText.js +36 -0
- package/dist/esm/elements/IconText.js.map +1 -0
- package/dist/esm/elements/Image.js +46 -0
- package/dist/esm/elements/Image.js.map +1 -0
- package/dist/esm/elements/Link.js +36 -0
- package/dist/esm/elements/Link.js.map +1 -0
- package/dist/esm/elements/LinkButton.js +37 -0
- package/dist/esm/elements/LinkButton.js.map +1 -0
- package/dist/esm/elements/ListItem.js +28 -0
- package/dist/esm/elements/ListItem.js.map +1 -0
- package/dist/esm/elements/Loader.js +37 -0
- package/dist/esm/elements/Loader.js.map +1 -0
- package/dist/esm/elements/Notification.js +316 -0
- package/dist/esm/elements/Notification.js.map +1 -0
- package/dist/esm/elements/OrderedList.js +31 -0
- package/dist/esm/elements/OrderedList.js.map +1 -0
- package/dist/esm/elements/Paragraph.js +28 -0
- package/dist/esm/elements/Paragraph.js.map +1 -0
- package/dist/esm/elements/Pre.js +25 -0
- package/dist/esm/elements/Pre.js.map +1 -0
- package/dist/esm/elements/Progress.js +33 -0
- package/dist/esm/elements/Progress.js.map +1 -0
- package/dist/esm/elements/Skeleton.js +30 -0
- package/dist/esm/elements/Skeleton.js.map +1 -0
- package/dist/esm/elements/Span.js +28 -0
- package/dist/esm/elements/Span.js.map +1 -0
- package/dist/esm/elements/Strong.js +25 -0
- package/dist/esm/elements/Strong.js.map +1 -0
- package/dist/esm/elements/SubTitle.js +51 -0
- package/dist/esm/elements/SubTitle.js.map +1 -0
- package/dist/esm/elements/Table.js +51 -0
- package/dist/esm/elements/Table.js.map +1 -0
- package/dist/esm/elements/Tag.js +49 -0
- package/dist/esm/elements/Tag.js.map +1 -0
- package/dist/esm/elements/Tags.js +34 -0
- package/dist/esm/elements/Tags.js.map +1 -0
- package/dist/esm/elements/Tbody.js +26 -0
- package/dist/esm/elements/Tbody.js.map +1 -0
- package/dist/esm/elements/Td.js +61 -0
- package/dist/esm/elements/Td.js.map +1 -0
- package/dist/esm/elements/Tfoot.js +26 -0
- package/dist/esm/elements/Tfoot.js.map +1 -0
- package/dist/esm/elements/Th.js +34 -0
- package/dist/esm/elements/Th.js.map +1 -0
- package/dist/esm/elements/Thead.js +26 -0
- package/dist/esm/elements/Thead.js.map +1 -0
- package/dist/esm/elements/Title.js +44 -0
- package/dist/esm/elements/Title.js.map +1 -0
- package/dist/esm/elements/Tr.js +31 -0
- package/dist/esm/elements/Tr.js.map +1 -0
- package/dist/esm/elements/UnorderedList.js +31 -0
- package/dist/esm/elements/UnorderedList.js.map +1 -0
- package/dist/esm/elements/iconProps.js +49 -0
- package/dist/esm/elements/iconProps.js.map +1 -0
- package/dist/esm/form/Autocomplete.js +279 -0
- package/dist/esm/form/Autocomplete.js.map +1 -0
- package/dist/esm/form/Checkbox.js +111 -0
- package/dist/esm/form/Checkbox.js.map +1 -0
- package/dist/esm/form/Checkboxes.js +89 -0
- package/dist/esm/form/Checkboxes.js.map +1 -0
- package/dist/esm/form/Control.js +79 -0
- package/dist/esm/form/Control.js.map +1 -0
- package/dist/esm/form/DateInput.js +87 -0
- package/dist/esm/form/DateInput.js.map +1 -0
- package/dist/esm/form/DateInputBase.js +263 -0
- package/dist/esm/form/DateInputBase.js.map +1 -0
- package/dist/esm/form/DateRangeInput.js +76 -0
- package/dist/esm/form/DateRangeInput.js.map +1 -0
- package/dist/esm/form/DateRangeInputBase.js +301 -0
- package/dist/esm/form/DateRangeInputBase.js.map +1 -0
- package/dist/esm/form/DateTimeInput.js +87 -0
- package/dist/esm/form/DateTimeInput.js.map +1 -0
- package/dist/esm/form/DateTimeInputBase.js +333 -0
- package/dist/esm/form/DateTimeInputBase.js.map +1 -0
- package/dist/esm/form/Field.js +153 -0
- package/dist/esm/form/Field.js.map +1 -0
- package/dist/esm/form/File.js +109 -0
- package/dist/esm/form/File.js.map +1 -0
- package/dist/esm/form/FormContext.js +170 -0
- package/dist/esm/form/FormContext.js.map +1 -0
- package/dist/esm/form/Input.js +88 -0
- package/dist/esm/form/Input.js.map +1 -0
- package/dist/esm/form/InputBase.js +40 -0
- package/dist/esm/form/InputBase.js.map +1 -0
- package/dist/esm/form/Numberinput.js +199 -0
- package/dist/esm/form/Numberinput.js.map +1 -0
- package/dist/esm/form/Radio.js +108 -0
- package/dist/esm/form/Radio.js.map +1 -0
- package/dist/esm/form/Radios.js +91 -0
- package/dist/esm/form/Radios.js.map +1 -0
- package/dist/esm/form/Rate.js +279 -0
- package/dist/esm/form/Rate.js.map +1 -0
- package/dist/esm/form/Select.js +81 -0
- package/dist/esm/form/Select.js.map +1 -0
- package/dist/esm/form/SelectBase.js +54 -0
- package/dist/esm/form/SelectBase.js.map +1 -0
- package/dist/esm/form/Slider.js +459 -0
- package/dist/esm/form/Slider.js.map +1 -0
- package/dist/esm/form/Switch.js +96 -0
- package/dist/esm/form/Switch.js.map +1 -0
- package/dist/esm/form/Taginput.js +352 -0
- package/dist/esm/form/Taginput.js.map +1 -0
- package/dist/esm/form/TextArea.js +77 -0
- package/dist/esm/form/TextArea.js.map +1 -0
- package/dist/esm/form/TextAreaBase.js +45 -0
- package/dist/esm/form/TextAreaBase.js.map +1 -0
- package/dist/esm/form/TimeInput.js +83 -0
- package/dist/esm/form/TimeInput.js.map +1 -0
- package/dist/esm/form/TimeInputBase.js +246 -0
- package/dist/esm/form/TimeInputBase.js.map +1 -0
- package/dist/esm/form/_pickerInternals/Calendar.js +760 -0
- package/dist/esm/form/_pickerInternals/Calendar.js.map +1 -0
- package/dist/esm/form/_pickerInternals/PickerPopover.js +95 -0
- package/dist/esm/form/_pickerInternals/PickerPopover.js.map +1 -0
- package/dist/esm/form/_pickerInternals/TimeWheels.js +721 -0
- package/dist/esm/form/_pickerInternals/TimeWheels.js.map +1 -0
- package/dist/esm/form/_pickerInternals/audioTick.js +109 -0
- package/dist/esm/form/_pickerInternals/audioTick.js.map +1 -0
- package/dist/esm/form/_pickerInternals/dateUtils.js +267 -0
- package/dist/esm/form/_pickerInternals/dateUtils.js.map +1 -0
- package/dist/esm/form/_pickerInternals/formatters.js +322 -0
- package/dist/esm/form/_pickerInternals/formatters.js.map +1 -0
- package/dist/esm/form/_pickerInternals/haptics.js +38 -0
- package/dist/esm/form/_pickerInternals/haptics.js.map +1 -0
- package/dist/esm/form/_pickerInternals/nativeInputSupport.js +25 -0
- package/dist/esm/form/_pickerInternals/nativeInputSupport.js.map +1 -0
- package/dist/esm/form/_pickerInternals/pickerTypes.js +50 -0
- package/dist/esm/form/_pickerInternals/pickerTypes.js.map +1 -0
- package/dist/esm/form/_pickerInternals/segmentMap.js +315 -0
- package/dist/esm/form/_pickerInternals/segmentMap.js.map +1 -0
- package/dist/esm/form/_pickerInternals/useNativeMobilePicker.js +49 -0
- package/dist/esm/form/_pickerInternals/useNativeMobilePicker.js.map +1 -0
- package/dist/esm/form/_pickerInternals/useSegmentedEntry.js +427 -0
- package/dist/esm/form/_pickerInternals/useSegmentedEntry.js.map +1 -0
- package/dist/esm/form/controlLoading.js +18 -0
- package/dist/esm/form/controlLoading.js.map +1 -0
- package/dist/esm/form/useAutoLabelId.js +54 -0
- package/dist/esm/form/useAutoLabelId.js.map +1 -0
- package/dist/esm/grid/Cell.js +35 -0
- package/dist/esm/grid/Cell.js.map +1 -0
- package/dist/esm/grid/Grid.js +51 -0
- package/dist/esm/grid/Grid.js.map +1 -0
- package/dist/esm/helpers/ClientOnly.js +33 -0
- package/dist/esm/helpers/ClientOnly.js.map +1 -0
- package/dist/esm/helpers/Config.js +60 -0
- package/dist/esm/helpers/Config.js.map +1 -0
- package/dist/esm/helpers/Theme.js +947 -0
- package/dist/esm/helpers/Theme.js.map +1 -0
- package/dist/esm/helpers/anchorAttrs.js +72 -0
- package/dist/esm/helpers/anchorAttrs.js.map +1 -0
- package/dist/esm/helpers/bulmaClassHelpers.js +415 -0
- package/dist/esm/helpers/bulmaClassHelpers.js.map +1 -0
- package/dist/esm/helpers/buttonType.js +24 -0
- package/dist/esm/helpers/buttonType.js.map +1 -0
- package/dist/esm/helpers/classNames.js +137 -0
- package/dist/esm/helpers/classNames.js.map +1 -0
- package/dist/esm/helpers/colorDeprecations.js +50 -0
- package/dist/esm/helpers/colorDeprecations.js.map +1 -0
- package/dist/esm/helpers/devWarnings.js +27 -0
- package/dist/esm/helpers/devWarnings.js.map +1 -0
- package/dist/esm/helpers/inertProps.js +27 -0
- package/dist/esm/helpers/inertProps.js.map +1 -0
- package/dist/esm/helpers/mergeBulmaStyles.js +20 -0
- package/dist/esm/helpers/mergeBulmaStyles.js.map +1 -0
- package/dist/esm/helpers/polymorphic.js +18 -0
- package/dist/esm/helpers/polymorphic.js.map +1 -0
- package/dist/esm/helpers/portal.js +76 -0
- package/dist/esm/helpers/portal.js.map +1 -0
- package/dist/esm/helpers/positionStacks.js +45 -0
- package/dist/esm/helpers/positionStacks.js.map +1 -0
- package/dist/esm/helpers/scrollLock.js +38 -0
- package/dist/esm/helpers/scrollLock.js.map +1 -0
- package/dist/esm/helpers/shadowDom.js +71 -0
- package/dist/esm/helpers/shadowDom.js.map +1 -0
- package/dist/esm/helpers/statusRegion.js +282 -0
- package/dist/esm/helpers/statusRegion.js.map +1 -0
- package/dist/esm/helpers/useAnchoredPosition.js +86 -0
- package/dist/esm/helpers/useAnchoredPosition.js.map +1 -0
- package/dist/esm/helpers/useBulmaClasses.js +158 -0
- package/dist/esm/helpers/useBulmaClasses.js.map +1 -0
- package/dist/esm/helpers/useClientLayoutEffect.js +13 -0
- package/dist/esm/helpers/useClientLayoutEffect.js.map +1 -0
- package/dist/esm/helpers/useColorClasses.js +84 -0
- package/dist/esm/helpers/useColorClasses.js.map +1 -0
- package/dist/esm/helpers/useFlexboxClasses.js +92 -0
- package/dist/esm/helpers/useFlexboxClasses.js.map +1 -0
- package/dist/esm/helpers/useFocusTrap.js +470 -0
- package/dist/esm/helpers/useFocusTrap.js.map +1 -0
- package/dist/esm/helpers/useIsHydrated.js +31 -0
- package/dist/esm/helpers/useIsHydrated.js.map +1 -0
- package/dist/esm/helpers/useOtherClasses.js +115 -0
- package/dist/esm/helpers/useOtherClasses.js.map +1 -0
- package/dist/esm/helpers/useSpacingClasses.js +82 -0
- package/dist/esm/helpers/useSpacingClasses.js.map +1 -0
- package/dist/esm/helpers/useTypographyClasses.js +93 -0
- package/dist/esm/helpers/useTypographyClasses.js.map +1 -0
- package/dist/esm/helpers/useVisibilityClasses.js +134 -0
- package/dist/esm/helpers/useVisibilityClasses.js.map +1 -0
- package/dist/esm/helpers/withSubComponents.js +24 -0
- package/dist/esm/helpers/withSubComponents.js.map +1 -0
- package/dist/esm/layout/Container.js +48 -0
- package/dist/esm/layout/Container.js.map +1 -0
- package/dist/esm/layout/Footer.js +33 -0
- package/dist/esm/layout/Footer.js.map +1 -0
- package/dist/esm/layout/Hero.js +90 -0
- package/dist/esm/layout/Hero.js.map +1 -0
- package/dist/esm/layout/Level.js +110 -0
- package/dist/esm/layout/Level.js.map +1 -0
- package/dist/esm/layout/Media.js +86 -0
- package/dist/esm/layout/Media.js.map +1 -0
- package/dist/esm/layout/Section.js +30 -0
- package/dist/esm/layout/Section.js.map +1 -0
- package/dist/extras.css +1 -1
- package/dist/extras.css.map +1 -1
- package/dist/index.cjs +75 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +115 -17516
- package/dist/index.esm.js.map +1 -1
- package/dist/types/elements/Icon.d.ts +10 -7
- package/dist/types/form/DateInputBase.d.ts +3 -4
- package/dist/types/form/DateTimeInputBase.d.ts +3 -4
- package/dist/types/form/File.d.ts +3 -3
- package/dist/types-cjs/elements/Icon.d.ts +10 -7
- package/dist/types-cjs/form/DateInputBase.d.ts +3 -4
- package/dist/types-cjs/form/DateTimeInputBase.d.ts +3 -4
- package/dist/types-cjs/form/File.d.ts +3 -3
- package/dist/versions/bestax-no-dark-mode.css +1 -1
- package/dist/versions/bestax-no-dark-mode.css.map +1 -1
- package/dist/versions/bestax-no-helpers-prefixed.css +1 -1
- package/dist/versions/bestax-no-helpers-prefixed.css.map +1 -1
- package/dist/versions/bestax-no-helpers.css +1 -1
- package/dist/versions/bestax-no-helpers.css.map +1 -1
- package/dist/versions/bestax-prefixed.css +1 -1
- package/dist/versions/bestax-prefixed.css.map +1 -1
- package/package.json +1 -1
- package/src/scss/form/_dateinput.scss +37 -6
- package/src/scss/form/_datetimeinput.scss +7 -2
- package/src/scss/form/_picker-popover.scss +1 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Collapse.js","sources":["../../../src/components/Collapse.tsx"],"sourcesContent":["import React, {\n useState,\n useRef,\n useEffect,\n useCallback,\n useContext,\n useId,\n} from 'react';\nimport { classNames, usePrefixedClassNames } from '../helpers/classNames';\nimport { useBulmaClasses, BulmaClassesProps } from '../helpers/useBulmaClasses';\nimport { warnOnce } from '../helpers/devWarnings';\nimport { inertProps } from '../helpers/inertProps';\nimport { CollapsesItemContext } from './collapsesContext';\n\n/**\n * Props for the Collapse component.\n * @extraProp {React.ReactNode} [children] - The collapsible content.\n * @extraProp {string} [className] - Additional CSS classes.\n */\nexport interface CollapseProps\n extends\n Omit<React.HTMLAttributes<HTMLDivElement>, 'color'>,\n Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {\n /**\n * Controlled open state. If provided, component is controlled, and the\n * trigger only reports through `onOpenChange`. Inside a `Collapses` group, a\n * Collapse that sets `open` stays yours: the group neither overrides it nor\n * closes it when another item opens.\n */\n open?: boolean;\n /** Initial open state for uncontrolled usage. Ignored inside a `Collapses` group, whose `defaultValue` decides. */\n defaultOpen?: boolean;\n /** Called when the trigger opens the Collapse. Fires only while the Collapse keeps its own state: not when `open` is set, and not when a `Collapses` group manages it. `onOpenChange` reports in every mode. */\n onOpen?: () => void;\n /** Called when the trigger closes the Collapse. Fires only while the Collapse keeps its own state: not when `open` is set, and not when a `Collapses` group manages it. `onOpenChange` reports in every mode. */\n onClose?: () => void;\n /** Called with the state the trigger asks for (`true` to open) each time it is clicked or activated with Enter or Space, in every mode. Pair it with `open` to let the trigger drive a controlled Collapse. */\n onOpenChange?: (open: boolean) => void;\n /** The clickable trigger element (header/button). */\n trigger?: React.ReactNode;\n /** Animation style, or `false` to disable. */\n animation?: 'fade' | 'slide' | false;\n /** Position of the trigger relative to content. */\n position?: 'top' | 'bottom';\n /**\n * Custom aria id for accessibility.\n * @defaultValue auto\n */\n ariaId?: string;\n /** Adds a border around the collapse. */\n bordered?: boolean;\n /** Additional classes for the trigger wrapper. */\n triggerClassName?: string;\n /** Additional classes for the content wrapper. */\n contentClassName?: string;\n}\n\n/**\n * The `Collapse` component provides an expandable/collapsible content panel.\n *\n * @function\n * @param {CollapseProps} props - Props for the Collapse component.\n * @returns {JSX.Element} The rendered collapse component.\n *\n * @example\n * // Basic uncontrolled collapse\n * <Collapse trigger={<button>Click to toggle</button>}>\n * <p>Collapsible content here</p>\n * </Collapse>\n *\n * @example\n * // Controlled collapse, driven by its own trigger\n * const [isOpen, setIsOpen] = useState(false);\n * <Collapse open={isOpen} onOpenChange={setIsOpen} trigger={<strong>Toggle</strong>}>\n * <p>Content</p>\n * </Collapse>\n *\n * @example\n * // With callbacks\n * <Collapse\n * trigger={<button>Toggle</button>}\n * onOpen={() => console.log('Opened!')}\n * onClose={() => console.log('Closed!')}\n * >\n * <p>Content</p>\n * </Collapse>\n */\nexport const Collapse: React.FC<CollapseProps> = ({\n open: controlledOpen,\n defaultOpen = false,\n onOpen,\n onClose,\n onOpenChange,\n trigger,\n animation = 'fade',\n position = 'top',\n ariaId,\n bordered,\n children,\n className,\n triggerClassName,\n contentClassName,\n ...props\n}) => {\n const { bulmaHelperClasses, rest } = useBulmaClasses(props);\n const contentRef = useRef<HTMLDivElement>(null);\n\n // Three possible owners of the open state, in order: the caller when `open`\n // is set, an enclosing Collapses group, and this Collapse itself. A caller's\n // `open` wins over the group, which is how the group leaves such an item\n // alone.\n const isControlled = controlledOpen !== undefined;\n const group = useContext(CollapsesItemContext);\n const groupItem = isControlled ? null : group;\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const isOpen = controlledOpen ?? groupItem?.open ?? internalOpen;\n\n // A group owns the state of the items it manages, so these props do\n // nothing there. That is easy to miss, so development says which ones and\n // what to use instead, once per combination (the way Avatar keys its\n // warning), and `warnOnce` keeps production silent.\n if (groupItem) {\n const ignored = [\n defaultOpen && 'defaultOpen',\n onOpen && 'onOpen',\n onClose && 'onClose',\n ].filter((name): name is string => Boolean(name));\n if (ignored.length > 0) {\n const callbacks = ignored.filter(name => name !== 'defaultOpen');\n warnOnce(\n `Collapse:ignored-in-Collapses:${ignored.join('+')}`,\n `[bestax-bulma] <Collapse ${ignored.join(' ')}> inside <Collapses>: ` +\n [\n ignored.includes('defaultOpen') &&\n `defaultOpen has no effect, because the group decides which ` +\n `items start open. Pass the item's index in the group's ` +\n `defaultValue instead.`,\n callbacks.length > 0 &&\n `${callbacks.join(' and ')} never fire${callbacks.length > 1 ? '' : 's'}, ` +\n `because the group holds the item's open state. Use the ` +\n `item's onOpenChange, or the group's onChange, instead.`,\n ]\n .filter(Boolean)\n .join(' ')\n );\n }\n }\n\n // Start from the resolved state rather than `defaultOpen`, so an item that\n // mounts open through `open` or a group is not first painted (or rendered\n // on the server) at height 0 under the slide animation.\n const [height, setHeight] = useState<number | 'auto'>(isOpen ? 'auto' : 0);\n\n // Generate unique ID for accessibility (useId is SSR-safe and stable across\n // renders; works in React 18 and 19).\n const generatedId = useId();\n const uniqueId = ariaId || generatedId;\n\n // Update height when open state changes (for 'slide' animation)\n useEffect(() => {\n if (!contentRef.current) return undefined;\n if (animation !== 'slide') return undefined;\n\n if (isOpen) {\n // Opening: set height to content's scrollHeight\n const contentHeight = contentRef.current.scrollHeight;\n setHeight(contentHeight);\n\n // After animation completes, set to auto for dynamic content\n const timer = setTimeout(() => {\n setHeight('auto');\n }, 300); // Match CSS transition duration\n return () => clearTimeout(timer);\n } else {\n // Closing: first set to current height, then to 0\n if (height === 'auto') {\n // Read scrollHeight and offsetHeight to capture the current size and\n // force a layout flush, then schedule the height transition to 0.\n // (Reading offsetHeight after assignment is the standard reflow trick;\n // assigning into a state setter avoids a bare expression statement.)\n const currentHeight = contentRef.current.scrollHeight;\n const reflowHeight = contentRef.current.offsetHeight;\n setHeight(Math.max(currentHeight, reflowHeight));\n requestAnimationFrame(() => {\n setHeight(0);\n });\n } else {\n setHeight(0);\n }\n }\n return undefined;\n // `height` is read here but is an output of this effect; re-running when it\n // changes would re-trigger the open/close animation, so it's intentionally\n // excluded from the deps.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isOpen, animation]);\n\n // The trigger reports in every mode, then changes only the state this\n // Collapse owns. `onOpen`/`onClose` belong to that last case alone.\n const handleToggle = useCallback(() => {\n const next = !isOpen;\n onOpenChange?.(next);\n if (isControlled) return;\n if (groupItem) {\n groupItem.setOpen(next);\n return;\n }\n setInternalOpen(next);\n if (next) {\n onOpen?.();\n } else {\n onClose?.();\n }\n }, [isOpen, isControlled, groupItem, onOpenChange, onOpen, onClose]);\n\n // Handle keyboard interaction\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n handleToggle();\n }\n },\n [handleToggle]\n );\n\n // Generate Bulma classes\n const collapseClasses = usePrefixedClassNames('collapse', {\n 'is-active': isOpen,\n 'is-bordered': bordered,\n });\n\n const combinedClasses = classNames(\n collapseClasses,\n bulmaHelperClasses,\n className\n );\n const combinedTriggerClasses = classNames(\n usePrefixedClassNames('collapse-trigger'),\n triggerClassName\n );\n const combinedContentClasses = classNames(\n usePrefixedClassNames('collapse-content', {\n 'is-active': isOpen,\n }),\n contentClassName\n );\n\n // Content wrapper styles based on animation type\n let contentWrapperStyle: React.CSSProperties;\n\n if (animation === 'slide') {\n contentWrapperStyle = {\n height: height === 'auto' ? 'auto' : `${height}px`,\n overflow: 'hidden',\n transition: 'height 0.3s ease-in-out',\n };\n } else if (animation === 'fade') {\n contentWrapperStyle = {\n opacity: isOpen ? 1 : 0,\n overflow: 'hidden',\n height: isOpen ? 'auto' : 0,\n transition: 'opacity 0.3s ease-in-out',\n };\n } else {\n contentWrapperStyle = {\n display: isOpen ? 'block' : 'none',\n };\n }\n\n const triggerElement = (\n <div\n className={combinedTriggerClasses}\n onClick={handleToggle}\n onKeyDown={handleKeyDown}\n role=\"button\"\n tabIndex={0}\n aria-expanded={isOpen}\n aria-controls={uniqueId}\n >\n {trigger}\n </div>\n );\n\n const contentElement = (\n <div style={contentWrapperStyle}>\n {/* A closed panel under `fade` or `slide` is only squeezed to height 0,\n so its links and fields would stay in the tab order. `inert` takes\n them out (and from pointer and find-in-page), matching\n `aria-hidden`, and costs the animations nothing. */}\n <div\n ref={contentRef}\n id={uniqueId}\n className={combinedContentClasses}\n aria-hidden={!isOpen}\n {...inertProps(!isOpen)}\n >\n {children}\n </div>\n </div>\n );\n\n // The group's item context stops here: a Collapse nested in this one's\n // content is not an item of this one's group.\n return (\n <CollapsesItemContext.Provider value={null}>\n <div className={combinedClasses} {...rest}>\n {position === 'bottom' ? (\n <>\n {contentElement}\n {triggerElement}\n </>\n ) : (\n <>\n {triggerElement}\n {contentElement}\n </>\n )}\n </div>\n </CollapsesItemContext.Provider>\n );\n};\n\nexport default Collapse;\n"],"names":["_jsx","_jsxs","_Fragment"],"mappings":";;;;;;;;;AAyDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BG;MACU,QAAQ,GAA4B,CAAC,EAChD,IAAI,EAAE,cAAc,EACpB,WAAW,GAAG,KAAK,EACnB,MAAM,EACN,OAAO,EACP,YAAY,EACZ,OAAO,EACP,SAAS,GAAG,MAAM,EAClB,QAAQ,GAAG,KAAK,EAChB,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,GAAG,KAAK,EACT,KAAI;IACH,MAAM,EAAE,kBAAkB,EAAE,IAAI,EAAE,GAAG,eAAe,CAAC,KAAK,CAAC;AAC3D,IAAA,MAAM,UAAU,GAAG,MAAM,CAAiB,IAAI,CAAC;;;;;AAM/C,IAAA,MAAM,YAAY,GAAG,cAAc,KAAK,SAAS;AACjD,IAAA,MAAM,KAAK,GAAG,UAAU,CAAC,oBAAoB,CAAC;IAC9C,MAAM,SAAS,GAAG,YAAY,GAAG,IAAI,GAAG,KAAK;IAC7C,MAAM,CAAC,YAAY,EAAE,eAAe,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|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/* @allxsmith/bestax-bulma — AI agents: see AGENTS.md in the package root, or https://bestax.io/llms.txt */
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import React, { useState } from 'react';
|
|
4
|
+
import { usePrefixedClassNames, classNames } from '../helpers/classNames.js';
|
|
5
|
+
import { withSubComponents } from '../helpers/withSubComponents.js';
|
|
6
|
+
import { useBulmaClasses } from '../helpers/useBulmaClasses.js';
|
|
7
|
+
import { Collapse } from './Collapse.js';
|
|
8
|
+
import { CollapsesItemContext } from './collapsesContext.js';
|
|
9
|
+
|
|
10
|
+
/** Either mode's value as the list of open indexes. */
|
|
11
|
+
function toIndexes(value) {
|
|
12
|
+
if (Array.isArray(value))
|
|
13
|
+
return value;
|
|
14
|
+
return typeof value === 'number' ? [value] : [];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Flattens Fragment children (recursively) so each item inside one gets its
|
|
18
|
+
* own index rather than sharing the fragment's. Children.toArray keys restart
|
|
19
|
+
* at ".0" inside each fragment, so those children are re-keyed with the
|
|
20
|
+
* fragment's own key as a prefix, the way Avatars does it.
|
|
21
|
+
*/
|
|
22
|
+
function flattenChildren(children, keyPrefix = '') {
|
|
23
|
+
return React.Children.toArray(children).flatMap(child => {
|
|
24
|
+
if (!React.isValidElement(child))
|
|
25
|
+
return [child];
|
|
26
|
+
if (child.type === React.Fragment) {
|
|
27
|
+
return flattenChildren(child.props.children, keyPrefix + child.key);
|
|
28
|
+
}
|
|
29
|
+
return [
|
|
30
|
+
keyPrefix
|
|
31
|
+
? React.cloneElement(child, { key: keyPrefix + child.key })
|
|
32
|
+
: child,
|
|
33
|
+
];
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The `Collapses` component groups `Collapse` items into an accordion that keeps one item open at a time, or any number with `multiple`.
|
|
38
|
+
*
|
|
39
|
+
* @function
|
|
40
|
+
* @param {CollapsesProps} props - Props for the Collapses component.
|
|
41
|
+
* @returns {JSX.Element} The rendered group.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* // Accordion: one item open at a time, the first to start with
|
|
45
|
+
* <Collapses defaultValue={0}>
|
|
46
|
+
* <Collapse bordered trigger={<strong>Shipping</strong>}>…</Collapse>
|
|
47
|
+
* <Collapse bordered trigger={<strong>Returns</strong>}>…</Collapse>
|
|
48
|
+
* </Collapses>
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* // Controlled, with items that open independently
|
|
52
|
+
* const [open, setOpen] = useState<number[]>([]);
|
|
53
|
+
* <Collapses multiple value={open} onChange={setOpen}>…</Collapses>
|
|
54
|
+
*/
|
|
55
|
+
const CollapsesComponent = ({ multiple = false, value, defaultValue, onChange, seamless = false, className, children, ...props }) => {
|
|
56
|
+
const { bulmaHelperClasses, rest } = useBulmaClasses({ ...props });
|
|
57
|
+
// Controlled vs uncontrolled, as in Tabs. State is held as a list of open
|
|
58
|
+
// indexes in both modes; `multiple` only decides how a change is computed
|
|
59
|
+
// and which shape `onChange` receives.
|
|
60
|
+
const isControlled = value !== undefined;
|
|
61
|
+
const [internalOpen, setInternalOpen] = useState(() => toIndexes(defaultValue));
|
|
62
|
+
const openIndexes = isControlled ? toIndexes(value) : internalOpen;
|
|
63
|
+
// Each mode types `onChange` for its own shape, and the value built below
|
|
64
|
+
// always matches `multiple`, the union's discriminant.
|
|
65
|
+
const reportChange = onChange;
|
|
66
|
+
const setItemOpen = (index, open) => {
|
|
67
|
+
const others = openIndexes.filter(i => i !== index);
|
|
68
|
+
// Single mode keeps at most one item open, so opening one drops the rest.
|
|
69
|
+
// Ascending order, whatever order the items were opened in, so the value
|
|
70
|
+
// reads and compares the same way however the user got there.
|
|
71
|
+
const next = (open ? (multiple ? [...others, index] : [index]) : others).sort((a, b) => a - b);
|
|
72
|
+
if (!isControlled)
|
|
73
|
+
setInternalOpen(next);
|
|
74
|
+
reportChange?.(multiple ? next : (next[0] ?? null));
|
|
75
|
+
};
|
|
76
|
+
const groupClasses = usePrefixedClassNames('collapses', {
|
|
77
|
+
'is-seamless': seamless,
|
|
78
|
+
});
|
|
79
|
+
const combinedClasses = classNames(groupClasses, bulmaHelperClasses, className);
|
|
80
|
+
const items = [];
|
|
81
|
+
let index = 0;
|
|
82
|
+
for (const child of flattenChildren(children)) {
|
|
83
|
+
if (!React.isValidElement(child)) {
|
|
84
|
+
items.push(child);
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
const itemIndex = index;
|
|
88
|
+
index += 1;
|
|
89
|
+
items.push(jsx(CollapsesItemContext.Provider, { value: {
|
|
90
|
+
open: openIndexes.includes(itemIndex),
|
|
91
|
+
setOpen: open => setItemOpen(itemIndex, open),
|
|
92
|
+
}, children: child }, child.key));
|
|
93
|
+
}
|
|
94
|
+
return (jsx("div", { className: combinedClasses, ...rest, children: items }));
|
|
95
|
+
};
|
|
96
|
+
const Collapses = withSubComponents(CollapsesComponent, { Collapse }, 'Collapses');
|
|
97
|
+
|
|
98
|
+
export { Collapses };
|
|
99
|
+
//# sourceMappingURL=Collapses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Collapses.js","sources":["../../../src/components/Collapses.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { classNames, usePrefixedClassNames } from '../helpers/classNames';\nimport { withSubComponents } from '../helpers/withSubComponents';\nimport { useBulmaClasses, BulmaClassesProps } from '../helpers/useBulmaClasses';\nimport { Collapse } from './Collapse';\nimport { CollapsesItemContext } from './collapsesContext';\n\n/**\n * Props shared by both modes of the Collapses component.\n */\ninterface CollapsesBaseProps\n extends\n Omit<\n React.HTMLAttributes<HTMLDivElement>,\n 'color' | 'defaultValue' | 'onChange'\n >,\n Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {\n /** Joins the items into one block, with no gap between them and only the outer corners rounded. The joins show on `bordered` items. */\n seamless?: boolean;\n /** Additional CSS classes to apply. */\n className?: string;\n /** The `Collapse` items. Each child element is one item, indexed from 0 in order, with the children of a fragment counted one by one. A child that sets its own `open` keeps it: the group leaves that item alone. */\n children?: React.ReactNode;\n}\n\n/**\n * Props for Collapses in single mode, the accordion: opening one item closes the others.\n */\nexport interface CollapsesSingleProps extends CollapsesBaseProps {\n /**\n * Lets items open independently. Without it, opening one item closes the others.\n * @defaultValue false\n */\n multiple?: false;\n /** Controlled open items: the index of the open item, or `null` for none. With `multiple`, an array of indexes. An index is a position among the children, so rendering an item conditionally or reordering them moves the open state onto a neighbour: render every item and hide one with `visibility=\"hidden\"`, or keep `value` in step yourself. */\n value?: number | null;\n /** Open items for uncontrolled use, as an index or `null` (the default, none open). With `multiple`, an array of indexes, empty by default. Indexes are positions among the children, as for `value`. */\n defaultValue?: number | null;\n /** Called with the new open items each time a trigger asks for a change, whether or not `value` is set: an index or `null`, or with `multiple` an array of indexes in ascending order. Indexes are positions among the children, as for `value`. */\n onChange?: (value: number | null) => void;\n}\n\n/**\n * Props for Collapses with `multiple`: items open and close independently.\n */\nexport interface CollapsesMultipleProps extends CollapsesBaseProps {\n /**\n * Lets items open independently. Without it, opening one item closes the others.\n * @defaultValue false\n */\n multiple: true;\n /** Controlled open items: the index of the open item, or `null` for none. With `multiple`, an array of indexes. An index is a position among the children, so rendering an item conditionally or reordering them moves the open state onto a neighbour: render every item and hide one with `visibility=\"hidden\"`, or keep `value` in step yourself. */\n value?: number[];\n /** Open items for uncontrolled use, as an index or `null` (the default, none open). With `multiple`, an array of indexes, empty by default. Indexes are positions among the children, as for `value`. */\n defaultValue?: number[];\n /** Called with the new open items each time a trigger asks for a change, whether or not `value` is set: an index or `null`, or with `multiple` an array of indexes in ascending order. Indexes are positions among the children, as for `value`. */\n onChange?: (value: number[]) => void;\n}\n\n/**\n * Props for the Collapses component, a discriminated union on `multiple`: the open items are an index (or `null`) in single mode and an array of indexes with `multiple`.\n */\nexport type CollapsesProps = CollapsesSingleProps | CollapsesMultipleProps;\n\n/** Either mode's value as the list of open indexes. */\nfunction toIndexes(value: number | number[] | null | undefined): number[] {\n if (Array.isArray(value)) return value;\n return typeof value === 'number' ? [value] : [];\n}\n\n/**\n * Flattens Fragment children (recursively) so each item inside one gets its\n * own index rather than sharing the fragment's. Children.toArray keys restart\n * at \".0\" inside each fragment, so those children are re-keyed with the\n * fragment's own key as a prefix, the way Avatars does it.\n */\nfunction flattenChildren(\n children: React.ReactNode,\n keyPrefix = ''\n): React.ReactNode[] {\n return React.Children.toArray(children).flatMap(child => {\n if (!React.isValidElement(child)) return [child];\n if (child.type === React.Fragment) {\n return flattenChildren(\n (child.props as { children?: React.ReactNode }).children,\n keyPrefix + child.key\n );\n }\n return [\n keyPrefix\n ? React.cloneElement(child, { key: keyPrefix + child.key })\n : child,\n ];\n });\n}\n\n/**\n * The `Collapses` component groups `Collapse` items into an accordion that keeps one item open at a time, or any number with `multiple`.\n *\n * @function\n * @param {CollapsesProps} props - Props for the Collapses component.\n * @returns {JSX.Element} The rendered group.\n *\n * @example\n * // Accordion: one item open at a time, the first to start with\n * <Collapses defaultValue={0}>\n * <Collapse bordered trigger={<strong>Shipping</strong>}>…</Collapse>\n * <Collapse bordered trigger={<strong>Returns</strong>}>…</Collapse>\n * </Collapses>\n *\n * @example\n * // Controlled, with items that open independently\n * const [open, setOpen] = useState<number[]>([]);\n * <Collapses multiple value={open} onChange={setOpen}>…</Collapses>\n */\nconst CollapsesComponent: React.FC<CollapsesProps> = ({\n multiple = false,\n value,\n defaultValue,\n onChange,\n seamless = false,\n className,\n children,\n ...props\n}) => {\n const { bulmaHelperClasses, rest } = useBulmaClasses({ ...props });\n\n // Controlled vs uncontrolled, as in Tabs. State is held as a list of open\n // indexes in both modes; `multiple` only decides how a change is computed\n // and which shape `onChange` receives.\n const isControlled = value !== undefined;\n const [internalOpen, setInternalOpen] = useState(() =>\n toIndexes(defaultValue)\n );\n const openIndexes = isControlled ? toIndexes(value) : internalOpen;\n\n // Each mode types `onChange` for its own shape, and the value built below\n // always matches `multiple`, the union's discriminant.\n const reportChange = onChange as\n ((next: number | number[] | null) => void) | undefined;\n\n const setItemOpen = (index: number, open: boolean) => {\n const others = openIndexes.filter(i => i !== index);\n // Single mode keeps at most one item open, so opening one drops the rest.\n // Ascending order, whatever order the items were opened in, so the value\n // reads and compares the same way however the user got there.\n const next = (\n open ? (multiple ? [...others, index] : [index]) : others\n ).sort((a, b) => a - b);\n if (!isControlled) setInternalOpen(next);\n reportChange?.(multiple ? next : (next[0] ?? null));\n };\n\n const groupClasses = usePrefixedClassNames('collapses', {\n 'is-seamless': seamless,\n });\n const combinedClasses = classNames(\n groupClasses,\n bulmaHelperClasses,\n className\n );\n\n const items: React.ReactNode[] = [];\n let index = 0;\n for (const child of flattenChildren(children)) {\n if (!React.isValidElement(child)) {\n items.push(child);\n continue;\n }\n const itemIndex = index;\n index += 1;\n items.push(\n <CollapsesItemContext.Provider\n key={child.key}\n value={{\n open: openIndexes.includes(itemIndex),\n setOpen: open => setItemOpen(itemIndex, open),\n }}\n >\n {child}\n </CollapsesItemContext.Provider>\n );\n }\n\n return (\n <div className={combinedClasses} {...rest}>\n {items}\n </div>\n );\n};\n\nexport const Collapses = withSubComponents(\n CollapsesComponent,\n { Collapse },\n 'Collapses'\n);\n\nexport default Collapses;\n"],"names":["_jsx"],"mappings":";;;;;;;;;AAgEA;AACA,SAAS,SAAS,CAAC,KAA2C,EAAA;AAC5D,IAAA,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;AAAE,QAAA,OAAO,KAAK;AACtC,IAAA,OAAO,OAAO,KAAK,KAAK,QAAQ,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE;AACjD;AAEA;;;;;AAKG;AACH,SAAS,eAAe,CACtB,QAAyB,EACzB,SAAS,GAAG,EAAE,EAAA;AAEd,IAAA,OAAO,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,KAAK,IAAG;AACtD,QAAA,IAAI,CAAC,KAAK,CAAC,cAAc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WAAW;;"}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/* @allxsmith/bestax-bulma — AI agents: see AGENTS.md in the package root, or https://bestax.io/llms.txt */
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { forwardRef, useRef, useCallback, useEffect, useSyncExternalStore } from 'react';
|
|
4
|
+
import { usePrefixedClassNames, classNames } from '../helpers/classNames.js';
|
|
5
|
+
import { useBulmaClasses } from '../helpers/useBulmaClasses.js';
|
|
6
|
+
import { useIsHydrated } from '../helpers/useIsHydrated.js';
|
|
7
|
+
import { Modal } from './Modal.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The `Dialog` component provides ready-made confirm and alert dialogs, so a destructive action stays one `await dialog.confirm()` call away.
|
|
11
|
+
*
|
|
12
|
+
* @function
|
|
13
|
+
* @param {DialogProps} props - Props for the Dialog component.
|
|
14
|
+
* @param {React.Ref<HTMLDivElement>} ref - Forwarded ref to the dialog element.
|
|
15
|
+
* @returns {JSX.Element | null} The rendered dialog component.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Alert dialog
|
|
19
|
+
* <Dialog
|
|
20
|
+
* isOpen={showAlert}
|
|
21
|
+
* title="Success"
|
|
22
|
+
* message="Operation completed successfully!"
|
|
23
|
+
* type="success"
|
|
24
|
+
* onConfirm={() => setShowAlert(false)}
|
|
25
|
+
* showCancel={false}
|
|
26
|
+
* />
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* // Confirm dialog
|
|
30
|
+
* <Dialog
|
|
31
|
+
* isOpen={showConfirm}
|
|
32
|
+
* title="Delete Item?"
|
|
33
|
+
* message="This action cannot be undone."
|
|
34
|
+
* type="danger"
|
|
35
|
+
* confirmText="Delete"
|
|
36
|
+
* onConfirm={handleDelete}
|
|
37
|
+
* onCancel={() => setShowConfirm(false)}
|
|
38
|
+
* />
|
|
39
|
+
*/
|
|
40
|
+
const Dialog = forwardRef(({ isOpen, title, message, type = 'default', confirmText = 'OK', cancelText = 'Cancel', onConfirm, onCancel, showCancel = true, canCancel = true, focusCancel = false, icon, portal, className, ...props }, ref) => {
|
|
41
|
+
const { bulmaHelperClasses, rest } = useBulmaClasses(props);
|
|
42
|
+
const dialogRef = useRef(null);
|
|
43
|
+
// Cleanup returned by a consumer's callback ref on attach, held until detach.
|
|
44
|
+
const consumerCleanupRef = useRef(null);
|
|
45
|
+
const confirmRef = useRef(null);
|
|
46
|
+
const cancelRef = useRef(null);
|
|
47
|
+
// Handle cancel
|
|
48
|
+
const handleCancel = useCallback(() => {
|
|
49
|
+
if (canCancel) {
|
|
50
|
+
onCancel?.();
|
|
51
|
+
}
|
|
52
|
+
}, [canCancel, onCancel]);
|
|
53
|
+
// Handle confirm
|
|
54
|
+
const handleConfirm = useCallback(() => {
|
|
55
|
+
onConfirm?.();
|
|
56
|
+
}, [onConfirm]);
|
|
57
|
+
// Handle background click
|
|
58
|
+
const handleBackgroundClick = useCallback(() => {
|
|
59
|
+
if (canCancel) {
|
|
60
|
+
handleCancel();
|
|
61
|
+
}
|
|
62
|
+
}, [canCancel, handleCancel]);
|
|
63
|
+
// Moving into the portal remounts the Modal's subtree — these buttons
|
|
64
|
+
// included — so the focus effect below has to re-run against the new
|
|
65
|
+
// nodes, exactly as the Modal's own focus effect does.
|
|
66
|
+
const isHydrated = useIsHydrated();
|
|
67
|
+
const isPortaled = Boolean(portal) && isHydrated;
|
|
68
|
+
// Focus management — Dialog picks a specific button rather than the
|
|
69
|
+
// Modal's default (first focusable/root); this effect runs after the
|
|
70
|
+
// inner Modal's own focus-on-open effect, so it wins.
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if (isOpen) {
|
|
73
|
+
const buttonToFocus = focusCancel && showCancel ? cancelRef.current : confirmRef.current;
|
|
74
|
+
buttonToFocus?.focus();
|
|
75
|
+
}
|
|
76
|
+
}, [isOpen, focusCancel, showCancel, isPortaled]);
|
|
77
|
+
// Use combined ref
|
|
78
|
+
const combinedRef = useCallback((node) => {
|
|
79
|
+
dialogRef.current =
|
|
80
|
+
node;
|
|
81
|
+
if (typeof ref === 'function') {
|
|
82
|
+
// React 19 lets a callback ref return a cleanup function and detaches by
|
|
83
|
+
// running it instead of calling the ref with `null`; React 18 discards the
|
|
84
|
+
// return value entirely. Returning it from here would be a React-19-only
|
|
85
|
+
// contract, so we hold the cleanup and run it ourselves on detach — the
|
|
86
|
+
// same shape as `Dropdown`, `Modal`, `Sidebar`, `Toast` and `Carousel`.
|
|
87
|
+
// The form controls that merge a forwarded ref still discard the cleanup
|
|
88
|
+
// and detach with `ref(null)`, so this is not yet library-wide — grep
|
|
89
|
+
// `typeof ref === 'function'` for the current split.
|
|
90
|
+
if (node === null) {
|
|
91
|
+
const consumerCleanup = consumerCleanupRef.current;
|
|
92
|
+
consumerCleanupRef.current = null;
|
|
93
|
+
if (consumerCleanup) {
|
|
94
|
+
consumerCleanup();
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
ref(null);
|
|
98
|
+
}
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const cleanup = ref(node);
|
|
102
|
+
consumerCleanupRef.current =
|
|
103
|
+
typeof cleanup === 'function' ? cleanup : null;
|
|
104
|
+
}
|
|
105
|
+
else if (ref) {
|
|
106
|
+
ref.current = node;
|
|
107
|
+
}
|
|
108
|
+
}, [ref]);
|
|
109
|
+
// Generate classes
|
|
110
|
+
const dialogClasses = usePrefixedClassNames('dialog', {
|
|
111
|
+
[`is-${type}`]: type !== 'default',
|
|
112
|
+
});
|
|
113
|
+
const headerClass = usePrefixedClassNames('dialog-header');
|
|
114
|
+
const iconClass = usePrefixedClassNames('dialog-icon');
|
|
115
|
+
const titleClass = usePrefixedClassNames('dialog-title');
|
|
116
|
+
const bodyClass = usePrefixedClassNames('dialog-body');
|
|
117
|
+
const footerClass = usePrefixedClassNames('dialog-footer');
|
|
118
|
+
const cancelButtonClass = usePrefixedClassNames('button');
|
|
119
|
+
const confirmButtonClass = usePrefixedClassNames('button', {
|
|
120
|
+
'is-success': type === 'success',
|
|
121
|
+
'is-danger': type === 'danger',
|
|
122
|
+
'is-warning': type === 'warning',
|
|
123
|
+
'is-info': type === 'info',
|
|
124
|
+
'is-primary': type === 'default',
|
|
125
|
+
});
|
|
126
|
+
const combinedClasses = classNames(dialogClasses, bulmaHelperClasses, className);
|
|
127
|
+
// Get default icon based on type
|
|
128
|
+
const getDefaultIcon = () => {
|
|
129
|
+
switch (type) {
|
|
130
|
+
case 'success':
|
|
131
|
+
return (jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: jsx("path", { d: "M20 6L9 17l-5-5" }) }));
|
|
132
|
+
case 'danger':
|
|
133
|
+
return (jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [jsx("circle", { cx: "12", cy: "12", r: "10" }), jsx("line", { x1: "15", y1: "9", x2: "9", y2: "15" }), jsx("line", { x1: "9", y1: "9", x2: "15", y2: "15" })] }));
|
|
134
|
+
case 'warning':
|
|
135
|
+
return (jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", stroke: "none", children: jsx("path", { d: "M12 2L1 21h22L12 2zm0 3.99L19.53 19H4.47L12 5.99zM11 16h2v2h-2zm0-6h2v4h-2z" }) }));
|
|
136
|
+
case 'info':
|
|
137
|
+
return (jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", stroke: "none", children: jsx("path", { d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm-1-9h2v6h-2zm0-4h2v2h-2z" }) }));
|
|
138
|
+
default:
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
const displayIcon = icon !== undefined ? icon : getDefaultIcon();
|
|
143
|
+
if (!isOpen) {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
return (jsxs(Modal, { isActive: isOpen, onClose: handleCancel, role: "presentation", portal: portal, children: [jsx(Modal.Background, { onClick: handleBackgroundClick }), jsxs("div", { ref: combinedRef, className: combinedClasses, role: "alertdialog", "aria-modal": "true", "aria-labelledby": title ? 'dialog-title' : undefined, "aria-describedby": "dialog-message", ...rest, children: [title && (jsxs("div", { className: headerClass, children: [displayIcon && jsx("span", { className: iconClass, children: displayIcon }), jsx("h3", { id: "dialog-title", className: titleClass, children: title })] })), jsx("div", { id: "dialog-message", className: bodyClass, children: message }), jsxs("div", { className: footerClass, children: [showCancel && (jsx("button", { ref: cancelRef, type: "button", className: cancelButtonClass, onClick: handleCancel, children: cancelText })), jsx("button", { ref: confirmRef, type: "button", className: confirmButtonClass, onClick: handleConfirm, children: confirmText })] })] })] }));
|
|
147
|
+
});
|
|
148
|
+
Dialog.displayName = 'Dialog';
|
|
149
|
+
let dialogListeners = new Set();
|
|
150
|
+
let currentDialog = null;
|
|
151
|
+
// DialogContainer renders from the open dialog rather than from updates alone,
|
|
152
|
+
// so a dialog raised before it mounted still opens once it does.
|
|
153
|
+
const getCurrentDialog = () => currentDialog;
|
|
154
|
+
// The server renders no dialog: its copy of this module is shared by every
|
|
155
|
+
// request, so the dialog it holds may belong to another page. Hydration reads
|
|
156
|
+
// the same empty value, which keeps the first client render matching the
|
|
157
|
+
// server's, and the dialog opens right after.
|
|
158
|
+
const getServerDialog = () => null;
|
|
159
|
+
const notifyDialogListeners = () => {
|
|
160
|
+
dialogListeners.forEach(listener => listener(currentDialog));
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Programmatic dialog API for showing dialogs from anywhere.
|
|
164
|
+
*/
|
|
165
|
+
const dialog = {
|
|
166
|
+
/**
|
|
167
|
+
* Show an alert dialog. Returns a promise that resolves when closed.
|
|
168
|
+
*/
|
|
169
|
+
alert: (options) => {
|
|
170
|
+
return new Promise(resolve => {
|
|
171
|
+
const opts = typeof options === 'string' ? { message: options } : options;
|
|
172
|
+
currentDialog = {
|
|
173
|
+
type: 'alert',
|
|
174
|
+
options: opts,
|
|
175
|
+
resolve: () => resolve(),
|
|
176
|
+
};
|
|
177
|
+
notifyDialogListeners();
|
|
178
|
+
});
|
|
179
|
+
},
|
|
180
|
+
/**
|
|
181
|
+
* Show a confirm dialog. Returns a promise that resolves to true/false.
|
|
182
|
+
*/
|
|
183
|
+
confirm: (options) => {
|
|
184
|
+
return new Promise(resolve => {
|
|
185
|
+
const opts = typeof options === 'string' ? { message: options } : options;
|
|
186
|
+
currentDialog = {
|
|
187
|
+
type: 'confirm',
|
|
188
|
+
options: opts,
|
|
189
|
+
resolve: value => resolve(Boolean(value)),
|
|
190
|
+
};
|
|
191
|
+
notifyDialogListeners();
|
|
192
|
+
});
|
|
193
|
+
},
|
|
194
|
+
/**
|
|
195
|
+
* Close the current dialog.
|
|
196
|
+
*/
|
|
197
|
+
close: (value) => {
|
|
198
|
+
if (currentDialog) {
|
|
199
|
+
currentDialog.resolve(value);
|
|
200
|
+
currentDialog = null;
|
|
201
|
+
notifyDialogListeners();
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
/**
|
|
205
|
+
* Subscribe to dialog changes.
|
|
206
|
+
*/
|
|
207
|
+
subscribe: (listener) => {
|
|
208
|
+
dialogListeners.add(listener);
|
|
209
|
+
return () => dialogListeners.delete(listener);
|
|
210
|
+
},
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
* DialogContainer component to render programmatic dialogs.
|
|
214
|
+
* Place this once at the root of your app.
|
|
215
|
+
*
|
|
216
|
+
* @function
|
|
217
|
+
* @returns {JSX.Element | null} The rendered dialog, or null if none is active.
|
|
218
|
+
*/
|
|
219
|
+
const DialogContainer = () => {
|
|
220
|
+
// Starts from the dialog already open instead of none, then follows changes.
|
|
221
|
+
const current = useSyncExternalStore(dialog.subscribe, getCurrentDialog, getServerDialog);
|
|
222
|
+
if (!current) {
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
const { type, options } = current;
|
|
226
|
+
return (jsx(Dialog, { isOpen: true, title: options.title, message: options.message, type: options.type, confirmText: options.confirmText, cancelText: options.cancelText, icon: options.icon, showCancel: type === 'confirm', focusCancel: options.focusCancel, onConfirm: () => dialog.close(type === 'confirm' ? true : undefined), onCancel: () => dialog.close(type === 'confirm' ? false : undefined) }));
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
export { Dialog, DialogContainer, dialog };
|
|
230
|
+
//# sourceMappingURL=Dialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dialog.js","sources":["../../../src/components/Dialog.tsx"],"sourcesContent":["import React, {\n forwardRef,\n useCallback,\n useEffect,\n useRef,\n useSyncExternalStore,\n} from 'react';\nimport { classNames, usePrefixedClassNames } from '../helpers/classNames';\nimport { useBulmaClasses, BulmaClassesProps } from '../helpers/useBulmaClasses';\nimport { useIsHydrated } from '../helpers/useIsHydrated';\nimport { Modal } from './Modal';\n\n/** Valid dialog type/color values. */\nexport type DialogType = 'default' | 'success' | 'danger' | 'warning' | 'info';\n\n/**\n * Props for the Dialog component.\n * @extraProp {string} [className] - Additional CSS classes.\n * @extraProp {React.Ref<HTMLElement>} [ref] - Ref forwarded to the dialog element.\n */\nexport interface DialogProps\n extends\n Omit<React.HTMLAttributes<HTMLDivElement>, 'color'>,\n Omit<BulmaClassesProps, 'color'> {\n /** Whether the dialog is open (required). */\n isOpen: boolean;\n /** Dialog title. */\n title?: string;\n /** Dialog message/content (required). */\n message: string | React.ReactNode;\n /** The type/color of the dialog. Default: 'default'. */\n type?: DialogType;\n /** Text for confirm button. Default: 'OK'. */\n confirmText?: string;\n /** Text for cancel button. Default: 'Cancel'. */\n cancelText?: string;\n /** Callback when confirm button is clicked. */\n onConfirm?: () => void;\n /** Callback when cancel button is clicked or dismissed. */\n onCancel?: () => void;\n /** Whether to show cancel button. Default: true for confirm dialogs. */\n showCancel?: boolean;\n /** Whether the dialog can be dismissed. Default: true. */\n canCancel?: boolean;\n /** Focus cancel button instead of confirm. Default: false. */\n focusCancel?: boolean;\n /** Custom icon to display. */\n icon?: React.ReactNode;\n /**\n * Renders the dialog into a portal target instead of inline. Forwarded to\n * the underlying `Modal`; see its `portal` prop for the accepted values.\n * @defaultValue false\n */\n portal?: boolean | string | HTMLElement;\n}\n\n/**\n * The `Dialog` component provides ready-made confirm and alert dialogs, so a destructive action stays one `await dialog.confirm()` call away.\n *\n * @function\n * @param {DialogProps} props - Props for the Dialog component.\n * @param {React.Ref<HTMLDivElement>} ref - Forwarded ref to the dialog element.\n * @returns {JSX.Element | null} The rendered dialog component.\n *\n * @example\n * // Alert dialog\n * <Dialog\n * isOpen={showAlert}\n * title=\"Success\"\n * message=\"Operation completed successfully!\"\n * type=\"success\"\n * onConfirm={() => setShowAlert(false)}\n * showCancel={false}\n * />\n *\n * @example\n * // Confirm dialog\n * <Dialog\n * isOpen={showConfirm}\n * title=\"Delete Item?\"\n * message=\"This action cannot be undone.\"\n * type=\"danger\"\n * confirmText=\"Delete\"\n * onConfirm={handleDelete}\n * onCancel={() => setShowConfirm(false)}\n * />\n */\nexport const Dialog = forwardRef<HTMLDivElement, DialogProps>(\n (\n {\n isOpen,\n title,\n message,\n type = 'default',\n confirmText = 'OK',\n cancelText = 'Cancel',\n onConfirm,\n onCancel,\n showCancel = true,\n canCancel = true,\n focusCancel = false,\n icon,\n portal,\n className,\n ...props\n },\n ref\n ) => {\n const { bulmaHelperClasses, rest } = useBulmaClasses(props);\n const dialogRef = useRef<HTMLDivElement>(null);\n // Cleanup returned by a consumer's callback ref on attach, held until detach.\n const consumerCleanupRef = useRef<(() => void) | null>(null);\n const confirmRef = useRef<HTMLButtonElement>(null);\n const cancelRef = useRef<HTMLButtonElement>(null);\n\n // Handle cancel\n const handleCancel = useCallback(() => {\n if (canCancel) {\n onCancel?.();\n }\n }, [canCancel, onCancel]);\n\n // Handle confirm\n const handleConfirm = useCallback(() => {\n onConfirm?.();\n }, [onConfirm]);\n\n // Handle background click\n const handleBackgroundClick = useCallback(() => {\n if (canCancel) {\n handleCancel();\n }\n }, [canCancel, handleCancel]);\n\n // Moving into the portal remounts the Modal's subtree — these buttons\n // included — so the focus effect below has to re-run against the new\n // nodes, exactly as the Modal's own focus effect does.\n const isHydrated = useIsHydrated();\n const isPortaled = Boolean(portal) && isHydrated;\n\n // Focus management — Dialog picks a specific button rather than the\n // Modal's default (first focusable/root); this effect runs after the\n // inner Modal's own focus-on-open effect, so it wins.\n useEffect(() => {\n if (isOpen) {\n const buttonToFocus =\n focusCancel && showCancel ? cancelRef.current : confirmRef.current;\n buttonToFocus?.focus();\n }\n }, [isOpen, focusCancel, showCancel, isPortaled]);\n\n // Use combined ref\n const combinedRef = useCallback(\n (node: HTMLDivElement | null) => {\n (dialogRef as React.MutableRefObject<HTMLDivElement | null>).current =\n node;\n if (typeof ref === 'function') {\n // React 19 lets a callback ref return a cleanup function and detaches by\n // running it instead of calling the ref with `null`; React 18 discards the\n // return value entirely. Returning it from here would be a React-19-only\n // contract, so we hold the cleanup and run it ourselves on detach — the\n // same shape as `Dropdown`, `Modal`, `Sidebar`, `Toast` and `Carousel`.\n // The form controls that merge a forwarded ref still discard the cleanup\n // and detach with `ref(null)`, so this is not yet library-wide — grep\n // `typeof ref === 'function'` for the current split.\n if (node === null) {\n const consumerCleanup = consumerCleanupRef.current;\n consumerCleanupRef.current = null;\n if (consumerCleanup) {\n consumerCleanup();\n } else {\n ref(null);\n }\n return;\n }\n const cleanup: unknown = ref(node);\n consumerCleanupRef.current =\n typeof cleanup === 'function' ? (cleanup as () => void) : null;\n } else if (ref) {\n (ref as React.MutableRefObject<HTMLDivElement | null>).current = node;\n }\n },\n [ref]\n );\n\n // Generate classes\n const dialogClasses = usePrefixedClassNames('dialog', {\n [`is-${type}`]: type !== 'default',\n });\n const headerClass = usePrefixedClassNames('dialog-header');\n const iconClass = usePrefixedClassNames('dialog-icon');\n const titleClass = usePrefixedClassNames('dialog-title');\n const bodyClass = usePrefixedClassNames('dialog-body');\n const footerClass = usePrefixedClassNames('dialog-footer');\n const cancelButtonClass = usePrefixedClassNames('button');\n const confirmButtonClass = usePrefixedClassNames('button', {\n 'is-success': type === 'success',\n 'is-danger': type === 'danger',\n 'is-warning': type === 'warning',\n 'is-info': type === 'info',\n 'is-primary': type === 'default',\n });\n\n const combinedClasses = classNames(\n dialogClasses,\n bulmaHelperClasses,\n className\n );\n\n // Get default icon based on type\n const getDefaultIcon = () => {\n switch (type) {\n case 'success':\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n >\n <path d=\"M20 6L9 17l-5-5\" />\n </svg>\n );\n case 'danger':\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <line x1=\"15\" y1=\"9\" x2=\"9\" y2=\"15\" />\n <line x1=\"9\" y1=\"9\" x2=\"15\" y2=\"15\" />\n </svg>\n );\n case 'warning':\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"currentColor\"\n stroke=\"none\"\n >\n <path d=\"M12 2L1 21h22L12 2zm0 3.99L19.53 19H4.47L12 5.99zM11 16h2v2h-2zm0-6h2v4h-2z\" />\n </svg>\n );\n case 'info':\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"currentColor\"\n stroke=\"none\"\n >\n <path d=\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm-1-9h2v6h-2zm0-4h2v2h-2z\" />\n </svg>\n );\n default:\n return null;\n }\n };\n\n const displayIcon = icon !== undefined ? icon : getDefaultIcon();\n\n if (!isOpen) {\n return null;\n }\n\n return (\n <Modal\n isActive={isOpen}\n onClose={handleCancel}\n role=\"presentation\"\n portal={portal}\n >\n <Modal.Background onClick={handleBackgroundClick} />\n <div\n ref={combinedRef}\n className={combinedClasses}\n role=\"alertdialog\"\n aria-modal=\"true\"\n aria-labelledby={title ? 'dialog-title' : undefined}\n aria-describedby=\"dialog-message\"\n {...rest}\n >\n {title && (\n <div className={headerClass}>\n {displayIcon && <span className={iconClass}>{displayIcon}</span>}\n <h3 id=\"dialog-title\" className={titleClass}>\n {title}\n </h3>\n </div>\n )}\n <div id=\"dialog-message\" className={bodyClass}>\n {message}\n </div>\n <div className={footerClass}>\n {showCancel && (\n <button\n ref={cancelRef}\n type=\"button\"\n className={cancelButtonClass}\n onClick={handleCancel}\n >\n {cancelText}\n </button>\n )}\n <button\n ref={confirmRef}\n type=\"button\"\n className={confirmButtonClass}\n onClick={handleConfirm}\n >\n {confirmText}\n </button>\n </div>\n </div>\n </Modal>\n );\n }\n);\n\nDialog.displayName = 'Dialog';\n\n// Dialog Manager for programmatic dialogs\n\n/**\n * Options for showing a programmatic alert dialog.\n */\nexport interface AlertOptions {\n /** Dialog title. */\n title?: string;\n /** Dialog message/content. */\n message: string | React.ReactNode;\n /** Dialog type/color. */\n type?: DialogType;\n /** Text for the confirm button. */\n confirmText?: string;\n /** Custom icon to display. */\n icon?: React.ReactNode;\n}\n\n/**\n * Options for showing a programmatic confirm dialog.\n */\nexport interface ConfirmOptions extends AlertOptions {\n /** Text for the cancel button. */\n cancelText?: string;\n /** Focus cancel button instead of confirm. */\n focusCancel?: boolean;\n}\n\n/**\n * Options for showing a programmatic prompt dialog.\n */\nexport interface PromptOptions extends ConfirmOptions {\n /** Input placeholder text. */\n placeholder?: string;\n /** Default input value. */\n defaultValue?: string;\n}\n\ntype DialogResolve = (value?: void | boolean | string) => void;\n\ntype DialogState = {\n type: 'alert' | 'confirm' | 'prompt';\n options: PromptOptions;\n resolve: DialogResolve;\n};\n\nlet dialogListeners: Set<(dialog: DialogState | null) => void> = new Set();\nlet currentDialog: DialogState | null = null;\n\n// DialogContainer renders from the open dialog rather than from updates alone,\n// so a dialog raised before it mounted still opens once it does.\nconst getCurrentDialog = () => currentDialog;\n\n// The server renders no dialog: its copy of this module is shared by every\n// request, so the dialog it holds may belong to another page. Hydration reads\n// the same empty value, which keeps the first client render matching the\n// server's, and the dialog opens right after.\nconst getServerDialog = (): DialogState | null => null;\n\nconst notifyDialogListeners = () => {\n dialogListeners.forEach(listener => listener(currentDialog));\n};\n\n/**\n * Programmatic dialog API for showing dialogs from anywhere.\n */\nexport const dialog = {\n /**\n * Show an alert dialog. Returns a promise that resolves when closed.\n */\n alert: (options: AlertOptions | string): Promise<void> => {\n return new Promise<void>(resolve => {\n const opts = typeof options === 'string' ? { message: options } : options;\n currentDialog = {\n type: 'alert',\n options: opts,\n resolve: () => resolve(),\n };\n notifyDialogListeners();\n });\n },\n\n /**\n * Show a confirm dialog. Returns a promise that resolves to true/false.\n */\n confirm: (options: ConfirmOptions | string): Promise<boolean> => {\n return new Promise<boolean>(resolve => {\n const opts = typeof options === 'string' ? { message: options } : options;\n currentDialog = {\n type: 'confirm',\n options: opts,\n resolve: value => resolve(Boolean(value)),\n };\n notifyDialogListeners();\n });\n },\n\n /**\n * Close the current dialog.\n */\n close: (value?: void | boolean | string): void => {\n if (currentDialog) {\n currentDialog.resolve(value);\n currentDialog = null;\n notifyDialogListeners();\n }\n },\n\n /**\n * Subscribe to dialog changes.\n */\n subscribe: (listener: (dialog: DialogState | null) => void): (() => void) => {\n dialogListeners.add(listener);\n return () => dialogListeners.delete(listener);\n },\n};\n\n/**\n * DialogContainer component to render programmatic dialogs.\n * Place this once at the root of your app.\n *\n * @function\n * @returns {JSX.Element | null} The rendered dialog, or null if none is active.\n */\nexport const DialogContainer: React.FC = () => {\n // Starts from the dialog already open instead of none, then follows changes.\n const current = useSyncExternalStore(\n dialog.subscribe,\n getCurrentDialog,\n getServerDialog\n );\n\n if (!current) {\n return null;\n }\n\n const { type, options } = current;\n\n return (\n <Dialog\n isOpen\n title={options.title}\n message={options.message}\n type={options.type}\n confirmText={options.confirmText}\n cancelText={options.cancelText}\n icon={options.icon}\n showCancel={type === 'confirm'}\n focusCancel={options.focusCancel}\n onConfirm={() => dialog.close(type === 'confirm' ? true : undefined)}\n onCancel={() => dialog.close(type === 'confirm' ? false : undefined)}\n />\n );\n};\n\nexport default Dialog;\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;AAwDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BG;AACI,MAAM,MAAM,GAAG,UAAU,CAC9B,CACE,EACE,MAAM,EACN,KAAK,EACL,OAAO,EACP,IAAI,GAAG,SAAS,EAChB,WAAW,GAAG,IAAI,EAClB,UAAU,GAAG,QAAQ,EACrB,SAAS,EACT,QAAQ,EACR,UAAU,GAAG,IAAI,EACjB,SAAS,GAAG,IAAI,EAChB,WAAW,GAAG,KAAK,EACnB,IAAI,EACJ,MAAM,EACN,SAAS,EACT,GAAG,KAAK,EACT,EACD,GAAG,KACD;IACF,MAAM,EAAE,kBAAkB,EAAE,IAAI,EAAE,GAAG,eAAe,CAAC,KAAK,CAAC;AAC3D,IAAA,MAAM,SAAS,GAAG,MAAM,CAAiB,IAAI,CAAC;;AAE9C,IAAA,MAAM,kBAAkB,GAAG,MAAM,CAAsB,IAAI,CAAC;AAC5D,IAAA,MAAM,UAAU,GAAG,MAAM,CAAoB,IAAI,CAAC;AAClD,IAAA,MAAM,SAAS,GAAG,MAAM,CAAoB,IAAI,CAAC;;AAGjD,IAAA,MAAM,YAAY,GAAG,WAAW,CAAC,MAAK;QACpC,IAAI,SAAS,EAAE;YACb,QAAQ,IAAI;QACd;AACF,IAAA,CAAC,EAAE,CAAC,SAAS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