@cryptlex/web-components 6.4.4 → 6.5.0-alpha00
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/alert.js.map +1 -1
- package/dist/components/avatar.js.map +1 -1
- package/dist/components/badge.js.map +1 -1
- package/dist/components/breadcrumbs.js +1 -1
- package/dist/components/breadcrumbs.js.map +1 -1
- package/dist/components/button.js +1 -1
- package/dist/components/button.js.map +1 -1
- package/dist/components/calendar.js +1 -1
- package/dist/components/calendar.js.map +1 -1
- package/dist/components/card.js.map +1 -1
- package/dist/components/checkbox.d.ts +1 -1
- package/dist/components/checkbox.js +1 -1
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/data-table-commons.d.ts +4 -4
- package/dist/components/data-table-commons.js +1 -1
- package/dist/components/data-table-commons.js.map +1 -1
- package/dist/components/data-table-filter.d.ts +21 -4
- package/dist/components/data-table-filter.js +1 -1
- package/dist/components/data-table.d.ts +32 -20
- package/dist/components/data-table.js +1 -1
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/date-picker.d.ts +1 -1
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/datefield.js.map +1 -1
- package/dist/components/dialog.js +1 -1
- package/dist/components/dialog.js.map +1 -1
- package/dist/components/disclosure.d.ts +1 -1
- package/dist/components/disclosure.js.map +1 -1
- package/dist/components/field.js +1 -1
- package/dist/components/field.js.map +1 -1
- package/dist/components/id-search.js +1 -1
- package/dist/components/id-search.js.map +1 -1
- package/dist/components/input-otp.js +1 -1
- package/dist/components/input-otp.js.map +1 -1
- package/dist/components/key-value-card.js +1 -1
- package/dist/components/key-value-card.js.map +1 -1
- package/dist/components/list-box.js +1 -1
- package/dist/components/list-box.js.map +1 -1
- package/dist/components/loader.js +1 -1
- package/dist/components/loader.js.map +1 -1
- package/dist/components/menu.js +1 -1
- package/dist/components/menu.js.map +1 -1
- package/dist/components/multi-select.d.ts +3 -3
- package/dist/components/multi-select.js +1 -1
- package/dist/components/multi-select.js.map +1 -1
- package/dist/components/numberfield.js +1 -1
- package/dist/components/numberfield.js.map +1 -1
- package/dist/components/popover.js.map +1 -1
- package/dist/components/searchfield.js.map +1 -1
- package/dist/components/select.d.ts +2 -2
- package/dist/components/select.js +1 -1
- package/dist/components/select.js.map +1 -1
- package/dist/components/sidebar.d.ts +2 -2
- package/dist/components/sidebar.js +1 -1
- package/dist/components/sidebar.js.map +1 -1
- package/dist/components/skeleton.js.map +1 -1
- package/dist/components/table-of-contents.js +1 -1
- package/dist/components/table-of-contents.js.map +1 -1
- package/dist/components/table.js.map +1 -1
- package/dist/components/tabs.js +1 -1
- package/dist/components/tabs.js.map +1 -1
- package/dist/components/textfield.js +1 -1
- package/dist/components/textfield.js.map +1 -1
- package/dist/components/timeline.js.map +1 -1
- package/dist/components/tooltip.js.map +1 -1
- package/dist/utils/form-hook.d.ts +6 -6
- package/dist/utils/form-hook.js +1 -1
- package/dist/utils/form-hook.js.map +1 -1
- package/dist/utils/form-utils.js +1 -1
- package/dist/utils/form-utils.js.map +1 -1
- package/dist/utils/resource-names.d.ts +1 -1
- package/dist/utils/resource-names.js +1 -1
- package/dist/utils/resource-names.js.map +1 -1
- package/package.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alert.js","sources":["../../lib/components/alert.tsx"],"sourcesContent":["import { cva, type VariantProps } from 'class-variance-authority';\nimport {
|
|
1
|
+
{"version":3,"file":"alert.js","sources":["../../lib/components/alert.tsx"],"sourcesContent":["import { cva, type VariantProps } from 'class-variance-authority';\nimport { type LucideIcon } from 'lucide-react';\nimport { classNames } from '../utils/primitives';\n\nexport const alertVariants = cva(\n `transition-colors border border-dotted p-2 text-foreground body inline-flex items-start gap-2`,\n {\n variants: {\n variant: {\n destructive: 'bg-destructive-foreground/20 text-destructive border-destructive',\n success: 'bg-success-foreground/20 text-success border-success',\n muted: 'bg-muted-foreground/20 text-muted border-muted',\n },\n },\n defaultVariants: {\n variant: 'muted',\n },\n }\n);\n\nexport function Alert({\n children,\n className,\n variant,\n icon: Icon,\n ...props\n}: React.ComponentProps<'div'> &\n VariantProps<typeof alertVariants> & {\n icon?: LucideIcon;\n }) {\n return (\n <div role=\"alert\" className={classNames(alertVariants({ variant }), className)} {...props}>\n {Icon && <Icon className=\"size-icon mt-1\" />}\n <span className=\"w-full\">{children}</span>\n </div>\n );\n}\n"],"names":["alertVariants","cva","Alert","children","className","variant","Icon","props","jsxs","classNames","jsx"],"mappings":"kKAIO,MAAMA,EAAgBC,EACzB,gGACA,CACI,SAAU,CACN,QAAS,CACL,YAAa,mEACb,QAAS,uDACT,MAAO,gDAAA,CACX,EAEJ,gBAAiB,CACb,QAAS,OAAA,CACb,CAER,EAEO,SAASC,EAAM,CAClB,SAAAC,EACA,UAAAC,EACA,QAAAC,EACA,KAAMC,EACN,GAAGC,CACP,EAGO,CACH,OACIC,EAAC,MAAA,CAAI,KAAK,QAAQ,UAAWC,EAAWT,EAAc,CAAE,QAAAK,CAAA,CAAS,EAAGD,CAAS,EAAI,GAAGG,EAC/E,SAAA,CAAAD,GAAQI,EAACJ,EAAA,CAAK,UAAU,gBAAA,CAAiB,EAC1CI,EAAC,OAAA,CAAK,UAAU,SAAU,SAAAP,CAAA,CAAS,CAAA,EACvC,CAER"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avatar.js","sources":["../../lib/components/avatar.tsx"],"sourcesContent":["import { classNames } from '
|
|
1
|
+
{"version":3,"file":"avatar.js","sources":["../../lib/components/avatar.tsx"],"sourcesContent":["import { classNames } from '../utils/primitives';\n\ninterface InitialString {\n initials: string[2];\n}\nexport interface AvatarProps extends Omit<React.ComponentProps<'div'>, 'children'>, InitialString {}\nexport function Avatar({ className, initials, ...props }: AvatarProps) {\n return (\n <div\n className={classNames(\n 'relative body-sm font-mono font-bold flex items-center leading-none justify-center bg-accent text-accent-foreground select-none size-input shrink-0 overflow-hidden rounded-full',\n className\n )}\n {...props}\n >\n {initials}\n </div>\n );\n}\n"],"names":["Avatar","className","initials","props","jsx","classNames"],"mappings":"yGAMO,SAASA,EAAO,CAAE,UAAAC,EAAW,SAAAC,EAAU,GAAGC,GAAsB,CACnE,OACIC,EAAC,MAAA,CACG,UAAWC,EACP,mLACAJ,CAAA,EAEH,GAAGE,EAEH,SAAAD,CAAA,CAAA,CAGb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"badge.js","sources":["../../lib/components/badge.tsx"],"sourcesContent":["import { classNames } from '
|
|
1
|
+
{"version":3,"file":"badge.js","sources":["../../lib/components/badge.tsx"],"sourcesContent":["import { classNames } from '../utils/primitives';\n\nexport function Badge({ className, children, ...props }: React.ComponentProps<'span'>) {\n return (\n <span\n className={classNames(\n 'text-muted leading-none body-sm px-1 inline-flex items-center justify-center select-none bg-popover border h-input focus:outline-hidden focus:ring-1 focus:ring-ring',\n className\n )}\n {...props}\n >\n {/* Contents */}\n <span>{children}</span>\n </span>\n );\n}\n"],"names":["Badge","className","children","props","jsx","classNames"],"mappings":"yGAEO,SAASA,EAAM,CAAE,UAAAC,EAAW,SAAAC,EAAU,GAAGC,GAAuC,CACnF,OACIC,EAAC,OAAA,CACG,UAAWC,EACP,uKACAJ,CAAA,EAEH,GAAGE,EAGJ,SAAAC,EAAC,QAAM,SAAAF,CAAA,CAAS,CAAA,CAAA,CAG5B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as a,jsxs as i}from"react/jsx-runtime";import{Breadcrumbs as c,Breadcrumb as m,Link as s,composeRenderProps as o}from"react-aria-components";import{
|
|
1
|
+
import{jsx as a,jsxs as i}from"react/jsx-runtime";import{Breadcrumbs as c,Breadcrumb as m,Link as s,composeRenderProps as o}from"react-aria-components";import{ChevronRight as d,DotSquare as u}from"lucide-react";import{classNames as t}from"../utils/primitives.js";import"clsx";function x({className:e,...r}){return a(c,{className:t("flex flex-wrap items-center gap-1.5 break-words body-sm text-muted-foreground sm:gap-2.5",e),...r})}function B({className:e,...r}){return a(m,{className:t("inline-flex items-center gap-1.5 sm:gap-2.5",e),...r})}function N({className:e,...r}){return a(s,{className:o(e,n=>t("transition-colors","data-[hovered]:text-foreground","data-[disabled]:pointer-events-none data-[disabled]:opacity-50","data-[current]:pointer-events-auto data-[current]:opacity-100",n)),...r})}function h({children:e,className:r,...n}){return a("span",{role:"presentation","aria-hidden":"true",className:t("[&>svg]:size-icon",r),...n,children:e||a(d,{})})}function v({className:e,...r}){return i("span",{role:"presentation","aria-hidden":"true",className:t("flex size-input items-center justify-center",e),...r,children:[a(u,{className:"size-icon"}),a("span",{className:"sr-only",children:"More"})]})}function y({className:e,...r}){return a(s,{className:o(e,n=>t("font-normal text-foreground",n)),...r})}export{v as BreadcrumbEllipsis,B as BreadcrumbItem,N as BreadcrumbLink,y as BreadcrumbPage,h as BreadcrumbSeparator,x as Breadcrumbs};
|
|
2
2
|
//# sourceMappingURL=breadcrumbs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"breadcrumbs.js","sources":["../../lib/components/breadcrumbs.tsx"],"sourcesContent":["import {\n Breadcrumb as AriaBreadcrumb,\n BreadcrumbProps as AriaBreadcrumbProps,\n Breadcrumbs as AriaBreadcrumbs,\n BreadcrumbsProps as AriaBreadcrumbsProps,\n Link as AriaLink,\n LinkProps as AriaLinkProps,\n composeRenderProps,\n} from 'react-aria-components';\n\nimport {
|
|
1
|
+
{"version":3,"file":"breadcrumbs.js","sources":["../../lib/components/breadcrumbs.tsx"],"sourcesContent":["import {\n Breadcrumb as AriaBreadcrumb,\n BreadcrumbProps as AriaBreadcrumbProps,\n Breadcrumbs as AriaBreadcrumbs,\n BreadcrumbsProps as AriaBreadcrumbsProps,\n Link as AriaLink,\n LinkProps as AriaLinkProps,\n composeRenderProps,\n} from 'react-aria-components';\n\nimport { ChevronRight, DotSquare } from 'lucide-react';\nimport { classNames } from '../utils/primitives';\n\nexport function Breadcrumbs<T extends object>({ className, ...props }: AriaBreadcrumbsProps<T>) {\n return (\n <AriaBreadcrumbs\n className={classNames(\n 'flex flex-wrap items-center gap-1.5 break-words body-sm text-muted-foreground sm:gap-2.5',\n className\n )}\n {...props}\n />\n );\n}\n\nexport function BreadcrumbItem({ className, ...props }: AriaBreadcrumbProps) {\n return (\n <AriaBreadcrumb className={classNames('inline-flex items-center gap-1.5 sm:gap-2.5', className)} {...props} />\n );\n}\n\nexport function BreadcrumbLink({ className, ...props }: AriaLinkProps) {\n return (\n <AriaLink\n className={composeRenderProps(className, className =>\n classNames(\n 'transition-colors',\n /* Hover */\n 'data-[hovered]:text-foreground',\n /* Disabled */\n 'data-[disabled]:pointer-events-none data-[disabled]:opacity-50',\n /* Current */\n 'data-[current]:pointer-events-auto data-[current]:opacity-100',\n className\n )\n )}\n {...props}\n />\n );\n}\n\nexport function BreadcrumbSeparator({ children, className, ...props }: React.ComponentProps<'span'>) {\n return (\n <span role=\"presentation\" aria-hidden=\"true\" className={classNames('[&>svg]:size-icon', className)} {...props}>\n {children || <ChevronRight />}\n </span>\n );\n}\n\nexport function BreadcrumbEllipsis({ className, ...props }: React.ComponentProps<'span'>) {\n return (\n <span\n role=\"presentation\"\n aria-hidden=\"true\"\n className={classNames('flex size-input items-center justify-center', className)}\n {...props}\n >\n <DotSquare className=\"size-icon\" />\n <span className=\"sr-only\">More</span>\n </span>\n );\n}\n\ninterface BreadcrumbPageProps extends Omit<AriaLinkProps, 'href'> {}\n\nexport function BreadcrumbPage({ className, ...props }: BreadcrumbPageProps) {\n return (\n <AriaLink\n className={composeRenderProps(className, className => classNames('font-normal text-foreground', className))}\n {...props}\n />\n );\n}\n"],"names":["Breadcrumbs","className","props","jsx","AriaBreadcrumbs","classNames","BreadcrumbItem","AriaBreadcrumb","BreadcrumbLink","AriaLink","composeRenderProps","BreadcrumbSeparator","children","ChevronRight","BreadcrumbEllipsis","jsxs","DotSquare","BreadcrumbPage"],"mappings":"oRAaO,SAASA,EAA8B,CAAE,UAAAC,EAAW,GAAGC,GAAkC,CAC5F,OACIC,EAACC,EAAA,CACG,UAAWC,EACP,2FACAJ,CAAA,EAEH,GAAGC,CAAA,CAAA,CAGhB,CAEO,SAASI,EAAe,CAAE,UAAAL,EAAW,GAAGC,GAA8B,CACzE,OACIC,EAACI,GAAe,UAAWF,EAAW,8CAA+CJ,CAAS,EAAI,GAAGC,EAAO,CAEpH,CAEO,SAASM,EAAe,CAAE,UAAAP,EAAW,GAAGC,GAAwB,CACnE,OACIC,EAACM,EAAA,CACG,UAAWC,EAAmBT,EAAWA,GACrCI,EACI,oBAEA,iCAEA,iEAEA,gEACAJ,CAAA,CACJ,EAEH,GAAGC,CAAA,CAAA,CAGhB,CAEO,SAASS,EAAoB,CAAE,SAAAC,EAAU,UAAAX,EAAW,GAAGC,GAAuC,CACjG,SACK,OAAA,CAAK,KAAK,eAAe,cAAY,OAAO,UAAWG,EAAW,oBAAqBJ,CAAS,EAAI,GAAGC,EACnG,SAAAU,GAAYT,EAACU,IAAa,EAC/B,CAER,CAEO,SAASC,EAAmB,CAAE,UAAAb,EAAW,GAAGC,GAAuC,CACtF,OACIa,EAAC,OAAA,CACG,KAAK,eACL,cAAY,OACZ,UAAWV,EAAW,8CAA+CJ,CAAS,EAC7E,GAAGC,EAEJ,SAAA,CAAAC,EAACa,EAAA,CAAU,UAAU,WAAA,CAAY,EACjCb,EAAC,OAAA,CAAK,UAAU,UAAU,SAAA,MAAA,CAAI,CAAA,CAAA,CAAA,CAG1C,CAIO,SAASc,EAAe,CAAE,UAAAhB,EAAW,GAAGC,GAA8B,CACzE,OACIC,EAACM,EAAA,CACG,UAAWC,EAAmBT,EAAWA,GAAaI,EAAW,8BAA+BJ,CAAS,CAAC,EACzG,GAAGC,CAAA,CAAA,CAGhB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{jsx as r,jsxs as c,Fragment as o}from"react/jsx-runtime";import{cva as p}from"class-variance-authority";import{
|
|
1
|
+
"use client";import{jsx as r,jsxs as c,Fragment as o}from"react/jsx-runtime";import{cva as p}from"class-variance-authority";import{Button as l,composeRenderProps as a}from"react-aria-components";import{classNames as d}from"../utils/primitives.js";import{Loader as f}from"./loader.js";import"clsx";import"lucide-react";const v=p("btn",{variants:{variant:{primary:"btn-primary",secondary:"btn-secondary",destructive:"btn-destructive",neutral:"btn-neutral",ghost:"btn-ghost",link:"text-primary underline-offset-4 hover:underline"},size:{default:"input-dim",icon:"size-input",none:""}},defaultVariants:{variant:"neutral",size:"default"}});function j({className:e,variant:i,size:s,children:m,isPending:n,active:b,...u}){return r(l,{...u,className:a(e,t=>d(v({variant:i,size:s,className:t}),e)),children:a(m,t=>c(o,{children:[n&&r(f,{}),!n&&r(o,{children:t})]}))})}export{j as Button,v as buttonVariants};
|
|
2
2
|
//# sourceMappingURL=button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.js","sources":["../../lib/components/button.tsx"],"sourcesContent":["'use client';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport {
|
|
1
|
+
{"version":3,"file":"button.js","sources":["../../lib/components/button.tsx"],"sourcesContent":["'use client';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { Button as AriaButton, composeRenderProps, type ButtonProps as AriaButtonProps } from 'react-aria-components';\nimport { classNames } from '../utils/primitives';\nimport { Loader } from './loader';\n\nexport const buttonVariants = cva('btn', {\n variants: {\n variant: {\n primary: 'btn-primary',\n secondary: 'btn-secondary',\n destructive: 'btn-destructive',\n neutral: 'btn-neutral',\n ghost: 'btn-ghost',\n link: 'text-primary underline-offset-4 hover:underline',\n },\n size: {\n default: 'input-dim',\n icon: 'size-input',\n none: '',\n },\n },\n defaultVariants: {\n variant: 'neutral',\n size: 'default',\n },\n});\n\nexport type ButtonProps = AriaButtonProps &\n VariantProps<typeof buttonVariants> & {\n ref?: React.Ref<HTMLButtonElement>;\n active?: boolean;\n };\n\nexport function Button({\n className: additionalClasses,\n variant,\n size,\n children,\n isPending,\n active,\n ...props\n}: ButtonProps) {\n return (\n <AriaButton\n {...props}\n className={composeRenderProps(additionalClasses, className =>\n classNames(\n buttonVariants({\n variant,\n size,\n className,\n }),\n additionalClasses\n )\n )}\n >\n {composeRenderProps(children, children => (\n <>\n {isPending && <Loader />}\n {!isPending && <>{children}</>}\n </>\n ))}\n </AriaButton>\n );\n}\n"],"names":["buttonVariants","cva","Button","additionalClasses","variant","size","children","isPending","active","props","jsx","AriaButton","composeRenderProps","className","classNames","jsxs","Fragment","Loader"],"mappings":"8TAMO,MAAMA,EAAiBC,EAAI,MAAO,CACrC,SAAU,CACN,QAAS,CACL,QAAS,cACT,UAAW,gBACX,YAAa,kBACb,QAAS,cACT,MAAO,YACP,KAAM,iDAAA,EAEV,KAAM,CACF,QAAS,YACT,KAAM,aACN,KAAM,EAAA,CACV,EAEJ,gBAAiB,CACb,QAAS,UACT,KAAM,SAAA,CAEd,CAAC,EAQM,SAASC,EAAO,CACnB,UAAWC,EACX,QAAAC,EACA,KAAAC,EACA,SAAAC,EACA,UAAAC,EACA,OAAAC,EACA,GAAGC,CACP,EAAgB,CACZ,OACIC,EAACC,EAAA,CACI,GAAGF,EACJ,UAAWG,EAAmBT,EAAmBU,GAC7CC,EACId,EAAe,CACX,QAAAI,EACA,KAAAC,EACA,UAAAQ,CAAA,CACH,EACDV,CAAA,CACJ,EAGH,SAAAS,EAAmBN,EAAUA,GAC1BS,EAAAC,EAAA,CACK,SAAA,CAAAT,KAAcU,EAAA,EAAO,EACrB,CAACV,GAAaG,EAAAM,EAAA,CAAG,SAAAV,CAAAA,CAAS,CAAA,EAC/B,CACH,CAAA,CAAA,CAGb"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsxs as o,jsx as e}from"react/jsx-runtime";import{today as y,getLocalTimeZone as b}from"@internationalized/date";import{CalendarGridHeader as v,useLocale as N,Heading as S,CalendarGrid as G,CalendarHeaderCell as H,CalendarGridBody as R,RangeCalendarStateContext as $,CalendarCell as w,composeRenderProps as l,Calendar as z,RangeCalendar as B}from"react-aria-components";import{
|
|
1
|
+
import{jsxs as o,jsx as e}from"react/jsx-runtime";import{today as y,getLocalTimeZone as b}from"@internationalized/date";import{CalendarGridHeader as v,useLocale as N,Heading as S,CalendarGrid as G,CalendarHeaderCell as H,CalendarGridBody as R,RangeCalendarStateContext as $,CalendarCell as w,composeRenderProps as l,Calendar as z,RangeCalendar as B}from"react-aria-components";import{ChevronRight as c,ChevronLeft as s}from"lucide-react";import{use as j}from"react";import{Button as u,buttonVariants as E}from"./button.js";import{FieldError as m}from"./field.js";import{classNames as n}from"../utils/primitives.js";import"class-variance-authority";import"./loader.js";import"clsx";function f(a){let{direction:t}=N();return o("header",{className:"flex w-full items-center gap-1 px-1 pb-icon",...a,children:[e(u,{slot:"previous",size:"none",className:n("size-7 bg-transparent p-0 opacity-50","data-[hovered]:opacity-100"),children:t==="rtl"?e(c,{"aria-hidden":!0}):e(s,{"aria-hidden":!0})}),e(S,{className:"grow text-center body font-medium"}),e(u,{slot:"next",className:n("size-7 bg-transparent p-0 opacity-50","data-[hovered]:opacity-100"),children:t==="rtl"?e(s,{"aria-hidden":!0}):e(c,{"aria-hidden":!0})})]})}function g({className:a,...t}){return e(G,{className:n(" border-separate border-spacing-x-0 border-spacing-y-1 ",a),...t})}const C=v;function h({className:a,...t}){return e(H,{className:n("w-9 body-sm font-normal text-muted-foreground",a),...t})}function p({className:a,...t}){return e(R,{className:n("[&>tr>td]:p-0",a),...t})}function x({className:a,...t}){const i=!!j($);return e(w,{className:l(a,(d,r)=>n(E({variant:"ghost",size:"none"}),"relative flex size-9 items-center justify-center p-0 body-sm font-normal",r.isDisabled&&"text-muted-foreground opacity-50",r.isSelected&&"bg-primary text-primary-foreground data-[focused]:bg-primary data-[focused]:text-primary-foreground",r.isHovered&&r.isSelected&&(r.isSelectionStart||r.isSelectionEnd||!i)&&"data-[hovered]:bg-primary data-[hovered]:text-primary-foreground",r.isSelected&&i&&!r.isSelectionStart&&!r.isSelectionEnd&&"rounded-none bg-accent text-accent-foreground",r.isOutsideMonth&&"text-muted-foreground opacity-50 data-[selected]:bg-accent/50 data-[selected]:text-muted-foreground data-[selected]:opacity-30",r.date.compare(y(b()))===0&&!r.isSelected&&"bg-accent text-accent-foreground",r.isUnavailable&&"cursor-default text-destructive ",r.isInvalid&&"bg-destructive text-destructive-foreground data-[focused]:bg-destructive data-[hovered]:bg-destructive data-[focused]:text-destructive-foreground data-[hovered]:text-destructive-foreground",d)),...t})}function A({errorMessage:a,className:t,...i}){return o(z,{className:l(t,d=>n("w-fit",d)),...i,children:[e(f,{}),o(g,{children:[e(C,{children:d=>e(h,{children:d})}),e(p,{children:d=>e(x,{date:d})})]}),a&&e(m,{children:a})]})}function J({errorMessage:a,className:t,...i}){return o(B,{className:l(t,d=>n("w-fit",d)),...i,children:[e(f,{}),o(g,{children:[e(C,{children:d=>e(h,{children:d})}),e(p,{children:d=>e(x,{date:d})})]}),a&&e(m,{slot:"errorMessage",children:a})]})}export{A as Calendar,x as CalendarCell,g as CalendarGrid,p as CalendarGridBody,C as CalendarGridHeader,h as CalendarHeaderCell,f as CalendarHeading,J as RangeCalendar};
|
|
2
2
|
//# sourceMappingURL=calendar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar.js","sources":["../../lib/components/calendar.tsx"],"sourcesContent":["import { getLocalTimeZone, today } from '@internationalized/date';\nimport {\n Calendar as AriaCalendar,\n CalendarCell as AriaCalendarCell,\n CalendarCellProps as AriaCalendarCellProps,\n CalendarGrid as AriaCalendarGrid,\n CalendarGridBody as AriaCalendarGridBody,\n CalendarGridBodyProps as AriaCalendarGridBodyProps,\n CalendarGridHeader as AriaCalendarGridHeader,\n CalendarGridProps as AriaCalendarGridProps,\n CalendarHeaderCell as AriaCalendarHeaderCell,\n CalendarHeaderCellProps as AriaCalendarHeaderCellProps,\n CalendarProps as AriaCalendarProps,\n DateValue as AriaDateValue,\n Heading as AriaHeading,\n RangeCalendar as AriaRangeCalendar,\n RangeCalendarProps as AriaRangeCalendarProps,\n RangeCalendarStateContext as AriaRangeCalendarStateContext,\n composeRenderProps,\n useLocale\n} from 'react-aria-components';\n\nimport { Button, buttonVariants } from 'lib/components/button';\nimport { FieldError } from 'lib/components/field';\nimport { classNames } from 'lib/utils/primitives';\nimport { ChevronLeft, ChevronRight } from 'lucide-react';\nimport { use } from 'react';\n\nexport function CalendarHeading(props: React.HTMLAttributes<HTMLElement>) {\n let { direction } = useLocale();\n\n return (\n <header className=\"flex w-full items-center gap-1 px-1 pb-4\" {...props}>\n <Button\n slot=\"previous\"\n size=\"none\"\n className={classNames(\n 'size-7 bg-transparent p-0 opacity-50',\n /* Hover */\n 'data-[hovered]:opacity-100'\n )}\n >\n {direction === 'rtl' ? <ChevronRight aria-hidden /> : <ChevronLeft aria-hidden />}\n </Button>\n <AriaHeading className=\"grow text-center body font-medium\" />\n <Button\n slot=\"next\"\n className={classNames(\n 'size-7 bg-transparent p-0 opacity-50',\n /* Hover */\n 'data-[hovered]:opacity-100'\n )}\n >\n {direction === 'rtl' ? <ChevronLeft aria-hidden /> : <ChevronRight aria-hidden />}\n </Button>\n </header>\n );\n}\n\nexport function CalendarGrid({ className, ...props }: AriaCalendarGridProps) {\n return (\n <AriaCalendarGrid\n className={classNames(' border-separate border-spacing-x-0 border-spacing-y-1 ', className)}\n {...props}\n />\n );\n}\n\nexport const CalendarGridHeader = AriaCalendarGridHeader;\n\nexport function CalendarHeaderCell({ className, ...props }: AriaCalendarHeaderCellProps) {\n return (\n <AriaCalendarHeaderCell\n className={classNames('w-9 body-sm font-normal text-muted-foreground', className)}\n {...props}\n />\n );\n}\n\nexport function CalendarGridBody({ className, ...props }: AriaCalendarGridBodyProps) {\n return <AriaCalendarGridBody className={classNames('[&>tr>td]:p-0', className)} {...props} />;\n}\n\nexport function CalendarCell({ className, ...props }: AriaCalendarCellProps) {\n const isRange = Boolean(use(AriaRangeCalendarStateContext));\n return (\n <AriaCalendarCell\n className={composeRenderProps(className, (className, renderProps) =>\n classNames(\n buttonVariants({ variant: 'ghost', size: 'none' }),\n 'relative flex size-9 items-center justify-center p-0 body-sm font-normal',\n /* Disabled */\n renderProps.isDisabled && 'text-muted-foreground opacity-50',\n /* Selected */\n renderProps.isSelected &&\n 'bg-primary text-primary-foreground data-[focused]:bg-primary data-[focused]:text-primary-foreground',\n /* Hover */\n renderProps.isHovered &&\n renderProps.isSelected &&\n (renderProps.isSelectionStart || renderProps.isSelectionEnd || !isRange) &&\n 'data-[hovered]:bg-primary data-[hovered]:text-primary-foreground',\n /* Selection Start/End */\n renderProps.isSelected &&\n isRange &&\n !renderProps.isSelectionStart &&\n !renderProps.isSelectionEnd &&\n 'rounded-none bg-accent text-accent-foreground',\n /* Outside Month */\n renderProps.isOutsideMonth &&\n 'text-muted-foreground opacity-50 data-[selected]:bg-accent/50 data-[selected]:text-muted-foreground data-[selected]:opacity-30',\n /* Current Date */\n renderProps.date.compare(today(getLocalTimeZone())) === 0 &&\n !renderProps.isSelected &&\n 'bg-accent text-accent-foreground',\n /* Unavailable Date */\n renderProps.isUnavailable && 'cursor-default text-destructive ',\n renderProps.isInvalid &&\n 'bg-destructive text-destructive-foreground data-[focused]:bg-destructive data-[hovered]:bg-destructive data-[focused]:text-destructive-foreground data-[hovered]:text-destructive-foreground',\n className\n )\n )}\n {...props}\n />\n );\n}\n\ninterface CalendarProps<T extends AriaDateValue> extends AriaCalendarProps<T> {\n errorMessage?: string;\n}\n\nexport function Calendar<T extends AriaDateValue>({ errorMessage, className, ...props }: CalendarProps<T>) {\n return (\n <AriaCalendar className={composeRenderProps(className, className => classNames('w-fit', className))} {...props}>\n <CalendarHeading />\n <CalendarGrid>\n <CalendarGridHeader>{day => <CalendarHeaderCell>{day}</CalendarHeaderCell>}</CalendarGridHeader>\n <CalendarGridBody>{date => <CalendarCell date={date} />}</CalendarGridBody>\n </CalendarGrid>\n {errorMessage && (<FieldError>{errorMessage}</FieldError>)}\n </AriaCalendar>\n );\n}\n\ninterface RangeCalendarProps<T extends AriaDateValue> extends AriaRangeCalendarProps<T> {\n errorMessage?: string;\n}\n\nexport function RangeCalendar<T extends AriaDateValue>({ errorMessage, className, ...props }: RangeCalendarProps<T>) {\n return (\n <AriaRangeCalendar\n className={composeRenderProps(className, className => classNames('w-fit', className))}\n {...props}\n >\n <CalendarHeading />\n <CalendarGrid>\n <CalendarGridHeader>{day => <CalendarHeaderCell>{day}</CalendarHeaderCell>}</CalendarGridHeader>\n <CalendarGridBody>{date => <CalendarCell date={date} />}</CalendarGridBody>\n </CalendarGrid>\n {errorMessage && (<FieldError slot=\"errorMessage\">{errorMessage}</FieldError>)}\n </AriaRangeCalendar>\n );\n}\n"],"names":["CalendarHeading","props","direction","useLocale","jsxs","jsx","Button","classNames","ChevronRight","ChevronLeft","AriaHeading","CalendarGrid","className","AriaCalendarGrid","CalendarGridHeader","AriaCalendarGridHeader","CalendarHeaderCell","AriaCalendarHeaderCell","CalendarGridBody","AriaCalendarGridBody","CalendarCell","isRange","use","AriaRangeCalendarStateContext","AriaCalendarCell","composeRenderProps","renderProps","buttonVariants","today","getLocalTimeZone","Calendar","errorMessage","AriaCalendar","day","date","FieldError","RangeCalendar","AriaRangeCalendar"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"calendar.js","sources":["../../lib/components/calendar.tsx"],"sourcesContent":["import { getLocalTimeZone, today } from '@internationalized/date';\nimport {\n Calendar as AriaCalendar,\n CalendarCell as AriaCalendarCell,\n CalendarCellProps as AriaCalendarCellProps,\n CalendarGrid as AriaCalendarGrid,\n CalendarGridBody as AriaCalendarGridBody,\n CalendarGridBodyProps as AriaCalendarGridBodyProps,\n CalendarGridHeader as AriaCalendarGridHeader,\n CalendarGridProps as AriaCalendarGridProps,\n CalendarHeaderCell as AriaCalendarHeaderCell,\n CalendarHeaderCellProps as AriaCalendarHeaderCellProps,\n CalendarProps as AriaCalendarProps,\n DateValue as AriaDateValue,\n Heading as AriaHeading,\n RangeCalendar as AriaRangeCalendar,\n RangeCalendarProps as AriaRangeCalendarProps,\n RangeCalendarStateContext as AriaRangeCalendarStateContext,\n composeRenderProps,\n useLocale,\n} from 'react-aria-components';\n\nimport { ChevronLeft, ChevronRight } from 'lucide-react';\nimport { use } from 'react';\nimport { Button, buttonVariants } from '../components/button';\nimport { FieldError } from '../components/field';\nimport { classNames } from '../utils/primitives';\n\nexport function CalendarHeading(props: React.HTMLAttributes<HTMLElement>) {\n let { direction } = useLocale();\n\n return (\n <header className=\"flex w-full items-center gap-1 px-1 pb-icon\" {...props}>\n <Button\n slot=\"previous\"\n size=\"none\"\n className={classNames(\n 'size-7 bg-transparent p-0 opacity-50',\n /* Hover */\n 'data-[hovered]:opacity-100'\n )}\n >\n {direction === 'rtl' ? <ChevronRight aria-hidden /> : <ChevronLeft aria-hidden />}\n </Button>\n <AriaHeading className=\"grow text-center body font-medium\" />\n <Button\n slot=\"next\"\n className={classNames(\n 'size-7 bg-transparent p-0 opacity-50',\n /* Hover */\n 'data-[hovered]:opacity-100'\n )}\n >\n {direction === 'rtl' ? <ChevronLeft aria-hidden /> : <ChevronRight aria-hidden />}\n </Button>\n </header>\n );\n}\n\nexport function CalendarGrid({ className, ...props }: AriaCalendarGridProps) {\n return (\n <AriaCalendarGrid\n className={classNames(' border-separate border-spacing-x-0 border-spacing-y-1 ', className)}\n {...props}\n />\n );\n}\n\nexport const CalendarGridHeader = AriaCalendarGridHeader;\n\nexport function CalendarHeaderCell({ className, ...props }: AriaCalendarHeaderCellProps) {\n return (\n <AriaCalendarHeaderCell\n className={classNames('w-9 body-sm font-normal text-muted-foreground', className)}\n {...props}\n />\n );\n}\n\nexport function CalendarGridBody({ className, ...props }: AriaCalendarGridBodyProps) {\n return <AriaCalendarGridBody className={classNames('[&>tr>td]:p-0', className)} {...props} />;\n}\n\nexport function CalendarCell({ className, ...props }: AriaCalendarCellProps) {\n const isRange = Boolean(use(AriaRangeCalendarStateContext));\n return (\n <AriaCalendarCell\n className={composeRenderProps(className, (className, renderProps) =>\n classNames(\n buttonVariants({ variant: 'ghost', size: 'none' }),\n 'relative flex size-9 items-center justify-center p-0 body-sm font-normal',\n /* Disabled */\n renderProps.isDisabled && 'text-muted-foreground opacity-50',\n /* Selected */\n renderProps.isSelected &&\n 'bg-primary text-primary-foreground data-[focused]:bg-primary data-[focused]:text-primary-foreground',\n /* Hover */\n renderProps.isHovered &&\n renderProps.isSelected &&\n (renderProps.isSelectionStart || renderProps.isSelectionEnd || !isRange) &&\n 'data-[hovered]:bg-primary data-[hovered]:text-primary-foreground',\n /* Selection Start/End */\n renderProps.isSelected &&\n isRange &&\n !renderProps.isSelectionStart &&\n !renderProps.isSelectionEnd &&\n 'rounded-none bg-accent text-accent-foreground',\n /* Outside Month */\n renderProps.isOutsideMonth &&\n 'text-muted-foreground opacity-50 data-[selected]:bg-accent/50 data-[selected]:text-muted-foreground data-[selected]:opacity-30',\n /* Current Date */\n renderProps.date.compare(today(getLocalTimeZone())) === 0 &&\n !renderProps.isSelected &&\n 'bg-accent text-accent-foreground',\n /* Unavailable Date */\n renderProps.isUnavailable && 'cursor-default text-destructive ',\n renderProps.isInvalid &&\n 'bg-destructive text-destructive-foreground data-[focused]:bg-destructive data-[hovered]:bg-destructive data-[focused]:text-destructive-foreground data-[hovered]:text-destructive-foreground',\n className\n )\n )}\n {...props}\n />\n );\n}\n\ninterface CalendarProps<T extends AriaDateValue> extends AriaCalendarProps<T> {\n errorMessage?: string;\n}\n\nexport function Calendar<T extends AriaDateValue>({ errorMessage, className, ...props }: CalendarProps<T>) {\n return (\n <AriaCalendar className={composeRenderProps(className, className => classNames('w-fit', className))} {...props}>\n <CalendarHeading />\n <CalendarGrid>\n <CalendarGridHeader>{day => <CalendarHeaderCell>{day}</CalendarHeaderCell>}</CalendarGridHeader>\n <CalendarGridBody>{date => <CalendarCell date={date} />}</CalendarGridBody>\n </CalendarGrid>\n {errorMessage && <FieldError>{errorMessage}</FieldError>}\n </AriaCalendar>\n );\n}\n\ninterface RangeCalendarProps<T extends AriaDateValue> extends AriaRangeCalendarProps<T> {\n errorMessage?: string;\n}\n\nexport function RangeCalendar<T extends AriaDateValue>({ errorMessage, className, ...props }: RangeCalendarProps<T>) {\n return (\n <AriaRangeCalendar\n className={composeRenderProps(className, className => classNames('w-fit', className))}\n {...props}\n >\n <CalendarHeading />\n <CalendarGrid>\n <CalendarGridHeader>{day => <CalendarHeaderCell>{day}</CalendarHeaderCell>}</CalendarGridHeader>\n <CalendarGridBody>{date => <CalendarCell date={date} />}</CalendarGridBody>\n </CalendarGrid>\n {errorMessage && <FieldError slot=\"errorMessage\">{errorMessage}</FieldError>}\n </AriaRangeCalendar>\n );\n}\n"],"names":["CalendarHeading","props","direction","useLocale","jsxs","jsx","Button","classNames","ChevronRight","ChevronLeft","AriaHeading","CalendarGrid","className","AriaCalendarGrid","CalendarGridHeader","AriaCalendarGridHeader","CalendarHeaderCell","AriaCalendarHeaderCell","CalendarGridBody","AriaCalendarGridBody","CalendarCell","isRange","use","AriaRangeCalendarStateContext","AriaCalendarCell","composeRenderProps","renderProps","buttonVariants","today","getLocalTimeZone","Calendar","errorMessage","AriaCalendar","day","date","FieldError","RangeCalendar","AriaRangeCalendar"],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card.js","sources":["../../lib/components/card.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"card.js","sources":["../../lib/components/card.tsx"],"sourcesContent":["import type * as React from 'react';\nimport { classNames } from '../utils/primitives';\n\nexport function Card({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n className={classNames('flex flex-col p-icon border border-border bg-card text-card-foreground', className)}\n {...props}\n />\n );\n}\n\nexport function CardHeader({ className, ...props }: React.ComponentProps<'div'>) {\n return <div className={classNames('flex flex-col gap-y-1 pb-icon shrink-0', className)} {...props} />;\n}\n\nexport function CardTitle({ className, ...props }: React.ComponentProps<'h3'>) {\n return <h3 className={classNames('heading-3 leading-none', className)} {...props} />;\n}\n\nexport function CardDescription({ className, ...props }: React.ComponentProps<'p'>) {\n return <p className={classNames('body-sm text-muted', className)} {...props} />;\n}\n\nexport function CardContent({ className, ...props }: React.ComponentProps<'div'>) {\n return <div className={classNames('grow body', className)} {...props} />;\n}\n\nexport function CardFooter({ className, ...props }: React.ComponentProps<'div'>) {\n return <div className={classNames('flex items-center w-full pt-icon gap-2 justify-end', className)} {...props} />;\n}\n"],"names":["Card","className","props","jsx","classNames","CardHeader","CardTitle","CardDescription","CardContent","CardFooter"],"mappings":"yGAGO,SAASA,EAAK,CAAE,UAAAC,EAAW,GAAGC,GAAsC,CACvE,OACIC,EAAC,MAAA,CACG,UAAWC,EAAW,yEAA0EH,CAAS,EACxG,GAAGC,CAAA,CAAA,CAGhB,CAEO,SAASG,EAAW,CAAE,UAAAJ,EAAW,GAAGC,GAAsC,CAC7E,OAAOC,EAAC,OAAI,UAAWC,EAAW,yCAA0CH,CAAS,EAAI,GAAGC,EAAO,CACvG,CAEO,SAASI,EAAU,CAAE,UAAAL,EAAW,GAAGC,GAAqC,CAC3E,OAAOC,EAAC,MAAG,UAAWC,EAAW,yBAA0BH,CAAS,EAAI,GAAGC,EAAO,CACtF,CAEO,SAASK,EAAgB,CAAE,UAAAN,EAAW,GAAGC,GAAoC,CAChF,OAAOC,EAAC,KAAE,UAAWC,EAAW,qBAAsBH,CAAS,EAAI,GAAGC,EAAO,CACjF,CAEO,SAASM,EAAY,CAAE,UAAAP,EAAW,GAAGC,GAAsC,CAC9E,OAAOC,EAAC,OAAI,UAAWC,EAAW,YAAaH,CAAS,EAAI,GAAGC,EAAO,CAC1E,CAEO,SAASO,EAAW,CAAE,UAAAR,EAAW,GAAGC,GAAsC,CAC7E,OAAOC,EAAC,OAAI,UAAWC,EAAW,qDAAsDH,CAAS,EAAI,GAAGC,EAAO,CACnH"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CheckboxProps as AriaCheckboxProps } from 'react-aria-components';
|
|
2
|
-
import { FormFieldProps } from '
|
|
2
|
+
import { FormFieldProps } from '../components/field';
|
|
3
3
|
export declare const CheckboxGroup: (props: import('react-aria-components').CheckboxGroupProps & React.RefAttributes<HTMLDivElement>) => React.ReactElement | null;
|
|
4
4
|
type CheckboxProps = AriaCheckboxProps & FormFieldProps;
|
|
5
5
|
export declare function Checkbox({ className, label, description, errorMessage, ...props }: Omit<CheckboxProps, 'children'>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as e,Fragment as a}from"react/jsx-runtime";import{Checkbox as u,composeRenderProps as c,CheckboxGroup as m}from"react-aria-components";import{
|
|
1
|
+
import{jsx as e,Fragment as a}from"react/jsx-runtime";import{Checkbox as u,composeRenderProps as c,CheckboxGroup as m}from"react-aria-components";import{Minus as b,Check as p}from"lucide-react";import{FormField as h,labelVariants as x}from"./field.js";import{useTfFieldContext as g}from"../utils/form-utils.js";import{classNames as d}from"../utils/primitives.js";import"class-variance-authority";import"react";import"../utils/form-context.js";import"@tanstack/react-form";import"clsx";const B=m;function f({className:r,label:o,description:s,errorMessage:n,...l}){return e("div",{className:"group form-field",children:e(h,{label:o,description:s,errorMessage:n,children:e(u,{className:c(r,t=>d("group/checkbox cursor-pointer focus-ring flex items-center gap-x-2","disabled-muted",x,t)),...l,children:c(e(a,{}),(t,i)=>e(a,{children:e("div",{className:d("flex size-input shrink-0 items-center bg-popover justify-center border border-input text-current ring-offset-background","group-data-[indeterminate]/checkbox:bg-primary group-data-[selected]/checkbox:bg-primary group-data-[indeterminate]/checkbox:text-primary-foreground group-data-[selected]/checkbox:text-primary-foreground","group-data-[disabled]/checkbox:cursor-not-allowed group-data-[disabled]/checkbox:opacity-50","group-data-[invalid]/checkbox:border-destructive group-data-[invalid]/checkbox:group-data-[selected]/checkbox:bg-destructive group-data-[invalid]/checkbox:group-data-[selected]/checkbox:text-destructive-foreground","focus:outline-none focus-visible:outline-none"),children:i.isIndeterminate?e(b,{className:"size-icon"}):i.isSelected?e(p,{className:"size-icon"}):null})}))})})})}function T({...r}){const o=g({disabled:r.isDisabled});return e(f,{isSelected:o.state.value,isDisabled:o.form.state.isSubmitting||r.isDisabled,onChange:()=>o.handleChange(!o.state.value),onBlur:o.handleBlur,...r})}export{f as Checkbox,B as CheckboxGroup,T as TfCheckbox};
|
|
2
2
|
//# sourceMappingURL=checkbox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.js","sources":["../../lib/components/checkbox.tsx"],"sourcesContent":["import {\n Checkbox as AriaCheckbox,\n CheckboxGroup as AriaCheckboxGroup,\n composeRenderProps,\n type CheckboxProps as AriaCheckboxProps,\n} from 'react-aria-components';\n\nimport { FormField, labelVariants, type FormFieldProps } from '
|
|
1
|
+
{"version":3,"file":"checkbox.js","sources":["../../lib/components/checkbox.tsx"],"sourcesContent":["import {\n Checkbox as AriaCheckbox,\n CheckboxGroup as AriaCheckboxGroup,\n composeRenderProps,\n type CheckboxProps as AriaCheckboxProps,\n} from 'react-aria-components';\n\nimport { Check, Minus } from 'lucide-react';\nimport { FormField, labelVariants, type FormFieldProps } from '../components/field';\nimport { useTfFieldContext } from '../utils/form-utils';\nimport { classNames } from '../utils/primitives';\n\nexport const CheckboxGroup = AriaCheckboxGroup;\ntype CheckboxProps = AriaCheckboxProps & FormFieldProps;\nexport function Checkbox({ className, label, description, errorMessage, ...props }: Omit<CheckboxProps, 'children'>) {\n return (\n <div className=\"group form-field\">\n <FormField label={label} description={description} errorMessage={errorMessage}>\n <AriaCheckbox\n className={composeRenderProps(className, className =>\n classNames(\n 'group/checkbox cursor-pointer focus-ring flex items-center gap-x-2',\n /* Disabled */\n 'disabled-muted',\n labelVariants,\n className\n )\n )}\n {...props}\n >\n {composeRenderProps(<></>, (_, renderProps) => (\n <>\n <div\n className={classNames(\n 'flex size-input shrink-0 items-center bg-popover justify-center border border-input text-current ring-offset-background',\n /* Selected */\n 'group-data-[indeterminate]/checkbox:bg-primary group-data-[selected]/checkbox:bg-primary group-data-[indeterminate]/checkbox:text-primary-foreground group-data-[selected]/checkbox:text-primary-foreground',\n /* Disabled */\n 'group-data-[disabled]/checkbox:cursor-not-allowed group-data-[disabled]/checkbox:opacity-50',\n /* Invalid */\n 'group-data-[invalid]/checkbox:border-destructive group-data-[invalid]/checkbox:group-data-[selected]/checkbox:bg-destructive group-data-[invalid]/checkbox:group-data-[selected]/checkbox:text-destructive-foreground',\n /* Resets */\n 'focus:outline-none focus-visible:outline-none'\n )}\n >\n {renderProps.isIndeterminate ? (\n <Minus className=\"size-icon\" />\n ) : renderProps.isSelected ? (\n <Check className=\"size-icon\" />\n ) : null}\n </div>\n </>\n ))}\n </AriaCheckbox>\n </FormField>\n </div>\n );\n}\n\nexport type TfCheckboxProps = Omit<React.ComponentProps<typeof Checkbox>, 'onChange' | 'onBlur' | 'isChecked'>;\nexport function TfCheckbox({ ...props }: TfCheckboxProps) {\n const field = useTfFieldContext<boolean>({ disabled: props.isDisabled });\n return (\n <Checkbox\n isSelected={field.state.value}\n isDisabled={field.form.state.isSubmitting || props.isDisabled}\n onChange={() => field.handleChange(!field.state.value)}\n onBlur={field.handleBlur}\n {...props}\n />\n );\n}\n"],"names":["CheckboxGroup","AriaCheckboxGroup","Checkbox","className","label","description","errorMessage","props","jsx","FormField","AriaCheckbox","composeRenderProps","classNames","labelVariants","Fragment","_","renderProps","Minus","Check","TfCheckbox","field","useTfFieldContext"],"mappings":"qeAYO,MAAMA,EAAgBC,EAEtB,SAASC,EAAS,CAAE,UAAAC,EAAW,MAAAC,EAAO,YAAAC,EAAa,aAAAC,EAAc,GAAGC,GAA0C,CACjH,OACIC,EAAC,OAAI,UAAU,mBACX,WAACC,EAAA,CAAU,MAAAL,EAAc,YAAAC,EAA0B,aAAAC,EAC/C,SAAAE,EAACE,EAAA,CACG,UAAWC,EAAmBR,EAAWA,GACrCS,EACI,qEAEA,iBACAC,EACAV,CAAA,CACJ,EAEH,GAAGI,EAEH,WAAmBC,EAAAM,EAAA,CAAA,CAAE,EAAK,CAACC,EAAGC,IAC3BR,EAAAM,EAAA,CACI,SAAAN,EAAC,MAAA,CACG,UAAWI,EACP,0HAEA,+MAEA,8FAEA,wNAEA,+CAAA,EAGH,SAAAI,EAAY,gBACTR,EAACS,EAAA,CAAM,UAAU,WAAA,CAAY,EAC7BD,EAAY,WACZR,EAACU,EAAA,CAAM,UAAU,YAAY,EAC7B,IAAA,CAAA,EAEZ,CACH,CAAA,CAAA,EAET,CAAA,CACJ,CAER,CAGO,SAASC,EAAW,CAAE,GAAGZ,GAA0B,CACtD,MAAMa,EAAQC,EAA2B,CAAE,SAAUd,EAAM,WAAY,EACvE,OACIC,EAACN,EAAA,CACG,WAAYkB,EAAM,MAAM,MACxB,WAAYA,EAAM,KAAK,MAAM,cAAgBb,EAAM,WACnD,SAAU,IAAMa,EAAM,aAAa,CAACA,EAAM,MAAM,KAAK,EACrD,OAAQA,EAAM,WACb,GAAGb,CAAA,CAAA,CAGhB"}
|
|
@@ -20,13 +20,13 @@ export declare const ALL_OS: {
|
|
|
20
20
|
export type VisibilityState<T> = {
|
|
21
21
|
[K in keyof T]?: boolean;
|
|
22
22
|
};
|
|
23
|
-
export type
|
|
23
|
+
export type TableAction = {
|
|
24
24
|
onClick: (e: PressEvent, t: Table<any>) => void;
|
|
25
25
|
bulk: boolean;
|
|
26
26
|
icon: LucideIcon;
|
|
27
27
|
tooltip?: string;
|
|
28
|
-
}
|
|
29
|
-
export type TableFetchFn<TData
|
|
28
|
+
};
|
|
29
|
+
export type TableFetchFn<TData> = (p: PaginationState, s: SortingState, q: string, f: Record<string, any>) => Promise<{
|
|
30
30
|
total: number;
|
|
31
31
|
data: TData[] | undefined;
|
|
32
32
|
}>;
|
|
@@ -52,5 +52,5 @@ export type ApiGetAllParameters = {
|
|
|
52
52
|
};
|
|
53
53
|
export type ApiFilter<T extends keyof operations> = Omit<ApiQuery<T>, 'page' | 'limit' | 'sort' | 'search'>;
|
|
54
54
|
export type ApiFilters<T extends keyof operations> = NonNullable<Omit<ApiQuery<T>, 'page' | 'limit' | 'sort' | 'search'>>;
|
|
55
|
-
export declare function createTableFetchFn<Return
|
|
55
|
+
export declare function createTableFetchFn<Return>(ctxclient: Client, path: GetPaths): TableFetchFn<Return>;
|
|
56
56
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as d}from"react/jsx-runtime";import{createColumnHelper as p}from"@tanstack/react-table";import{intervalToDuration as m}from"date-fns";import{Checkbox as i}from"./checkbox.js";import"react-aria-components";import"./field.js";import"class-variance-authority";import"../utils/primitives.js";import"clsx";import"
|
|
1
|
+
import{jsx as d}from"react/jsx-runtime";import{createColumnHelper as p}from"@tanstack/react-table";import{intervalToDuration as m}from"date-fns";import{Checkbox as i}from"./checkbox.js";import"react-aria-components";import"lucide-react";import"./field.js";import"class-variance-authority";import"../utils/primitives.js";import"clsx";import"../utils/form-utils.js";import"react";import"../utils/form-context.js";import"@tanstack/react-form";const n=p(),R=[n.accessor("checkbox",{header:({table:e})=>d(i,{isIndeterminate:e.getIsSomeRowsSelected()&&!e.getIsAllPageRowsSelected(),isSelected:e.getIsAllPageRowsSelected()||e.getIsSomePageRowsSelected(),onChange:()=>e.toggleAllPageRowsSelected(),"aria-label":"Select all"}),cell:({row:e})=>d(i,{isSelected:e.getIsSelected(),onChange:()=>e.toggleSelected(),"aria-label":"Select row"}),enableSorting:!1,enableHiding:!1})],O=[n.accessor("id",{header:()=>"ID"})],b=[n.accessor("createdAt",{header:()=>"Creation Date",cell:({row:e})=>{const t=e.getValue("createdAt");return c(t)},enableHiding:!1}),n.accessor("updatedAt",{header:()=>"Last Updated",cell:({row:e})=>{const t=e.getValue("updatedAt");return c(t)},enableHiding:!1})];function c(e){if(!e)return null;const t=new Date(e);return new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(t)}function H(e){const t=e.expiresAt&&new Date(e.expiresAt)<new Date;switch(!0){case(e.revoked&&e.suspended&&t):return"Revoked, Suspended, Expired";case(e.revoked&&e.suspended):return"Revoked, Suspended";case(e.revoked&&t):return"Revoked, Expired";case(e.suspended&&t):return"Suspended, Expired";case e.suspended:return"Suspended";case e.revoked:return"Revoked";case t:return"Expired";default:return"Active"}}function P(e){return e===0||!e?"Lifetime":g(e)}function g(e){const t=m({start:0,end:e*1e3});return[t.years&&`${t.years}y`,t.months&&`${t.months}m`,t.days&&`${t.days}d`,t.hours&&`${t.hours}h`].filter(Boolean).join(" ").trim()}function $(e,t){const r=t.toString().split(".");let o=e;for(const a of r)o=o?.[a];return o}const B={windows:"Windows",macos:"macOS",linux:"Linux",ios:"iOS",android:"Android"};function F(e,t){return async(r,o,a,u)=>{const l={...u,page:r.pageIndex+1,limit:r.pageSize,sort:S(o[0]),search:a};return e.GET(t,{params:{query:l}}).then(s=>({total:Number.parseInt(s.response.headers.get("Pagination-Count")||"0"),data:s.data}))}}function S(e){return e?e.desc?`-${e.id}`:`+${e.id}`:"-createdAt"}export{B as ALL_OS,R as TABLE_CHECK_BOX_COLUMN,b as TABLE_DEFAULT_DATE_COLUMNS,O as TABLE_ID_COLUMN,F as createTableFetchFn,c as formatDate,H as getLicenseStatus,P as getValidityDisplay,$ as getValueFromData,g as secondsToDuration};
|
|
2
2
|
//# sourceMappingURL=data-table-commons.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table-commons.js","sources":["../../lib/components/data-table-commons.tsx"],"sourcesContent":["import type { components, operations, paths } from '@cryptlex/web-api-types';\nimport type { PaginationState, SortingState, Table } from '@tanstack/react-table';\nimport { createColumnHelper } from '@tanstack/react-table';\nimport { intervalToDuration } from 'date-fns';\nimport
|
|
1
|
+
{"version":3,"file":"data-table-commons.js","sources":["../../lib/components/data-table-commons.tsx"],"sourcesContent":["import type { components, operations, paths } from '@cryptlex/web-api-types';\nimport type { PaginationState, SortingState, Table } from '@tanstack/react-table';\nimport { createColumnHelper } from '@tanstack/react-table';\nimport { intervalToDuration } from 'date-fns';\nimport type { LucideIcon } from 'lucide-react';\nimport type createClient from 'openapi-fetch';\nimport type { PressEvent } from 'react-aria-components';\nimport { Checkbox } from '../components/checkbox';\n\nconst cH = createColumnHelper<any>();\nexport const TABLE_CHECK_BOX_COLUMN = [\n cH.accessor('checkbox', {\n header: ({ table }) => (\n <Checkbox\n isIndeterminate={table.getIsSomeRowsSelected() && !table.getIsAllPageRowsSelected()}\n isSelected={table.getIsAllPageRowsSelected() || table.getIsSomePageRowsSelected()}\n onChange={() => table.toggleAllPageRowsSelected()}\n aria-label=\"Select all\"\n />\n ),\n\n cell: ({ row }) => (\n <Checkbox isSelected={row.getIsSelected()} onChange={() => row.toggleSelected()} aria-label=\"Select row\" />\n ),\n enableSorting: false,\n enableHiding: false,\n }),\n];\n\nexport const TABLE_ID_COLUMN = [\n cH.accessor('id', {\n header: () => 'ID',\n }),\n];\nexport const TABLE_DEFAULT_DATE_COLUMNS = [\n cH.accessor('createdAt', {\n header: () => 'Creation Date',\n cell: ({ row }) => {\n const date = row.getValue('createdAt') satisfies string | null | undefined;\n return formatDate(date);\n },\n enableHiding: false,\n }),\n cH.accessor('updatedAt', {\n header: () => 'Last Updated',\n cell: ({ row }) => {\n const date = row.getValue('updatedAt') satisfies string | null | undefined;\n return formatDate(date);\n },\n enableHiding: false,\n }),\n];\n\n// TODO, i18n using react-aria\nexport function formatDate(date: string | null | undefined) {\n if (!date) return null;\n const _date = new Date(date);\n return new Intl.DateTimeFormat(undefined, {\n dateStyle: 'medium',\n timeStyle: 'short',\n }).format(_date);\n}\n/**\n * Format multiple license parameters (expired, suspended, revoked) into a single status\n */\nexport function getLicenseStatus(license: any): string {\n const licenseExpired = license.expiresAt && new Date(license.expiresAt) < new Date();\n // Status Column\n switch (true) {\n case license.revoked && license.suspended && licenseExpired:\n return 'Revoked, Suspended, Expired';\n case license.revoked && license.suspended:\n return 'Revoked, Suspended';\n case license.revoked && licenseExpired:\n return 'Revoked, Expired';\n case license.suspended && licenseExpired:\n return 'Suspended, Expired';\n case license.suspended:\n return 'Suspended';\n case license.revoked:\n return 'Revoked';\n case licenseExpired:\n return 'Expired';\n default:\n return 'Active';\n }\n}\n\nexport function getValidityDisplay(validity: number | undefined) {\n if (validity === 0 || !validity) {\n return 'Lifetime';\n } else {\n return secondsToDuration(validity);\n }\n}\nexport function secondsToDuration(seconds: number): string {\n //@ts-ignore\n const duration = intervalToDuration({\n start: 0,\n end: seconds * 1000,\n });\n\n const parts = [\n duration.years && `${duration.years}y`,\n duration.months && `${duration.months}m`,\n duration.days && `${duration.days}d`,\n duration.hours && `${duration.hours}h`,\n ];\n\n // Filter out undefined values and join\n return parts.filter(Boolean).join(' ').trim();\n}\n\nexport function getValueFromData(data: any, accessor: string | number | symbol) {\n const accessors = accessor.toString().split('.');\n let value = data;\n for (const acc of accessors) {\n value = value?.[acc];\n }\n return value;\n}\nexport const ALL_OS: { [key: string]: string } = {\n windows: 'Windows',\n macos: 'macOS',\n linux: 'Linux',\n ios: 'iOS',\n android: 'Android',\n};\n\nexport type VisibilityState<T> = {\n [K in keyof T]?: boolean;\n};\n\nexport type TableAction = {\n onClick: (e: PressEvent, t: Table<any>) => void;\n bulk: boolean;\n icon: LucideIcon;\n tooltip?: string;\n};\n\nexport type TableFetchFn<TData> = (\n p: PaginationState,\n s: SortingState,\n q: string,\n f: Record<string, any>\n) => Promise<{\n total: number;\n data: TData[] | undefined;\n}>;\n/*** Type for hide some of the columns based on the dto of the particular page\n ** `id`, `updatedAt` are by default hidden\n */\nexport type DefaultVisibilityState<T> = {\n [K in keyof T]?: boolean;\n};\n\ntype Client = ReturnType<typeof createClient<paths>>;\n\n// Helper type to extract valid GET paths\ntype GetPaths = {\n [P in keyof paths]: paths[P] extends { get: any } ? P : never;\n}[keyof paths];\n\nexport type ApiSchema<T extends keyof components['schemas']> = components['schemas'][T];\nexport type ApiQuery<T extends keyof operations> = NonNullable<operations[T]['parameters']['query']>;\nexport type ApiGetAllParameters = {\n page: number;\n limit: number;\n search?: string;\n sort?: string;\n};\n\nexport type ApiFilter<T extends keyof operations> = Omit<ApiQuery<T>, 'page' | 'limit' | 'sort' | 'search'>;\nexport type ApiFilters<T extends keyof operations> = NonNullable<\n Omit<ApiQuery<T>, 'page' | 'limit' | 'sort' | 'search'>\n>;\n\nexport function createTableFetchFn<Return>(ctxclient: Client, path: GetPaths): TableFetchFn<Return> {\n return async (pagination, sorting, searching, filters) => {\n const query = {\n ...filters,\n page: pagination.pageIndex + 1,\n limit: pagination.pageSize,\n sort: generateSortParam(sorting[0]),\n search: searching,\n };\n\n return ctxclient.GET(path, { params: { query } }).then(value => {\n const rowCount = Number.parseInt(value.response.headers.get('Pagination-Count') || '0');\n return { total: rowCount, data: value.data };\n });\n };\n}\n\nfunction generateSortParam(sort: { id: string; desc: boolean } | undefined): string {\n if (sort) {\n if (sort.desc) {\n return `-${sort.id}`;\n } else {\n return `+${sort.id}`;\n }\n } else {\n return '-createdAt';\n }\n}\n"],"names":["cH","createColumnHelper","TABLE_CHECK_BOX_COLUMN","table","jsx","Checkbox","row","TABLE_ID_COLUMN","TABLE_DEFAULT_DATE_COLUMNS","date","formatDate","_date","getLicenseStatus","license","licenseExpired","getValidityDisplay","validity","secondsToDuration","seconds","duration","intervalToDuration","getValueFromData","data","accessor","accessors","value","acc","ALL_OS","createTableFetchFn","ctxclient","path","pagination","sorting","searching","filters","query","generateSortParam","sort"],"mappings":"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"}
|
|
@@ -1,9 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { operations } from '@cryptlex/web-api-types';
|
|
2
|
+
import { CalendarDateTime } from '@internationalized/date';
|
|
3
|
+
import { ApiFilters } from '../components/data-table-commons';
|
|
4
|
+
import { MultiSelectProps } from '../components/multi-select';
|
|
4
5
|
export declare const FILTER_COMPARISON_OPERATORS: readonly ["eq", "ne", "cn", "nc", "sw", "ew", "in", "nin", "gt", "gte", "lt", "lte"];
|
|
5
6
|
export type FilterComparisonOperator = (typeof FILTER_COMPARISON_OPERATORS)[number];
|
|
6
7
|
export declare const COMPARISON_OPERATOR_LABELS: Record<FilterComparisonOperator, string>;
|
|
8
|
+
type BaseLocalFilter<T extends FilterType, V> = {
|
|
9
|
+
id: string;
|
|
10
|
+
type: T;
|
|
11
|
+
property: string;
|
|
12
|
+
operator: FilterComparisonOperator;
|
|
13
|
+
value: V | undefined;
|
|
14
|
+
displayValue?: string;
|
|
15
|
+
};
|
|
16
|
+
type EnumLocalFilter = BaseLocalFilter<'enum', Set<string | number>>;
|
|
17
|
+
type IdLocalFilter = BaseLocalFilter<'id', string>;
|
|
18
|
+
type BoolLocalFilter = BaseLocalFilter<'bool', boolean>;
|
|
19
|
+
type StringLocalFilter = BaseLocalFilter<'string', string>;
|
|
20
|
+
type DateLocalFilter = BaseLocalFilter<'date', CalendarDateTime>;
|
|
21
|
+
type IdSearchLocalFilter = BaseLocalFilter<'id-search', Set<string | number>>;
|
|
22
|
+
export type TableFilter = EnumLocalFilter | IdLocalFilter | BoolLocalFilter | StringLocalFilter | DateLocalFilter | IdSearchLocalFilter;
|
|
7
23
|
export type FilterConfig = {
|
|
8
24
|
type: 'enum';
|
|
9
25
|
options: MultiSelectProps['items'];
|
|
@@ -23,5 +39,6 @@ export type FilterConfig = {
|
|
|
23
39
|
type: 'date';
|
|
24
40
|
};
|
|
25
41
|
export type FilterType = FilterConfig['type'];
|
|
26
|
-
export type FiltersConfig<TOperation extends
|
|
42
|
+
export type FiltersConfig<TOperation extends keyof operations> = Required<Record<keyof ApiFilters<TOperation>, FilterConfig>>;
|
|
27
43
|
export declare function DataTableFilter({ className, ...props }: React.ComponentProps<'section'>): import("react/jsx-runtime").JSX.Element;
|
|
44
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"react/jsx-runtime";import"./button.js";import{C as
|
|
1
|
+
import"react/jsx-runtime";import"lucide-react";import"react";import"./button.js";import{C as z,D as G,F as H}from"./data-table.js";import"./date-picker.js";import"./id-search.js";import"./menu.js";import"./popover.js";import"../utils/form-hook.js";import"../utils/primitives.js";import"../utils/resource-names.js";import"class-variance-authority";import"react-aria-components";import"./loader.js";import"clsx";import"@tanstack/react-query";import"@tanstack/react-table";import"@uidotdev/usehooks";import"@dnd-kit/sortable";import"@dnd-kit/core";import"@dnd-kit/utilities";import"lodash-es";import"./data-table-commons.js";import"date-fns";import"./checkbox.js";import"./field.js";import"../utils/form-utils.js";import"../utils/form-context.js";import"@tanstack/react-form";import"./searchfield.js";import"./table.js";import"@internationalized/date";import"./calendar.js";import"./datefield.js";import"./list-box.js";import"./select.js";import"./multi-select.js";import"./numberfield.js";import"./textfield.js";export{z as COMPARISON_OPERATOR_LABELS,G as DataTableFilter,H as FILTER_COMPARISON_OPERATORS};
|
|
2
2
|
//# sourceMappingURL=data-table-filter.js.map
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { components, operations } from '@cryptlex/web-api-types';
|
|
2
2
|
import { ColumnDef, TableState, VisibilityState } from '@tanstack/react-table';
|
|
3
|
-
import {
|
|
4
|
-
import { FiltersConfig } from '
|
|
3
|
+
import { ApiSchema, TableAction, TableFetchFn } from '../components/data-table-commons';
|
|
4
|
+
import { FiltersConfig, TableFilter } from '../components/data-table-filter';
|
|
5
5
|
/** Reserved name for actions column */
|
|
6
6
|
export declare const ACTIONS_COLUMN_ID = "tableActions";
|
|
7
7
|
export type Schemas = ApiSchema<keyof components['schemas']>;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
fetchFn: TableFetchFn<TData, OperationKeys>;
|
|
8
|
+
type DataTableFactory<TData extends Schemas, TOperation extends keyof operations> = {
|
|
9
|
+
fetchFn: TableFetchFn<TData>;
|
|
11
10
|
columns: ColumnDef<TData, any>[];
|
|
12
11
|
allowSelection?: boolean;
|
|
13
12
|
columnsToHideByDefault?: VisibilityState;
|
|
14
|
-
filterConfig: FiltersConfig<
|
|
13
|
+
filterConfig: FiltersConfig<TOperation>;
|
|
14
|
+
initialFilters: TableFilter[];
|
|
15
15
|
};
|
|
16
16
|
type DataTableState = Pick<TableState, 'sorting' | 'pagination'> & {};
|
|
17
17
|
/**
|
|
18
18
|
* Hook for handling all data-table state. Used in DataTableContext
|
|
19
19
|
*/
|
|
20
|
-
export declare function useDataTableState<TData extends Schemas>({ columns, fetchFn, columnsToHideByDefault, allowSelection,
|
|
20
|
+
export declare function useDataTableState<TData extends Schemas, TOperation extends keyof operations>({ columns, fetchFn, filterConfig, columnsToHideByDefault, allowSelection, initialFilters, }: DataTableFactory<TData, TOperation>): {
|
|
21
21
|
tableState: Pick<TableState, "sorting" | "pagination">;
|
|
22
22
|
updateTableState: (updates: Partial<DataTableState>) => void;
|
|
23
23
|
query: import('@tanstack/react-query').UseQueryResult<{
|
|
@@ -27,10 +27,14 @@ export declare function useDataTableState<TData extends Schemas>({ columns, fetc
|
|
|
27
27
|
setSearchQuery: import('react').Dispatch<import('react').SetStateAction<string>>;
|
|
28
28
|
searchQuery: string;
|
|
29
29
|
tanTable: import('@tanstack/react-table').Table<any>;
|
|
30
|
-
mergedFilters:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
mergedFilters: {
|
|
31
|
+
[x: string]: {
|
|
32
|
+
[x: string]: string | boolean | Set<string | number> | import('@internationalized/date').CalendarDateTime | undefined;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
filters: TableFilter[];
|
|
36
|
+
setFilters: import('react').Dispatch<import('react').SetStateAction<TableFilter[]>>;
|
|
37
|
+
filterConfig: Required<Record<Exclude<keyof import('../components/data-table-commons').ApiQuery<TOperation>, "search" | "sort" | "page" | "limit">, import('../components/data-table-filter').FilterConfig>>;
|
|
34
38
|
};
|
|
35
39
|
export declare const DataTableContext: import('react').Context<{
|
|
36
40
|
tableState: Pick<TableState, "sorting" | "pagination">;
|
|
@@ -42,10 +46,14 @@ export declare const DataTableContext: import('react').Context<{
|
|
|
42
46
|
setSearchQuery: import('react').Dispatch<import('react').SetStateAction<string>>;
|
|
43
47
|
searchQuery: string;
|
|
44
48
|
tanTable: import('@tanstack/react-table').Table<any>;
|
|
45
|
-
mergedFilters:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
mergedFilters: {
|
|
50
|
+
[x: string]: {
|
|
51
|
+
[x: string]: string | boolean | Set<string | number> | import('@internationalized/date').CalendarDateTime | undefined;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
filters: TableFilter[];
|
|
55
|
+
setFilters: import('react').Dispatch<import('react').SetStateAction<TableFilter[]>>;
|
|
56
|
+
filterConfig: Required<Record<never, import('../components/data-table-filter').FilterConfig>>;
|
|
49
57
|
} | null>;
|
|
50
58
|
export declare const useDataTable: () => {
|
|
51
59
|
tableState: Pick<TableState, "sorting" | "pagination">;
|
|
@@ -57,16 +65,20 @@ export declare const useDataTable: () => {
|
|
|
57
65
|
setSearchQuery: import('react').Dispatch<import('react').SetStateAction<string>>;
|
|
58
66
|
searchQuery: string;
|
|
59
67
|
tanTable: import('@tanstack/react-table').Table<any>;
|
|
60
|
-
mergedFilters:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
68
|
+
mergedFilters: {
|
|
69
|
+
[x: string]: {
|
|
70
|
+
[x: string]: string | boolean | Set<string | number> | import('@internationalized/date').CalendarDateTime | undefined;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
filters: TableFilter[];
|
|
74
|
+
setFilters: import('react').Dispatch<import('react').SetStateAction<TableFilter[]>>;
|
|
75
|
+
filterConfig: Required<Record<never, import('../components/data-table-filter').FilterConfig>>;
|
|
64
76
|
};
|
|
65
77
|
export declare function DataTableProvider({ children, ...props }: {
|
|
66
78
|
children: React.ReactNode;
|
|
67
79
|
} & ReturnType<typeof useDataTableState>): import("react/jsx-runtime").JSX.Element;
|
|
68
80
|
export type DataTableProps = React.ComponentProps<'section'> & {
|
|
69
|
-
tableActions:
|
|
81
|
+
tableActions: TableAction[];
|
|
70
82
|
};
|
|
71
83
|
export declare function DataTable({ tableActions, className, ...props }: DataTableProps): import("react/jsx-runtime").JSX.Element;
|
|
72
84
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{jsx as e,Fragment as C,jsxs as c}from"react/jsx-runtime";import{Button as y}from"./button.js";import{useQuery as te,keepPreviousData as ne}from"@tanstack/react-query";import{createColumnHelper as re,useReactTable as ae,getCoreRowModel as ie,flexRender as M}from"@tanstack/react-table";import{Info as oe,RotateCw as le,Columns3 as se,GripVertical as ce,ChevronFirst as de,ChevronLeft as ue,ChevronRight as me,ChevronLast as pe,ArrowDownNarrowWide as ge,ArrowDownWideNarrow as fe,ArrowUpDown as he,Filter as be,Trash as Se}from"lucide-react";import{createContext as ye,useId as ve,useState as w,useMemo as E,useEffect as j,useContext as Ce,useRef as we}from"react";import{sortableKeyboardCoordinates as xe,SortableContext as Te,verticalListSortingStrategy as Ne,arrayMove as Ae,useSortable as Fe}from"@dnd-kit/sortable";import{useSensors as Pe,useSensor as H,PointerSensor as De,KeyboardSensor as Oe,DndContext as Ie,closestCenter as Re,DragOverlay as Le}from"@dnd-kit/core";import{CSS as ze}from"@dnd-kit/utilities";import{TABLE_CHECK_BOX_COLUMN as Me,TABLE_ID_COLUMN as Ee,TABLE_DEFAULT_DATE_COLUMNS as _e}from"./data-table-commons.js";import{TfDatePicker as Ve}from"./date-picker.js";import{TfIdSearchInput as qe}from"./id-search.js";import{EasyMenu as V,MenuItem as L}from"./menu.js";import{PopoverTrigger as $e,Popover as Ue}from"./popover.js";import{useAppForm as ke}from"../utils/form-hook.js";import{classNames as x}from"../utils/primitives.js";import{useResourceFormatter as W}from"../utils/resource-names.js";import{Loader as je}from"./loader.js";import{SearchField as He}from"./searchfield.js";import{Table as Be,TableHeader as Ke,TableRow as B,TableHead as Qe,TableBody as We,TableCell as Ge}from"./table.js";import{merge as Xe}from"lodash-es";import"class-variance-authority";import"react-aria-components";import"date-fns";import"./checkbox.js";import"./field.js";import"../utils/form-utils.js";import"../utils/form-context.js";import"@tanstack/react-form";import"@internationalized/date";import"./calendar.js";import"./datefield.js";import"./list-box.js";import"./select.js";import"./multi-select.js";import"./numberfield.js";import"./textfield.js";import"clsx";const _="tableActions";function jt({columns:t,fetchFn:a,columnsToHideByDefault:l={},allowSelection:o=!1,filterConfig:n}){const f=ve(),[s,u]=w({pagination:{pageIndex:0,pageSize:20},sorting:[]}),[h,d]=w({}),[b,m]=w(""),[i,g]=w([]),[p,N]=w({id:!1,updatedAt:!1,...l}),[P,Y]=w([]),q=E(()=>P.reduce((r,v)=>Xe(r,v),{}),[P]),z=r=>{u(v=>({...v,...r}))},{sorting:I,pagination:R}=s,A=te({queryKey:[f,R,I,b],queryFn:()=>a(R,I,b,q),placeholderData:ne,retry:0,refetchOnWindowFocus:!1});j(()=>{},[p]);const Z=E(()=>re(),[]),$=E(()=>{const r=A.data?.data;if(!r?.length)return[];const v=S=>S!=null&&typeof S=="object"&&"metadata"in S&&Array.isArray(S.metadata),k=r.filter(v);return k.length===0?[]:Array.from(new Set(k.flatMap(S=>S.metadata?.map(F=>F.key)??[]))).map(S=>Z.accessor(F=>v(F)?F?.metadata?.find(O=>O.key===S)?.value??"":"",{id:S,header:S,enableSorting:!1,cell:F=>{const O=F.getValue();return O==null?"":String(O)}}))},[A.data?.data]),J=[...o?Me:[],...Ee,...t.filter(r=>r.id!==_),...$.length?$:[],..._e,...t.filter(r=>r.id===_)];function ee(r){return typeof r=="function"}function D(r,v){return ee(r)?r(v):r}const U=ae({data:A.data?.data??[],columns:J,getCoreRowModel:ie(),rowCount:A.data?.total,manualPagination:!0,onPaginationChange:r=>{z({pagination:D(r,R)})},manualSorting:!0,onSortingChange:r=>{d({}),z({sorting:[...D(r,I)]})},manualFiltering:!0,onColumnVisibilityChange:r=>{N(D(r,p))},onRowSelectionChange:r=>{d(D(r,h))},onColumnOrderChange:r=>{g(D(r,i))},state:{sorting:I,columnVisibility:p,pagination:R,rowSelection:h,columnOrder:i},meta:{refetch:A.refetch}});return j(()=>{g([...U.getAllLeafColumns().map(r=>r.id)])},[]),{tableState:s,updateTableState:z,query:A,setSearchQuery:m,searchQuery:b,tanTable:U,mergedFilters:q,filters:P,setFilters:Y,filterConfig:n}}const G=ye(null),T=()=>{const t=Ce(G);if(!t)throw Error("DataTable should be used within DataTableProvider.");return t};function Ht({children:t,...a}){return e(G.Provider,{value:a,children:t})}function Bt({tableActions:t,className:a,...l}){const{query:o,tanTable:n}=T();return e(C,{children:c("section",{...l,className:x("flex flex-col bg-card",a),children:[e(et,{tableActions:t}),c("div",{className:"w-full overflow-auto border-x grow min-h-table relative",tabIndex:0,children:[o.isLoading&&e(K,{className:"cursor-wait",children:e(je,{})}),!o.isLoading&&n.getRowModel().rows.length===0&&e(K,{className:"cursor-not-allowed",children:!o.isFetching&&(o.isError?c("span",{className:"flex gap-3 justify-center items-center",children:[e(oe,{}),e("span",{children:"You don't have the required permissions. Please contact your admin."})]}):o.data?.data?e(C,{children:"Unknown error. Please contact customer support."}):e(C,{children:"No results found."}))}),!o.isLoading&&n.getRowModel().rows.length!==0&&e(tt,{className:"size-full"})]}),c("div",{className:"flex w-full justify-between border gap-icon p-icon overflow-x-auto",children:[c("div",{className:"flex gap-icon",children:[e(Ye,{}),e(Je,{})]}),e(Ze,{})]})]})})}function K({children:t,className:a}){return c(C,{children:[e("span",{className:x(a,"absolute top-0 bg-card z-20 size-full body-sm flex items-center justify-center"),children:t}),e("span",{className:"relative h-full w-0 block"})]})}function Ye(){const{tanTable:t}=T(),[a,l]=w(null),o=W(),n=Pe(H(De),H(Oe,{coordinateGetter:xe}));return e(Ie,{sensors:n,collisionDetection:Re,onDragStart:s=>{const{active:u}=s;l(u.id.toString())},onDragEnd:s=>{const{active:u,over:h}=s;if(h&&u.id!==h.id){const d=t.getState().columnOrder,b=d.indexOf(u.id.toString()),m=d.indexOf(h.id.toString());t.setColumnOrder([...Ae(d,b,m)])}l(null)},children:c(Te,{items:t.getState().columnOrder,strategy:Ne,children:[c(V,{label:c(C,{children:[e(se,{}),"Columns"]}),selectionMode:"multiple",items:t.getAllFlatColumns(),selectedKeys:t.getIsAllColumnsVisible()?"all":t.getVisibleFlatColumns().map(s=>s.id),children:[e(L,{onAction:()=>t.toggleAllColumnsVisible(),className:"italic",children:"(select all)"}),t.getState().columnOrder.map(s=>{const u=t.getAllFlatColumns().find(h=>h.id===s);return u?e(f,{column:u},u.id):null})]}),e(Le,{children:a?e("div",{className:"opacity-70 border-2 border-primary",children:o(a)}):null})]})});function f({column:s}){const{attributes:u,listeners:h,setNodeRef:d,transform:b,transition:m}=Fe({id:s.id}),i={transform:ze.Transform.toString(b),transition:m,zIndex:"999"};return c(L,{ref:d,style:i,...u,id:s.id,onAction:()=>s.toggleVisibility(),isDisabled:!s.getCanHide(),className:"flex items-center",children:[e(ce,{...h,className:"size-icon cursor-grab"}),o(s.id),s.getIsSorted()&&e(X,{className:"size-icon",direction:s.getIsSorted()})]})}}function Ze(){const{tanTable:t,query:a}=T(),l=a.data?.total??0;return c("div",{className:"flex items-center gap-2",children:[e("span",{className:"whitespace-nowrap body-sm text-muted",children:`${t.getState().pagination.pageIndex*t.getState().pagination.pageSize+1} - ${Math.min((t.getState().pagination.pageIndex+1)*t.getState().pagination.pageSize,l)} of ${l?.toLocaleString()}`}),e(y,{onPress:()=>t.firstPage(),isDisabled:!t.getCanPreviousPage(),variant:"neutral",size:"icon",children:e(de,{})}),e(y,{onPress:()=>t.previousPage(),isDisabled:!t.getCanPreviousPage(),variant:"neutral",size:"icon",children:e(ue,{})}),e(y,{onPress:()=>t.nextPage(),isDisabled:!t.getCanNextPage(),variant:"neutral",size:"icon",children:e(me,{})}),e(y,{onClick:()=>t.lastPage(),isDisabled:!t.getCanNextPage(),variant:"neutral",size:"icon",children:e(pe,{})})]})}function Je(){const{tanTable:t}=T(),a=[10,20,30,40,50];return e(V,{label:t.getState().pagination.pageSize.toString(),selectionMode:"single",selectedKeys:[t.getState().pagination.pageSize.toString()],items:a.map(l=>({id:l.toString(),value:l})),children:l=>e(L,{onAction:()=>t.setPageSize(l.value),children:l.value})})}function et({tableActions:t}){const{query:a,tanTable:l,searchQuery:o,setSearchQuery:n}=T();return c("section",{className:"flex bg-card justify-between my-0 p-icon border gap-icon overflow-auto",children:[c("div",{className:"flex gap-icon",children:[e(y,{isPending:a.isFetching,onClick:()=>a.refetch(),variant:"neutral",size:"icon",children:e(le,{})}),t.filter(f=>f.bulk===l.getSelectedRowModel().rows.length>0).map((f,s)=>{const u=f.icon;return e(y,{type:"button",isDisabled:a.isFetching,className:"animate-in fade-in slide-in-from-left-15 duration-300 transition-transform",onPress:h=>{f.onClick(h,l)},size:"icon",children:e(u,{})},`${s}-${f.bulk}`)})]}),c("div",{className:"flex gap-icon",children:[e(rt,{}),e(He,{value:o,onChange:n})]})]})}function X({direction:t,...a}){return t==="asc"?e(ge,{...a}):t==="desc"?e(fe,{...a}):e(he,{...a})}function tt({className:t}){const{tanTable:a}=T(),l=(o,n)=>x("animate-in fade-in slide-in-from-top-10","px-icon py-2 text-left body-sm font-medium whitespace-nowrap",o&&"bg-card sticky right-0 z-50 text-center",n);return c(Be,{className:x(t),children:[e(Ke,{className:"sticky top-0 z-10",children:a.getHeaderGroups().map(o=>e(B,{className:x("h-input"),children:o.headers.map(n=>c(Qe,{className:l(!1,"bg-card"),children:[!n.column.getCanSort()&&!n.isPlaceholder&&e(C,{children:M(n.column.columnDef.header,n.getContext())}),n.column.getCanSort()&&c(y,{variant:"ghost",className:"w-full !justify-start !px-1.5",onPress:n.column.getToggleSortingHandler(),children:[M(n.column.columnDef.header,n.getContext()),e(X,{direction:n.column.getIsSorted()})]})]},n.id))},o.id))}),e(We,{className:"flex-1 overflow-y-auto relative",children:a.getRowModel().rows.map(o=>e(B,{className:x("h-input transition-colors data-[selected=true]:bg-primary/10 hover:bg-muted-foreground/20"),"data-selected":o.getIsSelected(),children:o.getVisibleCells().map(n=>e(Ge,{className:l(n.column.id===_),children:M(n.column.columnDef.cell,n.getContext())},n.id))},o.id))})]})}const Kt=["eq","ne","cn","nc","sw","ew","in","nin","gt","gte","lt","lte"],nt={eq:"equal to",ne:"not equal to",cn:"contains",nc:"does not contain",sw:"starts with",ew:"ends with",in:"includes",nin:"does not include",gt:"greater than",gte:"greater than or equal to",lt:"less than",lte:"less than or equal to"},Q={bool:["eq"],enum:["in","nin"],id:["in","nin"],"id-search":["in","nin"],string:["eq","ne","cn","nc","sw","ew","in","nin"],date:["lt","gt"]};function rt({className:t,...a}){const{filters:l,query:o,setFilters:n,filterConfig:f}=T(),s=we(null),u=W(),d=ke({defaultValues:{filters:[]},onSubmit:({value:m})=>{n(m.filters.map(i=>({[i.property]:{[i.operator]:[i.value]}})))}}),b=Object.keys(f).sort();return e("section",{...a,className:x("flex gap-icon items-center",t),children:c($e,{onOpenChange:m=>{m?s.current?.focus():d.handleSubmit()},children:[e(y,{active:l.length>0,isDisabled:o.isPending||b.length===0,type:"button",size:"icon",variant:"neutral",children:e(be,{})}),e(Ue,{className:"w-full p-icon",children:e("form",{onSubmit:m=>{m.preventDefault()},className:"flex flex-col gap-icon max-h-table overflow-auto ",children:e(d.Field,{mode:"array",name:"filters",children:m=>c(C,{children:[m.state.value.map((i,g)=>c("div",{className:"flex gap-icon items-center justify-normal",children:[e("span",{className:"body-sm",children:u(i.property)}),e(d.AppField,{name:`filters[${g}].operator`,children:p=>e(p.TfSingleSelect,{items:Q[i.type].map(N=>({id:N,label:e(C,{children:nt[N]})}))})},i.id),i.type==="bool"&&e(d.AppField,{name:`filters[${g}].value`,children:p=>e(p.TfCheckbox,{})}),i.type==="date"&&e(d.AppField,{name:`filters[${g}].value`,children:p=>e(Ve,{})}),i.type==="id"&&e(d.AppField,{name:`filters[${g}].value`,children:p=>e(p.TfTextField,{})}),i.type==="string"&&e(d.AppField,{name:`filters[${g}].value`,children:p=>e(p.TfTextField,{})}),i.type==="enum"&&e(d.AppField,{name:`filters[${g}].value`,children:p=>e(p.TfMultiSelect,{items:f[i.property].options})}),i.type==="id-search"&&e(d.AppField,{name:`filters[${g}].value`,children:p=>e(qe,{multiple:!0,accessor:"id",searchFn:f[i.property].search})}),e(y,{type:"button",variant:"destructive",size:"icon",onPress:()=>m.removeValue(g),children:e(Se,{})})]},i.id)),c("div",{className:"flex w-full items-center justify-end gap-2 not-first:mt-icon",children:[e(V,{label:"Add Filter",children:b.map(i=>e(L,{onAction:()=>{const g=f[i].type,p=P=>{switch(P){case"bool":return!0;case"string":return"";case"date":return new Date().toISOString();case"id":return"";case"id-search":return[];case"enum":return[]}},N={id:`${i}-${Date.now()}`,operator:Q[g][0],value:p(g),type:g,property:i};m.pushValue(N)},children:u(i)},i))}),m.state.value.length>0?e(y,{type:"button",variant:"neutral",onPress:()=>{m.setValue([])},children:"Reset filters"}):null]})]})})})})]})})}export{_ as ACTIONS_COLUMN_ID,nt as C,rt as D,Bt as DataTable,G as DataTableContext,Ht as DataTableProvider,Kt as F,T as useDataTable,jt as useDataTableState};
|
|
1
|
+
"use client";import{jsx as e,Fragment as C,jsxs as s}from"react/jsx-runtime";import{Info as ne,RotateCw as re,Columns3 as ae,GripVertical as ie,ChevronFirst as oe,ChevronLeft as le,ChevronRight as se,ChevronLast as ce,ArrowDownNarrowWide as de,ArrowDownWideNarrow as ue,ArrowUpDown as me,Filter as pe,Trash as ge}from"lucide-react";import{createContext as fe,useId as he,useState as D,useMemo as E,useEffect as be,useContext as ye,useRef as Se}from"react";import{Button as y}from"./button.js";import{useQuery as ve,keepPreviousData as Ce}from"@tanstack/react-query";import{createColumnHelper as we,useReactTable as xe,getCoreRowModel as Ne,flexRender as V}from"@tanstack/react-table";import{useLocalStorage as H}from"@uidotdev/usehooks";import{sortableKeyboardCoordinates as Te,SortableContext as Ae,verticalListSortingStrategy as Fe,arrayMove as Pe,useSortable as De}from"@dnd-kit/sortable";import{useSensors as Oe,useSensor as B,PointerSensor as Ie,KeyboardSensor as _e,DndContext as ze,closestCenter as Le,DragOverlay as Re}from"@dnd-kit/core";import{CSS as Me}from"@dnd-kit/utilities";import{merge as Ee}from"lodash-es";import{TABLE_CHECK_BOX_COLUMN as Ve,TABLE_ID_COLUMN as qe,TABLE_DEFAULT_DATE_COLUMNS as $e}from"./data-table-commons.js";import{TfDatePicker as Ue}from"./date-picker.js";import{TfIdSearchInput as je}from"./id-search.js";import{EasyMenu as $,MenuItem as _}from"./menu.js";import{PopoverTrigger as ke,Popover as He}from"./popover.js";import{useAppForm as Be}from"../utils/form-hook.js";import{classNames as x}from"../utils/primitives.js";import{useResourceFormatter as G}from"../utils/resource-names.js";import{Loader as Ke}from"./loader.js";import{SearchField as Qe}from"./searchfield.js";import{Table as We,TableHeader as Ge,TableRow as K,TableHead as Xe,TableBody as Ze,TableCell as Je}from"./table.js";import"class-variance-authority";import"react-aria-components";import"date-fns";import"./checkbox.js";import"./field.js";import"../utils/form-utils.js";import"../utils/form-context.js";import"@tanstack/react-form";import"@internationalized/date";import"./calendar.js";import"./datefield.js";import"./list-box.js";import"./select.js";import"./multi-select.js";import"./numberfield.js";import"./textfield.js";import"clsx";const q="tableActions";function Kt({columns:t,fetchFn:a,filterConfig:o,columnsToHideByDefault:i={},allowSelection:r=!1,initialFilters:f=[]}){const c=he(),[u,h]=D({pagination:{pageIndex:0,pageSize:20},sorting:[]}),[m,S]=D({}),[d,l]=D(""),[g,p]=H("ctx_column_order_preference",[]),[w,z]=H("ctx_column_visibility_preference",{id:!1,updatedAt:!1,...i}),[L,J]=D(f),R=E(()=>L.map(n=>Array.isArray(n.value)?{[n.property]:{[n.operator]:n.value.join(",")}}:{[n.property]:{[n.operator]:n.value}}).reduce((n,v)=>Ee(n,v),{}),[L]),M=n=>{h(v=>({...v,...n}))},{sorting:O,pagination:I}=u,T=ve({queryKey:[c,I,O,d,R],queryFn:()=>a(I,O,d,R),placeholderData:Ce,retry:0,refetchOnWindowFocus:!1}),Y=E(()=>we(),[]),U=E(()=>{const n=T.data?.data;if(!n?.length)return[];const v=b=>b!=null&&typeof b=="object"&&"metadata"in b&&Array.isArray(b.metadata),k=n.filter(v);return k.length===0?[]:Array.from(new Set(k.flatMap(b=>b.metadata?.map(A=>A.key)??[]))).map(b=>Y.accessor(A=>v(A)?A?.metadata?.find(P=>P.key===b)?.value??"":"",{id:b,header:b,enableSorting:!1,cell:A=>{const P=A.getValue();return P==null?"":String(P)}}))},[T.data?.data]),ee=[...r?Ve:[],...qe,...t.filter(n=>n.id!==q),...U.length?U:[],...$e,...t.filter(n=>n.id===q)];function te(n){return typeof n=="function"}function F(n,v){return te(n)?n(v):n}const j=xe({data:T.data?.data??[],columns:ee,getCoreRowModel:Ne(),rowCount:T.data?.total,manualPagination:!0,onPaginationChange:n=>{M({pagination:F(n,I)})},manualSorting:!0,onSortingChange:n=>{S({}),M({sorting:[...F(n,O)]})},manualFiltering:!0,onColumnVisibilityChange:n=>{z(F(n,w))},onRowSelectionChange:n=>{S(F(n,m))},onColumnOrderChange:n=>{p(F(n,g))},state:{sorting:O,columnVisibility:w,pagination:I,rowSelection:m,columnOrder:g},meta:{refetch:T.refetch}});return be(()=>{p([...j.getAllLeafColumns().map(n=>n.id)])},[]),{tableState:u,updateTableState:M,query:T,setSearchQuery:l,searchQuery:d,tanTable:j,mergedFilters:R,filters:L,setFilters:J,filterConfig:o}}const X=fe(null),N=()=>{const t=ye(X);if(!t)throw Error("DataTable should be used within DataTableProvider.");return t};function Qt({children:t,...a}){return e(X.Provider,{value:a,children:t})}function Wt({tableActions:t,className:a,...o}){const{query:i,tanTable:r}=N();return e(C,{children:s("section",{...o,className:x("flex flex-col bg-card",a),children:[e(nt,{tableActions:t}),s("div",{className:"w-full overflow-auto border-x grow min-h-table relative",tabIndex:0,children:[i.isLoading&&e(Q,{className:"cursor-wait",children:e(Ke,{})}),!i.isLoading&&r.getRowModel().rows.length===0&&e(Q,{className:"cursor-not-allowed",children:!i.isFetching&&(i.isError?s("span",{className:"flex gap-3 justify-center items-center",children:[e(ne,{}),e("span",{children:i.error.message})]}):i.data?.data?.length===0?e(C,{children:"No results found."}):e(C,{children:"Unknown error. Please contact customer support."}))}),!i.isLoading&&r.getRowModel().rows.length!==0&&e(rt,{className:"size-full"})]}),s("div",{className:"flex w-full justify-between border gap-icon p-icon overflow-x-auto",children:[s("div",{className:"flex gap-icon",children:[e(Ye,{}),e(tt,{})]}),e(et,{})]})]})})}function Q({children:t,className:a}){return s(C,{children:[e("span",{className:x(a,"absolute top-0 bg-card z-20 size-full body-sm flex items-center justify-center"),children:t}),e("span",{className:"relative h-full w-0 block"})]})}function Ye(){const{tanTable:t}=N(),[a,o]=D(null),i=G(),r=Oe(B(Ie),B(_e,{coordinateGetter:Te}));return e(ze,{sensors:r,collisionDetection:Le,onDragStart:c=>{const{active:u}=c;o(u.id.toString())},onDragEnd:c=>{const{active:u,over:h}=c;if(h&&u.id!==h.id){const m=t.getState().columnOrder,S=m.indexOf(u.id.toString()),d=m.indexOf(h.id.toString());t.setColumnOrder([...Pe(m,S,d)])}o(null)},children:s(Ae,{items:t.getState().columnOrder,strategy:Fe,children:[s($,{label:s(C,{children:[e(ae,{}),"Columns"]}),selectionMode:"multiple",items:t.getAllFlatColumns(),selectedKeys:t.getIsAllColumnsVisible()?"all":t.getVisibleFlatColumns().map(c=>c.id),children:[e(_,{onAction:()=>t.toggleAllColumnsVisible(),className:"italic",children:"(select all)"}),t.getState().columnOrder.map(c=>{const u=t.getAllFlatColumns().find(h=>h.id===c);return u?e(f,{column:u},u.id):null})]}),e(Re,{children:a?e("div",{className:"opacity-70 border-2 border-primary",children:i(a)}):null})]})});function f({column:c}){const{attributes:u,listeners:h,setNodeRef:m,transform:S,transition:d}=De({id:c.id}),l={transform:Me.Transform.toString(S),transition:d,zIndex:"999"};return s(_,{ref:m,style:l,...u,id:c.id,onAction:()=>c.toggleVisibility(),isDisabled:!c.getCanHide(),className:"flex items-center",children:[e(ie,{...h,className:"size-icon cursor-grab"}),i(c.id),c.getIsSorted()&&e(Z,{className:"size-icon",direction:c.getIsSorted()})]})}}function et(){const{tanTable:t,query:a}=N(),o=a.data?.total??0;return s("div",{className:"flex items-center gap-2",children:[e("span",{className:"whitespace-nowrap body-sm text-muted",children:`${t.getState().pagination.pageIndex*t.getState().pagination.pageSize+1} - ${Math.min((t.getState().pagination.pageIndex+1)*t.getState().pagination.pageSize,o)} of ${o?.toLocaleString()}`}),e(y,{onPress:()=>t.firstPage(),isDisabled:!t.getCanPreviousPage(),variant:"neutral",size:"icon",children:e(oe,{})}),e(y,{onPress:()=>t.previousPage(),isDisabled:!t.getCanPreviousPage(),variant:"neutral",size:"icon",children:e(le,{})}),e(y,{onPress:()=>t.nextPage(),isDisabled:!t.getCanNextPage(),variant:"neutral",size:"icon",children:e(se,{})}),e(y,{onClick:()=>t.lastPage(),isDisabled:!t.getCanNextPage(),variant:"neutral",size:"icon",children:e(ce,{})})]})}function tt(){const{tanTable:t}=N(),a=[10,20,30,40,50];return e($,{label:t.getState().pagination.pageSize.toString(),selectionMode:"single",selectedKeys:[t.getState().pagination.pageSize.toString()],items:a.map(o=>({id:o.toString(),value:o})),children:o=>e(_,{onAction:()=>t.setPageSize(o.value),children:o.value})})}function nt({tableActions:t}){const{query:a,tanTable:o,searchQuery:i,setSearchQuery:r}=N();return s("section",{className:"flex bg-card justify-between my-0 p-icon border gap-icon overflow-auto",children:[s("div",{className:"flex gap-icon",children:[e(y,{isPending:a.isFetching,onClick:()=>a.refetch(),variant:"neutral",size:"icon",children:e(re,{})}),t.filter(f=>f.bulk===o.getSelectedRowModel().rows.length>0).map((f,c)=>{const u=f.icon;return e(y,{type:"button",isDisabled:a.isFetching,className:"animate-in fade-in slide-in-from-left-15 duration-300 transition-transform",onPress:h=>{f.onClick(h,o)},size:"icon",children:e(u,{})},`${c}-${f.bulk}`)})]}),s("div",{className:"flex gap-icon",children:[e(it,{}),e(Qe,{value:i,onChange:r})]})]})}function Z({direction:t,...a}){return t==="asc"?e(de,{...a}):t==="desc"?e(ue,{...a}):e(me,{...a})}function rt({className:t}){const{tanTable:a}=N(),o=(i,r)=>x("animate-in fade-in slide-in-from-top-10","px-icon py-2 text-left body-sm font-medium whitespace-nowrap",i&&"bg-card sticky right-0 z-50 text-center",r);return s(We,{className:x(t),children:[e(Ge,{className:"sticky top-0 z-10",children:a.getHeaderGroups().map(i=>e(K,{className:x("h-input"),children:i.headers.map(r=>s(Xe,{className:o(!1,"bg-card"),children:[!r.column.getCanSort()&&!r.isPlaceholder&&e(C,{children:V(r.column.columnDef.header,r.getContext())}),r.column.getCanSort()&&s(y,{variant:"ghost",className:"w-full !justify-start !px-1.5",onPress:r.column.getToggleSortingHandler(),children:[V(r.column.columnDef.header,r.getContext()),e(Z,{direction:r.column.getIsSorted()})]})]},r.id))},i.id))}),e(Ze,{className:"flex-1 overflow-y-auto relative",children:a.getRowModel().rows.map(i=>e(K,{className:x("h-input transition-colors data-[selected=true]:bg-primary/10 hover:bg-muted-foreground/20"),"data-selected":i.getIsSelected(),children:i.getVisibleCells().map(r=>e(Je,{className:o(r.column.id===q),children:V(r.column.columnDef.cell,r.getContext())},r.id))},i.id))})]})}const Gt=["eq","ne","cn","nc","sw","ew","in","nin","gt","gte","lt","lte"],at={eq:"equal to",ne:"not equal to",cn:"contains",nc:"does not contain",sw:"starts with",ew:"ends with",in:"includes",nin:"does not include",gt:"greater than",gte:"greater than or equal to",lt:"less than",lte:"less than or equal to"},W={bool:["eq"],enum:["in","nin"],id:["in","nin"],"id-search":["in","nin"],string:["eq","ne","cn","nc","sw","ew","in","nin"],date:["lt","gt"]};function it({className:t,...a}){const{filters:o,query:i,setFilters:r,filterConfig:f}=N(),c=Se(null),u=G(),m=Be({defaultValues:{filters:o},onSubmit:({value:d})=>{r(d.filters)}}),S=Object.keys(f).sort();return e("section",{...a,className:x("flex gap-icon items-center",t),children:s(ke,{onOpenChange:d=>{d?c.current?.focus():m.handleSubmit()},children:[s("div",{className:"relative",children:[o.length>0&&e("div",{className:"size-2 rounded-full absolute bg-destructive z-20 top-0 right-0 translate-x-0.5 -translate-y-0.5"}),e(y,{isDisabled:i.isPending||S.length===0,type:"button",size:"icon",variant:"neutral",children:e(pe,{})})]}),e(He,{className:"w-full p-icon",children:e("form",{onSubmit:d=>{d.preventDefault()},className:"flex flex-col gap-icon max-h-table overflow-auto ",children:e(m.Field,{mode:"array",name:"filters",children:d=>s(C,{children:[d.state.value.map((l,g)=>s("div",{className:"flex gap-icon items-center justify-normal",children:[e("span",{className:"body-sm",children:u(l.property)}),e(m.AppField,{name:`filters[${g}].operator`,children:p=>e(p.TfSingleSelect,{items:W[l.type].map(w=>({id:w,label:e(C,{children:at[w]})}))})},l.id),l.type==="bool"&&e(m.AppField,{name:`filters[${g}].value`,children:p=>e(p.TfCheckbox,{})}),l.type==="date"&&e(m.AppField,{name:`filters[${g}].value`,children:p=>e(Ue,{})}),l.type==="id"&&e(m.AppField,{name:`filters[${g}].value`,children:p=>e(p.TfTextField,{})}),l.type==="string"&&e(m.AppField,{name:`filters[${g}].value`,children:p=>e(p.TfTextField,{})}),l.type==="enum"&&e(m.AppField,{name:`filters[${g}].value`,children:p=>e(p.TfMultiSelect,{items:f[l.property].options})}),l.type==="id-search"&&e(m.AppField,{name:`filters[${g}].value`,children:p=>e(je,{multiple:!0,accessor:"id",searchFn:f[l.property].search})}),e(y,{type:"button",variant:"destructive",size:"icon",onPress:()=>d.removeValue(g),children:e(ge,{})})]},l.id)),s("div",{className:"flex w-full items-center justify-end gap-2 not-first:mt-icon",children:[e($,{label:"Add Filter",children:S.map(l=>e(_,{onAction:()=>{const g=f[l].type,p=z=>{switch(z){case"bool":return!0;case"string":return"";case"date":return new Date().toISOString();case"id":return"";case"id-search":return[];case"enum":return[]}},w={id:`${l}-${Date.now()}`,operator:W[g][0],value:p(g),type:g,property:l};d.pushValue(w)},children:u(l)},l))}),d.state.value.length>0?e(y,{type:"button",variant:"neutral",onPress:()=>{d.setValue([])},children:"Reset filters"}):null]})]})})})})]})})}export{q as ACTIONS_COLUMN_ID,at as C,it as D,Wt as DataTable,X as DataTableContext,Qt as DataTableProvider,Gt as F,N as useDataTable,Kt as useDataTableState};
|
|
2
2
|
//# sourceMappingURL=data-table.js.map
|