@synnaxlabs/pluto 0.17.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Keyboard-79lsaV0f.cjs → Keyboard-Jopa0ImN.cjs} +2 -2
- package/dist/{Keyboard-79lsaV0f.cjs.map → Keyboard-Jopa0ImN.cjs.map} +1 -1
- package/dist/{Keyboard-SVZgM51r.js → Keyboard-kcohZ0JP.js} +2 -2
- package/dist/{Keyboard-SVZgM51r.js.map → Keyboard-kcohZ0JP.js.map} +1 -1
- package/dist/{Link-PQmsc2rv.js → Link-4oN98LnE.js} +2 -2
- package/dist/{Link-PQmsc2rv.js.map → Link-4oN98LnE.js.map} +1 -1
- package/dist/{Link-z0ioMNDX.cjs → Link-5t5MufKE.cjs} +2 -2
- package/dist/{Link-z0ioMNDX.cjs.map → Link-5t5MufKE.cjs.map} +1 -1
- package/dist/{Toggle-wVZJoVtX.cjs → Toggle-qW_TcIDh.cjs} +13 -13
- package/dist/{Toggle-wVZJoVtX.cjs.map → Toggle-qW_TcIDh.cjs.map} +1 -1
- package/dist/{Toggle-3mGeA8rE.js → Toggle-zmqGwWeq.js} +39 -37
- package/dist/{Toggle-3mGeA8rE.js.map → Toggle-zmqGwWeq.js.map} +1 -1
- package/dist/button.cjs +1 -1
- package/dist/button.js +1 -1
- package/dist/color.cjs +1 -1
- package/dist/color.js +1 -1
- package/dist/dropdown.cjs +1 -1
- package/dist/dropdown.js +1 -1
- package/dist/{external-jrFYN1k7.js → external-1WVrscEc.js} +2 -2
- package/dist/{external-jrFYN1k7.js.map → external-1WVrscEc.js.map} +1 -1
- package/dist/{external-V5Rc7RD4.cjs → external-6DXc9G-d.cjs} +2 -2
- package/dist/{external-V5Rc7RD4.cjs.map → external-6DXc9G-d.cjs.map} +1 -1
- package/dist/{external-j1RQBbSY.js → external-7FFXJt69.js} +2 -2
- package/dist/external-7FFXJt69.js.map +1 -0
- package/dist/{external-CRkuAd6C.cjs → external-A4JYxI--.cjs} +2 -2
- package/dist/external-A4JYxI--.cjs.map +1 -0
- package/dist/{external-1scdpCD9.js → external-D_-pAYEQ.js} +3 -3
- package/dist/{external-1scdpCD9.js.map → external-D_-pAYEQ.js.map} +1 -1
- package/dist/{external-FtteEuf4.js → external-K7wZqIN6.js} +2 -2
- package/dist/{external-FtteEuf4.js.map → external-K7wZqIN6.js.map} +1 -1
- package/dist/{external-WdZmpbBs.cjs → external-KoFBpSsV.cjs} +2 -2
- package/dist/{external-WdZmpbBs.cjs.map → external-KoFBpSsV.cjs.map} +1 -1
- package/dist/{external-PuMpEjUQ.cjs → external-Mc8M8Xzl.cjs} +2 -2
- package/dist/{external-PuMpEjUQ.cjs.map → external-Mc8M8Xzl.cjs.map} +1 -1
- package/dist/{external-QpYuwpfo.js → external-P6hmttIX.js} +2 -2
- package/dist/{external-QpYuwpfo.js.map → external-P6hmttIX.js.map} +1 -1
- package/dist/{external-hclXaeBH.cjs → external-RsG62zSr.cjs} +2 -2
- package/dist/{external-hclXaeBH.cjs.map → external-RsG62zSr.cjs.map} +1 -1
- package/dist/{external-LDAF36fG.js → external-Sip1coAq.js} +3 -3
- package/dist/{external-LDAF36fG.js.map → external-Sip1coAq.js.map} +1 -1
- package/dist/{external-qFz2sVjt.cjs → external-UezDJS5P.cjs} +2 -2
- package/dist/{external-qFz2sVjt.cjs.map → external-UezDJS5P.cjs.map} +1 -1
- package/dist/{external-bw_0NdEr.js → external-dD3TNRhO.js} +3 -3
- package/dist/{external-bw_0NdEr.js.map → external-dD3TNRhO.js.map} +1 -1
- package/dist/{external-iZdy0KqS.cjs → external-dFd3d4ZY.cjs} +2 -2
- package/dist/{external-iZdy0KqS.cjs.map → external-dFd3d4ZY.cjs.map} +1 -1
- package/dist/{external-7CL_DLHQ.cjs → external-er-l9iZA.cjs} +2 -2
- package/dist/{external-7CL_DLHQ.cjs.map → external-er-l9iZA.cjs.map} +1 -1
- package/dist/{external-f3-E2t1n.js → external-luTLo-w7.js} +2 -2
- package/dist/{external-f3-E2t1n.js.map → external-luTLo-w7.js.map} +1 -1
- package/dist/{external-ogG2kUq2.cjs → external-n4UdyJ7i.cjs} +2 -2
- package/dist/{external-ogG2kUq2.cjs.map → external-n4UdyJ7i.cjs.map} +1 -1
- package/dist/{external-mgTxEe4K.js → external-rZ3m5Z0a.js} +2 -2
- package/dist/{external-mgTxEe4K.js.map → external-rZ3m5Z0a.js.map} +1 -1
- package/dist/external-vjJtYX9R.cjs +2 -0
- package/dist/external-vjJtYX9R.cjs.map +1 -0
- package/dist/{external-194aFdnj.js → external-wMjPMnSO.js} +3 -3
- package/dist/{external-194aFdnj.js.map → external-wMjPMnSO.js.map} +1 -1
- package/dist/{external-jcvqdb1Z.cjs → external-y6ws_3c6.cjs} +2 -2
- package/dist/{external-jcvqdb1Z.cjs.map → external-y6ws_3c6.cjs.map} +1 -1
- package/dist/{external-HTq0VBUW.js → external-zoOMJkop.js} +3 -3
- package/dist/external-zoOMJkop.js.map +1 -0
- package/dist/header.cjs +1 -1
- package/dist/header.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +800 -799
- package/dist/index.js.map +1 -1
- package/dist/input.cjs +1 -1
- package/dist/input.js +1 -1
- package/dist/list.cjs +1 -1
- package/dist/list.js +1 -1
- package/dist/menu.cjs +1 -1
- package/dist/menu.js +1 -1
- package/dist/select/Multiple.d.ts +2 -2
- package/dist/select/Select.spec.d.ts +9 -0
- package/dist/select/Single.d.ts +2 -2
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.js +1 -1
- package/dist/text.cjs +1 -1
- package/dist/text.js +2 -2
- package/dist/theming.cjs +1 -1
- package/dist/theming.js +2 -2
- package/dist/tree.cjs +1 -1
- package/dist/tree.js +1 -1
- package/dist/triggers.cjs +1 -1
- package/dist/triggers.js +1 -1
- package/package.json +6 -6
- package/dist/external-CRkuAd6C.cjs.map +0 -1
- package/dist/external-HTq0VBUW.js.map +0 -1
- package/dist/external-VwYNFmdb.cjs +0 -2
- package/dist/external-VwYNFmdb.cjs.map +0 -1
- package/dist/external-j1RQBbSY.js.map +0 -1
- package/dist/select/SelectA.spec.d.ts +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external-PuMpEjUQ.cjs","sources":["../src/tree/core.ts","../src/tree/Tree.tsx"],"sourcesContent":["// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ReactElement } from \"react\";\n\nimport { toArray } from \"@synnaxlabs/x\";\n\nimport { type Haul } from \"@/haul\";\n\nexport interface Node {\n key: string;\n name: string;\n forcePosition?: number;\n icon?: ReactElement;\n allowRename?: boolean;\n hasChildren?: boolean;\n children?: Node[];\n haulItems?: Haul.Item[];\n canDrop?: (items: Haul.Item[]) => boolean;\n href?: string;\n}\n\nexport interface NodeWithPosition extends Node {\n depth: number;\n position: number;\n}\n\nexport interface FlattenedNode extends Node {\n index: number;\n depth: number;\n expanded: boolean;\n}\n\nexport const shouldExpand = (node: Node, expanded: string[]): boolean =>\n expanded.includes(node.key);\n\nexport interface FlattenProps {\n nodes: Node[];\n expanded: string[];\n depth?: number;\n sort?: boolean;\n}\n\nexport const sortAndSplice = (nodes: Node[], sort: boolean): Node[] => {\n if (sort) {\n nodes.sort((a, b) => a.name.localeCompare(b.name));\n }\n let found = false;\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node.forcePosition != null) {\n found = true;\n // remove the node from its current position\n nodes.splice(i, 1);\n // splice it into the forced position\n nodes.splice(node.forcePosition, 0, node);\n node.forcePosition = undefined;\n }\n }\n if (found) return sortAndSplice(nodes, false);\n return nodes;\n};\n\nexport const flatten = ({\n nodes,\n expanded,\n depth = 0,\n sort = true,\n}: FlattenProps): FlattenedNode[] => {\n // Sort the first level of the tree independently of the rest\n if (depth === 0 && sort) nodes = nodes.sort((a, b) => a.name.localeCompare(b.name));\n const flattened: FlattenedNode[] = [];\n nodes.forEach((node, index) => {\n const expand = shouldExpand(node, expanded);\n flattened.push({ ...node, depth, expanded: expand, index });\n if (expand && node.children != null) {\n node.children = sortAndSplice(node.children, sort);\n flattened.push(\n ...flatten({ nodes: node.children, expanded, depth: depth + 1, sort }),\n );\n }\n });\n return flattened;\n};\n\nexport interface MoveNodeProps {\n tree: Node[];\n destination: string;\n keys: string | string[];\n}\n\nexport const moveNode = ({ tree, destination, keys }: MoveNodeProps): Node[] => {\n keys = toArray(keys);\n keys.forEach((key) => {\n const node = findNode({ tree, key });\n if (node == null) return;\n removeNode({ tree, keys: key });\n setNode({ tree, destination, additions: node });\n });\n return tree;\n};\n\nexport interface RemoveNodeProps {\n tree: Node[];\n keys: string | string[];\n}\n\nexport const removeNode = ({ tree, keys }: RemoveNodeProps): Node[] => {\n keys = toArray(keys);\n const treeKeys = tree.map((node) => node.key);\n keys.forEach((key) => {\n const index = treeKeys.indexOf(key);\n if (index !== -1) tree.splice(index, 1);\n else {\n const parent = findNodeParent({ tree, key });\n if (parent != null)\n parent.children = parent.children?.filter((child) => child.key !== key);\n }\n });\n return tree;\n};\n\nexport interface SetNodeProps {\n tree: Node[];\n destination: string;\n additions: Node | Node[];\n}\n\nexport const setNode = ({ tree, destination, additions }: SetNodeProps): Node[] => {\n additions = toArray(additions);\n const node = findNode({ tree, key: destination });\n if (node == null) throw new Error(`Could not find node with key ${destination}`);\n if (node.children == null) node.children = [];\n const addedKeys = additions.map((node) => node.key);\n node.children = [\n ...additions,\n ...node.children.filter((child) => !addedKeys.includes(child.key)),\n ];\n return tree;\n};\n\nexport interface UpdateNodeProps {\n tree: Node[];\n key: string;\n updater: (node: Node) => Node;\n throwOnMissing?: boolean;\n}\n\nexport const updateNode = ({\n tree,\n key,\n updater,\n throwOnMissing = true,\n}: UpdateNodeProps): Node[] => {\n const node = findNode({ tree, key });\n if (node == null) {\n if (throwOnMissing) throw new Error(`Could not find node with key ${key}`);\n return tree;\n }\n const parent = findNodeParent({ tree, key });\n if (parent != null) {\n // splice the updated node into the parent's children\n const index = parent.children?.findIndex((child) => child.key === key);\n if (index != null && index !== -1) parent.children?.splice(index, 1, updater(node));\n } else {\n // we're in the root, so just update the node\n tree.splice(\n tree.findIndex((node) => node.key === key),\n 1,\n updater(node),\n );\n }\n return tree;\n};\n\nexport interface FindNodeProps {\n tree: Node[];\n key: string;\n depth?: number;\n}\n\nexport const findNode = ({\n tree,\n key,\n depth = 0,\n}: FindNodeProps): NodeWithPosition | null => {\n for (let i = 0; i < tree.length; i++) {\n const node = tree[i];\n if (node.key === key) {\n const n = node as NodeWithPosition;\n n.depth = depth;\n n.position = i;\n return n;\n }\n if (node.children != null) {\n const found = findNode({ tree: node.children, key, depth: depth + 1 });\n if (found != null) return found;\n }\n }\n return null;\n};\n\nexport interface FindNodesProps {\n tree: Node[];\n keys: string[];\n}\n\nexport const findNodes = ({ tree, keys }: FindNodesProps): NodeWithPosition[] => {\n const nodes: NodeWithPosition[] = [];\n for (const key of keys) {\n const node = findNode({ tree, key });\n if (node != null) nodes.push(node);\n }\n return nodes;\n};\n\nexport interface FindNodeParentProps {\n tree: Node[];\n key: string;\n}\n\nexport const findNodeParent = ({ tree, key }: FindNodeParentProps): Node | null => {\n for (const node of tree) {\n if (node.children != null) {\n if (node.children.some((child) => child.key === key)) return node;\n const found = findNodeParent({ tree: node.children, key });\n if (found != null) return found;\n }\n }\n return null;\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport {\n type ReactElement,\n useCallback,\n useMemo,\n useState,\n type FC,\n memo,\n} from \"react\";\n\nimport { Icon } from \"@synnaxlabs/media\";\n\nimport { Button } from \"@/button\";\nimport { CSS } from \"@/css\";\nimport { Haul } from \"@/haul\";\nimport { useSyncedRef, useCombinedStateAndRef } from \"@/hooks\";\nimport { List } from \"@/list\";\nimport { type UseSelectOnChangeExtra, type UseSelectProps } from \"@/list/useSelect\";\nimport { CONTEXT_SELECTED, CONTEXT_TARGET } from \"@/menu/ContextMenu\";\nimport { state } from \"@/state\";\nimport { Text } from \"@/text\";\nimport { flatten, type Node, type FlattenedNode } from \"@/tree/core\";\nimport { Triggers } from \"@/triggers\";\nimport { type RenderProp, componentRenderProp } from \"@/util/renderProp\";\n\nimport \"@/tree/Tree.css\";\n\nexport const HAUL_TYPE = \"tree-item\";\n\nexport interface HandleExpandProps {\n current: string[];\n action: \"expand\" | \"contract\";\n clicked: string;\n}\n\nexport interface UseProps {\n onExpand?: (props: HandleExpandProps) => void;\n selected?: string[];\n onSelectedChange?: state.Set<string[]>;\n initialExpanded?: string[];\n nodes: Node[];\n sort?: boolean;\n}\n\nexport interface UseReturn {\n selected: string[];\n expanded: string[];\n onSelect: UseSelectProps<string, FlattenedNode>[\"onChange\"];\n nodes: FlattenedNode[];\n}\n\nconst SHIFT_TRIGGERS: Triggers.Trigger[] = [[\"Shift\"]];\n\nexport const use = (props: UseProps): UseReturn => {\n const {\n onExpand,\n nodes,\n initialExpanded = [],\n sort = true,\n selected: propsSelected,\n onSelectedChange,\n } = props ?? {};\n const [expanded, setExpanded, ref] =\n useCombinedStateAndRef<string[]>(initialExpanded);\n const [selected, setSelected] = state.usePassthrough<string[]>({\n initial: [],\n value: propsSelected,\n onChange: onSelectedChange,\n });\n const flat = useMemo(\n () => flatten({ nodes, expanded, sort }),\n [nodes, expanded, sort],\n );\n const flatRef = useSyncedRef(flat);\n\n const shiftRef = Triggers.useHeldRef({ triggers: SHIFT_TRIGGERS });\n\n const handleSelect: UseSelectProps<string, FlattenedNode>[\"onChange\"] = useCallback(\n (\n keys: string[],\n { clicked }: UseSelectOnChangeExtra<string, FlattenedNode>,\n ): void => {\n setSelected(keys);\n const n = flatRef.current.find((node) => node.key === clicked);\n if (n?.hasChildren === false) return;\n if (clicked == null || shiftRef.current.held) return;\n const currentlyExpanded = ref.current;\n const action = currentlyExpanded.some((key) => key === clicked)\n ? \"contract\"\n : \"expand\";\n let nextExpanded = currentlyExpanded;\n if (action === \"contract\")\n nextExpanded = currentlyExpanded.filter((key) => key !== clicked);\n else nextExpanded = [...currentlyExpanded, clicked];\n setExpanded(nextExpanded);\n onExpand?.({ current: nextExpanded, action, clicked });\n },\n [onExpand, flatRef, setExpanded, setSelected],\n );\n\n return {\n onSelect: handleSelect,\n selected,\n expanded,\n nodes: flat,\n };\n};\n\nexport interface ItemProps extends List.ItemProps<string, FlattenedNode> {\n onDrop?: (key: string, props: Haul.OnDropProps) => Haul.Item[];\n onSuccessfulDrop?: (key: string, props: Haul.OnSuccessfulDropProps) => void;\n onRename?: (key: string, name: string) => void;\n onDoubleClick?: (key: string, e: React.MouseEvent) => void;\n loading?: boolean;\n useMargin?: boolean;\n}\n\ntype TreePropsInheritedFromItem = Pick<\n ItemProps,\n \"onDrop\" | \"onRename\" | \"onSuccessfulDrop\" | \"onDoubleClick\" | \"useMargin\"\n>;\n\ntype TreePropsInheritedFromList = Omit<\n List.VirtualCoreProps<string, FlattenedNode>,\n \"onDrop\" | \"onSelect\" | \"children\" | \"onDoubleClick\" | \"itemHeight\"\n> & {\n itemHeight?: number;\n};\n\nexport interface TreeProps\n extends TreePropsInheritedFromItem,\n TreePropsInheritedFromList {\n nodes: FlattenedNode[];\n selected?: string[];\n onSelect: UseSelectProps<string, FlattenedNode>[\"onChange\"];\n children?: RenderProp<ItemProps, ReactElement>;\n virtual?: boolean;\n}\n\nconst expandedCaret = <Icon.Caret.Down className={CSS.B(\"caret\")} />;\nconst collapsedCaret = <Icon.Caret.Right className={CSS.B(\"caret\")} />;\n\nexport type Item = FC<ItemProps>;\n\nexport const DefaultItem = memo(\n ({\n entry,\n selected,\n onSelect,\n onDrop,\n onRename,\n onSuccessfulDrop,\n onDoubleClick,\n loading = false,\n useMargin = false,\n translate,\n }: ItemProps): ReactElement => {\n const {\n key,\n hasChildren = false,\n allowRename = false,\n children,\n icon,\n name,\n depth,\n expanded,\n href,\n haulItems = [],\n } = entry;\n\n const { getSelected } = List.useSelectionUtils<string>();\n const { getSourceData } = List.useDataUtilContext<string, FlattenedNode>();\n\n const actuallyHasChildren =\n hasChildren || (children != null && children.length > 0);\n\n // Expand, contract, and loading items.\n const startIcons: ReactElement[] = [];\n if (actuallyHasChildren) startIcons.push(expanded ? expandedCaret : collapsedCaret);\n if (icon != null) startIcons.push(icon);\n const endIcons: ReactElement[] = [];\n if (loading) endIcons.push(<Icon.Loading className={CSS.B(\"loading-indicator\")} />);\n\n const [draggingOver, setDraggingOver] = useState(false);\n\n // Drag and Drop\n const { startDrag, ...dropProps } = Haul.useDragAndDrop({\n type: \"Tree.Item\",\n key,\n canDrop: useCallback(({ items: entities, source }) => {\n const keys = entities.map((item) => item.key);\n setDraggingOver(false);\n return source.type === \"Tree.Item\" && !keys.includes(key);\n }, []),\n onDrop: useCallback((props) => onDrop?.(key, props) ?? [], [key, onDrop]),\n onDragOver: useCallback(() => setDraggingOver(true), []),\n });\n\n const handleDragStart = (): void => {\n const selectedItemKeys = getSelected();\n const selectedItems = getSourceData().filter((item) =>\n selectedItemKeys.includes(item.key),\n );\n if (selectedItemKeys.includes(key)) {\n const selectedHaulItems = selectedItems\n .map(({ key, haulItems }) => [{ type: HAUL_TYPE, key }, ...(haulItems ?? [])])\n .flat();\n return startDrag(selectedHaulItems, (props) => onSuccessfulDrop?.(key, props));\n }\n startDrag([{ type: HAUL_TYPE, key }, ...haulItems], (props) =>\n onSuccessfulDrop?.(key, props),\n );\n };\n\n const offsetKey = useMargin ? \"marginLeft\" : \"paddingLeft\";\n\n const baseProps: Button.LinkProps | Button.ButtonProps = {\n id: key,\n variant: \"text\",\n draggable: true,\n className: CSS(\n CONTEXT_TARGET,\n draggingOver && CSS.M(\"dragging-over\"),\n selected && CONTEXT_SELECTED,\n CSS.selected(selected),\n actuallyHasChildren && CSS.M(\"has-children\"),\n ),\n onDragLeave: () => setDraggingOver(false),\n onDragStart: handleDragStart,\n onClick: () => onSelect?.(key),\n style: {\n position: \"absolute\",\n transform: `translateY(${translate}px)`,\n [offsetKey]: `${depth * 1.5 + 1}rem`,\n },\n startIcon: startIcons,\n iconSpacing: \"small\",\n noWrap: true,\n endIcon: endIcons,\n onDoubleClick: (e) => onDoubleClick?.(key, e),\n href,\n ...dropProps,\n };\n\n const Base = href != null ? Button.Link : Button.Button;\n\n return (\n <Base {...baseProps}>\n <Text.MaybeEditable\n id={`text-${key}`}\n level=\"p\"\n allowDoubleClick={false}\n value={name}\n disabled={!allowRename}\n onChange={(name) => onRename?.(key, name)}\n />\n </Base>\n );\n },\n);\nDefaultItem.displayName = \"Tree.Item\";\n\nconst defaultChild = componentRenderProp(DefaultItem);\nexport const Tree = ({\n nodes,\n selected = [],\n onSelect,\n onDrop,\n onRename,\n onSuccessfulDrop,\n onDoubleClick,\n className,\n children = defaultChild,\n itemHeight = 27,\n useMargin = false,\n virtual = true,\n ...props\n}: TreeProps): ReactElement => {\n const Core = virtual ? List.Core.Virtual : List.Core;\n\n return (\n <List.List<string, FlattenedNode> data={nodes}>\n <List.Selector value={selected} onChange={onSelect} allowMultiple replaceOnSingle>\n <Core<string, FlattenedNode>\n itemHeight={itemHeight}\n className={CSS(className, CSS.B(\"tree\"))}\n {...props}\n >\n {(props) =>\n children({\n ...props,\n useMargin,\n onDrop,\n onRename,\n onSuccessfulDrop,\n onDoubleClick,\n })\n }\n </Core>\n </List.Selector>\n </List.List>\n );\n};\n\nexport const startRenaming = (key: string): void => Text.edit(`text-${key}`);\n"],"names":["shouldExpand","node","expanded","sortAndSplice","nodes","sort","a","b","found","i","flatten","depth","flattened","index","expand","moveNode","tree","destination","keys","toArray","key","findNode","removeNode","setNode","treeKeys","parent","findNodeParent","_a","child","additions","addedKeys","updateNode","updater","throwOnMissing","_b","n","findNodes","HAUL_TYPE","SHIFT_TRIGGERS","use","props","onExpand","initialExpanded","propsSelected","onSelectedChange","setExpanded","ref","useCombinedStateAndRef","selected","setSelected","state.usePassthrough","flat","useMemo","flatRef","useSyncedRef","shiftRef","Triggers.useHeldRef","useCallback","clicked","currentlyExpanded","action","nextExpanded","expandedCaret","jsx","Icon","CSS","collapsedCaret","DefaultItem","memo","entry","onSelect","onDrop","onRename","onSuccessfulDrop","onDoubleClick","loading","useMargin","translate","hasChildren","allowRename","children","icon","name","href","haulItems","getSelected","List.useSelectionUtils","getSourceData","List.useDataUtilContext","actuallyHasChildren","startIcons","endIcons","draggingOver","setDraggingOver","useState","startDrag","dropProps","Haul.useDragAndDrop","entities","source","item","handleDragStart","selectedItemKeys","selectedItems","selectedHaulItems","offsetKey","baseProps","CONTEXT_TARGET","CONTEXT_SELECTED","e","Base","Button.Link","Button.Button","Text.MaybeEditable","defaultChild","componentRenderProp","Tree","className","itemHeight","virtual","Core","List.Core","List.List","List.Selector","startRenaming","Text.edit"],"mappings":"2RAuCO,MAAMA,EAAe,CAACC,EAAYC,IACvCA,EAAS,SAASD,EAAK,GAAG,EASfE,EAAgB,CAACC,EAAeC,IAA0B,CACjEA,GACID,EAAA,KAAK,CAACE,EAAGC,IAAMD,EAAE,KAAK,cAAcC,EAAE,IAAI,CAAC,EAEnD,IAAIC,EAAQ,GACZ,QAASC,EAAI,EAAGA,EAAIL,EAAM,OAAQK,IAAK,CAC/B,MAAAR,EAAOG,EAAMK,CAAC,EAChBR,EAAK,eAAiB,OAChBO,EAAA,GAEFJ,EAAA,OAAOK,EAAG,CAAC,EAEjBL,EAAM,OAAOH,EAAK,cAAe,EAAGA,CAAI,EACxCA,EAAK,cAAgB,OAEzB,CACI,OAAAO,EAAcL,EAAcC,EAAO,EAAK,EACrCA,CACT,EAEaM,EAAU,CAAC,CACtB,MAAAN,EACA,SAAAF,EACA,MAAAS,EAAQ,EACR,KAAAN,EAAO,EACT,IAAqC,CAE/BM,IAAU,G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,EAAM,CAAA,GAAGJ,EACR,SAAA3C,EAAA,kBAAA,IAACkD,EAAK,cAAL,CACC,GAAI,QAAQ7F,CAAG,GACf,MAAM,IACN,iBAAkB,GAClB,MAAO8D,EACP,SAAU,CAACH,EACX,SAAWG,GAASV,GAAA,YAAAA,EAAWpD,EAAK8D,EAAI,CAE5C,CAAA,CAAA,CAEJ,CACF,EACAf,EAAY,YAAc,YAE1B,MAAM+C,GAAeC,EAAAA,oBAAoBhD,CAAW,EACvCiD,GAAO,CAAC,CACnB,MAAAhH,EACA,SAAA4C,EAAW,CAAC,EACZ,SAAAsB,EACA,OAAAC,EACA,SAAAC,EACA,iBAAAC,EACA,cAAAC,EACA,UAAA2C,EACA,SAAArC,EAAWkC,GACX,WAAAI,EAAa,GACb,UAAA1C,EAAY,GACZ,QAAA2C,EAAU,GACV,GAAG/E,CACL,IAA+B,CAC7B,MAAMgF,EAAOD,EAAUE,SAAU,QAAUA,EAAAA,OAE3C,+BACGC,EAAAA,KAAA,CAAiC,KAAMtH,EACtC,SAAC2D,EAAA,kBAAA,IAAA4D,WAAA,CAAc,MAAO3E,EAAU,SAAUsB,EAAU,cAAa,GAAC,gBAAe,GAC/E,SAAAP,EAAA,kBAAA,IAACyD,EAAA,CACC,WAAAF,EACA,UAAWrD,EAAI,IAAAoD,EAAWpD,EAAI,IAAA,EAAE,MAAM,CAAC,EACtC,GAAGzB,EAEH,SAACA,GACAwC,EAAS,CACP,GAAGxC,EACH,UAAAoC,EACA,OAAAL,EACA,SAAAC,EACA,iBAAAC,EACA,cAAAC,CAAA,CACD,CAAA,CAAA,CAGP,CAAA,CACF,CAAA,CAEJ,EAEakD,GAAiBxG,GAAsByG,EAAAA,KAAU,QAAQzG,CAAG,EAAE"}
|
|
1
|
+
{"version":3,"file":"external-Mc8M8Xzl.cjs","sources":["../src/tree/core.ts","../src/tree/Tree.tsx"],"sourcesContent":["// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ReactElement } from \"react\";\n\nimport { toArray } from \"@synnaxlabs/x\";\n\nimport { type Haul } from \"@/haul\";\n\nexport interface Node {\n key: string;\n name: string;\n forcePosition?: number;\n icon?: ReactElement;\n allowRename?: boolean;\n hasChildren?: boolean;\n children?: Node[];\n haulItems?: Haul.Item[];\n canDrop?: (items: Haul.Item[]) => boolean;\n href?: string;\n}\n\nexport interface NodeWithPosition extends Node {\n depth: number;\n position: number;\n}\n\nexport interface FlattenedNode extends Node {\n index: number;\n depth: number;\n expanded: boolean;\n}\n\nexport const shouldExpand = (node: Node, expanded: string[]): boolean =>\n expanded.includes(node.key);\n\nexport interface FlattenProps {\n nodes: Node[];\n expanded: string[];\n depth?: number;\n sort?: boolean;\n}\n\nexport const sortAndSplice = (nodes: Node[], sort: boolean): Node[] => {\n if (sort) {\n nodes.sort((a, b) => a.name.localeCompare(b.name));\n }\n let found = false;\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node.forcePosition != null) {\n found = true;\n // remove the node from its current position\n nodes.splice(i, 1);\n // splice it into the forced position\n nodes.splice(node.forcePosition, 0, node);\n node.forcePosition = undefined;\n }\n }\n if (found) return sortAndSplice(nodes, false);\n return nodes;\n};\n\nexport const flatten = ({\n nodes,\n expanded,\n depth = 0,\n sort = true,\n}: FlattenProps): FlattenedNode[] => {\n // Sort the first level of the tree independently of the rest\n if (depth === 0 && sort) nodes = nodes.sort((a, b) => a.name.localeCompare(b.name));\n const flattened: FlattenedNode[] = [];\n nodes.forEach((node, index) => {\n const expand = shouldExpand(node, expanded);\n flattened.push({ ...node, depth, expanded: expand, index });\n if (expand && node.children != null) {\n node.children = sortAndSplice(node.children, sort);\n flattened.push(\n ...flatten({ nodes: node.children, expanded, depth: depth + 1, sort }),\n );\n }\n });\n return flattened;\n};\n\nexport interface MoveNodeProps {\n tree: Node[];\n destination: string;\n keys: string | string[];\n}\n\nexport const moveNode = ({ tree, destination, keys }: MoveNodeProps): Node[] => {\n keys = toArray(keys);\n keys.forEach((key) => {\n const node = findNode({ tree, key });\n if (node == null) return;\n removeNode({ tree, keys: key });\n setNode({ tree, destination, additions: node });\n });\n return tree;\n};\n\nexport interface RemoveNodeProps {\n tree: Node[];\n keys: string | string[];\n}\n\nexport const removeNode = ({ tree, keys }: RemoveNodeProps): Node[] => {\n keys = toArray(keys);\n const treeKeys = tree.map((node) => node.key);\n keys.forEach((key) => {\n const index = treeKeys.indexOf(key);\n if (index !== -1) tree.splice(index, 1);\n else {\n const parent = findNodeParent({ tree, key });\n if (parent != null)\n parent.children = parent.children?.filter((child) => child.key !== key);\n }\n });\n return tree;\n};\n\nexport interface SetNodeProps {\n tree: Node[];\n destination: string;\n additions: Node | Node[];\n}\n\nexport const setNode = ({ tree, destination, additions }: SetNodeProps): Node[] => {\n additions = toArray(additions);\n const node = findNode({ tree, key: destination });\n if (node == null) throw new Error(`Could not find node with key ${destination}`);\n if (node.children == null) node.children = [];\n const addedKeys = additions.map((node) => node.key);\n node.children = [\n ...additions,\n ...node.children.filter((child) => !addedKeys.includes(child.key)),\n ];\n return tree;\n};\n\nexport interface UpdateNodeProps {\n tree: Node[];\n key: string;\n updater: (node: Node) => Node;\n throwOnMissing?: boolean;\n}\n\nexport const updateNode = ({\n tree,\n key,\n updater,\n throwOnMissing = true,\n}: UpdateNodeProps): Node[] => {\n const node = findNode({ tree, key });\n if (node == null) {\n if (throwOnMissing) throw new Error(`Could not find node with key ${key}`);\n return tree;\n }\n const parent = findNodeParent({ tree, key });\n if (parent != null) {\n // splice the updated node into the parent's children\n const index = parent.children?.findIndex((child) => child.key === key);\n if (index != null && index !== -1) parent.children?.splice(index, 1, updater(node));\n } else {\n // we're in the root, so just update the node\n tree.splice(\n tree.findIndex((node) => node.key === key),\n 1,\n updater(node),\n );\n }\n return tree;\n};\n\nexport interface FindNodeProps {\n tree: Node[];\n key: string;\n depth?: number;\n}\n\nexport const findNode = ({\n tree,\n key,\n depth = 0,\n}: FindNodeProps): NodeWithPosition | null => {\n for (let i = 0; i < tree.length; i++) {\n const node = tree[i];\n if (node.key === key) {\n const n = node as NodeWithPosition;\n n.depth = depth;\n n.position = i;\n return n;\n }\n if (node.children != null) {\n const found = findNode({ tree: node.children, key, depth: depth + 1 });\n if (found != null) return found;\n }\n }\n return null;\n};\n\nexport interface FindNodesProps {\n tree: Node[];\n keys: string[];\n}\n\nexport const findNodes = ({ tree, keys }: FindNodesProps): NodeWithPosition[] => {\n const nodes: NodeWithPosition[] = [];\n for (const key of keys) {\n const node = findNode({ tree, key });\n if (node != null) nodes.push(node);\n }\n return nodes;\n};\n\nexport interface FindNodeParentProps {\n tree: Node[];\n key: string;\n}\n\nexport const findNodeParent = ({ tree, key }: FindNodeParentProps): Node | null => {\n for (const node of tree) {\n if (node.children != null) {\n if (node.children.some((child) => child.key === key)) return node;\n const found = findNodeParent({ tree: node.children, key });\n if (found != null) return found;\n }\n }\n return null;\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport {\n type ReactElement,\n useCallback,\n useMemo,\n useState,\n type FC,\n memo,\n} from \"react\";\n\nimport { Icon } from \"@synnaxlabs/media\";\n\nimport { Button } from \"@/button\";\nimport { CSS } from \"@/css\";\nimport { Haul } from \"@/haul\";\nimport { useSyncedRef, useCombinedStateAndRef } from \"@/hooks\";\nimport { List } from \"@/list\";\nimport { type UseSelectOnChangeExtra, type UseSelectProps } from \"@/list/useSelect\";\nimport { CONTEXT_SELECTED, CONTEXT_TARGET } from \"@/menu/ContextMenu\";\nimport { state } from \"@/state\";\nimport { Text } from \"@/text\";\nimport { flatten, type Node, type FlattenedNode } from \"@/tree/core\";\nimport { Triggers } from \"@/triggers\";\nimport { type RenderProp, componentRenderProp } from \"@/util/renderProp\";\n\nimport \"@/tree/Tree.css\";\n\nexport const HAUL_TYPE = \"tree-item\";\n\nexport interface HandleExpandProps {\n current: string[];\n action: \"expand\" | \"contract\";\n clicked: string;\n}\n\nexport interface UseProps {\n onExpand?: (props: HandleExpandProps) => void;\n selected?: string[];\n onSelectedChange?: state.Set<string[]>;\n initialExpanded?: string[];\n nodes: Node[];\n sort?: boolean;\n}\n\nexport interface UseReturn {\n selected: string[];\n expanded: string[];\n onSelect: UseSelectProps<string, FlattenedNode>[\"onChange\"];\n nodes: FlattenedNode[];\n}\n\nconst SHIFT_TRIGGERS: Triggers.Trigger[] = [[\"Shift\"]];\n\nexport const use = (props: UseProps): UseReturn => {\n const {\n onExpand,\n nodes,\n initialExpanded = [],\n sort = true,\n selected: propsSelected,\n onSelectedChange,\n } = props ?? {};\n const [expanded, setExpanded, ref] =\n useCombinedStateAndRef<string[]>(initialExpanded);\n const [selected, setSelected] = state.usePassthrough<string[]>({\n initial: [],\n value: propsSelected,\n onChange: onSelectedChange,\n });\n const flat = useMemo(\n () => flatten({ nodes, expanded, sort }),\n [nodes, expanded, sort],\n );\n const flatRef = useSyncedRef(flat);\n\n const shiftRef = Triggers.useHeldRef({ triggers: SHIFT_TRIGGERS });\n\n const handleSelect: UseSelectProps<string, FlattenedNode>[\"onChange\"] = useCallback(\n (\n keys: string[],\n { clicked }: UseSelectOnChangeExtra<string, FlattenedNode>,\n ): void => {\n setSelected(keys);\n const n = flatRef.current.find((node) => node.key === clicked);\n if (n?.hasChildren === false) return;\n if (clicked == null || shiftRef.current.held) return;\n const currentlyExpanded = ref.current;\n const action = currentlyExpanded.some((key) => key === clicked)\n ? \"contract\"\n : \"expand\";\n let nextExpanded = currentlyExpanded;\n if (action === \"contract\")\n nextExpanded = currentlyExpanded.filter((key) => key !== clicked);\n else nextExpanded = [...currentlyExpanded, clicked];\n setExpanded(nextExpanded);\n onExpand?.({ current: nextExpanded, action, clicked });\n },\n [onExpand, flatRef, setExpanded, setSelected],\n );\n\n return {\n onSelect: handleSelect,\n selected,\n expanded,\n nodes: flat,\n };\n};\n\nexport interface ItemProps extends List.ItemProps<string, FlattenedNode> {\n onDrop?: (key: string, props: Haul.OnDropProps) => Haul.Item[];\n onSuccessfulDrop?: (key: string, props: Haul.OnSuccessfulDropProps) => void;\n onRename?: (key: string, name: string) => void;\n onDoubleClick?: (key: string, e: React.MouseEvent) => void;\n loading?: boolean;\n useMargin?: boolean;\n}\n\ntype TreePropsInheritedFromItem = Pick<\n ItemProps,\n \"onDrop\" | \"onRename\" | \"onSuccessfulDrop\" | \"onDoubleClick\" | \"useMargin\"\n>;\n\ntype TreePropsInheritedFromList = Omit<\n List.VirtualCoreProps<string, FlattenedNode>,\n \"onDrop\" | \"onSelect\" | \"children\" | \"onDoubleClick\" | \"itemHeight\"\n> & {\n itemHeight?: number;\n};\n\nexport interface TreeProps\n extends TreePropsInheritedFromItem,\n TreePropsInheritedFromList {\n nodes: FlattenedNode[];\n selected?: string[];\n onSelect: UseSelectProps<string, FlattenedNode>[\"onChange\"];\n children?: RenderProp<ItemProps, ReactElement>;\n virtual?: boolean;\n}\n\nconst expandedCaret = <Icon.Caret.Down className={CSS.B(\"caret\")} />;\nconst collapsedCaret = <Icon.Caret.Right className={CSS.B(\"caret\")} />;\n\nexport type Item = FC<ItemProps>;\n\nexport const DefaultItem = memo(\n ({\n entry,\n selected,\n onSelect,\n onDrop,\n onRename,\n onSuccessfulDrop,\n onDoubleClick,\n loading = false,\n useMargin = false,\n translate,\n }: ItemProps): ReactElement => {\n const {\n key,\n hasChildren = false,\n allowRename = false,\n children,\n icon,\n name,\n depth,\n expanded,\n href,\n haulItems = [],\n } = entry;\n\n const { getSelected } = List.useSelectionUtils<string>();\n const { getSourceData } = List.useDataUtilContext<string, FlattenedNode>();\n\n const actuallyHasChildren =\n hasChildren || (children != null && children.length > 0);\n\n // Expand, contract, and loading items.\n const startIcons: ReactElement[] = [];\n if (actuallyHasChildren) startIcons.push(expanded ? expandedCaret : collapsedCaret);\n if (icon != null) startIcons.push(icon);\n const endIcons: ReactElement[] = [];\n if (loading) endIcons.push(<Icon.Loading className={CSS.B(\"loading-indicator\")} />);\n\n const [draggingOver, setDraggingOver] = useState(false);\n\n // Drag and Drop\n const { startDrag, ...dropProps } = Haul.useDragAndDrop({\n type: \"Tree.Item\",\n key,\n canDrop: useCallback(({ items: entities, source }) => {\n const keys = entities.map((item) => item.key);\n setDraggingOver(false);\n return source.type === \"Tree.Item\" && !keys.includes(key);\n }, []),\n onDrop: useCallback((props) => onDrop?.(key, props) ?? [], [key, onDrop]),\n onDragOver: useCallback(() => setDraggingOver(true), []),\n });\n\n const handleDragStart = (): void => {\n const selectedItemKeys = getSelected();\n const selectedItems = getSourceData().filter((item) =>\n selectedItemKeys.includes(item.key),\n );\n if (selectedItemKeys.includes(key)) {\n const selectedHaulItems = selectedItems\n .map(({ key, haulItems }) => [{ type: HAUL_TYPE, key }, ...(haulItems ?? [])])\n .flat();\n return startDrag(selectedHaulItems, (props) => onSuccessfulDrop?.(key, props));\n }\n startDrag([{ type: HAUL_TYPE, key }, ...haulItems], (props) =>\n onSuccessfulDrop?.(key, props),\n );\n };\n\n const offsetKey = useMargin ? \"marginLeft\" : \"paddingLeft\";\n\n const baseProps: Button.LinkProps | Button.ButtonProps = {\n id: key,\n variant: \"text\",\n draggable: true,\n className: CSS(\n CONTEXT_TARGET,\n draggingOver && CSS.M(\"dragging-over\"),\n selected && CONTEXT_SELECTED,\n CSS.selected(selected),\n actuallyHasChildren && CSS.M(\"has-children\"),\n ),\n onDragLeave: () => setDraggingOver(false),\n onDragStart: handleDragStart,\n onClick: () => onSelect?.(key),\n style: {\n position: \"absolute\",\n transform: `translateY(${translate}px)`,\n [offsetKey]: `${depth * 1.5 + 1}rem`,\n },\n startIcon: startIcons,\n iconSpacing: \"small\",\n noWrap: true,\n endIcon: endIcons,\n onDoubleClick: (e) => onDoubleClick?.(key, e),\n href,\n ...dropProps,\n };\n\n const Base = href != null ? Button.Link : Button.Button;\n\n return (\n <Base {...baseProps}>\n <Text.MaybeEditable\n id={`text-${key}`}\n level=\"p\"\n allowDoubleClick={false}\n value={name}\n disabled={!allowRename}\n onChange={(name) => onRename?.(key, name)}\n />\n </Base>\n );\n },\n);\nDefaultItem.displayName = \"Tree.Item\";\n\nconst defaultChild = componentRenderProp(DefaultItem);\nexport const Tree = ({\n nodes,\n selected = [],\n onSelect,\n onDrop,\n onRename,\n onSuccessfulDrop,\n onDoubleClick,\n className,\n children = defaultChild,\n itemHeight = 27,\n useMargin = false,\n virtual = true,\n ...props\n}: TreeProps): ReactElement => {\n const Core = virtual ? List.Core.Virtual : List.Core;\n\n return (\n <List.List<string, FlattenedNode> data={nodes}>\n <List.Selector value={selected} onChange={onSelect} allowMultiple replaceOnSingle>\n <Core<string, FlattenedNode>\n itemHeight={itemHeight}\n className={CSS(className, CSS.B(\"tree\"))}\n {...props}\n >\n {(props) =>\n children({\n ...props,\n useMargin,\n onDrop,\n onRename,\n onSuccessfulDrop,\n onDoubleClick,\n })\n }\n </Core>\n </List.Selector>\n </List.List>\n );\n};\n\nexport const startRenaming = (key: string): void => Text.edit(`text-${key}`);\n"],"names":["shouldExpand","node","expanded","sortAndSplice","nodes","sort","a","b","found","i","flatten","depth","flattened","index","expand","moveNode","tree","destination","keys","toArray","key","findNode","removeNode","setNode","treeKeys","parent","findNodeParent","_a","child","additions","addedKeys","updateNode","updater","throwOnMissing","_b","n","findNodes","HAUL_TYPE","SHIFT_TRIGGERS","use","props","onExpand","initialExpanded","propsSelected","onSelectedChange","setExpanded","ref","useCombinedStateAndRef","selected","setSelected","state.usePassthrough","flat","useMemo","flatRef","useSyncedRef","shiftRef","Triggers.useHeldRef","useCallback","clicked","currentlyExpanded","action","nextExpanded","expandedCaret","jsx","Icon","CSS","collapsedCaret","DefaultItem","memo","entry","onSelect","onDrop","onRename","onSuccessfulDrop","onDoubleClick","loading","useMargin","translate","hasChildren","allowRename","children","icon","name","href","haulItems","getSelected","List.useSelectionUtils","getSourceData","List.useDataUtilContext","actuallyHasChildren","startIcons","endIcons","draggingOver","setDraggingOver","useState","startDrag","dropProps","Haul.useDragAndDrop","entities","source","item","handleDragStart","selectedItemKeys","selectedItems","selectedHaulItems","offsetKey","baseProps","CONTEXT_TARGET","CONTEXT_SELECTED","e","Base","Button.Link","Button.Button","Text.MaybeEditable","defaultChild","componentRenderProp","Tree","className","itemHeight","virtual","Core","List.Core","List.List","List.Selector","startRenaming","Text.edit"],"mappings":"2RAuCO,MAAMA,EAAe,CAACC,EAAYC,IACvCA,EAAS,SAASD,EAAK,GAAG,EASfE,EAAgB,CAACC,EAAeC,IAA0B,CACjEA,GACID,EAAA,KAAK,CAACE,EAAGC,IAAMD,EAAE,KAAK,cAAcC,EAAE,IAAI,CAAC,EAEnD,IAAIC,EAAQ,GACZ,QAASC,EAAI,EAAGA,EAAIL,EAAM,OAAQK,IAAK,CAC/B,MAAAR,EAAOG,EAAMK,CAAC,EAChBR,EAAK,eAAiB,OAChBO,EAAA,GAEFJ,EAAA,OAAOK,EAAG,CAAC,EAEjBL,EAAM,OAAOH,EAAK,cAAe,EAAGA,CAAI,EACxCA,EAAK,cAAgB,OAEzB,CACI,OAAAO,EAAcL,EAAcC,EAAO,EAAK,EACrCA,CACT,EAEaM,EAAU,CAAC,CACtB,MAAAN,EACA,SAAAF,EACA,MAAAS,EAAQ,EACR,KAAAN,EAAO,EACT,IAAqC,CAE/BM,IAAU,GAAKN,IAAcD,EAAAA,EAAM,KAAK,CAACE,EAAGC,IAAMD,EAAE,KAAK,cAAcC,EAAE,IAAI,CAAC,GAClF,MAAMK,EAA6B,CAAA,EAC7B,OAAAR,EAAA,QAAQ,CAACH,EAAMY,IAAU,CACvB,MAAAC,EAASd,EAAaC,EAAMC,CAAQ,EAChCU,EAAA,KAAK,CAAE,GAAGX,EAAM,MAAAU,EAAO,SAAUG,EAAQ,MAAAD,EAAO,EACtDC,G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,CAAW,EACvCiD,GAAO,CAAC,CACnB,MAAAhH,EACA,SAAA4C,EAAW,CAAC,EACZ,SAAAsB,EACA,OAAAC,EACA,SAAAC,EACA,iBAAAC,EACA,cAAAC,EACA,UAAA2C,EACA,SAAArC,EAAWkC,GACX,WAAAI,EAAa,GACb,UAAA1C,EAAY,GACZ,QAAA2C,EAAU,GACV,GAAG/E,CACL,IAA+B,CAC7B,MAAMgF,EAAOD,EAAUE,SAAU,QAAUA,EAAAA,OAE3C,+BACGC,EAAAA,KAAA,CAAiC,KAAMtH,EACtC,SAAC2D,EAAA,kBAAA,IAAA4D,WAAA,CAAc,MAAO3E,EAAU,SAAUsB,EAAU,cAAa,GAAC,gBAAe,GAC/E,SAAAP,EAAA,kBAAA,IAACyD,EAAA,CACC,WAAAF,EACA,UAAWrD,EAAI,IAAAoD,EAAWpD,EAAI,IAAA,EAAE,MAAM,CAAC,EACtC,GAAGzB,EAEH,SAACA,GACAwC,EAAS,CACP,GAAGxC,EACH,UAAAoC,EACA,OAAAL,EACA,SAAAC,EACA,iBAAAC,EACA,cAAAC,CAAA,CACD,CAAA,CAAA,CAGP,CAAA,CACF,CAAA,CAEJ,EAEakD,GAAiBxG,GAAsByG,EAAAA,KAAU,QAAQzG,CAAG,EAAE"}
|
|
@@ -2,7 +2,7 @@ import { j as n } from "./jsx-runtime-NmMXPjeo.js";
|
|
|
2
2
|
import { createContext as p, useContext as v, isValidElement as j, Fragment as f } from "react";
|
|
3
3
|
import { C as a, e as h } from "./css-rizsElAK.js";
|
|
4
4
|
import { S as m } from "./Center-iTyfvHz5.js";
|
|
5
|
-
import { I as B, ad as C, B as S, W as b } from "./Toggle-
|
|
5
|
+
import { I as B, ad as C, B as S, W as b } from "./Toggle-zmqGwWeq.js";
|
|
6
6
|
import { c as x } from "./aggregator-Q_onjsH5.js";
|
|
7
7
|
const u = p({
|
|
8
8
|
divided: !1,
|
|
@@ -110,4 +110,4 @@ export {
|
|
|
110
110
|
z as H,
|
|
111
111
|
D as e
|
|
112
112
|
};
|
|
113
|
-
//# sourceMappingURL=external-
|
|
113
|
+
//# sourceMappingURL=external-P6hmttIX.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external-QpYuwpfo.js","sources":["../src/header/Header.tsx","../src/header/Actions.tsx","../src/header/ButtonTitle.tsx","../src/header/Title.tsx"],"sourcesContent":["// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport {\n createContext,\n type ReactElement,\n type ReactNode,\n useContext as reactUseContext,\n} from \"react\";\n\nimport { Align } from \"@/align\";\nimport { CSS } from \"@/css\";\nimport { type Text } from \"@/text\";\n\nimport \"@/header/Header.css\";\n\nexport interface HeaderProps extends Omit<Align.SpaceProps, \"children\" | \"el\"> {\n level?: Text.Level;\n divided?: boolean;\n children: ReactNode | [ReactNode, ReactNode];\n}\n\nexport interface ContextValue {\n divided: boolean;\n level: Text.Level;\n}\n\nconst Context = createContext<ContextValue>({\n divided: false,\n level: \"h1\",\n});\n\nexport const useContext = (): ContextValue => reactUseContext(Context);\n\n/**\n * The container for a module header.\n *\n * @param props - The component props. All unused props will be passed down to the\n * {@link Space} containing the header.\n * @param props.level - The font level for the header. See the {@link Typography.Text}\n * component for all possible levels. Default is \"h1.\"\n * @param props.icon - An optional icon to add add before the start of the header text.\n * @param props.actions - A list of actions to be rendered on the right side ofthe header.\n * If the action is a JSX element, it will be rendered directly, and if its of type\n * ButtonIconProps, a ButtonIconOnly will be rendered using the given props.\n * @param props.divided - If true, creates a divider between the start icon, header text,\n * and each action. Default is false.\n */\nexport const Header = ({\n children,\n className,\n level = \"h1\",\n divided = false,\n ...props\n}: HeaderProps): ReactElement => (\n <Context.Provider value={{ level, divided }}>\n <Align.Space\n el=\"header\"\n direction=\"x\"\n justify=\"spaceBetween\"\n className={CSS(\n CSS.B(\"header\"),\n CSS.bordered(\"bottom\"),\n divided && CSS.BM(\"header\", \"divided\"),\n className,\n )}\n {...props}\n >\n {children}\n </Align.Space>\n </Context.Provider>\n);\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { Fragment, isValidElement, type ReactElement } from \"react\";\n\nimport { toArray } from \"@synnaxlabs/x\";\n\nimport { Align } from \"@/align\";\nimport { Button } from \"@/button\";\nimport { CSS } from \"@/css\";\nimport { Divider } from \"@/divider\";\nimport { useContext } from \"@/header/Header\";\nimport { Text } from \"@/text\";\n\nexport type ActionSpec = Button.IconProps | ReactElement;\n\nexport interface ActionsProps {\n children?: ActionSpec | ActionSpec[];\n}\n\n/**\n * Custom actions to render on the right side of the header.\n *\n * @param children - The actions to render. If the action is of type\n * {@link ButtonIconProps}, a correectly sized {@link ButtonIconOnly} is rendered\n * using the given props. If the action is a JSX element, it is renderered directly.\n * It's a good idea to prefer the latter in almost all cases for simplicity.\n */\nexport const Actions = ({ children = [] }: ActionsProps): ReactElement => {\n const { level, divided } = useContext();\n return (\n <Align.Space\n direction=\"x\"\n size=\"small\"\n align=\"center\"\n className={CSS.BE(\"header\", \"actions\")}\n >\n {toArray(children).map((action, i) => (\n <Action key={i} index={i} level={level} divided={divided}>\n {action}\n </Action>\n ))}\n </Align.Space>\n );\n};\n\ninterface ActionProps {\n index: number;\n level: Text.Level;\n children: ReactElement | Button.IconProps;\n divided: boolean;\n}\n\nconst Action = ({ index, level, children, divided }: ActionProps): ReactElement => {\n let content: ReactElement = children as ReactElement;\n if (!isValidElement(children)) {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n const props = children as Button.IconProps;\n content = (\n <Button.Icon\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n props.onClick?.(e);\n }}\n key={index}\n size={Text.LevelComponentSizes[level]}\n {...props}\n />\n );\n }\n return (\n <Fragment key={index}>\n {divided && <Divider.Divider />}\n {content}\n </Fragment>\n );\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ReactElement } from \"react\";\n\nimport { Button } from \"@/button\";\nimport { CSS } from \"@/css\";\nimport { useContext } from \"@/header/Header\";\nimport { Text } from \"@/text\";\n\nexport interface ButtonTitleProps\n extends Omit<Button.ButtonProps, \"variant\" | \"size\"> {}\n\n/**\n * Header.Title.Use renders a clickable header title.\n *\n * @param props - The comonent props. The props for this component are identical\n * to {@link Button}, except the variant is always 'outlined' and that the component size\n * is automatically inferred from the 'level' prop passsed to the parent {@link Header}\n * component.\n */\nexport const ButtonTitle = ({\n children = \"\",\n className,\n onClick,\n ...props\n}: ButtonTitleProps): ReactElement => {\n const { level } = useContext();\n return (\n <Button.Button\n variant=\"text\"\n size={Text.LevelComponentSizes[level]}\n onClick={onClick}\n className={CSS(CSS.B(\"header-button-title\"), className)}\n sharp\n {...props}\n >\n {children}\n </Button.Button>\n );\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ReactElement } from \"react\";\n\nimport { CSS } from \"@/css\";\nimport { useContext } from \"@/header/Header\";\nimport { Text } from \"@/text\";\n\nexport interface TitleProps extends Omit<Text.WithIconProps, \"divided\" | \"level\"> {\n level?: Text.Level;\n}\n\n/**\n * Renders the title for the header component.\n *\n * @param props - The component props. The props for this component are identical\n * to the {@link Typography.TextWithIcon} component, except that the 'level', and\n * 'divider' props are inherited from the parent {@link Header} component.\n */\nexport const Title = ({\n className,\n level: propsLevel,\n ...props\n}: TitleProps): ReactElement => {\n const { level, divided } = useContext();\n return (\n <Text.WithIcon\n className={CSS(CSS.BE(\"header\", \"text\"), className)}\n level={propsLevel ?? level}\n divided={divided}\n size={1.5}\n {...props}\n />\n );\n};\n"],"names":["Context","createContext","useContext","reactUseContext","Header","children","className","level","divided","props","jsx","Align.Space","CSS","Actions","toArray","action","i","Action","index","content","isValidElement","Button.Icon","e","_a","Text.LevelComponentSizes","Fragment","Divider.Divider","ButtonTitle","onClick","Button.Button","Title","propsLevel","Text.WithIcon"],"mappings":";;;;;;AAiCA,MAAMA,IAAUC,EAA4B;AAAA,EAC1C,SAAS;AAAA,EACT,OAAO;AACT,CAAC,GAEYC,IAAa,MAAoBC,EAAgBH,CAAO,GAgBxDI,IAAS,CAAC;AAAA,EACrB,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,SAAAC,IAAU;AAAA,EACV,GAAGC;AACL,MACEC,gBAAAA,EAAA,IAACV,EAAQ,UAAR,EAAiB,OAAO,EAAE,OAAAO,GAAO,SAAAC,KAChC,UAAAE,gBAAAA,EAAA;AAAA,EAACC;AAAAA,EAAA;AAAA,IACC,IAAG;AAAA,IACH,WAAU;AAAA,IACV,SAAQ;AAAA,IACR,WAAWC;AAAA,MACTA,EAAI,EAAE,QAAQ;AAAA,MACdA,EAAI,SAAS,QAAQ;AAAA,MACrBJ,KAAWI,EAAI,GAAG,UAAU,SAAS;AAAA,MACrCN;AAAA,IACF;AAAA,IACC,GAAGG;AAAA,IAEH,UAAAJ;AAAA,EAAA;AACH,EACF,CAAA,GC1CWQ,IAAU,CAAC,EAAE,UAAAR,IAAW,CAAA,QAAqC;AACxE,QAAM,EAAE,OAAAE,GAAO,SAAAC,EAAQ,IAAIN,EAAW;AAEpC,SAAAQ,gBAAAA,EAAA;AAAA,IAACC;AAAAA,IAAA;AAAA,MAC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ACtD,OAAK;AAAA,MACJ,GAAGG;AAAA,MAEH,UAAAJ;AAAA,IAAA;AAAA,EAAA;AAGP,GCpBayB,IAAQ,CAAC;AAAA,EACpB,WAAAxB;AAAA,EACA,OAAOyB;AAAA,EACP,GAAGtB;AACL,MAAgC;AAC9B,QAAM,EAAE,OAAAF,GAAO,SAAAC,EAAQ,IAAIN,EAAW;AAEpC,SAAAQ,gBAAAA,EAAA;AAAA,IAACsB;AAAAA,IAAA;AAAA,MACC,WAAWpB,EAAIA,EAAI,GAAG,UAAU,MAAM,GAAGN,CAAS;AAAA,MAClD,OAAOyB,KAAcxB;AAAA,MACrB,SAAAC;AAAA,MACA,MAAM;AAAA,MACL,GAAGC;AAAA,IAAA;AAAA,EAAA;AAGV;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"external-P6hmttIX.js","sources":["../src/header/Header.tsx","../src/header/Actions.tsx","../src/header/ButtonTitle.tsx","../src/header/Title.tsx"],"sourcesContent":["// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport {\n createContext,\n type ReactElement,\n type ReactNode,\n useContext as reactUseContext,\n} from \"react\";\n\nimport { Align } from \"@/align\";\nimport { CSS } from \"@/css\";\nimport { type Text } from \"@/text\";\n\nimport \"@/header/Header.css\";\n\nexport interface HeaderProps extends Omit<Align.SpaceProps, \"children\" | \"el\"> {\n level?: Text.Level;\n divided?: boolean;\n children: ReactNode | [ReactNode, ReactNode];\n}\n\nexport interface ContextValue {\n divided: boolean;\n level: Text.Level;\n}\n\nconst Context = createContext<ContextValue>({\n divided: false,\n level: \"h1\",\n});\n\nexport const useContext = (): ContextValue => reactUseContext(Context);\n\n/**\n * The container for a module header.\n *\n * @param props - The component props. All unused props will be passed down to the\n * {@link Space} containing the header.\n * @param props.level - The font level for the header. See the {@link Typography.Text}\n * component for all possible levels. Default is \"h1.\"\n * @param props.icon - An optional icon to add add before the start of the header text.\n * @param props.actions - A list of actions to be rendered on the right side ofthe header.\n * If the action is a JSX element, it will be rendered directly, and if its of type\n * ButtonIconProps, a ButtonIconOnly will be rendered using the given props.\n * @param props.divided - If true, creates a divider between the start icon, header text,\n * and each action. Default is false.\n */\nexport const Header = ({\n children,\n className,\n level = \"h1\",\n divided = false,\n ...props\n}: HeaderProps): ReactElement => (\n <Context.Provider value={{ level, divided }}>\n <Align.Space\n el=\"header\"\n direction=\"x\"\n justify=\"spaceBetween\"\n className={CSS(\n CSS.B(\"header\"),\n CSS.bordered(\"bottom\"),\n divided && CSS.BM(\"header\", \"divided\"),\n className,\n )}\n {...props}\n >\n {children}\n </Align.Space>\n </Context.Provider>\n);\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { Fragment, isValidElement, type ReactElement } from \"react\";\n\nimport { toArray } from \"@synnaxlabs/x\";\n\nimport { Align } from \"@/align\";\nimport { Button } from \"@/button\";\nimport { CSS } from \"@/css\";\nimport { Divider } from \"@/divider\";\nimport { useContext } from \"@/header/Header\";\nimport { Text } from \"@/text\";\n\nexport type ActionSpec = Button.IconProps | ReactElement;\n\nexport interface ActionsProps {\n children?: ActionSpec | ActionSpec[];\n}\n\n/**\n * Custom actions to render on the right side of the header.\n *\n * @param children - The actions to render. If the action is of type\n * {@link ButtonIconProps}, a correectly sized {@link ButtonIconOnly} is rendered\n * using the given props. If the action is a JSX element, it is renderered directly.\n * It's a good idea to prefer the latter in almost all cases for simplicity.\n */\nexport const Actions = ({ children = [] }: ActionsProps): ReactElement => {\n const { level, divided } = useContext();\n return (\n <Align.Space\n direction=\"x\"\n size=\"small\"\n align=\"center\"\n className={CSS.BE(\"header\", \"actions\")}\n >\n {toArray(children).map((action, i) => (\n <Action key={i} index={i} level={level} divided={divided}>\n {action}\n </Action>\n ))}\n </Align.Space>\n );\n};\n\ninterface ActionProps {\n index: number;\n level: Text.Level;\n children: ReactElement | Button.IconProps;\n divided: boolean;\n}\n\nconst Action = ({ index, level, children, divided }: ActionProps): ReactElement => {\n let content: ReactElement = children as ReactElement;\n if (!isValidElement(children)) {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n const props = children as Button.IconProps;\n content = (\n <Button.Icon\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n props.onClick?.(e);\n }}\n key={index}\n size={Text.LevelComponentSizes[level]}\n {...props}\n />\n );\n }\n return (\n <Fragment key={index}>\n {divided && <Divider.Divider />}\n {content}\n </Fragment>\n );\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ReactElement } from \"react\";\n\nimport { Button } from \"@/button\";\nimport { CSS } from \"@/css\";\nimport { useContext } from \"@/header/Header\";\nimport { Text } from \"@/text\";\n\nexport interface ButtonTitleProps\n extends Omit<Button.ButtonProps, \"variant\" | \"size\"> {}\n\n/**\n * Header.Title.Use renders a clickable header title.\n *\n * @param props - The comonent props. The props for this component are identical\n * to {@link Button}, except the variant is always 'outlined' and that the component size\n * is automatically inferred from the 'level' prop passsed to the parent {@link Header}\n * component.\n */\nexport const ButtonTitle = ({\n children = \"\",\n className,\n onClick,\n ...props\n}: ButtonTitleProps): ReactElement => {\n const { level } = useContext();\n return (\n <Button.Button\n variant=\"text\"\n size={Text.LevelComponentSizes[level]}\n onClick={onClick}\n className={CSS(CSS.B(\"header-button-title\"), className)}\n sharp\n {...props}\n >\n {children}\n </Button.Button>\n );\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ReactElement } from \"react\";\n\nimport { CSS } from \"@/css\";\nimport { useContext } from \"@/header/Header\";\nimport { Text } from \"@/text\";\n\nexport interface TitleProps extends Omit<Text.WithIconProps, \"divided\" | \"level\"> {\n level?: Text.Level;\n}\n\n/**\n * Renders the title for the header component.\n *\n * @param props - The component props. The props for this component are identical\n * to the {@link Typography.TextWithIcon} component, except that the 'level', and\n * 'divider' props are inherited from the parent {@link Header} component.\n */\nexport const Title = ({\n className,\n level: propsLevel,\n ...props\n}: TitleProps): ReactElement => {\n const { level, divided } = useContext();\n return (\n <Text.WithIcon\n className={CSS(CSS.BE(\"header\", \"text\"), className)}\n level={propsLevel ?? level}\n divided={divided}\n size={1.5}\n {...props}\n />\n );\n};\n"],"names":["Context","createContext","useContext","reactUseContext","Header","children","className","level","divided","props","jsx","Align.Space","CSS","Actions","toArray","action","i","Action","index","content","isValidElement","Button.Icon","e","_a","Text.LevelComponentSizes","Fragment","Divider.Divider","ButtonTitle","onClick","Button.Button","Title","propsLevel","Text.WithIcon"],"mappings":";;;;;;AAiCA,MAAMA,IAAUC,EAA4B;AAAA,EAC1C,SAAS;AAAA,EACT,OAAO;AACT,CAAC,GAEYC,IAAa,MAAoBC,EAAgBH,CAAO,GAgBxDI,IAAS,CAAC;AAAA,EACrB,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,SAAAC,IAAU;AAAA,EACV,GAAGC;AACL,MACEC,gBAAAA,EAAA,IAACV,EAAQ,UAAR,EAAiB,OAAO,EAAE,OAAAO,GAAO,SAAAC,KAChC,UAAAE,gBAAAA,EAAA;AAAA,EAACC;AAAAA,EAAA;AAAA,IACC,IAAG;AAAA,IACH,WAAU;AAAA,IACV,SAAQ;AAAA,IACR,WAAWC;AAAA,MACT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GAFYD,CAGf;AAEJ,GCxDaS,IAAc,CAAC;AAAA,EAC1B,UAAAtB,IAAW;AAAA,EACX,WAAAC;AAAA,EACA,SAAAsB;AAAA,EACA,GAAGnB;AACL,MAAsC;AAC9B,QAAA,EAAE,OAAAF,MAAUL;AAEhB,SAAAQ,gBAAAA,EAAA;AAAA,IAACmB;AAAAA,IAAA;AAAA,MACC,SAAQ;AAAA,MACR,MAAML,EAAyBjB,CAAK;AAAA,MACpC,SAAAqB;AAAA,MACA,WAAWhB,EAAIA,EAAI,EAAE,qBAAqB,GAAGN,CAAS;AAAA,MACtD,OAAK;AAAA,MACJ,GAAGG;AAAA,MAEH,UAAAJ;AAAA,IAAA;AAAA,EAAA;AAGP,GCpBayB,IAAQ,CAAC;AAAA,EACpB,WAAAxB;AAAA,EACA,OAAOyB;AAAA,EACP,GAAGtB;AACL,MAAgC;AAC9B,QAAM,EAAE,OAAAF,GAAO,SAAAC,EAAQ,IAAIN,EAAW;AAEpC,SAAAQ,gBAAAA,EAAA;AAAA,IAACsB;AAAAA,IAAA;AAAA,MACC,WAAWpB,EAAIA,EAAI,GAAG,UAAU,MAAM,GAAGN,CAAS;AAAA,MAClD,OAAOyB,KAAcxB;AAAA,MACrB,SAAAC;AAAA,MACA,MAAM;AAAA,MACL,GAAGC;AAAA,IAAA;AAAA,EAAA;AAGV;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const t=require("./Toggle-
|
|
2
|
-
//# sourceMappingURL=external-
|
|
1
|
+
"use strict";const t=require("./Toggle-qW_TcIDh.cjs"),i=require("./jsx-runtime-evvPGacs.cjs"),n=require("./css-JWFtNl10.cjs"),j=require("react"),g=require("./Center-Q-fgAb96.cjs");require("./aggregator-6_J8kSSO.cjs");const R=require("react-hook-form"),C=({className:e,variant:r="error",...s})=>i.jsxRuntimeExports.jsx(t.Text,{className:n.CSS(n.CSS.B("input-help-text"),n.CSS.BM("input-help-text",r),e),level:"small",...s}),E=({className:e,...r})=>i.jsxRuntimeExports.jsx("label",{className:n.CSS(n.CSS.B("input-label"),e),...r}),D=e=>e.replace(/([A-Z])/g," $1").replace(/^./,r=>r.toUpperCase()),O=(e,r="x")=>e??(n.direction$1.construct(r)==="y"?"stretch":"center"),h=({label:e,showLabel:r=!0,helpText:s,direction:x="y",className:a,children:S,align:o,size:d="small",padHelpText:u=!1,...T})=>{let l;return x==="x"?l=i.jsxRuntimeExports.jsxs(g.Space,{direction:"y",size:"small",children:[S,(u||s!=null)&&i.jsxRuntimeExports.jsx(C,{children:s})]}):l=i.jsxRuntimeExports.jsxs(g.Space,{direction:"y",size:1/3,children:[S,(u||s!=null)&&i.jsxRuntimeExports.jsx(C,{children:s})]}),i.jsxRuntimeExports.jsxs(g.Space,{className:n.CSS(n.CSS.B("input-item"),a),direction:x,size:d,align:O(o,x),...T,children:[r&&i.jsxRuntimeExports.jsx(E,{children:e}),l]})},y=t.componentRenderProp(t.Text$1),b=({name:e,rules:r,shouldUnregister:s,defaultValue:x,label:a,children:S=y,alsoValidate:o,padHelpText:d=!0,ref:u,...T})=>{var f;const{field:l,fieldState:p}=R.useController({rules:r,name:e}),{trigger:c}=R.useFormContext();a==null&&(a=D(e));const m=j.useCallback(()=>{l.onBlur(),o!=null&&c(o)},[l.onBlur,c,o,e]);return i.jsxRuntimeExports.jsx(h,{label:a,padHelpText:d,helpText:(f=p.error)==null?void 0:f.message,...T,children:S({onChange:l.onChange,value:l.value,onBlur:m})})},q=({value:e,onChange:r,onBlur:s,...x})=>{const a=new n.TimeStamp(e,"UTC"),[S,o]=j.useState(a.fString("ISO","local").slice(0,-1)),[d,u]=j.useState(!0),T=p=>{let c=p.toString();o(c);let m=new n.TimeStamp(p,"UTC");c.length<23&&(c+=".000"),m=m.add((n.TimeStamp.now().date().getTimezoneOffset()-m.date().getTimezoneOffset())*n.TimeSpan.MINUTE.valueOf());let f=!1;try{f=m.fString("ISO","local").slice(0,-1)===c}catch{console.error("e")}if(!f){u(!1);return}r(m.valueOf()),u(!0)},l=p=>{u(!0),o(new n.TimeStamp(e,"UTC").fString("ISO","local").slice(0,-1)),s==null||s(p)};return i.jsxRuntimeExports.jsx(t.Text$1,{type:"datetime-local",onBlur:l,required:!1,value:d?new n.TimeStamp(e,"UTC").fString("ISO","local").slice(0,-1):S,onChange:T,...x})},B=Object.freeze(Object.defineProperty({__proto__:null,Date:t.Date,DateTime:q,DragButton:t.DragButton,HFItem:b,HelpText:C,Item:h,Label:E,Numeric:t.Numeric,Switch:t.Switch$1,Text:t.Text$1,TextArea:t.TextArea,Time:t.Time,combineDateAndTimeValue:t.combineDateAndTimeValue,useDate:t.useDate,useTime:t.useTime},Symbol.toStringTag,{value:"Module"}));exports.Item=h;exports.external=B;
|
|
2
|
+
//# sourceMappingURL=external-RsG62zSr.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external-hclXaeBH.cjs","sources":["../src/input/HelpText.tsx","../src/input/Label.tsx","../src/util/case.ts","../src/input/Item.tsx","../src/input/DateTime.tsx"],"sourcesContent":["// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ReactElement } from \"react\";\n\nimport { CSS } from \"@/css\";\nimport { type Status } from \"@/status\";\nimport { Text } from \"@/text\";\n\nimport \"@/input/HelpText.css\";\n\n/** Props for the {@link HelpText} component. */\nexport interface HelpTextProps extends Omit<Text.TextProps<\"small\">, \"level\" | \"ref\"> {\n variant?: Status.Variant;\n}\n\n/**\n * Help text for an input component. We generally recommend using Input.Item with a\n * 'helpText' prop instead of this component. This component is useful for low-level\n * control over the help text element.\n *\n * @param props - Props for the help text component. Unlisted props are passed to the\n * underlying text element.\n * @param props.variant - The variant of the help text.\n * \"success\" | \"error\" | \"warning\" | \"info\" | \"loading\" | \"disabled\n * @default \"info\"\n */\nexport const HelpText = ({\n className,\n variant = \"error\",\n ...props\n}: HelpTextProps): ReactElement => (\n <Text.Text<\"small\">\n className={CSS(\n CSS.B(\"input-help-text\"),\n CSS.BM(\"input-help-text\", variant),\n className,\n )}\n level=\"small\"\n {...props}\n />\n);\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type DetailedHTMLProps, type HTMLAttributes, type ReactElement } from \"react\";\n\nimport { CSS } from \"@/css\";\n\nimport \"@/input/Label.css\";\n\n/** Props for the {@link Label} component. */\nexport interface LabelProps\n extends DetailedHTMLProps<HTMLAttributes<HTMLLabelElement>, HTMLLabelElement> {}\n\n/**\n * A thin, styled wrapper for an input label. We generally recommend using Input.Item\n * with a 'label' prop instead of this component. This component is useful for\n * low-level control over the label element.\n *\n * @param props - Props for the label component. Unlisted props are passed to the\n * underlying label element.\n */\nexport const Label = ({ className, ...props }: LabelProps): ReactElement => {\n return <label className={CSS(CSS.B(\"input-label\"), className)} {...props} />;\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nexport const camelToTitle = (str: string): string =>\n str.replace(/([A-Z])/g, \" $1\").replace(/^./, (str) => str.toUpperCase());\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { useCallback, type ReactElement } from \"react\";\n\nimport { direction } from \"@synnaxlabs/x\";\nimport {\n type UseControllerProps,\n useController,\n useFormContext,\n} from \"react-hook-form\";\n\nimport { Align } from \"@/align\";\nimport { CSS } from \"@/css\";\nimport { HelpText } from \"@/input/HelpText\";\nimport { Label } from \"@/input/Label\";\nimport { Text } from \"@/input/Text\";\nimport { type Control, type Value } from \"@/input/types\";\nimport { camelToTitle } from \"@/util/case\";\nimport { componentRenderProp, type RenderProp } from \"@/util/renderProp\";\n\nimport \"@/input/Item.css\";\n\nexport interface ItemProps extends Align.SpaceProps {\n label?: string;\n showLabel?: boolean;\n helpText?: string;\n padHelpText?: boolean;\n}\n\nconst maybeDefaultAlignment = (\n align?: Align.Alignment,\n dir: direction.Crude = \"x\",\n): Align.Alignment => {\n if (align != null) return align;\n return direction.construct(dir) === \"y\" ? \"stretch\" : \"center\";\n};\n\nexport const Item = ({\n label,\n showLabel = true,\n helpText,\n direction = \"y\",\n className,\n children,\n align,\n size = \"small\",\n padHelpText = false,\n ...props\n}: ItemProps): ReactElement => {\n let inputAndHelp: ReactElement;\n if (direction === \"x\")\n inputAndHelp = (\n <Align.Space direction=\"y\" size=\"small\">\n {children}\n {(padHelpText || helpText != null) && <HelpText>{helpText}</HelpText>}\n </Align.Space>\n );\n else\n inputAndHelp = (\n <Align.Space direction=\"y\" size={1 / 3}>\n {children}\n {(padHelpText || helpText != null) && <HelpText>{helpText}</HelpText>}\n </Align.Space>\n );\n\n return (\n <Align.Space\n className={CSS(CSS.B(\"input-item\"), className)}\n direction={direction}\n size={size}\n align={maybeDefaultAlignment(align, direction)}\n {...props}\n >\n {showLabel && <Label>{label}</Label>}\n {inputAndHelp}\n </Align.Space>\n );\n};\n\nexport type ItemControlledProps<\n I extends Value = string | number,\n O extends Value = I,\n> = Omit<ItemProps, \"children\"> &\n Omit<UseControllerProps<any, string>, \"controller\"> & {\n children?: RenderProp<\n Control<I, O> & { onBlur?: () => void; ref?: React.Ref<any> }\n >;\n alsoValidate?: string[];\n padHelpText?: boolean;\n };\n\nconst defaultChild = componentRenderProp(Text);\n\nexport const HFItem = <I extends Value = string | number, O extends Value = I>({\n name,\n rules,\n shouldUnregister,\n defaultValue,\n label,\n children = defaultChild as unknown as RenderProp<Control<I, O>>,\n alsoValidate,\n padHelpText = true,\n ref: _,\n ...props\n}: ItemControlledProps<I, O>): ReactElement => {\n const { field, fieldState } = useController({\n rules,\n name,\n });\n const { trigger } = useFormContext();\n if (label == null) label = camelToTitle(name);\n\n const handleBlur = useCallback(() => {\n field.onBlur();\n if (alsoValidate != null) void trigger(alsoValidate);\n }, [field.onBlur, trigger, alsoValidate, name]);\n\n return (\n <Item\n label={label}\n padHelpText={padHelpText}\n helpText={fieldState.error?.message}\n {...props}\n >\n {children({\n onChange: field.onChange,\n value: field.value,\n onBlur: handleBlur,\n })}\n </Item>\n );\n};\n","import { useState } from \"react\";\n\nimport { TimeSpan, TimeStamp } from \"@synnaxlabs/x\";\n\nimport { Text } from \"@/input/Text\";\n\nimport { type BaseProps } from \"./types\";\n\nexport interface DateTimeProps extends BaseProps<number> {}\n\nexport const DateTime = ({ value, onChange, onBlur, ...props }: DateTimeProps) => {\n const ts = new TimeStamp(value, \"UTC\");\n const [internalValue, setInternalVlaue] = useState(\n ts.fString(\"ISO\", \"local\").slice(0, -1),\n );\n const [valueIsValid, setValueIsValid] = useState(true);\n\n const handleChange = (next: string | number): void => {\n let nextStr = next.toString();\n setInternalVlaue(nextStr);\n\n let ts = new TimeStamp(next, \"UTC\");\n if (nextStr.length < 23) nextStr += \".000\";\n\n ts = ts.add(\n (TimeStamp.now().date().getTimezoneOffset() - ts.date().getTimezoneOffset()) *\n TimeSpan.MINUTE.valueOf(),\n );\n let ok = false;\n try {\n const str = ts.fString(\"ISO\", \"local\");\n ok = str.slice(0, -1) === nextStr;\n } catch (_) {\n console.error(\"e\");\n }\n if (!ok) {\n setValueIsValid(false);\n return;\n }\n onChange(ts.valueOf());\n setValueIsValid(true);\n };\n\n const handleBlur: React.FocusEventHandler<HTMLInputElement> = (e) => {\n setValueIsValid(true);\n setInternalVlaue(new TimeStamp(value, \"UTC\").fString(\"ISO\", \"local\").slice(0, -1));\n onBlur?.(e);\n };\n\n return (\n <Text\n type=\"datetime-local\"\n onBlur={handleBlur}\n required={false}\n value={\n valueIsValid\n ? new TimeStamp(value, \"UTC\").fString(\"ISO\", \"local\").slice(0, -1)\n : internalValue\n }\n onChange={handleChange}\n {...props}\n />\n );\n};\n"],"names":["HelpText","className","variant","props","jsx","Text.Text","CSS","Label","camelToTitle","str","maybeDefaultAlignment","align","dir","direction","Item","label","showLabel","helpText","children","size","padHelpText","inputAndHelp","Align.Space","jsxs","defaultChild","componentRenderProp","Text","HFItem","name","rules","shouldUnregister","defaultValue","alsoValidate","_","field","fieldState","useController","trigger","useFormContext","handleBlur","useCallback","_a","DateTime","value","onChange","onBlur","ts","TimeStamp","internalValue","setInternalVlaue","useState","valueIsValid","setValueIsValid","handleChange","next","nextStr","TimeSpan","ok","e"],"mappings":"4PAiCaA,EAAW,CAAC,CACvB,UAAAC,EACA,QAAAC,EAAU,QACV,GAAGC,CACL,IACEC,EAAA,kBAAA,IAACC,EAAK,KAAL,CACC,UAAWC,EAAA,IACTA,EAAA,IAAI,EAAE,iBAAiB,EACvBA,MAAI,GAAG,kBAAmBJ,CAAO,EACjCD,CACF,EACA,MAAM,QACL,GAAGE,CAAA,CACN,ECnBWI,EAAQ,CAAC,CAAE,UAAAN,EAAW,GAAGE,KAC7BC,EAAA,kBAAA,IAAC,QAAM,CAAA,UAAWE,EAAI,IAAAA,EAAA,IAAI,EAAE,aAAa,EAAGL,CAAS,EAAI,GAAGE,CAAO,CAAA,ECnB/DK,EAAgBC,GAC3BA,EAAI,QAAQ,WAAY,KAAK,EAAE,QAAQ,KAAOA,GAAQA,EAAI,aAAa,EC0BnEC,EAAwB,CAC5BC,EACAC,EAAuB,MAEnBD,IACGE,EAAAA,YAAU,UAAUD,CAAG,IAAM,IAAM,UAAY,UAG3CE,EAAO,CAAC,CACnB,MAAAC,EACA,UAAAC,EAAY,GACZ,SAAAC,EACA,UAAAJ,E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KAAK,EAAE,QAAQ,MAAO,OAAO,EAAE,MAAM,EAAG,EAAE,CAAC,EACjFE,GAAA,MAAAA,EAASa,EAAC,EAIV,OAAAtD,EAAA,kBAAA,IAACsB,EAAA,OAAA,CACC,KAAK,iBACL,OAAQa,EACR,SAAU,GACV,MACEY,EACI,IAAIJ,EAAA,UAAUJ,EAAO,KAAK,EAAE,QAAQ,MAAO,OAAO,EAAE,MAAM,EAAG,EAAE,EAC/DK,EAEN,SAAUK,EACT,GAAGlD,CAAA,CAAA,CAGV"}
|
|
1
|
+
{"version":3,"file":"external-RsG62zSr.cjs","sources":["../src/input/HelpText.tsx","../src/input/Label.tsx","../src/util/case.ts","../src/input/Item.tsx","../src/input/DateTime.tsx"],"sourcesContent":["// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ReactElement } from \"react\";\n\nimport { CSS } from \"@/css\";\nimport { type Status } from \"@/status\";\nimport { Text } from \"@/text\";\n\nimport \"@/input/HelpText.css\";\n\n/** Props for the {@link HelpText} component. */\nexport interface HelpTextProps extends Omit<Text.TextProps<\"small\">, \"level\" | \"ref\"> {\n variant?: Status.Variant;\n}\n\n/**\n * Help text for an input component. We generally recommend using Input.Item with a\n * 'helpText' prop instead of this component. This component is useful for low-level\n * control over the help text element.\n *\n * @param props - Props for the help text component. Unlisted props are passed to the\n * underlying text element.\n * @param props.variant - The variant of the help text.\n * \"success\" | \"error\" | \"warning\" | \"info\" | \"loading\" | \"disabled\n * @default \"info\"\n */\nexport const HelpText = ({\n className,\n variant = \"error\",\n ...props\n}: HelpTextProps): ReactElement => (\n <Text.Text<\"small\">\n className={CSS(\n CSS.B(\"input-help-text\"),\n CSS.BM(\"input-help-text\", variant),\n className,\n )}\n level=\"small\"\n {...props}\n />\n);\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type DetailedHTMLProps, type HTMLAttributes, type ReactElement } from \"react\";\n\nimport { CSS } from \"@/css\";\n\nimport \"@/input/Label.css\";\n\n/** Props for the {@link Label} component. */\nexport interface LabelProps\n extends DetailedHTMLProps<HTMLAttributes<HTMLLabelElement>, HTMLLabelElement> {}\n\n/**\n * A thin, styled wrapper for an input label. We generally recommend using Input.Item\n * with a 'label' prop instead of this component. This component is useful for\n * low-level control over the label element.\n *\n * @param props - Props for the label component. Unlisted props are passed to the\n * underlying label element.\n */\nexport const Label = ({ className, ...props }: LabelProps): ReactElement => {\n return <label className={CSS(CSS.B(\"input-label\"), className)} {...props} />;\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nexport const camelToTitle = (str: string): string =>\n str.replace(/([A-Z])/g, \" $1\").replace(/^./, (str) => str.toUpperCase());\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { useCallback, type ReactElement } from \"react\";\n\nimport { direction } from \"@synnaxlabs/x\";\nimport {\n type UseControllerProps,\n useController,\n useFormContext,\n} from \"react-hook-form\";\n\nimport { Align } from \"@/align\";\nimport { CSS } from \"@/css\";\nimport { HelpText } from \"@/input/HelpText\";\nimport { Label } from \"@/input/Label\";\nimport { Text } from \"@/input/Text\";\nimport { type Control, type Value } from \"@/input/types\";\nimport { camelToTitle } from \"@/util/case\";\nimport { componentRenderProp, type RenderProp } from \"@/util/renderProp\";\n\nimport \"@/input/Item.css\";\n\nexport interface ItemProps extends Align.SpaceProps {\n label?: string;\n showLabel?: boolean;\n helpText?: string;\n padHelpText?: boolean;\n}\n\nconst maybeDefaultAlignment = (\n align?: Align.Alignment,\n dir: direction.Crude = \"x\",\n): Align.Alignment => {\n if (align != null) return align;\n return direction.construct(dir) === \"y\" ? \"stretch\" : \"center\";\n};\n\nexport const Item = ({\n label,\n showLabel = true,\n helpText,\n direction = \"y\",\n className,\n children,\n align,\n size = \"small\",\n padHelpText = false,\n ...props\n}: ItemProps): ReactElement => {\n let inputAndHelp: ReactElement;\n if (direction === \"x\")\n inputAndHelp = (\n <Align.Space direction=\"y\" size=\"small\">\n {children}\n {(padHelpText || helpText != null) && <HelpText>{helpText}</HelpText>}\n </Align.Space>\n );\n else\n inputAndHelp = (\n <Align.Space direction=\"y\" size={1 / 3}>\n {children}\n {(padHelpText || helpText != null) && <HelpText>{helpText}</HelpText>}\n </Align.Space>\n );\n\n return (\n <Align.Space\n className={CSS(CSS.B(\"input-item\"), className)}\n direction={direction}\n size={size}\n align={maybeDefaultAlignment(align, direction)}\n {...props}\n >\n {showLabel && <Label>{label}</Label>}\n {inputAndHelp}\n </Align.Space>\n );\n};\n\nexport type ItemControlledProps<\n I extends Value = string | number,\n O extends Value = I,\n> = Omit<ItemProps, \"children\"> &\n Omit<UseControllerProps<any, string>, \"controller\"> & {\n children?: RenderProp<\n Control<I, O> & { onBlur?: () => void; ref?: React.Ref<any> }\n >;\n alsoValidate?: string[];\n padHelpText?: boolean;\n };\n\nconst defaultChild = componentRenderProp(Text);\n\nexport const HFItem = <I extends Value = string | number, O extends Value = I>({\n name,\n rules,\n shouldUnregister,\n defaultValue,\n label,\n children = defaultChild as unknown as RenderProp<Control<I, O>>,\n alsoValidate,\n padHelpText = true,\n ref: _,\n ...props\n}: ItemControlledProps<I, O>): ReactElement => {\n const { field, fieldState } = useController({\n rules,\n name,\n });\n const { trigger } = useFormContext();\n if (label == null) label = camelToTitle(name);\n\n const handleBlur = useCallback(() => {\n field.onBlur();\n if (alsoValidate != null) void trigger(alsoValidate);\n }, [field.onBlur, trigger, alsoValidate, name]);\n\n return (\n <Item\n label={label}\n padHelpText={padHelpText}\n helpText={fieldState.error?.message}\n {...props}\n >\n {children({\n onChange: field.onChange,\n value: field.value,\n onBlur: handleBlur,\n })}\n </Item>\n );\n};\n","import { useState } from \"react\";\n\nimport { TimeSpan, TimeStamp } from \"@synnaxlabs/x\";\n\nimport { Text } from \"@/input/Text\";\n\nimport { type BaseProps } from \"./types\";\n\nexport interface DateTimeProps extends BaseProps<number> {}\n\nexport const DateTime = ({ value, onChange, onBlur, ...props }: DateTimeProps) => {\n const ts = new TimeStamp(value, \"UTC\");\n const [internalValue, setInternalVlaue] = useState(\n ts.fString(\"ISO\", \"local\").slice(0, -1),\n );\n const [valueIsValid, setValueIsValid] = useState(true);\n\n const handleChange = (next: string | number): void => {\n let nextStr = next.toString();\n setInternalVlaue(nextStr);\n\n let ts = new TimeStamp(next, \"UTC\");\n if (nextStr.length < 23) nextStr += \".000\";\n\n ts = ts.add(\n (TimeStamp.now().date().getTimezoneOffset() - ts.date().getTimezoneOffset()) *\n TimeSpan.MINUTE.valueOf(),\n );\n let ok = false;\n try {\n const str = ts.fString(\"ISO\", \"local\");\n ok = str.slice(0, -1) === nextStr;\n } catch (_) {\n console.error(\"e\");\n }\n if (!ok) {\n setValueIsValid(false);\n return;\n }\n onChange(ts.valueOf());\n setValueIsValid(true);\n };\n\n const handleBlur: React.FocusEventHandler<HTMLInputElement> = (e) => {\n setValueIsValid(true);\n setInternalVlaue(new TimeStamp(value, \"UTC\").fString(\"ISO\", \"local\").slice(0, -1));\n onBlur?.(e);\n };\n\n return (\n <Text\n type=\"datetime-local\"\n onBlur={handleBlur}\n required={false}\n value={\n valueIsValid\n ? new TimeStamp(value, \"UTC\").fString(\"ISO\", \"local\").slice(0, -1)\n : internalValue\n }\n onChange={handleChange}\n {...props}\n />\n );\n};\n"],"names":["HelpText","className","variant","props","jsx","Text.Text","CSS","Label","camelToTitle","str","maybeDefaultAlignment","align","dir","direction","Item","label","showLabel","helpText","children","size","padHelpText","inputAndHelp","Align.Space","jsxs","defaultChild","componentRenderProp","Text","HFItem","name","rules","shouldUnregister","defaultValue","alsoValidate","_","field","fieldState","useController","trigger","useFormContext","handleBlur","useCallback","_a","DateTime","value","onChange","onBlur","ts","TimeStamp","internalValue","setInternalVlaue","useState","valueIsValid","setValueIsValid","handleChange","next","nextStr","TimeSpan","ok","e"],"mappings":"4PAiCaA,EAAW,CAAC,CACvB,UAAAC,EACA,QAAAC,EAAU,QACV,GAAGC,CACL,IACEC,EAAA,kBAAA,IAACC,EAAK,KAAL,CACC,UAAWC,EAAA,IACTA,EAAA,IAAI,EAAE,iBAAiB,EACvBA,MAAI,GAAG,kBAAmBJ,CAAO,EACjCD,CACF,EACA,MAAM,QACL,GAAGE,CAAA,CACN,ECnBWI,EAAQ,CAAC,CAAE,UAAAN,EAAW,GAAGE,KAC7BC,EAAA,kBAAA,IAAC,QAAM,CAAA,UAAWE,EAAI,IAAAA,EAAA,IAAI,EAAE,aAAa,EAAGL,CAAS,EAAI,GAAGE,CAAO,CAAA,ECnB/DK,EAAgBC,GAC3BA,EAAI,QAAQ,WAAY,KAAK,EAAE,QAAQ,KAAOA,GAAQA,EAAI,aAAa,EC0BnEC,EAAwB,CAC5BC,EACAC,EAAuB,MAEnBD,IACGE,EAAAA,YAAU,UAAUD,CAAG,IAAM,IAAM,UAAY,UAG3CE,EAAO,CAAC,CACnB,MAAAC,EACA,UAAAC,EAAY,GACZ,SAAAC,EACA,UAAAJ,EAAY,IACZ,UAAAZ,EACA,SAAAiB,EACA,MAAAP,EACA,KAAAQ,EAAO,QACP,YAAAC,EAAc,GACd,GAAGjB,CACL,IAA+B,CACzB,IAAAkB,EACJ,OAAIR,IAAc,IAChBQ,2BACGC,EAAAA,MAAA,CAAY,UAAU,IAAI,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ACI,IAAIJ,EAAA,UAAUJ,EAAO,KAAK,EAAE,QAAQ,MAAO,OAAO,EAAE,MAAM,EAAG,EAAE,EAC/DK,EAEN,SAAUK,EACT,GAAGlD,CAAA,CAAA,CAGV"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { O as M, e as E, Q as p, l as d, g as b, R as y, U as C, V as R, X as j, Y as K, Z as h, _ as T, $ as _, a0 as L, a1 as k, a2 as O, a3 as v, a4 as A, a5 as Z, a6 as H, a7 as U, a8 as Y, a9 as w, aa as P, ab as $, ac as I, H as N } from "./Toggle-
|
|
1
|
+
import { O as M, e as E, Q as p, l as d, g as b, R as y, U as C, V as R, X as j, Y as K, Z as h, _ as T, $ as _, a0 as L, a1 as k, a2 as O, a3 as v, a4 as A, a5 as Z, a6 as H, a7 as U, a8 as Y, a9 as w, aa as P, ab as $, ac as I, H as N } from "./Toggle-zmqGwWeq.js";
|
|
2
2
|
import { j as n } from "./jsx-runtime-NmMXPjeo.js";
|
|
3
3
|
import { useState as X, useEffect as z, useRef as m, useCallback as x } from "react";
|
|
4
4
|
import { x as l, g as f } from "./css-rizsElAK.js";
|
|
5
5
|
import { S as F } from "./Center-iTyfvHz5.js";
|
|
6
6
|
import "./aggregator-Q_onjsH5.js";
|
|
7
|
-
import { K as Q } from "./Keyboard-
|
|
7
|
+
import { K as Q } from "./Keyboard-kcohZ0JP.js";
|
|
8
8
|
const V = (e) => {
|
|
9
9
|
const { listen: r } = M(), [u, o] = X([]);
|
|
10
10
|
return z(
|
|
@@ -92,4 +92,4 @@ export {
|
|
|
92
92
|
re as e,
|
|
93
93
|
q as u
|
|
94
94
|
};
|
|
95
|
-
//# sourceMappingURL=external-
|
|
95
|
+
//# sourceMappingURL=external-Sip1coAq.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external-
|
|
1
|
+
{"version":3,"file":"external-Sip1coAq.js","sources":["../src/triggers/Status.tsx","../src/triggers/useDrag.ts","../src/triggers/Text.tsx"],"sourcesContent":["// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ReactElement, useEffect, useState } from \"react\";\n\nimport { Text } from \"@/text\";\nimport { useContext } from \"@/triggers/Provider\";\nimport { type Trigger } from \"@/triggers/triggers\";\n\nexport interface StatusProps extends Text.TextProps {}\n\nexport const Status = (props: StatusProps): ReactElement => {\n const { listen } = useContext();\n const [trigger, setTrigger] = useState<Trigger>([]);\n\n useEffect(\n () => listen(({ next: [trigger] }) => setTrigger(trigger ?? [])),\n [listen, setTrigger],\n );\n\n return <Text.Text {...props}>{trigger.join(\" \")}</Text.Text>;\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type RefObject, useCallback, useRef } from \"react\";\n\nimport { box, xy } from \"@synnaxlabs/x\";\n\nimport { use, type UseEvent } from \"@/triggers/hooks\";\nimport { type Stage, type Trigger } from \"@/triggers/triggers\";\n\nexport interface DragEvent {\n stage: Stage;\n box: box.Box;\n cursor: xy.XY;\n triggers: Trigger[];\n}\n\nexport type DragCallback = (props: DragEvent) => void;\n\nexport interface UseDragProps {\n bound: RefObject<HTMLElement>;\n triggers?: Trigger[];\n onDrag: DragCallback;\n loose?: boolean;\n}\n\nexport const useDrag = ({\n onDrag,\n triggers = [[\"MouseLeft\"], [\"MouseRight\"]],\n bound,\n loose = false,\n}: UseDragProps): void => {\n const triggerRef = useRef<UseEvent | null>(null);\n const startLoc = useRef<xy.XY>(xy.ZERO);\n const onMove = useCallback(\n (e: xy.Client & { buttons: number }) => {\n const cursor = xy.construct(e);\n if (triggerRef.current === null) return;\n const { triggers } = triggerRef.current;\n onDrag({\n box: box.construct(startLoc.current, cursor),\n cursor,\n triggers,\n stage: \"during\",\n });\n },\n [onDrag],\n );\n const handleTrigger = useCallback(\n (event: UseEvent): void => {\n const { stage, cursor } = event;\n if (stage === \"start\") {\n onDrag({ box: box.construct(cursor), ...event });\n window.addEventListener(\"mousemove\", onMove);\n triggerRef.current = event;\n startLoc.current = cursor;\n } else if (stage === \"end\" && triggerRef.current != null) {\n onDrag({ box: box.construct(startLoc.current, cursor), ...event });\n window.removeEventListener(\"mousemove\", onMove);\n triggerRef.current = null;\n startLoc.current = xy.ZERO;\n }\n },\n [onDrag],\n );\n use({ triggers, callback: handleTrigger, region: bound, loose });\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ReactElement } from \"react\";\n\nimport { Icon } from \"@synnaxlabs/media\";\n\nimport { Align } from \"@/align\";\nimport { Text as Core } from \"@/text\";\nimport { type Key, type Trigger } from \"@/triggers/triggers\";\n\nexport type TextProps<L extends Core.Level> = Core.KeyboardProps<L> & {\n trigger: Trigger;\n};\n\nexport const Text = <L extends Core.Level>({\n className,\n style,\n trigger,\n ...props\n}: TextProps<L>): ReactElement => {\n const CUSTOM_TEXT: Partial<Record<Key, ReactElement | string>> = {\n Control: <Core.Symbols.Meta />,\n Alt: <Core.Symbols.Alt />,\n Shift: <Icon.Keyboard.Shift />,\n MouseLeft: \"Left Click\",\n MouseRight: \"Right Click\",\n MouseMiddle: \"Middle Click\",\n };\n return (\n <Align.Space className={className} style={style} direction=\"x\">\n {trigger.map((t) => (\n // @ts-expect-error\n <Core.Keyboard<L> key={t} {...props}>\n {CUSTOM_TEXT[t] ?? t}\n </Core.Keyboard>\n ))}\n </Align.Space>\n );\n};\n"],"names":["Status","props","listen","useContext","trigger","setTrigger","useState","useEffect","jsx","Text.Text","useDrag","onDrag","triggers","bound","loose","triggerRef","useRef","startLoc","xy","onMove","useCallback","e","cursor","box","handleTrigger","event","stage","use","Text","className","style","CUSTOM_TEXT","Core.Symbols","Icon","Align.Space","Core.Keyboard"],"mappings":";;;;;;;AAiBa,MAAAA,IAAS,CAACC,MAAqC;AACpD,QAAA,EAAE,QAAAC,MAAWC,KACb,CAACC,GAASC,CAAU,IAAIC,EAAkB,CAAE,CAAA;AAElD,SAAAC;AAAA,IACE,MAAML,EAAO,CAAC,EAAE,MAAM,CAACE,CAAO,EAAA,MAAQC,EAAWD,KAAW,CAAA,CAAE,CAAC;AAAA,IAC/D,CAACF,GAAQG,CAAU;AAAA,EAAA,GAGdG,gBAAAA,EAAA,IAACC,GAAA,EAAW,GAAGR,GAAQ,UAAAG,EAAQ,KAAK,GAAG,EAAE,CAAA;AAClD,GCKaM,IAAU,CAAC;AAAA,EACtB,QAAAC;AAAA,EACA,UAAAC,IAAW,CAAC,CAAC,WAAW,GAAG,CAAC,YAAY,CAAC;AAAA,EACzC,OAAAC;AAAA,EACA,OAAAC,IAAQ;AACV,MAA0B;AAClB,QAAAC,IAAaC,EAAwB,IAAI,GACzCC,IAAWD,EAAcE,EAAG,IAAI,GAChCC,IAASC;AAAA,IACb,CAACC,MAAuC;AAChC,YAAAC,IAASJ,EAAG,UAAUG,CAAC;AAC7B,UAAIN,EAAW,YAAY;AAAM;AACjC,YAAM,EAAE,UAAAH,MAAaG,EAAW;AACzB,MAAAJ,EAAA;AAAA,QACL,KAAKY,EAAI,UAAUN,EAAS,SAASK,CAAM;AAAA,QAC3C,QAAAA;AAAA,QACA,UAAAV;AAAAA,QACA,OAAO;AAAA,MAAA,CACR;AAAA,IACH;AAAA,IACA,CAACD,CAAM;AAAA,EAAA,GAEHa,IAAgBJ;AAAA,IACpB,CAACK,MAA0B;AACnB,YAAA,EAAE,OAAAC,GAAO,QAAAJ,EAAW,IAAAG;AAC1B,MAAIC,MA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PGacs.cjs"),l=require("react"),r=require("./css-JWFtNl10.cjs"),S=require("./Center-Q-fgAb96.cjs"),a=require("./Toggle-
|
|
2
|
-
//# sourceMappingURL=external-
|
|
1
|
+
"use strict";const i=require("./jsx-runtime-evvPGacs.cjs"),l=require("react"),r=require("./css-JWFtNl10.cjs"),S=require("./Center-Q-fgAb96.cjs"),a=require("./Toggle-qW_TcIDh.cjs"),j=require("./aggregator-6_J8kSSO.cjs"),m=l.createContext({divided:!1,level:"h1"}),x=()=>l.useContext(m),p=({children:s,className:o,level:e="h1",divided:n=!1,...t})=>i.jsxRuntimeExports.jsx(m.Provider,{value:{level:e,divided:n},children:i.jsxRuntimeExports.jsx(S.Space,{el:"header",direction:"x",justify:"spaceBetween",className:r.CSS(r.CSS.B("header"),r.CSS.bordered("bottom"),n&&r.CSS.BM("header","divided"),o),...t,children:s})}),C=({children:s=[]})=>{const{level:o,divided:e}=x();return i.jsxRuntimeExports.jsx(S.Space,{direction:"x",size:"small",align:"center",className:r.CSS.BE("header","actions"),children:r.toArray(s).map((n,t)=>i.jsxRuntimeExports.jsx(h,{index:t,level:o,divided:e,children:n},t))})},h=({index:s,level:o,children:e,divided:n})=>{let t=e;if(!l.isValidElement(e)){const c=e;t=i.jsxRuntimeExports.jsx(a.Icon,{onClick:u=>{var d;u.stopPropagation(),u.preventDefault(),(d=c.onClick)==null||d.call(c,u)},size:j.LevelComponentSizes[o],...c},s)}return i.jsxRuntimeExports.jsxs(l.Fragment,{children:[n&&i.jsxRuntimeExports.jsx(a.Divider,{}),t]},s)},v=({children:s="",className:o,onClick:e,...n})=>{const{level:t}=x();return i.jsxRuntimeExports.jsx(a.Button,{variant:"text",size:j.LevelComponentSizes[t],onClick:e,className:r.CSS(r.CSS.B("header-button-title"),o),sharp:!0,...n,children:s})},E=({className:s,level:o,...e})=>{const{level:n,divided:t}=x();return i.jsxRuntimeExports.jsx(a.WithIcon,{className:r.CSS(r.CSS.BE("header","text"),s),level:o??n,divided:t,size:1.5,...e})},R=Object.freeze(Object.defineProperty({__proto__:null,Actions:C,ButtonTitle:v,Header:p,Title:E,useContext:x},Symbol.toStringTag,{value:"Module"}));exports.Actions=C;exports.ButtonTitle=v;exports.Header=p;exports.external=R;
|
|
2
|
+
//# sourceMappingURL=external-UezDJS5P.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external-qFz2sVjt.cjs","sources":["../src/header/Header.tsx","../src/header/Actions.tsx","../src/header/ButtonTitle.tsx","../src/header/Title.tsx"],"sourcesContent":["// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport {\n createContext,\n type ReactElement,\n type ReactNode,\n useContext as reactUseContext,\n} from \"react\";\n\nimport { Align } from \"@/align\";\nimport { CSS } from \"@/css\";\nimport { type Text } from \"@/text\";\n\nimport \"@/header/Header.css\";\n\nexport interface HeaderProps extends Omit<Align.SpaceProps, \"children\" | \"el\"> {\n level?: Text.Level;\n divided?: boolean;\n children: ReactNode | [ReactNode, ReactNode];\n}\n\nexport interface ContextValue {\n divided: boolean;\n level: Text.Level;\n}\n\nconst Context = createContext<ContextValue>({\n divided: false,\n level: \"h1\",\n});\n\nexport const useContext = (): ContextValue => reactUseContext(Context);\n\n/**\n * The container for a module header.\n *\n * @param props - The component props. All unused props will be passed down to the\n * {@link Space} containing the header.\n * @param props.level - The font level for the header. See the {@link Typography.Text}\n * component for all possible levels. Default is \"h1.\"\n * @param props.icon - An optional icon to add add before the start of the header text.\n * @param props.actions - A list of actions to be rendered on the right side ofthe header.\n * If the action is a JSX element, it will be rendered directly, and if its of type\n * ButtonIconProps, a ButtonIconOnly will be rendered using the given props.\n * @param props.divided - If true, creates a divider between the start icon, header text,\n * and each action. Default is false.\n */\nexport const Header = ({\n children,\n className,\n level = \"h1\",\n divided = false,\n ...props\n}: HeaderProps): ReactElement => (\n <Context.Provider value={{ level, divided }}>\n <Align.Space\n el=\"header\"\n direction=\"x\"\n justify=\"spaceBetween\"\n className={CSS(\n CSS.B(\"header\"),\n CSS.bordered(\"bottom\"),\n divided && CSS.BM(\"header\", \"divided\"),\n className,\n )}\n {...props}\n >\n {children}\n </Align.Space>\n </Context.Provider>\n);\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { Fragment, isValidElement, type ReactElement } from \"react\";\n\nimport { toArray } from \"@synnaxlabs/x\";\n\nimport { Align } from \"@/align\";\nimport { Button } from \"@/button\";\nimport { CSS } from \"@/css\";\nimport { Divider } from \"@/divider\";\nimport { useContext } from \"@/header/Header\";\nimport { Text } from \"@/text\";\n\nexport type ActionSpec = Button.IconProps | ReactElement;\n\nexport interface ActionsProps {\n children?: ActionSpec | ActionSpec[];\n}\n\n/**\n * Custom actions to render on the right side of the header.\n *\n * @param children - The actions to render. If the action is of type\n * {@link ButtonIconProps}, a correectly sized {@link ButtonIconOnly} is rendered\n * using the given props. If the action is a JSX element, it is renderered directly.\n * It's a good idea to prefer the latter in almost all cases for simplicity.\n */\nexport const Actions = ({ children = [] }: ActionsProps): ReactElement => {\n const { level, divided } = useContext();\n return (\n <Align.Space\n direction=\"x\"\n size=\"small\"\n align=\"center\"\n className={CSS.BE(\"header\", \"actions\")}\n >\n {toArray(children).map((action, i) => (\n <Action key={i} index={i} level={level} divided={divided}>\n {action}\n </Action>\n ))}\n </Align.Space>\n );\n};\n\ninterface ActionProps {\n index: number;\n level: Text.Level;\n children: ReactElement | Button.IconProps;\n divided: boolean;\n}\n\nconst Action = ({ index, level, children, divided }: ActionProps): ReactElement => {\n let content: ReactElement = children as ReactElement;\n if (!isValidElement(children)) {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n const props = children as Button.IconProps;\n content = (\n <Button.Icon\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n props.onClick?.(e);\n }}\n key={index}\n size={Text.LevelComponentSizes[level]}\n {...props}\n />\n );\n }\n return (\n <Fragment key={index}>\n {divided && <Divider.Divider />}\n {content}\n </Fragment>\n );\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ReactElement } from \"react\";\n\nimport { Button } from \"@/button\";\nimport { CSS } from \"@/css\";\nimport { useContext } from \"@/header/Header\";\nimport { Text } from \"@/text\";\n\nexport interface ButtonTitleProps\n extends Omit<Button.ButtonProps, \"variant\" | \"size\"> {}\n\n/**\n * Header.Title.Use renders a clickable header title.\n *\n * @param props - The comonent props. The props for this component are identical\n * to {@link Button}, except the variant is always 'outlined' and that the component size\n * is automatically inferred from the 'level' prop passsed to the parent {@link Header}\n * component.\n */\nexport const ButtonTitle = ({\n children = \"\",\n className,\n onClick,\n ...props\n}: ButtonTitleProps): ReactElement => {\n const { level } = useContext();\n return (\n <Button.Button\n variant=\"text\"\n size={Text.LevelComponentSizes[level]}\n onClick={onClick}\n className={CSS(CSS.B(\"header-button-title\"), className)}\n sharp\n {...props}\n >\n {children}\n </Button.Button>\n );\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ReactElement } from \"react\";\n\nimport { CSS } from \"@/css\";\nimport { useContext } from \"@/header/Header\";\nimport { Text } from \"@/text\";\n\nexport interface TitleProps extends Omit<Text.WithIconProps, \"divided\" | \"level\"> {\n level?: Text.Level;\n}\n\n/**\n * Renders the title for the header component.\n *\n * @param props - The component props. The props for this component are identical\n * to the {@link Typography.TextWithIcon} component, except that the 'level', and\n * 'divider' props are inherited from the parent {@link Header} component.\n */\nexport const Title = ({\n className,\n level: propsLevel,\n ...props\n}: TitleProps): ReactElement => {\n const { level, divided } = useContext();\n return (\n <Text.WithIcon\n className={CSS(CSS.BE(\"header\", \"text\"), className)}\n level={propsLevel ?? level}\n divided={divided}\n size={1.5}\n {...props}\n />\n );\n};\n"],"names":["Context","createContext","useContext","reactUseContext","Header","children","className","level","divided","props","jsx","Align.Space","CSS","Actions","toArray","action","i","Action","index","content","isValidElement","Button.Icon","e","_a","Text.LevelComponentSizes","Fragment","Divider.Divider","ButtonTitle","onClick","Button.Button","Title","propsLevel","Text.WithIcon"],"mappings":"2NAiCMA,EAAUC,EAAAA,cAA4B,CAC1C,QAAS,GACT,MAAO,IACT,CAAC,EAEYC,EAAa,IAAoBC,aAAgBH,CAAO,EAgBxDI,EAAS,CAAC,CACrB,SAAAC,EACA,UAAAC,EACA,MAAAC,EAAQ,KACR,QAAAC,EAAU,GACV,GAAGC,CACL,IACEC,EAAA,kBAAA,IAACV,EAAQ,SAAR,CAAiB,MAAO,CAAE,MAAAO,EAAO,QAAAC,GAChC,SAAAE,EAAA,kBAAA,IAACC,EAAM,MAAN,CACC,GAAG,SACH,UAAU,IACV,QAAQ,eACR,UAAWC,EAAA,IACTA,EAAA,IAAI,EAAE,QAAQ,EACdA,EAAA,IAAI,SAAS,QAAQ,EACrBJ,GAAWI,EAAA,IAAI,GAAG,SAAU,SAAS,EACrCN,CACF,EACC,GAAGG,EAEH,SAAAJ,CAAA,CACH,CACF,CAAA,EC1CWQ,EAAU,CAAC,CAAE,SAAAR,EAAW,CAAA,KAAqC,CACxE,KAAM,CAAE,MAAAE,EAAO,QAAAC,CAAQ,EAAIN,EAAW,EAEpC,OAAAQ,EAAA,kBAAA,IAACC,EAAM,MAAN,CACC,UAAU,IACV,KAAK,Q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AC,CAAQ,EAAIN,EAAW,EAEpC,OAAAQ,EAAA,kBAAA,IAACsB,EAAK,SAAL,CACC,UAAWpB,EAAI,IAAAA,MAAI,GAAG,SAAU,MAAM,EAAGN,CAAS,EAClD,MAAOyB,GAAcxB,EACrB,QAAAC,EACA,KAAM,IACL,GAAGC,CAAA,CAAA,CAGV"}
|
|
1
|
+
{"version":3,"file":"external-UezDJS5P.cjs","sources":["../src/header/Header.tsx","../src/header/Actions.tsx","../src/header/ButtonTitle.tsx","../src/header/Title.tsx"],"sourcesContent":["// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport {\n createContext,\n type ReactElement,\n type ReactNode,\n useContext as reactUseContext,\n} from \"react\";\n\nimport { Align } from \"@/align\";\nimport { CSS } from \"@/css\";\nimport { type Text } from \"@/text\";\n\nimport \"@/header/Header.css\";\n\nexport interface HeaderProps extends Omit<Align.SpaceProps, \"children\" | \"el\"> {\n level?: Text.Level;\n divided?: boolean;\n children: ReactNode | [ReactNode, ReactNode];\n}\n\nexport interface ContextValue {\n divided: boolean;\n level: Text.Level;\n}\n\nconst Context = createContext<ContextValue>({\n divided: false,\n level: \"h1\",\n});\n\nexport const useContext = (): ContextValue => reactUseContext(Context);\n\n/**\n * The container for a module header.\n *\n * @param props - The component props. All unused props will be passed down to the\n * {@link Space} containing the header.\n * @param props.level - The font level for the header. See the {@link Typography.Text}\n * component for all possible levels. Default is \"h1.\"\n * @param props.icon - An optional icon to add add before the start of the header text.\n * @param props.actions - A list of actions to be rendered on the right side ofthe header.\n * If the action is a JSX element, it will be rendered directly, and if its of type\n * ButtonIconProps, a ButtonIconOnly will be rendered using the given props.\n * @param props.divided - If true, creates a divider between the start icon, header text,\n * and each action. Default is false.\n */\nexport const Header = ({\n children,\n className,\n level = \"h1\",\n divided = false,\n ...props\n}: HeaderProps): ReactElement => (\n <Context.Provider value={{ level, divided }}>\n <Align.Space\n el=\"header\"\n direction=\"x\"\n justify=\"spaceBetween\"\n className={CSS(\n CSS.B(\"header\"),\n CSS.bordered(\"bottom\"),\n divided && CSS.BM(\"header\", \"divided\"),\n className,\n )}\n {...props}\n >\n {children}\n </Align.Space>\n </Context.Provider>\n);\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { Fragment, isValidElement, type ReactElement } from \"react\";\n\nimport { toArray } from \"@synnaxlabs/x\";\n\nimport { Align } from \"@/align\";\nimport { Button } from \"@/button\";\nimport { CSS } from \"@/css\";\nimport { Divider } from \"@/divider\";\nimport { useContext } from \"@/header/Header\";\nimport { Text } from \"@/text\";\n\nexport type ActionSpec = Button.IconProps | ReactElement;\n\nexport interface ActionsProps {\n children?: ActionSpec | ActionSpec[];\n}\n\n/**\n * Custom actions to render on the right side of the header.\n *\n * @param children - The actions to render. If the action is of type\n * {@link ButtonIconProps}, a correectly sized {@link ButtonIconOnly} is rendered\n * using the given props. If the action is a JSX element, it is renderered directly.\n * It's a good idea to prefer the latter in almost all cases for simplicity.\n */\nexport const Actions = ({ children = [] }: ActionsProps): ReactElement => {\n const { level, divided } = useContext();\n return (\n <Align.Space\n direction=\"x\"\n size=\"small\"\n align=\"center\"\n className={CSS.BE(\"header\", \"actions\")}\n >\n {toArray(children).map((action, i) => (\n <Action key={i} index={i} level={level} divided={divided}>\n {action}\n </Action>\n ))}\n </Align.Space>\n );\n};\n\ninterface ActionProps {\n index: number;\n level: Text.Level;\n children: ReactElement | Button.IconProps;\n divided: boolean;\n}\n\nconst Action = ({ index, level, children, divided }: ActionProps): ReactElement => {\n let content: ReactElement = children as ReactElement;\n if (!isValidElement(children)) {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n const props = children as Button.IconProps;\n content = (\n <Button.Icon\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n props.onClick?.(e);\n }}\n key={index}\n size={Text.LevelComponentSizes[level]}\n {...props}\n />\n );\n }\n return (\n <Fragment key={index}>\n {divided && <Divider.Divider />}\n {content}\n </Fragment>\n );\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ReactElement } from \"react\";\n\nimport { Button } from \"@/button\";\nimport { CSS } from \"@/css\";\nimport { useContext } from \"@/header/Header\";\nimport { Text } from \"@/text\";\n\nexport interface ButtonTitleProps\n extends Omit<Button.ButtonProps, \"variant\" | \"size\"> {}\n\n/**\n * Header.Title.Use renders a clickable header title.\n *\n * @param props - The comonent props. The props for this component are identical\n * to {@link Button}, except the variant is always 'outlined' and that the component size\n * is automatically inferred from the 'level' prop passsed to the parent {@link Header}\n * component.\n */\nexport const ButtonTitle = ({\n children = \"\",\n className,\n onClick,\n ...props\n}: ButtonTitleProps): ReactElement => {\n const { level } = useContext();\n return (\n <Button.Button\n variant=\"text\"\n size={Text.LevelComponentSizes[level]}\n onClick={onClick}\n className={CSS(CSS.B(\"header-button-title\"), className)}\n sharp\n {...props}\n >\n {children}\n </Button.Button>\n );\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ReactElement } from \"react\";\n\nimport { CSS } from \"@/css\";\nimport { useContext } from \"@/header/Header\";\nimport { Text } from \"@/text\";\n\nexport interface TitleProps extends Omit<Text.WithIconProps, \"divided\" | \"level\"> {\n level?: Text.Level;\n}\n\n/**\n * Renders the title for the header component.\n *\n * @param props - The component props. The props for this component are identical\n * to the {@link Typography.TextWithIcon} component, except that the 'level', and\n * 'divider' props are inherited from the parent {@link Header} component.\n */\nexport const Title = ({\n className,\n level: propsLevel,\n ...props\n}: TitleProps): ReactElement => {\n const { level, divided } = useContext();\n return (\n <Text.WithIcon\n className={CSS(CSS.BE(\"header\", \"text\"), className)}\n level={propsLevel ?? level}\n divided={divided}\n size={1.5}\n {...props}\n />\n );\n};\n"],"names":["Context","createContext","useContext","reactUseContext","Header","children","className","level","divided","props","jsx","Align.Space","CSS","Actions","toArray","action","i","Action","index","content","isValidElement","Button.Icon","e","_a","Text.LevelComponentSizes","Fragment","Divider.Divider","ButtonTitle","onClick","Button.Button","Title","propsLevel","Text.WithIcon"],"mappings":"2NAiCMA,EAAUC,EAAAA,cAA4B,CAC1C,QAAS,GACT,MAAO,IACT,CAAC,EAEYC,EAAa,IAAoBC,aAAgBH,CAAO,EAgBxDI,EAAS,CAAC,CACrB,SAAAC,EACA,UAAAC,EACA,MAAAC,EAAQ,KACR,QAAAC,EAAU,GACV,GAAGC,CACL,IACEC,EAAA,kBAAA,IAACV,EAAQ,SAAR,CAAiB,MAAO,CAAE,MAAAO,EAAO,QAAAC,GAChC,SAAAE,EAAA,kBAAA,IAACC,EAAM,MAAN,CACC,GAAG,SACH,UAAU,IACV,QAAQ,eACR,UAAWC,EAAA,IACTA,EAAA,IAAI,EAAE,QAAQ,EACdA,EAAA,IAAI,SAAS,QAAQ,EACrBJ,GAAWI,EAAA,IAAI,GAAG,SAAU,SAAS,EACrCN,CACF,EACC,GAAGG,EAEH,SAAAJ,CAAA,CACH,CACF,CAAA,EC1CWQ,EAAU,CAAC,CAAE,SAAAR,EAAW,CAAA,KAAqC,CACxE,KAAM,CAAE,MAAAE,EAAO,QAAAC,CAAQ,EAAIN,EAAW,EAEpC,OAAAQ,EAAA,kBAAA,IAACC,EAAM,MAAN,CACC,UAAU,IACV,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AO,QAAAC,CAAQ,EAAIN,EAAW,EAEpC,OAAAQ,EAAA,kBAAA,IAACsB,EAAK,SAAL,CACC,UAAWpB,EAAI,IAAAA,MAAI,GAAG,SAAU,MAAM,EAAGN,CAAS,EAClD,MAAOyB,GAAcxB,EACrB,QAAAC,EACA,KAAM,IACL,GAAGC,CAAA,CAAA,CAGV"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { j as u } from "./jsx-runtime-NmMXPjeo.js";
|
|
2
|
-
import { B as j, I as v, v as M, w as S, x as y, y as L } from "./Toggle-
|
|
3
|
-
import { L as O } from "./Link-
|
|
2
|
+
import { B as j, I as v, v as M, w as S, x as y, y as L } from "./Toggle-zmqGwWeq.js";
|
|
3
|
+
import { L as O } from "./Link-4oN98LnE.js";
|
|
4
4
|
import { C as i } from "./css-rizsElAK.js";
|
|
5
5
|
import { createContext as N, useContext as b } from "react";
|
|
6
6
|
const l = N({
|
|
@@ -64,4 +64,4 @@ const D = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
64
64
|
export {
|
|
65
65
|
D as e
|
|
66
66
|
};
|
|
67
|
-
//# sourceMappingURL=external-
|
|
67
|
+
//# sourceMappingURL=external-dD3TNRhO.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external-
|
|
1
|
+
{"version":3,"file":"external-dD3TNRhO.js","sources":["../src/menu/Menu.tsx","../src/menu/Item.tsx"],"sourcesContent":["// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport {\n createContext,\n type PropsWithChildren,\n type ReactElement,\n useContext,\n} from \"react\";\n\nimport { type Input } from \"@/input\";\nimport { type Text } from \"@/text\";\nimport { type ComponentSize } from \"@/util/component\";\n\ninterface MenuContextValue {\n onClick: (key: string) => void;\n selected: string;\n level?: Text.Level;\n iconSpacing?: ComponentSize;\n}\n\nexport const MenuContext = createContext<MenuContextValue>({\n onClick: () => {},\n selected: \"\",\n});\n\nexport interface MenuProps\n extends Partial<Input.Control<string>>,\n PropsWithChildren,\n Pick<MenuContextValue, \"level\" | \"iconSpacing\"> {}\n\nexport const useMenuContext = (): MenuContextValue => useContext(MenuContext);\n\n/**\n * Menu is a modular component that allows you to create a menu with a list of items.\n * It satisfies the InputControl string interface, so it's selected value can be\n * controlled.\n *\n * @param props - Props for the component. All unlisted props will be spread to the\n * underlying Space component acting as the root element.\n * @param props.onChange - Callback executed when the selected item changes.\n * @param props.value - The selected item.\n */\nexport const Menu = ({\n children,\n onChange,\n level,\n iconSpacing,\n value = \"\",\n}: MenuProps): ReactElement => {\n const handleClick: MenuProps[\"onChange\"] = (key) => onChange?.(key);\n return (\n <MenuContext.Provider\n value={{ onClick: handleClick, selected: value, level, iconSpacing }}\n >\n {children}\n </MenuContext.Provider>\n );\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type FunctionComponent, type ReactElement } from \"react\";\n\nimport { Button } from \"@/button\";\nimport { CSS } from \"@/css\";\nimport { useMenuContext } from \"@/menu/Menu\";\n\nimport \"@/menu/Item.css\";\n\nconst menuItemFactory =\n <E extends Pick<Button.ButtonProps, \"className\" | \"onClick\" | \"size\">>(\n Base: FunctionComponent<E>,\n defaultProps?: Partial<E>,\n ): FunctionComponent<E & { itemKey: string }> =>\n // eslint-disable-next-line react/display-name\n (props): ReactElement => {\n const { itemKey, className, onClick, size, ...rest } = {\n ...defaultProps,\n ...props,\n };\n\n const { onClick: ctxOnClick, selected, level, iconSpacing } = useMenuContext();\n\n const handleClick: Button.ButtonProps[\"onClick\"] = (e) => {\n ctxOnClick(itemKey);\n onClick?.(e);\n };\n const _selected = selected === itemKey;\n return (\n // @ts-expect-error\n <Base\n level={level}\n {...rest}\n onClick={handleClick}\n variant=\"text\"\n className={CSS(CSS.B(\"menu-item\"), CSS.selected(_selected), className)}\n size={size ?? iconSpacing}\n />\n );\n };\n\nexport interface ItemProps extends Button.ButtonProps {\n itemKey: string;\n}\nexport const CoreItem = menuItemFactory(Button.Button, { noWrap: true });\n\nexport interface ItemIconProps extends Button.IconProps {\n itemKey: string;\n}\nconst ItemIcon = menuItemFactory(Button.Icon);\n\nconst ItemLink = menuItemFactory(Button.Link, { noWrap: true });\nexport interface MenuItemLinkProps extends Button.LinkProps {\n itemKey: string;\n}\n\ntype CoreItemType = typeof CoreItem;\n\nexport interface ItemType extends CoreItemType {\n Icon: typeof ItemIcon;\n Link: typeof ItemLink;\n}\n\n/**\n * Menu.Item renders a menu item.\n *\n * @param props - Props for the component. Identical props to those of Use except\n * for the ones listed below.\n * @param props.itemKey - The key of the item. This is used to identify the item and\n * is passed to the onChange callback of the Menu.\n */\nexport const Item = CoreItem as ItemType;\nItem.Icon = ItemIcon;\nItem.Link = ItemLink;\n"],"names":["MenuContext","createContext","useMenuContext","useContext","Menu","children","onChange","level","iconSpacing","value","handleClick","key","jsx","menuItemFactory","Base","defaultProps","props","itemKey","className","onClick","size","rest","ctxOnClick","selected","e","_selected","CSS","CoreItem","Button.Button","ItemIcon","Button.Icon","ItemLink","Button.Link","Item"],"mappings":";;;;;AA2BO,MAAMA,IAAcC,EAAgC;AAAA,EACzD,SAAS,MAAM;AAAA,EAAC;AAAA,EAChB,UAAU;AACZ,CAAC,GAOYC,IAAiB,MAAwBC,EAAWH,CAAW,GAY/DI,IAAO,CAAC;AAAA,EACnB,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,OAAAC,IAAQ;AACV,MAA+B;AAC7B,QAAMC,IAAqC,CAACC,MAAQL,KAAA,gBAAAA,EAAWK;AAE7D,SAAAC,gBAAAA,EAAA;AAAA,IAACZ,EAAY;AAAA,IAAZ;AAAA,MACC,OAAO,EAAE,SAASU,GAAa,UAAUD,GAAO,OAAAF,GAAO,aAAAC,EAAY;AAAA,MAElE,UAAAH;AAAA,IAAA;AAAA,EAAA;AAGP,GC/CMQ,IACJ,CACEC,GACAC;AAAA;AAAA,EAGF,CAACC,MAAwB;AACvB,UAAM,EAAE,SAAAC,GAAS,WAAAC,GAAW,SAAAC,GAAS,MAAAC,GAAM,GAAGC,MAAS;AAAA,MACrD,GAAGN;AAAA,MACH,GAAGC;AAAA,IAAA,GAGC,EAAE,SAASM,GAAY,UAAAC,GAAU,OAAAhB,GAAO,aAAAC,EAAA,IAAgBN,KAExDQ,IAA6C,CAACc,MAAM;AACxD,MAAAF,EAAWL,CAAO,GAClBE,KAAA,QAAAA,EAAUK;AAAA,IAAC,GAEPC,IAAYF,MAAaN;AAC/B;AAAA;AAAA,MAEEL,gBAAAA,EAAA;AAAA,QAACE;AAAA,QAAA;AAAA,UACC,OAAAP;AAAA,UACC,GAAGc;AAAA,UACJ,SAASX;AAAA,UACT,SAAQ;AAAA,UACR,WAAWgB,EAAIA,EAAI,EAAE,WAAW,GAAGA,EAAI,SAASD,CAAS,GAAGP,CAAS;AAAA,UACrE,MAAME,KAAQZ;AAAA,QAAA;AAAA,MAChB;AAAA;AAAA,EAEJ;AAAA,GAKWmB,IAAWd,EAAgBe,GAAe,EAAE,QAAQ,GAAM,CAAA,GAKjEC,IAAWhB,EAAgBiB,CAAW,GAEtCC,IAAWlB,EAAgBmB,GAAa,EAAE,QAAQ,GAAM,CAAA,GAoBjDC,IAAON;AACpBM,EAAK,OAAOJ;AACZI,EAAK,OAAOF;;;;;;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const u=require("./jsx-runtime-evvPGacs.cjs"),d=require("react"),j=require("./Toggle-
|
|
2
|
-
//# sourceMappingURL=external-
|
|
1
|
+
"use strict";const u=require("./jsx-runtime-evvPGacs.cjs"),d=require("react"),j=require("./Toggle-qW_TcIDh.cjs"),R=require("./Center-Q-fgAb96.cjs"),o=require("./css-JWFtNl10.cjs"),y=require("./aggregator-6_J8kSSO.cjs"),B=(r="",e=[])=>{var t;if(e.length!==0)return e.find(s=>s.tabKey===r)!=null?r:(t=e[e.length-1])==null?void 0:t.tabKey},k=(r,e,t)=>{if(e=e.trim(),e.length===0)return t;const s=t.find(n=>n.tabKey===r);return s==null||s.name===e?t:t.map(n=>n.tabKey===r?{...n,name:e}:n)},T=({tabs:r,content:e,onSelect:t})=>{var c;const[s,n]=d.useState(((c=r[0])==null?void 0:c.tabKey)??""),l=d.useCallback(i=>{n(i),t==null||t(i)},[n,t]);return{tabs:r,selected:s,content:e,onSelect:l}},f=d.createContext({tabs:[]}),v=()=>d.useContext(f),N=({content:r,children:e,onSelect:t,selected:s,closable:n,tabs:l,onClose:c,onDragStart:i,onDragEnd:p,onCreate:h,onRename:m,emptyContent:E,className:b,onDragOver:S,onDrop:a,size:g="medium",direction:x="y",...q})=>u.jsxRuntimeExports.jsx(R.Space,{empty:!0,className:o.CSS(o.CSS.B("tabs"),b),onDragOver:S,onDrop:a,direction:x,...q,children:u.jsxRuntimeExports.jsxs(f.Provider,{value:{tabs:l,emptyContent:E,selected:s,closable:n,content:e??r,onSelect:t,onClose:c,onDragStart:i,onDragEnd:p,onRename:m,onCreate:h,onDrop:a},children:[u.jsxRuntimeExports.jsx(_,{size:g,direction:o.direction$1.swap(x)}),u.jsxRuntimeExports.jsx(P,{})]})}),w=f.Provider,P=()=>{const{tabs:r,selected:e,content:t,emptyContent:s,onSelect:n}=v();let l=null;const c=r.find(i=>i.tabKey===e);return e==null||c==null?s??null:(t!=null?l=t(c):c.content!=null&&(l=c.content),u.jsxRuntimeExports.jsx("div",{className:o.CSS.B("tabs-content"),onClick:()=>n==null?void 0:n(e),style:{width:"100%",height:"100%",position:"relative",overflow:"hidden"},children:l}))},C="tabs-selector",_=({className:r,size:e="medium",direction:t="x",...s})=>{const{tabs:n,selected:l,onSelect:c,onClose:i,closable:p,onDragEnd:h,onDragStart:m,onDrop:E,onRename:b,onCreate:S}=v();return u.jsxRuntimeExports.jsxs(R.Space,{className:o.CSS(o.CSS.B(C),o.CSS.size(e),r),align:"center",justify:"spaceBetween",onDrop:E,empty:!0,direction:t,...s,children:[u.jsxRuntimeExports.jsx(R.Space,{direction:t,className:o.CSS.BE(C,"tabs"),empty:!0,children:n.map(a=>u.jsxRuntimeExports.jsx(I,{selected:l,onSelect:c,onClose:i,onDragStart:m,onDragEnd:h,onRename:b,closable:a.closable??p,size:e,...a},a.tabKey))}),u.jsxRuntimeExports.jsx(R.Space,{className:o.CSS.BE(C,"actions"),children:S!=null&&u.jsxRuntimeExports.jsx(j.Icon,{size:e,sharp:!0,onClick:S,children:u.jsxRuntimeExports.jsx(j.u0.Add,{})})})]})},I=({selected:r,onSelect:e,onClose:t,tabKey:s,name:n,onDragStart:l,onDragEnd:c,onRename:i,closable:p=!0,icon:h,size:m,editable:E=!0})=>{const b=d.useCallback(x=>l==null?void 0:l(x,{tabKey:s,name:n}),[l,s,n]),S=d.useCallback(x=>c==null?void 0:c(x,{tabKey:s,name:n}),[c,s,n]),a=d.useCallback(x=>{x.stopPropagation(),t==null||t(s)},[t,s]),g=d.useCallback(()=>e==null?void 0:e(s),[e,s]);return u.jsxRuntimeExports.jsxs(R.Pack,{size:m,className:o.CSS(o.CSS.BE(C,"btn"),i==null&&o.CSS.BEM(C,"btn","uneditable"),o.CSS.selected(r===s),p&&t!=null&&o.CSS.BEM(C,"btn","closable")),draggable:!0,direction:"x",justify:"center",align:"center",onClick:g,onDragStart:b,onDragEnd:S,bordered:!1,rounded:!1,children:[u.jsxRuntimeExports.jsx(W,{name:n,tabKey:s,onRename:i,icon:h,editable:E,level:y.ComponentSizeLevels[m]}),p&&t!=null&&u.jsxRuntimeExports.jsx(j.Icon,{onClick:a,children:u.jsxRuntimeExports.jsx(j.u0.Close,{"aria-label":"pluto-tabs__close"})})]})},W=({onRename:r,name:e,tabKey:t,icon:s,editable:n=!0,...l})=>r==null||!n?s!=null?u.jsxRuntimeExports.jsx(j.WithIcon,{startIcon:s,noWrap:!0,...l,children:e}):u.jsxRuntimeExports.jsx(j.Text,{noWrap:!0,...l,children:e}):u.jsxRuntimeExports.jsx(j.Editable,{onChange:c=>r(t,c),value:e,noWrap:!0,...l}),M=Object.freeze(Object.defineProperty({__proto__:null,Content:P,Provider:w,Selector:_,Tabs:N,TabsContext:f,rename:k,resetSelection:B,useStatic:T,useTabsContext:v},Symbol.toStringTag,{value:"Module"}));exports.Tabs=N;exports.external=M;exports.rename=k;exports.resetSelection=B;exports.useStatic=T;
|
|
2
|
+
//# sourceMappingURL=external-dFd3d4ZY.cjs.map
|