@cryptlex/web-components 6.6.6-alpha53 → 6.6.6-alpha56
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/button.d.ts +1 -1
- package/dist/components/data-table-filter.js +1 -1
- package/dist/components/data-table.d.ts +41 -5
- package/dist/components/data-table.js +1 -1
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/dialog.d.ts +69 -0
- package/dist/components/dialog.js +1 -1
- package/dist/components/dialog.js.map +1 -1
- package/dist/components/id-search.d.ts +5 -3
- package/dist/components/id-search.js +1 -1
- package/dist/components/id-search.js.map +1 -1
- package/dist/components/multi-select.js.map +1 -1
- package/dist/utilities/empty-option.d.ts +3 -0
- package/dist/utilities/empty-option.js +2 -0
- package/dist/utilities/empty-option.js.map +1 -0
- package/dist/utilities/resources.d.ts +1 -0
- package/dist/utilities/resources.js.map +1 -1
- package/dist/utilities/string.d.ts +0 -5
- package/dist/utilities/string.js +1 -1
- package/dist/utilities/string.js.map +1 -1
- package/lib/index.css +2 -2
- package/package.json +1 -1
- package/dist/components/data-table-actions.d.ts +0 -46
- package/dist/components/data-table-actions.js +0 -2
- package/dist/components/data-table-actions.js.map +0 -1
- package/dist/components/dialog-action-utils.d.ts +0 -38
- package/dist/components/dialog-action-utils.js +0 -2
- package/dist/components/dialog-action-utils.js.map +0 -1
- package/dist/components/dialog-menu.d.ts +0 -34
- package/dist/components/dialog-menu.js +0 -2
- package/dist/components/dialog-menu.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dialog-action-utils.js","sources":["../../lib/components/dialog-action-utils.tsx"],"sourcesContent":["'use client';\nimport { useState } from 'react';\nimport { normalizeLabel } from '../utilities/string';\nimport { DialogContent, DialogOverlay, DialogTrigger } from './dialog';\n\n/**\n * Hook for managing dialog state in action components.\n * Returns the open key and setter function.\n */\nexport function useDialogState() {\n const [openKey, setOpenKey] = useState<string | null>(null);\n return { openKey, setOpenKey };\n}\n\n/**\n * Props for rendering a dialog action.\n */\nexport type DialogActionRendererProps<TDialogProps extends { close: () => void }> = {\n /** The key of the currently open dialog */\n readonly openKey: string | null;\n /** Callback when dialog open state changes */\n readonly onOpenChange: (open: boolean) => void;\n /** Function to find the dialog item by normalized label key */\n readonly findItem: (key: string) => { component: React.ComponentType<TDialogProps> } | null;\n /** Function to get dialog props, receives close function and returns full dialog props */\n readonly getDialogProps: (close: () => void) => TDialogProps;\n};\n\n/**\n * Renders a dialog for action components.\n * Handles the DialogTrigger, DialogOverlay, and DialogContent wrapper.\n */\nexport function DialogActionRenderer<TDialogProps extends { close: () => void }>({\n openKey,\n onOpenChange,\n findItem,\n getDialogProps,\n}: DialogActionRendererProps<TDialogProps>) {\n return (\n <DialogTrigger isOpen={openKey !== null} onOpenChange={onOpenChange}>\n {openKey !== null &&\n (() => {\n const item = findItem(openKey);\n if (!item) return null;\n\n const Component = item.component;\n\n return (\n <DialogOverlay>\n <DialogContent>{({ close }) => <Component {...getDialogProps(close)} />}</DialogContent>\n </DialogOverlay>\n );\n })()}\n </DialogTrigger>\n );\n}\n\n/**\n * Helper function to find an item by normalized label.\n */\nexport function findItemByNormalizedLabel<T extends { label: string }>(\n items: T[],\n normalizedKey: string\n): T | undefined {\n return items.find(it => normalizeLabel(it.label) === normalizedKey);\n}\n"],"names":["useDialogState","openKey","setOpenKey","useState","DialogActionRenderer","onOpenChange","findItem","getDialogProps","jsx","DialogTrigger","item","Component","DialogOverlay","DialogContent","close","findItemByNormalizedLabel","items","normalizedKey","it","normalizeLabel"],"mappings":"uZASO,SAASA,GAAiB,CAC7B,KAAM,CAACC,EAASC,CAAU,EAAIC,EAAwB,IAAI,EAC1D,MAAO,CAAE,QAAAF,EAAS,WAAAC,CAAA,CACtB,CAoBO,SAASE,EAAiE,CAC7E,QAAAH,EACA,aAAAI,EACA,SAAAC,EACA,eAAAC,CACJ,EAA4C,CACxC,OACIC,EAACC,GAAc,OAAQR,IAAY,KAAM,aAAAI,EACpC,SAAAJ,IAAY,OACR,IAAM,CACH,MAAMS,EAAOJ,EAASL,CAAO,EAC7B,GAAI,CAACS,EAAM,OAAO,KAElB,MAAMC,EAAYD,EAAK,UAEvB,OACIF,EAACI,EAAA,CACG,SAAAJ,EAACK,EAAA,CAAe,UAAC,CAAE,MAAAC,CAAA,IAAYN,EAACG,GAAW,GAAGJ,EAAeO,CAAK,CAAA,CAAG,EAAG,EAC5E,CAER,IAAG,CACX,CAER,CAKO,SAASC,EACZC,EACAC,EACa,CACb,OAAOD,EAAM,KAAKE,GAAMC,EAAeD,EAAG,KAAK,IAAMD,CAAa,CACtE"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { CtxIcon } from './icons';
|
|
2
|
-
export type DialogMenuContentProps<T> = {
|
|
3
|
-
/** Callback to close the dialog */
|
|
4
|
-
close: () => void;
|
|
5
|
-
/** The data passed to the dialog */
|
|
6
|
-
data: T;
|
|
7
|
-
};
|
|
8
|
-
/** Base properties shared by all menu actions */
|
|
9
|
-
export type MenuActionBase<T> = {
|
|
10
|
-
label: string;
|
|
11
|
-
/** Optional function to determine if the action is disabled. Receives the data and returns a boolean. Defaults to false if not provided */
|
|
12
|
-
isDisabled?: (data: T) => boolean;
|
|
13
|
-
icon: CtxIcon;
|
|
14
|
-
};
|
|
15
|
-
/** Action that triggers a callback */
|
|
16
|
-
export type MenuActionAction<T> = MenuActionBase<T> & {
|
|
17
|
-
type: 'action';
|
|
18
|
-
/** Callback triggered when the action is pressed. Receives the data as parameter */
|
|
19
|
-
onPress: (data: T) => void;
|
|
20
|
-
};
|
|
21
|
-
/** Action that opens a dialog */
|
|
22
|
-
export type MenuActionDialog<T> = MenuActionBase<T> & {
|
|
23
|
-
type: 'dialog';
|
|
24
|
-
/** Component to render in the dialog */
|
|
25
|
-
component: React.ComponentType<DialogMenuContentProps<T>>;
|
|
26
|
-
};
|
|
27
|
-
/** Common menu action type that works for both DialogMenu and table row actions */
|
|
28
|
-
export type DialogMenuAction<T> = MenuActionAction<T> | MenuActionDialog<T>;
|
|
29
|
-
export type DialogMenuProps<T> = {
|
|
30
|
-
readonly label: React.ReactNode;
|
|
31
|
-
readonly items: DialogMenuAction<T>[];
|
|
32
|
-
readonly data: T;
|
|
33
|
-
};
|
|
34
|
-
export declare function DialogMenu<T>({ label, items, data }: DialogMenuProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";import{jsxs as m,Fragment as d,jsx as t}from"react/jsx-runtime";import{normalizeLabel as b}from"../utilities/string.js";import{useDialogState as g,findItemByNormalizedLabel as p,DialogActionRenderer as D}from"./dialog-action-utils.js";import{EasyMenu as A,MenuItem as y}from"./menu.js";import"lodash-es";import"react";import"./dialog.js";import"class-variance-authority";import"react-aria-components";import"./button.js";import"../utilities/theme.js";import"clsx";import"./loader.js";import"./icons.js";import"./list-box.js";import"./select.js";import"../utilities/form.js";import"../utilities/form-context.js";import"@tanstack/react-form";import"./form.js";import"./popover.js";function I(n){return n.type==="action"}function c(n){return n.type==="dialog"}function a(n,e){return n.isDisabled?n.isDisabled(e):!1}function J({label:n,items:e,data:r}){const{openKey:u,setOpenKey:s}=g();return m(d,{children:[t(A,{"aria-label":"Actions",label:n,size:"icon",onAction:i=>{if(typeof i!="string")return;const o=p(e,i);!o||a(o,r)||(I(o)?o.onPress(r):c(o)&&s(i))},children:e.map(i=>{const o=b(i.label),l=i.icon,f=a(i,r);return m(y,{id:o,isDisabled:f,children:[t(l,{className:"size-icon"})," ",i.label]},o)})}),t(D,{openKey:u,onOpenChange:i=>{i||s(null)},findItem:i=>{const o=p(e,i);return!o||!c(o)?null:{component:o.component}},getDialogProps:i=>({data:r,close:i})})]})}export{J as DialogMenu};
|
|
2
|
-
//# sourceMappingURL=dialog-menu.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dialog-menu.js","sources":["../../lib/components/dialog-menu.tsx"],"sourcesContent":["'use client';\nimport { normalizeLabel } from '../utilities/string';\nimport { DialogActionRenderer, findItemByNormalizedLabel, useDialogState } from './dialog-action-utils';\nimport type { CtxIcon } from './icons';\nimport { EasyMenu, MenuItem } from './menu';\n\nexport type DialogMenuContentProps<T> = {\n /** Callback to close the dialog */\n close: () => void;\n /** The data passed to the dialog */\n data: T;\n};\n\n/** Base properties shared by all menu actions */\nexport type MenuActionBase<T> = {\n label: string;\n /** Optional function to determine if the action is disabled. Receives the data and returns a boolean. Defaults to false if not provided */\n isDisabled?: (data: T) => boolean;\n icon: CtxIcon;\n};\n\n/** Action that triggers a callback */\nexport type MenuActionAction<T> = MenuActionBase<T> & {\n type: 'action';\n /** Callback triggered when the action is pressed. Receives the data as parameter */\n onPress: (data: T) => void;\n};\n\n/** Action that opens a dialog */\nexport type MenuActionDialog<T> = MenuActionBase<T> & {\n type: 'dialog';\n /** Component to render in the dialog */\n component: React.ComponentType<DialogMenuContentProps<T>>;\n};\n\n/** Common menu action type that works for both DialogMenu and table row actions */\nexport type DialogMenuAction<T> = MenuActionAction<T> | MenuActionDialog<T>;\n\nfunction isMenuActionAction<T>(item: DialogMenuAction<T>): item is MenuActionAction<T> {\n return item.type === 'action';\n}\n\nfunction isMenuActionDialog<T>(item: DialogMenuAction<T>): item is MenuActionDialog<T> {\n return item.type === 'dialog';\n}\n\nfunction getIsDisabled<T>(item: DialogMenuAction<T>, data: T): boolean {\n return item.isDisabled ? item.isDisabled(data) : false;\n}\n\nexport type DialogMenuProps<T> = {\n readonly label: React.ReactNode;\n readonly items: DialogMenuAction<T>[];\n readonly data: T;\n};\n\nexport function DialogMenu<T>({ label, items, data }: DialogMenuProps<T>) {\n const { openKey, setOpenKey } = useDialogState();\n\n return (\n <>\n <EasyMenu\n aria-label=\"Actions\"\n label={label}\n size={'icon'}\n onAction={key => {\n if (typeof key !== 'string') return;\n const found = findItemByNormalizedLabel(items, key);\n if (!found) return;\n\n const isDisabled = getIsDisabled(found, data);\n if (isDisabled) return;\n\n if (isMenuActionAction(found)) {\n found.onPress(data);\n } else if (isMenuActionDialog(found)) {\n setOpenKey(key);\n }\n }}\n >\n {items.map(it => {\n const id = normalizeLabel(it.label);\n const Icon = it.icon;\n const isDisabled = getIsDisabled(it, data);\n return (\n <MenuItem key={id} id={id} isDisabled={isDisabled}>\n {<Icon className=\"size-icon\" />} {it.label}\n </MenuItem>\n );\n })}\n </EasyMenu>\n\n <DialogActionRenderer<DialogMenuContentProps<T>>\n openKey={openKey}\n onOpenChange={open => {\n if (!open) setOpenKey(null);\n }}\n findItem={key => {\n const item = findItemByNormalizedLabel(items, key);\n if (!item || !isMenuActionDialog(item)) return null;\n return { component: item.component };\n }}\n getDialogProps={close => ({ data, close })}\n />\n </>\n );\n}\n"],"names":["isMenuActionAction","item","isMenuActionDialog","getIsDisabled","data","DialogMenu","label","items","openKey","setOpenKey","useDialogState","jsxs","Fragment","jsx","EasyMenu","key","found","findItemByNormalizedLabel","it","id","normalizeLabel","Icon","isDisabled","MenuItem","DialogActionRenderer","open","close"],"mappings":"orBAsCA,SAASA,EAAsBC,EAAwD,CACnF,OAAOA,EAAK,OAAS,QACzB,CAEA,SAASC,EAAsBD,EAAwD,CACnF,OAAOA,EAAK,OAAS,QACzB,CAEA,SAASE,EAAiBF,EAA2BG,EAAkB,CACnE,OAAOH,EAAK,WAAaA,EAAK,WAAWG,CAAI,EAAI,EACrD,CAQO,SAASC,EAAc,CAAE,MAAAC,EAAO,MAAAC,EAAO,KAAAH,GAA4B,CACtE,KAAM,CAAE,QAAAI,EAAS,WAAAC,CAAA,EAAeC,EAAA,EAEhC,OACIC,EAAAC,EAAA,CACI,SAAA,CAAAC,EAACC,EAAA,CACG,aAAW,UACX,MAAAR,EACA,KAAM,OACN,SAAUS,GAAO,CACb,GAAI,OAAOA,GAAQ,SAAU,OAC7B,MAAMC,EAAQC,EAA0BV,EAAOQ,CAAG,EAC9C,CAACC,GAEcb,EAAca,EAAOZ,CAAI,IAGxCJ,EAAmBgB,CAAK,EACxBA,EAAM,QAAQZ,CAAI,EACXF,EAAmBc,CAAK,GAC/BP,EAAWM,CAAG,EAEtB,EAEC,SAAAR,EAAM,IAAIW,GAAM,CACb,MAAMC,EAAKC,EAAeF,EAAG,KAAK,EAC5BG,EAAOH,EAAG,KACVI,EAAanB,EAAce,EAAId,CAAI,EACzC,OACIO,EAACY,EAAA,CAAkB,GAAAJ,EAAQ,WAAAG,EACtB,SAAA,CAAAT,EAACQ,EAAA,CAAK,UAAU,WAAA,CAAY,EAAG,IAAEH,EAAG,KAAA,CAAA,EAD1BC,CAEf,CAER,CAAC,CAAA,CAAA,EAGLN,EAACW,EAAA,CACG,QAAAhB,EACA,aAAciB,GAAQ,CACbA,GAAMhB,EAAW,IAAI,CAC9B,EACA,SAAUM,GAAO,CACb,MAAMd,EAAOgB,EAA0BV,EAAOQ,CAAG,EACjD,MAAI,CAACd,GAAQ,CAACC,EAAmBD,CAAI,EAAU,KACxC,CAAE,UAAWA,EAAK,SAAA,CAC7B,EACA,eAAgByB,IAAU,CAAE,KAAAtB,EAAM,MAAAsB,CAAA,EAAM,CAAA,CAC5C,EACJ,CAER"}
|