@shipfox/react-ui 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +6 -6
- package/.turbo/turbo-check.log +2 -2
- package/.turbo/turbo-type.log +1 -1
- package/CHANGELOG.md +6 -0
- package/dist/components/calendar/calendar.d.ts +5 -0
- package/dist/components/calendar/calendar.d.ts.map +1 -0
- package/dist/components/calendar/calendar.js +46 -0
- package/dist/components/calendar/calendar.js.map +1 -0
- package/dist/components/calendar/index.d.ts +2 -0
- package/dist/components/calendar/index.d.ts.map +1 -0
- package/dist/components/calendar/index.js +3 -0
- package/dist/components/calendar/index.js.map +1 -0
- package/dist/components/date-picker/date-picker.d.ts +19 -0
- package/dist/components/date-picker/date-picker.d.ts.map +1 -0
- package/dist/components/date-picker/date-picker.js +114 -0
- package/dist/components/date-picker/date-picker.js.map +1 -0
- package/dist/components/date-picker/date-picker.stories.js +333 -0
- package/dist/components/date-picker/date-picker.stories.js.map +1 -0
- package/dist/components/date-picker/index.d.ts +2 -0
- package/dist/components/date-picker/index.d.ts.map +1 -0
- package/dist/components/date-picker/index.js +3 -0
- package/dist/components/date-picker/index.js.map +1 -0
- package/dist/components/date-time-range-picker/date-time-range-picker.d.ts +24 -0
- package/dist/components/date-time-range-picker/date-time-range-picker.d.ts.map +1 -0
- package/dist/components/date-time-range-picker/date-time-range-picker.js +130 -0
- package/dist/components/date-time-range-picker/date-time-range-picker.js.map +1 -0
- package/dist/components/date-time-range-picker/index.d.ts +2 -0
- package/dist/components/date-time-range-picker/index.d.ts.map +1 -0
- package/dist/components/date-time-range-picker/index.js +3 -0
- package/dist/components/date-time-range-picker/index.js.map +1 -0
- 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/index.js.map +1 -1
- package/dist/components/inline-tips/inline-tips.stories.js +5 -0
- package/dist/components/inline-tips/inline-tips.stories.js.map +1 -1
- package/dist/components/item/item.stories.js +15 -8
- package/dist/components/item/item.stories.js.map +1 -1
- package/dist/components/modal/modal.stories.js +14 -6
- package/dist/components/modal/modal.stories.js.map +1 -1
- package/dist/components/popover/index.d.ts +2 -0
- package/dist/components/popover/index.d.ts.map +1 -0
- package/dist/components/popover/index.js +3 -0
- package/dist/components/popover/index.js.map +1 -0
- package/dist/components/popover/popover.d.ts +10 -0
- package/dist/components/popover/popover.d.ts.map +1 -0
- package/dist/components/popover/popover.js +47 -0
- package/dist/components/popover/popover.js.map +1 -0
- package/dist/components/textarea/textarea.stories.js +8 -2
- package/dist/components/textarea/textarea.stories.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/components/calendar/calendar.tsx +90 -0
- package/src/components/calendar/index.ts +1 -0
- package/src/components/date-picker/date-picker.stories.tsx +230 -0
- package/src/components/date-picker/date-picker.tsx +179 -0
- package/src/components/date-picker/index.ts +1 -0
- package/src/components/date-time-range-picker/date-time-range-picker.tsx +211 -0
- package/src/components/date-time-range-picker/index.ts +1 -0
- package/src/components/index.ts +4 -0
- package/src/components/inline-tips/inline-tips.stories.tsx +5 -0
- package/src/components/item/item.stories.tsx +65 -56
- package/src/components/modal/modal.stories.tsx +16 -6
- package/src/components/popover/index.ts +1 -0
- package/src/components/popover/popover.tsx +60 -0
- package/src/components/textarea/textarea.stories.tsx +8 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
WARN Issue while reading "/runner/_work/tooling/tooling/.npmrc". Failed to replace env in config: ${NPM_ACCESS_TOKEN}
|
|
2
2
|
|
|
3
|
-
> @shipfox/react-ui@0.
|
|
3
|
+
> @shipfox/react-ui@0.12.0 build /runner/_work/tooling/tooling/libs/react/ui
|
|
4
4
|
> swc && pnpm run build:css
|
|
5
5
|
|
|
6
|
-
Successfully compiled:
|
|
6
|
+
Successfully compiled: 132 files with swc (442.91ms)
|
|
7
7
|
WARN Issue while reading "/runner/_work/tooling/tooling/.npmrc". Failed to replace env in config: ${NPM_ACCESS_TOKEN}
|
|
8
8
|
|
|
9
|
-
> @shipfox/react-ui@0.
|
|
9
|
+
> @shipfox/react-ui@0.12.0 build:css /runner/_work/tooling/tooling/libs/react/ui
|
|
10
10
|
> vite build --config vite.css.config.ts && rm -f dist/css-entry.js dist/css-entry.js.map
|
|
11
11
|
|
|
12
|
-
[36mvite v7.2.
|
|
12
|
+
[36mvite v7.2.7 [32mbuilding client environment for production...[36m[39m
|
|
13
13
|
transforming...
|
|
14
14
|
[32m✓[39m 2 modules transformed.
|
|
15
15
|
rendering chunks...
|
|
16
16
|
computing gzip size...
|
|
17
|
-
[2mdist/[22m[35mstyles.css [39m[1m[
|
|
17
|
+
[2mdist/[22m[35mstyles.css [39m[1m[2m91.82 kB[22m[1m[22m[2m │ gzip: 14.49 kB[22m
|
|
18
18
|
[2mdist/[22m[36mcss-entry.js [39m[1m[2m 0.00 kB[22m[1m[22m[2m │ gzip: 0.02 kB[22m
|
|
19
|
-
[32m✓ built in
|
|
19
|
+
[32m✓ built in 616ms[39m
|
package/.turbo/turbo-check.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
WARN Issue while reading "/runner/_work/tooling/tooling/.npmrc". Failed to replace env in config: ${NPM_ACCESS_TOKEN}
|
|
2
2
|
|
|
3
|
-
> @shipfox/react-ui@0.
|
|
3
|
+
> @shipfox/react-ui@0.12.0 check /runner/_work/tooling/tooling/libs/react/ui
|
|
4
4
|
> biome-check --fix
|
|
5
5
|
|
|
6
|
-
Checked
|
|
6
|
+
Checked 151 files in 277ms. No fixes applied.
|
package/.turbo/turbo-type.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
WARN Issue while reading "/runner/_work/tooling/tooling/.npmrc". Failed to replace env in config: ${NPM_ACCESS_TOKEN}
|
|
2
2
|
|
|
3
|
-
> @shipfox/react-ui@0.
|
|
3
|
+
> @shipfox/react-ui@0.12.0 type /runner/_work/tooling/tooling/libs/react/ui
|
|
4
4
|
> tsc-emit
|
|
5
5
|
|
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
|
+
import { DayPicker } from 'react-day-picker';
|
|
3
|
+
export type CalendarProps = ComponentProps<typeof DayPicker>;
|
|
4
|
+
export declare function Calendar({ className, classNames, showOutsideDays, ...props }: CalendarProps): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
//# sourceMappingURL=calendar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../../../src/components/calendar/calendar.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAG3C,MAAM,MAAM,aAAa,GAAG,cAAc,CAAC,OAAO,SAAS,CAAC,CAAC;AAE7D,wBAAgB,QAAQ,CAAC,EAAC,SAAS,EAAE,UAAU,EAAE,eAAsB,EAAE,GAAG,KAAK,EAAC,EAAE,aAAa,2CAkFhG"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Icon } from '../../components/icon/index.js';
|
|
3
|
+
import { DayPicker } from 'react-day-picker';
|
|
4
|
+
import { cn } from '../../utils/cn.js';
|
|
5
|
+
export function Calendar({ className, classNames, showOutsideDays = true, ...props }) {
|
|
6
|
+
return /*#__PURE__*/ _jsx(DayPicker, {
|
|
7
|
+
showOutsideDays: showOutsideDays,
|
|
8
|
+
className: cn('p-16 transition-colors', className),
|
|
9
|
+
classNames: {
|
|
10
|
+
months: 'flex flex-col sm:flex-row gap-24',
|
|
11
|
+
month: 'space-y-16 relative',
|
|
12
|
+
month_caption: 'flex items-center justify-center mb-8 px-4 relative h-32',
|
|
13
|
+
caption_label: 'text-sm font-medium text-foreground-neutral-base',
|
|
14
|
+
nav: 'flex items-center gap-4 fixed left-0 top-16 w-full z-10',
|
|
15
|
+
button_previous: cn('size-32 bg-transparent p-0 absolute left-16 top-0', 'inline-flex items-center justify-center rounded-6', 'text-foreground-neutral-base', 'hover:bg-background-button-transparent-hover', 'active:bg-background-button-transparent-pressed', 'transition-colors outline-none', 'focus-visible:shadow-border-interactive-with-active', 'disabled:pointer-events-none disabled:opacity-50'),
|
|
16
|
+
button_next: cn('size-32 bg-transparent p-0 absolute right-16 top-0', 'inline-flex items-center justify-center rounded-6', 'text-foreground-neutral-base', 'hover:bg-background-button-transparent-hover', 'active:bg-background-button-transparent-pressed', 'transition-colors outline-none', 'focus-visible:shadow-border-interactive-with-active', 'disabled:pointer-events-none disabled:opacity-50'),
|
|
17
|
+
month_grid: 'w-full border-collapse mt-8',
|
|
18
|
+
weekdays: 'flex mb-8',
|
|
19
|
+
weekday: 'text-foreground-neutral-subtle text-xs font-medium w-36 h-32 flex items-center justify-center',
|
|
20
|
+
week: 'flex mt-4',
|
|
21
|
+
day: cn('relative text-center size-36 p-0 text-sm font-normal [&:last-child[data-selected=true]_button]:rounded-r-md group/day aspect-square select-none', '[&:last-child[data-selected=true]_button]:rounded-r-6', props.showWeekNumber ? '[&:nth-child(2)[data-selected=true]_button]:rounded-l-6' : '[&:first-child[data-selected=true]_button]:rounded-l-6'),
|
|
22
|
+
day_button: cn('size-36 p-0 text-sm font-normal rounded-6', 'inline-flex items-center justify-center', 'hover:bg-background-button-transparent-hover', 'focus-visible:shadow-border-interactive-with-active', 'transition-colors outline-none', 'aria-selected:opacity-100'),
|
|
23
|
+
range_start: 'day-range-start rounded-6',
|
|
24
|
+
range_end: 'day-range-end rounded-6',
|
|
25
|
+
selected: cn('bg-foreground-highlight-interactive/80 !text-foreground-neutral-base font-medium rounded-6', 'hover:bg-foreground-highlight-interactive-hover/80', 'focus:bg-foreground-highlight-interactive/80'),
|
|
26
|
+
today: cn('bg-background-field-base text-foreground-neutral-base font-medium rounded-6', 'border border-border-neutral-base'),
|
|
27
|
+
outside: 'day-outside text-foreground-neutral-muted',
|
|
28
|
+
disabled: 'text-foreground-neutral-disabled opacity-30 cursor-not-allowed',
|
|
29
|
+
range_middle: cn('aria-selected:bg-foreground-highlight-interactive/10 aria-selected:text-foreground-neutral-base', 'rounded-none', 'first:rounded-l-6 first:rounded-r-none', 'last:rounded-r-6 last:rounded-l-none'),
|
|
30
|
+
hidden: 'invisible',
|
|
31
|
+
...classNames
|
|
32
|
+
},
|
|
33
|
+
components: {
|
|
34
|
+
Chevron: ({ orientation })=>{
|
|
35
|
+
const iconName = orientation === 'left' ? 'arrowLeftSLine' : 'arrowRightSLine';
|
|
36
|
+
return /*#__PURE__*/ _jsx(Icon, {
|
|
37
|
+
name: iconName,
|
|
38
|
+
className: "size-20"
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
...props
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=calendar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/calendar/calendar.tsx"],"sourcesContent":["import {Icon} from 'components/icon';\nimport type {ComponentProps} from 'react';\nimport {DayPicker} from 'react-day-picker';\nimport {cn} from 'utils/cn';\n\nexport type CalendarProps = ComponentProps<typeof DayPicker>;\n\nexport function Calendar({className, classNames, showOutsideDays = true, ...props}: CalendarProps) {\n return (\n <DayPicker\n showOutsideDays={showOutsideDays}\n className={cn('p-16 transition-colors', className)}\n classNames={{\n months: 'flex flex-col sm:flex-row gap-24',\n month: 'space-y-16 relative',\n month_caption: 'flex items-center justify-center mb-8 px-4 relative h-32',\n caption_label: 'text-sm font-medium text-foreground-neutral-base',\n nav: 'flex items-center gap-4 fixed left-0 top-16 w-full z-10',\n button_previous: cn(\n 'size-32 bg-transparent p-0 absolute left-16 top-0',\n 'inline-flex items-center justify-center rounded-6',\n 'text-foreground-neutral-base',\n 'hover:bg-background-button-transparent-hover',\n 'active:bg-background-button-transparent-pressed',\n 'transition-colors outline-none',\n 'focus-visible:shadow-border-interactive-with-active',\n 'disabled:pointer-events-none disabled:opacity-50',\n ),\n button_next: cn(\n 'size-32 bg-transparent p-0 absolute right-16 top-0',\n 'inline-flex items-center justify-center rounded-6',\n 'text-foreground-neutral-base',\n 'hover:bg-background-button-transparent-hover',\n 'active:bg-background-button-transparent-pressed',\n 'transition-colors outline-none',\n 'focus-visible:shadow-border-interactive-with-active',\n 'disabled:pointer-events-none disabled:opacity-50',\n ),\n month_grid: 'w-full border-collapse mt-8',\n weekdays: 'flex mb-8',\n weekday:\n 'text-foreground-neutral-subtle text-xs font-medium w-36 h-32 flex items-center justify-center',\n week: 'flex mt-4',\n day: cn(\n 'relative text-center size-36 p-0 text-sm font-normal [&:last-child[data-selected=true]_button]:rounded-r-md group/day aspect-square select-none',\n '[&:last-child[data-selected=true]_button]:rounded-r-6',\n props.showWeekNumber\n ? '[&:nth-child(2)[data-selected=true]_button]:rounded-l-6'\n : '[&:first-child[data-selected=true]_button]:rounded-l-6',\n ),\n day_button: cn(\n 'size-36 p-0 text-sm font-normal rounded-6',\n 'inline-flex items-center justify-center',\n 'hover:bg-background-button-transparent-hover',\n 'focus-visible:shadow-border-interactive-with-active',\n 'transition-colors outline-none',\n 'aria-selected:opacity-100',\n ),\n range_start: 'day-range-start rounded-6',\n range_end: 'day-range-end rounded-6',\n selected: cn(\n 'bg-foreground-highlight-interactive/80 !text-foreground-neutral-base font-medium rounded-6',\n 'hover:bg-foreground-highlight-interactive-hover/80',\n 'focus:bg-foreground-highlight-interactive/80',\n ),\n today: cn(\n 'bg-background-field-base text-foreground-neutral-base font-medium rounded-6',\n 'border border-border-neutral-base',\n ),\n outside: 'day-outside text-foreground-neutral-muted',\n disabled: 'text-foreground-neutral-disabled opacity-30 cursor-not-allowed',\n range_middle: cn(\n 'aria-selected:bg-foreground-highlight-interactive/10 aria-selected:text-foreground-neutral-base',\n 'rounded-none',\n 'first:rounded-l-6 first:rounded-r-none',\n 'last:rounded-r-6 last:rounded-l-none',\n ),\n hidden: 'invisible',\n ...classNames,\n }}\n components={{\n Chevron: ({orientation}) => {\n const iconName = orientation === 'left' ? 'arrowLeftSLine' : 'arrowRightSLine';\n return <Icon name={iconName} className=\"size-20\" />;\n },\n }}\n {...props}\n />\n );\n}\n"],"names":["Icon","DayPicker","cn","Calendar","className","classNames","showOutsideDays","props","months","month","month_caption","caption_label","nav","button_previous","button_next","month_grid","weekdays","weekday","week","day","showWeekNumber","day_button","range_start","range_end","selected","today","outside","disabled","range_middle","hidden","components","Chevron","orientation","iconName","name"],"mappings":";AAAA,SAAQA,IAAI,QAAO,kBAAkB;AAErC,SAAQC,SAAS,QAAO,mBAAmB;AAC3C,SAAQC,EAAE,QAAO,WAAW;AAI5B,OAAO,SAASC,SAAS,EAACC,SAAS,EAAEC,UAAU,EAAEC,kBAAkB,IAAI,EAAE,GAAGC,OAAqB;IAC/F,qBACE,KAACN;QACCK,iBAAiBA;QACjBF,WAAWF,GAAG,0BAA0BE;QACxCC,YAAY;YACVG,QAAQ;YACRC,OAAO;YACPC,eAAe;YACfC,eAAe;YACfC,KAAK;YACLC,iBAAiBX,GACf,qDACA,qDACA,gCACA,gDACA,mDACA,kCACA,uDACA;YAEFY,aAAaZ,GACX,sDACA,qDACA,gCACA,gDACA,mDACA,kCACA,uDACA;YAEFa,YAAY;YACZC,UAAU;YACVC,SACE;YACFC,MAAM;YACNC,KAAKjB,GACH,mJACA,yDACAK,MAAMa,cAAc,GAChB,4DACA;YAENC,YAAYnB,GACV,6CACA,2CACA,gDACA,uDACA,kCACA;YAEFoB,aAAa;YACbC,WAAW;YACXC,UAAUtB,GACR,8FACA,sDACA;YAEFuB,OAAOvB,GACL,+EACA;YAEFwB,SAAS;YACTC,UAAU;YACVC,cAAc1B,GACZ,mGACA,gBACA,0CACA;YAEF2B,QAAQ;YACR,GAAGxB,UAAU;QACf;QACAyB,YAAY;YACVC,SAAS,CAAC,EAACC,WAAW,EAAC;gBACrB,MAAMC,WAAWD,gBAAgB,SAAS,mBAAmB;gBAC7D,qBAAO,KAAChC;oBAAKkC,MAAMD;oBAAU7B,WAAU;;YACzC;QACF;QACC,GAAGG,KAAK;;AAGf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/calendar/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/calendar/index.ts"],"sourcesContent":["export * from './calendar';\n"],"names":[],"mappings":"AAAA,cAAc,aAAa"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type VariantProps } from 'class-variance-authority';
|
|
2
|
+
import type { ComponentProps, ReactNode } from 'react';
|
|
3
|
+
export declare const datePickerVariants: (props?: ({
|
|
4
|
+
variant?: "base" | "component" | null | undefined;
|
|
5
|
+
size?: "base" | "small" | null | undefined;
|
|
6
|
+
state?: "default" | "error" | "disabled" | null | undefined;
|
|
7
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
8
|
+
export type DatePickerProps = Omit<ComponentProps<'input'>, 'size' | 'type'> & VariantProps<typeof datePickerVariants> & {
|
|
9
|
+
date?: Date;
|
|
10
|
+
onDateSelect?: (date: Date | undefined) => void;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
dateFormat?: string;
|
|
13
|
+
leftIcon?: ReactNode;
|
|
14
|
+
rightIcon?: ReactNode;
|
|
15
|
+
onClear?: () => void;
|
|
16
|
+
closeOnSelect?: boolean;
|
|
17
|
+
};
|
|
18
|
+
export declare const DatePicker: import("react").ForwardRefExoticComponent<Omit<DatePickerProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
19
|
+
//# sourceMappingURL=date-picker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-picker.d.ts","sourceRoot":"","sources":["../../../src/components/date-picker/date-picker.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAM,KAAK,YAAY,EAAC,MAAM,0BAA0B,CAAC;AAKhE,OAAO,KAAK,EAAC,cAAc,EAAE,SAAS,EAAC,MAAM,OAAO,CAAC;AAIrD,eAAO,MAAM,kBAAkB;;;;8EAyB9B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,GAC1E,YAAY,CAAC,OAAO,kBAAkB,CAAC,GAAG;IACxC,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,KAAK,IAAI,CAAC;IAChD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEJ,eAAO,MAAM,UAAU,2HAgItB,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cva } from 'class-variance-authority';
|
|
3
|
+
import { Calendar } from '../../components/calendar/index.js';
|
|
4
|
+
import { Icon } from '../../components/icon/index.js';
|
|
5
|
+
import { Popover, PopoverContent, PopoverTrigger } from '../../components/popover/index.js';
|
|
6
|
+
import { format } from 'date-fns';
|
|
7
|
+
import { forwardRef, useState } from 'react';
|
|
8
|
+
import { cn } from '../../utils/cn.js';
|
|
9
|
+
export const datePickerVariants = cva('relative flex items-center rounded-6 shadow-button-neutral transition-[background-color,box-shadow] outline-none', {
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
base: 'bg-background-field-base hover:bg-background-field-hover',
|
|
13
|
+
component: 'bg-background-field-component hover:bg-background-field-component-hover'
|
|
14
|
+
},
|
|
15
|
+
size: {
|
|
16
|
+
base: 'h-32',
|
|
17
|
+
small: 'h-28'
|
|
18
|
+
},
|
|
19
|
+
state: {
|
|
20
|
+
default: '',
|
|
21
|
+
error: 'shadow-border-error',
|
|
22
|
+
disabled: 'bg-background-neutral-disabled shadow-none pointer-events-none cursor-not-allowed'
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
defaultVariants: {
|
|
26
|
+
variant: 'base',
|
|
27
|
+
size: 'base',
|
|
28
|
+
state: 'default'
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
export const DatePicker = /*#__PURE__*/ forwardRef(({ className, variant, size, state, date, onDateSelect, placeholder = 'DD/MM/YYYY', dateFormat = 'dd/MM/yyyy', leftIcon, rightIcon, onClear, disabled, closeOnSelect = false, ...props }, ref)=>{
|
|
32
|
+
const [open, setOpen] = useState(false);
|
|
33
|
+
const isDisabled = disabled || state === 'disabled';
|
|
34
|
+
const displayValue = date ? format(date, dateFormat) : '';
|
|
35
|
+
const handleSelect = (selectedDate)=>{
|
|
36
|
+
onDateSelect?.(selectedDate);
|
|
37
|
+
if (closeOnSelect) {
|
|
38
|
+
setOpen(false);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const handleClear = (e)=>{
|
|
42
|
+
e.stopPropagation();
|
|
43
|
+
onClear?.();
|
|
44
|
+
setOpen(false);
|
|
45
|
+
};
|
|
46
|
+
return /*#__PURE__*/ _jsxs(Popover, {
|
|
47
|
+
open: open,
|
|
48
|
+
onOpenChange: setOpen,
|
|
49
|
+
children: [
|
|
50
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
51
|
+
className: cn(open && 'shadow-border-interactive-with-active', datePickerVariants({
|
|
52
|
+
variant,
|
|
53
|
+
size,
|
|
54
|
+
state: isDisabled ? 'disabled' : state
|
|
55
|
+
}), className),
|
|
56
|
+
children: [
|
|
57
|
+
/*#__PURE__*/ _jsx(PopoverTrigger, {
|
|
58
|
+
asChild: true,
|
|
59
|
+
children: /*#__PURE__*/ _jsx("button", {
|
|
60
|
+
type: "button",
|
|
61
|
+
disabled: isDisabled,
|
|
62
|
+
className: cn('flex items-center justify-center shrink-0 transition-colors', size === 'small' ? 'size-28' : 'size-32', isDisabled && 'text-foreground-neutral-disabled'),
|
|
63
|
+
"aria-label": "Open calendar",
|
|
64
|
+
children: leftIcon || /*#__PURE__*/ _jsx(Icon, {
|
|
65
|
+
name: "calendar2Line",
|
|
66
|
+
className: cn('size-16 text-foreground-neutral-muted', isDisabled && 'text-foreground-neutral-disabled')
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
}),
|
|
70
|
+
/*#__PURE__*/ _jsx("div", {
|
|
71
|
+
className: "h-full w-px bg-border-neutral-base shrink-0"
|
|
72
|
+
}),
|
|
73
|
+
/*#__PURE__*/ _jsx("input", {
|
|
74
|
+
ref: ref,
|
|
75
|
+
type: "text",
|
|
76
|
+
disabled: isDisabled,
|
|
77
|
+
placeholder: placeholder,
|
|
78
|
+
value: displayValue,
|
|
79
|
+
readOnly: true,
|
|
80
|
+
className: cn('flex-1 min-w-0 px-8 text-sm leading-20 bg-transparent outline-none border-none cursor-pointer', 'placeholder:text-foreground-neutral-muted', 'text-foreground-neutral-base', 'disabled:text-foreground-neutral-disabled disabled:cursor-not-allowed', size === 'small' ? 'py-4' : 'py-6'),
|
|
81
|
+
onClick: ()=>!isDisabled && setOpen(true),
|
|
82
|
+
...props
|
|
83
|
+
}),
|
|
84
|
+
/*#__PURE__*/ _jsx("button", {
|
|
85
|
+
type: "button",
|
|
86
|
+
onClick: handleClear,
|
|
87
|
+
className: cn('flex items-center justify-center shrink-0 cursor-pointer', size === 'small' ? 'size-28' : 'size-32', date && onClear && !isDisabled ? 'visible' : 'invisible'),
|
|
88
|
+
"aria-label": "Clear date",
|
|
89
|
+
children: /*#__PURE__*/ _jsx(Icon, {
|
|
90
|
+
name: "closeLine",
|
|
91
|
+
className: "size-16 text-foreground-neutral-muted hover:text-foreground-neutral-subtle transition-colors"
|
|
92
|
+
})
|
|
93
|
+
}),
|
|
94
|
+
rightIcon && !date && /*#__PURE__*/ _jsx("div", {
|
|
95
|
+
className: cn('flex items-center justify-center shrink-0', size === 'small' ? 'size-28' : 'size-32'),
|
|
96
|
+
children: rightIcon
|
|
97
|
+
})
|
|
98
|
+
]
|
|
99
|
+
}),
|
|
100
|
+
/*#__PURE__*/ _jsx(PopoverContent, {
|
|
101
|
+
className: "w-auto p-0",
|
|
102
|
+
align: "start",
|
|
103
|
+
children: /*#__PURE__*/ _jsx(Calendar, {
|
|
104
|
+
mode: "single",
|
|
105
|
+
selected: date,
|
|
106
|
+
onSelect: handleSelect
|
|
107
|
+
})
|
|
108
|
+
})
|
|
109
|
+
]
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
DatePicker.displayName = 'DatePicker';
|
|
113
|
+
|
|
114
|
+
//# sourceMappingURL=date-picker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/date-picker/date-picker.tsx"],"sourcesContent":["import {cva, type VariantProps} from 'class-variance-authority';\nimport {Calendar} from 'components/calendar';\nimport {Icon} from 'components/icon';\nimport {Popover, PopoverContent, PopoverTrigger} from 'components/popover';\nimport {format} from 'date-fns';\nimport type {ComponentProps, ReactNode} from 'react';\nimport {forwardRef, useState} from 'react';\nimport {cn} from 'utils/cn';\n\nexport const datePickerVariants = cva(\n 'relative flex items-center rounded-6 shadow-button-neutral transition-[background-color,box-shadow] outline-none',\n {\n variants: {\n variant: {\n base: 'bg-background-field-base hover:bg-background-field-hover',\n component: 'bg-background-field-component hover:bg-background-field-component-hover',\n },\n size: {\n base: 'h-32',\n small: 'h-28',\n },\n state: {\n default: '',\n error: 'shadow-border-error',\n disabled:\n 'bg-background-neutral-disabled shadow-none pointer-events-none cursor-not-allowed',\n },\n },\n defaultVariants: {\n variant: 'base',\n size: 'base',\n state: 'default',\n },\n },\n);\n\nexport type DatePickerProps = Omit<ComponentProps<'input'>, 'size' | 'type'> &\n VariantProps<typeof datePickerVariants> & {\n date?: Date;\n onDateSelect?: (date: Date | undefined) => void;\n placeholder?: string;\n dateFormat?: string;\n leftIcon?: ReactNode;\n rightIcon?: ReactNode;\n onClear?: () => void;\n closeOnSelect?: boolean;\n };\n\nexport const DatePicker = forwardRef<HTMLInputElement, DatePickerProps>(\n (\n {\n className,\n variant,\n size,\n state,\n date,\n onDateSelect,\n placeholder = 'DD/MM/YYYY',\n dateFormat = 'dd/MM/yyyy',\n leftIcon,\n rightIcon,\n onClear,\n disabled,\n closeOnSelect = false,\n ...props\n },\n ref,\n ) => {\n const [open, setOpen] = useState(false);\n const isDisabled = disabled || state === 'disabled';\n const displayValue = date ? format(date, dateFormat) : '';\n\n const handleSelect = (selectedDate: Date | undefined) => {\n onDateSelect?.(selectedDate);\n if (closeOnSelect) {\n setOpen(false);\n }\n };\n\n const handleClear = (e: React.MouseEvent) => {\n e.stopPropagation();\n onClear?.();\n setOpen(false);\n };\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <div\n className={cn(\n open && 'shadow-border-interactive-with-active',\n datePickerVariants({variant, size, state: isDisabled ? 'disabled' : state}),\n className,\n )}\n >\n {/* Calendar Icon Button */}\n <PopoverTrigger asChild>\n <button\n type=\"button\"\n disabled={isDisabled}\n className={cn(\n 'flex items-center justify-center shrink-0 transition-colors',\n size === 'small' ? 'size-28' : 'size-32',\n isDisabled && 'text-foreground-neutral-disabled',\n )}\n aria-label=\"Open calendar\"\n >\n {leftIcon || (\n <Icon\n name=\"calendar2Line\"\n className={cn(\n 'size-16 text-foreground-neutral-muted',\n isDisabled && 'text-foreground-neutral-disabled',\n )}\n />\n )}\n </button>\n </PopoverTrigger>\n\n {/* Divider */}\n <div className=\"h-full w-px bg-border-neutral-base shrink-0\" />\n\n {/* Input Field */}\n <input\n ref={ref}\n type=\"text\"\n disabled={isDisabled}\n placeholder={placeholder}\n value={displayValue}\n readOnly\n className={cn(\n 'flex-1 min-w-0 px-8 text-sm leading-20 bg-transparent outline-none border-none cursor-pointer',\n 'placeholder:text-foreground-neutral-muted',\n 'text-foreground-neutral-base',\n 'disabled:text-foreground-neutral-disabled disabled:cursor-not-allowed',\n size === 'small' ? 'py-4' : 'py-6',\n )}\n onClick={() => !isDisabled && setOpen(true)}\n {...props}\n />\n\n {/* Clear Button (shown when date is selected) */}\n <button\n type=\"button\"\n onClick={handleClear}\n className={cn(\n 'flex items-center justify-center shrink-0 cursor-pointer',\n size === 'small' ? 'size-28' : 'size-32',\n date && onClear && !isDisabled ? 'visible' : 'invisible',\n )}\n aria-label=\"Clear date\"\n >\n <Icon\n name=\"closeLine\"\n className=\"size-16 text-foreground-neutral-muted hover:text-foreground-neutral-subtle transition-colors\"\n />\n </button>\n\n {/* Custom Right Icon */}\n {rightIcon && !date && (\n <div\n className={cn(\n 'flex items-center justify-center shrink-0',\n size === 'small' ? 'size-28' : 'size-32',\n )}\n >\n {rightIcon}\n </div>\n )}\n </div>\n\n <PopoverContent className=\"w-auto p-0\" align=\"start\">\n <Calendar mode=\"single\" selected={date} onSelect={handleSelect} />\n </PopoverContent>\n </Popover>\n );\n },\n);\n\nDatePicker.displayName = 'DatePicker';\n"],"names":["cva","Calendar","Icon","Popover","PopoverContent","PopoverTrigger","format","forwardRef","useState","cn","datePickerVariants","variants","variant","base","component","size","small","state","default","error","disabled","defaultVariants","DatePicker","className","date","onDateSelect","placeholder","dateFormat","leftIcon","rightIcon","onClear","closeOnSelect","props","ref","open","setOpen","isDisabled","displayValue","handleSelect","selectedDate","handleClear","e","stopPropagation","onOpenChange","div","asChild","button","type","aria-label","name","input","value","readOnly","onClick","align","mode","selected","onSelect","displayName"],"mappings":";AAAA,SAAQA,GAAG,QAA0B,2BAA2B;AAChE,SAAQC,QAAQ,QAAO,sBAAsB;AAC7C,SAAQC,IAAI,QAAO,kBAAkB;AACrC,SAAQC,OAAO,EAA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