@namroodinc/liquid-editorial 0.3.1 → 0.3.3
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 +1568 -139
- package/UPGRADING.md +131 -0
- package/dist/chunks/{Board-BUJ5CinL.cjs → Board-BaQ04nWg.cjs} +2 -2
- package/dist/chunks/Board-BaQ04nWg.cjs.map +1 -0
- package/dist/chunks/{Board-Cyrda2qG.js → Board-CUhF8pTX.js} +2 -2
- package/dist/chunks/Board-CUhF8pTX.js.map +1 -0
- package/dist/chunks/ColourField-Bd4twbaG.js +499 -0
- package/dist/chunks/ColourField-Bd4twbaG.js.map +1 -0
- package/dist/chunks/ColourField-BdAbjgmY.cjs +2 -0
- package/dist/chunks/ColourField-BdAbjgmY.cjs.map +1 -0
- package/dist/chunks/FormEditor-DRmPFe2E.js.map +1 -1
- package/dist/chunks/FormEditor-PVkvKep1.cjs.map +1 -1
- package/dist/chunks/{Icon-CW6qJcDy.cjs → Icon-BBoWP_Y6.cjs} +2 -2
- package/dist/chunks/Icon-BBoWP_Y6.cjs.map +1 -0
- package/dist/chunks/{Icon-ByUB0L1a.js → Icon-XNismJDm.js} +21 -20
- package/dist/chunks/Icon-XNismJDm.js.map +1 -0
- package/dist/chunks/RichTextEditor-C7nMfDmE.cjs.map +1 -1
- package/dist/chunks/RichTextEditor-DjR10XJ-.js.map +1 -1
- package/dist/chunks/binding-Bshy43sG.js.map +1 -1
- package/dist/chunks/binding-tMjrUzkU.cjs.map +1 -1
- package/dist/chunks/dialogFocus-B9iqKl3I.cjs +2 -0
- package/dist/chunks/dialogFocus-B9iqKl3I.cjs.map +1 -0
- package/dist/chunks/dialogFocus-BFoyeTpA.js +48 -0
- package/dist/chunks/dialogFocus-BFoyeTpA.js.map +1 -0
- package/dist/chunks/dialogStack-6yv3NXFD.js.map +1 -1
- package/dist/chunks/dialogStack-C9SLVu6Q.cjs.map +1 -1
- package/dist/chunks/group-CzbacuAY.js.map +1 -1
- package/dist/chunks/group-pKDQtq-9.cjs.map +1 -1
- package/dist/chunks/mergeRefs-Bc3qS0Tt.cjs.map +1 -1
- package/dist/chunks/mergeRefs-DGM402mE.js.map +1 -1
- package/dist/chunks/observeElementWidth-BCJM2FAw.cjs.map +1 -1
- package/dist/chunks/observeElementWidth-BlQOlW2t.js.map +1 -1
- package/dist/components/AppShell/index.cjs.map +1 -1
- package/dist/components/AppShell/index.d.cts.map +1 -1
- package/dist/components/AppShell/index.d.ts.map +1 -1
- package/dist/components/AppShell/index.js.map +1 -1
- package/dist/components/AssetCard/index.cjs +1 -1
- package/dist/components/AssetCard/index.cjs.map +1 -1
- package/dist/components/AssetCard/index.d.cts.map +1 -1
- package/dist/components/AssetCard/index.d.ts.map +1 -1
- package/dist/components/AssetCard/index.js +1 -1
- package/dist/components/AssetCard/index.js.map +1 -1
- package/dist/components/AssetGrid/index.cjs +1 -1
- package/dist/components/AssetGrid/index.js +1 -1
- package/dist/components/Badge/index.cjs.map +1 -1
- package/dist/components/Badge/index.d.cts.map +1 -1
- package/dist/components/Badge/index.d.ts.map +1 -1
- package/dist/components/Badge/index.js.map +1 -1
- package/dist/components/Board/index.cjs +1 -1
- package/dist/components/Board/index.d.cts.map +1 -1
- package/dist/components/Board/index.d.ts.map +1 -1
- package/dist/components/Board/index.js +1 -1
- package/dist/components/Board/keyboard.d.cts.map +1 -1
- package/dist/components/Board/keyboard.d.ts.map +1 -1
- package/dist/components/Board/moves.d.cts.map +1 -1
- package/dist/components/Board/moves.d.ts.map +1 -1
- package/dist/components/Button/index.cjs +1 -1
- package/dist/components/Button/index.js +1 -1
- package/dist/components/Choice/index.cjs.map +1 -1
- package/dist/components/Choice/index.d.cts.map +1 -1
- package/dist/components/Choice/index.d.ts.map +1 -1
- package/dist/components/Choice/index.js.map +1 -1
- package/dist/components/ColourField/colour.d.cts +12 -0
- package/dist/components/ColourField/colour.d.cts.map +1 -0
- package/dist/components/ColourField/colour.d.ts +12 -0
- package/dist/components/ColourField/colour.d.ts.map +1 -0
- package/dist/components/ColourField/focus.d.cts +3 -0
- package/dist/components/ColourField/focus.d.cts.map +1 -0
- package/dist/components/ColourField/focus.d.ts +3 -0
- package/dist/components/ColourField/focus.d.ts.map +1 -0
- package/dist/components/ColourField/index.cjs +1 -0
- package/dist/components/ColourField/index.d.cts +15 -0
- package/dist/components/ColourField/index.d.cts.map +1 -0
- package/dist/components/ColourField/index.d.ts +15 -0
- package/dist/components/ColourField/index.d.ts.map +1 -0
- package/dist/components/ColourField/index.js +1 -0
- package/dist/components/ColourField/panel.d.cts +21 -0
- package/dist/components/ColourField/panel.d.cts.map +1 -0
- package/dist/components/ColourField/panel.d.ts +21 -0
- package/dist/components/ColourField/panel.d.ts.map +1 -0
- package/dist/components/ColourField/square.d.cts +9 -0
- package/dist/components/ColourField/square.d.cts.map +1 -0
- package/dist/components/ColourField/square.d.ts +9 -0
- package/dist/components/ColourField/square.d.ts.map +1 -0
- package/dist/components/ColourField/style.css +266 -0
- package/dist/components/ColourField/value.d.cts +13 -0
- package/dist/components/ColourField/value.d.cts.map +1 -0
- package/dist/components/ColourField/value.d.ts +13 -0
- package/dist/components/ColourField/value.d.ts.map +1 -0
- package/dist/components/DatePicker/index.cjs +1 -1
- package/dist/components/DatePicker/index.cjs.map +1 -1
- package/dist/components/DatePicker/index.d.cts +6 -2
- package/dist/components/DatePicker/index.d.cts.map +1 -1
- package/dist/components/DatePicker/index.d.ts +6 -2
- package/dist/components/DatePicker/index.d.ts.map +1 -1
- package/dist/components/DatePicker/index.js +45 -42
- package/dist/components/DatePicker/index.js.map +1 -1
- package/dist/components/Drawer/index.cjs +1 -1
- package/dist/components/Drawer/index.cjs.map +1 -1
- package/dist/components/Drawer/index.d.cts.map +1 -1
- package/dist/components/Drawer/index.d.ts.map +1 -1
- package/dist/components/Drawer/index.js +69 -73
- package/dist/components/Drawer/index.js.map +1 -1
- package/dist/components/EditLayout/index.cjs +1 -1
- package/dist/components/EditLayout/index.cjs.map +1 -1
- package/dist/components/EditLayout/index.d.cts.map +1 -1
- package/dist/components/EditLayout/index.d.ts.map +1 -1
- package/dist/components/EditLayout/index.js +69 -56
- package/dist/components/EditLayout/index.js.map +1 -1
- package/dist/components/EntryPicker/index.cjs +1 -1
- package/dist/components/EntryPicker/index.cjs.map +1 -1
- package/dist/components/EntryPicker/index.d.cts.map +1 -1
- package/dist/components/EntryPicker/index.d.ts.map +1 -1
- package/dist/components/EntryPicker/index.js +1 -1
- package/dist/components/EntryPicker/index.js.map +1 -1
- package/dist/components/Field/binding.d.cts.map +1 -1
- package/dist/components/Field/binding.d.ts.map +1 -1
- package/dist/components/Field/group.d.cts.map +1 -1
- package/dist/components/Field/group.d.ts.map +1 -1
- package/dist/components/FieldAffix/index.cjs +1 -1
- package/dist/components/FieldAffix/index.cjs.map +1 -1
- package/dist/components/FieldAffix/index.d.cts +3 -1
- package/dist/components/FieldAffix/index.d.cts.map +1 -1
- package/dist/components/FieldAffix/index.d.ts +3 -1
- package/dist/components/FieldAffix/index.d.ts.map +1 -1
- package/dist/components/FieldAffix/index.js +20 -16
- package/dist/components/FieldAffix/index.js.map +1 -1
- package/dist/components/FieldAffix/style.css +1 -0
- package/dist/components/FormEditor/control.d.cts.map +1 -1
- package/dist/components/FormEditor/control.d.ts.map +1 -1
- package/dist/components/FormEditor/index.d.cts.map +1 -1
- package/dist/components/FormEditor/index.d.ts.map +1 -1
- package/dist/components/FormEditor/model.d.cts.map +1 -1
- package/dist/components/FormEditor/model.d.ts.map +1 -1
- package/dist/components/Icon/icons.d.cts +1 -0
- package/dist/components/Icon/icons.d.cts.map +1 -1
- package/dist/components/Icon/icons.d.ts +1 -0
- package/dist/components/Icon/icons.d.ts.map +1 -1
- package/dist/components/Icon/index.cjs +1 -1
- package/dist/components/Icon/index.js +1 -1
- package/dist/components/ImageCropper/index.cjs.map +1 -1
- package/dist/components/ImageCropper/index.d.cts.map +1 -1
- package/dist/components/ImageCropper/index.d.ts.map +1 -1
- package/dist/components/ImageCropper/index.js.map +1 -1
- package/dist/components/Menu/index.cjs.map +1 -1
- package/dist/components/Menu/index.d.cts.map +1 -1
- package/dist/components/Menu/index.d.ts.map +1 -1
- package/dist/components/Menu/index.js.map +1 -1
- package/dist/components/Modal/index.cjs +1 -1
- package/dist/components/Modal/index.cjs.map +1 -1
- package/dist/components/Modal/index.d.cts.map +1 -1
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/Modal/index.js +40 -48
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/NumberField/index.cjs.map +1 -1
- package/dist/components/NumberField/index.d.cts.map +1 -1
- package/dist/components/NumberField/index.d.ts.map +1 -1
- package/dist/components/NumberField/index.js.map +1 -1
- package/dist/components/Pagination/index.cjs.map +1 -1
- package/dist/components/Pagination/index.d.cts.map +1 -1
- package/dist/components/Pagination/index.d.ts.map +1 -1
- package/dist/components/Pagination/index.js.map +1 -1
- package/dist/components/Popover/index.cjs +1 -1
- package/dist/components/Popover/index.cjs.map +1 -1
- package/dist/components/Popover/index.d.cts.map +1 -1
- package/dist/components/Popover/index.d.ts.map +1 -1
- package/dist/components/Popover/index.js +52 -37
- package/dist/components/Popover/index.js.map +1 -1
- package/dist/components/RichTextEditor/document.d.cts.map +1 -1
- package/dist/components/RichTextEditor/document.d.ts.map +1 -1
- package/dist/components/RichTextEditor/index.d.cts.map +1 -1
- package/dist/components/RichTextEditor/index.d.ts.map +1 -1
- package/dist/components/SearchField/index.cjs +1 -1
- package/dist/components/SearchField/index.cjs.map +1 -1
- package/dist/components/SearchField/index.d.cts.map +1 -1
- package/dist/components/SearchField/index.d.ts.map +1 -1
- package/dist/components/SearchField/index.js +1 -1
- package/dist/components/SearchField/index.js.map +1 -1
- package/dist/components/Select/index.cjs +1 -1
- package/dist/components/Select/index.cjs.map +1 -1
- package/dist/components/Select/index.d.cts.map +1 -1
- package/dist/components/Select/index.d.ts.map +1 -1
- package/dist/components/Select/index.js +1 -1
- package/dist/components/Select/index.js.map +1 -1
- package/dist/components/SideNav/index.cjs +1 -1
- package/dist/components/SideNav/index.cjs.map +1 -1
- package/dist/components/SideNav/index.d.cts.map +1 -1
- package/dist/components/SideNav/index.d.ts.map +1 -1
- package/dist/components/SideNav/index.js +1 -1
- package/dist/components/SideNav/index.js.map +1 -1
- package/dist/components/Slider/index.cjs.map +1 -1
- package/dist/components/Slider/index.d.cts.map +1 -1
- package/dist/components/Slider/index.d.ts.map +1 -1
- package/dist/components/Slider/index.js.map +1 -1
- package/dist/components/SortableList/index.cjs +1 -1
- package/dist/components/SortableList/index.cjs.map +1 -1
- package/dist/components/SortableList/index.d.cts.map +1 -1
- package/dist/components/SortableList/index.d.ts.map +1 -1
- package/dist/components/SortableList/index.js +1 -1
- package/dist/components/SortableList/index.js.map +1 -1
- package/dist/components/Stepper/index.cjs +1 -1
- package/dist/components/Stepper/index.cjs.map +1 -1
- package/dist/components/Stepper/index.d.cts.map +1 -1
- package/dist/components/Stepper/index.d.ts.map +1 -1
- package/dist/components/Stepper/index.js +1 -1
- package/dist/components/Stepper/index.js.map +1 -1
- package/dist/components/SubNav/index.cjs +1 -1
- package/dist/components/SubNav/index.js +1 -1
- package/dist/components/Switch/index.cjs.map +1 -1
- package/dist/components/Switch/index.d.cts.map +1 -1
- package/dist/components/Switch/index.d.ts.map +1 -1
- package/dist/components/Switch/index.js.map +1 -1
- package/dist/components/Table/index.cjs +1 -1
- package/dist/components/Table/index.js +1 -1
- package/dist/components/TagsInput/index.cjs.map +1 -1
- package/dist/components/TagsInput/index.d.cts.map +1 -1
- package/dist/components/TagsInput/index.d.ts.map +1 -1
- package/dist/components/TagsInput/index.js.map +1 -1
- package/dist/components/Time/index.cjs.map +1 -1
- package/dist/components/Time/index.d.cts.map +1 -1
- package/dist/components/Time/index.d.ts.map +1 -1
- package/dist/components/Time/index.js.map +1 -1
- package/dist/components/Toast/index.cjs +1 -1
- package/dist/components/Toast/index.cjs.map +1 -1
- package/dist/components/Toast/index.d.cts.map +1 -1
- package/dist/components/Toast/index.d.ts.map +1 -1
- package/dist/components/Toast/index.js +1 -1
- package/dist/components/Toast/index.js.map +1 -1
- package/dist/components/TopNav/index.cjs +1 -1
- package/dist/components/TopNav/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -7
- package/dist/internal/dialogFocus.d.cts +17 -0
- package/dist/internal/dialogFocus.d.cts.map +1 -0
- package/dist/internal/dialogFocus.d.ts +17 -0
- package/dist/internal/dialogFocus.d.ts.map +1 -0
- package/dist/internal/dialogStack.d.cts.map +1 -1
- package/dist/internal/dialogStack.d.ts.map +1 -1
- package/dist/internal/lockBodyScroll.d.cts.map +1 -1
- package/dist/internal/lockBodyScroll.d.ts.map +1 -1
- package/dist/internal/mergeRefs.d.cts.map +1 -1
- package/dist/internal/mergeRefs.d.ts.map +1 -1
- package/dist/internal/observeElementWidth.d.cts.map +1 -1
- package/dist/internal/observeElementWidth.d.ts.map +1 -1
- package/dist/styles.css +1 -0
- package/package.json +3 -2
- package/dist/chunks/Board-BUJ5CinL.cjs.map +0 -1
- package/dist/chunks/Board-Cyrda2qG.js.map +0 -1
- package/dist/chunks/Icon-ByUB0L1a.js.map +0 -1
- package/dist/chunks/Icon-CW6qJcDy.cjs.map +0 -1
- package/dist/components/Board/keyboard.test.d.cts +0 -2
- package/dist/components/Board/keyboard.test.d.cts.map +0 -1
- package/dist/components/Board/keyboard.test.d.ts +0 -2
- package/dist/components/Board/keyboard.test.d.ts.map +0 -1
- package/dist/components/Board/moves.test.d.cts +0 -2
- package/dist/components/Board/moves.test.d.cts.map +0 -1
- package/dist/components/Board/moves.test.d.ts +0 -2
- package/dist/components/Board/moves.test.d.ts.map +0 -1
- package/dist/test/dragEvent.d.cts +0 -3
- package/dist/test/dragEvent.d.cts.map +0 -1
- package/dist/test/dragEvent.d.ts +0 -3
- package/dist/test/dragEvent.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Icon","mergeRefs","isItem","isValidElement","child","SortableList","forwardRef","rest","dndId","useId","activeId","setActiveId","useState","order","setOrder","items","prevItems","setPrevItems","sensors","useSensors","useSensor","PointerSensor","KeyboardSensor","sortableKeyboardCoordinates","handleStart","useCallback","event","handleEnd","over","active","from","to","next","arrayMove","onReorder","childArray","Children","children","rows","ordered","id","activeRow","DndContext","closestCenter","restrictToVerticalAxis","SortableContext","verticalListSortingStrategy","className","DragOverlay","renderDragOverlay","SortableListItem","useSortable","setNodeRef","ref","CSS","transform","isDragging","Button","label","attributes","listeners","action"],"sources":["../../../src/components/SortableList/index.tsx"],"sourcesContent":["import {\n Children,\n forwardRef,\n isValidElement,\n useCallback,\n useId,\n useState,\n type HTMLAttributes,\n type ReactElement,\n type ReactNode,\n} from \"react\";\nimport {\n DndContext,\n DragOverlay,\n KeyboardSensor,\n PointerSensor,\n closestCenter,\n useSensor,\n useSensors,\n type DragEndEvent,\n type DragStartEvent,\n} from \"@dnd-kit/core\";\nimport { restrictToVerticalAxis } from \"@dnd-kit/modifiers\";\nimport {\n SortableContext,\n arrayMove,\n sortableKeyboardCoordinates,\n useSortable,\n verticalListSortingStrategy,\n} from \"@dnd-kit/sortable\";\nimport { CSS } from \"@dnd-kit/utilities\";\nimport { Button } from \"../Button\";\nimport { Icon } from \"../Icon\";\nimport { mergeRefs } from \"../../internal/mergeRefs\";\nimport \"./style.css\";\n\nexport interface SortableListProps extends Omit<HTMLAttributes<HTMLUListElement>, \"onDragEnd\"> {\n /** Item ids in render order. */\n items: string[];\n /** Fired with the whole list in its new order. Apply it to your own state. */\n onReorder?: (items: string[]) => void;\n /** Rendered inside the drag overlay while a row is in the air. Defaults to the row's content. */\n renderDragOverlay?: (id: string) => ReactNode;\n children?: ReactNode;\n}\n\ntype ItemElement = ReactElement<SortableListItemProps>;\n\nfunction isItem(child: ReactNode): child is ItemElement {\n return isValidElement<SortableListItemProps>(child) && typeof child.props.id === \"string\";\n}\n\n/**\n * A single vertical list you can re-order — the board's mechanics without the\n * lanes. Each row carries a grip on the left. The list keeps the dropped order\n * itself, so it works on its own; pass `onReorder` to mirror it into your data.\n * A new `items` value from the parent always wins.\n */\nexport const SortableList = forwardRef<HTMLUListElement, SortableListProps>(function SortableList(\n { items, onReorder, renderDragOverlay, className, children, ...rest },\n ref,\n) {\n const dndId = useId();\n const [activeId, setActiveId] = useState<string | null>(null);\n const [order, setOrder] = useState(items);\n const [prevItems, setPrevItems] = useState(items);\n if (items !== prevItems && items.join(\"\\u0000\") !== prevItems.join(\"\\u0000\")) {\n setPrevItems(items);\n setOrder(items);\n }\n const sensors = useSensors(\n useSensor(PointerSensor, { activationConstraint: { distance: 4 } }),\n useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }),\n );\n\n const handleStart = useCallback((event: DragStartEvent) => {\n setActiveId(String(event.active.id));\n }, []);\n\n const handleEnd = useCallback(\n (event: DragEndEvent) => {\n setActiveId(null);\n const { active, over } = event;\n if (!over || active.id === over.id) return;\n const from = order.indexOf(String(active.id));\n const to = order.indexOf(String(over.id));\n if (from < 0 || to < 0) return;\n const next = arrayMove(order, from, to);\n setOrder(next);\n onReorder?.(next);\n },\n [order, onReorder],\n );\n\n // Rows follow the list's own order; anything that isn't a row keeps its place at the end.\n const childArray = Children.toArray(children);\n const rows = new Map(childArray.filter(isItem).map((child) => [child.props.id, child]));\n const ordered = [\n ...order.flatMap((id) => rows.get(id) ?? []),\n ...childArray.filter((child) => !isItem(child) || !order.includes(child.props.id)),\n ];\n const activeRow = activeId ? rows.get(activeId) : undefined;\n\n return (\n <DndContext\n id={`ds-sortable-list-${dndId}`}\n sensors={sensors}\n collisionDetection={closestCenter}\n modifiers={[restrictToVerticalAxis]}\n onDragStart={handleStart}\n onDragEnd={handleEnd}\n onDragCancel={() => setActiveId(null)}\n >\n <SortableContext\n items={order}\n strategy={verticalListSortingStrategy}\n >\n <ul\n ref={ref}\n className={[\"ds-sortable-list\", className].filter(Boolean).join(\" \")}\n {...rest}\n >\n {ordered}\n </ul>\n </SortableContext>\n <DragOverlay>\n {activeId ? (\n <div\n className=\"ds-sortable-item\"\n data-overlay\n >\n <span\n className=\"ds-sortable-item__handle\"\n aria-hidden=\"true\"\n >\n <Icon name=\"grip-vertical\" />\n </span>\n <div className=\"ds-sortable-item__content\">\n {renderDragOverlay ? renderDragOverlay(activeId) : activeRow?.props.children}\n </div>\n </div>\n ) : null}\n </DragOverlay>\n </DndContext>\n );\n});\n\nexport interface SortableListItemProps extends HTMLAttributes<HTMLLIElement> {\n id: string;\n /** Accessible name announced when the row is picked up. */\n label?: string;\n /** A control at the end of the row, e.g. a menu or a delete button. */\n action?: ReactNode;\n children?: ReactNode;\n}\n\n/** One row of a `SortableList`. The grip on the left is the only handle. */\nexport const SortableListItem = forwardRef<HTMLLIElement, SortableListItemProps>(\n function SortableListItem({ id, label, action, className, children, ...rest }, ref) {\n const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({\n id,\n });\n\n return (\n <li\n ref={mergeRefs(setNodeRef, ref)}\n style={{ transform: CSS.Translate.toString(transform), transition }}\n className={[\"ds-sortable-item\", className].filter(Boolean).join(\" \")}\n data-dragging={isDragging || undefined}\n {...rest}\n >\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"grip-vertical\"\n className=\"ds-sortable-item__handle\"\n aria-label={label ? `Move ${label}` : \"Move item\"}\n {...attributes}\n {...listeners}\n />\n <div className=\"ds-sortable-item__content\">{children}</div>\n {action && <div className=\"ds-sortable-item__action\">{action}</div>}\n </li>\n );\n },\n);\n"],"mappings":";;;;;;;;;;AAgDA,SAASE,EAAO,GAAwC;CACtD,OAAOC,EAAsCC,CAAK,KAAK,OAAOA,EAAM,MAAM,MAAO;AACnF;AAQA,IAAaC,IAAeC,EAAgD,SAC1E,EAAE,UAAO,cAAW,sBAAmB,cAAW,aAAU,GAAGC,KAC/D,GACA;CACA,IAAMC,IAAQC,EAAM,GACd,CAACC,GAAUC,KAAeC,EAAwB,IAAI,GACtD,CAACC,GAAOC,KAAYF,EAASG,CAAK,GAClC,CAACC,GAAWC,KAAgBL,EAASG,CAAK;CAChD,AAAIA,MAAUC,KAAaD,EAAM,KAAK,IAAQ,MAAMC,EAAU,KAAK,IAAQ,MACzEC,EAAaF,CAAK,GAClBD,EAASC,CAAK;CAEhB,IAAMG,IAAUC,EACdC,EAAUC,GAAe,EAAE,sBAAsB,EAAE,UAAU,EAAE,EAAE,CAAC,GAClED,EAAUE,GAAgB,EAAE,kBAAkBC,EAA4B,CAAC,CAC7E,GAEMC,IAAcC,GAAa,MAA0B;EACzD,EAAY,OAAOC,EAAM,OAAO,EAAE,CAAC;CACrC,GAAG,CAAC,CAAC,GAECC,IAAYF,GACf,MAAwB;EACvB,EAAY,IAAI;EAChB,IAAM,EAAE,WAAQ,YAASC;EACzB,IAAI,CAACE,KAAQC,EAAO,OAAOD,EAAK,
|
|
1
|
+
{"version":3,"file":"index.js","names":["Icon","mergeRefs","isItem","isValidElement","child","SortableList","forwardRef","rest","dndId","useId","activeId","setActiveId","useState","order","setOrder","items","prevItems","setPrevItems","sensors","useSensors","useSensor","PointerSensor","KeyboardSensor","sortableKeyboardCoordinates","handleStart","useCallback","event","handleEnd","over","active","from","to","next","arrayMove","onReorder","childArray","Children","children","rows","ordered","id","activeRow","DndContext","closestCenter","restrictToVerticalAxis","SortableContext","verticalListSortingStrategy","className","DragOverlay","renderDragOverlay","SortableListItem","useSortable","setNodeRef","ref","CSS","transform","isDragging","Button","label","attributes","listeners","action"],"sources":["../../../src/components/SortableList/index.tsx"],"sourcesContent":["import {\n Children,\n forwardRef,\n isValidElement,\n useCallback,\n useId,\n useState,\n type HTMLAttributes,\n type ReactElement,\n type ReactNode,\n} from \"react\";\nimport {\n DndContext,\n DragOverlay,\n KeyboardSensor,\n PointerSensor,\n closestCenter,\n useSensor,\n useSensors,\n type DragEndEvent,\n type DragStartEvent,\n} from \"@dnd-kit/core\";\nimport { restrictToVerticalAxis } from \"@dnd-kit/modifiers\";\nimport {\n SortableContext,\n arrayMove,\n sortableKeyboardCoordinates,\n useSortable,\n verticalListSortingStrategy,\n} from \"@dnd-kit/sortable\";\nimport { CSS } from \"@dnd-kit/utilities\";\nimport { Button } from \"../Button\";\nimport { Icon } from \"../Icon\";\nimport { mergeRefs } from \"../../internal/mergeRefs\";\nimport \"./style.css\";\n\nexport interface SortableListProps extends Omit<HTMLAttributes<HTMLUListElement>, \"onDragEnd\"> {\n /** Item ids in render order. */\n items: string[];\n /** Fired with the whole list in its new order. Apply it to your own state. */\n onReorder?: (items: string[]) => void;\n /** Rendered inside the drag overlay while a row is in the air. Defaults to the row's content. */\n renderDragOverlay?: (id: string) => ReactNode;\n children?: ReactNode;\n}\n\ntype ItemElement = ReactElement<SortableListItemProps>;\n\nfunction isItem(child: ReactNode): child is ItemElement {\n return isValidElement<SortableListItemProps>(child) && typeof child.props.id === \"string\";\n}\n\n/**\n * A single vertical list you can re-order — the board's mechanics without the\n * lanes. Each row carries a grip on the left. The list keeps the dropped order\n * itself, so it works on its own; pass `onReorder` to mirror it into your data.\n * A new `items` value from the parent always wins.\n */\nexport const SortableList = forwardRef<HTMLUListElement, SortableListProps>(function SortableList(\n { items, onReorder, renderDragOverlay, className, children, ...rest },\n ref,\n) {\n const dndId = useId();\n const [activeId, setActiveId] = useState<string | null>(null);\n const [order, setOrder] = useState(items);\n const [prevItems, setPrevItems] = useState(items);\n if (items !== prevItems && items.join(\"\\u0000\") !== prevItems.join(\"\\u0000\")) {\n setPrevItems(items);\n setOrder(items);\n }\n const sensors = useSensors(\n useSensor(PointerSensor, { activationConstraint: { distance: 4 } }),\n useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }),\n );\n\n const handleStart = useCallback((event: DragStartEvent) => {\n setActiveId(String(event.active.id));\n }, []);\n\n const handleEnd = useCallback(\n (event: DragEndEvent) => {\n setActiveId(null);\n const { active, over } = event;\n if (!over || active.id === over.id) {\n return;\n }\n const from = order.indexOf(String(active.id));\n const to = order.indexOf(String(over.id));\n if (from < 0 || to < 0) {\n return;\n }\n const next = arrayMove(order, from, to);\n setOrder(next);\n onReorder?.(next);\n },\n [order, onReorder],\n );\n\n // Rows follow the list's own order; anything that isn't a row keeps its place at the end.\n const childArray = Children.toArray(children);\n const rows = new Map(childArray.filter(isItem).map((child) => [child.props.id, child]));\n const ordered = [\n ...order.flatMap((id) => rows.get(id) ?? []),\n ...childArray.filter((child) => !isItem(child) || !order.includes(child.props.id)),\n ];\n const activeRow = activeId ? rows.get(activeId) : undefined;\n\n return (\n <DndContext\n id={`ds-sortable-list-${dndId}`}\n sensors={sensors}\n collisionDetection={closestCenter}\n modifiers={[restrictToVerticalAxis]}\n onDragStart={handleStart}\n onDragEnd={handleEnd}\n onDragCancel={() => setActiveId(null)}\n >\n <SortableContext\n items={order}\n strategy={verticalListSortingStrategy}\n >\n <ul\n ref={ref}\n className={[\"ds-sortable-list\", className].filter(Boolean).join(\" \")}\n {...rest}\n >\n {ordered}\n </ul>\n </SortableContext>\n <DragOverlay>\n {activeId ? (\n <div\n className=\"ds-sortable-item\"\n data-overlay\n >\n <span\n className=\"ds-sortable-item__handle\"\n aria-hidden=\"true\"\n >\n <Icon name=\"grip-vertical\" />\n </span>\n <div className=\"ds-sortable-item__content\">\n {renderDragOverlay ? renderDragOverlay(activeId) : activeRow?.props.children}\n </div>\n </div>\n ) : null}\n </DragOverlay>\n </DndContext>\n );\n});\n\nexport interface SortableListItemProps extends HTMLAttributes<HTMLLIElement> {\n id: string;\n /** Accessible name announced when the row is picked up. */\n label?: string;\n /** A control at the end of the row, e.g. a menu or a delete button. */\n action?: ReactNode;\n children?: ReactNode;\n}\n\n/** One row of a `SortableList`. The grip on the left is the only handle. */\nexport const SortableListItem = forwardRef<HTMLLIElement, SortableListItemProps>(\n function SortableListItem({ id, label, action, className, children, ...rest }, ref) {\n const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({\n id,\n });\n\n return (\n <li\n ref={mergeRefs(setNodeRef, ref)}\n style={{ transform: CSS.Translate.toString(transform), transition }}\n className={[\"ds-sortable-item\", className].filter(Boolean).join(\" \")}\n data-dragging={isDragging || undefined}\n {...rest}\n >\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"grip-vertical\"\n className=\"ds-sortable-item__handle\"\n aria-label={label ? `Move ${label}` : \"Move item\"}\n {...attributes}\n {...listeners}\n />\n <div className=\"ds-sortable-item__content\">{children}</div>\n {action && <div className=\"ds-sortable-item__action\">{action}</div>}\n </li>\n );\n },\n);\n"],"mappings":";;;;;;;;;;AAgDA,SAASE,EAAO,GAAwC;CACtD,OAAOC,EAAsCC,CAAK,KAAK,OAAOA,EAAM,MAAM,MAAO;AACnF;AAQA,IAAaC,IAAeC,EAAgD,SAC1E,EAAE,UAAO,cAAW,sBAAmB,cAAW,aAAU,GAAGC,KAC/D,GACA;CACA,IAAMC,IAAQC,EAAM,GACd,CAACC,GAAUC,KAAeC,EAAwB,IAAI,GACtD,CAACC,GAAOC,KAAYF,EAASG,CAAK,GAClC,CAACC,GAAWC,KAAgBL,EAASG,CAAK;CAChD,AAAIA,MAAUC,KAAaD,EAAM,KAAK,IAAQ,MAAMC,EAAU,KAAK,IAAQ,MACzEC,EAAaF,CAAK,GAClBD,EAASC,CAAK;CAEhB,IAAMG,IAAUC,EACdC,EAAUC,GAAe,EAAE,sBAAsB,EAAE,UAAU,EAAE,EAAE,CAAC,GAClED,EAAUE,GAAgB,EAAE,kBAAkBC,EAA4B,CAAC,CAC7E,GAEMC,IAAcC,GAAa,MAA0B;EACzD,EAAY,OAAOC,EAAM,OAAO,EAAE,CAAC;CACrC,GAAG,CAAC,CAAC,GAECC,IAAYF,GACf,MAAwB;EACvB,EAAY,IAAI;EAChB,IAAM,EAAE,WAAQ,YAASC;EACzB,IAAI,CAACE,KAAQC,EAAO,OAAOD,EAAK,IAC9B;EAEF,IAAME,IAAOjB,EAAM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,OAAD;IAAK,WAAU;IACZ,UAAAiD,IAAoBA,EAAkBvC,CAAQ,IAAI+B,GAAW,MAAM;GACjE,CAAA,CACF;EACH,CAAA,IAAA,KACO,CAAA,CACH;;AAEhB,CAAC,GAYYS,IAAmB5C,EAC9B,SAA0B,EAAE,OAAI,UAAO,WAAQ,cAAW,aAAU,GAAGC,KAAQ,GAAK;CAClF,IAAM,EAAE,eAAY,cAAW,eAAY,cAAW,eAAY,kBAAe4C,EAAY,EAC3F,MACF,CAAC;CAED,OACE,kBAAC,MAAD;EACE,KAAKlD,EAAUmD,GAAYC,CAAG;EAC9B,OAAO;GAAE,WAAWC,EAAI,UAAU,SAASC,CAAS;GAAG;EAAW;EAClE,WAAW,CAAC,oBAAoBR,CAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;EACnE,iBAAeS,KAAc,KAAA;EAC7B,GAAIjD;EALN,UAAA;GAOE,kBAACkD,GAAD;IACE,SAAQ;IACR,MAAK;IACL,YAAA;IACA,WAAU;IACV,WAAU;IACV,cAAYC,IAAQ,QAAQA,MAAU;IACtC,GAAIC;IACJ,GAAIC;GACL,CAAA;GACD,kBAAC,OAAD;IAAK,WAAU;IAA6B;GAAc,CAAA;GACzDC,KAAU,kBAAC,OAAD;IAAK,WAAU;IAA4B,UAAAA;GAAY,CAAA;EAChE;;AAER,CACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/Icon-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/Icon-BBoWP_Y6.cjs"),t=require("../Button/index.cjs");let n=require("react"),r=require("react/jsx-runtime");function i(e,t){return e<t?`complete`:e===t?`current`:`upcoming`}var a=(0,n.forwardRef)(function({steps:a,activeStep:o,size:s=`md`,label:c=`Progress`,onStepChange:l,className:u,...d},f){let p=(0,n.useId)();return(0,r.jsx)(`nav`,{ref:f,"aria-label":c,"data-size":s,className:[`ds-stepper`,u].filter(Boolean).join(` `),...d,children:(0,r.jsx)(`ol`,{className:`ds-stepper__list`,children:a.map((n,a)=>{let s=i(a,o),c=!!l&&s!==`upcoming`,u=(0,r.jsxs)(r.Fragment,{children:[s===`complete`?(0,r.jsx)(e.t,{name:`check`,size:16,"aria-hidden":`true`}):a+1,(0,r.jsx)(`span`,{id:`${p}-${a}-status`,className:`ds-stepper__sr`,children:s})]});return(0,r.jsxs)(`li`,{className:`ds-stepper__step`,"data-status":s,"aria-current":s===`current`?`step`:void 0,children:[(0,r.jsxs)(`span`,{className:`ds-stepper__track`,"aria-hidden":`true`,children:[(0,r.jsx)(`span`,{className:`ds-stepper__connector`,"data-side":`start`}),(0,r.jsx)(`span`,{className:`ds-stepper__connector`,"data-side":`end`})]}),c?(0,r.jsx)(t.Button,{className:`ds-stepper__marker`,variant:s===`complete`?`primary`:`active`,size:`sm`,isIconOnly:!0,"aria-labelledby":`${p}-${a}-label`,"aria-describedby":`${p}-${a}-status`,onClick:()=>l?.(a,n.id),children:u}):(0,r.jsx)(`span`,{className:`ds-stepper__marker`,children:u}),(0,r.jsxs)(`span`,{className:`ds-stepper__text`,children:[(0,r.jsx)(`span`,{id:`${p}-${a}-label`,className:`ds-stepper__label`,children:n.label}),n.description&&(0,r.jsx)(`span`,{className:`ds-stepper__description`,children:n.description})]})]},n.id)})})})});exports.Stepper=a;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["forwardRef","useId","_Fragment","Icon","Button","require_Icon","require_components_Button_index","react","react_jsx_runtime","statusOf","index","activeStep","Stepper","rest","id","label","size","className","steps","status","interactive","onStepChange","marker","step"],"sources":["../../../src/components/Stepper/index.tsx"],"sourcesContent":["import { forwardRef, useId, type HTMLAttributes, type ReactNode } from \"react\";\nimport { Icon } from \"../Icon\";\nimport { Button } from \"../Button\";\nimport \"./style.css\";\n\nexport type StepperSize = \"sm\" | \"md\";\nexport type StepStatus = \"complete\" | \"current\" | \"upcoming\";\n\nexport interface Step {\n /** Stable key, and the value reported by `onStepChange`. */\n id: string;\n /** The step in the user's words — sentence case. */\n label: ReactNode;\n /** One line on what happens here. */\n description?: ReactNode;\n}\n\nexport interface StepperProps extends Omit<HTMLAttributes<HTMLElement>, \"onChange\" | \"children\"> {\n /** The ordered steps. Three or more spread evenly across the full width. */\n steps: Step[];\n /** Index of the step being worked on. Everything before it reads as complete. */\n activeStep: number;\n /** Marker scale. `sm` for a toolbar band, `md` for a page header. */\n size?: StepperSize;\n /** Accessible name for the progress bar. */\n label?: string;\n /**\n * Makes completed steps (and the current one) navigable. Omit for a\n * read-only progress indicator.\n */\n onStepChange?: (index: number, id: string) => void;\n}\n\nfunction statusOf(index: number, activeStep: number): StepStatus {\n if (index < activeStep) return \"complete\";\n if (index === activeStep) return \"current\";\n return \"upcoming\";\n}\n\n/**\n * A linear progress rail: 1 - 2 - 3. Steps share the row equally however many\n * there are, so the last marker always lands on the trailing edge.\n */\nexport const Stepper = forwardRef<HTMLElement, StepperProps>(function Stepper(\n { steps, activeStep, size = \"md\", label = \"Progress\", onStepChange, className, ...rest },\n ref,\n) {\n const id = useId();\n return (\n <nav\n ref={ref}\n aria-label={label}\n data-size={size}\n className={[\"ds-stepper\", className].filter(Boolean).join(\" \")}\n {...rest}\n >\n <ol className=\"ds-stepper__list\">\n {steps.map((step, index) => {\n const status = statusOf(index, activeStep);\n const interactive = Boolean(onStepChange) && status !== \"upcoming\";\n const marker = (\n <>\n {status === \"complete\" ? (\n <Icon\n name=\"check\"\n size={16}\n aria-hidden=\"true\"\n />\n ) : (\n index + 1\n )}\n <span\n id={`${id}-${index}-status`}\n className=\"ds-stepper__sr\"\n >\n {status}\n </span>\n </>\n );\n return (\n <li\n key={step.id}\n className=\"ds-stepper__step\"\n data-status={status}\n aria-current={status === \"current\" ? \"step\" : undefined}\n >\n <span\n className=\"ds-stepper__track\"\n aria-hidden=\"true\"\n >\n <span\n className=\"ds-stepper__connector\"\n data-side=\"start\"\n />\n <span\n className=\"ds-stepper__connector\"\n data-side=\"end\"\n />\n </span>\n {interactive ? (\n <Button\n className=\"ds-stepper__marker\"\n variant={status === \"complete\" ? \"primary\" : \"active\"}\n size=\"sm\"\n isIconOnly\n aria-labelledby={`${id}-${index}-label`}\n aria-describedby={`${id}-${index}-status`}\n onClick={() => onStepChange?.(index, step.id)}\n >\n {marker}\n </Button>\n ) : (\n <span className=\"ds-stepper__marker\">{marker}</span>\n )}\n <span className=\"ds-stepper__text\">\n <span\n id={`${id}-${index}-label`}\n className=\"ds-stepper__label\"\n >\n {step.label}\n </span>\n {step.description && (\n <span className=\"ds-stepper__description\">{step.description}</span>\n )}\n </span>\n </li>\n );\n })}\n </ol>\n </nav>\n );\n});\n"],"mappings":"A,4MAiCA,SAASS,EAAS,EAAe,EAAgC,
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["forwardRef","useId","_Fragment","Icon","Button","require_Icon","require_components_Button_index","react","react_jsx_runtime","statusOf","index","activeStep","Stepper","rest","id","label","size","className","steps","status","interactive","onStepChange","marker","step"],"sources":["../../../src/components/Stepper/index.tsx"],"sourcesContent":["import { forwardRef, useId, type HTMLAttributes, type ReactNode } from \"react\";\nimport { Icon } from \"../Icon\";\nimport { Button } from \"../Button\";\nimport \"./style.css\";\n\nexport type StepperSize = \"sm\" | \"md\";\nexport type StepStatus = \"complete\" | \"current\" | \"upcoming\";\n\nexport interface Step {\n /** Stable key, and the value reported by `onStepChange`. */\n id: string;\n /** The step in the user's words — sentence case. */\n label: ReactNode;\n /** One line on what happens here. */\n description?: ReactNode;\n}\n\nexport interface StepperProps extends Omit<HTMLAttributes<HTMLElement>, \"onChange\" | \"children\"> {\n /** The ordered steps. Three or more spread evenly across the full width. */\n steps: Step[];\n /** Index of the step being worked on. Everything before it reads as complete. */\n activeStep: number;\n /** Marker scale. `sm` for a toolbar band, `md` for a page header. */\n size?: StepperSize;\n /** Accessible name for the progress bar. */\n label?: string;\n /**\n * Makes completed steps (and the current one) navigable. Omit for a\n * read-only progress indicator.\n */\n onStepChange?: (index: number, id: string) => void;\n}\n\nfunction statusOf(index: number, activeStep: number): StepStatus {\n if (index < activeStep) {\n return \"complete\";\n }\n if (index === activeStep) {\n return \"current\";\n }\n return \"upcoming\";\n}\n\n/**\n * A linear progress rail: 1 - 2 - 3. Steps share the row equally however many\n * there are, so the last marker always lands on the trailing edge.\n */\nexport const Stepper = forwardRef<HTMLElement, StepperProps>(function Stepper(\n { steps, activeStep, size = \"md\", label = \"Progress\", onStepChange, className, ...rest },\n ref,\n) {\n const id = useId();\n return (\n <nav\n ref={ref}\n aria-label={label}\n data-size={size}\n className={[\"ds-stepper\", className].filter(Boolean).join(\" \")}\n {...rest}\n >\n <ol className=\"ds-stepper__list\">\n {steps.map((step, index) => {\n const status = statusOf(index, activeStep);\n const interactive = Boolean(onStepChange) && status !== \"upcoming\";\n const marker = (\n <>\n {status === \"complete\" ? (\n <Icon\n name=\"check\"\n size={16}\n aria-hidden=\"true\"\n />\n ) : (\n index + 1\n )}\n <span\n id={`${id}-${index}-status`}\n className=\"ds-stepper__sr\"\n >\n {status}\n </span>\n </>\n );\n return (\n <li\n key={step.id}\n className=\"ds-stepper__step\"\n data-status={status}\n aria-current={status === \"current\" ? \"step\" : undefined}\n >\n <span\n className=\"ds-stepper__track\"\n aria-hidden=\"true\"\n >\n <span\n className=\"ds-stepper__connector\"\n data-side=\"start\"\n />\n <span\n className=\"ds-stepper__connector\"\n data-side=\"end\"\n />\n </span>\n {interactive ? (\n <Button\n className=\"ds-stepper__marker\"\n variant={status === \"complete\" ? \"primary\" : \"active\"}\n size=\"sm\"\n isIconOnly\n aria-labelledby={`${id}-${index}-label`}\n aria-describedby={`${id}-${index}-status`}\n onClick={() => onStepChange?.(index, step.id)}\n >\n {marker}\n </Button>\n ) : (\n <span className=\"ds-stepper__marker\">{marker}</span>\n )}\n <span className=\"ds-stepper__text\">\n <span\n id={`${id}-${index}-label`}\n className=\"ds-stepper__label\"\n >\n {step.label}\n </span>\n {step.description && (\n <span className=\"ds-stepper__description\">{step.description}</span>\n )}\n </span>\n </li>\n );\n })}\n </ol>\n </nav>\n );\n});\n"],"mappings":"A,4MAiCA,SAASS,EAAS,EAAe,EAAgC,CAO/D,OANIC,EAAQC,EACH,WAELD,IAAUC,EACL,UAEF,UACT,CAMA,IAAaC,GAAA,EAAUZ,EAAAA,WAAAA,CAAsC,SAC3D,CAAE,QAAO,aAAY,OAAO,KAAM,QAAQ,WAAY,eAAc,YAAW,GAAGa,GAClF,EACA,CACA,IAAMC,GAAA,EAAKb,EAAAA,MAAAA,CAAM,EACjB,OACE,EAAAO,EAAA,IAAA,CAAC,MAAD,CACO,MACL,aAAYO,EACZ,YAAWC,EACX,UAAW,CAAC,aAAcC,CAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,EAC7D,GAAIJ,EAEJ,UAAA,EAAAL,EAAA,IAAA,CAAC,KAAD,CAAI,UAAU,mBACX,SAAAU,EAAM,KAAK,EAAM,IAAU,CAC1B,IAAMC,EAASV,EAASC,EAAOC,CAAU,EACnCS,EAAc,EAAQC,GAAiBF,IAAW,WAClDG,GACJ,EAAAd,EAAA,KAAA,CAAAN,EAAAA,SAAA,CAAA,SAAA,CACGiB,IAAW,YACV,EAAAX,EAAA,IAAA,CAACL,EAAAA,EAAD,CACE,KAAK,QACL,KAAM,GACN,cAAY,MACb,CAAA,EAEDO,EAAQ,GAEV,EAAAF,EAAA,IAAA,CAAC,OAAD,CACE,GAAI,GAAGM,EAAG,GAAGJ,EAAM,SACnB,UAAU,iBAET,SAAAS,CACG,CAAA,CACN,CAAA,CAAA,EAEJ,OACE,EAAAX,EAAA,KAAA,CAAC,KAAD,CAEE,UAAU,mBACV,cAAaW,EACb,eAAcA,IAAW,UAAY,OAAS,IAAA,GAJhD,SAAA,EAME,EAAAX,EAAA,KAAA,CAAC,OAAD,CACE,UAAU,oBACV,cAAY,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AC,EAAE,WAAW,CAAC;IACnB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACpD;AAYD;;;GAGG;AACH,eAAO,MAAM,OAAO,sGAwFlB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Stepper/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAG/E,OAAO,aAAa,CAAC;AAErB,MAAM,MAAM,WAAW,GAAG,IAAI,GAAG,IAAI,CAAC;AACtC,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,SAAS,GAAG,UAAU,CAAC;AAE7D,MAAM,WAAW,IAAI;IACnB,4DAA4D;IAC5D,EAAE,EAAE,MAAM,CAAC;IACX,oDAAoD;IACpD,KAAK,EAAE,SAAS,CAAC;IACjB,qCAAqC;IACrC,WAAW,CAAC,EAAE,SAAS,CAAC;CACzB;AAED,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;IAC9F,4EAA4E;IAC5E,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,iFAAiF;IACjF,UAAU,EAAE,MAAM,CAAC;IACnB,qEAAqE;IACrE,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACpD;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Stepper/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAG/E,OAAO,aAAa,CAAC;AAErB,MAAM,MAAM,WAAW,GAAG,IAAI,GAAG,IAAI,CAAC;AACtC,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,SAAS,GAAG,UAAU,CAAC;AAE7D,MAAM,WAAW,IAAI;IACnB,4DAA4D;IAC5D,EAAE,EAAE,MAAM,CAAC;IACX,oDAAoD;IACpD,KAAK,EAAE,SAAS,CAAC;IACjB,qCAAqC;IACrC,WAAW,CAAC,EAAE,SAAS,CAAC;CACzB;AAED,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;IAC9F,4EAA4E;IAC5E,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,iFAAiF;IACjF,UAAU,EAAE,MAAM,CAAC;IACnB,qEAAqE;IACrE,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACpD;AAYD;;;GAGG;AACH,eAAO,MAAM,OAAO,sGAwFlB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as e } from "../../chunks/Icon-
|
|
1
|
+
import { t as e } from "../../chunks/Icon-XNismJDm.js";
|
|
2
2
|
import { Button as t } from "../Button/index.js";
|
|
3
3
|
import { forwardRef as n, useId as r } from "react";
|
|
4
4
|
import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_Fragment","Icon","Fragment$1","statusOf","index","activeStep","Stepper","forwardRef","rest","id","useId","label","size","className","steps","status","interactive","onStepChange","marker","Button","step"],"sources":["../../../src/components/Stepper/index.tsx"],"sourcesContent":["import { forwardRef, useId, type HTMLAttributes, type ReactNode } from \"react\";\nimport { Icon } from \"../Icon\";\nimport { Button } from \"../Button\";\nimport \"./style.css\";\n\nexport type StepperSize = \"sm\" | \"md\";\nexport type StepStatus = \"complete\" | \"current\" | \"upcoming\";\n\nexport interface Step {\n /** Stable key, and the value reported by `onStepChange`. */\n id: string;\n /** The step in the user's words — sentence case. */\n label: ReactNode;\n /** One line on what happens here. */\n description?: ReactNode;\n}\n\nexport interface StepperProps extends Omit<HTMLAttributes<HTMLElement>, \"onChange\" | \"children\"> {\n /** The ordered steps. Three or more spread evenly across the full width. */\n steps: Step[];\n /** Index of the step being worked on. Everything before it reads as complete. */\n activeStep: number;\n /** Marker scale. `sm` for a toolbar band, `md` for a page header. */\n size?: StepperSize;\n /** Accessible name for the progress bar. */\n label?: string;\n /**\n * Makes completed steps (and the current one) navigable. Omit for a\n * read-only progress indicator.\n */\n onStepChange?: (index: number, id: string) => void;\n}\n\nfunction statusOf(index: number, activeStep: number): StepStatus {\n if (index < activeStep) return \"complete\";\n if (index === activeStep) return \"current\";\n return \"upcoming\";\n}\n\n/**\n * A linear progress rail: 1 - 2 - 3. Steps share the row equally however many\n * there are, so the last marker always lands on the trailing edge.\n */\nexport const Stepper = forwardRef<HTMLElement, StepperProps>(function Stepper(\n { steps, activeStep, size = \"md\", label = \"Progress\", onStepChange, className, ...rest },\n ref,\n) {\n const id = useId();\n return (\n <nav\n ref={ref}\n aria-label={label}\n data-size={size}\n className={[\"ds-stepper\", className].filter(Boolean).join(\" \")}\n {...rest}\n >\n <ol className=\"ds-stepper__list\">\n {steps.map((step, index) => {\n const status = statusOf(index, activeStep);\n const interactive = Boolean(onStepChange) && status !== \"upcoming\";\n const marker = (\n <>\n {status === \"complete\" ? (\n <Icon\n name=\"check\"\n size={16}\n aria-hidden=\"true\"\n />\n ) : (\n index + 1\n )}\n <span\n id={`${id}-${index}-status`}\n className=\"ds-stepper__sr\"\n >\n {status}\n </span>\n </>\n );\n return (\n <li\n key={step.id}\n className=\"ds-stepper__step\"\n data-status={status}\n aria-current={status === \"current\" ? \"step\" : undefined}\n >\n <span\n className=\"ds-stepper__track\"\n aria-hidden=\"true\"\n >\n <span\n className=\"ds-stepper__connector\"\n data-side=\"start\"\n />\n <span\n className=\"ds-stepper__connector\"\n data-side=\"end\"\n />\n </span>\n {interactive ? (\n <Button\n className=\"ds-stepper__marker\"\n variant={status === \"complete\" ? \"primary\" : \"active\"}\n size=\"sm\"\n isIconOnly\n aria-labelledby={`${id}-${index}-label`}\n aria-describedby={`${id}-${index}-status`}\n onClick={() => onStepChange?.(index, step.id)}\n >\n {marker}\n </Button>\n ) : (\n <span className=\"ds-stepper__marker\">{marker}</span>\n )}\n <span className=\"ds-stepper__text\">\n <span\n id={`${id}-${index}-label`}\n className=\"ds-stepper__label\"\n >\n {step.label}\n </span>\n {step.description && (\n <span className=\"ds-stepper__description\">{step.description}</span>\n )}\n </span>\n </li>\n );\n })}\n </ol>\n </nav>\n );\n});\n"],"mappings":";;;;;AAiCA,SAASG,EAAS,GAAe,GAAgC;
|
|
1
|
+
{"version":3,"file":"index.js","names":["_Fragment","Icon","Fragment$1","statusOf","index","activeStep","Stepper","forwardRef","rest","id","useId","label","size","className","steps","status","interactive","onStepChange","marker","Button","step"],"sources":["../../../src/components/Stepper/index.tsx"],"sourcesContent":["import { forwardRef, useId, type HTMLAttributes, type ReactNode } from \"react\";\nimport { Icon } from \"../Icon\";\nimport { Button } from \"../Button\";\nimport \"./style.css\";\n\nexport type StepperSize = \"sm\" | \"md\";\nexport type StepStatus = \"complete\" | \"current\" | \"upcoming\";\n\nexport interface Step {\n /** Stable key, and the value reported by `onStepChange`. */\n id: string;\n /** The step in the user's words — sentence case. */\n label: ReactNode;\n /** One line on what happens here. */\n description?: ReactNode;\n}\n\nexport interface StepperProps extends Omit<HTMLAttributes<HTMLElement>, \"onChange\" | \"children\"> {\n /** The ordered steps. Three or more spread evenly across the full width. */\n steps: Step[];\n /** Index of the step being worked on. Everything before it reads as complete. */\n activeStep: number;\n /** Marker scale. `sm` for a toolbar band, `md` for a page header. */\n size?: StepperSize;\n /** Accessible name for the progress bar. */\n label?: string;\n /**\n * Makes completed steps (and the current one) navigable. Omit for a\n * read-only progress indicator.\n */\n onStepChange?: (index: number, id: string) => void;\n}\n\nfunction statusOf(index: number, activeStep: number): StepStatus {\n if (index < activeStep) {\n return \"complete\";\n }\n if (index === activeStep) {\n return \"current\";\n }\n return \"upcoming\";\n}\n\n/**\n * A linear progress rail: 1 - 2 - 3. Steps share the row equally however many\n * there are, so the last marker always lands on the trailing edge.\n */\nexport const Stepper = forwardRef<HTMLElement, StepperProps>(function Stepper(\n { steps, activeStep, size = \"md\", label = \"Progress\", onStepChange, className, ...rest },\n ref,\n) {\n const id = useId();\n return (\n <nav\n ref={ref}\n aria-label={label}\n data-size={size}\n className={[\"ds-stepper\", className].filter(Boolean).join(\" \")}\n {...rest}\n >\n <ol className=\"ds-stepper__list\">\n {steps.map((step, index) => {\n const status = statusOf(index, activeStep);\n const interactive = Boolean(onStepChange) && status !== \"upcoming\";\n const marker = (\n <>\n {status === \"complete\" ? (\n <Icon\n name=\"check\"\n size={16}\n aria-hidden=\"true\"\n />\n ) : (\n index + 1\n )}\n <span\n id={`${id}-${index}-status`}\n className=\"ds-stepper__sr\"\n >\n {status}\n </span>\n </>\n );\n return (\n <li\n key={step.id}\n className=\"ds-stepper__step\"\n data-status={status}\n aria-current={status === \"current\" ? \"step\" : undefined}\n >\n <span\n className=\"ds-stepper__track\"\n aria-hidden=\"true\"\n >\n <span\n className=\"ds-stepper__connector\"\n data-side=\"start\"\n />\n <span\n className=\"ds-stepper__connector\"\n data-side=\"end\"\n />\n </span>\n {interactive ? (\n <Button\n className=\"ds-stepper__marker\"\n variant={status === \"complete\" ? \"primary\" : \"active\"}\n size=\"sm\"\n isIconOnly\n aria-labelledby={`${id}-${index}-label`}\n aria-describedby={`${id}-${index}-status`}\n onClick={() => onStepChange?.(index, step.id)}\n >\n {marker}\n </Button>\n ) : (\n <span className=\"ds-stepper__marker\">{marker}</span>\n )}\n <span className=\"ds-stepper__text\">\n <span\n id={`${id}-${index}-label`}\n className=\"ds-stepper__label\"\n >\n {step.label}\n </span>\n {step.description && (\n <span className=\"ds-stepper__description\">{step.description}</span>\n )}\n </span>\n </li>\n );\n })}\n </ol>\n </nav>\n );\n});\n"],"mappings":";;;;;AAiCA,SAASG,EAAS,GAAe,GAAgC;CAO/D,OANIC,IAAQC,IACH,aAELD,MAAUC,IACL,YAEF;AACT;AAMA,IAAaC,IAAUC,EAAsC,SAC3D,EAAE,UAAO,eAAY,UAAO,MAAM,WAAQ,YAAY,iBAAc,cAAW,GAAGC,KAClF,GACA;CACA,IAAMC,IAAKC,EAAM;CACjB,OACE,kBAAC,OAAD;EACO;EACL,cAAYC;EACZ,aAAWC;EACX,WAAW,CAAC,cAAcC,CAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;EAC7D,GAAIL;EAEJ,UAAA,kBAAC,MAAD;GAAI,WAAU;GACX,UAAAM,EAAM,KAAK,GAAM,MAAU;IAC1B,IAAMC,IAASZ,EAASC,GAAOC,CAAU,GACnCW,IAAc,EAAQC,KAAiBF,MAAW,YAClDG,IACJ,kBAAAlB,GAAA,EAAA,UAAA,CACGe,MAAW,aACV,kBAACd,GAAD;KACE,MAAK;KACL,MAAM;KACN,eAAY;IACb,CAAA,IAEDG,IAAQ,GAEV,kBAAC,QAAD;KACE,IAAI,GAAGK,EAAG,GAAGL,EAAM;KACnB,WAAU;KAET,UAAAW;IACG,CAAA,CACN,EAAA,CAAA;IAEJ,OACE,kBAAC,MAAD;KAEE,WAAU;KACV,eAAaA;KACb,gBAAcA,MAAW,YAAY,SAAS,KAAA;KAJhD,UAAA;MAME,kBAAC,QAAD;OACE,WAAU;OACV,eAAY;OAFd,UAAA,CAIE,kBAAC,QAAD;QACE,WAAU;QACV,aAAU;OACX,CAAA,GACD,kBAAC,QAAD;QACE,WAAU;QACV,aAAU;OACX,CAAA,CACG;;MACLC,IACC,kBAACG,GAAD;OACE,WAAU;OACV,SAASJ,MAAW,aAAa,YAAY;OAC7C,MAAK;OACL,YAAA;OACA,mBAAiB,GAAGN,EAAG,GAAGL,EAAM;OAChC,oBAAkB,GAAGK,EAAG,GAAGL,EAAM;OACjC,eAAea,IAAeb,GAAOgB,EAAK,EAAE;OAE3C,UAAAF;MACK,CAAA,IAER,kBAAC,QAAD;OAAM,WAAU;OAAsB,UAAAA;MAAa,CAAA;MAErD,kBAAC,QAAD;OAAM,WAAU;OAAhB,UAAA,CACE,kBAAC,QAAD;QACE,IAAI,GAAGT,EAAG,GAAGL,EAAM;QACnB,WAAU;QAET,UAAAgB,EAAK;OACF,CAAA,GACLA,EAAK,eACJ,kBAAC,QAAD;QAAM,WAAU;QAA2B,UAAAA,EAAK;OAAkB,CAAA,CAEhE;;KACJ;IA5CG,GAAAA,EAAK,EA4CR;GAER,CAAC;EACC,CAAA;CACD,CAAA;AAET,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/Icon-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/Icon-BBoWP_Y6.cjs"),t=require("../Button/index.cjs");let n=require("react"),r=require("react/jsx-runtime");var i=(0,n.forwardRef)(function({label:e,actions:t,className:n,children:i,...a},o){return(0,r.jsxs)(`nav`,{ref:o,"aria-label":e,className:[`ds-subnav`,n].filter(Boolean).join(` `),...a,children:[(0,r.jsx)(`ul`,{className:`ds-subnav__list`,children:i}),t&&(0,r.jsx)(`div`,{className:`ds-subnav__actions`,children:t})]})}),a=(0,n.forwardRef)(function({label:t,icon:n,isActive:i,count:a,className:o,...s},c){return(0,r.jsx)(`li`,{className:`ds-subnav__row`,children:(0,r.jsxs)(`a`,{ref:c,className:[`ds-subnav__item`,o].filter(Boolean).join(` `),"data-active":i||void 0,"aria-current":i?`page`:void 0,...s,children:[n&&(0,r.jsx)(e.t,{name:n}),t,a!==void 0&&(0,r.jsx)(`span`,{className:`ds-subnav__count`,children:a})]})})}),o=(0,n.forwardRef)(function({label:e,icon:n,isActive:i,count:a,disabled:o,className:s,...c},l){return(0,r.jsx)(`li`,{className:`ds-subnav__row`,children:(0,r.jsxs)(t.Button,{ref:l,variant:`simple`,iconStart:n,isDisabled:o,className:[`ds-subnav__item`,s].filter(Boolean).join(` `),"data-active":i||void 0,"aria-pressed":i,...c,children:[e,a!==void 0&&(0,r.jsx)(`span`,{className:`ds-subnav__count`,children:a})]})})});exports.SubNav=i,exports.SubNavButton=o,exports.SubNavItem=a;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["forwardRef","useState","Button","require_components_Button_index","react","react_jsx_runtime","cx","parts","Switch","rest","internal","setInternal","defaultSelected","current","isSelected","className","required","onClick","event","next","onSelectedChange","children"],"sources":["../../../src/components/Switch/index.tsx"],"sourcesContent":["import { forwardRef, useState, type ButtonHTMLAttributes, type ReactNode } from \"react\";\nimport { Button } from \"../Button\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nexport interface SwitchProps extends Omit<\n ButtonHTMLAttributes<HTMLButtonElement>,\n \"onChange\" | \"value\" | \"disabled\"\n> {\n /** Required state when bound to Field. */\n required?: boolean;\n isSelected?: boolean;\n defaultSelected?: boolean;\n onSelectedChange?: (isSelected: boolean) => void;\n isDisabled?: boolean;\n /** Label to the right of the track. Omit it and pass `aria-label`. */\n children?: ReactNode;\n}\n\n/** An immediate on/off — it commits as it is pressed, no Save behind it. */\nexport const Switch = forwardRef<HTMLButtonElement, SwitchProps>(function Switch(\n {\n isSelected,\n defaultSelected = false,\n onSelectedChange,\n isDisabled = false,\n required,\n className,\n children,\n onClick,\n ...rest\n },\n ref,\n) {\n const [internal, setInternal] = useState(defaultSelected);\n const current = isSelected ?? internal;\n\n return (\n <label className={cx(\"ds-switch\", className)}>\n <Button\n ref={ref}\n variant={current ? \"primary\" : \"neutral\"}\n size=\"sm\"\n role=\"switch\"\n aria-checked={current}\n aria-required={required || undefined}\n isDisabled={isDisabled}\n className=\"ds-switch__track\"\n onClick={(event) => {\n onClick?.(event);\n if (event.defaultPrevented) return;\n const next = !current;\n if (isSelected === undefined) setInternal(next);\n onSelectedChange?.(next);\n }}\n {...rest}\n >\n <span\n className=\"ds-switch__knob\"\n aria-hidden=\"true\"\n />\n </Button>\n {children && <span className=\"ds-switch__label\">{children}</span>}\n </label>\n );\n});\n"],"mappings":"A,gKAIA,SAASM,EAAG,GAAGC,EAAuC,CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,CACvC,CAiBA,IAAaC,GAAA,EAASR,EAAAA,WAAAA,CAA2C,SAC/D,CACE,aACA,kBAAkB,GAClB,mBACA,aAAa,GACb,WACA,YACA,WACA,UACA,GAAGS,GAEL,EACA,CACA,GAAM,CAACC,EAAUC,IAAA,EAAeV,EAAAA,SAAAA,CAASW,CAAe,EAClDC,EAAUC,GAAcJ,EAE9B,OACE,EAAAL,EAAA,KAAA,CAAC,QAAD,CAAO,UAAWC,EAAG,YAAaS,CAAS,EAA3C,SAAA,EACE,EAAAV,EAAA,IAAA,CAACH,EAAAA,OAAD,CACO,MACL,QAASW,EAAU,UAAY,UAC/B,KAAK,KACL,KAAK,SACL,eAAcA,EACd,gBAAeG,GAAY,IAAA,GACf,aACZ,UAAU,mBACV,QAAU,GAAU,CAElB,GADAC,IAAUC,CAAK,EACXA,EAAM,
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["forwardRef","useState","Button","require_components_Button_index","react","react_jsx_runtime","cx","parts","Switch","rest","internal","setInternal","defaultSelected","current","isSelected","className","required","onClick","event","next","onSelectedChange","children"],"sources":["../../../src/components/Switch/index.tsx"],"sourcesContent":["import { forwardRef, useState, type ButtonHTMLAttributes, type ReactNode } from \"react\";\nimport { Button } from \"../Button\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nexport interface SwitchProps extends Omit<\n ButtonHTMLAttributes<HTMLButtonElement>,\n \"onChange\" | \"value\" | \"disabled\"\n> {\n /** Required state when bound to Field. */\n required?: boolean;\n isSelected?: boolean;\n defaultSelected?: boolean;\n onSelectedChange?: (isSelected: boolean) => void;\n isDisabled?: boolean;\n /** Label to the right of the track. Omit it and pass `aria-label`. */\n children?: ReactNode;\n}\n\n/** An immediate on/off — it commits as it is pressed, no Save behind it. */\nexport const Switch = forwardRef<HTMLButtonElement, SwitchProps>(function Switch(\n {\n isSelected,\n defaultSelected = false,\n onSelectedChange,\n isDisabled = false,\n required,\n className,\n children,\n onClick,\n ...rest\n },\n ref,\n) {\n const [internal, setInternal] = useState(defaultSelected);\n const current = isSelected ?? internal;\n\n return (\n <label className={cx(\"ds-switch\", className)}>\n <Button\n ref={ref}\n variant={current ? \"primary\" : \"neutral\"}\n size=\"sm\"\n role=\"switch\"\n aria-checked={current}\n aria-required={required || undefined}\n isDisabled={isDisabled}\n className=\"ds-switch__track\"\n onClick={(event) => {\n onClick?.(event);\n if (event.defaultPrevented) {\n return;\n }\n const next = !current;\n if (isSelected === undefined) {\n setInternal(next);\n }\n onSelectedChange?.(next);\n }}\n {...rest}\n >\n <span\n className=\"ds-switch__knob\"\n aria-hidden=\"true\"\n />\n </Button>\n {children && <span className=\"ds-switch__label\">{children}</span>}\n </label>\n );\n});\n"],"mappings":"A,gKAIA,SAASM,EAAG,GAAGC,EAAuC,CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,CACvC,CAiBA,IAAaC,GAAA,EAASR,EAAAA,WAAAA,CAA2C,SAC/D,CACE,aACA,kBAAkB,GAClB,mBACA,aAAa,GACb,WACA,YACA,WACA,UACA,GAAGS,GAEL,EACA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AAC;IACrB,sEAAsE;IACtE,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,4EAA4E;AAC5E,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/Switch/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,oBAAoB,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAExF,OAAO,aAAa,CAAC;AAMrB,MAAM,WAAW,WAAY,SAAQ,IAAI,CACvC,oBAAoB,CAAC,iBAAiB,CAAC,EACvC,UAAU,GAAG,OAAO,GAAG,UAAU,CAClC;IACC,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IACjD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,sEAAsE;IACtE,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,4EAA4E;AAC5E,eAAO,MAAM,MAAM,2GAiDjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Switch/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,oBAAoB,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAExF,OAAO,aAAa,CAAC;AAMrB,MAAM,WAAW,WAAY,SAAQ,IAAI,CACvC,oBAAoB,CAAC,iBAAiB,CAAC,EACvC,UAAU,GAAG,OAAO,GAAG,UAAU,CAClC;IACC,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IACjD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,sEAAsE;IACtE,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,4EAA4E;AAC5E,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Switch/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,oBAAoB,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAExF,OAAO,aAAa,CAAC;AAMrB,MAAM,WAAW,WAAY,SAAQ,IAAI,CACvC,oBAAoB,CAAC,iBAAiB,CAAC,EACvC,UAAU,GAAG,OAAO,GAAG,UAAU,CAClC;IACC,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IACjD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,sEAAsE;IACtE,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,4EAA4E;AAC5E,eAAO,MAAM,MAAM,2GAiDjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["cx","parts","Switch","forwardRef","rest","internal","setInternal","useState","defaultSelected","current","isSelected","className","Button","required","onClick","event","next","onSelectedChange","children"],"sources":["../../../src/components/Switch/index.tsx"],"sourcesContent":["import { forwardRef, useState, type ButtonHTMLAttributes, type ReactNode } from \"react\";\nimport { Button } from \"../Button\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nexport interface SwitchProps extends Omit<\n ButtonHTMLAttributes<HTMLButtonElement>,\n \"onChange\" | \"value\" | \"disabled\"\n> {\n /** Required state when bound to Field. */\n required?: boolean;\n isSelected?: boolean;\n defaultSelected?: boolean;\n onSelectedChange?: (isSelected: boolean) => void;\n isDisabled?: boolean;\n /** Label to the right of the track. Omit it and pass `aria-label`. */\n children?: ReactNode;\n}\n\n/** An immediate on/off — it commits as it is pressed, no Save behind it. */\nexport const Switch = forwardRef<HTMLButtonElement, SwitchProps>(function Switch(\n {\n isSelected,\n defaultSelected = false,\n onSelectedChange,\n isDisabled = false,\n required,\n className,\n children,\n onClick,\n ...rest\n },\n ref,\n) {\n const [internal, setInternal] = useState(defaultSelected);\n const current = isSelected ?? internal;\n\n return (\n <label className={cx(\"ds-switch\", className)}>\n <Button\n ref={ref}\n variant={current ? \"primary\" : \"neutral\"}\n size=\"sm\"\n role=\"switch\"\n aria-checked={current}\n aria-required={required || undefined}\n isDisabled={isDisabled}\n className=\"ds-switch__track\"\n onClick={(event) => {\n onClick?.(event);\n if (event.defaultPrevented) return;\n const next = !current;\n if (isSelected === undefined) setInternal(next);\n onSelectedChange?.(next);\n }}\n {...rest}\n >\n <span\n className=\"ds-switch__knob\"\n aria-hidden=\"true\"\n />\n </Button>\n {children && <span className=\"ds-switch__label\">{children}</span>}\n </label>\n );\n});\n"],"mappings":";;;;AAIA,SAASA,EAAG,GAAGC,GAAuC;CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;AACvC;AAiBA,IAAaC,IAASC,EAA2C,SAC/D,EACE,eACA,qBAAkB,IAClB,qBACA,gBAAa,IACb,aACA,cACA,aACA,YACA,GAAGC,KAEL,GACA;CACA,IAAM,CAACC,GAAUC,KAAeC,EAASC,CAAe,GAClDC,IAAUC,KAAcL;CAE9B,OACE,kBAAC,SAAD;EAAO,WAAWL,EAAG,aAAaW,CAAS;EAA3C,UAAA,CACE,kBAACC,GAAD;GACO;GACL,SAASH,IAAU,YAAY;GAC/B,MAAK;GACL,MAAK;GACL,gBAAcA;GACd,iBAAeI,KAAY,KAAA;GACf;GACZ,WAAU;GACV,UAAU,MAAU;IAElB,IADAC,IAAUC,CAAK,GACXA,EAAM,
|
|
1
|
+
{"version":3,"file":"index.js","names":["cx","parts","Switch","forwardRef","rest","internal","setInternal","useState","defaultSelected","current","isSelected","className","Button","required","onClick","event","next","onSelectedChange","children"],"sources":["../../../src/components/Switch/index.tsx"],"sourcesContent":["import { forwardRef, useState, type ButtonHTMLAttributes, type ReactNode } from \"react\";\nimport { Button } from \"../Button\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nexport interface SwitchProps extends Omit<\n ButtonHTMLAttributes<HTMLButtonElement>,\n \"onChange\" | \"value\" | \"disabled\"\n> {\n /** Required state when bound to Field. */\n required?: boolean;\n isSelected?: boolean;\n defaultSelected?: boolean;\n onSelectedChange?: (isSelected: boolean) => void;\n isDisabled?: boolean;\n /** Label to the right of the track. Omit it and pass `aria-label`. */\n children?: ReactNode;\n}\n\n/** An immediate on/off — it commits as it is pressed, no Save behind it. */\nexport const Switch = forwardRef<HTMLButtonElement, SwitchProps>(function Switch(\n {\n isSelected,\n defaultSelected = false,\n onSelectedChange,\n isDisabled = false,\n required,\n className,\n children,\n onClick,\n ...rest\n },\n ref,\n) {\n const [internal, setInternal] = useState(defaultSelected);\n const current = isSelected ?? internal;\n\n return (\n <label className={cx(\"ds-switch\", className)}>\n <Button\n ref={ref}\n variant={current ? \"primary\" : \"neutral\"}\n size=\"sm\"\n role=\"switch\"\n aria-checked={current}\n aria-required={required || undefined}\n isDisabled={isDisabled}\n className=\"ds-switch__track\"\n onClick={(event) => {\n onClick?.(event);\n if (event.defaultPrevented) {\n return;\n }\n const next = !current;\n if (isSelected === undefined) {\n setInternal(next);\n }\n onSelectedChange?.(next);\n }}\n {...rest}\n >\n <span\n className=\"ds-switch__knob\"\n aria-hidden=\"true\"\n />\n </Button>\n {children && <span className=\"ds-switch__label\">{children}</span>}\n </label>\n );\n});\n"],"mappings":";;;;AAIA,SAASA,EAAG,GAAGC,GAAuC;CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;AACvC;AAiBA,IAAaC,IAASC,EAA2C,SAC/D,EACE,eACA,qBAAkB,IAClB,qBACA,gBAAa,IACb,aACA,cACA,aACA,YACA,GAAGC,KAEL,GACA;CACA,IAAM,CAACC,GAAUC,KAAeC,EAASC,CAAe,GAClDC,IAAUC,KAAcL;CAE9B,OACE,kBAAC,SAAD;EAAO,WAAWL,EAAG,aAAaW,CAAS;EAA3C,UAAA,CACE,kBAACC,GAAD;GACO;GACL,SAASH,IAAU,YAAY;GAC/B,MAAK;GACL,MAAK;GACL,gBAAcA;GACd,iBAAeI,KAAY,KAAA;GACf;GACZ,WAAU;GACV,UAAU,MAAU;IAElB,IADAC,IAAUC,CAAK,GACXA,EAAM,kBACR;IAEF,IAAMC,IAAO,CAACP;IAId,AAHIC,MAAe,KAAA,KACjBJ,EAAYU,CAAI,GAElBC,IAAmBD,CAAI;GACzB;GACA,GAAIZ;GAEJ,UAAA,kBAAC,QAAD;IACE,WAAU;IACV,eAAY;GACb,CAAA;EACK,CAAA,GACPc,KAAY,kBAAC,QAAD;GAAM,WAAU;GAAoB;EAAe,CAAA,CAC3D;;AAEX,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/Icon-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/Icon-BBoWP_Y6.cjs");let t=require("react"),n=require("react/jsx-runtime");function r(...e){return e.filter(Boolean).join(` `)}var i=(0,t.forwardRef)(function({className:e,children:t,...i},a){return(0,n.jsx)(`div`,{ref:a,className:r(`ds-table-frame`,e),...i,children:t})}),a=(0,t.forwardRef)(function({start:e,end:t,className:i,...a},o){return(0,n.jsxs)(`div`,{ref:o,className:r(`ds-table-toolbar`,i),...a,children:[(0,n.jsx)(`div`,{className:`ds-table-toolbar__group`,children:e}),(0,n.jsx)(`div`,{className:`ds-table-toolbar__group`,children:t})]})});function o(e){return t.Children.toArray(e).some(e=>(0,t.isValidElement)(e)&&(e.type!==t.Fragment||o(e.props.children)))}var s=(0,t.createContext)({emptyMessage:`No data found.`}),c=(0,t.forwardRef)(function({emptyMessage:e=`No data found.`,isEmpty:t,className:i,children:a,...o},c){return(0,n.jsx)(s.Provider,{value:{emptyMessage:e,isEmpty:t},children:(0,n.jsx)(`div`,{className:`ds-table-frame__scroll`,children:(0,n.jsx)(`table`,{...o,ref:c,className:r(`ds-table`,i),children:a})})})}),l=(0,t.forwardRef)(function({className:e,...t},r){return(0,n.jsx)(`thead`,{ref:r,className:e,...t})}),u=(0,t.forwardRef)(function({className:e,children:r,...i},a){let{emptyMessage:c,isEmpty:l}=(0,t.useContext)(s);return(0,n.jsx)(`tbody`,{ref:a,className:e,...i,children:l??!o(r)?(0,n.jsx)(d,{children:(0,n.jsx)(p,{colSpan:1e3,className:`ds-table__empty-cell`,children:(0,n.jsx)(m,{title:c,role:`status`})})}):r})}),d=(0,t.forwardRef)(function({isSelected:e=!1,isInteractive:t=!1,className:r,...i},a){return(0,n.jsx)(`tr`,{ref:a,"data-selected":e||void 0,"data-interactive":t||void 0,tabIndex:t?0:void 0,className:r,...i})}),f=(0,t.forwardRef)(function({align:e=`start`,width:t=`auto`,className:r,...i},a){return(0,n.jsx)(`th`,{ref:a,scope:`col`,"data-align":e,"data-width":t,className:r,...i})}),p=(0,t.forwardRef)(function({align:e=`start`,width:t=`auto`,emphasis:r=`default`,className:i,...a},o){return(0,n.jsx)(`td`,{ref:o,"data-align":e,"data-width":t,"data-emphasis":r==="default"?void 0:r,className:i,...a})}),m=(0,t.forwardRef)(function({icon:t=`info`,title:i=`No data found.`,description:a,action:o,className:s,...c},l){return(0,n.jsxs)(`div`,{ref:l,className:r(`ds-table-empty`,s),...c,children:[(0,n.jsx)(e.t,{name:t,size:24}),(0,n.jsx)(`span`,{style:{color:`var(--color-text)`,fontWeight:`var(--font-weight-bold)`},children:i}),a&&(0,n.jsx)(`span`,{children:a}),o]})});exports.Table=c,exports.TableBody=u,exports.TableCell=p,exports.TableEmpty=m,exports.TableFrame=i,exports.TableHead=l,exports.TableHeaderCell=f,exports.TableRow=d,exports.TableToolbar=a;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as e } from "../../chunks/Icon-
|
|
1
|
+
import { t as e } from "../../chunks/Icon-XNismJDm.js";
|
|
2
2
|
import { Children as t, Fragment as n, createContext as r, forwardRef as i, isValidElement as a, useContext as o } from "react";
|
|
3
3
|
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
4
4
|
//#region src/components/Table/index.tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["forwardRef","useState","useRef","Button","require_components_Button_index","react","react_jsx_runtime","cx","parts","TagsInput","ariaInvalid","rest","internal","setInternal","defaultValue","current","value","draft","setDraft","inputRef","commit","next","onValueChange","add","tag","raw","max","className","size","isDisabled","isInvalid","event","item","node","ref","placeholder","required"],"sources":["../../../src/components/TagsInput/index.tsx"],"sourcesContent":["import { forwardRef, useRef, useState, type KeyboardEvent } from \"react\";\nimport { Button } from \"../Button\";\nimport type { FieldBinding, FieldSize } from \"../Field\";\nimport \"../Field/style.css\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nexport interface TagsInputProps extends FieldBinding {\n value?: string[];\n defaultValue?: string[];\n onValueChange?: (value: string[]) => void;\n placeholder?: string;\n size?: FieldSize;\n /** Stop accepting new tags past this count. */\n max?: number;\n isDisabled?: boolean;\n isInvalid?: boolean;\n className?: string;\n}\n\n/**\n * Free-text keywords. Enter or comma commits a tag, Backspace on an empty\n * input removes the last one. Tags are plain strings — never status tones.\n */\nexport const TagsInput = forwardRef<HTMLInputElement, TagsInputProps>(function TagsInput(\n {\n value,\n defaultValue = [],\n onValueChange,\n placeholder = \"Add a tag\",\n size = \"md\",\n max,\n isDisabled = false,\n isInvalid = false,\n required,\n \"aria-invalid\": ariaInvalid,\n className,\n ...rest\n },\n ref,\n) {\n const [internal, setInternal] = useState<string[]>(defaultValue);\n const current = value ?? internal;\n const [draft, setDraft] = useState(\"\");\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n const commit = (next: string[]) => {\n if (value === undefined) setInternal(next);\n onValueChange?.(next);\n };\n\n const add = (raw: string) => {\n const tag = raw.trim();\n if (!tag || current.includes(tag)) return;\n if (max !== undefined && current.length >= max) return;\n commit([...current, tag]);\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === \"Enter\" || event.key === \",\") {\n event.preventDefault();\n add(draft);\n setDraft(\"\");\n } else if (event.key === \"Backspace\" && draft === \"\" && current.length > 0) {\n commit(current.slice(0, -1));\n }\n };\n\n return (\n <div\n className={cx(\"ds-field-skin\", \"ds-tags\", className)}\n data-size={size}\n data-disabled={isDisabled || undefined}\n aria-invalid={isInvalid || ariaInvalid || undefined}\n onClick={() => inputRef.current?.focus()}\n >\n {current.map((tag) => (\n <span\n key={tag}\n className=\"ds-tags__tag\"\n >\n {tag}\n <Button\n variant=\"simple\"\n size=\"xs\"\n isIconOnly\n iconStart=\"x\"\n aria-label={`Remove ${tag}`}\n isDisabled={isDisabled}\n onClick={(event) => {\n event.stopPropagation();\n commit(current.filter((item) => item !== tag));\n }}\n />\n </span>\n ))}\n <input\n ref={(node) => {\n inputRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }}\n type=\"text\"\n className=\"ds-tags__input\"\n value={draft}\n placeholder={current.length === 0 ? placeholder : \"\"}\n disabled={isDisabled}\n aria-invalid={isInvalid || ariaInvalid || undefined}\n aria-required={required || undefined}\n onChange={(event) => setDraft(event.target.value)}\n onKeyDown={onKeyDown}\n onBlur={() => {\n add(draft);\n setDraft(\"\");\n }}\n {...rest}\n />\n </div>\n );\n});\n"],"mappings":"A,2MAMA,SAASO,EAAG,GAAGC,EAAuC,CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,CACvC,CAmBA,IAAaC,GAAA,EAAYT,EAAAA,WAAAA,CAA6C,SACpE,CACE,QACA,eAAe,CAAC,EAChB,gBACA,cAAc,YACd,OAAO,KACP,MACA,aAAa,GACb,YAAY,GACZ,WACA,eAAgBU,EAChB,YACA,GAAGC,GAEL,EACA,CACA,GAAM,CAACC,EAAUC,IAAA,EAAeZ,EAAAA,SAAAA,CAAmBa,CAAY,EACzDC,EAAUC,GAASJ,EACnB,CAACK,EAAOC,IAAA,EAAYjB,EAAAA,SAAAA,CAAS,EAAE,EAC/BkB,GAAA,EAAWjB,EAAAA,OAAAA,CAAgC,IAAI,EAE/CkB,EAAU,GAAmB,CAC7BJ,IAAU,IAAA,
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["forwardRef","useState","useRef","Button","require_components_Button_index","react","react_jsx_runtime","cx","parts","TagsInput","ariaInvalid","rest","internal","setInternal","defaultValue","current","value","draft","setDraft","inputRef","commit","next","onValueChange","add","tag","raw","max","className","size","isDisabled","isInvalid","event","item","node","ref","placeholder","required"],"sources":["../../../src/components/TagsInput/index.tsx"],"sourcesContent":["import { forwardRef, useRef, useState, type KeyboardEvent } from \"react\";\nimport { Button } from \"../Button\";\nimport type { FieldBinding, FieldSize } from \"../Field\";\nimport \"../Field/style.css\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nexport interface TagsInputProps extends FieldBinding {\n value?: string[];\n defaultValue?: string[];\n onValueChange?: (value: string[]) => void;\n placeholder?: string;\n size?: FieldSize;\n /** Stop accepting new tags past this count. */\n max?: number;\n isDisabled?: boolean;\n isInvalid?: boolean;\n className?: string;\n}\n\n/**\n * Free-text keywords. Enter or comma commits a tag, Backspace on an empty\n * input removes the last one. Tags are plain strings — never status tones.\n */\nexport const TagsInput = forwardRef<HTMLInputElement, TagsInputProps>(function TagsInput(\n {\n value,\n defaultValue = [],\n onValueChange,\n placeholder = \"Add a tag\",\n size = \"md\",\n max,\n isDisabled = false,\n isInvalid = false,\n required,\n \"aria-invalid\": ariaInvalid,\n className,\n ...rest\n },\n ref,\n) {\n const [internal, setInternal] = useState<string[]>(defaultValue);\n const current = value ?? internal;\n const [draft, setDraft] = useState(\"\");\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n const commit = (next: string[]) => {\n if (value === undefined) {\n setInternal(next);\n }\n onValueChange?.(next);\n };\n\n const add = (raw: string) => {\n const tag = raw.trim();\n if (!tag || current.includes(tag)) {\n return;\n }\n if (max !== undefined && current.length >= max) {\n return;\n }\n commit([...current, tag]);\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === \"Enter\" || event.key === \",\") {\n event.preventDefault();\n add(draft);\n setDraft(\"\");\n } else if (event.key === \"Backspace\" && draft === \"\" && current.length > 0) {\n commit(current.slice(0, -1));\n }\n };\n\n return (\n <div\n className={cx(\"ds-field-skin\", \"ds-tags\", className)}\n data-size={size}\n data-disabled={isDisabled || undefined}\n aria-invalid={isInvalid || ariaInvalid || undefined}\n onClick={() => inputRef.current?.focus()}\n >\n {current.map((tag) => (\n <span\n key={tag}\n className=\"ds-tags__tag\"\n >\n {tag}\n <Button\n variant=\"simple\"\n size=\"xs\"\n isIconOnly\n iconStart=\"x\"\n aria-label={`Remove ${tag}`}\n isDisabled={isDisabled}\n onClick={(event) => {\n event.stopPropagation();\n commit(current.filter((item) => item !== tag));\n }}\n />\n </span>\n ))}\n <input\n ref={(node) => {\n inputRef.current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n ref.current = node;\n }\n }}\n type=\"text\"\n className=\"ds-tags__input\"\n value={draft}\n placeholder={current.length === 0 ? placeholder : \"\"}\n disabled={isDisabled}\n aria-invalid={isInvalid || ariaInvalid || undefined}\n aria-required={required || undefined}\n onChange={(event) => setDraft(event.target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AU,IACV,aAAY,UAAUqB,IACV,aACZ,QAAU,GAAU,CAClBO,EAAM,gBAAgB,EACtBX,EAAOL,EAAQ,OAAQ,GAASiB,IAASR,CAAG,CAAC,CAC/C,CACD,CAAA,CACG,CAhBC,EAAAA,CAgBD,CACP,GACD,EAAAlB,EAAA,IAAA,CAAC,QAAD,CACE,IAAM,GAAS,CACb,EAAS,QAAU2B,EACf,OAAOC,GAAQ,WACjBA,EAAID,CAAI,EACCC,IACT,EAAI,QAAUD,EAElB,EACA,KAAK,OACL,UAAU,iBACV,MAAOhB,EACP,YAAaF,EAAQ,SAAW,EAAIoB,EAAc,GAClD,SAAUN,EACV,eAAcC,GAAapB,GAAe,IAAA,GAC1C,gBAAe0B,GAAY,IAAA,GAC3B,SAAW,GAAUlB,EAASa,EAAM,OAAO,KAAK,EACrC,UAvDE,GAA2C,CACxDA,EAAM,MAAQ,SAAWA,EAAM,MAAQ,KACzCA,EAAM,eAAe,EACrBR,EAAIN,CAAK,EACTC,EAAS,EAAE,GACFa,EAAM,MAAQ,aAAed,IAAU,IAAMF,EAAQ,OAAS,GACvEK,EAAOL,EAAQ,MAAM,EAAG,EAAE,CAAC,CAE/B,EAgDM,WAAc,CACZQ,EAAIN,CAAK,EACTC,EAAS,EAAE,CACb,EACA,GAAIP,CACL,CAAA,CACE,C,EAET,CAAC,E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/TagsInput/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,oBAAoB,CAAC;AAC5B,OAAO,aAAa,CAAC;AAMrB,MAAM,WAAW,cAAe,SAAQ,YAAY;IAClD,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,+CAA+C;IAC/C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/TagsInput/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,oBAAoB,CAAC;AAC5B,OAAO,aAAa,CAAC;AAMrB,MAAM,WAAW,cAAe,SAAQ,YAAY;IAClD,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,+CAA+C;IAC/C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS,6GAwGpB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/TagsInput/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,oBAAoB,CAAC;AAC5B,OAAO,aAAa,CAAC;AAMrB,MAAM,WAAW,cAAe,SAAQ,YAAY;IAClD,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,+CAA+C;IAC/C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/TagsInput/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,oBAAoB,CAAC;AAC5B,OAAO,aAAa,CAAC;AAMrB,MAAM,WAAW,cAAe,SAAQ,YAAY;IAClD,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,+CAA+C;IAC/C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS,6GAwGpB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["cx","parts","TagsInput","forwardRef","ariaInvalid","rest","internal","setInternal","useState","defaultValue","current","value","draft","setDraft","inputRef","useRef","commit","next","onValueChange","add","tag","raw","max","className","size","isDisabled","isInvalid","Button","event","item","node","ref","placeholder","required"],"sources":["../../../src/components/TagsInput/index.tsx"],"sourcesContent":["import { forwardRef, useRef, useState, type KeyboardEvent } from \"react\";\nimport { Button } from \"../Button\";\nimport type { FieldBinding, FieldSize } from \"../Field\";\nimport \"../Field/style.css\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nexport interface TagsInputProps extends FieldBinding {\n value?: string[];\n defaultValue?: string[];\n onValueChange?: (value: string[]) => void;\n placeholder?: string;\n size?: FieldSize;\n /** Stop accepting new tags past this count. */\n max?: number;\n isDisabled?: boolean;\n isInvalid?: boolean;\n className?: string;\n}\n\n/**\n * Free-text keywords. Enter or comma commits a tag, Backspace on an empty\n * input removes the last one. Tags are plain strings — never status tones.\n */\nexport const TagsInput = forwardRef<HTMLInputElement, TagsInputProps>(function TagsInput(\n {\n value,\n defaultValue = [],\n onValueChange,\n placeholder = \"Add a tag\",\n size = \"md\",\n max,\n isDisabled = false,\n isInvalid = false,\n required,\n \"aria-invalid\": ariaInvalid,\n className,\n ...rest\n },\n ref,\n) {\n const [internal, setInternal] = useState<string[]>(defaultValue);\n const current = value ?? internal;\n const [draft, setDraft] = useState(\"\");\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n const commit = (next: string[]) => {\n if (value === undefined) setInternal(next);\n onValueChange?.(next);\n };\n\n const add = (raw: string) => {\n const tag = raw.trim();\n if (!tag || current.includes(tag)) return;\n if (max !== undefined && current.length >= max) return;\n commit([...current, tag]);\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === \"Enter\" || event.key === \",\") {\n event.preventDefault();\n add(draft);\n setDraft(\"\");\n } else if (event.key === \"Backspace\" && draft === \"\" && current.length > 0) {\n commit(current.slice(0, -1));\n }\n };\n\n return (\n <div\n className={cx(\"ds-field-skin\", \"ds-tags\", className)}\n data-size={size}\n data-disabled={isDisabled || undefined}\n aria-invalid={isInvalid || ariaInvalid || undefined}\n onClick={() => inputRef.current?.focus()}\n >\n {current.map((tag) => (\n <span\n key={tag}\n className=\"ds-tags__tag\"\n >\n {tag}\n <Button\n variant=\"simple\"\n size=\"xs\"\n isIconOnly\n iconStart=\"x\"\n aria-label={`Remove ${tag}`}\n isDisabled={isDisabled}\n onClick={(event) => {\n event.stopPropagation();\n commit(current.filter((item) => item !== tag));\n }}\n />\n </span>\n ))}\n <input\n ref={(node) => {\n inputRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }}\n type=\"text\"\n className=\"ds-tags__input\"\n value={draft}\n placeholder={current.length === 0 ? placeholder : \"\"}\n disabled={isDisabled}\n aria-invalid={isInvalid || ariaInvalid || undefined}\n aria-required={required || undefined}\n onChange={(event) => setDraft(event.target.value)}\n onKeyDown={onKeyDown}\n onBlur={() => {\n add(draft);\n setDraft(\"\");\n }}\n {...rest}\n />\n </div>\n );\n});\n"],"mappings":";;;;;AAMA,SAASA,EAAG,GAAGC,GAAuC;CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;AACvC;AAmBA,IAAaC,IAAYC,EAA6C,SACpE,EACE,UACA,kBAAe,CAAC,GAChB,kBACA,iBAAc,aACd,UAAO,MACP,QACA,gBAAa,IACb,eAAY,IACZ,aACA,gBAAgBC,GAChB,cACA,GAAGC,KAEL,GACA;CACA,IAAM,CAACC,GAAUC,KAAeC,EAAmBC,CAAY,GACzDC,IAAUC,KAASL,GACnB,CAACM,GAAOC,KAAYL,EAAS,EAAE,GAC/BM,IAAWC,EAAgC,IAAI,GAE/CC,KAAU,MAAmB;
|
|
1
|
+
{"version":3,"file":"index.js","names":["cx","parts","TagsInput","forwardRef","ariaInvalid","rest","internal","setInternal","useState","defaultValue","current","value","draft","setDraft","inputRef","useRef","commit","next","onValueChange","add","tag","raw","max","className","size","isDisabled","isInvalid","Button","event","item","node","ref","placeholder","required"],"sources":["../../../src/components/TagsInput/index.tsx"],"sourcesContent":["import { forwardRef, useRef, useState, type KeyboardEvent } from \"react\";\nimport { Button } from \"../Button\";\nimport type { FieldBinding, FieldSize } from \"../Field\";\nimport \"../Field/style.css\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nexport interface TagsInputProps extends FieldBinding {\n value?: string[];\n defaultValue?: string[];\n onValueChange?: (value: string[]) => void;\n placeholder?: string;\n size?: FieldSize;\n /** Stop accepting new tags past this count. */\n max?: number;\n isDisabled?: boolean;\n isInvalid?: boolean;\n className?: string;\n}\n\n/**\n * Free-text keywords. Enter or comma commits a tag, Backspace on an empty\n * input removes the last one. Tags are plain strings — never status tones.\n */\nexport const TagsInput = forwardRef<HTMLInputElement, TagsInputProps>(function TagsInput(\n {\n value,\n defaultValue = [],\n onValueChange,\n placeholder = \"Add a tag\",\n size = \"md\",\n max,\n isDisabled = false,\n isInvalid = false,\n required,\n \"aria-invalid\": ariaInvalid,\n className,\n ...rest\n },\n ref,\n) {\n const [internal, setInternal] = useState<string[]>(defaultValue);\n const current = value ?? internal;\n const [draft, setDraft] = useState(\"\");\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n const commit = (next: string[]) => {\n if (value === undefined) {\n setInternal(next);\n }\n onValueChange?.(next);\n };\n\n const add = (raw: string) => {\n const tag = raw.trim();\n if (!tag || current.includes(tag)) {\n return;\n }\n if (max !== undefined && current.length >= max) {\n return;\n }\n commit([...current, tag]);\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === \"Enter\" || event.key === \",\") {\n event.preventDefault();\n add(draft);\n setDraft(\"\");\n } else if (event.key === \"Backspace\" && draft === \"\" && current.length > 0) {\n commit(current.slice(0, -1));\n }\n };\n\n return (\n <div\n className={cx(\"ds-field-skin\", \"ds-tags\", className)}\n data-size={size}\n data-disabled={isDisabled || undefined}\n aria-invalid={isInvalid || ariaInvalid || undefined}\n onClick={() => inputRef.current?.focus()}\n >\n {current.map((tag) => (\n <span\n key={tag}\n className=\"ds-tags__tag\"\n >\n {tag}\n <Button\n variant=\"simple\"\n size=\"xs\"\n isIconOnly\n iconStart=\"x\"\n aria-label={`Remove ${tag}`}\n isDisabled={isDisabled}\n onClick={(event) => {\n event.stopPropagation();\n commit(current.filter((item) => item !== tag));\n }}\n />\n </span>\n ))}\n <input\n ref={(node) => {\n inputRef.current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n ref.current = node;\n }\n }}\n type=\"text\"\n className=\"ds-tags__input\"\n value={draft}\n placeholder={current.length === 0 ? placeholder : \"\"}\n disabled={isDisabled}\n aria-invalid={isInvalid || ariaInvalid || undefined}\n aria-required={required || undefined}\n onChange={(event) => setDraft(event.target.value)}\n onKeyDown={onKeyDown}\n onBlur={() => {\n add(draft);\n setDraft(\"\");\n }}\n {...rest}\n />\n </div>\n );\n});\n"],"mappings":";;;;;AAMA,SAASA,EAAG,GAAGC,GAAuC;CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;AACvC;AAmBA,IAAaC,IAAYC,EAA6C,SACpE,EACE,UACA,kBAAe,CAAC,GAChB,kBACA,iBAAc,aACd,UAAO,MACP,QACA,gBAAa,IACb,eAAY,IACZ,aACA,gBAAgBC,GAChB,cACA,GAAGC,KAEL,GACA;CACA,IAAM,CAACC,GAAUC,KAAeC,EAAmBC,CAAY,GACzDC,IAAUC,KAASL,GACnB,CAACM,GAAOC,KAAYL,EAAS,EAAE,GAC/BM,IAAWC,EAAgC,IAAI,GAE/CC,KAAU,MAAmB;EAIjC,AAHIL,MAAU,KAAA,KACZJ,EAAYU,CAAI,GAElBC,IAAgBD,CAAI;CACtB,GAEME,KAAO,MAAgB;EAC3B,IAAMC,IAAMC,EAAI,KAAK;EACrB,AAAKD,KAAO,GAAQ,SAASA,CAAG,MAG5BE,M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AC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["forwardRef","useRef","useState","useId","_Fragment","Popover","require_components_Popover_index","react","react_jsx_runtime","cx","parts","MONTHS","MINUTE","HOUR","DAY","WEEK","pad","value","formatAbsoluteDate","options","stem","date","hasYear","formatAbsoluteTime","stamp","hasTimeZone","zone","part","formatRelativeTime","delta","now","days","Time","describedBy","rest","anchorRef","isOpen","setIsOpen","tooltipId","setTick","format","id","t","refreshInterval","label","isTipped","hasTooltip","node","ref","className","tabIndex","title","onMouseEnter","event","onMouseLeave","onFocus","onBlur","onKeyDown"],"sources":["../../../src/components/Time/index.tsx"],"sourcesContent":["import { forwardRef, useEffect, useId, useRef, useState, type HTMLAttributes } from \"react\";\nimport { Popover } from \"../Popover\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nconst MONTHS = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"];\n\nconst MINUTE = 60_000;\nconst HOUR = 60 * MINUTE;\nconst DAY = 24 * HOUR;\nconst WEEK = 7 * DAY;\n\nfunction pad(value: number) {\n return String(value).padStart(2, \"0\");\n}\n\n/** Day before month, one order everywhere: `12 Jun 2026`. */\nexport function formatAbsoluteDate(date: Date, options: { hasYear?: boolean } = {}) {\n const { hasYear = true } = options;\n const stem = `${date.getDate()} ${MONTHS[date.getMonth()]}`;\n return hasYear ? `${stem} ${date.getFullYear()}` : stem;\n}\n\n/** The tooltip form: `6 Aug 2026, 11:05`, with the reader's zone appended. */\nexport function formatAbsoluteTime(date: Date, options: { hasTimeZone?: boolean } = {}) {\n const { hasTimeZone = true } = options;\n const stamp = `${formatAbsoluteDate(date)}, ${pad(date.getHours())}:${pad(date.getMinutes())}`;\n if (!hasTimeZone) return stamp;\n const zone = new Intl.DateTimeFormat(undefined, { timeZoneName: \"short\" })\n .formatToParts(date)\n .find((part) => part.type === \"timeZoneName\")?.value;\n return zone ? `${stamp} ${zone}` : stamp;\n}\n\n/**\n * Relative up to a week, absolute after. Future dates are always absolute — a\n * scheduled publish reads `12 Jun`, never `in 3 days`.\n */\nexport function formatRelativeTime(date: Date, now: Date = new Date()) {\n const delta = now.getTime() - date.getTime();\n if (delta < 0) {\n return formatAbsoluteDate(date, { hasYear: date.getFullYear() !== now.getFullYear() });\n }\n if (delta < MINUTE) return \"Just now\";\n if (delta < HOUR) return `${Math.floor(delta / MINUTE)}m ago`;\n if (delta < DAY) return `${Math.floor(delta / HOUR)}h ago`;\n if (delta < WEEK) {\n const days = Math.floor(delta / DAY);\n return `${days} ${days === 1 ? \"day\" : \"days\"} ago`;\n }\n return formatAbsoluteDate(date, { hasYear: date.getFullYear() !== now.getFullYear() });\n}\n\nexport type TimeFormat = \"auto\" | \"relative\" | \"absolute\";\n\nexport interface TimeProps extends Omit<HTMLAttributes<HTMLElement>, \"children\"> {\n /** The instant to print — Date, epoch ms, or an ISO string. */\n value: Date | string | number;\n /** `auto` ages the value; `absolute` always prints the date. */\n format?: TimeFormat;\n /** Show the absolute stamp on hover and focus. */\n hasTooltip?: boolean;\n /** Append the reader's time zone to the tooltip. */\n hasTimeZone?: boolean;\n /** Pin \"now\" — useful for tests and stories. */\n now?: Date;\n /** Re-render interval in ms while the value is still relative. */\n refreshInterval?: number;\n}\n\n/**\n * A machine-readable `<time>` that ages itself. One form per cell: relative or\n * absolute, never both side by side.\n */\nexport const Time = forwardRef<HTMLTimeElement, TimeProps>(function Time(\n {\n value,\n format = \"auto\",\n hasTooltip = true,\n hasTimeZone = true,\n now,\n refreshInterval = 30_000,\n className,\n tabIndex,\n title,\n onMouseEnter,\n onMouseLeave,\n onFocus,\n onBlur,\n onKeyDown,\n \"aria-describedby\": describedBy,\n ...rest\n },\n ref,\n) {\n const date = value instanceof Date ? value : new Date(value);\n const anchorRef = useRef<HTMLTimeElement | null>(null);\n const [isOpen, setIsOpen] = useState(false);\n const tooltipId = useId();\n const [, setTick] = useState(0);\n\n useEffect(() => {\n if (format === \"absolute\" || now) return;\n const id = window.setInterval(() => setTick((t) => t + 1), refreshInterval);\n return () => window.clearInterval(id);\n }, [format, now, refreshInterval]);\n\n if (Number.isNaN(date.getTime())) return null;\n\n const reference = now ?? new Date();\n const label =\n format === \"absolute\" ? formatAbsoluteDate(date) : formatRelativeTime(date, reference);\n const stamp = formatAbsoluteTime(date, { hasTimeZone });\n const isTipped = hasTooltip && label !== stamp;\n\n return (\n <>\n <time\n ref={(node) => {\n anchorRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }}\n dateTime={date.toISOString()}\n suppressHydrationWarning\n className={cx(\"ds-time\", !isTipped && \"ds-time--plain\", className)}\n tabIndex={tabIndex ?? (isTipped ? 0 : undefined)}\n aria-describedby={\n [describedBy, isTipped && isOpen && tooltipId].filter(Boolean).join(\" \") || undefined\n }\n title={title ?? (isTipped ? undefined : stamp)}\n onMouseEnter={(event) => {\n onMouseEnter?.(event);\n if (isTipped && !event.defaultPrevented) setIsOpen(true);\n }}\n onMouseLeave={(event) => {\n onMouseLeave?.(event);\n if (isTipped && !event.defaultPrevented) setIsOpen(false);\n }}\n onFocus={(event) => {\n onFocus?.(event);\n if (isTipped && !event.defaultPrevented) setIsOpen(true);\n }}\n onBlur={(event) => {\n onBlur?.(event);\n if (isTipped && !event.defaultPrevented) setIsOpen(false);\n }}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (isTipped && !event.defaultPrevented && event.key === \"Escape\") setIsOpen(false);\n }}\n {...rest}\n >\n {label}\n </time>\n {isTipped && (\n <Popover\n anchorRef={anchorRef}\n isOpen={isOpen}\n id={tooltipId}\n role=\"tooltip\"\n className=\"ds-surface-raised ds-time-tooltip\"\n >\n {stamp}\n </Popover>\n )}\n </>\n );\n});\n"],"mappings":"A,iKAIA,SAASS,EAAG,GAAGC,EAAuC,CACpD,OAAOA,EAAM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fragment","Popover","require_components_Popover_index","react","react_jsx_runtime","cx","parts","MONTHS","MINUTE","HOUR","DAY","WEEK","pad","value","formatAbsoluteDate","options","stem","date","hasYear","formatAbsoluteTime","stamp","hasTimeZone","zone","part","formatRelativeTime","delta","now","days","Time","describedBy","rest","anchorRef","isOpen","setIsOpen","tooltipId","setTick","format","id","t","refreshInterval","label","isTipped","hasTooltip","node","ref","className","tabIndex","title","onMouseEnter","event","onMouseLeave","onFocus","onBlur","onKeyDown"],"sources":["../../../src/components/Time/index.tsx"],"sourcesContent":["import { forwardRef, useEffect, useId, useRef, useState, type HTMLAttributes } from \"react\";\nimport { Popover } from \"../Popover\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nconst MONTHS = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"];\n\nconst MINUTE = 60_000;\nconst HOUR = 60 * MINUTE;\nconst DAY = 24 * HOUR;\nconst WEEK = 7 * DAY;\n\nfunction pad(value: number) {\n return String(value).padStart(2, \"0\");\n}\n\n/** Day before month, one order everywhere: `12 Jun 2026`. */\nexport function formatAbsoluteDate(date: Date, options: { hasYear?: boolean } = {}) {\n const { hasYear = true } = options;\n const stem = `${date.getDate()} ${MONTHS[date.getMonth()]}`;\n return hasYear ? `${stem} ${date.getFullYear()}` : stem;\n}\n\n/** The tooltip form: `6 Aug 2026, 11:05`, with the reader's zone appended. */\nexport function formatAbsoluteTime(date: Date, options: { hasTimeZone?: boolean } = {}) {\n const { hasTimeZone = true } = options;\n const stamp = `${formatAbsoluteDate(date)}, ${pad(date.getHours())}:${pad(date.getMinutes())}`;\n if (!hasTimeZone) {\n return stamp;\n }\n const zone = new Intl.DateTimeFormat(undefined, { timeZoneName: \"short\" })\n .formatToParts(date)\n .find((part) => part.type === \"timeZoneName\")?.value;\n return zone ? `${stamp} ${zone}` : stamp;\n}\n\n/**\n * Relative up to a week, absolute after. Future dates are always absolute — a\n * scheduled publish reads `12 Jun`, never `in 3 days`.\n */\nexport function formatRelativeTime(date: Date, now: Date = new Date()) {\n const delta = now.getTime() - date.getTime();\n if (delta < 0) {\n return formatAbsoluteDate(date, { hasYear: date.getFullYear() !== now.getFullYear() });\n }\n if (delta < MINUTE) {\n return \"Just now\";\n }\n if (delta < HOUR) {\n return `${Math.floor(delta / MINUTE)}m ago`;\n }\n if (delta < DAY) {\n return `${Math.floor(delta / HOUR)}h ago`;\n }\n if (delta < WEEK) {\n const days = Math.floor(delta / DAY);\n return `${days} ${days === 1 ? \"day\" : \"days\"} ago`;\n }\n return formatAbsoluteDate(date, { hasYear: date.getFullYear() !== now.getFullYear() });\n}\n\nexport type TimeFormat = \"auto\" | \"relative\" | \"absolute\";\n\nexport interface TimeProps extends Omit<HTMLAttributes<HTMLElement>, \"children\"> {\n /** The instant to print — Date, epoch ms, or an ISO string. */\n value: Date | string | number;\n /** `auto` ages the value; `absolute` always prints the date. */\n format?: TimeFormat;\n /** Show the absolute stamp on hover and focus. */\n hasTooltip?: boolean;\n /** Append the reader's time zone to the tooltip. */\n hasTimeZone?: boolean;\n /** Pin \"now\" — useful for tests and stories. */\n now?: Date;\n /** Re-render interval in ms while the value is still relative. */\n refreshInterval?: number;\n}\n\n/**\n * A machine-readable `<time>` that ages itself. One form per cell: relative or\n * absolute, never both side by side.\n */\nexport const Time = forwardRef<HTMLTimeElement, TimeProps>(function Time(\n {\n value,\n format = \"auto\",\n hasTooltip = true,\n hasTimeZone = true,\n now,\n refreshInterval = 30_000,\n className,\n tabIndex,\n title,\n onMouseEnter,\n onMouseLeave,\n onFocus,\n onBlur,\n onKeyDown,\n \"aria-describedby\": describedBy,\n ...rest\n },\n ref,\n) {\n const date = value instanceof Date ? value : new Date(value);\n const anchorRef = useRef<HTMLTimeElement | null>(null);\n const [isOpen, setIsOpen] = useState(false);\n const tooltipId = useId();\n const [, setTick] = useState(0);\n\n useEffect(() => {\n if (format === \"absolute\" || now) {\n return;\n }\n const id = window.setInterval(() => setTick((t) => t + 1), refreshInterval);\n return () => window.clearInterval(id);\n }, [format, now, refreshInterval]);\n\n if (Number.isNaN(date.getTime())) {\n return null;\n }\n\n const reference = now ?? new Date();\n const label =\n format === \"absolute\" ? formatAbsoluteDate(date) : formatRelativeTime(date, reference);\n const stamp = formatAbsoluteTime(date, { hasTimeZone });\n const isTipped = hasTooltip && label !== stamp;\n\n return (\n <>\n <time\n ref={(node) => {\n anchorRef.current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n ref.current = node;\n }\n }}\n dateTime={date.toISOString()}\n suppressHydrationWarning\n className={cx(\"ds-time\", !isTipped && \"ds-time--plain\", className)}\n tabIndex={tabIndex ?? (isTipped ? 0 : undefined)}\n aria-describedby={\n [describedBy, isTipped && isOpen && tooltipId].filter(Boolean).join(\" \") || undefined\n }\n title={title ?? (isTipped ? undefined : stamp)}\n onMouseEnter={(event) => {\n onMouseEnter?.(event);\n if (isTipped && !event.defaultPrevented) {\n setIsOpen(true);\n }\n }}\n onMouseLeave={(event) => {\n onMouseLeave?.(event);\n if (isTipped && !event.defaultPrevented) {\n setIsOpen(false);\n }\n }}\n onFocus={(event) => {\n onFocus?.(event);\n if (isTipped && !event.defaultPrevented) {\n setIsOpen(true);\n }\n }}\n onBlur={(event) => {\n onBlur?.(event);\n if (isTipped && !event.defaultPrevented) {\n setIsOpen(false);\n }\n }}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (isTipped && !event.defaultPrevented && event.key === \"Escape\") {\n setIsOpen(false);\n }\n }}\n {...rest}\n >\n {label}\n </time>\n {isTipped && (\n <Popover\n anchorRef={anchorRef}\n isOpen={isOpen}\n id={tooltipId}\n role=\"tooltip\"\n className=\"ds-surface-raised ds-time-tooltip\"\n >\n {stamp}\n </Popover>\n )}\n </>\n );\n});\n"],"mappings":"A,iKAIA,SAASS,EAAG,GAAGC,EAAuC,CACpD,OAAO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ources":["../../../src/components/Time/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAkD,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5F,OAAO,aAAa,CAAC;AAiBrB,6DAA6D;AAC7D,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAO,UAIjF;AAED,8EAA8E;AAC9E,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/Time/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAkD,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5F,OAAO,aAAa,CAAC;AAiBrB,6DAA6D;AAC7D,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAO,UAIjF;AAED,8EAA8E;AAC9E,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,UAUrF;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,GAAE,IAAiB,UAmBpE;AAED,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,UAAU,GAAG,UAAU,CAAC;AAE1D,MAAM,WAAW,SAAU,SAAQ,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,UAAU,CAAC;IAC9E,+DAA+D;IAC/D,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC;IAC9B,gEAAgE;IAChE,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,kDAAkD;IAClD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,oDAAoD;IACpD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,gDAAgD;IAChD,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,kEAAkE;IAClE,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,eAAO,MAAM,IAAI,uGA+Gf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Time/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAkD,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5F,OAAO,aAAa,CAAC;AAiBrB,6DAA6D;AAC7D,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAO,UAIjF;AAED,8EAA8E;AAC9E,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Time/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAkD,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5F,OAAO,aAAa,CAAC;AAiBrB,6DAA6D;AAC7D,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAO,UAIjF;AAED,8EAA8E;AAC9E,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,UAUrF;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,GAAE,IAAiB,UAmBpE;AAED,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,UAAU,GAAG,UAAU,CAAC;AAE1D,MAAM,WAAW,SAAU,SAAQ,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,UAAU,CAAC;IAC9E,+DAA+D;IAC/D,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC;IAC9B,gEAAgE;IAChE,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,kDAAkD;IAClD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,oDAAoD;IACpD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,gDAAgD;IAChD,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,kEAAkE;IAClE,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,eAAO,MAAM,IAAI,uGA+Gf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_Fragment","Fragment$1","cx","parts","MONTHS","MINUTE","HOUR","DAY","WEEK","pad","value","formatAbsoluteDate","options","stem","date","hasYear","formatAbsoluteTime","stamp","hasTimeZone","zone","part","formatRelativeTime","delta","now","days","Time","forwardRef","describedBy","rest","anchorRef","useRef","isOpen","setIsOpen","useState","tooltipId","useId","setTick","useEffect","format","id","t","refreshInterval","label","isTipped","hasTooltip","node","ref","className","tabIndex","title","onMouseEnter","event","onMouseLeave","onFocus","onBlur","onKeyDown","Popover"],"sources":["../../../src/components/Time/index.tsx"],"sourcesContent":["import { forwardRef, useEffect, useId, useRef, useState, type HTMLAttributes } from \"react\";\nimport { Popover } from \"../Popover\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nconst MONTHS = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"];\n\nconst MINUTE = 60_000;\nconst HOUR = 60 * MINUTE;\nconst DAY = 24 * HOUR;\nconst WEEK = 7 * DAY;\n\nfunction pad(value: number) {\n return String(value).padStart(2, \"0\");\n}\n\n/** Day before month, one order everywhere: `12 Jun 2026`. */\nexport function formatAbsoluteDate(date: Date, options: { hasYear?: boolean } = {}) {\n const { hasYear = true } = options;\n const stem = `${date.getDate()} ${MONTHS[date.getMonth()]}`;\n return hasYear ? `${stem} ${date.getFullYear()}` : stem;\n}\n\n/** The tooltip form: `6 Aug 2026, 11:05`, with the reader's zone appended. */\nexport function formatAbsoluteTime(date: Date, options: { hasTimeZone?: boolean } = {}) {\n const { hasTimeZone = true } = options;\n const stamp = `${formatAbsoluteDate(date)}, ${pad(date.getHours())}:${pad(date.getMinutes())}`;\n if (!hasTimeZone) return stamp;\n const zone = new Intl.DateTimeFormat(undefined, { timeZoneName: \"short\" })\n .formatToParts(date)\n .find((part) => part.type === \"timeZoneName\")?.value;\n return zone ? `${stamp} ${zone}` : stamp;\n}\n\n/**\n * Relative up to a week, absolute after. Future dates are always absolute — a\n * scheduled publish reads `12 Jun`, never `in 3 days`.\n */\nexport function formatRelativeTime(date: Date, now: Date = new Date()) {\n const delta = now.getTime() - date.getTime();\n if (delta < 0) {\n return formatAbsoluteDate(date, { hasYear: date.getFullYear() !== now.getFullYear() });\n }\n if (delta < MINUTE) return \"Just now\";\n if (delta < HOUR) return `${Math.floor(delta / MINUTE)}m ago`;\n if (delta < DAY) return `${Math.floor(delta / HOUR)}h ago`;\n if (delta < WEEK) {\n const days = Math.floor(delta / DAY);\n return `${days} ${days === 1 ? \"day\" : \"days\"} ago`;\n }\n return formatAbsoluteDate(date, { hasYear: date.getFullYear() !== now.getFullYear() });\n}\n\nexport type TimeFormat = \"auto\" | \"relative\" | \"absolute\";\n\nexport interface TimeProps extends Omit<HTMLAttributes<HTMLElement>, \"children\"> {\n /** The instant to print — Date, epoch ms, or an ISO string. */\n value: Date | string | number;\n /** `auto` ages the value; `absolute` always prints the date. */\n format?: TimeFormat;\n /** Show the absolute stamp on hover and focus. */\n hasTooltip?: boolean;\n /** Append the reader's time zone to the tooltip. */\n hasTimeZone?: boolean;\n /** Pin \"now\" — useful for tests and stories. */\n now?: Date;\n /** Re-render interval in ms while the value is still relative. */\n refreshInterval?: number;\n}\n\n/**\n * A machine-readable `<time>` that ages itself. One form per cell: relative or\n * absolute, never both side by side.\n */\nexport const Time = forwardRef<HTMLTimeElement, TimeProps>(function Time(\n {\n value,\n format = \"auto\",\n hasTooltip = true,\n hasTimeZone = true,\n now,\n refreshInterval = 30_000,\n className,\n tabIndex,\n title,\n onMouseEnter,\n onMouseLeave,\n onFocus,\n onBlur,\n onKeyDown,\n \"aria-describedby\": describedBy,\n ...rest\n },\n ref,\n) {\n const date = value instanceof Date ? value : new Date(value);\n const anchorRef = useRef<HTMLTimeElement | null>(null);\n const [isOpen, setIsOpen] = useState(false);\n const tooltipId = useId();\n const [, setTick] = useState(0);\n\n useEffect(() => {\n if (format === \"absolute\" || now) return;\n const id = window.setInterval(() => setTick((t) => t + 1), refreshInterval);\n return () => window.clearInterval(id);\n }, [format, now, refreshInterval]);\n\n if (Number.isNaN(date.getTime())) return null;\n\n const reference = now ?? new Date();\n const label =\n format === \"absolute\" ? formatAbsoluteDate(date) : formatRelativeTime(date, reference);\n const stamp = formatAbsoluteTime(date, { hasTimeZone });\n const isTipped = hasTooltip && label !== stamp;\n\n return (\n <>\n <time\n ref={(node) => {\n anchorRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }}\n dateTime={date.toISOString()}\n suppressHydrationWarning\n className={cx(\"ds-time\", !isTipped && \"ds-time--plain\", className)}\n tabIndex={tabIndex ?? (isTipped ? 0 : undefined)}\n aria-describedby={\n [describedBy, isTipped && isOpen && tooltipId].filter(Boolean).join(\" \") || undefined\n }\n title={title ?? (isTipped ? undefined : stamp)}\n onMouseEnter={(event) => {\n onMouseEnter?.(event);\n if (isTipped && !event.defaultPrevented) setIsOpen(true);\n }}\n onMouseLeave={(event) => {\n onMouseLeave?.(event);\n if (isTipped && !event.defaultPrevented) setIsOpen(false);\n }}\n onFocus={(event) => {\n onFocus?.(event);\n if (isTipped && !event.defaultPrevented) setIsOpen(true);\n }}\n onBlur={(event) => {\n onBlur?.(event);\n if (isTipped && !event.defaultPrevented) setIsOpen(false);\n }}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (isTipped && !event.defaultPrevented && event.key === \"Escape\") setIsOpen(false);\n }}\n {...rest}\n >\n {label}\n </time>\n {isTipped && (\n <Popover\n anchorRef={anchorRef}\n isOpen={isOpen}\n id={tooltipId}\n role=\"tooltip\"\n className=\"ds-surface-raised ds-time-tooltip\"\n >\n {stamp}\n </Popover>\n )}\n </>\n );\n});\n"],"mappings":";;;;AAIA,SAASE,EAAG,GAAGC,GAAuC;CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;AACvC;AAEA,IAAMC,IAAS;CAAC;CAAO;CAAO;CAAO;CAAO;CAAO;CAAO;CAAO;CAAO;CAAO;CAAO;CAAO;AAAK,GAE5FC,IAAS,KACTC,IAAO,KAAKD,GACZE,IAAM,KAAKD,GACXE,IAAO,IAAID;AAEjB,SAASE,EAAI,GAAe;CAC1B,OAAO,OAAOC,CAAK,CAAC,CAAC,SAAS,GAAG,GAAG;AACtC;AAGA,SAAgBC,EAAmB,GAAY,IAAiC,CAAC,GAAG;CAClF,IAAM,EAAE,aAAU,OAASC,GACrBC,IAAO,GAAGC,EAAK,QAAQ,EAAE,GAAGV,EAAOU,EAAK,SAAS;CACvD,OAAOC,IAAU,GAAGF,EAAK,GAAGC,EAAK,YAAY,MAAMD;AACrD;AAGA,SAAgBG,EAAmB,GAAY,IAAqC,CAAC,GAAG;CACtF,IAAM,EAAE,iBAAc,OAASJ,GACzBK,IAAQ,GAAGN,EAAmBG,CAAI,EAAE,IAAIL,EAAIK,EAAK,SAAS,CAAC,EAAE,GAAGL,EAAIK,EAAK,WAAW,CAAC;CAC3F,IAAI,CAACI,
|
|
1
|
+
{"version":3,"file":"index.js","names":["_Fragment","Fragment$1","cx","parts","MONTHS","MINUTE","HOUR","DAY","WEEK","pad","value","formatAbsoluteDate","options","stem","date","hasYear","formatAbsoluteTime","stamp","hasTimeZone","zone","part","formatRelativeTime","delta","now","days","Time","forwardRef","describedBy","rest","anchorRef","useRef","isOpen","setIsOpen","useState","tooltipId","useId","setTick","useEffect","format","id","t","refreshInterval","label","isTipped","hasTooltip","node","ref","className","tabIndex","title","onMouseEnter","event","onMouseLeave","onFocus","onBlur","onKeyDown","Popover"],"sources":["../../../src/components/Time/index.tsx"],"sourcesContent":["import { forwardRef, useEffect, useId, useRef, useState, type HTMLAttributes } from \"react\";\nimport { Popover } from \"../Popover\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nconst MONTHS = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"];\n\nconst MINUTE = 60_000;\nconst HOUR = 60 * MINUTE;\nconst DAY = 24 * HOUR;\nconst WEEK = 7 * DAY;\n\nfunction pad(value: number) {\n return String(value).padStart(2, \"0\");\n}\n\n/** Day before month, one order everywhere: `12 Jun 2026`. */\nexport function formatAbsoluteDate(date: Date, options: { hasYear?: boolean } = {}) {\n const { hasYear = true } = options;\n const stem = `${date.getDate()} ${MONTHS[date.getMonth()]}`;\n return hasYear ? `${stem} ${date.getFullYear()}` : stem;\n}\n\n/** The tooltip form: `6 Aug 2026, 11:05`, with the reader's zone appended. */\nexport function formatAbsoluteTime(date: Date, options: { hasTimeZone?: boolean } = {}) {\n const { hasTimeZone = true } = options;\n const stamp = `${formatAbsoluteDate(date)}, ${pad(date.getHours())}:${pad(date.getMinutes())}`;\n if (!hasTimeZone) {\n return stamp;\n }\n const zone = new Intl.DateTimeFormat(undefined, { timeZoneName: \"short\" })\n .formatToParts(date)\n .find((part) => part.type === \"timeZoneName\")?.value;\n return zone ? `${stamp} ${zone}` : stamp;\n}\n\n/**\n * Relative up to a week, absolute after. Future dates are always absolute — a\n * scheduled publish reads `12 Jun`, never `in 3 days`.\n */\nexport function formatRelativeTime(date: Date, now: Date = new Date()) {\n const delta = now.getTime() - date.getTime();\n if (delta < 0) {\n return formatAbsoluteDate(date, { hasYear: date.getFullYear() !== now.getFullYear() });\n }\n if (delta < MINUTE) {\n return \"Just now\";\n }\n if (delta < HOUR) {\n return `${Math.floor(delta / MINUTE)}m ago`;\n }\n if (delta < DAY) {\n return `${Math.floor(delta / HOUR)}h ago`;\n }\n if (delta < WEEK) {\n const days = Math.floor(delta / DAY);\n return `${days} ${days === 1 ? \"day\" : \"days\"} ago`;\n }\n return formatAbsoluteDate(date, { hasYear: date.getFullYear() !== now.getFullYear() });\n}\n\nexport type TimeFormat = \"auto\" | \"relative\" | \"absolute\";\n\nexport interface TimeProps extends Omit<HTMLAttributes<HTMLElement>, \"children\"> {\n /** The instant to print — Date, epoch ms, or an ISO string. */\n value: Date | string | number;\n /** `auto` ages the value; `absolute` always prints the date. */\n format?: TimeFormat;\n /** Show the absolute stamp on hover and focus. */\n hasTooltip?: boolean;\n /** Append the reader's time zone to the tooltip. */\n hasTimeZone?: boolean;\n /** Pin \"now\" — useful for tests and stories. */\n now?: Date;\n /** Re-render interval in ms while the value is still relative. */\n refreshInterval?: number;\n}\n\n/**\n * A machine-readable `<time>` that ages itself. One form per cell: relative or\n * absolute, never both side by side.\n */\nexport const Time = forwardRef<HTMLTimeElement, TimeProps>(function Time(\n {\n value,\n format = \"auto\",\n hasTooltip = true,\n hasTimeZone = true,\n now,\n refreshInterval = 30_000,\n className,\n tabIndex,\n title,\n onMouseEnter,\n onMouseLeave,\n onFocus,\n onBlur,\n onKeyDown,\n \"aria-describedby\": describedBy,\n ...rest\n },\n ref,\n) {\n const date = value instanceof Date ? value : new Date(value);\n const anchorRef = useRef<HTMLTimeElement | null>(null);\n const [isOpen, setIsOpen] = useState(false);\n const tooltipId = useId();\n const [, setTick] = useState(0);\n\n useEffect(() => {\n if (format === \"absolute\" || now) {\n return;\n }\n const id = window.setInterval(() => setTick((t) => t + 1), refreshInterval);\n return () => window.clearInterval(id);\n }, [format, now, refreshInterval]);\n\n if (Number.isNaN(date.getTime())) {\n return null;\n }\n\n const reference = now ?? new Date();\n const label =\n format === \"absolute\" ? formatAbsoluteDate(date) : formatRelativeTime(date, reference);\n const stamp = formatAbsoluteTime(date, { hasTimeZone });\n const isTipped = hasTooltip && label !== stamp;\n\n return (\n <>\n <time\n ref={(node) => {\n anchorRef.current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n ref.current = node;\n }\n }}\n dateTime={date.toISOString()}\n suppressHydrationWarning\n className={cx(\"ds-time\", !isTipped && \"ds-time--plain\", className)}\n tabIndex={tabIndex ?? (isTipped ? 0 : undefined)}\n aria-describedby={\n [describedBy, isTipped && isOpen && tooltipId].filter(Boolean).join(\" \") || undefined\n }\n title={title ?? (isTipped ? undefined : stamp)}\n onMouseEnter={(event) => {\n onMouseEnter?.(event);\n if (isTipped && !event.defaultPrevented) {\n setIsOpen(true);\n }\n }}\n onMouseLeave={(event) => {\n onMouseLeave?.(event);\n if (isTipped && !event.defaultPrevented) {\n setIsOpen(false);\n }\n }}\n onFocus={(event) => {\n onFocus?.(event);\n if (isTipped && !event.defaultPrevented) {\n setIsOpen(true);\n }\n }}\n onBlur={(event) => {\n onBlur?.(event);\n if (isTipped && !event.defaultPrevented) {\n setIsOpen(false);\n }\n }}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (isTipped && !event.defaultPrevented && event.key === \"Escape\") {\n setIsOpen(false);\n }\n }}\n {...rest}\n >\n {label}\n </time>\n {isTipped && (\n <Popover\n anchorRef={anchorRef}\n isOpen={isOpen}\n id={tooltipId}\n role=\"tooltip\"\n className=\"ds-surface-raised ds-time-tooltip\"\n >\n {stamp}\n </Popover>\n )}\n </>\n );\n});\n"],"mappings":";;;;AAIA,SAASE,EAAG,GAAGC,GAAuC;CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAA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,MACT,EAAI,UAAUD;EAElB;EACA,UAAU/B,EAAK,YAAY;EAC3B,0BAAA;EACA,WAAWZ,EAAG,WAAW,CAACyC,KAAY,kBAAkBI,CAAS;EACjE,UAAUC,MAAaL,IAAW,IAAI,KAAA;EACtC,oBACE,CAAChB,GAAagB,KAAYZ,KAAUG,CAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,KAAK,KAAA;EAE9E,OAAOe,MAAUN,IAAW,KAAA,IAAY1B;EACxC,eAAe,MAAU;GAEvB,AADAiC,IAAeC,CAAK,GAChBR,KAAY,CAACQ,EAAM,oBACrBnB,EAAU,EAAI;EAElB;EACA,eAAe,MAAU;GAEvB,AADAoB,IAAeD,CAAK,GAChBR,KAAY,CAACQ,EAAM,oBACrBnB,EAAU,EAAK;EAEnB;EACA,UAAU,MAAU;GAElB,AADAqB,IAAUF,CAAK,GACXR,KAAY,CAACQ,EAAM,oBACrBnB,EAAU,EAAI;EAElB;EACA,SAAS,MAAU;GAEjB,AADAsB,IAASH,CAAK,GACVR,KAAY,CAACQ,EAAM,oBACrBnB,EAAU,EAAK;EAEnB;EACA,YAAY,MAAU;GAEpB,AADAuB,IAAYJ,CAAK,GACbR,KAAY,CAACQ,EAAM,oBAAoBA,EAAM,QAAQ,YACvDnB,EAAU,EAAK;EAEnB;EACA,GAAIJ;EAEH,UAAAc;CACG,CAAA,GACLC,KACC,kBAACa,GAAD;EACa;EACH;EACR,IAAItB;EACJ,MAAK;EACL,WAAU;EAET,UAAAjB;CACM,CAAA,CAEX,EAAA,CAAA;AAEN,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/Icon-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/Icon-BBoWP_Y6.cjs"),t=require("../Button/index.cjs");let n=require("react"),r=require("react/jsx-runtime");var i={neutral:`info`,info:`info`,success:`check`,warning:`alert-triangle`,danger:`alert-triangle`},a=(0,n.forwardRef)(function({tone:n=`neutral`,title:a,description:o,onDismiss:s,className:c,...l},u){return(0,r.jsxs)(`div`,{ref:u,role:`status`,"data-tone":n===`neutral`?void 0:n,className:[`ds-toast`,c].filter(Boolean).join(` `),...l,children:[(0,r.jsx)(e.t,{name:i[n],size:20,className:`ds-toast__icon`}),(0,r.jsxs)(`div`,{className:`ds-toast__body`,children:[(0,r.jsx)(`span`,{className:`ds-toast__title`,children:a}),o&&(0,r.jsx)(`span`,{className:`ds-toast__description`,children:o})]}),s&&(0,r.jsx)(t.Button,{variant:`simple`,size:`sm`,isIconOnly:!0,iconStart:`x`,"aria-label":`Dismiss notification`,onClick:s})]})}),o=(0,n.createContext)(null);function s({children:e}){let[t,i]=(0,n.useState)([]),a=(0,n.useRef)(0),s=(0,n.useCallback)(e=>{i(t=>t.filter(t=>t.id!==e))},[]),l=(0,n.useCallback)(e=>{i(t=>[...t,{...e,id:a.current++}])},[]),u=(0,n.useMemo)(()=>({toast:l,dismiss:s}),[l,s]);return(0,r.jsxs)(o.Provider,{value:u,children:[e,(0,r.jsx)(c,{items:t,onDismiss:s})]})}function c({items:e,onDismiss:t}){return e.length===0?null:(0,r.jsx)(`div`,{className:`ds-toast-region`,role:`region`,"aria-label":`Notifications`,children:e.map(e=>(0,r.jsx)(l,{item:e,onDismiss:t},e.id))})}function l({item:e,onDismiss:t}){return(0,n.useEffect)(()=>{let n=window.setTimeout(()=>t(e.id),e.duration??5e3);return()=>window.clearTimeout(n)},[e,t]),(0,r.jsx)(a,{tone:e.tone,title:e.title,description:e.description,onDismiss:()=>t(e.id)})}function u(){let e=(0,n.useContext)(o);if(!e)throw Error(`useToast must be used inside a <ToastProvider>.`);return e}exports.Toast=a,exports.ToastProvider=s,exports.useToast=u;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["forwardRef","Icon","Button","createContext","useState","useRef","useCallback","useMemo","useContext","require_Icon","require_components_Button_index","react","react_jsx_runtime","TONE_ICON","Toast","rest","tone","className","title","description","onDismiss","ToastContext","ToastProvider","items","setItems","nextId","dismiss","current","item","id","toast","options","value","children","ToastRegion","TimedToast","timer","useToast","context"],"sources":["../../../src/components/Toast/index.tsx"],"sourcesContent":["import {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactNode,\n} from \"react\";\nimport { Button } from \"../Button\";\nimport { Icon } from \"../Icon\";\nimport type { IconName } from \"../Icon/icons\";\nimport \"./style.css\";\n\nexport type ToastTone = \"neutral\" | \"info\" | \"success\" | \"warning\" | \"danger\";\n\nconst TONE_ICON: Record<ToastTone, IconName> = {\n neutral: \"info\",\n info: \"info\",\n success: \"check\",\n warning: \"alert-triangle\",\n danger: \"alert-triangle\",\n};\n\nexport interface ToastProps extends HTMLAttributes<HTMLDivElement> {\n tone?: ToastTone;\n title: string;\n description?: string;\n /** Renders a dismiss button. Omit for a toast that only times out. */\n onDismiss?: () => void;\n}\n\n/** One fact about something that already happened. Never a question. */\nexport const Toast = forwardRef<HTMLDivElement, ToastProps>(function Toast(\n { tone = \"neutral\", title, description, onDismiss, className, ...rest },\n ref,\n) {\n return (\n <div\n ref={ref}\n role=\"status\"\n data-tone={tone === \"neutral\" ? undefined : tone}\n className={[\"ds-toast\", className].filter(Boolean).join(\" \")}\n {...rest}\n >\n <Icon\n name={TONE_ICON[tone]}\n size={20}\n className=\"ds-toast__icon\"\n />\n <div className=\"ds-toast__body\">\n <span className=\"ds-toast__title\">{title}</span>\n {description && <span className=\"ds-toast__description\">{description}</span>}\n </div>\n {onDismiss && (\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"x\"\n aria-label=\"Dismiss notification\"\n onClick={onDismiss}\n />\n )}\n </div>\n );\n});\n\nexport interface ToastOptions {\n tone?: ToastTone;\n title: string;\n description?: string;\n /** Milliseconds before it dismisses itself. Defaults to `--toast-duration`. */\n duration?: number;\n}\n\ninterface ToastRecord extends ToastOptions {\n id: number;\n}\n\ninterface ToastContextValue {\n toast: (options: ToastOptions) => void;\n dismiss: (id: number) => void;\n}\n\nconst ToastContext = createContext<ToastContextValue | null>(null);\n\nexport interface ToastProviderProps {\n children: ReactNode;\n}\n\n/** Mount once, near the root. Everything below it can call `useToast()`. */\nexport function ToastProvider({ children }: ToastProviderProps) {\n const [items, setItems] = useState<ToastRecord[]>([]);\n const nextId = useRef(0);\n\n const dismiss = useCallback((id: number) => {\n setItems((current) => current.filter((item) => item.id !== id));\n }, []);\n\n const toast = useCallback((options: ToastOptions) => {\n setItems((current) => [...current, { ...options, id: nextId.current++ }]);\n }, []);\n\n const value = useMemo(() => ({ toast, dismiss }), [toast, dismiss]);\n\n return (\n <ToastContext.Provider value={value}>\n {children}\n <ToastRegion\n items={items}\n onDismiss={dismiss}\n />\n </ToastContext.Provider>\n );\n}\n\nfunction ToastRegion({\n items,\n onDismiss,\n}: {\n items: ToastRecord[];\n onDismiss: (id: number) => void;\n}) {\n if (items.length === 0) return null;\n return (\n <div\n className=\"ds-toast-region\"\n role=\"region\"\n aria-label=\"Notifications\"\n >\n {items.map((item) => (\n <TimedToast\n key={item.id}\n item={item}\n onDismiss={onDismiss}\n />\n ))}\n </div>\n );\n}\n\nfunction TimedToast({ item, onDismiss }: { item: ToastRecord; onDismiss: (id: number) => void }) {\n useEffect(() => {\n const timer = window.setTimeout(() => onDismiss(item.id), item.duration ?? 5000);\n return () => window.clearTimeout(timer);\n }, [item, onDismiss]);\n\n return (\n <Toast\n tone={item.tone}\n title={item.title}\n description={item.description}\n onDismiss={() => onDismiss(item.id)}\n />\n );\n}\n\nexport function useToast(): ToastContextValue {\n const context = useContext(ToastContext);\n if (!context) throw new Error(\"useToast must be used inside a <ToastProvider>.\");\n return context;\n}\n"],"mappings":"A,4MAmBA,IAAMa,EAAyC,CAC7C,QAAS,OACT,KAAM,O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nDkB,EAAU,GAAY,CAAC,GAAGG,EAAS,CAAE,GAAGI,EAAS,GAAI,EAAO,SAAU,CAAC,CAAC,CAC1E,EAAG,CAAC,CAAC,EAECC,GAAA,EAAQzB,EAAAA,QAAAA,MAAe,CAAE,QAAO,SAAQ,GAAI,CAACuB,EAAOJ,CAAO,CAAC,EAElE,OACE,EAAAd,EAAA,KAAA,CAACS,EAAa,SAAd,CAA8B,QAA9B,SAAA,CACGY,GACD,EAAArB,EAAA,IAAA,CAACsB,EAAD,CACS,QACP,UAAWR,CACZ,CAAA,CACoB,C,EAE3B,CAEA,SAASQ,EAAY,CACnB,QACA,aAIC,
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["forwardRef","Icon","Button","createContext","useState","useRef","useCallback","useMemo","useContext","require_Icon","require_components_Button_index","react","react_jsx_runtime","TONE_ICON","Toast","rest","tone","className","title","description","onDismiss","ToastContext","ToastProvider","items","setItems","nextId","dismiss","current","item","id","toast","options","value","children","ToastRegion","TimedToast","timer","useToast","context"],"sources":["../../../src/components/Toast/index.tsx"],"sourcesContent":["import {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactNode,\n} from \"react\";\nimport { Button } from \"../Button\";\nimport { Icon } from \"../Icon\";\nimport type { IconName } from \"../Icon/icons\";\nimport \"./style.css\";\n\nexport type ToastTone = \"neutral\" | \"info\" | \"success\" | \"warning\" | \"danger\";\n\nconst TONE_ICON: Record<ToastTone, IconName> = {\n neutral: \"info\",\n info: \"info\",\n success: \"check\",\n warning: \"alert-triangle\",\n danger: \"alert-triangle\",\n};\n\nexport interface ToastProps extends HTMLAttributes<HTMLDivElement> {\n tone?: ToastTone;\n title: string;\n description?: string;\n /** Renders a dismiss button. Omit for a toast that only times out. */\n onDismiss?: () => void;\n}\n\n/** One fact about something that already happened. Never a question. */\nexport const Toast = forwardRef<HTMLDivElement, ToastProps>(function Toast(\n { tone = \"neutral\", title, description, onDismiss, className, ...rest },\n ref,\n) {\n return (\n <div\n ref={ref}\n role=\"status\"\n data-tone={tone === \"neutral\" ? undefined : tone}\n className={[\"ds-toast\", className].filter(Boolean).join(\" \")}\n {...rest}\n >\n <Icon\n name={TONE_ICON[tone]}\n size={20}\n className=\"ds-toast__icon\"\n />\n <div className=\"ds-toast__body\">\n <span className=\"ds-toast__title\">{title}</span>\n {description && <span className=\"ds-toast__description\">{description}</span>}\n </div>\n {onDismiss && (\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"x\"\n aria-label=\"Dismiss notification\"\n onClick={onDismiss}\n />\n )}\n </div>\n );\n});\n\nexport interface ToastOptions {\n tone?: ToastTone;\n title: string;\n description?: string;\n /** Milliseconds before it dismisses itself. Defaults to `--toast-duration`. */\n duration?: number;\n}\n\ninterface ToastRecord extends ToastOptions {\n id: number;\n}\n\ninterface ToastContextValue {\n toast: (options: ToastOptions) => void;\n dismiss: (id: number) => void;\n}\n\nconst ToastContext = createContext<ToastContextValue | null>(null);\n\nexport interface ToastProviderProps {\n children: ReactNode;\n}\n\n/** Mount once, near the root. Everything below it can call `useToast()`. */\nexport function ToastProvider({ children }: ToastProviderProps) {\n const [items, setItems] = useState<ToastRecord[]>([]);\n const nextId = useRef(0);\n\n const dismiss = useCallback((id: number) => {\n setItems((current) => current.filter((item) => item.id !== id));\n }, []);\n\n const toast = useCallback((options: ToastOptions) => {\n setItems((current) => [...current, { ...options, id: nextId.current++ }]);\n }, []);\n\n const value = useMemo(() => ({ toast, dismiss }), [toast, dismiss]);\n\n return (\n <ToastContext.Provider value={value}>\n {children}\n <ToastRegion\n items={items}\n onDismiss={dismiss}\n />\n </ToastContext.Provider>\n );\n}\n\nfunction ToastRegion({\n items,\n onDismiss,\n}: {\n items: ToastRecord[];\n onDismiss: (id: number) => void;\n}) {\n if (items.length === 0) {\n return null;\n }\n return (\n <div\n className=\"ds-toast-region\"\n role=\"region\"\n aria-label=\"Notifications\"\n >\n {items.map((item) => (\n <TimedToast\n key={item.id}\n item={item}\n onDismiss={onDismiss}\n />\n ))}\n </div>\n );\n}\n\nfunction TimedToast({ item, onDismiss }: { item: ToastRecord; onDismiss: (id: number) => void }) {\n useEffect(() => {\n const timer = window.setTimeout(() => onDismiss(item.id), item.duration ?? 5000);\n return () => window.clearTimeout(timer);\n }, [item, onDismiss]);\n\n return (\n <Toast\n tone={item.tone}\n title={item.title}\n description={item.description}\n onDismiss={() => onDismiss(item.id)}\n />\n );\n}\n\nexport function useToast(): ToastContextValue {\n const context = useContext(ToastContext);\n if (!context) {\n throw new Error(\"useToast must be used inside a <ToastProvider>.\");\n }\n return context;\n}\n"],"mappings":"A,4MAmBA,IAAMa,EAAyC,CAC7C,QAAS,OACT,KAAM,OACN,QAAS,QACT,QAAS,iBACT,OAAQ,gBACV,EAWaC,GAAA,EAAQd,EAAAA,WAAAA,CAAuC,SAC1D,CAAE,OAAO,UAAW,QAAO,cAAa,YAAW,YAAW,GAAGe,GACjE,EACA,CACA,OACE,EAAAH,EAAA,KAAA,CAAC,MAAD,CACO,MACL,KAAK,SACL,YAAWI,IAAS,UAAY,IAAA,GAAYA,EAC5C,UAAW,CAAC,WAAYC,CAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,EAC3D,GAAIF,EALN,SAAA,EAOE,EAAAH,EAAA,IAAA,CAACX,EAAAA,EAAD,CACE,KAAMY,EAAUG,GAChB,KAAM,GACN,UAAU,gBACX,CAAA,GACD,EAAAJ,EAAA,KAAA,CAAC,MAAD,CAAK,UAAU,iBAAf,SAAA,EACE,EAAAA,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,kBAAmB,SAAAM,CAAY,CAAA,EAC9CC,IAAe,EAAAP,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,wBAAyB,SAAAO,CAAkB,CAAA,CACxE,C,GACJC,IACC,EAAAR,EAAA,IAAA,CAACV,EAAAA,OAAD,CACE,QAAQ,SACR,KAAK,KACL,WAAA,GACA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AAI,iBAAiB,CAM5C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Toast/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,cAAc,EACnB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAIf,OAAO,aAAa,CAAC;AAErB,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAU9E,MAAM,WAAW,UAAW,SAAQ,cAAc,CAAC,cAAc,CAAC;IAChE,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sEAAsE;IACtE,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,wEAAwE;AACxE,eAAO,MAAM,KAAK,uGAiChB,CAAC;AAEH,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAMD,UAAU,iBAAiB;IACzB,KAAK,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC;IACvC,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/B;AAID,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,4EAA4E;AAC5E,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,EAAE,kBAAkB,+BAuB7D;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Toast/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,cAAc,EACnB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAIf,OAAO,aAAa,CAAC;AAErB,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAU9E,MAAM,WAAW,UAAW,SAAQ,cAAc,CAAC,cAAc,CAAC;IAChE,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sEAAsE;IACtE,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,wEAAwE;AACxE,eAAO,MAAM,KAAK,uGAiChB,CAAC;AAEH,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAMD,UAAU,iBAAiB;IACzB,KAAK,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC;IACvC,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/B;AAID,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,4EAA4E;AAC5E,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,EAAE,kBAAkB,+BAuB7D;AA6CD,wBAAgB,QAAQ,IAAI,iBAAiB,CAM5C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as e } from "../../chunks/Icon-
|
|
1
|
+
import { t as e } from "../../chunks/Icon-XNismJDm.js";
|
|
2
2
|
import { Button as t } from "../Button/index.js";
|
|
3
3
|
import { createContext as n, forwardRef as r, useCallback as i, useContext as a, useEffect as o, useMemo as s, useRef as c, useState as l } from "react";
|
|
4
4
|
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|