@vritti/quantum-ui 0.3.20 → 0.3.21
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/CopyButton.js +47 -0
- package/dist/CopyButton.js.map +1 -0
- package/dist/Form.js +1 -1
- package/dist/Form.js.map +1 -1
- package/dist/assets/quantum-ui.css +2 -6
- package/dist/components/CopyButton.js +2 -0
- package/dist/components/CopyButton.js.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/components/CopyButton/CopyButton.d.ts +8 -0
- package/dist/lib/components/CopyButton/CopyButton.d.ts.map +1 -0
- package/dist/lib/components/CopyButton/index.d.ts +2 -0
- package/dist/lib/components/CopyButton/index.d.ts.map +1 -0
- package/dist/lib/components/DataTable/DataTable.d.ts.map +1 -1
- package/dist/lib/components/index.d.ts +1 -0
- package/dist/lib/components/index.d.ts.map +1 -1
- package/dist/useDataTable.js +153 -122
- package/dist/useDataTable.js.map +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useState, useRef, useEffect, useCallback } from 'react';
|
|
3
|
+
import { c as cn } from './utils.js';
|
|
4
|
+
import { T as Tooltip } from './Tooltip.js';
|
|
5
|
+
import { C as Check } from './check.js';
|
|
6
|
+
import { C as Copy } from './copy.js';
|
|
7
|
+
|
|
8
|
+
const CopyButton = ({ value, label = "Copy", className }) => {
|
|
9
|
+
const [copied, setCopied] = useState(false);
|
|
10
|
+
const timeoutRef = useRef(null);
|
|
11
|
+
useEffect(
|
|
12
|
+
() => () => {
|
|
13
|
+
if (timeoutRef.current) {
|
|
14
|
+
clearTimeout(timeoutRef.current);
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
[]
|
|
18
|
+
);
|
|
19
|
+
const handleCopy = useCallback(async () => {
|
|
20
|
+
try {
|
|
21
|
+
await navigator.clipboard.writeText(value);
|
|
22
|
+
setCopied(true);
|
|
23
|
+
if (timeoutRef.current) {
|
|
24
|
+
clearTimeout(timeoutRef.current);
|
|
25
|
+
}
|
|
26
|
+
timeoutRef.current = setTimeout(() => setCopied(false), 1500);
|
|
27
|
+
} catch {
|
|
28
|
+
}
|
|
29
|
+
}, [value]);
|
|
30
|
+
return /* @__PURE__ */ jsx(Tooltip, { content: copied ? "Copied" : label, children: /* @__PURE__ */ jsx(
|
|
31
|
+
"button",
|
|
32
|
+
{
|
|
33
|
+
type: "button",
|
|
34
|
+
onClick: handleCopy,
|
|
35
|
+
"aria-label": label,
|
|
36
|
+
className: cn(
|
|
37
|
+
"inline-flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
|
|
38
|
+
className
|
|
39
|
+
),
|
|
40
|
+
children: copied ? /* @__PURE__ */ jsx(Check, { className: "size-3.5 text-success" }) : /* @__PURE__ */ jsx(Copy, { className: "size-3.5" })
|
|
41
|
+
}
|
|
42
|
+
) });
|
|
43
|
+
};
|
|
44
|
+
CopyButton.displayName = "CopyButton";
|
|
45
|
+
|
|
46
|
+
export { CopyButton as C };
|
|
47
|
+
//# sourceMappingURL=CopyButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CopyButton.js","sources":["../lib/components/CopyButton/CopyButton.tsx"],"sourcesContent":["import { Check, Copy } from 'lucide-react';\nimport type React from 'react';\nimport { useCallback, useEffect, useRef, useState } from 'react';\nimport { cn } from '../../../shadcn/utils';\nimport { Tooltip } from '../Tooltip';\n\n/**\n * Props for the CopyButton component\n */\nexport interface CopyButtonProps {\n /** The full string copied to the clipboard */\n value: string;\n /** Accessible label and tooltip text (default: 'Copy'); the tooltip shows 'Copied' after a copy */\n label?: string;\n /** Additional CSS classes applied to the button */\n className?: string;\n}\n\n/**\n * CopyButton is an icon-only copy-to-clipboard affordance that briefly flips a\n * Copy icon to a Check and surfaces a Tooltip confirming the copy.\n *\n * @example\n * ```tsx\n * <CopyButton value=\"sk_live_123\" label=\"Copy API key\" />\n * ```\n */\nexport const CopyButton: React.FC<CopyButtonProps> = ({ value, label = 'Copy', className }) => {\n const [copied, setCopied] = useState(false);\n const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n // Clear any pending revert timer on unmount to avoid setting state on an unmounted component\n useEffect(\n () => () => {\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n },\n [],\n );\n\n // Write the value to the clipboard and briefly show the copied confirmation\n const handleCopy = useCallback(async () => {\n try {\n await navigator.clipboard.writeText(value);\n setCopied(true);\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n timeoutRef.current = setTimeout(() => setCopied(false), 1500);\n } catch {\n // Clipboard access can be denied or unavailable; fail silently without breaking the UI\n }\n }, [value]);\n\n return (\n <Tooltip content={copied ? 'Copied' : label}>\n <button\n type=\"button\"\n onClick={handleCopy}\n aria-label={label}\n className={cn(\n 'inline-flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground',\n className,\n )}\n >\n {copied ? <Check className=\"size-3.5 text-success\" /> : <Copy className=\"size-3.5\" />}\n </button>\n </Tooltip>\n );\n};\n\nCopyButton.displayName = 'CopyButton';\n"],"names":[],"mappings":";;;;;;;AA2BO,MAAM,aAAwC,CAAC,EAAE,OAAO,KAAA,GAAQ,MAAA,EAAQ,WAAU,KAAM;AAC7F,EAAA,MAAM,CAAC,MAAA,EAAQ,SAAS,CAAA,GAAI,SAAS,KAAK,CAAA;AAC1C,EAAA,MAAM,UAAA,GAAa,OAA6C,IAAI,CAAA;AAGpE,EAAA,SAAA;AAAA,IACE,MAAM,MAAM;AACV,MAAA,IAAI,WAAW,OAAA,EAAS;AACtB,QAAA,YAAA,CAAa,WAAW,OAAO,CAAA;AAAA,MACjC;AAAA,IACF,CAAA;AAAA,IACA;AAAC,GACH;AAGA,EAAA,MAAM,UAAA,GAAa,YAAY,YAAY;AACzC,IAAA,IAAI;AACF,MAAA,MAAM,SAAA,CAAU,SAAA,CAAU,SAAA,CAAU,KAAK,CAAA;AACzC,MAAA,SAAA,CAAU,IAAI,CAAA;AACd,MAAA,IAAI,WAAW,OAAA,EAAS;AACtB,QAAA,YAAA,CAAa,WAAW,OAAO,CAAA;AAAA,MACjC;AACA,MAAA,UAAA,CAAW,UAAU,UAAA,CAAW,MAAM,SAAA,CAAU,KAAK,GAAG,IAAI,CAAA;AAAA,IAC9D,CAAA,CAAA,MAAQ;AAAA,IAER;AAAA,EACF,CAAA,EAAG,CAAC,KAAK,CAAC,CAAA;AAEV,EAAA,uBACE,GAAA,CAAC,OAAA,EAAA,EAAQ,OAAA,EAAS,MAAA,GAAS,WAAW,KAAA,EACpC,QAAA,kBAAA,GAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,IAAA,EAAK,QAAA;AAAA,MACL,OAAA,EAAS,UAAA;AAAA,MACT,YAAA,EAAY,KAAA;AAAA,MACZ,SAAA,EAAW,EAAA;AAAA,QACT,iJAAA;AAAA,QACA;AAAA,OACF;AAAA,MAEC,QAAA,EAAA,MAAA,uBAAU,KAAA,EAAA,EAAM,SAAA,EAAU,yBAAwB,CAAA,mBAAK,GAAA,CAAC,IAAA,EAAA,EAAK,SAAA,EAAU,UAAA,EAAW;AAAA;AAAA,GACrF,EACF,CAAA;AAEJ;AAEA,UAAA,CAAW,WAAA,GAAc,YAAA;;;;"}
|
package/dist/Form.js
CHANGED
|
@@ -217,7 +217,7 @@ function Form({
|
|
|
217
217
|
className: cn(hasActions ? "flex min-h-0 flex-1 flex-col" : "space-y-4", className),
|
|
218
218
|
...props,
|
|
219
219
|
children: hasActions ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
220
|
-
/* @__PURE__ */ jsxs("div", { className: "min-h-0 flex-1 space-y-4 overflow-y-auto overscroll-contain px-6 py-4
|
|
220
|
+
/* @__PURE__ */ jsxs("div", { className: "min-h-0 flex-1 space-y-4 overflow-y-auto overscroll-contain px-6 py-4", children: [
|
|
221
221
|
topError,
|
|
222
222
|
bodyChildren,
|
|
223
223
|
bottomError
|
package/dist/Form.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.js","sources":["../lib/utils/formHelpers.ts","../lib/components/Form/Form.tsx"],"sourcesContent":["import type { FieldPath, FieldValues, UseFormReturn } from 'react-hook-form';\n\nexport interface FieldMapping {\n [apiField: string]: string;\n}\n\ninterface AxiosLikeError {\n response?: {\n data?: unknown;\n };\n}\n\nexport interface FieldError {\n field: string;\n message: string;\n}\n\nexport interface ApiErrorResponse {\n type?: string;\n title?: string;\n status?: number;\n label?: string;\n detail?: string;\n instance?: string;\n errors?: FieldError[];\n}\n\nexport interface MapApiErrorsOptions {\n fieldMapping?: FieldMapping;\n setRootError?: boolean;\n}\n\n// Maps an RFC 9457 Problem Details API error response to react-hook-form root + field errors.\nexport function mapApiErrorsToForm<TFieldValues extends FieldValues = FieldValues>(\n error: unknown,\n form: UseFormReturn<TFieldValues>,\n options: MapApiErrorsOptions = {},\n): void {\n const { fieldMapping = {}, setRootError = true } = options;\n\n if (!error || typeof error !== 'object') {\n if (setRootError) {\n form.setError('root', {\n type: 'Error',\n message: 'An error occurred',\n });\n }\n return;\n }\n\n // Extract error data from axios response structure\n const axiosError = error as AxiosLikeError;\n const errorData = axiosError.response?.data || error;\n const apiError = errorData as ApiErrorResponse;\n\n // Extract title/label for error heading (RFC 9457)\n const errorTitle = apiError.label || apiError.title || 'Error';\n const generalMessage = apiError.detail;\n\n // Map field-specific errors (field is always present in RFC 9457)\n let mappedFieldErrorsCount = 0;\n if (apiError.errors && Array.isArray(apiError.errors)) {\n for (const errorItem of apiError.errors) {\n const formField = fieldMapping[errorItem.field] || errorItem.field;\n\n form.setError(formField as FieldPath<TFieldValues>, {\n type: 'manual',\n message: errorItem.message,\n });\n mappedFieldErrorsCount += 1;\n }\n }\n\n // Root error is shown only when no field errors are present\n if (generalMessage && setRootError && mappedFieldErrorsCount === 0) {\n form.setError('root', {\n type: errorTitle,\n message: generalMessage,\n });\n }\n}\n","import type { UseMutationResult } from '@tanstack/react-query';\nimport type React from 'react';\nimport { Children, cloneElement, Fragment, isValidElement, useCallback } from 'react';\nimport {\n Controller,\n type ControllerProps,\n type FieldPath,\n type FieldValues,\n FormProvider,\n type UseFormReturn,\n} from 'react-hook-form';\nimport type { Country } from 'react-phone-number-input';\nimport { cn } from '../../../shadcn/utils';\nimport { axios } from '../../utils/axios';\nimport { type FieldMapping, mapApiErrorsToForm } from '../../utils/formHelpers';\nimport { Alert } from '../Alert';\nimport { Button } from '../Button';\nimport { Checkbox } from '../Checkbox';\nimport { CheckboxGroup } from '../CheckboxGroup';\nimport { DatePicker } from '../DatePicker';\nimport { DateTimePicker } from '../DateTimePicker';\nimport { PhoneField } from '../PhoneField';\nimport { RadioGroup } from '../RadioGroup';\nimport { Switch } from '../Switch';\nimport { UploadFile } from '../UploadFile';\n\n// Re-export Controller for explicit usage\nexport { Controller } from 'react-hook-form';\n\n// Recursively process children to wrap form fields with Controller and inject loading state into submit buttons\nfunction processChildren<\n TFieldValues extends FieldValues = FieldValues,\n _TContext = any,\n TTransformedValues extends FieldValues | undefined = TFieldValues,\n>(\n children: React.ReactNode,\n control: ControllerProps<TFieldValues, FieldPath<TFieldValues>, TTransformedValues>['control'],\n isSubmitting: boolean,\n setValue: UseFormReturn<TFieldValues, _TContext, TTransformedValues>['setValue'],\n onCancel?: () => void,\n reset?: UseFormReturn<TFieldValues, _TContext, TTransformedValues>['reset'],\n): React.ReactNode {\n return Children.map(children, (child) => {\n // Handle non-element children (strings, numbers, null, etc.)\n if (!isValidElement(child)) {\n return child;\n }\n\n const childProps = child.props as any;\n const isFragment = child.type === Fragment;\n\n // Handle form fields with name prop (but not Fragments)\n if (!isFragment && childProps.name && typeof childProps.name === 'string') {\n const name = childProps.name as FieldPath<TFieldValues>;\n\n return (\n <Controller\n key={name}\n control={control}\n name={name}\n render={({ field, fieldState }) => {\n // Check if this is a Checkbox, Switch, RadioGroup, or CheckboxGroup component\n const isCheckbox = child.type === Checkbox;\n const isSwitch = child.type === Switch;\n const isRadioGroup = child.type === RadioGroup;\n const isCheckboxGroup = child.type === CheckboxGroup;\n const isPhone = child.type === PhoneField;\n const isDatePicker = child.type === DatePicker;\n const isDateTimePicker = child.type === DateTimePicker;\n\n const fieldProps =\n isCheckbox || isSwitch\n ? {\n checked: field.value,\n onCheckedChange: field.onChange,\n onBlur: field.onBlur,\n ref: field.ref,\n }\n : isRadioGroup || isCheckboxGroup\n ? {\n value: field.value,\n onValueChange: field.onChange,\n onBlur: field.onBlur,\n }\n : isDatePicker\n ? {\n value: field.value,\n onValueChange: field.onChange,\n onBlur: field.onBlur,\n ref: field.ref,\n }\n : isDateTimePicker\n ? {\n value: field.value,\n onValueChange: field.onChange,\n onBlur: field.onBlur,\n ref: field.ref,\n }\n : isPhone\n ? {\n ...field,\n onCountryChange: (country: Country | undefined) => {\n setValue(`${name}Country` as FieldPath<TFieldValues>, country as any);\n },\n }\n : field;\n\n const isUploadFile = child.type === UploadFile;\n\n return cloneElement(child, {\n ...childProps,\n ...fieldProps,\n error: fieldState.error?.message || (fieldState.error ? 'Invalid' : undefined),\n name: undefined, // Remove name to avoid passing it to the underlying input\n ...(isUploadFile ? { isLoading: isSubmitting } : {}),\n });\n }}\n />\n );\n }\n\n // Handle cancel buttons - wire up form.reset() + onCancel callback\n if (childProps['data-cancel'] && onCancel && reset) {\n return cloneElement(child, {\n ...childProps,\n onClick: () => {\n reset();\n onCancel();\n },\n });\n }\n\n // Handle submit buttons - inject loading state via isLoading prop\n if (childProps.type === 'submit') {\n const isButtonElement =\n child.type === Button || (typeof child.type === 'function' && (child.type as any).displayName === 'Button');\n\n if (isButtonElement) {\n return cloneElement(child, {\n ...childProps,\n isLoading: isSubmitting,\n });\n }\n }\n\n // Handle React Fragments - process their children directly\n if (isFragment) {\n return processChildren(childProps.children, control, isSubmitting, setValue, onCancel, reset);\n }\n\n // Recurse into children for container elements (divs, FieldGroups, etc.)\n if (childProps.children != null) {\n return cloneElement(child, {\n ...childProps,\n children: processChildren(childProps.children, control, isSubmitting, setValue, onCancel, reset),\n });\n }\n\n // Return unchanged if no name prop and no children\n return child;\n });\n}\n\nexport interface FormProps<\n TFieldValues extends FieldValues = FieldValues,\n TContext = any,\n TTransformedValues extends FieldValues | undefined = TFieldValues,\n TMutationData = unknown,\n TMutationError = Error,\n TMutationVariables = any,\n> extends Omit<React.FormHTMLAttributes<HTMLFormElement>, 'onSubmit'> {\n form: UseFormReturn<TFieldValues, TContext, TTransformedValues>;\n\n onSubmit?: Parameters<UseFormReturn<TFieldValues, TContext, TTransformedValues>['handleSubmit']>[0];\n\n children: React.ReactNode;\n\n rootErrorPosition?: 'top' | 'bottom';\n\n rootErrorClassName?: string;\n\n rootErrorAction?: React.ReactNode;\n\n fieldMapping?: FieldMapping;\n\n mutation?: UseMutationResult<TMutationData, TMutationError, TMutationVariables, unknown>;\n\n transformSubmit?: (\n data: TTransformedValues extends undefined ? TFieldValues : TTransformedValues,\n ) => TMutationVariables;\n\n resetOnSuccess?: boolean;\n\n onCancel?: () => void;\n}\n\n// Smart Form component that automatically wraps children with Controller\nexport function Form<\n TFieldValues extends FieldValues = FieldValues,\n TContext = any,\n TTransformedValues extends FieldValues | undefined = TFieldValues,\n TMutationData = unknown,\n TMutationError = Error,\n TMutationVariables = any,\n>({\n form,\n onSubmit,\n children,\n rootErrorPosition = 'bottom',\n rootErrorClassName,\n rootErrorAction,\n fieldMapping,\n mutation,\n transformSubmit,\n resetOnSuccess,\n onCancel,\n className,\n ...props\n}: FormProps<TFieldValues, TContext, TTransformedValues, TMutationData, TMutationError, TMutationVariables>) {\n // Compute isSubmitting from both form state and mutation state\n const isSubmitting = form.formState.isSubmitting || (mutation?.isPending ?? false);\n\n // Wrap the submit handler with automatic error mapping; the mutation's own callbacks fire automatically\n const wrappedOnSubmit = useCallback(\n async (data: TTransformedValues extends undefined ? TFieldValues : TTransformedValues) => {\n // Suppress error toasts during form submission — Form handles errors inline\n const interceptorId = axios.interceptors.request.use((config) => ({\n ...config,\n showErrorToast: false,\n }));\n\n try {\n if (mutation) {\n const variables = transformSubmit ? transformSubmit(data) : data;\n // mutateAsync will trigger the mutation's onSuccess/onError callbacks\n await mutation.mutateAsync(variables as TMutationVariables);\n } else if (onSubmit) {\n await onSubmit(data as any);\n }\n\n // Reset form after successful submission (default: true)\n if (resetOnSuccess !== false) form.reset();\n } catch (error) {\n // Map API errors to form fields — mapApiErrorsToForm extracts the axios error structure internally\n mapApiErrorsToForm(error, form as any, {\n fieldMapping,\n });\n // Log error for debugging\n console.error('[Form Submission Error]', error);\n // Error is swallowed, not re-thrown (mutation's onError already fired)\n } finally {\n axios.interceptors.request.eject(interceptorId);\n }\n },\n [onSubmit, mutation, transformSubmit, fieldMapping, form, resetOnSuccess],\n );\n\n const handleSubmit = form.handleSubmit(wrappedOnSubmit as any);\n\n // Process children recursively to automatically wrap with Controller\n const processedChildren = processChildren(children, form.control, isSubmitting, form.setValue, onCancel, form.reset);\n\n const childArray = Children.toArray(processedChildren);\n const actionsIndex = childArray.findIndex(\n (child) => isValidElement(child) && (child.type as { displayName?: string })?.displayName === 'DialogActions',\n );\n const hasActions = actionsIndex !== -1;\n const bodyChildren = hasActions ? childArray.filter((_, index) => index !== actionsIndex) : processedChildren;\n const actions = hasActions ? childArray[actionsIndex] : null;\n\n const topError =\n rootErrorPosition === 'top' && form.formState.errors.root ? (\n <Alert\n variant=\"destructive\"\n title={form.formState.errors.root.type || 'Error'}\n description={form.formState.errors.root.message}\n action={rootErrorAction}\n className={cn('mb-4', rootErrorClassName)}\n />\n ) : null;\n const bottomError =\n rootErrorPosition === 'bottom' && form.formState.errors.root ? (\n <Alert\n variant=\"destructive\"\n title={form.formState.errors.root.type || 'Error'}\n description={form.formState.errors.root.message}\n action={rootErrorAction}\n className={cn('mt-4', rootErrorClassName)}\n />\n ) : null;\n\n return (\n <FormProvider {...form}>\n <form\n onSubmit={handleSubmit}\n className={cn(hasActions ? 'flex min-h-0 flex-1 flex-col' : 'space-y-4', className)}\n {...props}\n >\n {hasActions ? (\n <>\n <div className=\"min-h-0 flex-1 space-y-4 overflow-y-auto overscroll-contain px-6 py-4 [scrollbar-gutter:stable]\">\n {topError}\n {bodyChildren}\n {bottomError}\n </div>\n {actions}\n </>\n ) : (\n <>\n {topError}\n {processedChildren}\n {bottomError}\n </>\n )}\n </form>\n </FormProvider>\n );\n}\n\nForm.displayName = 'Form';\n"],"names":["Fragment"],"mappings":";;;;;;;;;;;;;;;;AAiCO,SAAS,kBAAA,CACd,KAAA,EACA,IAAA,EACA,OAAA,GAA+B,EAAC,EAC1B;AACN,EAAA,MAAM,EAAE,YAAA,GAAe,EAAC,EAAG,YAAA,GAAe,MAAK,GAAI,OAAA;AAEnD,EAAA,IAAI,CAAC,KAAA,IAAS,OAAO,KAAA,KAAU,QAAA,EAAU;AACvC,IAAA,IAAI,YAAA,EAAc;AAChB,MAAA,IAAA,CAAK,SAAS,MAAA,EAAQ;AAAA,QACpB,IAAA,EAAM,OAAA;AAAA,QACN,OAAA,EAAS;AAAA,OACV,CAAA;AAAA,IACH;AACA,IAAA;AAAA,EACF;AAGA,EAAA,MAAM,UAAA,GAAa,KAAA;AACnB,EAAA,MAAM,SAAA,GAAY,UAAA,CAAW,QAAA,EAAU,IAAA,IAAQ,KAAA;AAC/C,EAAA,MAAM,QAAA,GAAW,SAAA;AAGjB,EAAA,MAAM,UAAA,GAAa,QAAA,CAAS,KAAA,IAAS,QAAA,CAAS,KAAA,IAAS,OAAA;AACvD,EAAA,MAAM,iBAAiB,QAAA,CAAS,MAAA;AAGhC,EAAA,IAAI,sBAAA,GAAyB,CAAA;AAC7B,EAAA,IAAI,SAAS,MAAA,IAAU,KAAA,CAAM,OAAA,CAAQ,QAAA,CAAS,MAAM,CAAA,EAAG;AACrD,IAAA,KAAA,MAAW,SAAA,IAAa,SAAS,MAAA,EAAQ;AACvC,MAAA,MAAM,SAAA,GAA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AAA;AACN,EAAA,MAAM,cACJ,iBAAA,KAAsB,QAAA,IAAY,IAAA,CAAK,SAAA,CAAU,OAAO,IAAA,mBACtD,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,OAAA,EAAQ,aAAA;AAAA,MACR,KAAA,EAAO,IAAA,CAAK,SAAA,CAAU,MAAA,CAAO,KAAK,IAAA,IAAQ,OAAA;AAAA,MAC1C,WAAA,EAAa,IAAA,CAAK,SAAA,CAAU,MAAA,CAAO,IAAA,CAAK,OAAA;AAAA,MACxC,MAAA,EAAQ,eAAA;AAAA,MACR,SAAA,EAAW,EAAA,CAAG,MAAA,EAAQ,kBAAkB;AAAA;AAAA,GAC1C,GACE,IAAA;AAEN,EAAA,uBACE,GAAA,CAAC,YAAA,EAAA,EAAc,GAAG,IAAA,EAChB,QAAA,kBAAA,GAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,QAAA,EAAU,YAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,UAAA,GAAa,8BAAA,GAAiC,aAAa,SAAS,CAAA;AAAA,MACjF,GAAG,KAAA;AAAA,MAEH,uCACC,IAAA,CAAA,QAAA,EAAA,EACE,QAAA,EAAA;AAAA,wBAAA,IAAA,CAAC,KAAA,EAAA,EAAI,WAAU,iGAAA,EACZ,QAAA,EAAA;AAAA,UAAA,QAAA;AAAA,UACA,YAAA;AAAA,UACA;AAAA,SAAA,EACH,CAAA;AAAA,QACC;AAAA,OAAA,EACH,oBAEA,IAAA,CAAA,QAAA,EAAA,EACG,QAAA,EAAA;AAAA,QAAA,QAAA;AAAA,QACA,iBAAA;AAAA,QACA;AAAA,OAAA,EACH;AAAA;AAAA,GAEJ,EACF,CAAA;AAEJ;AAEA,IAAA,CAAK,WAAA,GAAc,MAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"Form.js","sources":["../lib/utils/formHelpers.ts","../lib/components/Form/Form.tsx"],"sourcesContent":["import type { FieldPath, FieldValues, UseFormReturn } from 'react-hook-form';\n\nexport interface FieldMapping {\n [apiField: string]: string;\n}\n\ninterface AxiosLikeError {\n response?: {\n data?: unknown;\n };\n}\n\nexport interface FieldError {\n field: string;\n message: string;\n}\n\nexport interface ApiErrorResponse {\n type?: string;\n title?: string;\n status?: number;\n label?: string;\n detail?: string;\n instance?: string;\n errors?: FieldError[];\n}\n\nexport interface MapApiErrorsOptions {\n fieldMapping?: FieldMapping;\n setRootError?: boolean;\n}\n\n// Maps an RFC 9457 Problem Details API error response to react-hook-form root + field errors.\nexport function mapApiErrorsToForm<TFieldValues extends FieldValues = FieldValues>(\n error: unknown,\n form: UseFormReturn<TFieldValues>,\n options: MapApiErrorsOptions = {},\n): void {\n const { fieldMapping = {}, setRootError = true } = options;\n\n if (!error || typeof error !== 'object') {\n if (setRootError) {\n form.setError('root', {\n type: 'Error',\n message: 'An error occurred',\n });\n }\n return;\n }\n\n // Extract error data from axios response structure\n const axiosError = error as AxiosLikeError;\n const errorData = axiosError.response?.data || error;\n const apiError = errorData as ApiErrorResponse;\n\n // Extract title/label for error heading (RFC 9457)\n const errorTitle = apiError.label || apiError.title || 'Error';\n const generalMessage = apiError.detail;\n\n // Map field-specific errors (field is always present in RFC 9457)\n let mappedFieldErrorsCount = 0;\n if (apiError.errors && Array.isArray(apiError.errors)) {\n for (const errorItem of apiError.errors) {\n const formField = fieldMapping[errorItem.field] || errorItem.field;\n\n form.setError(formField as FieldPath<TFieldValues>, {\n type: 'manual',\n message: errorItem.message,\n });\n mappedFieldErrorsCount += 1;\n }\n }\n\n // Root error is shown only when no field errors are present\n if (generalMessage && setRootError && mappedFieldErrorsCount === 0) {\n form.setError('root', {\n type: errorTitle,\n message: generalMessage,\n });\n }\n}\n","import type { UseMutationResult } from '@tanstack/react-query';\nimport type React from 'react';\nimport { Children, cloneElement, Fragment, isValidElement, useCallback } from 'react';\nimport {\n Controller,\n type ControllerProps,\n type FieldPath,\n type FieldValues,\n FormProvider,\n type UseFormReturn,\n} from 'react-hook-form';\nimport type { Country } from 'react-phone-number-input';\nimport { cn } from '../../../shadcn/utils';\nimport { axios } from '../../utils/axios';\nimport { type FieldMapping, mapApiErrorsToForm } from '../../utils/formHelpers';\nimport { Alert } from '../Alert';\nimport { Button } from '../Button';\nimport { Checkbox } from '../Checkbox';\nimport { CheckboxGroup } from '../CheckboxGroup';\nimport { DatePicker } from '../DatePicker';\nimport { DateTimePicker } from '../DateTimePicker';\nimport { PhoneField } from '../PhoneField';\nimport { RadioGroup } from '../RadioGroup';\nimport { Switch } from '../Switch';\nimport { UploadFile } from '../UploadFile';\n\n// Re-export Controller for explicit usage\nexport { Controller } from 'react-hook-form';\n\n// Recursively process children to wrap form fields with Controller and inject loading state into submit buttons\nfunction processChildren<\n TFieldValues extends FieldValues = FieldValues,\n _TContext = any,\n TTransformedValues extends FieldValues | undefined = TFieldValues,\n>(\n children: React.ReactNode,\n control: ControllerProps<TFieldValues, FieldPath<TFieldValues>, TTransformedValues>['control'],\n isSubmitting: boolean,\n setValue: UseFormReturn<TFieldValues, _TContext, TTransformedValues>['setValue'],\n onCancel?: () => void,\n reset?: UseFormReturn<TFieldValues, _TContext, TTransformedValues>['reset'],\n): React.ReactNode {\n return Children.map(children, (child) => {\n // Handle non-element children (strings, numbers, null, etc.)\n if (!isValidElement(child)) {\n return child;\n }\n\n const childProps = child.props as any;\n const isFragment = child.type === Fragment;\n\n // Handle form fields with name prop (but not Fragments)\n if (!isFragment && childProps.name && typeof childProps.name === 'string') {\n const name = childProps.name as FieldPath<TFieldValues>;\n\n return (\n <Controller\n key={name}\n control={control}\n name={name}\n render={({ field, fieldState }) => {\n // Check if this is a Checkbox, Switch, RadioGroup, or CheckboxGroup component\n const isCheckbox = child.type === Checkbox;\n const isSwitch = child.type === Switch;\n const isRadioGroup = child.type === RadioGroup;\n const isCheckboxGroup = child.type === CheckboxGroup;\n const isPhone = child.type === PhoneField;\n const isDatePicker = child.type === DatePicker;\n const isDateTimePicker = child.type === DateTimePicker;\n\n const fieldProps =\n isCheckbox || isSwitch\n ? {\n checked: field.value,\n onCheckedChange: field.onChange,\n onBlur: field.onBlur,\n ref: field.ref,\n }\n : isRadioGroup || isCheckboxGroup\n ? {\n value: field.value,\n onValueChange: field.onChange,\n onBlur: field.onBlur,\n }\n : isDatePicker\n ? {\n value: field.value,\n onValueChange: field.onChange,\n onBlur: field.onBlur,\n ref: field.ref,\n }\n : isDateTimePicker\n ? {\n value: field.value,\n onValueChange: field.onChange,\n onBlur: field.onBlur,\n ref: field.ref,\n }\n : isPhone\n ? {\n ...field,\n onCountryChange: (country: Country | undefined) => {\n setValue(`${name}Country` as FieldPath<TFieldValues>, country as any);\n },\n }\n : field;\n\n const isUploadFile = child.type === UploadFile;\n\n return cloneElement(child, {\n ...childProps,\n ...fieldProps,\n error: fieldState.error?.message || (fieldState.error ? 'Invalid' : undefined),\n name: undefined, // Remove name to avoid passing it to the underlying input\n ...(isUploadFile ? { isLoading: isSubmitting } : {}),\n });\n }}\n />\n );\n }\n\n // Handle cancel buttons - wire up form.reset() + onCancel callback\n if (childProps['data-cancel'] && onCancel && reset) {\n return cloneElement(child, {\n ...childProps,\n onClick: () => {\n reset();\n onCancel();\n },\n });\n }\n\n // Handle submit buttons - inject loading state via isLoading prop\n if (childProps.type === 'submit') {\n const isButtonElement =\n child.type === Button || (typeof child.type === 'function' && (child.type as any).displayName === 'Button');\n\n if (isButtonElement) {\n return cloneElement(child, {\n ...childProps,\n isLoading: isSubmitting,\n });\n }\n }\n\n // Handle React Fragments - process their children directly\n if (isFragment) {\n return processChildren(childProps.children, control, isSubmitting, setValue, onCancel, reset);\n }\n\n // Recurse into children for container elements (divs, FieldGroups, etc.)\n if (childProps.children != null) {\n return cloneElement(child, {\n ...childProps,\n children: processChildren(childProps.children, control, isSubmitting, setValue, onCancel, reset),\n });\n }\n\n // Return unchanged if no name prop and no children\n return child;\n });\n}\n\nexport interface FormProps<\n TFieldValues extends FieldValues = FieldValues,\n TContext = any,\n TTransformedValues extends FieldValues | undefined = TFieldValues,\n TMutationData = unknown,\n TMutationError = Error,\n TMutationVariables = any,\n> extends Omit<React.FormHTMLAttributes<HTMLFormElement>, 'onSubmit'> {\n form: UseFormReturn<TFieldValues, TContext, TTransformedValues>;\n\n onSubmit?: Parameters<UseFormReturn<TFieldValues, TContext, TTransformedValues>['handleSubmit']>[0];\n\n children: React.ReactNode;\n\n rootErrorPosition?: 'top' | 'bottom';\n\n rootErrorClassName?: string;\n\n rootErrorAction?: React.ReactNode;\n\n fieldMapping?: FieldMapping;\n\n mutation?: UseMutationResult<TMutationData, TMutationError, TMutationVariables, unknown>;\n\n transformSubmit?: (\n data: TTransformedValues extends undefined ? TFieldValues : TTransformedValues,\n ) => TMutationVariables;\n\n resetOnSuccess?: boolean;\n\n onCancel?: () => void;\n}\n\n// Smart Form component that automatically wraps children with Controller\nexport function Form<\n TFieldValues extends FieldValues = FieldValues,\n TContext = any,\n TTransformedValues extends FieldValues | undefined = TFieldValues,\n TMutationData = unknown,\n TMutationError = Error,\n TMutationVariables = any,\n>({\n form,\n onSubmit,\n children,\n rootErrorPosition = 'bottom',\n rootErrorClassName,\n rootErrorAction,\n fieldMapping,\n mutation,\n transformSubmit,\n resetOnSuccess,\n onCancel,\n className,\n ...props\n}: FormProps<TFieldValues, TContext, TTransformedValues, TMutationData, TMutationError, TMutationVariables>) {\n // Compute isSubmitting from both form state and mutation state\n const isSubmitting = form.formState.isSubmitting || (mutation?.isPending ?? false);\n\n // Wrap the submit handler with automatic error mapping; the mutation's own callbacks fire automatically\n const wrappedOnSubmit = useCallback(\n async (data: TTransformedValues extends undefined ? TFieldValues : TTransformedValues) => {\n // Suppress error toasts during form submission — Form handles errors inline\n const interceptorId = axios.interceptors.request.use((config) => ({\n ...config,\n showErrorToast: false,\n }));\n\n try {\n if (mutation) {\n const variables = transformSubmit ? transformSubmit(data) : data;\n // mutateAsync will trigger the mutation's onSuccess/onError callbacks\n await mutation.mutateAsync(variables as TMutationVariables);\n } else if (onSubmit) {\n await onSubmit(data as any);\n }\n\n // Reset form after successful submission (default: true)\n if (resetOnSuccess !== false) form.reset();\n } catch (error) {\n // Map API errors to form fields — mapApiErrorsToForm extracts the axios error structure internally\n mapApiErrorsToForm(error, form as any, {\n fieldMapping,\n });\n // Log error for debugging\n console.error('[Form Submission Error]', error);\n // Error is swallowed, not re-thrown (mutation's onError already fired)\n } finally {\n axios.interceptors.request.eject(interceptorId);\n }\n },\n [onSubmit, mutation, transformSubmit, fieldMapping, form, resetOnSuccess],\n );\n\n const handleSubmit = form.handleSubmit(wrappedOnSubmit as any);\n\n // Process children recursively to automatically wrap with Controller\n const processedChildren = processChildren(children, form.control, isSubmitting, form.setValue, onCancel, form.reset);\n\n const childArray = Children.toArray(processedChildren);\n const actionsIndex = childArray.findIndex(\n (child) => isValidElement(child) && (child.type as { displayName?: string })?.displayName === 'DialogActions',\n );\n const hasActions = actionsIndex !== -1;\n const bodyChildren = hasActions ? childArray.filter((_, index) => index !== actionsIndex) : processedChildren;\n const actions = hasActions ? childArray[actionsIndex] : null;\n\n const topError =\n rootErrorPosition === 'top' && form.formState.errors.root ? (\n <Alert\n variant=\"destructive\"\n title={form.formState.errors.root.type || 'Error'}\n description={form.formState.errors.root.message}\n action={rootErrorAction}\n className={cn('mb-4', rootErrorClassName)}\n />\n ) : null;\n const bottomError =\n rootErrorPosition === 'bottom' && form.formState.errors.root ? (\n <Alert\n variant=\"destructive\"\n title={form.formState.errors.root.type || 'Error'}\n description={form.formState.errors.root.message}\n action={rootErrorAction}\n className={cn('mt-4', rootErrorClassName)}\n />\n ) : null;\n\n return (\n <FormProvider {...form}>\n <form\n onSubmit={handleSubmit}\n className={cn(hasActions ? 'flex min-h-0 flex-1 flex-col' : 'space-y-4', className)}\n {...props}\n >\n {hasActions ? (\n <>\n <div className=\"min-h-0 flex-1 space-y-4 overflow-y-auto overscroll-contain px-6 py-4\">\n {topError}\n {bodyChildren}\n {bottomError}\n </div>\n {actions}\n </>\n ) : (\n <>\n {topError}\n {processedChildren}\n {bottom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AAA,MAC1C,WAAA,EAAa,IAAA,CAAK,SAAA,CAAU,MAAA,CAAO,IAAA,CAAK,OAAA;AAAA,MACxC,MAAA,EAAQ,eAAA;AAAA,MACR,SAAA,EAAW,EAAA,CAAG,MAAA,EAAQ,kBAAkB;AAAA;AAAA,GAC1C,GACE,IAAA;AAEN,EAAA,uBACE,GAAA,CAAC,YAAA,EAAA,EAAc,GAAG,IAAA,EAChB,QAAA,kBAAA,GAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,QAAA,EAAU,YAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,UAAA,GAAa,8BAAA,GAAiC,aAAa,SAAS,CAAA;AAAA,MACjF,GAAG,KAAA;AAAA,MAEH,uCACC,IAAA,CAAA,QAAA,EAAA,EACE,QAAA,EAAA;AAAA,wBAAA,IAAA,CAAC,KAAA,EAAA,EAAI,WAAU,uEAAA,EACZ,QAAA,EAAA;AAAA,UAAA,QAAA;AAAA,UACA,YAAA;AAAA,UACA;AAAA,SAAA,EACH,CAAA;AAAA,QACC;AAAA,OAAA,EACH,oBAEA,IAAA,CAAA,QAAA,EAAA,EACG,QAAA,EAAA;AAAA,QAAA,QAAA;AAAA,QACA,iBAAA;AAAA,QACA;AAAA,OAAA,EACH;AAAA;AAAA,GAEJ,EACF,CAAA;AAEJ;AAEA,IAAA,CAAK,WAAA,GAAc,MAAA;;;;"}
|
|
@@ -967,7 +967,7 @@ svg.react-flow__connectionline {
|
|
|
967
967
|
--font-sans: "IBM Plex Sans", sans-serif;
|
|
968
968
|
--font-serif: "Playfair Display", serif;
|
|
969
969
|
--font-mono: "JetBrains Mono", monospace;
|
|
970
|
-
--radius: 0.
|
|
970
|
+
--radius: 0.625rem;
|
|
971
971
|
--shadow-x: 0rem;
|
|
972
972
|
--shadow-y: 0.5rem;
|
|
973
973
|
--shadow-blur: 1rem;
|
|
@@ -1043,7 +1043,7 @@ svg.react-flow__connectionline {
|
|
|
1043
1043
|
--font-sans: "IBM Plex Sans", sans-serif;
|
|
1044
1044
|
--font-serif: "Playfair Display", serif;
|
|
1045
1045
|
--font-mono: "JetBrains Mono", monospace;
|
|
1046
|
-
--radius: 0.
|
|
1046
|
+
--radius: 0.625rem;
|
|
1047
1047
|
--shadow-x: 0rem;
|
|
1048
1048
|
--shadow-y: 0.5rem;
|
|
1049
1049
|
--shadow-blur: 1.25rem;
|
|
@@ -4704,10 +4704,6 @@ select:-webkit-autofill:active {
|
|
|
4704
4704
|
-moz-appearance: textfield;
|
|
4705
4705
|
}
|
|
4706
4706
|
|
|
4707
|
-
.\[scrollbar-gutter\:stable\] {
|
|
4708
|
-
scrollbar-gutter: stable;
|
|
4709
|
-
}
|
|
4710
|
-
|
|
4711
4707
|
.\[text-decoration\:underline_line-through\] {
|
|
4712
4708
|
text-decoration: underline line-through;
|
|
4713
4709
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CopyButton.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/index.js
CHANGED
|
@@ -32,6 +32,7 @@ export { C as CompactTableSkeleton, a as CurrencyCell, D as DataTable, b as Data
|
|
|
32
32
|
export { C as CompanySelector } from './CompanySelector.js';
|
|
33
33
|
export { C as ConfirmHost } from './ConfirmHost.js';
|
|
34
34
|
export { C as Controller } from './index.esm.js';
|
|
35
|
+
export { C as CopyButton } from './CopyButton.js';
|
|
35
36
|
export { C as CopyField } from './CopyField.js';
|
|
36
37
|
export { C as CountryFilter, a as CountrySelector } from './CountrySelector.js';
|
|
37
38
|
export { C as CurrencyField } from './CurrencyField.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CopyButton.d.ts","sourceRoot":"","sources":["../../../../lib/components/CopyButton/CopyButton.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAQ/B,MAAM,WAAW,eAAe;IAE9B,KAAK,EAAE,MAAM,CAAC;IAEd,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAWD,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA2ChD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../lib/components/CopyButton/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTable.d.ts","sourceRoot":"","sources":["../../../../lib/components/DataTable/DataTable.tsx"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAiB,cAAc,EAA4B,MAAM,SAAS,CAAC;AA8BvF,wBAAgB,SAAS,CAAC,KAAK,EAAE,EAC/B,KAAK,EACL,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,OAAO,EACP,SAAiB,EACjB,SAAS,EACT,WAAkB,EAClB,YAAY,EACZ,IAAa,EACb,UAAU,EACV,aAAa,EACb,UAAU,GACX,EAAE,cAAc,CAAC,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"DataTable.d.ts","sourceRoot":"","sources":["../../../../lib/components/DataTable/DataTable.tsx"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAiB,cAAc,EAA4B,MAAM,SAAS,CAAC;AA8BvF,wBAAgB,SAAS,CAAC,KAAK,EAAE,EAC/B,KAAK,EACL,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,OAAO,EACP,SAAiB,EACjB,SAAS,EACT,WAAkB,EAClB,YAAY,EACZ,IAAa,EACb,UAAU,EACV,aAAa,EACb,UAAU,GACX,EAAE,cAAc,CAAC,KAAK,CAAC,kDAkdvB;yBAjee,SAAS"}
|
|
@@ -18,6 +18,7 @@ export * from './DatePicker';
|
|
|
18
18
|
export * from './DateRangePicker';
|
|
19
19
|
export * from './DateTimePicker';
|
|
20
20
|
export * from './DateTimeRangePicker';
|
|
21
|
+
export * from './CopyButton';
|
|
21
22
|
export * from './CopyField';
|
|
22
23
|
export * from './DetailField';
|
|
23
24
|
export * from './Dialog';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;A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AAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC"}
|
package/dist/useDataTable.js
CHANGED
|
@@ -21830,6 +21830,13 @@ function DataTable({
|
|
|
21830
21830
|
}) {
|
|
21831
21831
|
const [filtersOpen, setFiltersOpen] = useState(false);
|
|
21832
21832
|
const importDialog = useDialog();
|
|
21833
|
+
const headerScrollRef = useRef(null);
|
|
21834
|
+
const bodyScrollRef = useRef(null);
|
|
21835
|
+
const syncHeaderScroll = () => {
|
|
21836
|
+
if (headerScrollRef.current && bodyScrollRef.current) {
|
|
21837
|
+
headerScrollRef.current.scrollLeft = bodyScrollRef.current.scrollLeft;
|
|
21838
|
+
}
|
|
21839
|
+
};
|
|
21833
21840
|
const tableGate = usePermission(permission);
|
|
21834
21841
|
const importGate = usePermission(importExport?.importPermission);
|
|
21835
21842
|
const exportGate = usePermission(importExport?.exportPermission);
|
|
@@ -22002,134 +22009,158 @@ function DataTable({
|
|
|
22002
22009
|
},
|
|
22003
22010
|
"filters"
|
|
22004
22011
|
) : null }),
|
|
22005
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
22006
|
-
/* @__PURE__ */
|
|
22007
|
-
|
|
22008
|
-
|
|
22009
|
-
|
|
22010
|
-
|
|
22011
|
-
|
|
22012
|
-
|
|
22013
|
-
|
|
22014
|
-
|
|
22015
|
-
|
|
22016
|
-
|
|
22017
|
-
|
|
22018
|
-
|
|
22019
|
-
|
|
22020
|
-
|
|
22021
|
-
|
|
22022
|
-
|
|
22023
|
-
|
|
22024
|
-
"aria-hidden": true,
|
|
22025
|
-
className: "pointer-events-none absolute inset-x-0 top-0 bottom-px bg-muted/40 backdrop-blur-sm"
|
|
22026
|
-
}
|
|
22012
|
+
/* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col flex-1 min-h-0", children: [
|
|
22013
|
+
/* @__PURE__ */ jsx("div", { ref: headerScrollRef, className: "shrink-0 overflow-hidden", children: /* @__PURE__ */ jsx(
|
|
22014
|
+
"table",
|
|
22015
|
+
{
|
|
22016
|
+
className: "w-full caption-bottom text-sm table-fixed",
|
|
22017
|
+
style: { minWidth: table.getCenterTotalSize() },
|
|
22018
|
+
children: /* @__PURE__ */ jsx(TableHeader, { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx(TableRow, { children: headerGroup.headers.map((header) => {
|
|
22019
|
+
const isActions = header.column.id === "actions";
|
|
22020
|
+
const headerAlignClass = isActions ? "justify-end" : "justify-center";
|
|
22021
|
+
return /* @__PURE__ */ jsxs(
|
|
22022
|
+
TableHead,
|
|
22023
|
+
{
|
|
22024
|
+
colSpan: header.colSpan,
|
|
22025
|
+
style: isActions ? { width: "70px" } : { width: header.getSize(), minWidth: header.getSize(), maxWidth: header.getSize() },
|
|
22026
|
+
className: cn(
|
|
22027
|
+
"relative group/resize",
|
|
22028
|
+
// actions header stays pinned on horizontal scroll; z-20 keeps it above the
|
|
22029
|
+
// regular header cells that scroll underneath it.
|
|
22030
|
+
isActions ? "text-right sticky right-0 z-20" : "text-center"
|
|
22027
22031
|
),
|
|
22028
|
-
|
|
22029
|
-
|
|
22030
|
-
|
|
22031
|
-
|
|
22032
|
-
|
|
22033
|
-
|
|
22034
|
-
|
|
22035
|
-
|
|
22036
|
-
|
|
22037
|
-
|
|
22038
|
-
|
|
22039
|
-
|
|
22040
|
-
|
|
22041
|
-
|
|
22042
|
-
|
|
22043
|
-
|
|
22044
|
-
|
|
22045
|
-
|
|
22046
|
-
|
|
22047
|
-
{ length: table.getState().pagination?.pageSize ?? 20 },
|
|
22048
|
-
(_, i) => `skeleton-row-${i}`
|
|
22049
|
-
).map((rowKey) => /* @__PURE__ */ jsx(TableRow, { children: Array.from({ length: columnCount }, (_, i) => `${rowKey}-cell-${i}`).map((cellKey) => /* @__PURE__ */ jsx(TableCell, { className: densityClasses[density], children: /* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-full" }) }, cellKey)) }, rowKey)) : table.getRowModel().rows.map((row, index) => {
|
|
22050
|
-
const externallySelected = selectedRowId != null && row.id === selectedRowId;
|
|
22051
|
-
const isSelected = row.getIsSelected() || externallySelected;
|
|
22052
|
-
return /* @__PURE__ */ jsx(
|
|
22053
|
-
TableRow,
|
|
22054
|
-
{
|
|
22055
|
-
"data-state": isSelected ? "selected" : void 0,
|
|
22056
|
-
className: "group animate-in fade-in duration-300",
|
|
22057
|
-
style: { animationDelay: `${Math.min(index, 12) * 25}ms`, animationFillMode: "both" },
|
|
22058
|
-
children: row.getVisibleCells().map((cell) => {
|
|
22059
|
-
const isActionsCell = cell.column.id === "actions";
|
|
22060
|
-
return /* @__PURE__ */ jsxs(
|
|
22061
|
-
TableCell,
|
|
22062
|
-
{
|
|
22063
|
-
className: cn(
|
|
22064
|
-
densityClasses[density],
|
|
22065
|
-
isActionsCell ? "px-2 sticky right-0 z-10" : void 0,
|
|
22066
|
-
onRowClick && !isActionsCell ? "cursor-pointer" : void 0
|
|
22067
|
-
),
|
|
22068
|
-
onClick: onRowClick && !isActionsCell ? () => onRowClick(row.original) : void 0,
|
|
22069
|
-
style: isActionsCell ? { width: "70px" } : {
|
|
22070
|
-
width: cell.column.getSize(),
|
|
22071
|
-
minWidth: cell.column.getSize(),
|
|
22072
|
-
maxWidth: cell.column.getSize()
|
|
22073
|
-
},
|
|
22074
|
-
children: [
|
|
22075
|
-
isActionsCell && /* @__PURE__ */ jsx(
|
|
22076
|
-
"div",
|
|
22077
|
-
{
|
|
22078
|
-
"aria-hidden": true,
|
|
22079
|
-
className: "pointer-events-none absolute inset-x-0 top-0 bottom-px bg-background/40 backdrop-blur-sm group-hover:bg-muted/30 group-data-[state=selected]:bg-muted/40"
|
|
22080
|
-
}
|
|
22081
|
-
),
|
|
22082
|
-
/* @__PURE__ */ jsx(
|
|
22083
|
-
"div",
|
|
22084
|
-
{
|
|
22085
|
-
className: cn(
|
|
22086
|
-
isActionsCell ? "relative flex items-center justify-end" : "overflow-hidden text-center"
|
|
22087
|
-
),
|
|
22088
|
-
children: flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
22089
|
-
}
|
|
22032
|
+
"aria-sort": header.column.getCanSort() ? header.column.getIsSorted() === "asc" ? "ascending" : header.column.getIsSorted() === "desc" ? "descending" : "none" : void 0,
|
|
22033
|
+
children: [
|
|
22034
|
+
isActions && /* @__PURE__ */ jsx(
|
|
22035
|
+
"div",
|
|
22036
|
+
{
|
|
22037
|
+
"aria-hidden": true,
|
|
22038
|
+
className: "pointer-events-none absolute inset-x-0 top-0 bottom-px bg-muted backdrop-blur-sm"
|
|
22039
|
+
}
|
|
22040
|
+
),
|
|
22041
|
+
/* @__PURE__ */ jsx("div", { className: cn(isActions ? "relative" : void 0), children: header.isPlaceholder ? null : typeof header.column.columnDef.header === "string" ? /* @__PURE__ */ jsx("div", { className: cn("flex", headerAlignClass), children: /* @__PURE__ */ jsx(DataTableColumnHeader, { column: header.column, title: header.column.columnDef.header }) }) : flexRender(header.column.columnDef.header, header.getContext()) }),
|
|
22042
|
+
!meta?.lockedColumnSizing && header.column.getCanResize() && /* @__PURE__ */ jsx(
|
|
22043
|
+
"div",
|
|
22044
|
+
{
|
|
22045
|
+
onPointerDown: header.getResizeHandler(),
|
|
22046
|
+
onTouchStart: header.getResizeHandler(),
|
|
22047
|
+
className: cn(
|
|
22048
|
+
"absolute top-0 right-0 w-1 h-full cursor-col-resize select-none touch-none z-10",
|
|
22049
|
+
"opacity-0 group-hover/resize:opacity-100 hover:bg-primary/50",
|
|
22050
|
+
header.column.getIsResizing() && "opacity-100 bg-primary"
|
|
22090
22051
|
)
|
|
22091
|
-
|
|
22092
|
-
|
|
22093
|
-
|
|
22094
|
-
|
|
22095
|
-
|
|
22096
|
-
|
|
22097
|
-
|
|
22098
|
-
|
|
22099
|
-
|
|
22100
|
-
|
|
22101
|
-
|
|
22102
|
-
/* @__PURE__ */ jsx(PermissionLockIcon, { reason: tableGate.reason, className: "size-6" }),
|
|
22103
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: lockedTip(tableGate) })
|
|
22104
|
-
] }) : isFiltered ? /* @__PURE__ */ jsx(
|
|
22105
|
-
DataTableEmpty,
|
|
22052
|
+
}
|
|
22053
|
+
)
|
|
22054
|
+
]
|
|
22055
|
+
},
|
|
22056
|
+
header.id
|
|
22057
|
+
);
|
|
22058
|
+
}) }, headerGroup.id)) })
|
|
22059
|
+
}
|
|
22060
|
+
) }),
|
|
22061
|
+
/* @__PURE__ */ jsxs(
|
|
22062
|
+
"div",
|
|
22106
22063
|
{
|
|
22107
|
-
|
|
22108
|
-
|
|
22109
|
-
|
|
22110
|
-
|
|
22111
|
-
|
|
22112
|
-
|
|
22113
|
-
hasActiveView && slug && /* @__PURE__ */ jsx(
|
|
22114
|
-
Button,
|
|
22064
|
+
ref: bodyScrollRef,
|
|
22065
|
+
onScroll: syncHeaderScroll,
|
|
22066
|
+
className: "relative flex flex-col flex-1 min-h-0 overflow-auto overscroll-auto",
|
|
22067
|
+
children: [
|
|
22068
|
+
!locked && (isLoading || table.getRowModel().rows.length > 0) && /* @__PURE__ */ jsx(
|
|
22069
|
+
"table",
|
|
22115
22070
|
{
|
|
22116
|
-
|
|
22117
|
-
|
|
22118
|
-
|
|
22119
|
-
|
|
22071
|
+
className: "w-full caption-bottom text-sm table-fixed",
|
|
22072
|
+
style: { minWidth: table.getCenterTotalSize() },
|
|
22073
|
+
children: /* @__PURE__ */ jsx(TableBody, { children: isLoading ? Array.from(
|
|
22074
|
+
{ length: table.getState().pagination?.pageSize ?? 20 },
|
|
22075
|
+
(_, i) => `skeleton-row-${i}`
|
|
22076
|
+
).map((rowKey) => /* @__PURE__ */ jsx(TableRow, { children: Array.from({ length: columnCount }, (_, i) => `${rowKey}-cell-${i}`).map((cellKey) => /* @__PURE__ */ jsx(TableCell, { className: densityClasses[density], children: /* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-full" }) }, cellKey)) }, rowKey)) : table.getRowModel().rows.map((row, index) => {
|
|
22077
|
+
const externallySelected = selectedRowId != null && row.id === selectedRowId;
|
|
22078
|
+
const isSelected = row.getIsSelected() || externallySelected;
|
|
22079
|
+
return /* @__PURE__ */ jsx(
|
|
22080
|
+
TableRow,
|
|
22081
|
+
{
|
|
22082
|
+
"data-state": isSelected ? "selected" : void 0,
|
|
22083
|
+
className: "group animate-in fade-in duration-300",
|
|
22084
|
+
style: { animationDelay: `${Math.min(index, 12) * 25}ms`, animationFillMode: "both" },
|
|
22085
|
+
children: row.getVisibleCells().map((cell) => {
|
|
22086
|
+
const isActionsCell = cell.column.id === "actions";
|
|
22087
|
+
return /* @__PURE__ */ jsxs(
|
|
22088
|
+
TableCell,
|
|
22089
|
+
{
|
|
22090
|
+
className: cn(
|
|
22091
|
+
densityClasses[density],
|
|
22092
|
+
isActionsCell ? "px-2 sticky right-0 z-10" : void 0,
|
|
22093
|
+
onRowClick && !isActionsCell ? "cursor-pointer" : void 0
|
|
22094
|
+
),
|
|
22095
|
+
onClick: onRowClick && !isActionsCell ? () => onRowClick(row.original) : void 0,
|
|
22096
|
+
style: isActionsCell ? { width: "70px" } : {
|
|
22097
|
+
width: cell.column.getSize(),
|
|
22098
|
+
minWidth: cell.column.getSize(),
|
|
22099
|
+
maxWidth: cell.column.getSize()
|
|
22100
|
+
},
|
|
22101
|
+
children: [
|
|
22102
|
+
isActionsCell && /* @__PURE__ */ jsx(
|
|
22103
|
+
"div",
|
|
22104
|
+
{
|
|
22105
|
+
"aria-hidden": true,
|
|
22106
|
+
className: "pointer-events-none absolute inset-x-0 top-0 bottom-px bg-background/40 backdrop-blur-sm group-hover:bg-muted/30 group-data-[state=selected]:bg-muted/40"
|
|
22107
|
+
}
|
|
22108
|
+
),
|
|
22109
|
+
/* @__PURE__ */ jsx(
|
|
22110
|
+
"div",
|
|
22111
|
+
{
|
|
22112
|
+
className: cn(
|
|
22113
|
+
isActionsCell ? "relative flex items-center justify-end" : "overflow-hidden text-center"
|
|
22114
|
+
),
|
|
22115
|
+
children: flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
22116
|
+
}
|
|
22117
|
+
)
|
|
22118
|
+
]
|
|
22119
|
+
},
|
|
22120
|
+
cell.id
|
|
22121
|
+
);
|
|
22122
|
+
})
|
|
22123
|
+
},
|
|
22124
|
+
row.id
|
|
22125
|
+
);
|
|
22126
|
+
}) })
|
|
22120
22127
|
}
|
|
22121
|
-
)
|
|
22122
|
-
|
|
22123
|
-
|
|
22124
|
-
|
|
22125
|
-
|
|
22126
|
-
|
|
22127
|
-
|
|
22128
|
-
|
|
22129
|
-
|
|
22130
|
-
|
|
22128
|
+
),
|
|
22129
|
+
(locked || !isLoading && table.getRowModel().rows.length === 0) && /* @__PURE__ */ jsx("div", { className: "flex flex-1 items-center justify-center", children: locked ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-2 text-center", children: [
|
|
22130
|
+
/* @__PURE__ */ jsx(PermissionLockIcon, { reason: tableGate.reason, className: "size-6" }),
|
|
22131
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: lockedTip(tableGate) })
|
|
22132
|
+
] }) : isFiltered ? /* @__PURE__ */ jsx(
|
|
22133
|
+
DataTableEmpty,
|
|
22134
|
+
{
|
|
22135
|
+
icon: emptyStateConfig?.icon,
|
|
22136
|
+
title: "No results found",
|
|
22137
|
+
description: buildNoResultsDescription({ hasActiveSearch, hasActiveFilters, hasActiveView }),
|
|
22138
|
+
action: /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
22139
|
+
hasActiveSearch && /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: () => meta?.setSearch?.(searchBaseline), children: "Clear Search" }),
|
|
22140
|
+
hasActiveFilters && /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: () => meta?.setFilters?.(filtersBaseline), children: "Clear Filters" }),
|
|
22141
|
+
hasActiveView && slug && /* @__PURE__ */ jsx(
|
|
22142
|
+
Button,
|
|
22143
|
+
{
|
|
22144
|
+
variant: "outline",
|
|
22145
|
+
size: "sm",
|
|
22146
|
+
onClick: () => loadViewState(slug, EMPTY_TABLE_STATE, null, false),
|
|
22147
|
+
children: "Clear View"
|
|
22148
|
+
}
|
|
22149
|
+
)
|
|
22150
|
+
] })
|
|
22151
|
+
}
|
|
22152
|
+
) : /* @__PURE__ */ jsx(
|
|
22153
|
+
DataTableEmpty,
|
|
22154
|
+
{
|
|
22155
|
+
icon: emptyStateConfig?.icon,
|
|
22156
|
+
title: emptyStateConfig?.title,
|
|
22157
|
+
description: emptyStateConfig?.description,
|
|
22158
|
+
action: emptyStateConfig?.action
|
|
22159
|
+
}
|
|
22160
|
+
) })
|
|
22161
|
+
]
|
|
22131
22162
|
}
|
|
22132
|
-
)
|
|
22163
|
+
)
|
|
22133
22164
|
] })
|
|
22134
22165
|
] }),
|
|
22135
22166
|
(mode !== "compact" || table.getRowCount() > (table.getState().pagination?.pageSize ?? 20)) && /* @__PURE__ */ jsx(DataTablePagination, { table }),
|