@accelint/design-toolkit 4.0.0 → 5.1.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/components/accordion/index.d.ts +1 -1
- package/dist/components/accordion/index.js +3 -1
- package/dist/components/accordion/index.js.map +1 -1
- package/dist/components/accordion/styles.js +1 -1
- package/dist/components/accordion/styles.js.map +1 -1
- package/dist/components/accordion/types.d.ts +1 -1
- package/dist/components/action-bar/index.d.ts +10 -0
- package/dist/components/action-bar/index.js +4 -0
- package/dist/components/action-bar/index.js.map +1 -0
- package/dist/components/action-bar/styles.d.ts +5 -0
- package/dist/components/action-bar/styles.js +2 -0
- package/dist/components/action-bar/styles.js.map +1 -0
- package/dist/components/action-bar/types.d.ts +5 -0
- package/dist/components/action-bar/types.js +2 -0
- package/dist/components/action-bar/types.js.map +1 -0
- package/dist/components/avatar/index.d.ts +1 -1
- package/dist/components/avatar/index.js +3 -1
- package/dist/components/avatar/index.js.map +1 -1
- package/dist/components/avatar/styles.js +1 -1
- package/dist/components/avatar/styles.js.map +1 -1
- package/dist/components/avatar/types.d.ts +1 -1
- package/dist/components/badge/index.d.ts +1 -1
- package/dist/components/badge/index.js +2 -0
- package/dist/components/badge/index.js.map +1 -1
- package/dist/components/badge/styles.js +1 -1
- package/dist/components/badge/styles.js.map +1 -1
- package/dist/components/button/index.d.ts +1 -1
- package/dist/components/button/index.js +2 -0
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/button/styles.js +1 -1
- package/dist/components/button/styles.js.map +1 -1
- package/dist/components/button/types.d.ts +1 -1
- package/dist/components/checkbox/index.js +2 -0
- package/dist/components/checkbox/styles.js +1 -1
- package/dist/components/checkbox/styles.js.map +1 -1
- package/dist/components/chip/index.d.ts +1 -1
- package/dist/components/chip/index.js +2 -0
- package/dist/components/chip/index.js.map +1 -1
- package/dist/components/chip/styles.js +1 -1
- package/dist/components/chip/styles.js.map +1 -1
- package/dist/components/classification-badge/index.d.ts +1 -1
- package/dist/components/classification-badge/index.js +3 -1
- package/dist/components/classification-badge/index.js.map +1 -1
- package/dist/components/classification-badge/styles.d.ts +1 -1
- package/dist/components/classification-badge/styles.js +1 -1
- package/dist/components/classification-badge/styles.js.map +1 -1
- package/dist/components/classification-banner/index.d.ts +1 -1
- package/dist/components/classification-banner/index.js +3 -1
- package/dist/components/classification-banner/index.js.map +1 -1
- package/dist/components/classification-banner/styles.d.ts +1 -1
- package/dist/components/classification-banner/styles.js +1 -1
- package/dist/components/classification-banner/styles.js.map +1 -1
- package/dist/components/color-picker/index.js +2 -0
- package/dist/components/color-picker/styles.js +1 -1
- package/dist/components/color-picker/styles.js.map +1 -1
- package/dist/components/combobox-field/index.d.ts +1 -1
- package/dist/components/combobox-field/index.js +2 -0
- package/dist/components/combobox-field/index.js.map +1 -1
- package/dist/components/combobox-field/styles.d.ts +1 -1
- package/dist/components/combobox-field/styles.js +1 -1
- package/dist/components/combobox-field/styles.js.map +1 -1
- package/dist/components/combobox-field/types.d.ts +1 -1
- package/dist/components/date-field/index.js +2 -0
- package/dist/components/date-field/index.js.map +1 -1
- package/dist/components/date-field/styles.d.ts +1 -1
- package/dist/components/date-field/styles.js +1 -1
- package/dist/components/date-field/styles.js.map +1 -1
- package/dist/components/details-list/index.d.ts +1 -1
- package/dist/components/details-list/index.js +3 -1
- package/dist/components/details-list/index.js.map +1 -1
- package/dist/components/details-list/styles.js +1 -1
- package/dist/components/details-list/styles.js.map +1 -1
- package/dist/components/dialog/index.js +3 -1
- package/dist/components/dialog/index.js.map +1 -1
- package/dist/components/dialog/styles.d.ts +1 -1
- package/dist/components/dialog/styles.js +1 -1
- package/dist/components/dialog/styles.js.map +1 -1
- package/dist/components/drawer/index.d.ts +1 -1
- package/dist/components/drawer/index.js +3 -1
- package/dist/components/drawer/index.js.map +1 -1
- package/dist/components/drawer/styles.d.ts +4 -4
- package/dist/components/drawer/styles.js +1 -1
- package/dist/components/drawer/styles.js.map +1 -1
- package/dist/components/drawer/types.d.ts +1 -1
- package/dist/components/hero/index.js +3 -1
- package/dist/components/hero/index.js.map +1 -1
- package/dist/components/hero/styles.js +1 -1
- package/dist/components/hero/styles.js.map +1 -1
- package/dist/components/hotkey/index.d.ts +1 -1
- package/dist/components/hotkey/index.js +2 -0
- package/dist/components/hotkey/index.js.map +1 -1
- package/dist/components/hotkey/styles.js +1 -1
- package/dist/components/hotkey/styles.js.map +1 -1
- package/dist/components/icon/index.d.ts +1 -1
- package/dist/components/icon/index.js +3 -1
- package/dist/components/icon/index.js.map +1 -1
- package/dist/components/input/index.d.ts +1 -1
- package/dist/components/input/index.js +2 -0
- package/dist/components/input/index.js.map +1 -1
- package/dist/components/input/styles.js +1 -1
- package/dist/components/input/styles.js.map +1 -1
- package/dist/components/label/index.d.ts +1 -1
- package/dist/components/label/index.js +2 -0
- package/dist/components/label/index.js.map +1 -1
- package/dist/components/label/styles.js +1 -1
- package/dist/components/label/styles.js.map +1 -1
- package/dist/components/lines/index.d.ts +9 -0
- package/dist/components/lines/index.js +2 -0
- package/dist/components/lines/index.js.map +1 -0
- package/dist/components/lines/styles.d.ts +32 -0
- package/dist/components/lines/styles.js +2 -0
- package/dist/components/lines/styles.js.map +1 -0
- package/dist/components/lines/types.d.ts +10 -0
- package/dist/components/lines/types.js +2 -0
- package/dist/components/lines/types.js.map +1 -0
- package/dist/components/link/index.d.ts +17 -0
- package/dist/components/link/index.js +4 -0
- package/dist/components/link/index.js.map +1 -0
- package/dist/components/link/styles.d.ts +5 -0
- package/dist/components/link/styles.js +2 -0
- package/dist/components/link/styles.js.map +1 -0
- package/dist/components/link/types.d.ts +9 -0
- package/dist/components/link/types.js +2 -0
- package/dist/components/link/types.js.map +1 -0
- package/dist/components/menu/index.js +3 -1
- package/dist/components/menu/index.js.map +1 -1
- package/dist/components/menu/styles.js +1 -1
- package/dist/components/menu/styles.js.map +1 -1
- package/dist/components/options/index.js +2 -0
- package/dist/components/options/index.js.map +1 -1
- package/dist/components/options/styles.d.ts +1 -1
- package/dist/components/options/styles.js +1 -1
- package/dist/components/options/styles.js.map +1 -1
- package/dist/components/popover/index.js +2 -0
- package/dist/components/popover/index.js.map +1 -1
- package/dist/components/popover/styles.js +1 -1
- package/dist/components/popover/styles.js.map +1 -1
- package/dist/components/query-builder/action-element.js +2 -0
- package/dist/components/query-builder/action-element.js.map +1 -1
- package/dist/components/query-builder/group.js +3 -1
- package/dist/components/query-builder/group.js.map +1 -1
- package/dist/components/query-builder/index.js +1 -1
- package/dist/components/query-builder/index.js.map +1 -1
- package/dist/components/query-builder/rule.js +2 -0
- package/dist/components/query-builder/value-editor.js +2 -0
- package/dist/components/query-builder/value-editor.js.map +1 -1
- package/dist/components/query-builder/value-selector.js.map +1 -1
- package/dist/components/radio/index.js +2 -0
- package/dist/components/radio/styles.js +1 -1
- package/dist/components/radio/styles.js.map +1 -1
- package/dist/components/search-field/index.d.ts +3 -3
- package/dist/components/search-field/index.js +2 -0
- package/dist/components/search-field/index.js.map +1 -1
- package/dist/components/search-field/styles.js +1 -1
- package/dist/components/search-field/styles.js.map +1 -1
- package/dist/components/select-field/index.d.ts +1 -1
- package/dist/components/select-field/index.js +3 -1
- package/dist/components/select-field/index.js.map +1 -1
- package/dist/components/select-field/styles.js +1 -1
- package/dist/components/select-field/styles.js.map +1 -1
- package/dist/components/select-field/types.d.ts +1 -1
- package/dist/components/sidenav/events.d.ts +8 -0
- package/dist/components/sidenav/events.js +2 -0
- package/dist/components/sidenav/events.js.map +1 -0
- package/dist/components/sidenav/index.d.ts +64 -0
- package/dist/components/sidenav/index.js +4 -0
- package/dist/components/sidenav/index.js.map +1 -0
- package/dist/components/sidenav/styles.d.ts +156 -0
- package/dist/components/sidenav/styles.js +2 -0
- package/dist/components/sidenav/styles.js.map +1 -0
- package/dist/components/sidenav/types.d.ts +70 -0
- package/dist/components/sidenav/types.js +2 -0
- package/dist/components/sidenav/types.js.map +1 -0
- package/dist/components/skeleton/styles.d.ts +2 -2
- package/dist/components/skeleton/styles.js +1 -1
- package/dist/components/skeleton/styles.js.map +1 -1
- package/dist/components/slider/index.js +2 -0
- package/dist/components/slider/index.js.map +1 -1
- package/dist/components/slider/styles.d.ts +1 -1
- package/dist/components/slider/styles.js +1 -1
- package/dist/components/slider/styles.js.map +1 -1
- package/dist/components/switch/index.d.ts +1 -1
- package/dist/components/switch/index.js +2 -0
- package/dist/components/switch/index.js.map +1 -1
- package/dist/components/switch/styles.js +1 -1
- package/dist/components/switch/styles.js.map +1 -1
- package/dist/components/tabs/index.d.ts +37 -36
- package/dist/components/tabs/index.js +3 -1
- package/dist/components/tabs/index.js.map +1 -1
- package/dist/components/tabs/styles.d.ts +48 -0
- package/dist/components/tabs/styles.js +2 -0
- package/dist/components/tabs/styles.js.map +1 -0
- package/dist/components/tabs/types.d.ts +6 -0
- package/dist/components/tabs/types.js +2 -0
- package/dist/components/tabs/types.js.map +1 -0
- package/dist/components/text-area-field/index.d.ts +1 -1
- package/dist/components/text-area-field/index.js +2 -0
- package/dist/components/text-area-field/index.js.map +1 -1
- package/dist/components/text-area-field/styles.js +1 -1
- package/dist/components/text-area-field/styles.js.map +1 -1
- package/dist/components/text-field/index.js +2 -0
- package/dist/components/text-field/index.js.map +1 -1
- package/dist/components/text-field/styles.js +1 -1
- package/dist/components/text-field/styles.js.map +1 -1
- package/dist/components/tooltip/index.d.ts +1 -1
- package/dist/components/tooltip/index.js +3 -1
- package/dist/components/tooltip/index.js.map +1 -1
- package/dist/components/tooltip/styles.d.ts +1 -1
- package/dist/components/tooltip/styles.js +1 -1
- package/dist/components/tooltip/styles.js.map +1 -1
- package/dist/components/tooltip/types.d.ts +3 -1
- package/dist/components/tree/index.d.ts +51 -0
- package/dist/components/tree/index.js +4 -0
- package/dist/components/tree/index.js.map +1 -0
- package/dist/components/tree/styles.d.ts +128 -0
- package/dist/components/tree/styles.js +2 -0
- package/dist/components/tree/styles.js.map +1 -0
- package/dist/components/tree/types.d.ts +41 -0
- package/dist/components/tree/types.js +2 -0
- package/dist/components/tree/types.js.map +1 -0
- package/dist/components/view-stack/index.js +2 -0
- package/dist/components/view-stack/index.js.map +1 -1
- package/dist/foundation/token-data.d.ts +17 -0
- package/dist/foundation/token-data.js +2 -0
- package/dist/foundation/token-data.js.map +1 -0
- package/dist/hooks/use-tree/actions/cache.d.ts +78 -0
- package/dist/hooks/use-tree/actions/cache.js +2 -0
- package/dist/hooks/use-tree/actions/cache.js.map +1 -0
- package/dist/hooks/use-tree/actions/index.d.ts +38 -0
- package/dist/hooks/use-tree/actions/index.js +4 -0
- package/dist/hooks/use-tree/actions/index.js.map +1 -0
- package/dist/hooks/use-tree/state/index.d.ts +8 -0
- package/dist/hooks/use-tree/state/index.js +2 -0
- package/dist/hooks/use-tree/state/index.js.map +1 -0
- package/dist/hooks/use-tree/state/utils.d.ts +7 -0
- package/dist/hooks/use-tree/state/utils.js +2 -0
- package/dist/hooks/use-tree/state/utils.js.map +1 -0
- package/dist/hooks/use-tree/types.d.ts +171 -0
- package/dist/hooks/use-tree/types.js +2 -0
- package/dist/hooks/use-tree/types.js.map +1 -0
- package/dist/icons/catalog.js +1 -1
- package/dist/icons/catalog.js.map +1 -1
- package/dist/index.css +9 -15
- package/dist/index.d.ts +26 -3
- package/dist/index.js +1 -1
- package/dist/lib/react.d.ts +22 -8
- package/dist/lib/react.js +8 -4
- package/dist/lib/react.js.map +1 -1
- package/dist/lib/utils.d.ts +2 -2
- package/dist/lib/utils.js +1 -1
- package/dist/lib/utils.js.map +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/providers/theme-provider.d.ts +22 -0
- package/dist/providers/theme-provider.js +4 -0
- package/dist/providers/theme-provider.js.map +1 -0
- package/dist/styles.css +1663 -920
- package/dist/tokens/themes.css +729 -53
- package/dist/tokens/tokens.css +121 -65
- package/dist/tokens/tokens.d.ts +449 -1
- package/dist/tokens/tokens.js +2 -0
- package/dist/tokens/tokens.js.map +1 -0
- package/dist/tokens/types.d.ts +299 -0
- package/dist/tokens/types.js +2 -0
- package/dist/tokens/types.js.map +1 -0
- package/dist/variants/variants.css +6 -1
- package/package.json +13 -8
- package/dist/tokens/index.d.ts +0 -123
- package/dist/tokens/index.js +0 -2
- package/dist/tokens/index.js.map +0 -1
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import {jsx}from'react/jsx-runtime';import'client-only';import {UNSAFE_PortalProvider}from'@react-aria/overlays';import {useIsSSR}from'@react-aria/ssr';import {createContext,useState,useEffect}from'react';import {useContextProps,TooltipTrigger,Focusable,Tooltip,composeRenderProps}from'react-aria-components';import {containsExactChildren}from'./../../lib/react.js';import {TooltipStyles}from'./styles.js';const B=createContext(null);function p({ref:t,...o}){[o,t]=useContextProps(o,t??null,B);const{children:r,delay:s=250,...a}=o;return containsExactChildren({children:r,componentName:p.displayName,restrictions:[[m,{min:1,max:1}],[T,{min:1,max:1}]]}),jsx(TooltipTrigger,{...a,delay:s,children:r})}p.displayName="Tooltip";function m({children:t,...o}){return jsx(Focusable,{...o,children:t})}m.displayName="Tooltip.Trigger";function T({children:t,parentRef:o,className:r,offset:s=5,placement:a="bottom",...u}){const i=useIsSSR(),[d,c]=useState(i?null:document.body);return useEffect(()=>{const l=o?.current,e=i?null:document.createElement("div");return e?.setAttribute("style","position: absolute;"),l&&e&&(l.appendChild(e),c(e)),()=>{e?.remove(),c(i?null:document.body);}},[i,o]),jsx(UNSAFE_PortalProvider,{getContainer:()=>d,children:jsx(Tooltip,{...u,className:composeRenderProps(r,l=>TooltipStyles({className:l})),offset:s,placement:a,children:t})})}T.displayName="Tooltip.Body",p.Trigger=m,p.Body=T;export{p as Tooltip,B as TooltipContext};//# sourceMappingURL=index.js.map
|
|
2
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/tooltip/index.tsx"],"names":["
|
|
1
|
+
{"version":3,"sources":["../../../src/components/tooltip/index.tsx"],"names":["P","props","useContextProps","ref","TooltipContext","A","E","Tooltip","jsx","AriaTooltipTrigger","rest","delay","Focusable","n","b","children","TooltipTrigger","parentRef","className","placement","isSSR","portal","g","x","useEffect","node","port","setPortal","UNSAFE_PortalProvider","y","AriaTooltip","C","S","v","offset","TooltipBody"],"mappings":"sZA8EO,MAAA,CAAA,CAAAA,aAAA,CAAA,IAAmB,EAAA,SAAc,CAAiB,CACvD,CAACC,GAAU,CAAA,CAAIC,CAAAA,GAAuBC,CAAAA,CAAAA,CAAO,KAAMC,CAAc,CAAAC,eAEjE,CAAA,CAAA,CAAA,CAAA,EAAQ,IAAA,CAAA,CAAA,CAAA,CAAA,KAAU,CAAA,QAAQ,CAAK,CAAA,CAAA,KAAYJ,CAE3C,CAAA,CAAA,GAAA,CAAA,GAAsB,CACpB,CAAA,CAAA,CAAA,CAAA,OACAK,qBAAA,CAAA,CAAA,QAAA,CAAA,CAAA,CAAeC,aAAQ,CACvB,CAAA,CAAA,WAAc,CACZ,YAA2B,CAAA,CAAK,CAAE,CAAC,CAAA,CACnC,GAAc,CAAE,CAAA,CAAA,GAAK,CAAG,CAAA,CAAA,CAAA,CAAK,CAAE,CAAC,CAClC,CACF,GAGEC,CAAAA,CAACC,CAAAA,GAAoB,CAAA,CAAGC,CAAAA,CAAM,QAAOC,cAAAA,CAClC,CAAA,GAAA,CAAA,CAAA,KACH,CAEJ,CACAJ,CAAAA,QAAQ,CAAA,CAAA,CAAA,CAAA,CAAc,CAAA,CAAA,WAEtB,CAAA,SAA0B,CAAA,SAAU,CAAA,CAAA,CAAGN,QACrC,CAAA,CAAA,CAAOO,GAACI,CAAA,CAAW,CAAA,CAAA,OAAWC,GAAA,CAAAC,SAAA,CAAA,CAAAC,GAChC,CACAC,CAAAA,QAAe,CAAA,CAAA,CAAA,CAAA,CAAc,CAAA,CAAA,WAAA,CAAA,iBAG3B,CAAA,SACA,CAAA,CAAA,CAAA,QAAAC,CACA,CAAA,CAAA,SAAAC,CACA,CAAA,CAAA,SACA,CAAA,CAAA,CAAA,M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reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n'use client';\n\nimport 'client-only';\nimport { UNSAFE_PortalProvider } from '@react-aria/overlays';\nimport { useIsSSR } from '@react-aria/ssr';\nimport { createContext, useEffect, useState } from 'react';\nimport {\n Tooltip as AriaTooltip,\n TooltipTrigger as AriaTooltipTrigger,\n type ContextValue,\n composeRenderProps,\n Focusable,\n useContextProps,\n} from 'react-aria-components';\nimport { containsExactChildren } from '@/lib/react';\nimport { TooltipStyles } from './styles';\nimport type {\n TooltipBodyProps,\n TooltipProps,\n TooltipTriggerProps,\n} from './types';\n\nexport const TooltipContext =\n createContext<ContextValue<TooltipProps, HTMLDivElement>>(null);\n\n/**\n * Tooltip - A contextual popup component for providing additional information\n *\n * Displays helpful information when users hover over or focus on an element.\n * Provides accessible tooltip functionality with proper positioning, keyboard\n * navigation, and screen reader support for enhanced user experience.\n *\n * @example\n * // Basic tooltip\n * <Tooltip>\n * <Tooltip.Trigger>\n * <Button>Hover me</Button>\n * </Tooltip.Trigger>\n * <Tooltip.Body>\n * This is helpful information\n * </Tooltip.Body>\n * </Tooltip>\n *\n * @example\n * // Tooltip with custom positioning\n * <Tooltip>\n * <Tooltip.Trigger>\n * <Button>Hover for info</Button>\n * </Tooltip.Trigger>\n * <Tooltip.Body placement=\"top\" offset={10}>\n * Positioned above with custom offset\n * </Tooltip.Body>\n * </Tooltip>\n *\n * @example\n * // Icon with tooltip\n * <Tooltip>\n * <Tooltip.Trigger>\n * <Button variant=\"icon\">\n * <Icon><Info /></Icon>\n * </Button>\n * </Tooltip.Trigger>\n * <Tooltip.Body>\n * Additional context for this action\n * </Tooltip.Body>\n * </Tooltip>\n */\nexport function Tooltip({ ref, ...props }: TooltipProps) {\n [props, ref] = useContextProps(props, ref ?? null, TooltipContext);\n\n const { children, delay = 250, ...rest } = props;\n\n containsExactChildren({\n children,\n componentName: Tooltip.displayName,\n restrictions: [\n [TooltipTrigger, { min: 1, max: 1 }],\n [TooltipBody, { min: 1, max: 1 }],\n ],\n });\n\n return (\n <AriaTooltipTrigger {...rest} delay={delay}>\n {children}\n </AriaTooltipTrigger>\n );\n}\nTooltip.displayName = 'Tooltip';\n\nfunction TooltipTrigger({ children, ...props }: TooltipTriggerProps) {\n return <Focusable {...props}>{children}</Focusable>;\n}\nTooltipTrigger.displayName = 'Tooltip.Trigger';\n\nfunction TooltipBody({\n children,\n parentRef,\n className,\n offset = 5,\n placement = 'bottom',\n ...props\n}: TooltipBodyProps) {\n const isSSR = useIsSSR();\n const [portal, setPortal] = useState(isSSR ? null : document.body);\n\n useEffect(() => {\n const node = parentRef?.current;\n // TODO: Ensure proper ssr hydration\n const port = isSSR ? null : document.createElement('div');\n port?.setAttribute('style', 'position: absolute;');\n\n if (node && port) {\n node.appendChild(port);\n\n setPortal(port);\n }\n\n return () => {\n port?.remove();\n\n setPortal(isSSR ? null : document.body);\n };\n }, [isSSR, parentRef]);\n\n return (\n <UNSAFE_PortalProvider getContainer={() => portal}>\n <AriaTooltip\n {...props}\n className={composeRenderProps(className, (className) =>\n TooltipStyles({ className }),\n )}\n offset={offset}\n placement={placement}\n >\n {children}\n </AriaTooltip>\n </UNSAFE_PortalProvider>\n );\n}\nTooltipBody.displayName = 'Tooltip.Body';\n\nTooltip.Trigger = TooltipTrigger;\nTooltip.Body = TooltipBody;\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as tailwind_variants from 'tailwind-variants';
|
|
2
2
|
|
|
3
|
-
declare const TooltipStyles: tailwind_variants.TVReturnType<{} | {} | {}, undefined, "fg-
|
|
3
|
+
declare const TooltipStyles: tailwind_variants.TVReturnType<{} | {} | {}, undefined, "fg-primary-bold flex max-w-[160px] items-center justify-center break-words rounded-small bg-surface-overlay px-s py-xs text-center text-body-xs shadow-elevation-overlay", {} | {}, undefined, tailwind_variants.TVReturnType<unknown, undefined, "fg-primary-bold flex max-w-[160px] items-center justify-center break-words rounded-small bg-surface-overlay px-s py-xs text-center text-body-xs shadow-elevation-overlay", unknown, unknown>>;
|
|
4
4
|
|
|
5
5
|
export { TooltipStyles };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {tv}from'./../../lib/utils.js';const o=tv({base:"fg-
|
|
1
|
+
import {tv}from'./../../lib/utils.js';const o=tv({base:"fg-primary-bold flex max-w-[160px] items-center justify-center break-words rounded-small bg-surface-overlay px-s py-xs text-center text-body-xs shadow-elevation-overlay"});export{o as TooltipStyles};//# sourceMappingURL=styles.js.map
|
|
2
2
|
//# sourceMappingURL=styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/tooltip/styles.ts"],"names":["e"],"mappings":"sCAeE,MAAM,CAAA,CAAAA,EAAA,CAAA,CAAA,IAAA,CAAA,
|
|
1
|
+
{"version":3,"sources":["../../../src/components/tooltip/styles.ts"],"names":["e"],"mappings":"sCAeE,MAAM,CAAA,CAAAA,EAAA,CAAA,CAAA,IAAA,CAAA,0KACP,CAAA","file":"styles.js","sourcesContent":["/*\n * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { tv } from '@/lib/utils';\n\nexport const TooltipStyles = tv({\n base: 'fg-primary-bold flex max-w-[160px] items-center justify-center break-words rounded-small bg-surface-overlay px-s py-xs text-center text-body-xs shadow-elevation-overlay',\n});\n"]}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { ComponentPropsWithRef, ComponentProps } from 'react';
|
|
2
2
|
import { TooltipTriggerComponentProps, Focusable, TooltipProps as TooltipProps$1 } from 'react-aria-components';
|
|
3
3
|
|
|
4
|
-
type TooltipBodyProps = TooltipProps$1
|
|
4
|
+
type TooltipBodyProps = TooltipProps$1 & {
|
|
5
|
+
parentRef?: React.RefObject<HTMLElement | null>;
|
|
6
|
+
};
|
|
5
7
|
type TooltipProps = Omit<ComponentPropsWithRef<'div'>, 'className'> & TooltipTriggerComponentProps;
|
|
6
8
|
type TooltipTriggerProps = ComponentProps<typeof Focusable>;
|
|
7
9
|
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
import { PropsWithChildren } from 'react';
|
|
4
|
+
import { TextProps } from 'react-aria-components';
|
|
5
|
+
import { IconProps } from '../icon/types.js';
|
|
6
|
+
import { TreeProps, TreeItemProps, TreeItemContentProps, TreeContextValue, TreeItemContextValue } from './types.js';
|
|
7
|
+
import '@react-types/shared';
|
|
8
|
+
import 'tailwind-variants';
|
|
9
|
+
import '../../hooks/use-tree/types.js';
|
|
10
|
+
import './styles.js';
|
|
11
|
+
|
|
12
|
+
declare const TreeContext: react.Context<TreeContextValue>;
|
|
13
|
+
declare function Tree<T>({ children, className, disabledKeys: disabledKeysProp, dragAndDropConfig, expandedKeys: expandedKeysProp, items, selectedKeys: selectedKeysProp, showRuleLines, showVisibility, selectionMode, variant, visibleKeys: visibleKeysProp, onVisibilityChange, onSelectionChange, ...rest }: TreeProps<T>): react_jsx_runtime.JSX.Element;
|
|
14
|
+
declare namespace Tree {
|
|
15
|
+
var displayName: string;
|
|
16
|
+
var Item: typeof TreeItem;
|
|
17
|
+
}
|
|
18
|
+
declare const TreeItemContext: react.Context<TreeItemContextValue>;
|
|
19
|
+
declare function TreeItem({ className, id, ...rest }: TreeItemProps): react_jsx_runtime.JSX.Element;
|
|
20
|
+
declare namespace TreeItem {
|
|
21
|
+
var displayName: string;
|
|
22
|
+
var Content: typeof ItemContent;
|
|
23
|
+
var Label: typeof ItemLabel;
|
|
24
|
+
var Description: typeof ItemDescription;
|
|
25
|
+
var PrefixIcon: typeof ItemIcon;
|
|
26
|
+
var Actions: typeof ItemActions;
|
|
27
|
+
}
|
|
28
|
+
declare function ItemContent({ children }: TreeItemContentProps): react_jsx_runtime.JSX.Element;
|
|
29
|
+
declare namespace ItemContent {
|
|
30
|
+
var displayName: string;
|
|
31
|
+
}
|
|
32
|
+
declare function ItemLabel({ children, className }: TextProps): react_jsx_runtime.JSX.Element;
|
|
33
|
+
declare namespace ItemLabel {
|
|
34
|
+
var displayName: string;
|
|
35
|
+
}
|
|
36
|
+
declare function ItemDescription({ children, className }: TextProps): react_jsx_runtime.JSX.Element | null;
|
|
37
|
+
declare namespace ItemDescription {
|
|
38
|
+
var displayName: string;
|
|
39
|
+
}
|
|
40
|
+
declare function ItemIcon({ children, className }: IconProps): react_jsx_runtime.JSX.Element;
|
|
41
|
+
declare namespace ItemIcon {
|
|
42
|
+
var displayName: string;
|
|
43
|
+
}
|
|
44
|
+
declare function ItemActions({ children, className, }: PropsWithChildren & {
|
|
45
|
+
className?: string;
|
|
46
|
+
}): react_jsx_runtime.JSX.Element;
|
|
47
|
+
declare namespace ItemActions {
|
|
48
|
+
var displayName: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { Tree, TreeContext, TreeItem, TreeItemContext };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import {jsx,jsxs}from'react/jsx-runtime';import'client-only';import {Show,Hide,ChevronDown,ChevronUp,DragVert}from'@accelint/icons';import {createContext,memo,useContext,useMemo}from'react';import {TreeItemContent,TreeItem,composeRenderProps,Text,useDragAndDrop,Tree,DropIndicator}from'react-aria-components';import {Cache}from'./../../hooks/use-tree/actions/cache.js';import {Button}from'../button/index.js';import {Checkbox}from'../checkbox/index.js';import {Icon}from'../icon/index.js';import {Lines}from'../lines/index.js';import {TreeStyles,TreeStylesDefaults}from'./styles.js';const {tree:pe,item:ue,content:ye,display:fe,icon:be,label:ve,actions:Te,spacing:E,description:he,drag:Ie,expansion:Ce,visibility:ge}=TreeStyles(),x=createContext({visibilityComputedKeys:new Set,showRuleLines:true,showVisibility:false,variant:TreeStylesDefaults.variant,isStatic:true,onVisibilityChange:()=>{}}),xe=t=>jsx(DropIndicator,{target:t,className:"border border-highlight-hover"}),we=memo(function({level:s,isLastOfSet:o}){const{showRuleLines:m,variant:r}=useContext(x);return Array.from({length:s}).map((i,n)=>{const a=n===s-1?"branch":"vert",d=o&&n>0?"last":a;return jsx(Lines,{variant:d,size:r==="crammed"?"medium":"large",isVisible:m,className:E({variant:r})},n)})});function H({children:t,className:s,disabledKeys:o,dragAndDropConfig:m,expandedKeys:r,items:i,selectedKeys:n,showRuleLines:a=true,showVisibility:d=true,selectionMode:l="multiple",variant:w=TreeStylesDefaults.variant,visibleKeys:y,onVisibilityChange:K,onSelectionChange:N,...D}){if(i&&(o||r||n||y))throw new Error("Tree should only be controlled with state from either `items` or keys props, not both");if(!!i!=(typeof t=="function"))throw new Error("Tree `items` and node iterator `children` must be used together");const{dragAndDropHooks:V}=useDragAndDrop({renderDropIndicator:xe,getAllowedDropOperations:()=>["move"],getDropOperation:()=>"move",...m}),f=useMemo(()=>i?new Cache([...i]):null,[i]),c=useMemo(()=>f?.getAllNodes(),[f]),{disabledKeys:S,expandedKeys:T,selectedKeys:h,visibleKeys:A,visibilityComputedKeys:I}=useMemo(()=>{const p={disabledKeys:c?new Set:o,expandedKeys:c?new Set:r,selectedKeys:c?new Set:n,visibleKeys:c?new Set:y,visibilityComputedKeys:new Set};return c?c.reduce((b,{key:C,isDisabled:G,isExpanded:J,isSelected:Q,isVisible:X,isVisibleComputed:Y})=>(G&&b.disabledKeys?.add(C),J&&b.expandedKeys?.add(C),Q&&b.selectedKeys?.add(C),X&&b.visibleKeys?.add(C),Y&&b.visibilityComputedKeys.add(C),b),p):p},[c,o,r,n,y]),F=h?p=>{p!=="all"&&N?.(p);}:void 0;return jsx(x.Provider,{value:{disabledKeys:S,expandedKeys:T,selectedKeys:h,showRuleLines:a,showVisibility:d,variant:w,visibleKeys:A,visibilityComputedKeys:I,isStatic:typeof t!="function",onVisibilityChange:K??(()=>{})},children:jsx(Tree,{...D,className:composeRenderProps(s,p=>pe({className:p,variant:w})),disabledKeys:S,dragAndDropHooks:V,expandedKeys:T,items:i,selectedKeys:h,onSelectionChange:F,selectionMode:l,children:t})})}H.displayName="Tree";const z=createContext({isVisible:true,isViewable:true,ancestors:[]});function u({className:t,id:s,...o}){const{visibilityComputedKeys:m,visibleKeys:r,isStatic:i}=useContext(x),{ancestors:n}=useContext(z),a=m?.has(s)||i&&n.every(l=>r?.has(l)),d=r?.has(s);return jsx(z.Provider,{value:{isVisible:d,isViewable:a,ancestors:[...n,s]},children:jsx(TreeItem,{...o,id:s,className:composeRenderProps(t,l=>ue({className:l})),"data-viewable":a||null,"data-visible":d||null})})}u.displayName="Tree.Item";function M({children:t}){const{showVisibility:s,variant:o,visibleKeys:m,onVisibilityChange:r}=useContext(x),{isVisible:i,isViewable:n}=useContext(z),a=o==="cozy"?"medium":"small";return jsx(TreeItemContent,{children:d=>{const{id:l,allowsDragging:w,hasChildItems:y,level:K,selectionBehavior:N,selectionMode:D,state:V,isDisabled:f,isExpanded:c,isSelected:S}=d,T=!(V.collection.getItem(l)?.nextKey||y),h=N==="toggle"&&D!=="none",A=()=>{const I=new Set(m);m?.has(l)?I.delete(l):I.add(l),r?.(I);};return jsx(Icon.Provider,{size:a,children:jsxs("div",{className:ye({variant:o}),"data-last-of-set":T,children:[s&&jsx(Button,{variant:"icon",color:"info",size:a,onPress:A,isDisabled:f,className:ge(),children:jsx(Icon,{children:i?jsx(Show,{}):jsx(Hide,{})})}),K>1&&jsx(we,{level:K,isLastOfSet:T}),y?jsx(Button,{slot:"chevron",variant:"icon",size:a,className:Ce(),children:jsx(Icon,{children:c?jsx(ChevronDown,{}):jsx(ChevronUp,{})})}):jsx("div",{className:E({variant:o})}),jsx("div",{className:fe({variant:o}),children:typeof t=="function"?t({...d,variant:o,isVisible:i,isViewable:n,defaultChildren:null}):t}),h&&jsx(Checkbox,{slot:"selection",isSelected:S,isDisabled:f}),w&&jsx(Button,{slot:"drag",variant:"icon",size:a,isDisabled:f,className:Ie({}),children:jsx(Icon,{children:jsx(DragVert,{})})})]})})}})}M.displayName="Tree.Item.Content";function W({children:t,className:s}){return jsx(Text,{className:ve({className:s}),children:t})}W.displayName="Tree.Item.Label";function U({children:t,className:s}){const{variant:o}=useContext(x);return o!=="crammed"?jsx(Text,{"data-slot":"description",className:he({className:s,variant:o}),children:t}):null}U.displayName="Tree.Item.Description";function _({children:t,className:s}){return jsx(Icon,{className:be({className:s}),children:t})}_.displayName="Tree.Item.PrefixIcon";function q({children:t,className:s}){return jsx("div",{className:Te({className:s}),children:t})}q.displayName="Tree.Icon.Actions",H.Item=u,u.Content=M,u.Label=W,u.Description=U,u.PrefixIcon=_,u.Actions=q;export{H as Tree,x as TreeContext,u as TreeItem,z as TreeItemContext};//# sourceMappingURL=index.js.map
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/tree/index.tsx"],"names":["label","description","drag","expansion","TreeStyles","me","B","target","jsx","e","re","TreeLines","se","showRuleLines","variant","TreeContext","_","i","type","level","Lines","ce","spacing","Tree","children","className","disabledKeysProp","selectionMode","onVisibilityChange","k","onSelectionChange","items","defaultRenderDropIndicator","ae","nodes","P","le","disabledKeys","visibilityComputedKeys","acc","selectedKeysProp","visibleKeysProp","isExpanded","isSelected","isDisabled","key","isVisible","isVisibleComputed","expandedKeysProp","handleSelectionChange","selectedKeys","AriaTree","oe","O","expandedKeys","TreeItem","visibleKeys","isStatic","isViewable","ancestors","v","id","TreeItemContext","rest","item","ie","useContext","renderProps","allowsDragging","ne","state","isLastOfSet","hasChildItems","keys","size","jsxs","g","Ke","Button","handlePress","L","visibility","Hide","te","ee","ChevronUp","$","display","shouldShowSelection","j","ItemLabel","R","ItemDescription","ItemIcon","actions","ItemContent","ItemActions"],"mappings":"ukBAuDEA,MAAAA,CAAAA,IACA,CAAA,EAAA,CAAA,IACA,CAAA,EAAA,CAAA,OACA,CAAA,EAAA,CAAA,OAAAC,CAAAA,EACA,CAAA,IAAAC,CAAAA,EACA,CAAA,KAAA,CAAA,EAAA,CAAAC,OACA,CAAA,EAAA,CAAA,OACEC,CAAAA,CAAAA,CAAW,WAGb,CAAA,EAAA,CAAA,IAAA,CAAA,EAAA,CAAA,SAAwB,CAAA,EAAI,CAAA,UAC5B,CAAA,EAAA,CAAA,CAAAC,UAAe,EACf,CAAA,CAAA,CAAAC,aAAA,CAAA,CAAA,sBAC4B,CAAA,IAAA,GAC5B,CAAA,aACA,CAAA,IAAA,CAAA,cAAoB,CAAA,KAAG,CAAA,OAGWC,CAAAA,kBAAAA,CAClCC,gBAA+B,CAAA,IAAA,CAAA,kBAAU,CAAA,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAAC,GAAA,CAAAC,aAAgC,CAGrEC,CAAAA,MAAiB,CAAA,CAAA,CAAA,SACrB,CAAA,+BAMQ,CAAA,CAAA,CAAA,EAAA,CAAAC,IAAA,CAAAC,SAAe,CAAAC,KAAuBC,CAAW,CAAA,CAEzD,WAAO,CAAA,CAAM,CAAA,CAAA,CAAA,KAAO,CAAA,aAAsBC,CAAAA,CAAGC,CAAAA,OAC3C,CAAA,CAAA,CAAMC,CAAAA,UAAOD,CAAAA,CAAAA,CAAAA,CAAME,OAAY,KAAA,CAAW,IAAA,CAAA,CAAA,MACdF,CAAAA,CAAI,CAAA,CAAI,CAAA,GAAA,CAAA,CAAA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AA,SAAc,CAAA,CAAA,CAAA,OAAA,CAAA,CAAA,CAAA,CAAA,CAAA,QAE9B,CAAA,CAAA,CAASoE,CAAAA,CAAS,kBAAY,CAAA,uBACf,CAAA,SAAkB,CAAA,CAAA,CAAA,QAAU,CAAC,CAAA,CAAI,SAAArE,CAAAA,CAAS,CACzD,CACAqE,CAAAA,OAASpF,GAAA,CAAAmE,IAAA,CAAA,CAAA,SAAc,CAAA,EAAA,CAAA,CAAA,SAAA,CAEvB,CAAA,CAAA,CAAA,CAAA,QACE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,WACA,CAAA,sBAEY,CAAA,SAAWkB,CAAAA,CAAAA,CAAQ,QAAE,CAAA,CAAA,CAAArE,SAAe,CAAA,CAAA,CAAA,CAAAD,CAAAA,OAEtCf,GAAA,CAAA,KAAA,CAAA,CAAA,SAAc,CAAA,EAAA,CAAA,CAAA,SAErB,CAAA,CAAA,CAAA,CAAA,CAAO8C,QACH,CAAA,CAAA,CAAA,CAAUwC,CAAAA,CACnBxC,CAAAA,WACS,CAAA,mBACA,CAAA,CAAA,CAAA,IAAasC,CAAAA,CACtBtC,EAAS,CAAA,OAAUyC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,KAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,WAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,UAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,OAAAA,CAAAA,CAAAA","file":"index.js","sourcesContent":["/*\n * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n'use client';\n\nimport 'client-only';\nimport { ChevronDown, ChevronUp, DragVert, Hide, Show } from '@accelint/icons';\nimport {\n createContext,\n memo,\n type PropsWithChildren,\n useContext,\n useMemo,\n} from 'react';\nimport {\n Tree as AriaTree,\n TreeItem as AriaTreeItem,\n TreeItemContent as AriaTreeItemContent,\n composeRenderProps,\n DropIndicator,\n type DropTarget,\n Text,\n type TextProps,\n useDragAndDrop,\n} from 'react-aria-components';\nimport { Cache } from '@/hooks/use-tree/actions/cache';\nimport { Button } from '../button';\nimport { Checkbox } from '../checkbox';\nimport { Icon } from '../icon';\nimport { Lines } from '../lines';\nimport { TreeStyles, TreeStylesDefaults } from './styles';\nimport type { Key, Selection } from '@react-types/shared';\nimport type { IconProps } from '../icon/types';\nimport type {\n TreeContextValue,\n TreeItemContentProps,\n TreeItemContextValue,\n TreeItemProps,\n TreeProps,\n} from './types';\n\nconst {\n tree,\n item,\n content,\n display,\n icon,\n label,\n actions,\n spacing,\n description,\n drag,\n expansion,\n visibility,\n} = TreeStyles();\n\nexport const TreeContext = createContext<TreeContextValue>({\n visibilityComputedKeys: new Set(),\n showRuleLines: true,\n showVisibility: false,\n variant: TreeStylesDefaults.variant,\n isStatic: true,\n onVisibilityChange: () => undefined,\n});\n\nconst defaultRenderDropIndicator = (target: DropTarget) => (\n <DropIndicator target={target} className='border border-highlight-hover' />\n);\n\nconst TreeLines = memo(function TreeLines({\n level,\n isLastOfSet,\n}: {\n level: number;\n isLastOfSet: boolean;\n}) {\n const { showRuleLines, variant } = useContext(TreeContext);\n\n return Array.from({ length: level }).map((_, i) => {\n const type = i === level - 1 ? 'branch' : 'vert';\n const line = isLastOfSet && i > 0 ? 'last' : type;\n const size = variant === 'crammed' ? 'medium' : 'large';\n\n return (\n <Lines\n // biome-ignore lint/suspicious/noArrayIndexKey: index should be the key, only count matters\n key={i}\n variant={line}\n size={size}\n isVisible={showRuleLines}\n className={spacing({ variant })}\n />\n );\n });\n});\n\nexport function Tree<T>({\n children,\n className,\n disabledKeys: disabledKeysProp,\n dragAndDropConfig,\n expandedKeys: expandedKeysProp,\n items,\n selectedKeys: selectedKeysProp,\n showRuleLines = true,\n showVisibility = true,\n selectionMode = 'multiple',\n variant = TreeStylesDefaults.variant,\n visibleKeys: visibleKeysProp,\n onVisibilityChange,\n onSelectionChange,\n ...rest\n}: TreeProps<T>) {\n /**\n * A static collection is hard-coded. Dynamic is data-driven from an external source.\n * https://react-spectrum.adobe.com/react-aria/Tree.html#content\n *\n * Controlled state should only be used on a static tree.\n */\n if (\n items &&\n (disabledKeysProp ||\n expandedKeysProp ||\n selectedKeysProp ||\n visibleKeysProp)\n ) {\n throw new Error(\n 'Tree should only be controlled with state from either `items` or keys props, not both',\n );\n }\n\n /**\n * A static tree won't support the node iterator pattern.\n */\n if (!!items !== (typeof children === 'function')) {\n throw new Error(\n 'Tree `items` and node iterator `children` must be used together',\n );\n }\n\n const { dragAndDropHooks } = useDragAndDrop({\n renderDropIndicator: defaultRenderDropIndicator,\n getAllowedDropOperations: () => ['move'],\n getDropOperation: () => 'move',\n ...dragAndDropConfig,\n });\n const cache = useMemo(() => (items ? new Cache([...items]) : null), [items]);\n const nodes = useMemo(() => cache?.getAllNodes(), [cache]);\n const {\n disabledKeys,\n expandedKeys,\n selectedKeys,\n visibleKeys,\n visibilityComputedKeys,\n } = useMemo(() => {\n const acc = {\n disabledKeys: nodes ? new Set<Key>() : disabledKeysProp,\n expandedKeys: nodes ? new Set<Key>() : expandedKeysProp,\n selectedKeys: nodes ? new Set<Key>() : selectedKeysProp,\n visibleKeys: nodes ? new Set<Key>() : visibleKeysProp,\n visibilityComputedKeys: new Set<Key>(),\n };\n\n if (!nodes) {\n return acc;\n }\n\n return nodes.reduce(\n (\n acc,\n {\n key,\n isDisabled,\n isExpanded,\n isSelected,\n isVisible,\n isVisibleComputed,\n },\n ) => {\n if (isDisabled) {\n acc.disabledKeys?.add(key);\n }\n if (isExpanded) {\n acc.expandedKeys?.add(key);\n }\n if (isSelected) {\n acc.selectedKeys?.add(key);\n }\n if (isVisible) {\n acc.visibleKeys?.add(key);\n }\n if (isVisibleComputed) {\n acc.visibilityComputedKeys.add(key);\n }\n return acc;\n },\n acc,\n );\n }, [\n nodes,\n disabledKeysProp,\n expandedKeysProp,\n selectedKeysProp,\n visibleKeysProp,\n ]);\n\n const handleSelectionChange = selectedKeys\n ? (selection: Selection) => {\n if (selection !== 'all') {\n onSelectionChange?.(selection);\n }\n }\n : undefined;\n\n return (\n <TreeContext.Provider\n value={{\n disabledKeys,\n expandedKeys,\n selectedKeys,\n showRuleLines,\n showVisibility,\n variant,\n visibleKeys,\n visibilityComputedKeys,\n isStatic: typeof children !== 'function',\n onVisibilityChange: onVisibilityChange ?? (() => undefined), // TODO: improve\n }}\n >\n <AriaTree\n {...rest}\n className={composeRenderProps(className, (className) =>\n tree({ className, variant }),\n )}\n disabledKeys={disabledKeys}\n dragAndDropHooks={dragAndDropHooks}\n expandedKeys={expandedKeys}\n items={items}\n selectedKeys={selectedKeys}\n onSelectionChange={handleSelectionChange}\n selectionMode={selectionMode}\n >\n {children}\n </AriaTree>\n </TreeContext.Provider>\n );\n}\nTree.displayName = 'Tree';\n\nexport const TreeItemContext = createContext<TreeItemContextValue>({\n isVisible: true,\n isViewable: true,\n ancestors: [],\n});\n\nexport function TreeItem({ className, id, ...rest }: TreeItemProps) {\n const { visibilityComputedKeys, visibleKeys, isStatic } =\n useContext(TreeContext);\n const { ancestors } = useContext(TreeItemContext);\n const isViewable =\n visibilityComputedKeys?.has(id) ||\n (isStatic && ancestors.every((key) => visibleKeys?.has(key)));\n const isVisible = visibleKeys?.has(id);\n\n return (\n <TreeItemContext.Provider\n value={{\n isVisible,\n isViewable,\n ancestors: [...ancestors, id],\n }}\n >\n <AriaTreeItem\n {...rest}\n id={id}\n className={composeRenderProps(className, (className) =>\n item({ className }),\n )}\n data-viewable={isViewable || null}\n data-visible={isVisible || null}\n />\n </TreeItemContext.Provider>\n );\n}\nTreeItem.displayName = 'Tree.Item';\n\nfunction ItemContent({ children }: TreeItemContentProps) {\n const { showVisibility, variant, visibleKeys, onVisibilityChange } =\n useContext(TreeContext);\n const { isVisible, isViewable } = useContext(TreeItemContext);\n const size = variant === 'cozy' ? 'medium' : 'small';\n\n return (\n <AriaTreeItemContent>\n {(renderProps) => {\n const {\n id,\n allowsDragging,\n hasChildItems,\n level,\n selectionBehavior,\n selectionMode,\n state,\n isDisabled,\n isExpanded,\n isSelected,\n } = renderProps;\n\n const isLastOfSet = !(\n state.collection.getItem(id)?.nextKey || hasChildItems\n );\n const shouldShowSelection =\n selectionBehavior === 'toggle' && selectionMode !== 'none';\n\n const handlePress = () => {\n const keys = new Set<Key>(visibleKeys);\n visibleKeys?.has(id) ? keys.delete(id) : keys.add(id);\n onVisibilityChange?.(keys);\n };\n\n return (\n <Icon.Provider size={size}>\n <div\n className={content({ variant })}\n data-last-of-set={isLastOfSet}\n >\n {showVisibility && (\n <Button\n variant='icon'\n color='info'\n size={size}\n onPress={handlePress}\n isDisabled={isDisabled}\n className={visibility()}\n >\n <Icon>{isVisible ? <Show /> : <Hide />}</Icon>\n </Button>\n )}\n {level > 1 && (\n <TreeLines level={level} isLastOfSet={isLastOfSet} />\n )}\n {hasChildItems ? (\n <Button\n slot='chevron'\n variant='icon'\n size={size}\n className={expansion()}\n >\n <Icon>{isExpanded ? <ChevronDown /> : <ChevronUp />}</Icon>\n </Button>\n ) : (\n <div className={spacing({ variant })} />\n )}\n <div className={display({ variant })}>\n {typeof children === 'function'\n ? children({\n ...renderProps,\n variant,\n isVisible,\n isViewable: isViewable,\n defaultChildren: null,\n })\n : children}\n </div>\n {shouldShowSelection && (\n <Checkbox\n slot='selection'\n isSelected={isSelected}\n isDisabled={isDisabled}\n />\n )}\n {allowsDragging && (\n <Button\n slot='drag'\n variant='icon'\n size={size}\n isDisabled={isDisabled}\n className={drag({})}\n >\n <Icon>\n <DragVert />\n </Icon>\n </Button>\n )}\n </div>\n </Icon.Provider>\n );\n }}\n </AriaTreeItemContent>\n );\n}\nItemContent.displayName = 'Tree.Item.Content';\n\nfunction ItemLabel({ children, className }: TextProps) {\n return <Text className={label({ className })}>{children}</Text>;\n}\nItemLabel.displayName = 'Tree.Item.Label';\n\nfunction ItemDescription({ children, className }: TextProps) {\n const { variant } = useContext(TreeContext);\n\n return variant !== 'crammed' ? (\n <Text\n data-slot='description'\n className={description({ className, variant })}\n >\n {children}\n </Text>\n ) : null;\n}\nItemDescription.displayName = 'Tree.Item.Description';\n\nfunction ItemIcon({ children, className }: IconProps) {\n return <Icon className={icon({ className })}>{children}</Icon>;\n}\nItemIcon.displayName = 'Tree.Item.PrefixIcon';\n\nfunction ItemActions({\n children,\n className,\n}: PropsWithChildren & { className?: string }) {\n return <div className={actions({ className })}>{children}</div>;\n}\nItemActions.displayName = 'Tree.Icon.Actions';\n\nTree.Item = TreeItem;\nTreeItem.Content = ItemContent;\nTreeItem.Label = ItemLabel;\nTreeItem.Description = ItemDescription;\nTreeItem.PrefixIcon = ItemIcon;\nTreeItem.Actions = ItemActions;\n"]}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import * as tailwind_variants from 'tailwind-variants';
|
|
2
|
+
|
|
3
|
+
declare const TreeStylesDefaults: {
|
|
4
|
+
readonly variant: "cozy";
|
|
5
|
+
};
|
|
6
|
+
declare const TreeStyles: tailwind_variants.TVReturnType<{
|
|
7
|
+
variant: {
|
|
8
|
+
cozy: {
|
|
9
|
+
content: string;
|
|
10
|
+
display: string;
|
|
11
|
+
label: string;
|
|
12
|
+
actions: string;
|
|
13
|
+
spacing: string;
|
|
14
|
+
item: string;
|
|
15
|
+
};
|
|
16
|
+
compact: {
|
|
17
|
+
content: string;
|
|
18
|
+
display: string;
|
|
19
|
+
label: string;
|
|
20
|
+
actions: string;
|
|
21
|
+
spacing: string;
|
|
22
|
+
item: string;
|
|
23
|
+
};
|
|
24
|
+
crammed: {
|
|
25
|
+
content: string;
|
|
26
|
+
display: string;
|
|
27
|
+
label: string;
|
|
28
|
+
actions: string;
|
|
29
|
+
spacing: string;
|
|
30
|
+
item: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
}, {
|
|
34
|
+
tree: string;
|
|
35
|
+
item: string[];
|
|
36
|
+
content: string[];
|
|
37
|
+
display: string;
|
|
38
|
+
icon: string;
|
|
39
|
+
label: string;
|
|
40
|
+
description: string;
|
|
41
|
+
actions: string;
|
|
42
|
+
spacing: string;
|
|
43
|
+
visibility: string[];
|
|
44
|
+
expansion: string[];
|
|
45
|
+
drag: string[];
|
|
46
|
+
}, undefined, {
|
|
47
|
+
variant: {
|
|
48
|
+
cozy: {
|
|
49
|
+
content: string;
|
|
50
|
+
display: string;
|
|
51
|
+
label: string;
|
|
52
|
+
actions: string;
|
|
53
|
+
spacing: string;
|
|
54
|
+
item: string;
|
|
55
|
+
};
|
|
56
|
+
compact: {
|
|
57
|
+
content: string;
|
|
58
|
+
display: string;
|
|
59
|
+
label: string;
|
|
60
|
+
actions: string;
|
|
61
|
+
spacing: string;
|
|
62
|
+
item: string;
|
|
63
|
+
};
|
|
64
|
+
crammed: {
|
|
65
|
+
content: string;
|
|
66
|
+
display: string;
|
|
67
|
+
label: string;
|
|
68
|
+
actions: string;
|
|
69
|
+
spacing: string;
|
|
70
|
+
item: string;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
}, {
|
|
74
|
+
tree: string;
|
|
75
|
+
item: string[];
|
|
76
|
+
content: string[];
|
|
77
|
+
display: string;
|
|
78
|
+
icon: string;
|
|
79
|
+
label: string;
|
|
80
|
+
description: string;
|
|
81
|
+
actions: string;
|
|
82
|
+
spacing: string;
|
|
83
|
+
visibility: string[];
|
|
84
|
+
expansion: string[];
|
|
85
|
+
drag: string[];
|
|
86
|
+
}, tailwind_variants.TVReturnType<{
|
|
87
|
+
variant: {
|
|
88
|
+
cozy: {
|
|
89
|
+
content: string;
|
|
90
|
+
display: string;
|
|
91
|
+
label: string;
|
|
92
|
+
actions: string;
|
|
93
|
+
spacing: string;
|
|
94
|
+
item: string;
|
|
95
|
+
};
|
|
96
|
+
compact: {
|
|
97
|
+
content: string;
|
|
98
|
+
display: string;
|
|
99
|
+
label: string;
|
|
100
|
+
actions: string;
|
|
101
|
+
spacing: string;
|
|
102
|
+
item: string;
|
|
103
|
+
};
|
|
104
|
+
crammed: {
|
|
105
|
+
content: string;
|
|
106
|
+
display: string;
|
|
107
|
+
label: string;
|
|
108
|
+
actions: string;
|
|
109
|
+
spacing: string;
|
|
110
|
+
item: string;
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
}, {
|
|
114
|
+
tree: string;
|
|
115
|
+
item: string[];
|
|
116
|
+
content: string[];
|
|
117
|
+
display: string;
|
|
118
|
+
icon: string;
|
|
119
|
+
label: string;
|
|
120
|
+
description: string;
|
|
121
|
+
actions: string;
|
|
122
|
+
spacing: string;
|
|
123
|
+
visibility: string[];
|
|
124
|
+
expansion: string[];
|
|
125
|
+
drag: string[];
|
|
126
|
+
}, undefined, unknown, unknown>>;
|
|
127
|
+
|
|
128
|
+
export { TreeStyles, TreeStylesDefaults };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {tv}from'./../../lib/utils.js';const t={variant:"cozy"},a=tv({slots:{tree:"overflow-auto outline-hidden",item:["not-visible:fg-primary-muted not-viewable:fg-primary-muted fg-primary-bold px-s","group/tree-item rounded-medium hover:bg-interactive-muted-hover","drop-target:border drop-target:bg-accent-primary-muted/20 drop-target:outline-accent-primary-bold","disabled:cursor-not-allowed disabled:border-none disabled:hover:bg-transparent disabled:data-[drop-target=true]:bg-transparent"],content:["flex items-center justify-items-start px-xs","overflow-x group w-full outline-hidden"],display:'grid flex-1 grid-cols-[auto_auto_1fr_auto] items-center [grid-template-areas:"icon_label_space_action"_"icon_description_space_action"]',icon:"[grid-area:icon]",label:"not-has-[+[data-slot=description]]:row-span-full [grid-area:label]",description:"fg-primary-muted text-body-s [grid-area:description]",actions:"flex shrink-0 items-center [grid-area:action]",spacing:"",visibility:["group-not-visible/tree-item:enabled:color-info:fg-primary-muted","group-not-viewable/tree-item:enabled:color-info:fg-primary-muted fg-primary-bold","fg-primary-bold"],expansion:["group-not-visible/tree-item:enabled:color-info:fg-primary-muted","group-not-viewable/tree-item:enabled:color-info:fg-primary-muted fg-primary-bold","fg-primary-bold"],drag:["group-not-visible/tree-item:enabled:color-info:fg-primary-muted","group-not-viewable/tree-item:enabled:color-info:fg-primary-muted fg-primary-bold","fg-primary-bold"]},variants:{variant:{cozy:{content:"min-h-[48px] text-header-m",display:"gap-x-s px-xs",label:"gap-xs",actions:"gap-x-xs",spacing:"min-h-[46px] w-[28px]",item:"min-h-s"},compact:{content:"min-h-[36px] gap-xs text-header-s",display:"gap-x-s px-xxs",label:"gap-xs",actions:"gap-x-xxs",spacing:"min-h-[38px] w-[20px]",item:"min-h-l"},crammed:{content:"gap-xs text-header-s",display:"gap-x-xs px-xxs",label:"gap-xs",actions:"gap-x-xxs",spacing:"min-h-xl w-[20px]",item:"min-h-s"}}},defaultVariants:t});export{a as TreeStyles,t as TreeStylesDefaults};//# sourceMappingURL=styles.js.map
|
|
2
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/tree/styles.ts"],"names":["TreeStyles","tv","e"],"mappings":"sCAeE,MAAA,CAAS,CAAA,CAAA,OAGEA,CAAaC,SACjB,CACLC,EAAA,CAAA,CAAA,KAAM,CAAA,CAAA,IAAA,CAAA,8BAEJ,CAAA,IAAA,CAAA,CAAA,iFACA,CAAA,iEACA,CAAA,mGACA,CAAA,gIAEO,CACP,CAAA,OAAA,CAAA,CAAA,6CACA,CAAA,wCAGA,CAAA,CAAA,OAAA,CAAA,yIACI,CAAA,IAAA,CAAA,kBACC,CAAA,KAAA,CAAA,gFACM,CAAA,sDACJ,CAAA,OAAA,CAAA,+CACA,CAAA,OACT,CAAA,EAAA,CAAA,UACE,CAAA,CAAA,iEACA,CAAA,kFACA,CAAA,iBAEF,CAAA,CAAW,SACT,CAAA,CAAA,iEACA,CAAA,kFACA,CAAA,iBAGA,CAAA,CAAA,IAAA,CAAA,CAAA,iEACA,CAAA,oGAIJ,CAAA,CAAU,CACR,QAAS,CACP,QACE,CAAA,CAAA,IAAS,CAAA,CAAA,OAAA,CAAA,4BACA,CAAA,OAAA,CAAA,qBAET,CAAA,QAAS,CAAA,OAAA,CAAA,UACA,CAAA,OAAA,CAAA,uBACH,CAAA,IACR,CAAA,SACS,CACP,CAAA,OAAS,CAAA,CAAA,OAAA,CAAA,mCACA,CAAA,OAAA,CAAA,sBAET,CAAA,QAAS,CAAA,OAAA,CAAA,WACA,CAAA,OAAA,CAAA,uBACH,CAAA,IACR,UACS,CACP,CAAA,OAAS,CAAA,CAAA,OAAA,CAAA,sBACA,CAAA,OAAA,CAAA,iBACF,CAAA,KACP,CAAA,QAAS,CAAA,OAAA,CAAA,WACA,CAAA,OAAA,CAAA,mBACH,CAAA,IACR,CACF,SAEF,CAAA,CAAA,CAAA,CAAA,eACD,CAAA,CAAA,CAAA","file":"styles.js","sourcesContent":["/*\n * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { tv } from '@/lib/utils';\n\nexport const TreeStylesDefaults = {\n variant: 'cozy',\n} as const;\n\nexport const TreeStyles = tv({\n slots: {\n tree: 'overflow-auto outline-hidden',\n item: [\n 'not-visible:fg-primary-muted not-viewable:fg-primary-muted fg-primary-bold px-s',\n 'group/tree-item rounded-medium hover:bg-interactive-muted-hover',\n 'drop-target:border drop-target:bg-accent-primary-muted/20 drop-target:outline-accent-primary-bold',\n 'disabled:cursor-not-allowed disabled:border-none disabled:hover:bg-transparent disabled:data-[drop-target=true]:bg-transparent',\n ],\n content: [\n 'flex items-center justify-items-start px-xs',\n 'overflow-x group w-full outline-hidden',\n ],\n display:\n 'grid flex-1 grid-cols-[auto_auto_1fr_auto] items-center [grid-template-areas:\"icon_label_space_action\"_\"icon_description_space_action\"]',\n icon: '[grid-area:icon]',\n label: 'not-has-[+[data-slot=description]]:row-span-full [grid-area:label]',\n description: 'fg-primary-muted text-body-s [grid-area:description]',\n actions: 'flex shrink-0 items-center [grid-area:action]',\n spacing: '',\n visibility: [\n 'group-not-visible/tree-item:enabled:color-info:fg-primary-muted',\n 'group-not-viewable/tree-item:enabled:color-info:fg-primary-muted fg-primary-bold',\n 'fg-primary-bold',\n ],\n expansion: [\n 'group-not-visible/tree-item:enabled:color-info:fg-primary-muted',\n 'group-not-viewable/tree-item:enabled:color-info:fg-primary-muted fg-primary-bold',\n 'fg-primary-bold',\n ],\n drag: [\n 'group-not-visible/tree-item:enabled:color-info:fg-primary-muted',\n 'group-not-viewable/tree-item:enabled:color-info:fg-primary-muted fg-primary-bold',\n 'fg-primary-bold',\n ],\n },\n variants: {\n variant: {\n cozy: {\n content: 'min-h-[48px] text-header-m',\n display: 'gap-x-s px-xs',\n label: 'gap-xs',\n actions: 'gap-x-xs',\n spacing: 'min-h-[46px] w-[28px]',\n item: 'min-h-s',\n },\n compact: {\n content: 'min-h-[36px] gap-xs text-header-s',\n display: 'gap-x-s px-xxs',\n label: 'gap-xs',\n actions: 'gap-x-xxs',\n spacing: 'min-h-[38px] w-[20px]',\n item: 'min-h-l',\n },\n crammed: {\n content: 'gap-xs text-header-s',\n display: 'gap-x-xs px-xxs',\n label: 'gap-xs',\n actions: 'gap-x-xxs',\n spacing: 'min-h-xl w-[20px]',\n item: 'min-h-s',\n },\n },\n },\n defaultVariants: TreeStylesDefaults,\n});\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Key } from '@react-types/shared';
|
|
2
|
+
import { TreeProps as TreeProps$1, TreeItemProps as TreeItemProps$1, RenderProps, TreeItemContentRenderProps as TreeItemContentRenderProps$1 } from 'react-aria-components';
|
|
3
|
+
import { VariantProps } from 'tailwind-variants';
|
|
4
|
+
import { TreeNode, DragAndDropConfig } from '../../hooks/use-tree/types.js';
|
|
5
|
+
import { TreeStyles } from './styles.js';
|
|
6
|
+
import 'react';
|
|
7
|
+
|
|
8
|
+
type TreeProps<T> = Omit<TreeProps$1<TreeNode<T>>, 'defaultExpandedKeys' | 'defaultSelectedKeys' | 'disabledKeys' | 'expandedKeys' | 'selectedKeys' | 'onSelectionChange'> & VariantProps<typeof TreeStyles> & {
|
|
9
|
+
disabledKeys?: Set<Key>;
|
|
10
|
+
dragAndDropConfig?: DragAndDropConfig;
|
|
11
|
+
expandedKeys?: Set<Key>;
|
|
12
|
+
selectedKeys?: Set<Key>;
|
|
13
|
+
visibleKeys?: Set<Key>;
|
|
14
|
+
showRuleLines?: boolean;
|
|
15
|
+
showVisibility?: boolean;
|
|
16
|
+
onVisibilityChange?: (keys: Set<Key>) => void;
|
|
17
|
+
onSelectionChange?: (keys: Set<Key>) => void;
|
|
18
|
+
};
|
|
19
|
+
type TreeItemProps = Omit<TreeItemProps$1, 'id'> & {
|
|
20
|
+
id: Key;
|
|
21
|
+
};
|
|
22
|
+
type TreeItemContentProps = Pick<RenderProps<TreeItemContentRenderProps>, 'children'>;
|
|
23
|
+
type TreeItemContentRenderProps = TreeItemContentRenderProps$1 & VariantProps<typeof TreeStyles> & {
|
|
24
|
+
isViewable?: boolean;
|
|
25
|
+
isVisible?: boolean;
|
|
26
|
+
};
|
|
27
|
+
type TreeContextValue = Required<Pick<TreeProps<unknown>, 'showRuleLines' | 'showVisibility' | 'variant' | 'onVisibilityChange'>> & {
|
|
28
|
+
disabledKeys?: Set<Key>;
|
|
29
|
+
expandedKeys?: Set<Key>;
|
|
30
|
+
selectedKeys?: Set<Key>;
|
|
31
|
+
visibleKeys?: Set<Key>;
|
|
32
|
+
visibilityComputedKeys?: Set<Key>;
|
|
33
|
+
isStatic: boolean;
|
|
34
|
+
};
|
|
35
|
+
type TreeItemContextValue = {
|
|
36
|
+
isVisible?: boolean;
|
|
37
|
+
isViewable?: boolean;
|
|
38
|
+
ancestors: Key[];
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export type { TreeContextValue, TreeItemContentProps, TreeItemContentRenderProps, TreeItemContextValue, TreeItemProps, TreeProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"types.js"}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
1
3
|
import {jsx}from'react/jsx-runtime';import'client-only';import {Broadcast}from'@accelint/bus';import {isUUID}from'@accelint/core';import {createContext,useRef,useState,useCallback,useEffect,useContext}from'react';import {Pressable}from'react-aria-components';import {ViewStackEventTypes}from'./events.js';const u=Broadcast.getInstance(),p=createContext({parent:null,stack:[],view:null,register:()=>{},unregister:()=>{}}),T={back:e=>u.emit(ViewStackEventTypes.back,{stack:e}),clear:e=>u.emit(ViewStackEventTypes.clear,{stack:e}),push:e=>u.emit(ViewStackEventTypes.push,{view:e}),reset:e=>u.emit(ViewStackEventTypes.reset,{stack:e})};function P({children:e,for:k}){const{parent:r}=useContext(p);function i(){for(const n of Array.isArray(k)?k:[k]){let[s,a]=isUUID(n)?["push",n]:n.split(":");a??=r,a&&T[s](a);}}return jsx(Pressable,{onPress:i,children:e})}P.displayName="ViewStack.Trigger";function y({id:e,children:k}){const{parent:r,view:i,register:n,unregister:s}=useContext(p);if(!r)throw new Error("ViewStack.View must be implemented within a ViewStack");if(!isUUID(e))throw new Error("ViewStack.View's id must be a UniqueId");return useEffect(()=>{n(e);},[n,s,e]),i===e?k:null}y.displayName="ViewStack.View";function S({id:e,children:k,defaultView:r,onChange:i}){if(!isUUID(e))throw new Error("ViewStack's id must be a UniqueId");const n=useRef(new Set),[s,a]=useState(r?[r]:[]),U=s.at(-1)??null,V=useCallback(t=>{if(e===t?.payload?.stack){const c=s.slice(0,-1);!c.length&&r&&c.push(r),a(c),i?.(c.at(-1)??null);}},[e,r,i,s]),f=useCallback(t=>{e===t?.payload?.stack&&(a([]),i?.(null));},[e,i]),m=useCallback(t=>{n.current.has(t?.payload?.view)&&(a(c=>[...c,t?.payload?.view]),i?.(t?.payload?.view));},[i]),v=useCallback(t=>{e===t?.payload?.stack&&(a(r?[r]:[]),i?.(r??null));},[e,r,i]);return useEffect(()=>{const t=[u.on(ViewStackEventTypes.back,V),u.on(ViewStackEventTypes.clear,f),u.on(ViewStackEventTypes.push,m),u.on(ViewStackEventTypes.reset,v)];return ()=>{for(const c of t)c();}},[V,f,m,v]),jsx(p.Provider,{value:{parent:e,stack:s,view:U,register:t=>n.current.add(t),unregister:t=>n.current.delete(t)},children:k})}S.displayName="ViewStack",S.View=y,S.Trigger=P;export{S as ViewStack,p as ViewStackContext,T as ViewStackEventHandlers};//# sourceMappingURL=index.js.map
|
|
2
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/view-stack/index.tsx"],"names":["Broadcast","h","ViewStackContext","createContext","q","ViewStackEventHandlers","bus","o","types","useContext","d","type","event","isUUID","l","id","parent","I","x","ViewStackTrigger","E","register","unregister","view","b","stack","setStack","useState","defaultView","g","useCallback","data","next","onChange","handleClear","handlePush","views","prev","handleReset","ViewStackEventTypes","off","listeners","handleBack","jsx","ViewStack"],"mappings":"iTAsCYA,MAAU,CAAA,CAAAC,SAAA,CAAA,WAETC,EAAmBC,CAAqC,CACnE,CAAAC,aAAA,CAAA,CAAA,MAAQ,CAAA,IACR,CAAA,KACA,CAAA,EAAA,CAAA,IAAM,CAAA,IACN,CAAA,QAAU,CAAG,IACb,CAAA,CAAA,CAAA,UAAY,CAAG,IAChB,CAEYC,CAAAA,CAAyB,CACpC,CAAA,CAAA,CAAA,C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CAAI,CAAA,CAAA,CAAGiC,CAAAA,EAAoB,CAAAhC,mBAAA,CAAA,KAC3BD,CAAAA,CAAI,CAAA,CAAA,CAAGiC,CAAAA,EAAoB,CAAAhC,mBAAA,CAAA,IAC3BD,CAAAA,CAAI,GAAGiC,CAAAA,EAAoB,CAAAhC,mBAAA,CAAA,KAC7B,CAEA,CAAA,CAAA,CAAA,CAAA,OAAa,IACX,CAAA,IAAA,MAAWiC,CAAOC,IACZ,CAER,CACF,CAAA,GAAIC,CAAAA,CAAYR,CAAAA,CAAaC,CAAAA,CAAYG,CAAW,CAAC,CAAA,CAGnDK,CAAAA,CAACzC,CAAAA,CAAiBe,GAAA,CAAA,CAAA,CAAA,QAChB,CAAA,CAAA,KACE,CAAA,CAAA,MACA,CAAA,CAAA,CAAA,KACA,CAAA,CAAA,CAAA,IACA,CAAA,CAAA,CAAA,QAA8BmB,CAAAA,CAAM,EAAA,CAAA,CAAA,OAAQ,CAAIb,GAChD,CAAA,CAAA,CAAA,CAAA,UAAgCa,CAAAA,CAAM,EAAA,CAAA,CAAA,OAAQ,CAAA,MAChD,CAEC,CAAA,CAAA,CAAA,CAAA,QAGP,CACAQ,CAAAA,CAAU,CAAA,CAAA,CAAA,CAAA,WAAc,CAAA,WACd,CAAA,CAAA,CAAA,IACVA,CAAU,CAAA,CAAA,CAAA,CAAA,OAAUzB,CAAAA,CAAAA","file":"index.js","sourcesContent":["/*\n * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n'use client';\n\nimport 'client-only';\nimport { Broadcast } from '@accelint/bus';\nimport { type UniqueId, isUUID } from '@accelint/core';\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from 'react';\nimport { Pressable } from 'react-aria-components';\nimport { ViewStackEventTypes } from './events';\nimport type {\n ViewStackBackEvent,\n ViewStackClearEvent,\n ViewStackContextValue,\n ViewStackEvent,\n ViewStackProps,\n ViewStackPushEvent,\n ViewStackResetEvent,\n ViewStackTriggerProps,\n ViewStackViewProps,\n} from './types';\n\nconst bus = Broadcast.getInstance<ViewStackEvent>();\n\nexport const ViewStackContext = createContext<ViewStackContextValue>({\n parent: null,\n stack: [],\n view: null,\n register: () => undefined,\n unregister: () => undefined,\n});\n\nexport const ViewStackEventHandlers = {\n back: (stack: UniqueId) => bus.emit(ViewStackEventTypes.back, { stack }),\n clear: (stack: UniqueId) => bus.emit(ViewStackEventTypes.clear, { stack }),\n push: (view: UniqueId) => bus.emit(ViewStackEventTypes.push, { view }),\n reset: (stack: UniqueId) => bus.emit(ViewStackEventTypes.reset, { stack }),\n} as const;\n\nfunction ViewStackTrigger({ children, for: types }: ViewStackTriggerProps) {\n const { parent } = useContext(ViewStackContext);\n\n function handlePress() {\n for (const type of Array.isArray(types) ? types : [types]) {\n let [event, id] = (isUUID(type) ? ['push', type] : type.split(':')) as [\n 'back' | 'clear' | 'reset' | 'push',\n UniqueId | undefined | null,\n ];\n\n id ??= parent;\n\n if (!id) {\n continue;\n }\n\n ViewStackEventHandlers[event](id);\n }\n }\n\n return <Pressable onPress={handlePress}>{children}</Pressable>;\n}\nViewStackTrigger.displayName = 'ViewStack.Trigger';\n\nfunction ViewStackView({ id, children }: ViewStackViewProps) {\n const { parent, view, register, unregister } = useContext(ViewStackContext);\n\n if (!parent) {\n throw new Error('ViewStack.View must be implemented within a ViewStack');\n }\n\n if (!isUUID(id)) {\n throw new Error(`ViewStack.View's id must be a UniqueId`);\n }\n\n useEffect(() => {\n register(id);\n\n () => unregister(id);\n }, [register, unregister, id]);\n\n return view === id ? children : null;\n}\nViewStackView.displayName = 'ViewStack.View';\n\nexport function ViewStack({\n id,\n children,\n defaultView,\n onChange,\n}: ViewStackProps) {\n if (!isUUID(id)) {\n throw new Error(`ViewStack's id must be a UniqueId`);\n }\n\n const views = useRef(new Set<UniqueId>());\n const [stack, setStack] = useState<UniqueId[]>(\n defaultView ? [defaultView] : [],\n );\n const view = stack.at(-1) ?? null;\n\n const handleBack = useCallback(\n (data: ViewStackBackEvent) => {\n if (id === data?.payload?.stack) {\n const next = stack.slice(0, -1);\n\n if (!next.length && defaultView) {\n next.push(defaultView);\n }\n\n setStack(next);\n onChange?.(next.at(-1) ?? null);\n }\n },\n [id, defaultView, onChange, stack],\n );\n\n const handleClear = useCallback(\n (data: ViewStackClearEvent) => {\n if (id === data?.payload?.stack) {\n setStack([]);\n onChange?.(null);\n }\n },\n [id, onChange],\n );\n\n const handlePush = useCallback(\n (data: ViewStackPushEvent) => {\n if (views.current.has(data?.payload?.view)) {\n setStack((prev) => [...prev, data?.payload?.view]);\n onChange?.(data?.payload?.view);\n }\n },\n [onChange],\n );\n\n const handleReset = useCallback(\n (data: ViewStackResetEvent) => {\n if (id === data?.payload?.stack) {\n setStack(defaultView ? [defaultView] : []);\n onChange?.(defaultView ?? null);\n }\n },\n [id, defaultView, onChange],\n );\n\n useEffect(() => {\n const listeners = [\n bus.on(ViewStackEventTypes.back, handleBack),\n bus.on(ViewStackEventTypes.clear, handleClear),\n bus.on(ViewStackEventTypes.push, handlePush),\n bus.on(ViewStackEventTypes.reset, handleReset),\n ];\n\n return () => {\n for (const off of listeners) {\n off();\n }\n };\n }, [handleBack, handleClear, handlePush, handleReset]);\n\n return (\n <ViewStackContext.Provider\n value={{\n parent: id,\n stack,\n view,\n register: (view: UniqueId) => views.current.add(view),\n unregister: (view: UniqueId) => views.current.delete(view),\n }}\n >\n {children}\n </ViewStackContext.Provider>\n );\n}\nViewStack.displayName = 'ViewStack';\nViewStack.View = ViewStackView;\nViewStack.Trigger = ViewStackTrigger;\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/view-stack/index.tsx"],"names":["Broadcast","h","ViewStackContext","createContext","q","ViewStackEventHandlers","bus","o","types","useContext","d","type","event","isUUID","l","id","parent","I","x","ViewStackTrigger","E","register","unregister","view","b","stack","setStack","useState","defaultView","g","useCallback","data","next","onChange","handleClear","handlePush","views","prev","handleReset","ViewStackEventTypes","off","listeners","handleBack","jsx","ViewStack"],"mappings":"iTAsCYA,MAAU,CAAA,CAAAC,SAAA,CAAA,WAETC,EAAmBC,CAAqC,CACnE,CAAAC,aAAA,CAAA,CAAA,MAAQ,CAAA,IACR,CAAA,KACA,CAAA,EAAA,CAAA,IAAM,CAAA,IACN,CAAA,QAAU,CAAG,IACb,CAAA,CAAA,CAAA,UAAY,CAAG,IAChB,CAEYC,CAAAA,CAAyB,CACpC,CAAA,CAAA,CAAA,CAAA,IAA2BC,CAAAA,CAAI,EAAA,CAAA,CAAA,IAAyB,CAAAC,mBAAA,CAAA,IAAQ,CAAA,CAAA,KAAO,CACvE,CAAA,CAAA,CAAA,CAAA,KAA4BD,CAAAA,CAAI,EAAA,CAAA,CAAA,IAAyB,CAAAC,mBAAA,CAAA,KAAS,CAAA,CAAA,KAAO,CACzE,CAAA,CAAA,CAAA,CAAA,IAA0BD,CAAAA,CAAI,EAAA,CAAA,CAAA,IAAyB,CAAAC,mBAAA,CAAA,IAAQ,CAAA,CAAA,KAC/D,CAAA,CAAA,CAAA,CAAA,KAA4BD,CAAAA,CAAI,EAAA,CAAA,CAAA,IAAyB,CAAAC,mBAAA,CAAA,KAAS,CAAA,CAAA,KACpE,CAAA,CAEA,CAAA,CAAA,EAAA,SAA4B,CAAA,CAAA,CAAA,QAAU,CAAA,CAAA,CAAKC,GAAgC,CACzE,CAAA,CAAA,CAAA,CAAA,KAAQ,CAAA,MAAWC,CAAAA,CAAWP,CAAgB,CAAAQ,UAE9C,CAAA,CAAA,CAAA,CAAA,SACE,CAAA,EAAA,CAAA,IAAA,MAAWC,CAAQ,IAAA,KAAM,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QAGP,CACAQ,CAAAA,CAAU,CAAA,CAAA,CAAA,CAAA,WAAc,CAAA,WACd,CAAA,CAAA,CAAA,IACVA,CAAU,CAAA,CAAA,CAAA,CAAA,OAAUzB,CAAAA,CAAAA","file":"index.js","sourcesContent":["/*\n * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n'use client';\n\nimport 'client-only';\nimport { Broadcast } from '@accelint/bus';\nimport { isUUID, type UniqueId } from '@accelint/core';\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from 'react';\nimport { Pressable } from 'react-aria-components';\nimport { ViewStackEventTypes } from './events';\nimport type {\n ViewStackBackEvent,\n ViewStackClearEvent,\n ViewStackContextValue,\n ViewStackEvent,\n ViewStackProps,\n ViewStackPushEvent,\n ViewStackResetEvent,\n ViewStackTriggerProps,\n ViewStackViewProps,\n} from './types';\n\nconst bus = Broadcast.getInstance<ViewStackEvent>();\n\nexport const ViewStackContext = createContext<ViewStackContextValue>({\n parent: null,\n stack: [],\n view: null,\n register: () => undefined,\n unregister: () => undefined,\n});\n\nexport const ViewStackEventHandlers = {\n back: (stack: UniqueId) => bus.emit(ViewStackEventTypes.back, { stack }),\n clear: (stack: UniqueId) => bus.emit(ViewStackEventTypes.clear, { stack }),\n push: (view: UniqueId) => bus.emit(ViewStackEventTypes.push, { view }),\n reset: (stack: UniqueId) => bus.emit(ViewStackEventTypes.reset, { stack }),\n} as const;\n\nfunction ViewStackTrigger({ children, for: types }: ViewStackTriggerProps) {\n const { parent } = useContext(ViewStackContext);\n\n function handlePress() {\n for (const type of Array.isArray(types) ? types : [types]) {\n let [event, id] = (isUUID(type) ? ['push', type] : type.split(':')) as [\n 'back' | 'clear' | 'reset' | 'push',\n UniqueId | undefined | null,\n ];\n\n id ??= parent;\n\n if (!id) {\n continue;\n }\n\n ViewStackEventHandlers[event](id);\n }\n }\n\n return <Pressable onPress={handlePress}>{children}</Pressable>;\n}\nViewStackTrigger.displayName = 'ViewStack.Trigger';\n\nfunction ViewStackView({ id, children }: ViewStackViewProps) {\n const { parent, view, register, unregister } = useContext(ViewStackContext);\n\n if (!parent) {\n throw new Error('ViewStack.View must be implemented within a ViewStack');\n }\n\n if (!isUUID(id)) {\n throw new Error(`ViewStack.View's id must be a UniqueId`);\n }\n\n useEffect(() => {\n register(id);\n\n () => unregister(id);\n }, [register, unregister, id]);\n\n return view === id ? children : null;\n}\nViewStackView.displayName = 'ViewStack.View';\n\nexport function ViewStack({\n id,\n children,\n defaultView,\n onChange,\n}: ViewStackProps) {\n if (!isUUID(id)) {\n throw new Error(`ViewStack's id must be a UniqueId`);\n }\n\n const views = useRef(new Set<UniqueId>());\n const [stack, setStack] = useState<UniqueId[]>(\n defaultView ? [defaultView] : [],\n );\n const view = stack.at(-1) ?? null;\n\n const handleBack = useCallback(\n (data: ViewStackBackEvent) => {\n if (id === data?.payload?.stack) {\n const next = stack.slice(0, -1);\n\n if (!next.length && defaultView) {\n next.push(defaultView);\n }\n\n setStack(next);\n onChange?.(next.at(-1) ?? null);\n }\n },\n [id, defaultView, onChange, stack],\n );\n\n const handleClear = useCallback(\n (data: ViewStackClearEvent) => {\n if (id === data?.payload?.stack) {\n setStack([]);\n onChange?.(null);\n }\n },\n [id, onChange],\n );\n\n const handlePush = useCallback(\n (data: ViewStackPushEvent) => {\n if (views.current.has(data?.payload?.view)) {\n setStack((prev) => [...prev, data?.payload?.view]);\n onChange?.(data?.payload?.view);\n }\n },\n [onChange],\n );\n\n const handleReset = useCallback(\n (data: ViewStackResetEvent) => {\n if (id === data?.payload?.stack) {\n setStack(defaultView ? [defaultView] : []);\n onChange?.(defaultView ?? null);\n }\n },\n [id, defaultView, onChange],\n );\n\n useEffect(() => {\n const listeners = [\n bus.on(ViewStackEventTypes.back, handleBack),\n bus.on(ViewStackEventTypes.clear, handleClear),\n bus.on(ViewStackEventTypes.push, handlePush),\n bus.on(ViewStackEventTypes.reset, handleReset),\n ];\n\n return () => {\n for (const off of listeners) {\n off();\n }\n };\n }, [handleBack, handleClear, handlePush, handleReset]);\n\n return (\n <ViewStackContext.Provider\n value={{\n parent: id,\n stack,\n view,\n register: (view: UniqueId) => views.current.add(view),\n unregister: (view: UniqueId) => views.current.delete(view),\n }}\n >\n {children}\n </ViewStackContext.Provider>\n );\n}\nViewStack.displayName = 'ViewStack';\nViewStack.View = ViewStackView;\nViewStack.Trigger = ViewStackTrigger;\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e={bg:{base:["bg-surface-default","bg-surface-raised","bg-surface-overlay","bg-surface-muted","bg-interactive-bold","bg-interactive-bold-hover","bg-interactive-bold-pressed","bg-interactive-muted","bg-interactive-muted-hover","bg-interactive-muted-pressed","bg-interactive-disabled","bg-accent-primary-bold","bg-accent-primary-hover","bg-accent-primary-pressed","bg-accent-primary-muted"],utility:["bg-info-bold","bg-info-hover","bg-info-pressed","bg-info-muted","bg-advisory-bold","bg-advisory-hover","bg-advisory-pressed","bg-advisory-muted","bg-normal-bold","bg-normal-hover","bg-normal-pressed","bg-normal-muted","bg-serious-bold","bg-serious-hover","bg-serious-pressed","bg-serious-muted","bg-critical-bold","bg-critical-hover","bg-critical-pressed","bg-critical-muted"]},fg:{base:["fg-primary-bold","fg-primary-muted","fg-inverse-bold","fg-inverse-muted","fg-disabled"],utility:["fg-accent-primary-bold","fg-accent-primary-hover","fg-accent-primary-pressed","fg-info-bold","fg-info-hover","fg-info-pressed","fg-advisory-bold","fg-advisory-hover","fg-advisory-pressed","fg-normal-bold","fg-normal-hover","fg-normal-pressed","fg-serious-bold","fg-serious-hover","fg-serious-pressed","fg-critical-bold","fg-critical-hover","fg-critical-pressed"],a11y:["fg-a11y-on-accent","fg-a11y-on-utility"]},outline:{base:["outline-static","outline-interactive","outline-interactive-hover","outline-interactive-pressed","outline-interactive-disabled","outline-accent-primary-bold","outline-accent-primary-hover","outline-accent-primary-pressed"],utility:["outline-info-bold","outline-info-hover","outline-info-pressed","outline-advisory-bold","outline-advisory-hover","outline-advisory-pressed","outline-normal-bold","outline-normal-hover","outline-normal-pressed","outline-serious-bold","outline-serious-hover","outline-serious-pressed","outline-critical-bold","outline-critical-hover","outline-critical-pressed"]}};export{e as tokens};//# sourceMappingURL=token-data.js.map
|
|
2
|
+
//# sourceMappingURL=token-data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/foundation/token-data.ts"],"names":["tokens"],"mappings":"AAgBO,MAAMA,CAAAA,CAAS,CACpB,EAAA,CAAI,CACF,IAAA,CAAM,CACJ,oBAAA,CACA,mBAAA,CACA,oBAAA,CACA,kBAAA,CACA,qBAAA,CACA,2BAAA,CACA,8BACA,sBAAA,CACA,4BAAA,CACA,8BAAA,CACA,yBAAA,CACA,wBAAA,CACA,yBAAA,CACA,2BAAA,CACA,yBACF,CAAA,CACA,OAAA,CAAS,CACP,cAAA,CACA,eAAA,CACA,iBAAA,CACA,gBACA,kBAAA,CACA,mBAAA,CACA,qBAAA,CACA,mBAAA,CACA,gBAAA,CACA,iBAAA,CACA,mBAAA,CACA,iBAAA,CACA,iBAAA,CACA,kBAAA,CACA,oBAAA,CACA,kBAAA,CACA,kBAAA,CACA,mBAAA,CACA,sBACA,mBACF,CACF,CAAA,CACA,EAAA,CAAI,CACF,IAAA,CAAM,CACJ,iBAAA,CACA,kBAAA,CACA,iBAAA,CACA,kBAAA,CACA,aACF,CAAA,CACA,OAAA,CAAS,CACP,wBAAA,CACA,yBAAA,CACA,2BAAA,CACA,cAAA,CACA,eAAA,CACA,iBAAA,CACA,mBACA,mBAAA,CACA,qBAAA,CACA,gBAAA,CACA,iBAAA,CACA,mBAAA,CACA,iBAAA,CACA,mBACA,oBAAA,CACA,kBAAA,CACA,mBAAA,CACA,qBACF,CAAA,CACA,IAAA,CAAM,CAAC,mBAAA,CAAqB,oBAAoB,CAClD,CAAA,CACA,OAAA,CAAS,CACP,IAAA,CAAM,CACJ,gBAAA,CACA,qBAAA,CACA,2BAAA,CACA,6BAAA,CACA,8BAAA,CACA,6BAAA,CACA,8BAAA,CACA,gCACF,CAAA,CACA,OAAA,CAAS,CACP,mBAAA,CACA,oBAAA,CACA,sBAAA,CACA,wBACA,wBAAA,CACA,0BAAA,CACA,qBAAA,CACA,sBAAA,CACA,wBAAA,CACA,sBAAA,CACA,uBAAA,CACA,yBAAA,CACA,uBAAA,CACA,wBAAA,CACA,0BACF,CACF,CACF","file":"token-data.js","sourcesContent":["// __private-exports\n/*\n * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// These tokens drive the storybook stories.\n// future: generate these\n\nexport const tokens = {\n bg: {\n base: [\n 'bg-surface-default',\n 'bg-surface-raised',\n 'bg-surface-overlay',\n 'bg-surface-muted',\n 'bg-interactive-bold',\n 'bg-interactive-bold-hover',\n 'bg-interactive-bold-pressed',\n 'bg-interactive-muted',\n 'bg-interactive-muted-hover',\n 'bg-interactive-muted-pressed',\n 'bg-interactive-disabled',\n 'bg-accent-primary-bold',\n 'bg-accent-primary-hover',\n 'bg-accent-primary-pressed',\n 'bg-accent-primary-muted',\n ],\n utility: [\n 'bg-info-bold',\n 'bg-info-hover',\n 'bg-info-pressed',\n 'bg-info-muted',\n 'bg-advisory-bold',\n 'bg-advisory-hover',\n 'bg-advisory-pressed',\n 'bg-advisory-muted',\n 'bg-normal-bold',\n 'bg-normal-hover',\n 'bg-normal-pressed',\n 'bg-normal-muted',\n 'bg-serious-bold',\n 'bg-serious-hover',\n 'bg-serious-pressed',\n 'bg-serious-muted',\n 'bg-critical-bold',\n 'bg-critical-hover',\n 'bg-critical-pressed',\n 'bg-critical-muted',\n ],\n },\n fg: {\n base: [\n 'fg-primary-bold',\n 'fg-primary-muted',\n 'fg-inverse-bold',\n 'fg-inverse-muted',\n 'fg-disabled',\n ],\n utility: [\n 'fg-accent-primary-bold',\n 'fg-accent-primary-hover',\n 'fg-accent-primary-pressed',\n 'fg-info-bold',\n 'fg-info-hover',\n 'fg-info-pressed',\n 'fg-advisory-bold',\n 'fg-advisory-hover',\n 'fg-advisory-pressed',\n 'fg-normal-bold',\n 'fg-normal-hover',\n 'fg-normal-pressed',\n 'fg-serious-bold',\n 'fg-serious-hover',\n 'fg-serious-pressed',\n 'fg-critical-bold',\n 'fg-critical-hover',\n 'fg-critical-pressed',\n ],\n a11y: ['fg-a11y-on-accent', 'fg-a11y-on-utility'],\n },\n outline: {\n base: [\n 'outline-static',\n 'outline-interactive',\n 'outline-interactive-hover',\n 'outline-interactive-pressed',\n 'outline-interactive-disabled',\n 'outline-accent-primary-bold',\n 'outline-accent-primary-hover',\n 'outline-accent-primary-pressed',\n ],\n utility: [\n 'outline-info-bold',\n 'outline-info-hover',\n 'outline-info-pressed',\n 'outline-advisory-bold',\n 'outline-advisory-hover',\n 'outline-advisory-pressed',\n 'outline-normal-bold',\n 'outline-normal-hover',\n 'outline-normal-pressed',\n 'outline-serious-bold',\n 'outline-serious-hover',\n 'outline-serious-pressed',\n 'outline-critical-bold',\n 'outline-critical-hover',\n 'outline-critical-pressed',\n ],\n },\n};\n"]}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Key } from '@react-types/shared';
|
|
2
|
+
import { TreeNode } from '../types.js';
|
|
3
|
+
import 'react';
|
|
4
|
+
import 'react-aria-components';
|
|
5
|
+
|
|
6
|
+
type CacheTreeNode<T> = Omit<TreeNode<T>, 'children'> & {
|
|
7
|
+
children?: Key[];
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* This is a cache created only for performance reasons and is considered
|
|
11
|
+
* to be only a temporary mirror of the data. The data is *always* correct
|
|
12
|
+
* cache should be updated according to the data, only. If the data and
|
|
13
|
+
* the cache do not match, the cache is invalidated and rebuilt.
|
|
14
|
+
*
|
|
15
|
+
* This will initialize once on load with data, then
|
|
16
|
+
* updated with each tree operation.
|
|
17
|
+
*/
|
|
18
|
+
declare class Cache<T> {
|
|
19
|
+
protected cache: {
|
|
20
|
+
lookup: Map<Key, CacheTreeNode<T>>;
|
|
21
|
+
roots: Key[];
|
|
22
|
+
};
|
|
23
|
+
constructor(nodes?: TreeNode<T>[]);
|
|
24
|
+
/**
|
|
25
|
+
* Recursively creates the cache object from tree data
|
|
26
|
+
*/
|
|
27
|
+
rebuild(nodes: TreeNode<T>[], lookup?: Map<Key, CacheTreeNode<T>>, parentKey?: Key | null): {
|
|
28
|
+
lookup: Map<Key, CacheTreeNode<T>>;
|
|
29
|
+
roots: Key[];
|
|
30
|
+
};
|
|
31
|
+
protected get(key: Key): CacheTreeNode<T>;
|
|
32
|
+
protected set(key: Key, node: CacheTreeNode<T>): void;
|
|
33
|
+
protected delete(key: Key): void;
|
|
34
|
+
protected addToParent(parentKey: Key, childKey: Key, idx: number): void;
|
|
35
|
+
protected addToRoot(key: Key, idx: number): void;
|
|
36
|
+
protected removeFromParent(parentKey: Key, childKey: Key): void;
|
|
37
|
+
protected removeFromRoot(key: Key): void;
|
|
38
|
+
protected parentOrSibling(target: Key | null, position: 'before' | 'after'): {
|
|
39
|
+
parentKey: Key | null;
|
|
40
|
+
index: number;
|
|
41
|
+
};
|
|
42
|
+
protected traverse(key: Key): void;
|
|
43
|
+
protected calculateVisibility(key: Key): boolean;
|
|
44
|
+
protected deriveVisibility(): void[];
|
|
45
|
+
/**
|
|
46
|
+
* Recursively builds a TreeNode from a key
|
|
47
|
+
*
|
|
48
|
+
* @param key
|
|
49
|
+
*/
|
|
50
|
+
protected buildNode(key: Key): TreeNode<T>;
|
|
51
|
+
/**
|
|
52
|
+
* Builds a tree structure from cache
|
|
53
|
+
*
|
|
54
|
+
* TODO: optimization - rebuild only from change to root
|
|
55
|
+
* Rebuild only from the changed node up the tree to avoid
|
|
56
|
+
* rebuilding the entire tree
|
|
57
|
+
*
|
|
58
|
+
* @param deriveVisible boolean - if true, will recompute visibility for nodes based on ancestry
|
|
59
|
+
*/
|
|
60
|
+
toTree(deriveVisible?: boolean): TreeNode<T>[];
|
|
61
|
+
/**
|
|
62
|
+
* CACHE FUNCTIONS
|
|
63
|
+
* These manage cache operations. No cache operations should ever be done
|
|
64
|
+
* outside this file.
|
|
65
|
+
**/
|
|
66
|
+
getNode(key: Key): TreeNode<T>;
|
|
67
|
+
getAllKeys(): MapIterator<Key>;
|
|
68
|
+
getAllNodes(): MapIterator<CacheTreeNode<T>>;
|
|
69
|
+
setNode(key: Key, node: TreeNode<T>): void;
|
|
70
|
+
setAllNodes({ parentKey, children, ...rest }: Partial<TreeNode<T>>): void;
|
|
71
|
+
deleteNode(key: Key): void;
|
|
72
|
+
addNodes(target: Key | null, nodes: TreeNode<T>[], position: 'before' | 'after'): void;
|
|
73
|
+
insertNode(parentKey: Key | null, node: TreeNode<T>, idx: number): void;
|
|
74
|
+
moveNodes(target: Key | null, nodes: Set<Key>, position: 'before' | 'after'): void;
|
|
75
|
+
moveNode(parentKey: Key | null, key: Key, idx: number): void;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export { Cache };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
class d{cache={lookup:new Map,roots:[]};constructor(e=[]){this.rebuild(e);}rebuild(e,t=new Map,s=null){e.forEach(r=>{const{children:o,...n}=r;t.set(r.key,{isDisabled:false,isExpanded:false,isSelected:false,isVisible:false,isVisibleComputed:false,...n,parentKey:s,...o?{children:o.map(l=>l.key)}:{}}),r.children&&this.rebuild(r.children,t,r.key);});const i={lookup:t,roots:e.map(r=>r.key)};return s||(this.cache=i),this.deriveVisibility(),i}get(e){const t=this.cache.lookup.get(e);if(t===void 0)throw new Error(`Key of ${e} does not exist in tree`);return t}set(e,t){this.cache.lookup.set(e,t);}delete(e){this.cache.lookup.delete(e);}addToParent(e,t,s){const i=this.get(e),r=this.get(t),o=Math.max(0,s);this.set(t,{...r,parentKey:e});const n=(i.children??[]).slice(0);n.splice(o,0,t),this.set(e,{...i,children:n});}addToRoot(e,t){const s=this.get(e),i=Math.max(0,t);this.set(e,{...s,parentKey:null}),this.cache.roots.splice(i,0,e);}removeFromParent(e,t){const s=this.get(e),i=this.get(t);this.set(t,{...i,parentKey:null}),this.cache.lookup.set(e,{...s,children:s.children?.filter(r=>r!==t)});}removeFromRoot(e){const t=this.get(e),s=this.cache.roots.indexOf(e);s>=0&&(this.set(e,{...t,parentKey:null}),this.cache.roots.splice(s,1));}parentOrSibling(e,t){let s,i=null;if(e===null)s=t==="before"?0:this.cache.roots.length;else {const r=this.get(e);if(r.parentKey){const o=this.get(r.parentKey);i=o.key,s=o.children?.indexOf(e)??0;}else s=this.cache.roots.indexOf(e);}return {parentKey:i,index:s}}traverse(e){const t=this.get(e);this.cache.lookup.set(e,{...t,isVisibleComputed:this.calculateVisibility(e)}),t.children?.map(s=>this.traverse(s));}calculateVisibility(e){let t=this.get(e);const s=[t];for(;t.parentKey;){const i=this.get(t.parentKey);i&&s.push(i),t=i;}return s.every(i=>i.isVisible)}deriveVisibility(){return this.cache.roots.map(e=>this.traverse(e))}buildNode(e){const t=this.get(e),s=(t.children??[]).reduce((i,r)=>{const o=this.cache.lookup.get(r);return o&&o.parentKey===e&&i.push(this.buildNode(r)),i},[]);return {...t,children:s}}toTree(e){return e&&this.deriveVisibility(),this.cache.roots.map(t=>this.buildNode(t))}getNode(e){const t=this.get(e);return {...t,children:t.children?.map(s=>this.buildNode(s))}}getAllKeys(){return this.cache.lookup.keys()}getAllNodes(){return this.cache.lookup.values()}setNode(e,t){this.set(e,{...t,children:(t.children??[]).map(s=>s.key)});}setAllNodes({parentKey:e,children:t,...s}){for(const i of this.cache.lookup.values())this.set(i.key,{...i,...s});}deleteNode(e){const t=this.cache.lookup.get(e);t&&(t.children?.map(s=>this.deleteNode(s)),t.parentKey?this.removeFromParent(t.parentKey,e):this.removeFromRoot(e),this.delete(e));}addNodes(e,t,s){const{parentKey:i,index:r}=this.parentOrSibling(e,s),o=r+(s==="before"?0:1);t.map((n,l)=>this.insertNode(i,n,o+l));}insertNode(e,t,s){const{children:i,...r}=t;this.set(t.key,{isDisabled:false,isExpanded:false,isSelected:false,isVisible:false,isVisibleComputed:false,...r,parentKey:e,...i?{children:i.map(o=>o.key)}:{}}),t.children?.map((o,n)=>this.insertNode(t.key,o,n)),e===null?this.addToRoot(t.key,s):this.addToParent(e,t.key,s);}moveNodes(e,t,s){const{parentKey:i,index:r}=this.parentOrSibling(e,s),o=r+(s==="before"?0:1);Array.from(t).map((n,l)=>this.moveNode(i,n,o+l));}moveNode(e,t,s){const i=this.get(t);i.parentKey?this.removeFromParent(i.parentKey,t):this.removeFromRoot(t),e?this.addToParent(e,t,s):this.addToRoot(t,s);}}export{d as Cache};//# sourceMappingURL=cache.js.map
|
|
2
|
+
//# sourceMappingURL=cache.js.map
|