@accelint/design-toolkit 5.1.0 → 6.0.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/catalog-info.yaml +44 -0
- package/dist/components/accordion/index.js +1 -1
- package/dist/components/accordion/index.js.map +1 -1
- package/dist/components/accordion/styles.d.ts +3 -3
- package/dist/components/accordion/styles.js +1 -1
- package/dist/components/accordion/styles.js.map +1 -1
- package/dist/components/action-bar/index.d.ts +11 -0
- package/dist/components/action-bar/index.js.map +1 -1
- package/dist/components/breadcrumbs/index.d.ts +27 -0
- package/dist/components/breadcrumbs/index.js +4 -0
- package/dist/components/breadcrumbs/index.js.map +1 -0
- package/dist/components/breadcrumbs/styles.d.ts +48 -0
- package/dist/components/breadcrumbs/styles.js +2 -0
- package/dist/components/breadcrumbs/styles.js.map +1 -0
- package/dist/components/breadcrumbs/types.d.ts +20 -0
- package/dist/components/breadcrumbs/types.js +2 -0
- package/dist/components/breadcrumbs/types.js.map +1 -0
- package/dist/components/button/index.d.ts +2 -2
- package/dist/components/button/index.js +1 -1
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/button/styles.d.ts +15 -15
- package/dist/components/button/styles.js +1 -1
- package/dist/components/button/styles.js.map +1 -1
- package/dist/components/button/types.d.ts +7 -5
- package/dist/components/clock/index.d.ts +39 -0
- package/dist/components/clock/index.js +4 -0
- package/dist/components/clock/index.js.map +1 -0
- package/dist/components/clock/types.d.ts +7 -0
- package/dist/components/clock/types.js +2 -0
- package/dist/components/clock/types.js.map +1 -0
- package/dist/components/color-picker/styles.d.ts +3 -3
- package/dist/components/combobox-field/index.d.ts +11 -0
- package/dist/components/combobox-field/index.js.map +1 -1
- package/dist/components/combobox-field/styles.js +1 -1
- package/dist/components/combobox-field/styles.js.map +1 -1
- package/dist/components/dialog/index.js +1 -1
- package/dist/components/dialog/index.js.map +1 -1
- package/dist/components/divider/index.d.ts +32 -0
- package/dist/components/divider/index.js +4 -0
- package/dist/components/divider/index.js.map +1 -0
- package/dist/components/divider/styles.d.ts +5 -0
- package/dist/components/divider/styles.js +2 -0
- package/dist/components/divider/styles.js.map +1 -0
- package/dist/components/divider/types.d.ts +11 -0
- package/dist/components/divider/types.js +2 -0
- package/dist/components/divider/types.js.map +1 -0
- package/dist/components/drawer/index.d.ts +48 -3
- package/dist/components/drawer/index.js +1 -1
- package/dist/components/drawer/index.js.map +1 -1
- package/dist/components/drawer/styles.js +1 -1
- package/dist/components/drawer/styles.js.map +1 -1
- package/dist/components/drawer/types.d.ts +13 -7
- package/dist/components/input/styles.js +1 -1
- package/dist/components/input/styles.js.map +1 -1
- package/dist/components/lines/index.d.ts +9 -0
- package/dist/components/lines/index.js.map +1 -1
- package/dist/components/link/index.d.ts +9 -0
- package/dist/components/link/index.js.map +1 -1
- package/dist/components/link/styles.js +1 -1
- package/dist/components/link/styles.js.map +1 -1
- package/dist/components/menu/styles.js +1 -1
- package/dist/components/menu/styles.js.map +1 -1
- package/dist/components/notice/events.d.ts +10 -0
- package/dist/components/notice/events.js +2 -0
- package/dist/components/notice/events.js.map +1 -0
- package/dist/components/notice/index.d.ts +20 -0
- package/dist/components/notice/index.js +4 -0
- package/dist/components/notice/index.js.map +1 -0
- package/dist/components/notice/styles.d.ts +60 -0
- package/dist/components/notice/styles.js +2 -0
- package/dist/components/notice/styles.js.map +1 -0
- package/dist/components/notice/types.d.ts +75 -0
- package/dist/components/notice/types.js +2 -0
- package/dist/components/notice/types.js.map +1 -0
- package/dist/components/query-builder/index.js +1 -1
- package/dist/components/query-builder/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/types.d.ts +0 -1
- package/dist/components/sidenav/index.d.ts +57 -6
- package/dist/components/sidenav/index.js +1 -1
- package/dist/components/sidenav/index.js.map +1 -1
- package/dist/components/sidenav/styles.js +1 -1
- package/dist/components/sidenav/styles.js.map +1 -1
- package/dist/components/slider/index.js +1 -1
- package/dist/components/slider/index.js.map +1 -1
- package/dist/components/slider/styles.js +1 -1
- package/dist/components/slider/styles.js.map +1 -1
- package/dist/components/table/context.d.ts +11 -0
- package/dist/components/table/context.js +2 -0
- package/dist/components/table/context.js.map +1 -0
- package/dist/components/table/index.d.ts +36 -0
- package/dist/components/table/index.js +4 -0
- package/dist/components/table/index.js.map +1 -0
- package/dist/components/table/styles.d.ts +134 -0
- package/dist/components/table/styles.js +2 -0
- package/dist/components/table/styles.js.map +1 -0
- package/dist/components/table/table-body.d.ts +12 -0
- package/dist/components/table/table-body.js +2 -0
- package/dist/components/table/table-body.js.map +1 -0
- package/dist/components/table/table-cell.d.ts +12 -0
- package/dist/components/table/table-cell.js +2 -0
- package/dist/components/table/table-cell.js.map +1 -0
- package/dist/components/table/table-header-cell.d.ts +12 -0
- package/dist/components/table/table-header-cell.js +2 -0
- package/dist/components/table/table-header-cell.js.map +1 -0
- package/dist/components/table/table-header.d.ts +12 -0
- package/dist/components/table/table-header.js +2 -0
- package/dist/components/table/table-header.js.map +1 -0
- package/dist/components/table/table-row.d.ts +12 -0
- package/dist/components/table/table-row.js +2 -0
- package/dist/components/table/table-row.js.map +1 -0
- package/dist/components/table/types.d.ts +185 -0
- package/dist/components/table/types.js +2 -0
- package/dist/components/table/types.js.map +1 -0
- package/dist/components/tabs/styles.js +1 -1
- package/dist/components/tabs/styles.js.map +1 -1
- package/dist/components/time-field/index.d.ts +19 -0
- package/dist/components/time-field/index.js +4 -0
- package/dist/components/time-field/index.js.map +1 -0
- package/dist/components/time-field/styles.d.ts +69 -0
- package/dist/components/time-field/styles.js +2 -0
- package/dist/components/time-field/styles.js.map +1 -0
- package/dist/components/time-field/types.d.ts +23 -0
- package/dist/components/time-field/types.js +2 -0
- package/dist/components/time-field/types.js.map +1 -0
- package/dist/components/tooltip/index.d.ts +23 -34
- package/dist/components/tooltip/index.js +1 -1
- package/dist/components/tooltip/index.js.map +1 -1
- package/dist/components/tooltip/types.d.ts +5 -6
- package/dist/components/tree/index.d.ts +22 -1
- package/dist/components/tree/index.js +1 -1
- package/dist/components/tree/index.js.map +1 -1
- package/dist/components/tree/styles.js +1 -1
- package/dist/components/tree/styles.js.map +1 -1
- package/dist/components/view-stack/index.d.ts +42 -2
- package/dist/components/view-stack/index.js +1 -1
- package/dist/components/view-stack/index.js.map +1 -1
- package/dist/foundation/token-data.js +1 -1
- package/dist/foundation/token-data.js.map +1 -1
- package/dist/index.css +5 -3
- package/dist/index.d.ts +32 -6
- package/dist/index.js +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/providers/portal.d.ts +9 -0
- package/dist/providers/portal.js +2 -0
- package/dist/providers/portal.js.map +1 -0
- package/dist/providers/theme-provider.d.ts +6 -6
- package/dist/providers/theme-provider.js +1 -1
- package/dist/providers/theme-provider.js.map +1 -1
- package/dist/styles.css +3355 -974
- package/dist/tokens/themes.css +56 -24
- package/dist/tokens/tokens.css +8 -8
- package/dist/tokens/tokens.d.ts +18 -0
- package/dist/tokens/tokens.js +1 -1
- package/dist/tokens/tokens.js.map +1 -1
- package/dist/tokens/types.d.ts +9 -0
- package/dist/variants/variants.css +3 -0
- package/package.json +39 -17
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { NoticeProps, NoticeListProps } from './types.js';
|
|
3
|
+
import '@accelint/bus';
|
|
4
|
+
import '@accelint/core';
|
|
5
|
+
import 'react-aria-components';
|
|
6
|
+
import '../button/types.js';
|
|
7
|
+
import 'tailwind-variants';
|
|
8
|
+
import '../../lib/types.js';
|
|
9
|
+
import 'react';
|
|
10
|
+
import '../button/styles.js';
|
|
11
|
+
import 'tailwind-merge';
|
|
12
|
+
import './events.js';
|
|
13
|
+
|
|
14
|
+
declare function Notice({ id, classNames, color, message, primary, secondary, hideIcon, showClose, shouldCloseOnAction, size, onPrimaryAction, onSecondaryAction, onClose, }: NoticeProps): react_jsx_runtime.JSX.Element;
|
|
15
|
+
declare namespace Notice {
|
|
16
|
+
var List: typeof NoticeList;
|
|
17
|
+
}
|
|
18
|
+
declare function NoticeList({ id, classNames, defaultColor, defaultTimeout, hideClearAll, limit, global, placement, size, ...rest }: NoticeListProps): react_jsx_runtime.JSX.Element;
|
|
19
|
+
|
|
20
|
+
export { Notice };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useMemo,useState,useRef,useEffect,createElement}from'react';import'client-only';import {useBus}from'@accelint/bus/react';import {uuid}from'@accelint/core';import {Cancel,Information,Success,Warning,Problem}from'@accelint/icons';import {useToastRegion}from'@react-aria/toast';import {useToastQueue}from'@react-stately/toast';import {isEqual}from'lodash';import {UNSTABLE_Toast,UNSTABLE_ToastContent,Text,UNSTABLE_ToastQueue,composeRenderProps,UNSTABLE_ToastList,UNSTABLE_ToastRegion,UNSTABLE_ToastStateContext}from'react-aria-components';import {Button}from'../button/index.js';import {Icon}from'../icon/index.js';import {NoticeEventTypes}from'./events.js';import {NoticeStyles}from'./styles.js';const{notice:no,content:io,list:so,actions:co,region:R,message:ro}=NoticeStyles();function ao({color:n="info",size:t}){return jsxs(Icon,{size:t==="small"?"medium":"large",children:[n==="info"&&jsx(Information,{}),n==="advisory"&&jsx(Information,{}),n==="normal"&&jsx(Success,{}),n==="serious"&&jsx(Warning,{}),n==="critical"&&jsx(Problem,{})]})}const E={normal:"mono-bold",advisory:"mono-bold",info:"mono-bold",serious:"serious",critical:"critical"};function Q({id:n,classNames:t,color:s="info",message:r,primary:m,secondary:a,hideIcon:T,showClose:d,shouldCloseOnAction:p,size:c="medium",onPrimaryAction:i,onSecondaryAction:y,onClose:u}){return jsx(UNSTABLE_Toast,{className:no({className:t?.notice}),toast:{key:n,content:r,onClose:u},"data-color":s,"data-size":c,children:jsxs(UNSTABLE_ToastContent,{className:io({className:t?.content}),children:[!T&&c==="medium"&&jsx(ao,{color:s,size:c}),jsx(Text,{slot:"description",className:ro({className:t?.message}),children:r}),(m||a)&&jsxs("div",{className:co({className:t?.actions}),children:[m&&jsx(Button,{color:E[s],variant:"filled",...m,size:c,onPress:()=>{i?.(),p&&u?.();}}),a&&jsx(Button,{color:E[s],variant:"outline",...a,size:c,onPress:()=>{y?.(),p&&u?.();}})]}),d&&jsx(Button,{color:E[s],variant:"icon",onPress:u,children:jsx(Icon,{children:jsx(Cancel,{})})})]})})}function uo(n,t){return t?Object.entries(n).every(([s,r])=>s in t&&isEqual(t[s],r)):false}function mo({id:n,classNames:t,defaultColor:s,defaultTimeout:r,hideClearAll:m,limit:a=3,global:T,placement:d,size:p="medium",...c}){const i=useMemo(()=>new UNSTABLE_ToastQueue({maxVisibleToasts:a}),[a]),y=useToastQueue(i),[u,h]=useState(false),C=useRef(null),{regionProps:I}=useToastRegion(c,i,C),{useEmit:v,useOn:S}=useBus(),k=v(NoticeEventTypes.actionPrimary),x=v(NoticeEventTypes.actionSecondary),U=v(NoticeEventTypes.close);S(NoticeEventTypes.queue,o=>{(n&&o.payload.target===n||!n)&&i.add({...o.payload,id:o.payload.id||uuid(),color:s||o.payload.color},{timeout:r??o.payload.timeout});}),S(NoticeEventTypes.dequeue,o=>{const L=i.queue,P=L.filter(g=>uo(o.payload,g.content));if(P.length&&P.length===L.length)i.clear();else for(const g of P)i.close(g.key);}),useEffect(()=>{i.subscribe(()=>{h(i.visibleToasts.length>0);});});const B=jsxs(Fragment,{children:[!m&&u&&jsx(Button,{className:composeRenderProps(t?.button,o=>o??""),variant:"outline",onPress:i.clear,children:"Clear All"}),jsx(UNSTABLE_ToastList,{className:composeRenderProps(t?.list,o=>so({className:o})),children:({toast:o})=>createElement(Q,{...o.content,key:o.key,showClose:!(o.timeout&&o.content.primary&&o.content.secondary),classNames:t?.notice,size:p,onPrimaryAction:()=>k({id:o.content.id}),onSecondaryAction:()=>x({id:o.content.id}),onClose:()=>{o.onClose?.(),i.close(o.key),U({id:o.content.id});}})})]});return T?jsx(UNSTABLE_ToastRegion,{className:R({className:t?.region}),"data-placement":d,queue:i,children:B}):jsx("div",{...I,className:R({className:t?.region}),"data-placement":d,ref:C,children:jsx(UNSTABLE_ToastStateContext.Provider,{value:y,children:B})})}Q.List=mo;export{Q as Notice};//# sourceMappingURL=index.js.map
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/notice/index.tsx"],"names":["actions","region","description","NoticeIcon","color","Icon","size","f","q","Information","e","A","Warning","D","Problem","H","id","classNames","primary","onPrimaryAction","onClose","notice","ToastContent","content","jsx","Text","K","secondary","Button","ButtonColorMap","shouldCloseOnAction","N","onSecondaryAction","Cancel","matchesMetadata","payload","metadata","key","value","isEqual","W","defaultColor","F","limit","state","useToastQueue","ref","useRef","V","regionProps","useToastRegion","rest","queue","useOn","O","useBus","emitActionPrimary","useEmit","NoticeEventTypes","emitActionSecondary","l","data","uuid","w","defaultTimeout","queuedNotices","dequeue","toast","setHasNotices","j","hideClearAll","hasNotices","po","className","list","b","createElement","Notice","lo","emitClose","global","placement","eo","children","NoticeList"],"mappings":"ivBA0DE,YACA,CAAA,EAAAA,CAAAA,UACAC,CACA,IAAA,CAAA,EAAA,CAASC,OACM,GAEjB,CAAA,MAAA,CAASC,CAAAA,CAAAA,OAAa,CAAAC,EAAQ,iBAAQ,SACpC,SACGC,CAAAA,CAAA,CAAK,MAAMC,CAAAA,gBAAmBC,IAAA,CAAAC,IAAW,CAAA,CAAA,IAAA,CAAA,CACvC,UAAAJ,CAAAA,QAAU,CAAA,OAAW,CAAY,QACvB,CAAA,CAAA,CAAA,GAAA,MAAeK,EAAAC,GAAA,CAAYC,WAAA,CACrCP,EAAAA,CAAAA,CAAU,cAAa,EAAQM,GAAA,CAC/BN,WAAAA,CAAAA,EAAU,cAAcQ,KAAQ,CAAAC,OAChCT,CAAAA,EAAAA,CAAU,cAAeU,EAAAJ,IAAQK,OAAA,CAAA,EAGxC,CAEA,CAAA,CAAA,GAA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,CAAE,YAAWgB,GAAY,CAAA,CAAA,SAC3C,CAAA,CAAA,CAAA,CAAA,SAAA,CAAA,CAAgBgE,EAChB,MAEA,yBAA4B,CAAA,CAAA,CAAA,QACzB,CAAAvE,GAAA,CAAAwE,0BAAAC,CAAAA,QAMF,CAAA,CAAA,KAAOC,CAAAA,CAAAA,CAAAA,QAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,IAAAA,CAAAA,EAAAA","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\n'use client';\n\nimport 'client-only';\nimport { useBus } from '@accelint/bus/react';\nimport { uuid } from '@accelint/core';\nimport {\n Cancel,\n Information,\n Problem,\n Success,\n Warning,\n} from '@accelint/icons';\nimport { useToastRegion } from '@react-aria/toast';\nimport { useToastQueue } from '@react-stately/toast';\nimport { isEqual } from 'lodash';\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport {\n composeRenderProps,\n type QueuedToast,\n Text,\n UNSTABLE_Toast as Toast,\n UNSTABLE_ToastContent as ToastContent,\n UNSTABLE_ToastList as ToastList,\n UNSTABLE_ToastQueue as ToastQueue,\n UNSTABLE_ToastRegion as ToastRegion,\n UNSTABLE_ToastStateContext as ToastStateContext,\n} from 'react-aria-components';\nimport { Button } from '../button';\nimport { Icon } from '../icon';\nimport { NoticeEventTypes } from './events';\nimport { NoticeStyles } from './styles';\nimport type { ButtonProps } from '../button/types';\nimport type {\n NoticeActionEvent,\n NoticeColor,\n NoticeContent,\n NoticeDequeueEvent,\n NoticeIconProps,\n NoticeListProps,\n NoticeProps,\n NoticeQueueEvent,\n} from './types';\n\nconst {\n notice,\n content,\n list,\n actions,\n region,\n message: description,\n} = NoticeStyles();\n\nfunction NoticeIcon({ color = 'info', size }: NoticeIconProps) {\n return (\n <Icon size={size === 'small' ? 'medium' : 'large'}>\n {color === 'info' && <Information />}\n {color === 'advisory' && <Information />}\n {color === 'normal' && <Success />}\n {color === 'serious' && <Warning />}\n {color === 'critical' && <Problem />}\n </Icon>\n );\n}\n\nconst ButtonColorMap: Record<NoticeColor, ButtonProps['color']> = {\n normal: 'mono-bold',\n advisory: 'mono-bold',\n info: 'mono-bold',\n serious: 'serious',\n critical: 'critical',\n};\n\nexport function Notice({\n id,\n classNames,\n color = 'info',\n message,\n primary,\n secondary,\n hideIcon,\n showClose,\n shouldCloseOnAction,\n size = 'medium',\n onPrimaryAction,\n onSecondaryAction,\n onClose,\n}: NoticeProps) {\n return (\n <Toast\n className={notice({ className: classNames?.notice })}\n toast={{ key: id, content: message, onClose }}\n data-color={color}\n data-size={size}\n >\n <ToastContent className={content({ className: classNames?.content })}>\n {!hideIcon && size === 'medium' && (\n <NoticeIcon color={color} size={size} />\n )}\n <Text\n slot='description'\n className={description({ className: classNames?.message })}\n >\n {message}\n </Text>\n {(primary || secondary) && (\n <div className={actions({ className: classNames?.actions })}>\n {primary && (\n <Button\n color={ButtonColorMap[color]}\n variant='filled'\n {...primary}\n size={size}\n onPress={() => {\n onPrimaryAction?.();\n\n if (shouldCloseOnAction) {\n onClose?.();\n }\n }}\n />\n )}\n {secondary && (\n <Button\n color={ButtonColorMap[color]}\n variant='outline'\n {...secondary}\n size={size}\n onPress={() => {\n onSecondaryAction?.();\n\n if (shouldCloseOnAction) {\n onClose?.();\n }\n }}\n />\n )}\n </div>\n )}\n {showClose && (\n <Button\n color={ButtonColorMap[color]}\n variant='icon'\n onPress={onClose}\n >\n <Icon>\n <Cancel />\n </Icon>\n </Button>\n )}\n </ToastContent>\n </Toast>\n );\n}\n\nfunction matchesMetadata(\n payload: Record<string, unknown>,\n metadata?: Record<string, unknown>,\n) {\n if (!metadata) {\n return false;\n }\n\n return Object.entries(payload).every(\n ([key, value]) => key in metadata && isEqual(metadata[key], value),\n );\n}\n\nfunction NoticeList({\n id,\n classNames,\n defaultColor,\n defaultTimeout,\n hideClearAll,\n limit = 3,\n global,\n placement,\n size = 'medium',\n ...rest\n}: NoticeListProps) {\n const queue = useMemo(\n () => new ToastQueue<NoticeContent>({ maxVisibleToasts: limit }),\n [limit],\n );\n const state = useToastQueue(queue);\n\n const [hasNotices, setHasNotices] = useState(false);\n const ref = useRef(null);\n const { regionProps } = useToastRegion(rest, queue, ref);\n\n const { useEmit, useOn } = useBus<\n NoticeQueueEvent | NoticeDequeueEvent | NoticeActionEvent\n >();\n const emitActionPrimary = useEmit(NoticeEventTypes.actionPrimary);\n const emitActionSecondary = useEmit(NoticeEventTypes.actionSecondary);\n const emitClose = useEmit(NoticeEventTypes.close);\n\n useOn(NoticeEventTypes.queue, (data) => {\n if ((id && data.payload.target === id) || !id) {\n queue.add(\n {\n ...data.payload,\n id: data.payload.id || uuid(),\n color: defaultColor || data.payload.color,\n },\n {\n timeout: defaultTimeout ?? data.payload.timeout,\n },\n );\n }\n });\n\n useOn(NoticeEventTypes.dequeue, (data) => {\n // @ts-expect-error : queue.queue exists, but is not currently documented\n const queuedNotices = queue.queue;\n\n const dequeue = queuedNotices.filter((toast: QueuedToast<NoticeContent>) =>\n matchesMetadata(data.payload, toast.content),\n );\n\n if (dequeue.length && dequeue.length === queuedNotices.length) {\n queue.clear();\n } else {\n for (const toast of dequeue) {\n queue.close(toast.key);\n }\n }\n });\n\n useEffect(() => {\n queue.subscribe(() => {\n setHasNotices(queue.visibleToasts.length > 0);\n });\n });\n\n const children = (\n <>\n {!hideClearAll && hasNotices && (\n <Button\n className={composeRenderProps(\n classNames?.button,\n (className) => className ?? '',\n )}\n variant='outline'\n onPress={queue.clear}\n >\n Clear All\n </Button>\n )}\n <ToastList\n className={composeRenderProps(classNames?.list, (className) =>\n list({ className }),\n )}\n >\n {({ toast }: { toast: QueuedToast<NoticeContent> }) => (\n <Notice\n {...toast.content}\n key={toast.key}\n showClose={\n !(\n toast.timeout &&\n toast.content.primary &&\n toast.content.secondary\n )\n }\n classNames={classNames?.notice}\n size={size}\n onPrimaryAction={() => emitActionPrimary({ id: toast.content.id })}\n onSecondaryAction={() =>\n emitActionSecondary({ id: toast.content.id })\n }\n onClose={() => {\n toast.onClose?.();\n queue.close(toast.key);\n emitClose({ id: toast.content.id });\n }}\n />\n )}\n </ToastList>\n </>\n );\n\n return global ? (\n <ToastRegion\n className={region({ className: classNames?.region })}\n data-placement={placement}\n queue={queue}\n >\n {children}\n </ToastRegion>\n ) : (\n <div\n {...regionProps}\n className={region({ className: classNames?.region })}\n data-placement={placement}\n ref={ref}\n >\n <ToastStateContext.Provider value={state}>\n {children}\n </ToastStateContext.Provider>\n </div>\n );\n}\n\nNotice.List = NoticeList;\n"]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import * as tailwind_variants from 'tailwind-variants';
|
|
2
|
+
import * as tailwind_merge from 'tailwind-merge';
|
|
3
|
+
|
|
4
|
+
declare const NoticeStyles: tailwind_variants.TVReturnType<{
|
|
5
|
+
[key: string]: {
|
|
6
|
+
[key: string]: tailwind_merge.ClassNameValue | {
|
|
7
|
+
content?: tailwind_merge.ClassNameValue;
|
|
8
|
+
list?: tailwind_merge.ClassNameValue;
|
|
9
|
+
region?: tailwind_merge.ClassNameValue;
|
|
10
|
+
message?: tailwind_merge.ClassNameValue;
|
|
11
|
+
actions?: tailwind_merge.ClassNameValue;
|
|
12
|
+
notice?: tailwind_merge.ClassNameValue;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
} | {
|
|
16
|
+
[x: string]: {
|
|
17
|
+
[x: string]: tailwind_merge.ClassNameValue | {
|
|
18
|
+
content?: tailwind_merge.ClassNameValue;
|
|
19
|
+
list?: tailwind_merge.ClassNameValue;
|
|
20
|
+
region?: tailwind_merge.ClassNameValue;
|
|
21
|
+
message?: tailwind_merge.ClassNameValue;
|
|
22
|
+
actions?: tailwind_merge.ClassNameValue;
|
|
23
|
+
notice?: tailwind_merge.ClassNameValue;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
} | {}, {
|
|
27
|
+
notice: string[];
|
|
28
|
+
content: string[];
|
|
29
|
+
message: string;
|
|
30
|
+
region: string[];
|
|
31
|
+
list: string[];
|
|
32
|
+
actions: string;
|
|
33
|
+
}, undefined, {
|
|
34
|
+
[key: string]: {
|
|
35
|
+
[key: string]: tailwind_merge.ClassNameValue | {
|
|
36
|
+
content?: tailwind_merge.ClassNameValue;
|
|
37
|
+
list?: tailwind_merge.ClassNameValue;
|
|
38
|
+
region?: tailwind_merge.ClassNameValue;
|
|
39
|
+
message?: tailwind_merge.ClassNameValue;
|
|
40
|
+
actions?: tailwind_merge.ClassNameValue;
|
|
41
|
+
notice?: tailwind_merge.ClassNameValue;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
} | {}, {
|
|
45
|
+
notice: string[];
|
|
46
|
+
content: string[];
|
|
47
|
+
message: string;
|
|
48
|
+
region: string[];
|
|
49
|
+
list: string[];
|
|
50
|
+
actions: string;
|
|
51
|
+
}, tailwind_variants.TVReturnType<unknown, {
|
|
52
|
+
notice: string[];
|
|
53
|
+
content: string[];
|
|
54
|
+
message: string;
|
|
55
|
+
region: string[];
|
|
56
|
+
list: string[];
|
|
57
|
+
actions: string;
|
|
58
|
+
}, undefined, unknown, unknown>>;
|
|
59
|
+
|
|
60
|
+
export { NoticeStyles };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {tv}from'./../../lib/utils.js';const l=tv({slots:{notice:["group/notice fg-primary-bold flex rounded-medium text-body-s shadow-elevation-overlay outline","size-small:flex-col size-small:flex-wrap size-small:gap-m size-small:p-s group-data-placement/region:size-small:min-w-[120px] group-data-placement/region:size-small:max-w-[320px]","size-medium:gap-l size-medium:p-l group-data-placement/region:size-medium:min-w-[200px] group-data-placement/region:size-medium:max-w-[640px]","color-info:bg-info-muted color-info:outline-info-bold","color-advisory:bg-advisory-muted color-advisory:outline-accent-primary-bold","color-normal:bg-normal-muted color-normal:outline-normal-bold","color-serious:bg-serious-muted color-serious:outline-serious-bold","color-critical:bg-critical-muted color-critical:outline-critical-bold"],content:["flex flex-1 items-center group-size-medium/notice:gap-l group-size-small/notice:gap-m"],message:"flex-1 group-size-small/notice:basis-10/12",region:["group/region flex flex-col gap-y-s","data-placement:absolute","data-[placement=top]:-translate-x-1/2 placement-top:top-0 data-[placement=top]:left-1/2","data-[placement=bottom]:-translate-x-1/2 placement-bottom:bottom-0 data-[placement=bottom]:left-1/2","placement-right:right-0 data-[placement=right]:top-1/2","placement-left:left-0 data-[placement=left]:top-1/2"],list:["flex flex-col gap-y-s"],actions:"flex flex-row-reverse items-center gap-s group-size-small/notice:grow-1 group-size-small/notice:basis-1 group-size-small/notice:justify-start"}});export{l as NoticeStyles};//# sourceMappingURL=styles.js.map
|
|
2
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/notice/styles.ts"],"names":["e"],"mappings":"sCAeE,MAAA,CAAO,CACLA,SACE,CAAA,CAAA,MAAA,CAAA,CAAA,oRAEA,CAAA,+IACA,CAAA,qIAEA,CAAA,+DACA,CAAA,2IAGO,CACP,CAAA,OAAA,CAAA,CAAA,uFAEO,CAAA,CAAA,OAAA,CAAA,4CAEP,CAAA,MAAA,CAAA,CAAA,8DAEA,CAAA,yFACA,CAAA,8JAEA,CAAA,qDAEK,CAAA,CAAA,IAAA,CAAA,CAAA,uBAEL,CAAA,CAAA,OAAA,CAAA,+IAEL,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 NoticeStyles = tv({\n slots: {\n notice: [\n 'group/notice fg-primary-bold flex rounded-medium text-body-s shadow-elevation-overlay outline',\n 'size-small:flex-col size-small:flex-wrap size-small:gap-m size-small:p-s group-data-placement/region:size-small:min-w-[120px] group-data-placement/region:size-small:max-w-[320px]',\n 'size-medium:gap-l size-medium:p-l group-data-placement/region:size-medium:min-w-[200px] group-data-placement/region:size-medium:max-w-[640px]',\n 'color-info:bg-info-muted color-info:outline-info-bold',\n 'color-advisory:bg-advisory-muted color-advisory:outline-accent-primary-bold',\n 'color-normal:bg-normal-muted color-normal:outline-normal-bold',\n 'color-serious:bg-serious-muted color-serious:outline-serious-bold',\n 'color-critical:bg-critical-muted color-critical:outline-critical-bold',\n ],\n content: [\n 'flex flex-1 items-center group-size-medium/notice:gap-l group-size-small/notice:gap-m',\n ],\n message: 'flex-1 group-size-small/notice:basis-10/12',\n region: [\n 'group/region flex flex-col gap-y-s',\n 'data-placement:absolute',\n 'data-[placement=top]:-translate-x-1/2 placement-top:top-0 data-[placement=top]:left-1/2',\n 'data-[placement=bottom]:-translate-x-1/2 placement-bottom:bottom-0 data-[placement=bottom]:left-1/2',\n 'placement-right:right-0 data-[placement=right]:top-1/2',\n 'placement-left:left-0 data-[placement=left]:top-1/2',\n ],\n list: ['flex flex-col gap-y-s'],\n actions:\n 'flex flex-row-reverse items-center gap-s group-size-small/notice:grow-1 group-size-small/notice:basis-1 group-size-small/notice:justify-start',\n },\n});\n"]}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Payload } from '@accelint/bus';
|
|
2
|
+
import { UniqueId } from '@accelint/core';
|
|
3
|
+
import { ToastListProps } from 'react-aria-components';
|
|
4
|
+
import { ButtonProps } from '../button/types.js';
|
|
5
|
+
import { NoticeEventTypes } from './events.js';
|
|
6
|
+
import 'tailwind-variants';
|
|
7
|
+
import '../../lib/types.js';
|
|
8
|
+
import 'react';
|
|
9
|
+
import '../button/styles.js';
|
|
10
|
+
import 'tailwind-merge';
|
|
11
|
+
|
|
12
|
+
type NoticeColor = 'info' | 'advisory' | 'normal' | 'serious' | 'critical';
|
|
13
|
+
type ActionButtonProps = Pick<ButtonProps, 'color' | 'variant'> & {
|
|
14
|
+
children: string;
|
|
15
|
+
};
|
|
16
|
+
type NoticeContent = {
|
|
17
|
+
id: UniqueId;
|
|
18
|
+
message: string;
|
|
19
|
+
color?: NoticeColor;
|
|
20
|
+
primary?: ActionButtonProps;
|
|
21
|
+
secondary?: ActionButtonProps;
|
|
22
|
+
timeout?: number;
|
|
23
|
+
target?: UniqueId;
|
|
24
|
+
metadata?: Record<string, unknown>;
|
|
25
|
+
};
|
|
26
|
+
type NoticeIconProps = {
|
|
27
|
+
color?: NoticeColor;
|
|
28
|
+
size: 'small' | 'medium';
|
|
29
|
+
};
|
|
30
|
+
type NoticeListProps = {
|
|
31
|
+
id?: UniqueId;
|
|
32
|
+
placement?: 'top left' | 'top' | 'top right' | 'right' | 'bottom right' | 'bottom' | 'bottom left' | 'left';
|
|
33
|
+
limit?: number;
|
|
34
|
+
defaultColor?: NoticeColor;
|
|
35
|
+
defaultTimeout?: number;
|
|
36
|
+
hideClearAll?: boolean;
|
|
37
|
+
size?: 'small' | 'medium';
|
|
38
|
+
global?: boolean;
|
|
39
|
+
classNames?: {
|
|
40
|
+
region?: string;
|
|
41
|
+
list?: ToastListProps<NoticeContent>['className'];
|
|
42
|
+
button?: ButtonProps['className'];
|
|
43
|
+
notice?: NoticeProps['classNames'];
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
type NoticeProps = Omit<NoticeContent, 'metadata' | 'timeout' | 'target'> & {
|
|
47
|
+
id: UniqueId;
|
|
48
|
+
classNames?: {
|
|
49
|
+
notice?: string;
|
|
50
|
+
content?: string;
|
|
51
|
+
message?: string;
|
|
52
|
+
actions?: string;
|
|
53
|
+
};
|
|
54
|
+
hideIcon?: boolean;
|
|
55
|
+
showClose?: boolean;
|
|
56
|
+
shouldCloseOnAction?: boolean;
|
|
57
|
+
size?: 'small' | 'medium';
|
|
58
|
+
onPrimaryAction?: () => void;
|
|
59
|
+
onSecondaryAction?: () => void;
|
|
60
|
+
onClose?: () => void;
|
|
61
|
+
};
|
|
62
|
+
type NoticeQueueEvent = Payload<typeof NoticeEventTypes.queue, Omit<NoticeContent, 'id'> & {
|
|
63
|
+
id?: UniqueId;
|
|
64
|
+
}>;
|
|
65
|
+
type NoticeDequeueEvent = Payload<typeof NoticeEventTypes.dequeue, {
|
|
66
|
+
id?: UniqueId;
|
|
67
|
+
target?: UniqueId;
|
|
68
|
+
color?: NoticeColor;
|
|
69
|
+
metadata?: Record<string, unknown>;
|
|
70
|
+
}>;
|
|
71
|
+
type NoticeActionEvent = Payload<typeof NoticeEventTypes.actionPrimary | typeof NoticeEventTypes.actionSecondary | typeof NoticeEventTypes.close, {
|
|
72
|
+
id: UniqueId;
|
|
73
|
+
}>;
|
|
74
|
+
|
|
75
|
+
export type { NoticeActionEvent, NoticeColor, NoticeContent, NoticeDequeueEvent, NoticeIconProps, NoticeListProps, NoticeProps, NoticeQueueEvent };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"types.js"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {jsx,jsxs}from'react/jsx-runtime';import'client-only';import {LockFill,Delete,Duplicate}from'@accelint/icons';import {useMemo,createContext,useCallback}from'react';import {QueryBuilder}from'react-querybuilder';import {cn}from'../../lib/utils.js';import {Button}from'../button/index.js';import {Icon}from'../icon/index.js';import {Label}from'../label/index.js';import {Radio}from'../radio/index.js';import {Tooltip}from'../tooltip/index.js';import {ActionElement}from'./action-element.js';import {RuleGroup,RuleGroupHeaderComponent,RuleGroupFooterComponent}from'./group.js';import {Rule}from'./rule.js';import {getValidationResult,pressToMouseEvent}from'./utils.js';import {ValueEditor}from'./value-editor.js';import {ValueSelector}from'./value-selector.js';const w={AND:"All rules below must be true for a match",OR:"One of the rules below must be true for a match"};function x({options:r,value:n,handleOnChange:l}){return jsxs(Radio.Group,{value:n,onChange:l,orientation:"horizontal",children:[jsx(Label,{children:"Combinator"}),r.map(
|
|
1
|
+
import {jsx,jsxs}from'react/jsx-runtime';import'client-only';import {LockFill,Delete,Duplicate}from'@accelint/icons';import {useMemo,createContext,useCallback}from'react';import {QueryBuilder}from'react-querybuilder';import {cn}from'../../lib/utils.js';import {Button}from'../button/index.js';import {Icon}from'../icon/index.js';import {Label}from'../label/index.js';import {Radio}from'../radio/index.js';import {Tooltip}from'../tooltip/index.js';import {ActionElement}from'./action-element.js';import {RuleGroup,RuleGroupHeaderComponent,RuleGroupFooterComponent}from'./group.js';import {Rule}from'./rule.js';import {getValidationResult,pressToMouseEvent}from'./utils.js';import {ValueEditor}from'./value-editor.js';import {ValueSelector}from'./value-selector.js';const w={AND:"All rules below must be true for a match",OR:"One of the rules below must be true for a match"};function x({options:r,value:n,handleOnChange:l}){return jsxs(Radio.Group,{value:n,onChange:l,orientation:"horizontal",children:[jsx(Label,{children:"Combinator"}),r.map(o=>jsx(Radio,{value:o.label,children:jsxs(Tooltip.Trigger,{children:[jsx("button",{type:"button",children:o.label}),jsx(Tooltip,{placement:"top",children:w[o.label]})]})},o.label))]})}function C({handleOnClick:r,className:n,...l}){const o=useCallback(i=>r(pressToMouseEvent(i)),[r]);return jsx(Button,{size:"small",variant:"icon",onPress:o,className:n,...l,children:jsx(Icon,{children:jsx(Delete,{})})})}function c({handleOnClick:r,className:n,...l}){const o=useCallback(i=>r(pressToMouseEvent(i)),[r]);return jsx(Button,{size:"small",variant:"icon",onPress:o,className:n,...l,children:jsx(Icon,{children:jsx(LockFill,{})})})}function f({handleOnClick:r,className:n,...l}){const o=useCallback(i=>r(pressToMouseEvent(i)),[r]);return jsx(Button,{size:"small",variant:"icon",onPress:o,className:n,...l,children:jsx(Icon,{children:jsx(Duplicate,{})})})}function t({controlClassnames:r,controlElements:n,orientation:l="horizontal",showRuleLines:o=true,...i}){const B=useMemo(()=>({combinatorSelector:x,cloneGroupAction:f,cloneRuleAction:f,removeRuleAction:C,lockGroupAction:c,lockRuleAction:c,ruleGroup:RuleGroup,rule:Rule,actionElement:ActionElement,valueSelector:ValueSelector,valueEditor:ValueEditor,...n}),[n]),d=useMemo(()=>({queryBuilder:"outline outline-transparent",ruleGroup:"group col-span-full flex flex-col gap-s p-s outline outline-info-bold rounded-medium",header:"flex gap-s",body:cn("group grid gap-x-s empty:hidden",o?"grid-cols-[10px_minmax(100px,_1fr)_min-content]":"grid-cols-[minmax(100px,_1fr)_min-content]"),combinators:"my-s",addRule:"",addGroup:"",cloneRule:"fg-info-bold hover:fg-info-hover",cloneGroup:"fg-info-bold hover:fg-info-hover",removeGroup:"",rule:cn("flex gap-xs py-s",l==="vertical"?"flex-col":"min-height-[50px] items-start"),fields:"w-full",operators:"",value:"w-full",removeRule:"",valid:"",invalid:"",disabled:"",lockRule:"fg-info-bold hover:fg-info-hover",lockGroup:"fg-info-bold hover:fg-info-hover",valueSource:"",valueListItem:""}),[l,o]),E=useMemo(()=>({...d,...r}),[r,d]),S=createContext({orientation:l,showRuleLines:o});return jsx(QueryBuilder,{showNotToggle:false,showShiftActions:false,enableDragAndDrop:false,controlClassnames:E,controlElements:B,context:S,listsAsArrays:true,...i})}t.CombinatorSelector=x,t.RemoveRuleAction=C,t.LockAction=c,t.CloneAction=f,t.ActionElement=ActionElement,t.Rule=Rule,t.RuleGroup=RuleGroup,t.RuleGroupHeaderComponent=RuleGroupHeaderComponent,t.RuleGroupFooterComponent=RuleGroupFooterComponent,t.getValidationResult=getValidationResult,t.ValueEditor=ValueEditor,t.ValueSelector=ValueSelector;export{t as QueryBuilder};//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/query-builder/index.tsx"],"names":["jsx","Label","B","b","options","Radio","jsxs","Tooltip","o","z","p","operatorDescriptions","option","RemoveRuleAction","className","event","handleOnClick","pressToMouseEvent","handlePress","rest","c","Icon","a","LockAction","useCallback","T","CloneAction","k","QueryBuilder","m","Q","mergedElements","CombinatorSelector","u","defaultClassnames","R","A","y","P","h","v","orientation","mergedClassnames","useMemo","RQBBuilder","D","V","Rule","RuleGroupFooterComponent","getValidationResult","N","ValueSelector"],"mappings":"4vBA2CM,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,0CAKJ,CAAA,EAAA,CAAA,iDAMI,CAAA,CAAA,SACA,CAAA,CAAA,CAAA,OAAA,CAAY,CAAA,CAAA,KAAA,CAAA,CAAA,CAAA,cAEZA,CAACC,CAAAA,CAAA,CAAM,CAAA,OAAAC,IAAA,CAAAC,KAAA,CAAA,KAAA,CAAA,CAAA,KACNC,CAAAA,CAAQ,CAAA,QACNC,CAAAA,CAAA,CAAyB,WAAc,CAAA,YACtCC,CAACC,QACC,CAAA,CAAAC,GAAA,CAAAC,KAAAT,CAAAA,CAACO,QAAQ,CAAA,YACPP,CAAC,CAAA,CAAA,CAAA,CAAA,GAAA,CAAM,CAAA,EAAAQ,GAAA,CAAAL,KAAA,CAAA,CAAA,KAAO,CAAA,CAAA,CAAA,KAEhBH,CAAAA,QAAC,CAAaE,IAAA,CAAAQ,OAAA,CAAA,CAAA,QAAU,CAAA,CAAAF,GACrB,CAAAE,OAAA,CAAA,OAAAC,CAAqBC,CAAAA,QACxB,CAAAJ,GAAA,CACF,MARiB,CAAA,CAAA,QAe3B,CAAA,CAAA,CAAA,KAAA,CAASK,CAAAA,CAAiB,CAAE,CAAAL,GAAA,CAAAE,OAAA,CAAA,IAAA,CAAA,CAAA,SAAe,CAAA,KAAAI,CA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AA,CAAA,CAAA,CAAA,SAAA,CAAAD,SAAA,CAAA,CAAA,CAAsBc,wBAEtB,CAAAC,wBAAA,CAAA,CAAA,CAAA,wBAAgBC,CAAAA,wBAAAA,CAAAA,CAAAA,CAAAA,mBAAAA,CAAAA,mBAAAA,CAAAA,CAAAA,CAAAA,WAAAA,CAAAA,WAAAA,CAAAA,CAAAA,CAAAA,aAAAA,CAAAA,aAAAA","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 { Delete, Duplicate, LockFill } from '@accelint/icons';\nimport { createContext, useCallback, useMemo } from 'react';\nimport {\n type ActionProps,\n type Classnames,\n type CombinatorSelectorProps,\n QueryBuilder as RQBBuilder,\n} from 'react-querybuilder';\nimport { cn } from '../../lib/utils';\nimport { Button } from '../button';\nimport { Icon } from '../icon';\nimport { Label } from '../label';\nimport { Radio } from '../radio';\nimport { Tooltip } from '../tooltip';\nimport { ActionElement } from './action-element';\nimport {\n RuleGroup,\n RuleGroupFooterComponent,\n RuleGroupHeaderComponent,\n} from './group';\nimport { Rule } from './rule';\nimport { getValidationResult, pressToMouseEvent } from './utils';\nimport { ValueEditor } from './value-editor';\nimport { ValueSelector } from './value-selector';\nimport type { PressEvent } from '@react-types/shared';\nimport type { QueryBuilderContextType, QueryBuilderProps } from './types';\n\nconst operatorDescriptions: Record<string, string> = {\n AND: 'All rules below must be true for a match',\n OR: 'One of the rules below must be true for a match',\n};\n\nfunction CombinatorSelector({\n options,\n value,\n handleOnChange,\n}: CombinatorSelectorProps) {\n return (\n <Radio.Group\n value={value}\n onChange={handleOnChange}\n orientation='horizontal'\n >\n <Label>Combinator</Label>\n {options.map((option) => (\n <Radio key={option.label} value={option.label}>\n <Tooltip>\n <Tooltip.Trigger>\n <span>{option.label}</span>\n </Tooltip.Trigger>\n <Tooltip.Body placement='top'>\n {operatorDescriptions[option.label]}\n </Tooltip.Body>\n </Tooltip>\n </Radio>\n ))}\n </Radio.Group>\n );\n}\n\nfunction RemoveRuleAction({ handleOnClick, className, ...rest }: ActionProps) {\n // TODO: remove pressToMouseEvent when design-system is removed\n const handlePress = useCallback(\n (event: PressEvent) => handleOnClick(pressToMouseEvent(event)),\n [handleOnClick],\n );\n\n return (\n <Button\n size='small'\n variant='icon'\n onPress={handlePress}\n className={className}\n {...rest}\n >\n <Icon>\n <Delete />\n </Icon>\n </Button>\n );\n}\n\nfunction LockAction({ handleOnClick, className, ...rest }: ActionProps) {\n // TODO: remove pressToMouseEvent when design-system is removed\n const handlePress = useCallback(\n (event: PressEvent) => handleOnClick(pressToMouseEvent(event)),\n [handleOnClick],\n );\n\n return (\n <Button\n size='small'\n variant='icon'\n onPress={handlePress}\n className={className}\n {...rest}\n >\n <Icon>\n <LockFill />\n </Icon>\n </Button>\n );\n}\n\nfunction CloneAction({ handleOnClick, className, ...rest }: ActionProps) {\n // TODO: remove pressToMouseEvent when design-system is removed\n const handlePress = useCallback(\n (event: PressEvent) => handleOnClick(pressToMouseEvent(event)),\n [handleOnClick],\n );\n\n return (\n <Button\n size='small'\n variant='icon'\n onPress={handlePress}\n className={className}\n {...rest}\n >\n <Icon>\n <Duplicate />\n </Icon>\n </Button>\n );\n}\n\n/**\n * QueryBuilder - A visual interface for building complex database queries\n *\n * Provides an intuitive drag-and-drop interface for constructing database queries\n * with support for multiple conditions, operators, and logical grouping. Enables\n * users to build complex filters without writing SQL or code.\n *\n * @example\n * // Basic query builder\n * <QueryBuilder\n * fields={[\n * // { name, label, type, inputType, operators },\n * ]}\n * query={\n * // { combinator, rules }\n * }\n * onQueryChange={handleQueryChange}\n * controlElements={{\n * addRuleAction: CustomAddButton,\n * removeRuleAction: CustomRemoveButton\n * }}\n * orientation=\"vertical\"\n * />\n */\nexport function QueryBuilder({\n controlClassnames,\n controlElements,\n orientation = 'horizontal',\n showRuleLines = true,\n ...rest\n}: QueryBuilderProps) {\n /**\n * Represents the list of available controls that the component can use as a custom\n * component override.Passed in as a map of our custom defaults, but can be\n * overridden by using the controlElements prop\n */\n const mergedElements = useMemo(\n () => ({\n combinatorSelector: CombinatorSelector,\n cloneGroupAction: CloneAction,\n cloneRuleAction: CloneAction,\n removeRuleAction: RemoveRuleAction,\n lockGroupAction: LockAction,\n lockRuleAction: LockAction,\n ruleGroup: RuleGroup,\n rule: Rule,\n actionElement: ActionElement,\n valueSelector: ValueSelector,\n valueEditor: ValueEditor,\n ...controlElements,\n }),\n [controlElements],\n );\n\n /**\n * Represents the list of available classnames that the component will recognize.\n * Passed in as a map as all the default styling, but can be overridden by using the\n * controlClassnames prop\n */\n const defaultClassnames: Partial<Classnames> = useMemo(\n () => ({\n queryBuilder: 'outline outline-transparent',\n ruleGroup:\n 'group col-span-full flex flex-col gap-s p-s outline outline-info-bold rounded-medium',\n header: 'flex gap-s',\n body: cn(\n 'group grid gap-x-s empty:hidden',\n showRuleLines\n ? 'grid-cols-[10px_minmax(100px,_1fr)_min-content]'\n : 'grid-cols-[minmax(100px,_1fr)_min-content]',\n ),\n combinators: 'my-s',\n addRule: '',\n addGroup: '',\n cloneRule: 'fg-info-bold hover:fg-info-hover',\n cloneGroup: 'fg-info-bold hover:fg-info-hover',\n removeGroup: '',\n rule: cn(\n 'flex gap-xs py-s',\n orientation === 'vertical'\n ? 'flex-col'\n : 'min-height-[50px] items-start',\n ),\n fields: 'w-full',\n operators: '',\n value: 'w-full',\n removeRule: '',\n valid: '',\n invalid: '',\n disabled: '',\n lockRule: 'fg-info-bold hover:fg-info-hover',\n lockGroup: 'fg-info-bold hover:fg-info-hover',\n valueSource: '',\n valueListItem: '',\n }),\n [orientation, showRuleLines],\n );\n\n const mergedClassnames = useMemo(() => {\n return {\n ...defaultClassnames,\n ...controlClassnames,\n };\n }, [controlClassnames, defaultClassnames]);\n\n const QueryBuilderContext = createContext<QueryBuilderContextType>({\n orientation,\n showRuleLines,\n });\n\n return (\n <RQBBuilder\n showNotToggle={false}\n showShiftActions={false}\n enableDragAndDrop={false}\n controlClassnames={mergedClassnames}\n controlElements={mergedElements}\n context={QueryBuilderContext}\n listsAsArrays\n {...rest}\n />\n );\n}\n\nQueryBuilder.CombinatorSelector = CombinatorSelector;\nQueryBuilder.RemoveRuleAction = RemoveRuleAction;\nQueryBuilder.LockAction = LockAction;\nQueryBuilder.CloneAction = CloneAction;\nQueryBuilder.ActionElement = ActionElement;\nQueryBuilder.Rule = Rule;\nQueryBuilder.RuleGroup = RuleGroup;\nQueryBuilder.RuleGroupHeaderComponent = RuleGroupHeaderComponent;\nQueryBuilder.RuleGroupFooterComponent = RuleGroupFooterComponent;\nQueryBuilder.getValidationResult = getValidationResult;\nQueryBuilder.ValueEditor = ValueEditor;\nQueryBuilder.ValueSelector = ValueSelector;\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/query-builder/index.tsx"],"names":["jsx","Label","G","v","options","Radio","jsxs","Tooltip","e","z","b","operatorDescriptions","option","RemoveRuleAction","className","event","handleOnClick","pressToMouseEvent","handlePress","rest","p","Icon","a","LockAction","useCallback","T","CloneAction","k","QueryBuilder","Q","mergedElements","CombinatorSelector","s","defaultClassnames","y","A","R","P","h","g","orientation","mergedClassnames","useMemo","RQBBuilder","D","V","Rule","RuleGroupFooterComponent","getValidationResult","N","ValueSelector"],"mappings":"4vBA2CM,MAAA,CAAA,CAAA,CAAA,GAAA,CAAA,0CAKJ,CAAA,EAAA,CAAA,iDAMI,CAAA,CAAA,SACA,CAAA,CAAA,CAAA,OAAA,CAAY,CAAA,CAAA,KAAA,CAAA,CAAA,CAAA,cAEZA,CAACC,CAAAA,CAAA,CAAM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kB,WAClB,CAAA,CAAA,CAAA,aACA,CAAA,CAAA,CAAA,CAAA,CAAA,OAAApC,GAAA,CAAAqC,YAAmBJ,CAAAA,CACnB,aAAA,CAAA,KAAiBX,CAAAA,gBAEjB,CAAA,KAAA,CAAA,iBAMO,CAAA,KAAA,CAAA,iBACbF,CAAAA,CAAa,CAAA,eAAA,CAAmBf,CAAAA,CAChCe,OAAa,CAAA,CAAA,CAAA,aACA,CAAA,IAAA,CAAA,GAAcF,CAC3BE,CAAAA,CAAa,CAAA,CAAA,CAAA,kBACA,CAAA,CAAOkB,CAAAA,CACpBlB,CAAAA,gBACa,CAAA,CAAA,CAAA,CAAA,CAAA,UAAA,CAAA,CAAA,CAAA,CAAA,CAAA,WACA,CAAA,CAAA,CAAA,CAAA,CAAA,aAAA,CAAAQ,aAAA,CAAA,CAA2BW,CAAAA,IAC3B,CAAAZ,IAAA,CAAA,CAAA,CAAA,SAAA,CAAAD,SAAA,CAAA,CAAA,CAAsBc,wBAEtB,CAAAC,wBAAA,CAAA,CAAA,CAAA,wBAAgBC,CAAAA,wBAAAA,CAAAA,CAAAA,CAAAA,mBAAAA,CAAAA,mBAAAA,CAAAA,CAAAA,CAAAA,WAAAA,CAAAA,WAAAA,CAAAA,CAAAA,CAAAA,aAAAA,CAAAA,aAAAA","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 { Delete, Duplicate, LockFill } from '@accelint/icons';\nimport { createContext, useCallback, useMemo } from 'react';\nimport {\n type ActionProps,\n type Classnames,\n type CombinatorSelectorProps,\n QueryBuilder as RQBBuilder,\n} from 'react-querybuilder';\nimport { cn } from '../../lib/utils';\nimport { Button } from '../button';\nimport { Icon } from '../icon';\nimport { Label } from '../label';\nimport { Radio } from '../radio';\nimport { Tooltip } from '../tooltip';\nimport { ActionElement } from './action-element';\nimport {\n RuleGroup,\n RuleGroupFooterComponent,\n RuleGroupHeaderComponent,\n} from './group';\nimport { Rule } from './rule';\nimport { getValidationResult, pressToMouseEvent } from './utils';\nimport { ValueEditor } from './value-editor';\nimport { ValueSelector } from './value-selector';\nimport type { PressEvent } from '@react-types/shared';\nimport type { QueryBuilderContextType, QueryBuilderProps } from './types';\n\nconst operatorDescriptions: Record<string, string> = {\n AND: 'All rules below must be true for a match',\n OR: 'One of the rules below must be true for a match',\n};\n\nfunction CombinatorSelector({\n options,\n value,\n handleOnChange,\n}: CombinatorSelectorProps) {\n return (\n <Radio.Group\n value={value}\n onChange={handleOnChange}\n orientation='horizontal'\n >\n <Label>Combinator</Label>\n {options.map((option) => (\n <Radio key={option.label} value={option.label}>\n <Tooltip.Trigger>\n <button type='button'>{option.label}</button>\n <Tooltip placement='top'>\n {operatorDescriptions[option.label]}\n </Tooltip>\n </Tooltip.Trigger>\n </Radio>\n ))}\n </Radio.Group>\n );\n}\n\nfunction RemoveRuleAction({ handleOnClick, className, ...rest }: ActionProps) {\n // TODO: remove pressToMouseEvent when design-system is removed\n const handlePress = useCallback(\n (event: PressEvent) => handleOnClick(pressToMouseEvent(event)),\n [handleOnClick],\n );\n\n return (\n <Button\n size='small'\n variant='icon'\n onPress={handlePress}\n className={className}\n {...rest}\n >\n <Icon>\n <Delete />\n </Icon>\n </Button>\n );\n}\n\nfunction LockAction({ handleOnClick, className, ...rest }: ActionProps) {\n // TODO: remove pressToMouseEvent when design-system is removed\n const handlePress = useCallback(\n (event: PressEvent) => handleOnClick(pressToMouseEvent(event)),\n [handleOnClick],\n );\n\n return (\n <Button\n size='small'\n variant='icon'\n onPress={handlePress}\n className={className}\n {...rest}\n >\n <Icon>\n <LockFill />\n </Icon>\n </Button>\n );\n}\n\nfunction CloneAction({ handleOnClick, className, ...rest }: ActionProps) {\n // TODO: remove pressToMouseEvent when design-system is removed\n const handlePress = useCallback(\n (event: PressEvent) => handleOnClick(pressToMouseEvent(event)),\n [handleOnClick],\n );\n\n return (\n <Button\n size='small'\n variant='icon'\n onPress={handlePress}\n className={className}\n {...rest}\n >\n <Icon>\n <Duplicate />\n </Icon>\n </Button>\n );\n}\n\n/**\n * QueryBuilder - A visual interface for building complex database queries\n *\n * Provides an intuitive drag-and-drop interface for constructing database queries\n * with support for multiple conditions, operators, and logical grouping. Enables\n * users to build complex filters without writing SQL or code.\n *\n * @example\n * // Basic query builder\n * <QueryBuilder\n * fields={[\n * // { name, label, type, inputType, operators },\n * ]}\n * query={\n * // { combinator, rules }\n * }\n * onQueryChange={handleQueryChange}\n * controlElements={{\n * addRuleAction: CustomAddButton,\n * removeRuleAction: CustomRemoveButton\n * }}\n * orientation=\"vertical\"\n * />\n */\nexport function QueryBuilder({\n controlClassnames,\n controlElements,\n orientation = 'horizontal',\n showRuleLines = true,\n ...rest\n}: QueryBuilderProps) {\n /**\n * Represents the list of available controls that the component can use as a custom\n * component override.Passed in as a map of our custom defaults, but can be\n * overridden by using the controlElements prop\n */\n const mergedElements = useMemo(\n () => ({\n combinatorSelector: CombinatorSelector,\n cloneGroupAction: CloneAction,\n cloneRuleAction: CloneAction,\n removeRuleAction: RemoveRuleAction,\n lockGroupAction: LockAction,\n lockRuleAction: LockAction,\n ruleGroup: RuleGroup,\n rule: Rule,\n actionElement: ActionElement,\n valueSelector: ValueSelector,\n valueEditor: ValueEditor,\n ...controlElements,\n }),\n [controlElements],\n );\n\n /**\n * Represents the list of available classnames that the component will recognize.\n * Passed in as a map as all the default styling, but can be overridden by using the\n * controlClassnames prop\n */\n const defaultClassnames: Partial<Classnames> = useMemo(\n () => ({\n queryBuilder: 'outline outline-transparent',\n ruleGroup:\n 'group col-span-full flex flex-col gap-s p-s outline outline-info-bold rounded-medium',\n header: 'flex gap-s',\n body: cn(\n 'group grid gap-x-s empty:hidden',\n showRuleLines\n ? 'grid-cols-[10px_minmax(100px,_1fr)_min-content]'\n : 'grid-cols-[minmax(100px,_1fr)_min-content]',\n ),\n combinators: 'my-s',\n addRule: '',\n addGroup: '',\n cloneRule: 'fg-info-bold hover:fg-info-hover',\n cloneGroup: 'fg-info-bold hover:fg-info-hover',\n removeGroup: '',\n rule: cn(\n 'flex gap-xs py-s',\n orientation === 'vertical'\n ? 'flex-col'\n : 'min-height-[50px] items-start',\n ),\n fields: 'w-full',\n operators: '',\n value: 'w-full',\n removeRule: '',\n valid: '',\n invalid: '',\n disabled: '',\n lockRule: 'fg-info-bold hover:fg-info-hover',\n lockGroup: 'fg-info-bold hover:fg-info-hover',\n valueSource: '',\n valueListItem: '',\n }),\n [orientation, showRuleLines],\n );\n\n const mergedClassnames = useMemo(() => {\n return {\n ...defaultClassnames,\n ...controlClassnames,\n };\n }, [controlClassnames, defaultClassnames]);\n\n const QueryBuilderContext = createContext<QueryBuilderContextType>({\n orientation,\n showRuleLines,\n });\n\n return (\n <RQBBuilder\n showNotToggle={false}\n showShiftActions={false}\n enableDragAndDrop={false}\n controlClassnames={mergedClassnames}\n controlElements={mergedElements}\n context={QueryBuilderContext}\n listsAsArrays\n {...rest}\n />\n );\n}\n\nQueryBuilder.CombinatorSelector = CombinatorSelector;\nQueryBuilder.RemoveRuleAction = RemoveRuleAction;\nQueryBuilder.LockAction = LockAction;\nQueryBuilder.CloneAction = CloneAction;\nQueryBuilder.ActionElement = ActionElement;\nQueryBuilder.Rule = Rule;\nQueryBuilder.RuleGroup = RuleGroup;\nQueryBuilder.RuleGroupHeaderComponent = RuleGroupHeaderComponent;\nQueryBuilder.RuleGroupFooterComponent = RuleGroupFooterComponent;\nQueryBuilder.getValidationResult = getValidationResult;\nQueryBuilder.ValueEditor = ValueEditor;\nQueryBuilder.ValueSelector = ValueSelector;\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {tv}from'./../../lib/utils.js';const i={variant:"outlined"},o=tv({slots:{field:["group/search-field fg-primary-bold flex items-center gap-s rounded-round p-s outline","focus-visible-within:outline-accent-primary-bold","hover:outline-interactive-hover","disabled:fg-disabled disabled:placeholder:fg-disabled disabled:cursor-not-allowed disabled:outline-interactive-disabled"],input:["hide-cancel block w-full font-display text-body-s outline-none","placeholder:fg-primary-muted","disabled:cursor-not-allowed"],clear:["fg-info-bold cursor-pointer","focus-visible:fg-info-hover","hover:fg-info-hover","group-empty/search-field:invisible group-disabled/search-field:invisible"],loading:"motion-safe:animate-spin",search:""},variants:{variant:{filled:{field:"bg-surface-raised outline-static"},outlined:{field:"outline-interactive"}}},defaultVariants:i});export{o as SearchFieldStyles,i as SearchFieldStylesDefaults};//# sourceMappingURL=styles.js.map
|
|
1
|
+
import {tv}from'./../../lib/utils.js';const i={variant:"outlined"},o=tv({slots:{field:["group/search-field fg-primary-bold flex items-center gap-s rounded-round p-s outline","focus-visible-within:outline-accent-primary-bold","hover:outline-interactive-hover","pressed:outline-interactive-pressed","disabled:fg-disabled disabled:placeholder:fg-disabled disabled:cursor-not-allowed disabled:outline-interactive-disabled"],input:["hide-cancel block w-full font-display text-body-s outline-none","placeholder:fg-primary-muted","disabled:cursor-not-allowed"],clear:["fg-info-bold cursor-pointer","focus-visible:fg-info-hover","hover:fg-info-hover","group-empty/search-field:invisible group-disabled/search-field:invisible"],loading:"motion-safe:animate-spin",search:""},variants:{variant:{filled:{field:"bg-surface-raised outline-static"},outlined:{field:"outline-interactive"}}},defaultVariants:i});export{o as SearchFieldStyles,i as SearchFieldStylesDefaults};//# sourceMappingURL=styles.js.map
|
|
2
2
|
//# sourceMappingURL=styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/search-field/styles.ts"],"names":["e"],"mappings":"sCAeE,MAAA,CAAS,CAAA,CAAA,OAAA,CACX,UAGE,CAAA,CAAA,CAAO,CACLA,EAAA,CAAA,CAAA,KACE,CAAA,CAAA,KAAA,CAAA,CAAA,sFACA,CAAA,kDACA,CAAA,iCACA,CAAA,yHAGA,CAAA,CAAA,KAAA,CAAA,CAAA,gEACA,CAAA,8BACA,CAAA,6BAGA,CAAA,CAAA,KAAA,CAAA,CAAA,6BACA,CAAA,6BACA,CAAA,qBACA,CAAA,0EAEO,CAAA,CAAA,OAAA,CAAA,0BAEX,CAAA,MACA,CAAA,EAAA,CAAU,CACR,QAAS,CACP,CAAA,OACE,CAAA,CAAA,MAAO,CAAA,CAAA,KAAA,CAAA,kCAET,CAAU,CACR,QAAO,CAAA,CAAA,KAAA,CAAA,qBAIb,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 SearchFieldStylesDefaults = {\n variant: 'outlined',\n} as const;\n\nexport const SearchFieldStyles = tv({\n slots: {\n field: [\n 'group/search-field fg-primary-bold flex items-center gap-s rounded-round p-s outline',\n 'focus-visible-within:outline-accent-primary-bold',\n 'hover:outline-interactive-hover',\n 'disabled:fg-disabled disabled:placeholder:fg-disabled disabled:cursor-not-allowed disabled:outline-interactive-disabled',\n ],\n input: [\n 'hide-cancel block w-full font-display text-body-s outline-none',\n 'placeholder:fg-primary-muted',\n 'disabled:cursor-not-allowed',\n ],\n clear: [\n 'fg-info-bold cursor-pointer',\n 'focus-visible:fg-info-hover',\n 'hover:fg-info-hover',\n 'group-empty/search-field:invisible group-disabled/search-field:invisible',\n ],\n loading: 'motion-safe:animate-spin',\n search: '',\n },\n variants: {\n variant: {\n filled: {\n field: 'bg-surface-raised outline-static',\n },\n outlined: {\n field: 'outline-interactive',\n },\n },\n },\n defaultVariants: SearchFieldStylesDefaults,\n});\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/search-field/styles.ts"],"names":["e"],"mappings":"sCAeE,MAAA,CAAS,CAAA,CAAA,OAAA,CACX,UAGE,CAAA,CAAA,CAAO,CACLA,EAAA,CAAA,CAAA,KACE,CAAA,CAAA,KAAA,CAAA,CAAA,sFACA,CAAA,kDACA,CAAA,iCACA,CAAA,qCACA,CAAA,yHAGA,CAAA,CAAA,KAAA,CAAA,CAAA,gEACA,CAAA,8BACA,CAAA,6BAGA,CAAA,CAAA,KAAA,CAAA,CAAA,6BACA,CAAA,6BACA,CAAA,qBACA,CAAA,0EAEO,CAAA,CAAA,OAAA,CAAA,0BAEX,CAAA,MACA,CAAA,EAAA,CAAU,CACR,QAAS,CACP,CAAA,OACE,CAAA,CAAA,MAAO,CAAA,CAAA,KAAA,CAAA,kCAET,CAAU,CACR,QAAO,CAAA,CAAA,KAAA,CAAA,qBAIb,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 SearchFieldStylesDefaults = {\n variant: 'outlined',\n} as const;\n\nexport const SearchFieldStyles = tv({\n slots: {\n field: [\n 'group/search-field fg-primary-bold flex items-center gap-s rounded-round p-s outline',\n 'focus-visible-within:outline-accent-primary-bold',\n 'hover:outline-interactive-hover',\n 'pressed:outline-interactive-pressed',\n 'disabled:fg-disabled disabled:placeholder:fg-disabled disabled:cursor-not-allowed disabled:outline-interactive-disabled',\n ],\n input: [\n 'hide-cancel block w-full font-display text-body-s outline-none',\n 'placeholder:fg-primary-muted',\n 'disabled:cursor-not-allowed',\n ],\n clear: [\n 'fg-info-bold cursor-pointer',\n 'focus-visible:fg-info-hover',\n 'hover:fg-info-hover',\n 'group-empty/search-field:invisible group-disabled/search-field:invisible',\n ],\n loading: 'motion-safe:animate-spin',\n search: '',\n },\n variants: {\n variant: {\n filled: {\n field: 'bg-surface-raised outline-static',\n },\n outlined: {\n field: 'outline-interactive',\n },\n },\n },\n defaultVariants: SearchFieldStylesDefaults,\n});\n"]}
|
|
@@ -1,11 +1,67 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { SidenavProps, SidenavTriggerProps, SidenavHeaderProps, SidenavItemProps, SidenavLinkProps,
|
|
2
|
+
import { SidenavProps, SidenavTriggerProps, SidenavHeaderProps, SidenavItemProps, SidenavLinkProps, SidenavAvatarProps, SidenavFooterProps, SidenavContentProps, SidenavMenuProps, SidenavMenuItemProps } from './types.js';
|
|
3
3
|
import '@accelint/bus';
|
|
4
4
|
import '@accelint/core';
|
|
5
5
|
import 'react';
|
|
6
6
|
import 'react-aria-components';
|
|
7
7
|
import './events.js';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Sidenav - Collapsible side navigation panel
|
|
11
|
+
*
|
|
12
|
+
* Provides a hierarchical collapsible side navigation intended to be used
|
|
13
|
+
* inside a Drawer.Layout. Supports headers, avatars, nested menus, and items.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* <Drawer.Layout push="left">
|
|
17
|
+
* <Drawer.Layout.Main className="col-start-2">
|
|
18
|
+
* <Sidenav.Trigger>
|
|
19
|
+
* <Button variant="icon" size="large">
|
|
20
|
+
* <Icon>
|
|
21
|
+
* <MenuIcon />
|
|
22
|
+
* </Icon>
|
|
23
|
+
* </Button>
|
|
24
|
+
* </Sidenav.Trigger>
|
|
25
|
+
* </Drawer.Layout.Main>
|
|
26
|
+
* <Sidenav>
|
|
27
|
+
* <Sidenav.Header>
|
|
28
|
+
* <Sidenav.Avatar>
|
|
29
|
+
* <Icon><AppLogo /></Icon>
|
|
30
|
+
* <Heading>Application Header</Heading>
|
|
31
|
+
* <Text>subheader</Text>
|
|
32
|
+
* </Sidenav.Avatar>
|
|
33
|
+
* </Sidenav.Header>
|
|
34
|
+
* <Sidenav.Content>
|
|
35
|
+
* <Heading>Navigation</Heading>
|
|
36
|
+
* <Sidenav.Item>
|
|
37
|
+
* <Icon><HomeIcon /></Icon>
|
|
38
|
+
* <Text>Home</Text>
|
|
39
|
+
* </Sidenav.Item>
|
|
40
|
+
* <Divider />
|
|
41
|
+
* <Sidenav.Item isSelected>
|
|
42
|
+
* <Icon><SettingsIcon /></Icon>
|
|
43
|
+
* <Text>Settings</Text>
|
|
44
|
+
* </Sidenav.Item>
|
|
45
|
+
* <Divider />
|
|
46
|
+
* <Sidenav.Menu title="More Options" icon={<Icon><MenuIcon /></Icon>}>
|
|
47
|
+
* <Sidenav.Menu.Item>
|
|
48
|
+
* <Text>Sub Item 1</Text>
|
|
49
|
+
* </Sidenav.Menu.Item>
|
|
50
|
+
* <Sidenav.Menu.Item>
|
|
51
|
+
* <Text>Sub Item 2</Text>
|
|
52
|
+
* </Sidenav.Menu.Item>
|
|
53
|
+
* </Sidenav.Menu>
|
|
54
|
+
* </Sidenav.Content>
|
|
55
|
+
* <Sidenav.Footer>
|
|
56
|
+
* <Sidenav.Avatar>
|
|
57
|
+
* <Icon><UserIcon /></Icon>
|
|
58
|
+
* <Heading>User Name</Heading>
|
|
59
|
+
* <Text>john@example.com</Text>
|
|
60
|
+
* </Sidenav.Avatar>
|
|
61
|
+
* </Sidenav.Footer>
|
|
62
|
+
* </Sidenav>
|
|
63
|
+
* </Drawer.Layout>
|
|
64
|
+
*/
|
|
9
65
|
declare function Sidenav({ id, className, isHiddenWhenClosed, children, ...rest }: SidenavProps): react_jsx_runtime.JSX.Element | null;
|
|
10
66
|
declare namespace Sidenav {
|
|
11
67
|
var displayName: string;
|
|
@@ -13,7 +69,6 @@ declare namespace Sidenav {
|
|
|
13
69
|
var Header: typeof SidenavHeader;
|
|
14
70
|
var Item: typeof SidenavItem;
|
|
15
71
|
var Link: typeof SidenavLink;
|
|
16
|
-
var Divider: typeof SidenavDivider;
|
|
17
72
|
var Avatar: typeof SidenavAvatar;
|
|
18
73
|
var Footer: typeof SidenavFooter;
|
|
19
74
|
var Content: typeof SidenavContent;
|
|
@@ -43,10 +98,6 @@ declare function SidenavLink({ children, classNames, textValue, ...rest }: Siden
|
|
|
43
98
|
declare namespace SidenavLink {
|
|
44
99
|
var displayName: string;
|
|
45
100
|
}
|
|
46
|
-
declare function SidenavDivider({ className, ...rest }: SidenavDividerProps): react_jsx_runtime.JSX.Element;
|
|
47
|
-
declare namespace SidenavDivider {
|
|
48
|
-
var displayName: string;
|
|
49
|
-
}
|
|
50
101
|
declare function SidenavAvatar({ children, className, ...rest }: SidenavAvatarProps): react_jsx_runtime.JSX.Element;
|
|
51
102
|
declare namespace SidenavAvatar {
|
|
52
103
|
var displayName: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import {jsx,jsxs,Fragment}from'react/jsx-runtime';import'client-only';import {useOn,useEmit}from'@accelint/bus/react';import {uuid,isUUID}from'@accelint/core';import {ChevronLeft,ArrowNortheast,ChevronDown}from'@accelint/icons';import {createContext,useState,useContext,useRef}from'react';import {Provider,HeadingContext,DEFAULT_SLOT,Header,Button,composeRenderProps,Pressable,Text,TextContext,ToggleButton,Link,Heading,Disclosure,DisclosurePanel,DialogTrigger,Popover}from'react-aria-components';import {containsExactChildren,containsAnyOfExactChildren}from'./../../lib/react.js';import {Avatar,AvatarContext}from'../avatar/index.js';import {Icon,IconContext}from'../icon/index.js';import {Tooltip}from'../tooltip/index.js';import {SidenavEventTypes}from'./events.js';import {SidenavStyles}from'./styles.js';const{sidenav:ve,content:pe,header:ce,toggle:ue,heading:ge,divider:
|
|
3
|
+
import {jsx,jsxs,Fragment}from'react/jsx-runtime';import'client-only';import {useOn,useEmit}from'@accelint/bus/react';import {uuid,isUUID}from'@accelint/core';import {ChevronLeft,ArrowNortheast,ChevronDown}from'@accelint/icons';import {createContext,useState,useContext,useRef}from'react';import {Provider,HeadingContext,DEFAULT_SLOT,Header,Button,composeRenderProps,Pressable,Text,TextContext,ToggleButton,Link,Heading,Disclosure,DisclosurePanel,DialogTrigger,Popover}from'react-aria-components';import {containsExactChildren,containsAnyOfExactChildren}from'./../../lib/react.js';import {Avatar,AvatarContext}from'../avatar/index.js';import {DividerContext}from'../divider/index.js';import {Icon,IconContext}from'../icon/index.js';import {Tooltip}from'../tooltip/index.js';import {SidenavEventTypes}from'./events.js';import {SidenavStyles}from'./styles.js';const{sidenav:ve,content:pe,header:ce,toggle:ue,heading:ge,divider:Ne,item:Se,text:z,transient:p,avatar:fe,avatarHeading:Pe,avatarIcon:V,avatarText:xe,link:Te,tooltip:b,menu:Ce,menuButton:_,menuHeading:ye,menuPanel:Ie,menuItem:Ee,panelHeading:He,panelContent:G}=SidenavStyles(),f=createContext({id:uuid(),isOpen:false});function d({id:a,className:t,isHiddenWhenClosed:n,children:i,...r}){containsExactChildren({children:i,componentName:d.displayName,restrictions:[[L,{min:1,max:1}],[A,{min:1,max:1}],[M,{min:0,max:1}]]});const[o,m]=useState(false);return useOn(SidenavEventTypes.toggle,s=>{s.payload.id===a&&m(K=>!K);}),useOn(SidenavEventTypes.open,s=>{!o&&s.payload.id===a&&m(true);}),useOn(SidenavEventTypes.close,s=>{o&&s.payload.id===a&&m(false);}),n&&!o?null:jsx(Provider,{values:[[HeadingContext,{slots:{[DEFAULT_SLOT]:{className:ge({className:p()})},menu:{className:ye({className:p()})},panel:{className:He()}}}],[f,{id:a,isOpen:o}]],children:jsx("nav",{...r,className:ve({className:t}),"data-open":o||null,children:i})})}d.displayName="Sidenav";function A({className:a,children:t,...n}){return jsx(Provider,{values:[[DividerContext,{className:Ne()}]],children:jsx("div",{...n,className:pe({className:a}),children:t})})}A.displayName="Sidenav.Content";function L({children:a,classNames:t,...n}){const i=useEmit(SidenavEventTypes.toggle),{id:r}=useContext(f);return jsx(Header,{...n,className:ce({className:t?.header}),children:jsxs(Button,{className:composeRenderProps(t?.button,o=>ue({className:o})),onPress:()=>i({id:r}),children:[a,jsx(Icon,{className:p(),children:jsx(ChevronLeft,{})})]})})}L.displayName="Sidenav.Header";function M(a){return jsx("footer",{...a})}M.displayName="Sidenav.Footer";function J({children:a,for:t,...n}){const[i,r]=isUUID(t)?["toggle",t]:t.split(":"),o=useEmit(SidenavEventTypes[i]);return jsx(Pressable,{...n,onPress:()=>o({id:r}),children:a})}J.displayName="Sidenav.Trigger";function k({children:a,classNames:t,textValue:n,...i}){containsAnyOfExactChildren({children:a,componentName:k.displayName,restrictions:[[[C,{min:1,max:1}]],[[Icon,{min:1,max:1}],[Text,{min:1,max:1}]]]});const{isOpen:r}=useContext(f),o=useRef(null);return jsx(Provider,{values:[[IconContext,{size:"medium"}],[TextContext,{className:z({className:p()})}]],children:jsxs(Tooltip.Trigger,{isDisabled:r,children:[jsx(ToggleButton,{...i,ref:o,className:composeRenderProps(t?.button,m=>Se({className:m})),children:a}),jsx(Tooltip,{parentRef:o,placement:"right",className:b(),children:n})]})})}k.displayName="Sidenav.Item";function B({children:a,classNames:t,textValue:n,...i}){containsExactChildren({children:a,componentName:B.displayName,restrictions:[[Icon,{min:1,max:1}],[Text,{min:1,max:1}]]});const{isOpen:r}=useContext(f),o=useRef(null);return jsx(Provider,{values:[[TextContext,{className:z({className:p()})}]],children:jsxs(Tooltip.Trigger,{isDisabled:r,children:[jsx(Link,{...i,ref:o,className:composeRenderProps(t?.button,m=>Te({className:m})),children:composeRenderProps(a,m=>jsxs(Fragment,{children:[m,jsx(Icon,{className:p(),children:jsx(ArrowNortheast,{})})]}))}),jsxs(Tooltip,{parentRef:o,placement:"right",className:b(),children:[n,jsx(Icon,{children:jsx(ArrowNortheast,{})})]})]})})}B.displayName="Sidenav.Link";function C({children:a,className:t,...n}){return containsAnyOfExactChildren({children:a,componentName:C.displayName,restrictions:[[[Avatar,{min:1,max:1}],[Heading,{min:1,max:1}],[Text,{min:0,max:1}]],[[Icon,{min:1,max:1}],[Heading,{min:1,max:1}],[Text,{min:0,max:1}]]]}),jsx(Provider,{values:[[IconContext,{size:"large",className:V()}],[HeadingContext,{className:Pe({className:p()})}],[TextContext,{className:xe({className:p()})}],[AvatarContext,{classNames:{avatar:V()}}]],children:jsx("div",{...n,className:fe({className:t}),children:a})})}C.displayName="Sidenav.Avatar";function y({icon:a,title:t,classNames:n,children:i,...r}){containsExactChildren({children:i,componentName:y.displayName,restrictions:[[I,{min:2}]]});const{isOpen:o}=useContext(f),m=useRef(null);return o?jsxs(Disclosure,{className:composeRenderProps(n?.menu,s=>Ce({className:s})),children:[jsxs(Button,{...r,slot:"trigger",className:composeRenderProps(n?.button,s=>_({className:s})),children:[a,jsx(Heading,{slot:"menu",children:t}),jsx(Icon,{className:p({className:n?.icon}),children:jsx(ChevronDown,{className:"transform group-expanded/menu:rotate-180"})})]}),jsx(DisclosurePanel,{className:composeRenderProps(n?.disclosurePanel,s=>s??""),children:jsx("div",{className:G({className:n?.panelContent}),children:i})})]}):jsxs(DialogTrigger,{children:[jsxs(Tooltip.Trigger,{isDisabled:o,children:[jsx(Button,{...r,ref:m,className:composeRenderProps(n?.button,s=>_({className:s})),children:a}),jsx(Tooltip,{parentRef:m,placement:"right",className:b(),children:t})]}),jsxs(Popover,{className:composeRenderProps(n?.popoverPanel,s=>Ie({className:s})),placement:"right top",shouldFlip:false,children:[jsx(Heading,{slot:"panel",children:t}),jsx("div",{className:G({className:n?.panelContent}),children:i})]})]})}y.displayName="Sidenav.Menu";function I({className:a,children:t,...n}){return containsExactChildren({children:t,componentName:I.displayName,restrictions:[[Text,{min:1,max:1}]]}),jsx(ToggleButton,{...n,className:composeRenderProps(a,i=>Ee({className:i})),children:t})}I.displayName="Sidenav.Menu.Item",y.Item=I,d.Trigger=J,d.Header=L,d.Item=k,d.Link=B,d.Avatar=C,d.Footer=M,d.Content=A,d.Menu=y;export{d as Sidenav};//# sourceMappingURL=index.js.map
|
|
4
4
|
//# sourceMappingURL=index.js.map
|