@wheelhouse/ui 0.2.0 → 0.2.1
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/blocks/index.d.ts +2 -0
- package/dist/blocks/index.d.ts.map +1 -0
- package/dist/blocks/index.js +1 -0
- package/dist/blocks/navigation/index.d.ts +2 -0
- package/dist/blocks/navigation/index.d.ts.map +1 -0
- package/dist/blocks/navigation/index.js +1 -0
- package/dist/blocks/navigation/pattern-1/index.d.ts +3 -0
- package/dist/blocks/navigation/pattern-1/index.d.ts.map +1 -0
- package/dist/blocks/navigation/pattern-1/index.js +1 -0
- package/dist/blocks/navigation/pattern-1/pattern-1.config.d.ts +47 -0
- package/dist/blocks/navigation/pattern-1/pattern-1.config.d.ts.map +1 -0
- package/dist/blocks/navigation/pattern-1/pattern-1.config.js +55 -0
- package/dist/blocks/navigation/pattern-1/pattern-1.d.ts +7 -0
- package/dist/blocks/navigation/pattern-1/pattern-1.d.ts.map +1 -0
- package/dist/blocks/navigation/pattern-1/pattern-1.js +50 -0
- package/dist/blocks/navigation/pattern-1/pattern-1.stories.d.ts +16 -0
- package/dist/blocks/navigation/pattern-1/pattern-1.stories.d.ts.map +1 -0
- package/dist/blocks/navigation/pattern-1/pattern-1.stories.js +20 -0
- package/dist/components/accordion/accordion.js +2 -2
- package/dist/components/alert/alert.stories.js +4 -4
- package/dist/components/alert-dialog/alert-dialog.stories.js +2 -2
- package/dist/components/badge/badge.d.ts +1 -1
- package/dist/components/breadcrumb/breadcrumb.d.ts.map +1 -1
- package/dist/components/breadcrumb/breadcrumb.js +3 -4
- package/dist/components/button/button.d.ts +2 -2
- package/dist/components/calendar/calendar.d.ts +34 -0
- package/dist/components/calendar/calendar.d.ts.map +1 -0
- package/dist/components/calendar/calendar.js +82 -0
- package/dist/components/calendar/calendar.stories.d.ts +16 -0
- package/dist/components/calendar/calendar.stories.d.ts.map +1 -0
- package/dist/components/calendar/calendar.stories.js +33 -0
- package/dist/components/calendar/index.d.ts +3 -0
- package/dist/components/calendar/index.d.ts.map +1 -0
- package/dist/components/calendar/index.js +1 -0
- package/dist/components/checkbox/checkbox.js +2 -2
- package/dist/components/collapsible/collapsible.stories.js +4 -4
- package/dist/components/combobox/combobox.d.ts.map +1 -1
- package/dist/components/combobox/combobox.js +5 -7
- package/dist/components/command/command.d.ts.map +1 -1
- package/dist/components/command/command.js +3 -4
- package/dist/components/context-menu/context-menu.d.ts.map +1 -1
- package/dist/components/context-menu/context-menu.js +4 -5
- package/dist/components/date-selector/date-selector-context.d.ts +6 -0
- package/dist/components/date-selector/date-selector-context.d.ts.map +1 -0
- package/dist/components/date-selector/date-selector-context.js +11 -0
- package/dist/components/date-selector/date-selector-parts.d.ts +68 -0
- package/dist/components/date-selector/date-selector-parts.d.ts.map +1 -0
- package/dist/components/date-selector/date-selector-parts.js +131 -0
- package/dist/components/date-selector/date-selector-types.d.ts +118 -0
- package/dist/components/date-selector/date-selector-types.d.ts.map +1 -0
- package/dist/components/date-selector/date-selector-types.js +32 -0
- package/dist/components/date-selector/date-selector-value.d.ts +47 -0
- package/dist/components/date-selector/date-selector-value.d.ts.map +1 -0
- package/dist/components/date-selector/date-selector-value.js +183 -0
- package/dist/components/date-selector/date-selector.d.ts +6 -0
- package/dist/components/date-selector/date-selector.d.ts.map +1 -0
- package/dist/components/date-selector/date-selector.js +144 -0
- package/dist/components/date-selector/date-selector.stories.d.ts +135 -0
- package/dist/components/date-selector/date-selector.stories.d.ts.map +1 -0
- package/dist/components/date-selector/date-selector.stories.js +144 -0
- package/dist/components/date-selector/index.d.ts +7 -0
- package/dist/components/date-selector/index.d.ts.map +1 -0
- package/dist/components/date-selector/index.js +5 -0
- package/dist/components/date-selector/use-date-selector.d.ts +50 -0
- package/dist/components/date-selector/use-date-selector.d.ts.map +1 -0
- package/dist/components/date-selector/use-date-selector.js +305 -0
- package/dist/components/dialog/dialog.js +2 -2
- package/dist/components/dropdown-menu/dropdown-menu.d.ts.map +1 -1
- package/dist/components/dropdown-menu/dropdown-menu.js +5 -6
- package/dist/components/empty/empty.stories.js +2 -2
- package/dist/components/filters/filters.js +4 -4
- package/dist/components/filters/filters.stories.js +3 -3
- package/dist/components/frame/frame.d.ts +1 -1
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +4 -0
- package/dist/components/input-group/input-group.d.ts +2 -2
- package/dist/components/input-group/input-group.stories.js +3 -3
- package/dist/components/item/item.d.ts +2 -2
- package/dist/components/item/item.stories.d.ts.map +1 -1
- package/dist/components/item/item.stories.js +5 -6
- package/dist/components/kbd/kbd.stories.js +2 -2
- package/dist/components/menubar/menubar.js +3 -3
- package/dist/components/native-select/native-select.js +2 -2
- package/dist/components/navigation-menu/navigation-menu.js +2 -2
- package/dist/components/pagination/pagination.js +4 -4
- package/dist/components/select/select.js +5 -5
- package/dist/components/sheet/sheet.js +2 -2
- package/dist/components/sonner/sonner.d.ts +1 -1
- package/dist/components/sonner/sonner.js +7 -7
- package/dist/components/sortable/index.d.ts +3 -0
- package/dist/components/sortable/index.d.ts.map +1 -0
- package/dist/components/sortable/index.js +1 -0
- package/dist/components/sortable/sortable.d.ts +94 -0
- package/dist/components/sortable/sortable.d.ts.map +1 -0
- package/dist/components/sortable/sortable.js +210 -0
- package/dist/components/sortable/sortable.stories.d.ts +14 -0
- package/dist/components/sortable/sortable.stories.d.ts.map +1 -0
- package/dist/components/sortable/sortable.stories.js +38 -0
- package/dist/components/spinner/spinner.d.ts +3 -3
- package/dist/components/spinner/spinner.d.ts.map +1 -1
- package/dist/components/spinner/spinner.js +2 -2
- package/dist/components/status-indicator/index.d.ts +3 -0
- package/dist/components/status-indicator/index.d.ts.map +1 -0
- package/dist/components/status-indicator/index.js +1 -0
- package/dist/components/status-indicator/status-indicator.d.ts +51 -0
- package/dist/components/status-indicator/status-indicator.d.ts.map +1 -0
- package/dist/components/status-indicator/status-indicator.js +48 -0
- package/dist/components/status-indicator/status-indicator.stories.d.ts +20 -0
- package/dist/components/status-indicator/status-indicator.stories.d.ts.map +1 -0
- package/dist/components/status-indicator/status-indicator.stories.js +97 -0
- package/dist/components/tabs/tabs.d.ts +1 -1
- package/dist/components/text/text.d.ts +1 -1
- package/dist/components/text/text.js +1 -1
- package/dist/hooks/use-mobile.d.ts +2 -0
- package/dist/hooks/use-mobile.d.ts.map +1 -0
- package/dist/hooks/use-mobile.js +15 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/llms.txt +11 -4
- package/package.json +9 -6
- package/src/styles/globals.css +4 -12
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { Checkbox as CheckboxPrimitive } from '@base-ui/react/checkbox';
|
|
4
4
|
import { cn } from '../../lib/utils';
|
|
5
|
-
import {
|
|
5
|
+
import { Check } from 'lucide-react';
|
|
6
6
|
function Checkbox({ className, ...props }) {
|
|
7
|
-
return (_jsx(CheckboxPrimitive.Root, { "data-slot": "checkbox", className: cn('peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-muted disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary', className), ...props, children: _jsx(CheckboxPrimitive.Indicator, { "data-slot": "checkbox-indicator", className: "grid place-content-center text-current transition-none [&>svg]:size-3.5", children: _jsx(
|
|
7
|
+
return (_jsx(CheckboxPrimitive.Root, { "data-slot": "checkbox", className: cn('peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-muted disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary', className), ...props, children: _jsx(CheckboxPrimitive.Indicator, { "data-slot": "checkbox-indicator", className: "grid place-content-center text-current transition-none [&>svg]:size-3.5", children: _jsx(Check, {}) }) }));
|
|
8
8
|
}
|
|
9
9
|
export { Checkbox };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { ChevronDown } from 'lucide-react';
|
|
3
3
|
import { Button } from '../button';
|
|
4
4
|
import { Text } from '../text';
|
|
5
5
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '.';
|
|
@@ -13,12 +13,12 @@ const meta = {
|
|
|
13
13
|
};
|
|
14
14
|
export default meta;
|
|
15
15
|
export const Default = {
|
|
16
|
-
render: () => (_jsxs(Collapsible, { className: "flex w-72 flex-col gap-2", children: [_jsx(CollapsibleTrigger, { render: _jsxs(Button, { variant: "outline", className: "group flex w-full items-center justify-between gap-2", children: [_jsx("span", { children: "Advanced options" }), _jsx(
|
|
16
|
+
render: () => (_jsxs(Collapsible, { className: "flex w-72 flex-col gap-2", children: [_jsx(CollapsibleTrigger, { render: _jsxs(Button, { variant: "outline", className: "group flex w-full items-center justify-between gap-2", children: [_jsx("span", { children: "Advanced options" }), _jsx(ChevronDown, { className: "size-4 shrink-0 transition-transform group-data-[panel-open]:rotate-180" })] }) }), _jsx(CollapsibleContent, { className: "flex flex-col gap-2 rounded-md border bg-card p-3 text-card-foreground shadow-xs", children: _jsx(Text, { size: "sm", tone: "muted", children: "Extra settings and details appear here when expanded." }) })] })),
|
|
17
17
|
};
|
|
18
18
|
export const OpenByDefault = {
|
|
19
|
-
render: () => (_jsxs(Collapsible, { defaultOpen: true, className: "flex w-72 flex-col gap-2", children: [_jsx(CollapsibleTrigger, { render: _jsxs(Button, { variant: "ghost", className: "group w-full justify-between px-2", children: [_jsx("span", { children: "Details" }), _jsx(
|
|
19
|
+
render: () => (_jsxs(Collapsible, { defaultOpen: true, className: "flex w-72 flex-col gap-2", children: [_jsx(CollapsibleTrigger, { render: _jsxs(Button, { variant: "ghost", className: "group w-full justify-between px-2", children: [_jsx("span", { children: "Details" }), _jsx(ChevronDown, { className: "size-4 transition-transform group-data-[panel-open]:rotate-180" })] }) }), _jsx(CollapsibleContent, { className: "rounded-md border border-dashed p-3", children: _jsx(Text, { size: "sm", children: "This block starts expanded." }) })] })),
|
|
20
20
|
};
|
|
21
21
|
export const Gallery = {
|
|
22
22
|
parameters: { layout: 'padded' },
|
|
23
|
-
render: () => (_jsx("div", { className: "flex max-w-md flex-col gap-6", children: _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("p", { className: "text-xs font-medium tracking-wide text-muted-foreground uppercase", children: "Bordered card" }), _jsxs(Collapsible, { defaultOpen: true, className: "rounded-lg border bg-card text-card-foreground shadow-xs", children: [_jsxs("div", { className: "flex items-center justify-between gap-2 border-b px-3 py-2", children: [_jsx(Text, { weight: "medium", children: "Shipping address" }), _jsx(CollapsibleTrigger, { className: "group inline-flex size-8 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground", "aria-label": "Toggle shipping section", children: _jsx(
|
|
23
|
+
render: () => (_jsx("div", { className: "flex max-w-md flex-col gap-6", children: _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("p", { className: "text-xs font-medium tracking-wide text-muted-foreground uppercase", children: "Bordered card" }), _jsxs(Collapsible, { defaultOpen: true, className: "rounded-lg border bg-card text-card-foreground shadow-xs", children: [_jsxs("div", { className: "flex items-center justify-between gap-2 border-b px-3 py-2", children: [_jsx(Text, { weight: "medium", children: "Shipping address" }), _jsx(CollapsibleTrigger, { className: "group inline-flex size-8 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground", "aria-label": "Toggle shipping section", children: _jsx(ChevronDown, { className: "size-4 transition-transform group-data-[panel-open]:rotate-180" }) })] }), _jsx(CollapsibleContent, { className: "px-3 py-3", children: _jsx(Text, { size: "sm", tone: "muted", children: "742 Evergreen Terrace, Springfield." }) })] })] }) })),
|
|
24
24
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combobox.d.ts","sourceRoot":"","sources":["../../../src/components/combobox/combobox.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,IAAI,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"combobox.d.ts","sourceRoot":"","sources":["../../../src/components/combobox/combobox.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,IAAI,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAO/D,+EAA+E;AAC/E,MAAM,MAAM,aAAa,CAAC,KAAK,GAAG,OAAO,EAAE,QAAQ,SAAS,OAAO,GAAG,SAAS,GAAG,KAAK,IAAI,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AAEzI,0EAA0E;AAC1E,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,CAAC,KAAK,CAAC,KAAK,GAAG;IAC7D,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,wDAAwD;AACxD,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,CAAC,KAA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B,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,iBAAiB,GACpB,CAAC"}
|
|
@@ -5,9 +5,7 @@ import { Combobox as ComboboxPrimitive } from '@base-ui/react';
|
|
|
5
5
|
import { cn } from '../../lib/utils';
|
|
6
6
|
import { Button } from '../button';
|
|
7
7
|
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from '../input-group';
|
|
8
|
-
import {
|
|
9
|
-
import { CheckIcon } from '@phosphor-icons/react/Check';
|
|
10
|
-
import { XIcon } from '@phosphor-icons/react/X';
|
|
8
|
+
import { Check, ChevronDown, X } from 'lucide-react';
|
|
11
9
|
/**
|
|
12
10
|
* Root for a combobox. Provide `items` and compose with input, popup, list, and items.
|
|
13
11
|
*/
|
|
@@ -18,10 +16,10 @@ function ComboboxValue({ ...props }) {
|
|
|
18
16
|
return _jsx(ComboboxPrimitive.Value, { "data-slot": "combobox-value", ...props });
|
|
19
17
|
}
|
|
20
18
|
function ComboboxTrigger({ className, children, ...props }) {
|
|
21
|
-
return (_jsxs(ComboboxPrimitive.Trigger, { "data-slot": "combobox-trigger", className: cn("[&_svg:not([class*='size-'])]:size-4", className), ...props, children: [children, _jsx(
|
|
19
|
+
return (_jsxs(ComboboxPrimitive.Trigger, { "data-slot": "combobox-trigger", className: cn("[&_svg:not([class*='size-'])]:size-4", className), ...props, children: [children, _jsx(ChevronDown, { className: "pointer-events-none size-4 text-muted-foreground" })] }));
|
|
22
20
|
}
|
|
23
21
|
function ComboboxClear({ className, ...props }) {
|
|
24
|
-
return (_jsx(ComboboxPrimitive.Clear, { "data-slot": "combobox-clear", render: _jsx(InputGroupButton, { variant: "ghost", size: "icon-xs" }), className: cn(className), ...props, children: _jsx(
|
|
22
|
+
return (_jsx(ComboboxPrimitive.Clear, { "data-slot": "combobox-clear", render: _jsx(InputGroupButton, { variant: "ghost", size: "icon-xs" }), className: cn(className), ...props, children: _jsx(X, { className: "pointer-events-none" }) }));
|
|
25
23
|
}
|
|
26
24
|
function ComboboxInput({ className, children, disabled = false, showTrigger = true, showClear = false, ...props }) {
|
|
27
25
|
return (_jsxs(InputGroup, { className: cn('w-auto', className), children: [_jsx(ComboboxPrimitive.Input, { render: _jsx(InputGroupInput, { disabled: disabled }), ...props }), _jsxs(InputGroupAddon, { align: "inline-end", children: [showTrigger && (_jsx(InputGroupButton, { size: "icon-xs", variant: "ghost", render: _jsx(ComboboxTrigger, {}), "data-slot": "input-group-button", className: "group-has-data-[slot=combobox-clear]/input-group:hidden data-pressed:bg-transparent", disabled: disabled })), showClear && _jsx(ComboboxClear, { disabled: disabled })] }), children] }));
|
|
@@ -33,7 +31,7 @@ function ComboboxList({ className, ...props }) {
|
|
|
33
31
|
return (_jsx(ComboboxPrimitive.List, { "data-slot": "combobox-list", className: cn('no-scrollbar max-h-[min(calc(--spacing(72)---spacing(9)),calc(var(--available-height)---spacing(9)))] scroll-py-1 overflow-y-auto overscroll-contain p-1 data-empty:p-0', className), ...props }));
|
|
34
32
|
}
|
|
35
33
|
function ComboboxItem({ className, children, ...props }) {
|
|
36
|
-
return (_jsxs(ComboboxPrimitive.Item, { "data-slot": "combobox-item", className: cn("relative flex w-full cursor-default items-center gap-2 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground not-data-[variant=destructive]:data-highlighted:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className), ...props, children: [children, _jsx(ComboboxPrimitive.ItemIndicator, { render: _jsx("span", { className: "pointer-events-none absolute right-2 flex size-4 items-center justify-center" }), children: _jsx(
|
|
34
|
+
return (_jsxs(ComboboxPrimitive.Item, { "data-slot": "combobox-item", className: cn("relative flex w-full cursor-default items-center gap-2 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground not-data-[variant=destructive]:data-highlighted:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className), ...props, children: [children, _jsx(ComboboxPrimitive.ItemIndicator, { render: _jsx("span", { className: "pointer-events-none absolute right-2 flex size-4 items-center justify-center" }), children: _jsx(Check, { className: "pointer-events-none" }) })] }));
|
|
37
35
|
}
|
|
38
36
|
function ComboboxGroup({ className, ...props }) {
|
|
39
37
|
return _jsx(ComboboxPrimitive.Group, { "data-slot": "combobox-group", className: cn(className), ...props });
|
|
@@ -54,7 +52,7 @@ function ComboboxChips({ className, ...props }) {
|
|
|
54
52
|
return (_jsx(ComboboxPrimitive.Chips, { "data-slot": "combobox-chips", className: cn('flex min-h-8 flex-wrap items-center gap-1 rounded-lg border border-input bg-transparent bg-clip-padding px-2.5 py-1 text-sm transition-colors focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50 has-aria-invalid:border-destructive has-aria-invalid:ring-3 has-aria-invalid:ring-destructive/20 has-data-[slot=combobox-chip]:px-1 dark:bg-input/30 dark:has-aria-invalid:border-destructive/50 dark:has-aria-invalid:ring-destructive/40', className), ...props }));
|
|
55
53
|
}
|
|
56
54
|
function ComboboxChip({ className, children, showRemove = true, ...props }) {
|
|
57
|
-
return (_jsxs(ComboboxPrimitive.Chip, { "data-slot": "combobox-chip", className: cn('flex h-[calc(--spacing(5.25))] w-fit items-center justify-center gap-1 rounded-sm bg-muted px-1.5 text-xs font-medium whitespace-nowrap text-foreground has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50 has-data-[slot=combobox-chip-remove]:pr-0', className), ...props, children: [children, showRemove && (_jsx(ComboboxPrimitive.ChipRemove, { render: _jsx(Button, { variant: "ghost", size: "icon-xs" }), className: "-ml-1 opacity-50 hover:opacity-100", "data-slot": "combobox-chip-remove", children: _jsx(
|
|
55
|
+
return (_jsxs(ComboboxPrimitive.Chip, { "data-slot": "combobox-chip", className: cn('flex h-[calc(--spacing(5.25))] w-fit items-center justify-center gap-1 rounded-sm bg-muted px-1.5 text-xs font-medium whitespace-nowrap text-foreground has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50 has-data-[slot=combobox-chip-remove]:pr-0', className), ...props, children: [children, showRemove && (_jsx(ComboboxPrimitive.ChipRemove, { render: _jsx(Button, { variant: "ghost", size: "icon-xs" }), className: "-ml-1 opacity-50 hover:opacity-100", "data-slot": "combobox-chip-remove", children: _jsx(X, { className: "pointer-events-none" }) }))] }));
|
|
58
56
|
}
|
|
59
57
|
function ComboboxChipsInput({ className, ...props }) {
|
|
60
58
|
return _jsx(ComboboxPrimitive.Input, { "data-slot": "combobox-chip-input", className: cn('min-w-16 flex-1 outline-none', className), ...props });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../src/components/command/command.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../src/components/command/command.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,MAAM,CAAC;AAInD,OAAO,EAAE,MAAM,EAA+D,MAAM,WAAW,CAAC;AAGhG,gFAAgF;AAChF,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEzE,iBAAS,OAAO,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,YAAY,2CAQrD;AAED,qFAAqF;AACrF,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,MAAM,CAAC,EAAE,UA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,qBAAqB,2CAEvE;AAED,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC;AAElF,iBAAS,WAAW,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,gBAAgB,2CAcvE;AAED,MAAM,MAAM,oBAAoB,GAAG,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;AAEhE,iBAAS,eAAe,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,oBAAoB,2CAQrE;AAED,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { Command as CommandPrimitive } from 'cmdk';
|
|
5
|
-
import {
|
|
6
|
-
import { MagnifyingGlassIcon } from '@phosphor-icons/react/MagnifyingGlass';
|
|
5
|
+
import { Check, Search } from 'lucide-react';
|
|
7
6
|
import { cn } from '../../lib/utils';
|
|
8
7
|
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '../dialog';
|
|
9
8
|
import { InputGroup, InputGroupAddon } from '../input-group';
|
|
@@ -14,7 +13,7 @@ function CommandDialog({ title = 'Command Palette', description = 'Search for a
|
|
|
14
13
|
return (_jsxs(Dialog, { ...props, children: [_jsxs(DialogHeader, { className: "sr-only", children: [_jsx(DialogTitle, { children: title }), _jsx(DialogDescription, { children: description })] }), _jsx(DialogContent, { className: cn('top-1/3 translate-y-0 overflow-hidden rounded-xl! p-0', className), showCloseButton: showCloseButton, children: children })] }));
|
|
15
14
|
}
|
|
16
15
|
function CommandInput({ className, ...props }) {
|
|
17
|
-
return (_jsx("div", { "data-slot": "command-input-wrapper", className: "p-1 pb-0", children: _jsxs(InputGroup, { className: "h-8! rounded-lg! border-input/30 bg-input/30 shadow-none! *:data-[slot=input-group-addon]:pl-2!", children: [_jsx(CommandPrimitive.Input, { "data-slot": "command-input", className: cn('w-full text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50', className), ...props }), _jsx(InputGroupAddon, { children: _jsx(
|
|
16
|
+
return (_jsx("div", { "data-slot": "command-input-wrapper", className: "p-1 pb-0", children: _jsxs(InputGroup, { className: "h-8! rounded-lg! border-input/30 bg-input/30 shadow-none! *:data-[slot=input-group-addon]:pl-2!", children: [_jsx(CommandPrimitive.Input, { "data-slot": "command-input", className: cn('w-full text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50', className), ...props }), _jsx(InputGroupAddon, { children: _jsx(Search, { className: "size-4 shrink-0 opacity-50" }) })] }) }));
|
|
18
17
|
}
|
|
19
18
|
function CommandList({ className, ...props }) {
|
|
20
19
|
return (_jsx(CommandPrimitive.List, { "data-slot": "command-list", className: cn('no-scrollbar max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none', className), ...props }));
|
|
@@ -29,7 +28,7 @@ function CommandSeparator({ className, ...props }) {
|
|
|
29
28
|
return _jsx(CommandPrimitive.Separator, { "data-slot": "command-separator", className: cn('-mx-1 h-px bg-border', className), ...props });
|
|
30
29
|
}
|
|
31
30
|
function CommandItem({ className, children, ...props }) {
|
|
32
|
-
return (_jsxs(CommandPrimitive.Item, { "data-slot": "command-item", className: cn("group/command-item relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none in-data-[slot=dialog-content]:rounded-lg! data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-selected:bg-muted data-selected:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-selected:*:[svg]:text-foreground", className), ...props, children: [children, _jsx(
|
|
31
|
+
return (_jsxs(CommandPrimitive.Item, { "data-slot": "command-item", className: cn("group/command-item relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none in-data-[slot=dialog-content]:rounded-lg! data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-selected:bg-muted data-selected:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-selected:*:[svg]:text-foreground", className), ...props, children: [children, _jsx(Check, { className: "ml-auto opacity-0 group-has-data-[slot=command-shortcut]/command-item:hidden group-data-[checked=true]/command-item:opacity-100" })] }));
|
|
33
32
|
}
|
|
34
33
|
function CommandShortcut({ className, ...props }) {
|
|
35
34
|
return (_jsx("span", { "data-slot": "command-shortcut", className: cn('ml-auto text-xs tracking-widest text-muted-foreground group-data-selected/command-item:text-foreground', className), ...props }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-menu.d.ts","sourceRoot":"","sources":["../../../src/components/context-menu/context-menu.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,IAAI,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"context-menu.d.ts","sourceRoot":"","sources":["../../../src/components/context-menu/context-menu.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,IAAI,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAKlF,KAAK,+BAA+B,GAAG,IAAI,CAAC,oBAAoB,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,GAAG,MAAM,GAAG,YAAY,CAAC,CAAC;AAEpI,8GAA8G;AAC9G,KAAK,gBAAgB,GAAG,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC;AAExD,qCAAqC;AACrC,KAAK,sBAAsB,GAAG,oBAAoB,CAAC,MAAM,CAAC,KAAK,CAAC;AAEhE,wEAAwE;AAC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,EAAE,GAAG,KAAK,EAAE,EAAE,yBAAyB,2CAmBhG;AAED,iBAAS,oBAAoB,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,yBAAyB,2CAE/E;AAED,iBAAS,mBAAmB,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,wBAAwB,2CAQ7E;AAED,OAAO,EACH,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,uBAAuB,EACvB,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,GACxB,CAAC;AAEF,YAAY,EACR,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,0BAA0B,EAC1B,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,EACnB,0BAA0B,EAC1B,4BAA4B,EAC5B,0BAA0B,EAC1B,yBAAyB,EACzB,yBAAyB,EACzB,wBAAwB,GAC3B,CAAC"}
|
|
@@ -3,8 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { ContextMenu as ContextMenuPrimitive } from '@base-ui/react/context-menu';
|
|
5
5
|
import { cn } from '../../lib/utils';
|
|
6
|
-
import {
|
|
7
|
-
import { CheckIcon } from '@phosphor-icons/react/dist/ssr/Check';
|
|
6
|
+
import { Check, ChevronRight } from 'lucide-react';
|
|
8
7
|
function ContextMenu({ ...props }) {
|
|
9
8
|
return _jsx(ContextMenuPrimitive.Root, { "data-slot": "context-menu", ...props });
|
|
10
9
|
}
|
|
@@ -30,19 +29,19 @@ function ContextMenuSub({ ...props }) {
|
|
|
30
29
|
return _jsx(ContextMenuPrimitive.SubmenuRoot, { "data-slot": "context-menu-sub", ...props });
|
|
31
30
|
}
|
|
32
31
|
function ContextMenuSubTrigger({ className, inset, children, ...props }) {
|
|
33
|
-
return (_jsxs(ContextMenuPrimitive.SubmenuTrigger, { "data-slot": "context-menu-sub-trigger", "data-inset": inset, className: cn("flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className), ...props, children: [children, _jsx(
|
|
32
|
+
return (_jsxs(ContextMenuPrimitive.SubmenuTrigger, { "data-slot": "context-menu-sub-trigger", "data-inset": inset, className: cn("flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className), ...props, children: [children, _jsx(ChevronRight, { className: "ml-auto" })] }));
|
|
34
33
|
}
|
|
35
34
|
function ContextMenuSubContent({ ...props }) {
|
|
36
35
|
return _jsx(ContextMenuContent, { "data-slot": "context-menu-sub-content", className: "shadow-lg", side: "right", ...props });
|
|
37
36
|
}
|
|
38
37
|
function ContextMenuCheckboxItem({ className, children, checked, inset, ...props }) {
|
|
39
|
-
return (_jsxs(ContextMenuPrimitive.CheckboxItem, { "data-slot": "context-menu-checkbox-item", "data-inset": inset, className: cn("relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className), checked: checked, ...props, children: [_jsx("span", { className: "pointer-events-none absolute right-2", children: _jsx(ContextMenuPrimitive.CheckboxItemIndicator, { children: _jsx(
|
|
38
|
+
return (_jsxs(ContextMenuPrimitive.CheckboxItem, { "data-slot": "context-menu-checkbox-item", "data-inset": inset, className: cn("relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className), checked: checked, ...props, children: [_jsx("span", { className: "pointer-events-none absolute right-2", children: _jsx(ContextMenuPrimitive.CheckboxItemIndicator, { children: _jsx(Check, {}) }) }), children] }));
|
|
40
39
|
}
|
|
41
40
|
function ContextMenuRadioGroup({ ...props }) {
|
|
42
41
|
return _jsx(ContextMenuPrimitive.RadioGroup, { "data-slot": "context-menu-radio-group", ...props });
|
|
43
42
|
}
|
|
44
43
|
function ContextMenuRadioItem({ className, children, inset, ...props }) {
|
|
45
|
-
return (_jsxs(ContextMenuPrimitive.RadioItem, { "data-slot": "context-menu-radio-item", "data-inset": inset, className: cn("relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className), ...props, children: [_jsx("span", { className: "pointer-events-none absolute right-2", children: _jsx(ContextMenuPrimitive.RadioItemIndicator, { children: _jsx(
|
|
44
|
+
return (_jsxs(ContextMenuPrimitive.RadioItem, { "data-slot": "context-menu-radio-item", "data-inset": inset, className: cn("relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className), ...props, children: [_jsx("span", { className: "pointer-events-none absolute right-2", children: _jsx(ContextMenuPrimitive.RadioItemIndicator, { children: _jsx(Check, {}) }) }), children] }));
|
|
46
45
|
}
|
|
47
46
|
function ContextMenuSeparator({ className, ...props }) {
|
|
48
47
|
return _jsx(ContextMenuPrimitive.Separator, { "data-slot": "context-menu-separator", className: cn('-mx-1 my-1 h-px bg-border', className), ...props });
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type DateSelectorContextValue } from './date-selector-types';
|
|
2
|
+
declare const DateSelectorContext: import("react").Context<DateSelectorContextValue>;
|
|
3
|
+
/** Reads {@link DateSelectorContextValue} from a parent {@link DateSelector}. */
|
|
4
|
+
export declare const useDateSelectorContext: () => DateSelectorContextValue;
|
|
5
|
+
export { DateSelectorContext };
|
|
6
|
+
//# sourceMappingURL=date-selector-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-selector-context.d.ts","sourceRoot":"","sources":["../../../src/components/date-selector/date-selector-context.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,wBAAwB,EAA8B,MAAM,uBAAuB,CAAC;AAElG,QAAA,MAAM,mBAAmB,mDAIvB,CAAC;AAEH,iFAAiF;AACjF,eAAO,MAAM,sBAAsB,gCAAwC,CAAC;AAE5E,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { createContext, useContext } from 'react';
|
|
3
|
+
import { DEFAULT_DATE_SELECTOR_I18N } from './date-selector-types';
|
|
4
|
+
const DateSelectorContext = createContext({
|
|
5
|
+
i18n: DEFAULT_DATE_SELECTOR_I18N,
|
|
6
|
+
variant: 'outline',
|
|
7
|
+
size: 'default',
|
|
8
|
+
});
|
|
9
|
+
/** Reads {@link DateSelectorContextValue} from a parent {@link DateSelector}. */
|
|
10
|
+
export const useDateSelectorContext = () => useContext(DateSelectorContext);
|
|
11
|
+
export { DateSelectorContext };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { DateSelectorFilterType, DateSelectorPeriodType } from './date-selector-types';
|
|
2
|
+
interface DateSelectorFilterToggleProps {
|
|
3
|
+
value: DateSelectorFilterType;
|
|
4
|
+
onChange: (value: DateSelectorFilterType) => void;
|
|
5
|
+
showBetween?: boolean;
|
|
6
|
+
showIs?: boolean;
|
|
7
|
+
presetMode?: DateSelectorFilterType;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function DateSelectorFilterToggle({ value, onChange, showBetween, showIs, presetMode, className }: DateSelectorFilterToggleProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
interface DateSelectorPeriodTabsProps {
|
|
12
|
+
value: DateSelectorPeriodType;
|
|
13
|
+
onChange: (value: DateSelectorPeriodType) => void;
|
|
14
|
+
periodTypes?: DateSelectorPeriodType[];
|
|
15
|
+
className?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function DateSelectorPeriodTabs({ value, onChange, periodTypes, className }: DateSelectorPeriodTabsProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
interface DateSelectorDayPickerProps {
|
|
19
|
+
currentMonth: Date;
|
|
20
|
+
selectedDate?: Date;
|
|
21
|
+
selectedEndDate?: Date;
|
|
22
|
+
onDayClick: (day: Date) => void;
|
|
23
|
+
isRange: boolean;
|
|
24
|
+
onDayHover?: (day: Date | undefined) => void;
|
|
25
|
+
hoverDate?: Date;
|
|
26
|
+
showTwoMonths?: boolean;
|
|
27
|
+
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
28
|
+
onMonthChange?: (month: Date) => void;
|
|
29
|
+
className?: string;
|
|
30
|
+
}
|
|
31
|
+
export declare function DateSelectorDayPicker({ currentMonth, selectedDate, selectedEndDate, onDayClick, isRange, onDayHover, hoverDate, showTwoMonths, weekStartsOn, onMonthChange, className, }: DateSelectorDayPickerProps): import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
interface DateSelectorPeriodGridProps {
|
|
33
|
+
years: number[];
|
|
34
|
+
items: string[];
|
|
35
|
+
selectedYear?: number;
|
|
36
|
+
selectedValue?: number;
|
|
37
|
+
rangeStart?: {
|
|
38
|
+
year: number;
|
|
39
|
+
value: number;
|
|
40
|
+
};
|
|
41
|
+
rangeEnd?: {
|
|
42
|
+
year: number;
|
|
43
|
+
value: number;
|
|
44
|
+
};
|
|
45
|
+
isInRange: (year: number, value: number) => boolean;
|
|
46
|
+
onSelect: (year: number, value: number) => void;
|
|
47
|
+
columns: number;
|
|
48
|
+
className?: string;
|
|
49
|
+
}
|
|
50
|
+
export declare function DateSelectorPeriodGrid({ years, items, selectedYear, selectedValue, rangeStart, rangeEnd, isInRange, onSelect, columns, className, }: DateSelectorPeriodGridProps): import("react/jsx-runtime").JSX.Element;
|
|
51
|
+
interface DateSelectorYearListProps {
|
|
52
|
+
years: number[];
|
|
53
|
+
selectedYear?: number;
|
|
54
|
+
rangeStart?: {
|
|
55
|
+
year: number;
|
|
56
|
+
value: number;
|
|
57
|
+
};
|
|
58
|
+
rangeEnd?: {
|
|
59
|
+
year: number;
|
|
60
|
+
value: number;
|
|
61
|
+
};
|
|
62
|
+
isYearInRange: (year: number) => boolean;
|
|
63
|
+
onSelect: (year: number) => void;
|
|
64
|
+
className?: string;
|
|
65
|
+
}
|
|
66
|
+
export declare function DateSelectorYearList({ years, selectedYear, rangeStart, rangeEnd, isYearInRange, onSelect, className }: DateSelectorYearListProps): import("react/jsx-runtime").JSX.Element;
|
|
67
|
+
export {};
|
|
68
|
+
//# sourceMappingURL=date-selector-parts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-selector-parts.d.ts","sourceRoot":"","sources":["../../../src/components/date-selector/date-selector-parts.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE5F,UAAU,6BAA6B;IACnC,KAAK,EAAE,sBAAsB,CAAC;IAC9B,QAAQ,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,CAAC;I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AAK,OAAO,CAAC;IACzC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,oBAAoB,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,yBAAyB,2CAuBhJ"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
import { addMonths, isSameMonth, subMonths } from 'date-fns';
|
|
5
|
+
import { DayButton, getDefaultClassNames } from 'react-day-picker';
|
|
6
|
+
import { useIsMobile } from '../../hooks/use-mobile';
|
|
7
|
+
import { cn } from '../../lib/utils';
|
|
8
|
+
import { Button } from '../button';
|
|
9
|
+
import { Calendar, CalendarDayButton } from '../calendar';
|
|
10
|
+
import { Tabs, TabsList, TabsTrigger } from '../tabs';
|
|
11
|
+
import { ChevronLeft, ChevronRight, CornerUpLeft, CornerUpRight } from 'lucide-react';
|
|
12
|
+
import { useDateSelectorContext } from './date-selector-context';
|
|
13
|
+
export function DateSelectorFilterToggle({ value, onChange, showBetween = true, showIs = true, presetMode, className }) {
|
|
14
|
+
const { i18n } = useDateSelectorContext();
|
|
15
|
+
const isDisabled = presetMode !== undefined;
|
|
16
|
+
return (_jsx(Tabs, { className: cn('w-full', className), value: value, onValueChange: (newValue) => {
|
|
17
|
+
if (!isDisabled && newValue) {
|
|
18
|
+
onChange(newValue);
|
|
19
|
+
}
|
|
20
|
+
}, children: _jsxs(TabsList, { className: cn('flex h-9 w-full min-w-0 gap-1 bg-muted/80 p-[3px]', isDisabled && 'pointer-events-none opacity-50'), children: [showIs && (_jsx(TabsTrigger, { value: "is", "aria-label": i18n.filterTypes.is, className: "min-w-0 flex-1 px-1 py-1 text-center font-normal sm:px-2.5", children: i18n.filterTypes.is })), _jsx(TabsTrigger, { value: "before", "aria-label": i18n.filterTypes.before, className: "min-w-0 flex-1 px-1 py-1 text-center font-normal sm:px-2.5", children: i18n.filterTypes.before }), _jsx(TabsTrigger, { value: "after", "aria-label": i18n.filterTypes.after, className: "min-w-0 flex-1 px-1 py-1 text-center font-normal sm:px-2.5", children: i18n.filterTypes.after }), showBetween && (_jsx(TabsTrigger, { value: "between", "aria-label": i18n.filterTypes.between, className: "min-w-0 flex-1 px-1 py-1 text-center font-normal sm:px-2.5", children: i18n.filterTypes.between }))] }) }));
|
|
21
|
+
}
|
|
22
|
+
export function DateSelectorPeriodTabs({ value, onChange, periodTypes, className }) {
|
|
23
|
+
const { i18n } = useDateSelectorContext();
|
|
24
|
+
const tabs = [
|
|
25
|
+
{ value: 'day', label: i18n.periodTypes.day },
|
|
26
|
+
{ value: 'month', label: i18n.periodTypes.month },
|
|
27
|
+
{ value: 'quarter', label: i18n.periodTypes.quarter },
|
|
28
|
+
{ value: 'year', label: i18n.periodTypes.year },
|
|
29
|
+
];
|
|
30
|
+
return (_jsx("div", { className: cn('w-full', className), children: _jsx(Tabs, { className: "w-full", value: value, onValueChange: (newValue) => {
|
|
31
|
+
if (newValue) {
|
|
32
|
+
onChange(newValue);
|
|
33
|
+
}
|
|
34
|
+
}, children: _jsx(TabsList, { className: "flex h-9 w-full min-w-0 gap-1 bg-muted/80 p-[3px]", children: tabs.map((tab) => {
|
|
35
|
+
const disabled = Boolean(periodTypes?.length && !periodTypes.includes(tab.value));
|
|
36
|
+
return (_jsx(TabsTrigger, { value: tab.value, disabled: disabled, "aria-label": tab.label, className: "min-w-0 flex-1 px-1 py-1 text-center font-normal sm:px-2.5", children: tab.label }, tab.value));
|
|
37
|
+
}) }) }) }));
|
|
38
|
+
}
|
|
39
|
+
export function DateSelectorDayPicker({ currentMonth, selectedDate, selectedEndDate, onDayClick, isRange, onDayHover, hoverDate, showTwoMonths = false, weekStartsOn, onMonthChange, className, }) {
|
|
40
|
+
const { i18n } = useDateSelectorContext();
|
|
41
|
+
const isMobile = useIsMobile();
|
|
42
|
+
const selected = isRange
|
|
43
|
+
? selectedDate && selectedEndDate
|
|
44
|
+
? { from: selectedDate, to: selectedEndDate }
|
|
45
|
+
: selectedDate
|
|
46
|
+
? { from: selectedDate, to: hoverDate || selectedDate }
|
|
47
|
+
: undefined
|
|
48
|
+
: selectedDate;
|
|
49
|
+
const handleSelect = (date) => {
|
|
50
|
+
if (!date) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (isRange && 'from' in date) {
|
|
54
|
+
if (date.from && !date.to) {
|
|
55
|
+
onDayClick(date.from);
|
|
56
|
+
}
|
|
57
|
+
else if (date.from && date.to) {
|
|
58
|
+
onDayClick(date.to);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else if (!isRange && date instanceof Date) {
|
|
62
|
+
onDayClick(date);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const CustomDayButton = useCallback((props) => {
|
|
66
|
+
return (_jsx(CalendarDayButton, { ...props, onMouseEnter: () => {
|
|
67
|
+
if (isRange && onDayHover && props.day) {
|
|
68
|
+
onDayHover(props.day.date);
|
|
69
|
+
}
|
|
70
|
+
}, onMouseLeave: () => {
|
|
71
|
+
if (isRange && onDayHover) {
|
|
72
|
+
onDayHover(undefined);
|
|
73
|
+
}
|
|
74
|
+
} }));
|
|
75
|
+
}, [isRange, onDayHover]);
|
|
76
|
+
const formatters = {
|
|
77
|
+
formatWeekdayName: (date) => {
|
|
78
|
+
const dayIndex = date.getDay();
|
|
79
|
+
return i18n.weekdaysShort[dayIndex] || i18n.weekdays[dayIndex];
|
|
80
|
+
},
|
|
81
|
+
formatMonthCaption: (date) => {
|
|
82
|
+
const monthIndex = date.getMonth();
|
|
83
|
+
const year = date.getFullYear();
|
|
84
|
+
return `${i18n.months[monthIndex]} ${year}`;
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
const monthCount = isMobile ? 1 : showTwoMonths ? 2 : 1;
|
|
88
|
+
const secondMonth = addMonths(currentMonth, 1);
|
|
89
|
+
const captionClass = 'truncate text-center text-sm font-medium';
|
|
90
|
+
const monthNavRow = onMonthChange && (_jsxs("div", { className: "flex w-full min-w-0 items-center gap-2 pb-2", children: [_jsx(Button, { type: "button", variant: "ghost", className: "size-8.5 shrink-0", onClick: () => onMonthChange(subMonths(currentMonth, 1)), "aria-label": "Previous month", children: _jsx(ChevronLeft, { className: "size-4" }) }), monthCount === 2 ? (_jsxs(_Fragment, { children: [_jsx("div", { className: cn(captionClass, 'min-w-0 flex-1'), children: formatters.formatMonthCaption(currentMonth) }), _jsx("div", { className: cn(captionClass, 'min-w-0 flex-1'), children: formatters.formatMonthCaption(secondMonth) })] })) : (_jsx("div", { className: cn(captionClass, 'min-w-0 flex-1'), children: formatters.formatMonthCaption(currentMonth) })), _jsx(Button, { type: "button", variant: "ghost", className: "size-8.5 shrink-0", onClick: () => onMonthChange(addMonths(currentMonth, 1)), "aria-label": "Next month", children: _jsx(ChevronRight, { className: "size-4" }) }), (() => {
|
|
91
|
+
const today = new Date();
|
|
92
|
+
if (isSameMonth(currentMonth, today))
|
|
93
|
+
return null;
|
|
94
|
+
const isFuture = currentMonth > today;
|
|
95
|
+
return (_jsx(Button, { type: "button", variant: "ghost", className: "size-8.5 shrink-0", onClick: () => onMonthChange(new Date()), title: i18n.today, children: isFuture ? _jsx(CornerUpLeft, { className: "size-4" }) : _jsx(CornerUpRight, { className: "size-4" }) }));
|
|
96
|
+
})()] }));
|
|
97
|
+
const rdpClassNames = getDefaultClassNames();
|
|
98
|
+
const calendarClassNames = {
|
|
99
|
+
root: cn('w-full min-w-0', rdpClassNames.root),
|
|
100
|
+
months: 'flex flex-wrap items-start justify-between gap-5 w-full',
|
|
101
|
+
month: cn('flex w-full min-w-0 flex-1 flex-col items-center', rdpClassNames.month),
|
|
102
|
+
month_grid: cn('w-full min-w-0 border-collapse', rdpClassNames.month_grid),
|
|
103
|
+
nav: 'hidden',
|
|
104
|
+
month_caption: 'hidden',
|
|
105
|
+
};
|
|
106
|
+
return (_jsxs("div", { className: cn('flex w-full flex-col', className), children: [monthNavRow, isRange ? (_jsx(Calendar, { month: currentMonth, mode: "range", selected: selected, onSelect: handleSelect, numberOfMonths: monthCount, showOutsideDays: true, weekStartsOn: weekStartsOn, formatters: formatters, className: "w-full shrink-0 p-0", classNames: calendarClassNames, components: {
|
|
107
|
+
DayButton: CustomDayButton,
|
|
108
|
+
} })) : (_jsx(Calendar, { month: currentMonth, mode: "single", selected: selected, onSelect: handleSelect, numberOfMonths: monthCount, showOutsideDays: true, weekStartsOn: weekStartsOn, formatters: formatters, className: "w-full shrink-0 p-0", classNames: calendarClassNames, components: {
|
|
109
|
+
DayButton: CustomDayButton,
|
|
110
|
+
} }))] }));
|
|
111
|
+
}
|
|
112
|
+
export function DateSelectorPeriodGrid({ years, items, selectedYear, selectedValue, rangeStart, rangeEnd, isInRange, onSelect, columns, className, }) {
|
|
113
|
+
return (_jsx("div", { className: cn('w-full space-y-6', className), children: years.map((year) => (_jsxs("div", { children: [_jsx("div", { className: "sticky top-0 z-10 w-full bg-background py-1 text-center text-sm font-medium text-muted-foreground", children: year }), _jsx("div", { className: "grid gap-2", style: {
|
|
114
|
+
gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))`,
|
|
115
|
+
}, children: items.map((item, index) => {
|
|
116
|
+
const isSelected = selectedYear === year && selectedValue === index;
|
|
117
|
+
const isRangeStart = rangeStart?.year === year && rangeStart?.value === index;
|
|
118
|
+
const isRangeEnd = rangeEnd?.year === year && rangeEnd?.value === index;
|
|
119
|
+
const inRange = isInRange(year, index);
|
|
120
|
+
return (_jsx(Button, { size: "sm", variant: isSelected || isRangeStart || isRangeEnd ? 'default' : 'outline', className: cn(inRange && !isSelected && !isRangeStart && !isRangeEnd && 'bg-accent dark:bg-accent/60'), onClick: () => onSelect(year, index), children: item }, item));
|
|
121
|
+
}) })] }, year))) }));
|
|
122
|
+
}
|
|
123
|
+
export function DateSelectorYearList({ years, selectedYear, rangeStart, rangeEnd, isYearInRange, onSelect, className }) {
|
|
124
|
+
return (_jsx("div", { className: cn('grid grid-cols-2 gap-2', className), children: years.map((year) => {
|
|
125
|
+
const isSelected = selectedYear === year && !rangeStart && !rangeEnd;
|
|
126
|
+
const isRangeStart = rangeStart?.year === year;
|
|
127
|
+
const isRangeEnd = rangeEnd?.year === year;
|
|
128
|
+
const inRange = isYearInRange(year);
|
|
129
|
+
return (_jsx(Button, { size: "sm", variant: isSelected || isRangeStart || isRangeEnd ? 'default' : 'outline', className: cn(inRange && !isSelected && !isRangeStart && !isRangeEnd && 'bg-accent dark:bg-accent/60'), onClick: () => onSelect(year), children: year }, year));
|
|
130
|
+
}) }));
|
|
131
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/** Strings and labels for all UI copy in {@link DateSelector}; override partially via {@link DateSelectorProps.i18n}. */
|
|
2
|
+
export interface DateSelectorI18nConfig {
|
|
3
|
+
selectDate: string;
|
|
4
|
+
apply: string;
|
|
5
|
+
cancel: string;
|
|
6
|
+
clear: string;
|
|
7
|
+
today: string;
|
|
8
|
+
filterTypes: {
|
|
9
|
+
is: string;
|
|
10
|
+
before: string;
|
|
11
|
+
after: string;
|
|
12
|
+
between: string;
|
|
13
|
+
};
|
|
14
|
+
periodTypes: {
|
|
15
|
+
day: string;
|
|
16
|
+
month: string;
|
|
17
|
+
quarter: string;
|
|
18
|
+
year: string;
|
|
19
|
+
};
|
|
20
|
+
months: string[];
|
|
21
|
+
monthsShort: string[];
|
|
22
|
+
quarters: string[];
|
|
23
|
+
weekdays: string[];
|
|
24
|
+
weekdaysShort: string[];
|
|
25
|
+
placeholder: string;
|
|
26
|
+
rangePlaceholder: string;
|
|
27
|
+
rollingWindowTabs: {
|
|
28
|
+
next: string;
|
|
29
|
+
last: string;
|
|
30
|
+
custom: string;
|
|
31
|
+
};
|
|
32
|
+
rollingSummaryNext: string;
|
|
33
|
+
rollingSummaryLast: string;
|
|
34
|
+
rollingDaysChip: string;
|
|
35
|
+
}
|
|
36
|
+
/** Default English copy for {@link DateSelector}. */
|
|
37
|
+
export declare const DEFAULT_DATE_SELECTOR_I18N: DateSelectorI18nConfig;
|
|
38
|
+
export type DateSelectorPeriodType = 'day' | 'month' | 'quarter' | 'year';
|
|
39
|
+
export type DateSelectorFilterType = 'is' | 'before' | 'after' | 'between';
|
|
40
|
+
export declare const DATE_SELECTOR_ROLLING_DAY_OPTIONS: readonly [3, 7, 14, 30, 60, 90, 180, 365];
|
|
41
|
+
export type DateSelectorRollingDays = (typeof DATE_SELECTOR_ROLLING_DAY_OPTIONS)[number];
|
|
42
|
+
export type DateSelectorSelectionMode = 'custom' | 'rolling-next' | 'rolling-last';
|
|
43
|
+
/** Canonical value emitted by {@link DateSelector} and {@link useDateSelector}; shape depends on `period` and `operator`. */
|
|
44
|
+
export interface DateSelectorValue {
|
|
45
|
+
period: DateSelectorPeriodType;
|
|
46
|
+
operator: DateSelectorFilterType;
|
|
47
|
+
selectionMode?: DateSelectorSelectionMode;
|
|
48
|
+
rollingDays?: DateSelectorRollingDays;
|
|
49
|
+
startDate?: Date;
|
|
50
|
+
endDate?: Date;
|
|
51
|
+
year?: number;
|
|
52
|
+
month?: number;
|
|
53
|
+
quarter?: number;
|
|
54
|
+
rangeStart?: {
|
|
55
|
+
year: number;
|
|
56
|
+
value: number;
|
|
57
|
+
};
|
|
58
|
+
rangeEnd?: {
|
|
59
|
+
year: number;
|
|
60
|
+
value: number;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/** Context passed to subcomponents (variant/size/i18n) from {@link DateSelector}. */
|
|
64
|
+
export interface DateSelectorContextValue {
|
|
65
|
+
i18n: DateSelectorI18nConfig;
|
|
66
|
+
variant: 'outline' | 'default';
|
|
67
|
+
size: 'sm' | 'default' | 'lg';
|
|
68
|
+
}
|
|
69
|
+
/** Options for {@link useDateSelector} (headless state); mirrors the core props of {@link DateSelector} without UI. */
|
|
70
|
+
export interface UseDateSelectorOptions {
|
|
71
|
+
value?: DateSelectorValue;
|
|
72
|
+
onChange?: (value: DateSelectorValue) => void;
|
|
73
|
+
defaultPeriodType?: DateSelectorPeriodType;
|
|
74
|
+
defaultFilterType?: DateSelectorFilterType;
|
|
75
|
+
presetMode?: DateSelectorFilterType;
|
|
76
|
+
allowRange?: boolean;
|
|
77
|
+
yearRange?: number;
|
|
78
|
+
baseYear?: number;
|
|
79
|
+
minYear?: number;
|
|
80
|
+
maxYear?: number;
|
|
81
|
+
yearOptions?: readonly number[];
|
|
82
|
+
periodTypes?: DateSelectorPeriodType[];
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Props for the full {@link DateSelector} UI (filter toggles, optional text input, period tabs, and picker surface).
|
|
86
|
+
*
|
|
87
|
+
* **Data model:** `DateSelectorValue` is the emitted filter (period × operator × selection). When `value` is passed,
|
|
88
|
+
* the hook stays in sync via a derived sync key (controlled). When `value` is omitted, state is internal
|
|
89
|
+
* (uncontrolled); typed input still calls `onChange` and, for uncontrolled usage, updates the hook via
|
|
90
|
+
* `syncInternalFromParsedValue`.
|
|
91
|
+
*/
|
|
92
|
+
export interface DateSelectorProps {
|
|
93
|
+
value?: DateSelectorValue;
|
|
94
|
+
onChange?: (value: DateSelectorValue) => void;
|
|
95
|
+
allowRange?: boolean;
|
|
96
|
+
periodTypes?: DateSelectorPeriodType[];
|
|
97
|
+
defaultPeriodType?: DateSelectorPeriodType;
|
|
98
|
+
defaultFilterType?: DateSelectorFilterType;
|
|
99
|
+
presetMode?: DateSelectorFilterType;
|
|
100
|
+
showInput?: boolean;
|
|
101
|
+
showOperators?: boolean;
|
|
102
|
+
showTwoMonths?: boolean;
|
|
103
|
+
label?: string;
|
|
104
|
+
className?: string;
|
|
105
|
+
yearRange?: number;
|
|
106
|
+
baseYear?: number;
|
|
107
|
+
minYear?: number;
|
|
108
|
+
maxYear?: number;
|
|
109
|
+
yearOptions?: readonly number[];
|
|
110
|
+
i18n?: Partial<DateSelectorI18nConfig>;
|
|
111
|
+
inputHint?: string;
|
|
112
|
+
dayDateFormat?: string;
|
|
113
|
+
dayDateFormats?: string[];
|
|
114
|
+
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
115
|
+
showRollingPresets?: boolean;
|
|
116
|
+
rollingDayOptions?: readonly DateSelectorRollingDays[];
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=date-selector-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-selector-types.d.ts","sourceRoot":"","sources":["../../../src/components/date-selector/date-selector-types.ts"],"names":[],"mappings":"AAAA,yHAAyH;AACzH,MAAM,WAAW,sBAAsB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE;QACT,EAAE,EAAE,MAAM,CAAC;QACX,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,WAAW,EAAE;QACT,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,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AAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,IAAI,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACzC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,iBAAiB,CAAC,EAAE,SAAS,uBAAuB,EAAE,CAAC;CAC1D"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Default English copy for {@link DateSelector}. */
|
|
2
|
+
export const DEFAULT_DATE_SELECTOR_I18N = {
|
|
3
|
+
selectDate: 'Select date',
|
|
4
|
+
apply: 'Apply',
|
|
5
|
+
cancel: 'Cancel',
|
|
6
|
+
clear: 'Clear',
|
|
7
|
+
today: 'Today',
|
|
8
|
+
filterTypes: {
|
|
9
|
+
is: 'is',
|
|
10
|
+
before: 'before',
|
|
11
|
+
after: 'after',
|
|
12
|
+
between: 'between',
|
|
13
|
+
},
|
|
14
|
+
periodTypes: {
|
|
15
|
+
day: 'Day',
|
|
16
|
+
month: 'Month',
|
|
17
|
+
quarter: 'Quarter',
|
|
18
|
+
year: 'Year',
|
|
19
|
+
},
|
|
20
|
+
months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
|
|
21
|
+
monthsShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
|
|
22
|
+
quarters: ['Q1', 'Q2', 'Q3', 'Q4'],
|
|
23
|
+
weekdays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
|
|
24
|
+
weekdaysShort: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
|
|
25
|
+
placeholder: 'Select date...',
|
|
26
|
+
rangePlaceholder: 'Select date range...',
|
|
27
|
+
rollingWindowTabs: { next: 'Next', last: 'Last', custom: 'Custom' },
|
|
28
|
+
rollingSummaryNext: 'Next {{count}} days',
|
|
29
|
+
rollingSummaryLast: 'Last {{count}} days',
|
|
30
|
+
rollingDaysChip: '{{count}} days',
|
|
31
|
+
};
|
|
32
|
+
export const DATE_SELECTOR_ROLLING_DAY_OPTIONS = [3, 7, 14, 30, 60, 90, 180, 365];
|