@jesusgm/react-components 0.0.0-stage → 0.1.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/Readme.md +158 -0
- package/dist/components/atoms/avatar/index.d.ts +19 -0
- package/dist/components/atoms/avatar/index.js +44 -0
- package/dist/components/atoms/avatar/index.js.map +1 -0
- package/dist/components/atoms/avatar/styles.css +50 -0
- package/dist/components/atoms/badge/index.d.ts +17 -0
- package/dist/components/atoms/badge/index.js +37 -0
- package/dist/components/atoms/badge/index.js.map +1 -0
- package/dist/components/atoms/badge/styles.css +83 -0
- package/dist/components/atoms/button/index.d.ts +16 -0
- package/dist/components/atoms/button/index.js +22 -0
- package/dist/components/atoms/button/index.js.map +1 -0
- package/dist/components/atoms/button/styles.css +77 -0
- package/dist/components/atoms/checkbox/index.d.ts +13 -0
- package/dist/components/atoms/checkbox/index.js +63 -0
- package/dist/components/atoms/checkbox/index.js.map +1 -0
- package/dist/components/atoms/checkbox/styles.css +87 -0
- package/dist/components/atoms/code-highlighter/index.d.ts +8 -0
- package/dist/components/atoms/code-highlighter/index.js +24 -0
- package/dist/components/atoms/code-highlighter/index.js.map +1 -0
- package/dist/components/atoms/code-highlighter/railscasts.css +1 -0
- package/dist/components/atoms/code-highlighter/styles.css +17 -0
- package/dist/components/atoms/divider/index.d.ts +10 -0
- package/dist/components/atoms/divider/index.js +25 -0
- package/dist/components/atoms/divider/index.js.map +1 -0
- package/dist/components/atoms/divider/styles.css +56 -0
- package/dist/components/atoms/icon/index.d.ts +23 -0
- package/dist/components/atoms/icon/index.js +20 -0
- package/dist/components/atoms/icon/index.js.map +1 -0
- package/dist/components/atoms/icon/styles.css +13 -0
- package/dist/components/atoms/kbd/index.d.ts +7 -0
- package/dist/components/atoms/kbd/index.js +26 -0
- package/dist/components/atoms/kbd/index.js.map +1 -0
- package/dist/components/atoms/kbd/styles.css +29 -0
- package/dist/components/atoms/label/index.d.ts +9 -0
- package/dist/components/atoms/label/index.js +18 -0
- package/dist/components/atoms/label/index.js.map +1 -0
- package/dist/components/atoms/label/styles.css +19 -0
- package/dist/components/atoms/link/index.d.ts +12 -0
- package/dist/components/atoms/link/index.js +32 -0
- package/dist/components/atoms/link/index.js.map +1 -0
- package/dist/components/atoms/link/styles.css +54 -0
- package/dist/components/atoms/progress-bar/index.d.ts +23 -0
- package/dist/components/atoms/progress-bar/index.js +45 -0
- package/dist/components/atoms/progress-bar/index.js.map +1 -0
- package/dist/components/atoms/progress-bar/styles.css +75 -0
- package/dist/components/atoms/radio/context.d.ts +9 -0
- package/dist/components/atoms/radio/context.js +9 -0
- package/dist/components/atoms/radio/context.js.map +1 -0
- package/dist/components/atoms/radio/index.d.ts +15 -0
- package/dist/components/atoms/radio/index.js +44 -0
- package/dist/components/atoms/radio/index.js.map +1 -0
- package/dist/components/atoms/radio/radio-group.d.ts +25 -0
- package/dist/components/atoms/radio/radio-group.js +49 -0
- package/dist/components/atoms/radio/radio-group.js.map +1 -0
- package/dist/components/atoms/radio/styles.css +110 -0
- package/dist/components/atoms/skeleton/index.d.ts +15 -0
- package/dist/components/atoms/skeleton/index.js +38 -0
- package/dist/components/atoms/skeleton/index.js.map +1 -0
- package/dist/components/atoms/skeleton/styles.css +57 -0
- package/dist/components/atoms/spinner/index.d.ts +11 -0
- package/dist/components/atoms/spinner/index.js +22 -0
- package/dist/components/atoms/spinner/index.js.map +1 -0
- package/dist/components/atoms/spinner/styles.css +51 -0
- package/dist/components/atoms/switch/index.d.ts +14 -0
- package/dist/components/atoms/switch/index.js +33 -0
- package/dist/components/atoms/switch/index.js.map +1 -0
- package/dist/components/atoms/switch/styles.css +99 -0
- package/dist/components/atoms/text-input/index.d.ts +20 -0
- package/dist/components/atoms/text-input/index.js +33 -0
- package/dist/components/atoms/text-input/index.js.map +1 -0
- package/dist/components/atoms/text-input/styles.css +80 -0
- package/dist/components/atoms/textarea/index.d.ts +14 -0
- package/dist/components/atoms/textarea/index.js +43 -0
- package/dist/components/atoms/textarea/index.js.map +1 -0
- package/dist/components/atoms/textarea/styles.css +49 -0
- package/dist/components/atoms/typography/index.d.ts +30 -0
- package/dist/components/atoms/typography/index.js +30 -0
- package/dist/components/atoms/typography/index.js.map +1 -0
- package/dist/components/atoms/typography/styles.css +50 -0
- package/dist/components/atoms/video-player/index.d.ts +9 -0
- package/dist/components/atoms/video-player/index.js +17 -0
- package/dist/components/atoms/video-player/index.js.map +1 -0
- package/dist/components/atoms/video-player/styles.css +18 -0
- package/dist/components/atoms/visually-hidden/index.d.ts +7 -0
- package/dist/components/atoms/visually-hidden/index.js +13 -0
- package/dist/components/atoms/visually-hidden/index.js.map +1 -0
- package/dist/components/atoms/visually-hidden/styles.css +12 -0
- package/dist/components/hooks/index.d.ts +3 -0
- package/dist/components/hooks/index.js +4 -0
- package/dist/components/hooks/use-click-outside.d.ts +6 -0
- package/dist/components/hooks/use-click-outside.js +30 -0
- package/dist/components/hooks/use-click-outside.js.map +1 -0
- package/dist/components/hooks/use-controllable-state.d.ts +5 -0
- package/dist/components/hooks/use-controllable-state.js +22 -0
- package/dist/components/hooks/use-controllable-state.js.map +1 -0
- package/dist/components/hooks/use-focus-trap.d.ts +8 -0
- package/dist/components/hooks/use-focus-trap.js +57 -0
- package/dist/components/hooks/use-focus-trap.js.map +1 -0
- package/dist/components/index.d.ts +122 -0
- package/dist/components/index.js +74 -0
- package/dist/components/molecules/accordion/index.d.ts +27 -0
- package/dist/components/molecules/accordion/index.js +98 -0
- package/dist/components/molecules/accordion/index.js.map +1 -0
- package/dist/components/molecules/accordion/styles.css +75 -0
- package/dist/components/molecules/alert/index.d.ts +18 -0
- package/dist/components/molecules/alert/index.js +91 -0
- package/dist/components/molecules/alert/index.js.map +1 -0
- package/dist/components/molecules/alert/styles.css +97 -0
- package/dist/components/molecules/binary-clock/index.d.ts +16 -0
- package/dist/components/molecules/binary-clock/index.js +66 -0
- package/dist/components/molecules/binary-clock/index.js.map +1 -0
- package/dist/components/molecules/binary-clock/styles.css +46 -0
- package/dist/components/molecules/breadcrumb/index.d.ts +23 -0
- package/dist/components/molecules/breadcrumb/index.js +79 -0
- package/dist/components/molecules/breadcrumb/index.js.map +1 -0
- package/dist/components/molecules/breadcrumb/styles.css +61 -0
- package/dist/components/molecules/card/index.d.ts +39 -0
- package/dist/components/molecules/card/index.js +60 -0
- package/dist/components/molecules/card/index.js.map +1 -0
- package/dist/components/molecules/card/styles.css +105 -0
- package/dist/components/molecules/chart/index.d.ts +14 -0
- package/dist/components/molecules/chart/index.js +104 -0
- package/dist/components/molecules/chart/index.js.map +1 -0
- package/dist/components/molecules/conflict-resolver/components/conflictItem.d.ts +8 -0
- package/dist/components/molecules/conflict-resolver/components/conflictItem.js +58 -0
- package/dist/components/molecules/conflict-resolver/components/conflictItem.js.map +1 -0
- package/dist/components/molecules/conflict-resolver/components/styles.css +64 -0
- package/dist/components/molecules/conflict-resolver/index.d.ts +10 -0
- package/dist/components/molecules/conflict-resolver/index.js +35 -0
- package/dist/components/molecules/conflict-resolver/index.js.map +1 -0
- package/dist/components/molecules/conflict-resolver/types.d.ts +10 -0
- package/dist/components/molecules/dropable-list/draggable.d.ts +9 -0
- package/dist/components/molecules/dropable-list/draggable.js +18 -0
- package/dist/components/molecules/dropable-list/draggable.js.map +1 -0
- package/dist/components/molecules/dropable-list/index.d.ts +20 -0
- package/dist/components/molecules/dropable-list/index.js +52 -0
- package/dist/components/molecules/dropable-list/index.js.map +1 -0
- package/dist/components/molecules/dropable-list/styles.css +63 -0
- package/dist/components/molecules/dropdown-menu/index.d.ts +43 -0
- package/dist/components/molecules/dropdown-menu/index.js +226 -0
- package/dist/components/molecules/dropdown-menu/index.js.map +1 -0
- package/dist/components/molecules/dropdown-menu/styles.css +94 -0
- package/dist/components/molecules/empty-state/index.d.ts +16 -0
- package/dist/components/molecules/empty-state/index.js +32 -0
- package/dist/components/molecules/empty-state/index.js.map +1 -0
- package/dist/components/molecules/empty-state/styles.css +64 -0
- package/dist/components/molecules/file-input/index.d.ts +39 -0
- package/dist/components/molecules/file-input/index.js +121 -0
- package/dist/components/molecules/file-input/index.js.map +1 -0
- package/dist/components/molecules/file-input/styles.css +86 -0
- package/dist/components/molecules/form-field/index.d.ts +38 -0
- package/dist/components/molecules/form-field/index.js +71 -0
- package/dist/components/molecules/form-field/index.js.map +1 -0
- package/dist/components/molecules/form-field/styles.css +43 -0
- package/dist/components/molecules/list/index.d.ts +25 -0
- package/dist/components/molecules/list/index.js +30 -0
- package/dist/components/molecules/list/index.js.map +1 -0
- package/dist/components/molecules/list/styles.css +28 -0
- package/dist/components/molecules/number-stepper/index.d.ts +31 -0
- package/dist/components/molecules/number-stepper/index.js +163 -0
- package/dist/components/molecules/number-stepper/index.js.map +1 -0
- package/dist/components/molecules/number-stepper/styles.css +69 -0
- package/dist/components/molecules/pagination/index.d.ts +39 -0
- package/dist/components/molecules/pagination/index.js +111 -0
- package/dist/components/molecules/pagination/index.js.map +1 -0
- package/dist/components/molecules/pagination/styles.css +41 -0
- package/dist/components/molecules/popover/index.d.ts +22 -0
- package/dist/components/molecules/popover/index.js +76 -0
- package/dist/components/molecules/popover/index.js.map +1 -0
- package/dist/components/molecules/popover/positioning.d.ts +40 -0
- package/dist/components/molecules/popover/positioning.js +115 -0
- package/dist/components/molecules/popover/positioning.js.map +1 -0
- package/dist/components/molecules/popover/styles.css +36 -0
- package/dist/components/molecules/rating/index.d.ts +33 -0
- package/dist/components/molecules/rating/index.js +117 -0
- package/dist/components/molecules/rating/index.js.map +1 -0
- package/dist/components/molecules/rating/styles.css +94 -0
- package/dist/components/molecules/search-input/index.d.ts +23 -0
- package/dist/components/molecules/search-input/index.js +118 -0
- package/dist/components/molecules/search-input/index.js.map +1 -0
- package/dist/components/molecules/search-input/styles.css +69 -0
- package/dist/components/molecules/segmented-control/button-group.d.ts +10 -0
- package/dist/components/molecules/segmented-control/button-group.js +15 -0
- package/dist/components/molecules/segmented-control/button-group.js.map +1 -0
- package/dist/components/molecules/segmented-control/index.d.ts +38 -0
- package/dist/components/molecules/segmented-control/index.js +80 -0
- package/dist/components/molecules/segmented-control/index.js.map +1 -0
- package/dist/components/molecules/segmented-control/styles.css +130 -0
- package/dist/components/molecules/select/index.d.ts +30 -0
- package/dist/components/molecules/select/index.js +48 -0
- package/dist/components/molecules/select/index.js.map +1 -0
- package/dist/components/molecules/select/styles.css +102 -0
- package/dist/components/molecules/tabs/index.d.ts +31 -0
- package/dist/components/molecules/tabs/index.js +87 -0
- package/dist/components/molecules/tabs/index.js.map +1 -0
- package/dist/components/molecules/tabs/styles.css +87 -0
- package/dist/components/molecules/tag-cloud/index.d.ts +16 -0
- package/dist/components/molecules/tag-cloud/index.js +133 -0
- package/dist/components/molecules/tag-cloud/index.js.map +1 -0
- package/dist/components/molecules/tag-cloud/styles.css +29 -0
- package/dist/components/molecules/tooltip/index.d.ts +22 -0
- package/dist/components/molecules/tooltip/index.js +83 -0
- package/dist/components/molecules/tooltip/index.js.map +1 -0
- package/dist/components/molecules/tooltip/styles.css +30 -0
- package/dist/components/molecules/virtualized-list/index.d.ts +5 -0
- package/dist/components/molecules/virtualized-list/index.js +3 -0
- package/dist/components/molecules/virtualized-list/lista/index.d.ts +11 -0
- package/dist/components/molecules/virtualized-list/lista/index.js +30 -0
- package/dist/components/molecules/virtualized-list/lista/index.js.map +1 -0
- package/dist/components/molecules/virtualized-list/lista/styles.css +27 -0
- package/dist/components/molecules/virtualized-list/lista-slow/index.d.ts +10 -0
- package/dist/components/molecules/virtualized-list/lista-slow/index.js +17 -0
- package/dist/components/molecules/virtualized-list/lista-slow/index.js.map +1 -0
- package/dist/components/molecules/virtualized-list/row/index.d.ts +9 -0
- package/dist/components/molecules/virtualized-list/row/index.js +30 -0
- package/dist/components/molecules/virtualized-list/row/index.js.map +1 -0
- package/dist/components/molecules/virtualized-list/types.d.ts +4 -0
- package/dist/components/organisms/combobox/index.d.ts +82 -0
- package/dist/components/organisms/combobox/index.js +386 -0
- package/dist/components/organisms/combobox/index.js.map +1 -0
- package/dist/components/organisms/combobox/styles.css +269 -0
- package/dist/components/organisms/command-palette/index.d.ts +49 -0
- package/dist/components/organisms/command-palette/index.js +239 -0
- package/dist/components/organisms/command-palette/index.js.map +1 -0
- package/dist/components/organisms/command-palette/score.d.ts +12 -0
- package/dist/components/organisms/command-palette/score.js +43 -0
- package/dist/components/organisms/command-palette/score.js.map +1 -0
- package/dist/components/organisms/command-palette/styles.css +212 -0
- package/dist/components/organisms/date-picker/calendar.d.ts +29 -0
- package/dist/components/organisms/date-picker/calendar.js +178 -0
- package/dist/components/organisms/date-picker/calendar.js.map +1 -0
- package/dist/components/organisms/date-picker/date-utils.d.ts +52 -0
- package/dist/components/organisms/date-picker/date-utils.js +139 -0
- package/dist/components/organisms/date-picker/date-utils.js.map +1 -0
- package/dist/components/organisms/date-picker/index.d.ts +54 -0
- package/dist/components/organisms/date-picker/index.js +173 -0
- package/dist/components/organisms/date-picker/index.js.map +1 -0
- package/dist/components/organisms/date-picker/styles.css +179 -0
- package/dist/components/organisms/drawer/index.d.ts +16 -0
- package/dist/components/organisms/drawer/index.js +15 -0
- package/dist/components/organisms/drawer/index.js.map +1 -0
- package/dist/components/organisms/drawer/styles.css +163 -0
- package/dist/components/organisms/editor/index.d.ts +13 -0
- package/dist/components/organisms/editor/index.js +56 -0
- package/dist/components/organisms/editor/index.js.map +1 -0
- package/dist/components/organisms/editor/styles.css +61 -0
- package/dist/components/organisms/form/context.d.ts +7 -0
- package/dist/components/organisms/form/context.js +11 -0
- package/dist/components/organisms/form/context.js.map +1 -0
- package/dist/components/organisms/form/field.d.ts +18 -0
- package/dist/components/organisms/form/field.js +98 -0
- package/dist/components/organisms/form/field.js.map +1 -0
- package/dist/components/organisms/form/form-actions.d.ts +8 -0
- package/dist/components/organisms/form/form-actions.js +13 -0
- package/dist/components/organisms/form/form-actions.js.map +1 -0
- package/dist/components/organisms/form/index.d.ts +24 -0
- package/dist/components/organisms/form/index.js +215 -0
- package/dist/components/organisms/form/index.js.map +1 -0
- package/dist/components/organisms/form/styles.css +29 -0
- package/dist/components/organisms/form/types.d.ts +95 -0
- package/dist/components/organisms/form/validation.d.ts +5 -0
- package/dist/components/organisms/form/validation.js +35 -0
- package/dist/components/organisms/form/validation.js.map +1 -0
- package/dist/components/organisms/header/index.d.ts +40 -0
- package/dist/components/organisms/header/index.js +186 -0
- package/dist/components/organisms/header/index.js.map +1 -0
- package/dist/components/organisms/header/styles.css +126 -0
- package/dist/components/organisms/modal/dialog-base.d.ts +31 -0
- package/dist/components/organisms/modal/dialog-base.js +123 -0
- package/dist/components/organisms/modal/dialog-base.js.map +1 -0
- package/dist/components/organisms/modal/index.d.ts +13 -0
- package/dist/components/organisms/modal/index.js +15 -0
- package/dist/components/organisms/modal/index.js.map +1 -0
- package/dist/components/organisms/modal/styles.css +143 -0
- package/dist/components/organisms/presenter/components/slides/simple/index.d.ts +13 -0
- package/dist/components/organisms/presenter/components/slides/simple/index.js +16 -0
- package/dist/components/organisms/presenter/components/slides/simple/index.js.map +1 -0
- package/dist/components/organisms/presenter/components/slides/simple/styles.css +6 -0
- package/dist/components/organisms/presenter/index.d.ts +17 -0
- package/dist/components/organisms/presenter/index.js +63 -0
- package/dist/components/organisms/presenter/index.js.map +1 -0
- package/dist/components/organisms/presenter/styles.css +75 -0
- package/dist/components/organisms/sidebar/index.d.ts +50 -0
- package/dist/components/organisms/sidebar/index.js +157 -0
- package/dist/components/organisms/sidebar/index.js.map +1 -0
- package/dist/components/organisms/sidebar/styles.css +197 -0
- package/dist/components/organisms/slider/index.d.ts +47 -0
- package/dist/components/organisms/slider/index.js +214 -0
- package/dist/components/organisms/slider/index.js.map +1 -0
- package/dist/components/organisms/slider/styles.css +110 -0
- package/dist/components/organisms/table/components/cell/index.d.ts +8 -0
- package/dist/components/organisms/table/components/cell/index.js +11 -0
- package/dist/components/organisms/table/components/cell/index.js.map +1 -0
- package/dist/components/organisms/table/index.d.ts +29 -0
- package/dist/components/organisms/table/index.js +105 -0
- package/dist/components/organisms/table/index.js.map +1 -0
- package/dist/components/organisms/table/styles.css +66 -0
- package/dist/components/organisms/terminal/index.d.ts +15 -0
- package/dist/components/organisms/terminal/index.js +111 -0
- package/dist/components/organisms/terminal/index.js.map +1 -0
- package/dist/components/organisms/terminal/styles.css +123 -0
- package/dist/components/organisms/toast/index.d.ts +66 -0
- package/dist/components/organisms/toast/index.js +142 -0
- package/dist/components/organisms/toast/index.js.map +1 -0
- package/dist/components/organisms/toast/styles.css +138 -0
- package/dist/components/organisms/wizard/index.d.ts +44 -0
- package/dist/components/organisms/wizard/index.js +171 -0
- package/dist/components/organisms/wizard/index.js.map +1 -0
- package/dist/components/organisms/wizard/styles.css +160 -0
- package/dist/components/utils/cx.d.ts +2 -0
- package/dist/components/utils/cx.js +8 -0
- package/dist/components/utils/cx.js.map +1 -0
- package/dist/components/utils/portal/index.d.ts +9 -0
- package/dist/components/utils/portal/index.js +13 -0
- package/dist/components/utils/portal/index.js.map +1 -0
- package/dist/components/utils/theme-provider/index.d.ts +22 -0
- package/dist/components/utils/theme-provider/index.js +36 -0
- package/dist/components/utils/theme-provider/index.js.map +1 -0
- package/dist/styles.css +743 -0
- package/dist/tokens.css +299 -0
- package/package.json +390 -4
- package/README.md +0 -3
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type InputHTMLAttributes } from "react";
|
|
2
|
+
import { type TextInputSize } from "../../atoms/text-input";
|
|
3
|
+
import { type WeekStart } from "./date-utils";
|
|
4
|
+
export { default as Calendar } from "./calendar";
|
|
5
|
+
export type { CalendarProps, WeekStart } from "./calendar";
|
|
6
|
+
export interface DatePickerProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "value" | "defaultValue" | "onChange" | "size" | "min" | "max"> {
|
|
7
|
+
/** Selected date (controlled). `null` for empty */
|
|
8
|
+
value?: Date | null;
|
|
9
|
+
/** Initially selected date (uncontrolled) */
|
|
10
|
+
defaultValue?: Date | null;
|
|
11
|
+
/** Called when the date changes (picked, typed or cleared) */
|
|
12
|
+
onChange?: (date: Date | null) => void;
|
|
13
|
+
/** Whether the calendar popover is open (controlled) */
|
|
14
|
+
open?: boolean;
|
|
15
|
+
/** Initial open state (uncontrolled) */
|
|
16
|
+
defaultOpen?: boolean;
|
|
17
|
+
/** Called when the calendar popover opens or closes */
|
|
18
|
+
onOpenChange?: (open: boolean) => void;
|
|
19
|
+
/** Earliest selectable date */
|
|
20
|
+
min?: Date | null;
|
|
21
|
+
/** Latest selectable date */
|
|
22
|
+
max?: Date | null;
|
|
23
|
+
/** Return `true` to disable a specific date */
|
|
24
|
+
isDateDisabled?: (date: Date) => boolean;
|
|
25
|
+
/** BCP 47 locale for formatting, parsing and calendar labels */
|
|
26
|
+
locale?: string;
|
|
27
|
+
/** First day of the week: 0 = Sunday … 6 = Saturday */
|
|
28
|
+
weekStartsOn?: WeekStart;
|
|
29
|
+
/** Turns a date into the text shown in the input. Default: numeric date in `locale` */
|
|
30
|
+
format?: (date: Date, locale: string) => string;
|
|
31
|
+
/** Turns typed text into a date (or `null` if invalid). Default: ISO `yyyy-mm-dd`, then numeric date in `locale` */
|
|
32
|
+
parse?: (text: string, locale: string) => Date | null;
|
|
33
|
+
/** Show a button that clears the date */
|
|
34
|
+
clearable?: boolean;
|
|
35
|
+
/** Height and padding, from the control-size tokens */
|
|
36
|
+
size?: TextInputSize;
|
|
37
|
+
/** Marks the value as invalid */
|
|
38
|
+
invalid?: boolean;
|
|
39
|
+
/** Stretch to the container width */
|
|
40
|
+
fullWidth?: boolean;
|
|
41
|
+
/** Class name applied to the root wrapper */
|
|
42
|
+
className?: string;
|
|
43
|
+
/** Accessible label of the calendar button (and of the calendar dialog) */
|
|
44
|
+
chooseDateLabel?: string;
|
|
45
|
+
/** Accessible label of the clear button */
|
|
46
|
+
clearLabel?: string;
|
|
47
|
+
/** Accessible label of the previous-month button */
|
|
48
|
+
previousMonthLabel?: string;
|
|
49
|
+
/** Accessible label of the next-month button */
|
|
50
|
+
nextMonthLabel?: string;
|
|
51
|
+
}
|
|
52
|
+
/** Date input with a calendar popover. Typed text is parsed on blur or Enter. */
|
|
53
|
+
declare const DatePicker: import("react").ForwardRefExoticComponent<DatePickerProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
54
|
+
export default DatePicker;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { forwardRef, useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
2
|
+
import TextInput from "../../atoms/text-input/index.js";
|
|
3
|
+
import { useClickOutside } from "../../hooks/use-click-outside.js";
|
|
4
|
+
import { useControllableState } from "../../hooks/use-controllable-state.js";
|
|
5
|
+
import { mergeRefs, useFloatingPosition } from "../../molecules/popover/positioning.js";
|
|
6
|
+
import { cx } from "../../utils/cx.js";
|
|
7
|
+
import Portal from "../../utils/portal/index.js";
|
|
8
|
+
import Calendar from "./calendar.js";
|
|
9
|
+
import { formatDate, isOutOfRange, isSameDay, parseDate } from "./date-utils.js";
|
|
10
|
+
import './styles.css';/* empty css */
|
|
11
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
// src/components/organisms/date-picker/index.tsx
|
|
13
|
+
/** Date input with a calendar popover. Typed text is parsed on blur or Enter. */
|
|
14
|
+
var DatePicker = forwardRef(function DatePicker({ value: valueProp, defaultValue = null, onChange, open: openProp, defaultOpen = false, onOpenChange, min, max, isDateDisabled, locale = "en-US", weekStartsOn = 1, format = formatDate, parse = parseDate, clearable = false, size = "md", invalid = false, fullWidth = false, disabled, className, chooseDateLabel = "Choose date", clearLabel = "Clear date", previousMonthLabel, nextMonthLabel, onBlur, onKeyDown, ...rest }, ref) {
|
|
15
|
+
const [value, setValue] = useControllableState(valueProp, defaultValue, onChange);
|
|
16
|
+
const [open, setOpen] = useControllableState(openProp, defaultOpen, onOpenChange);
|
|
17
|
+
const formatted = value ? format(value, locale) : "";
|
|
18
|
+
const [text, setText] = useState(formatted);
|
|
19
|
+
const dialogId = useId();
|
|
20
|
+
const wrapperRef = useRef(null);
|
|
21
|
+
const buttonRef = useRef(null);
|
|
22
|
+
const inputRef = useRef(null);
|
|
23
|
+
const popupRef = useRef(null);
|
|
24
|
+
const [popup, setPopup] = useState(null);
|
|
25
|
+
const isOpen = open && !disabled;
|
|
26
|
+
const position = useFloatingPosition(wrapperRef, popup, isOpen, "bottom-start", 4);
|
|
27
|
+
const inputCallbackRef = useMemo(() => mergeRefs(inputRef, ref), [ref]);
|
|
28
|
+
useEffect(() => setText(formatted), [formatted]);
|
|
29
|
+
useClickOutside([wrapperRef, popupRef], () => setOpen(false), isOpen);
|
|
30
|
+
const popupCallbackRef = useCallback((node) => {
|
|
31
|
+
popupRef.current = node;
|
|
32
|
+
setPopup(node);
|
|
33
|
+
}, []);
|
|
34
|
+
const isDisabled = (date) => isOutOfRange(date, min, max) || Boolean(isDateDisabled?.(date));
|
|
35
|
+
const commitText = () => {
|
|
36
|
+
const trimmed = text.trim();
|
|
37
|
+
if (trimmed === "") {
|
|
38
|
+
setValue(null);
|
|
39
|
+
setText("");
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const parsed = parse(trimmed, locale);
|
|
43
|
+
if (parsed && !isDisabled(parsed)) {
|
|
44
|
+
if (!isSameDay(parsed, value)) setValue(parsed);
|
|
45
|
+
setText(format(parsed, locale));
|
|
46
|
+
} else setText(formatted);
|
|
47
|
+
};
|
|
48
|
+
const close = (returnFocus) => {
|
|
49
|
+
setOpen(false);
|
|
50
|
+
if (returnFocus) buttonRef.current?.focus();
|
|
51
|
+
};
|
|
52
|
+
const onPopupKeyDown = (event) => {
|
|
53
|
+
if (event.key === "Escape") {
|
|
54
|
+
event.preventDefault();
|
|
55
|
+
event.stopPropagation();
|
|
56
|
+
close(true);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
60
|
+
ref: wrapperRef,
|
|
61
|
+
className: cx("ds-date-picker", fullWidth && "ds-date-picker--full", className),
|
|
62
|
+
children: [
|
|
63
|
+
/* @__PURE__ */ jsx(TextInput, {
|
|
64
|
+
...rest,
|
|
65
|
+
ref: inputCallbackRef,
|
|
66
|
+
size,
|
|
67
|
+
invalid,
|
|
68
|
+
disabled,
|
|
69
|
+
fullWidth,
|
|
70
|
+
className: "ds-date-picker__input",
|
|
71
|
+
value: text,
|
|
72
|
+
onChange: (event) => setText(event.target.value),
|
|
73
|
+
onBlur: (event) => {
|
|
74
|
+
commitText();
|
|
75
|
+
onBlur?.(event);
|
|
76
|
+
},
|
|
77
|
+
onKeyDown: (event) => {
|
|
78
|
+
onKeyDown?.(event);
|
|
79
|
+
if (event.defaultPrevented) return;
|
|
80
|
+
if (event.key === "Enter") commitText();
|
|
81
|
+
else if (event.key === "ArrowDown" && event.altKey) {
|
|
82
|
+
event.preventDefault();
|
|
83
|
+
setOpen(true);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}),
|
|
87
|
+
clearable && value && !disabled && /* @__PURE__ */ jsx("button", {
|
|
88
|
+
type: "button",
|
|
89
|
+
className: cx("ds-date-picker__button", `ds-date-picker__button--${size}`),
|
|
90
|
+
"aria-label": clearLabel,
|
|
91
|
+
onClick: () => {
|
|
92
|
+
setValue(null);
|
|
93
|
+
setText("");
|
|
94
|
+
inputRef.current?.focus();
|
|
95
|
+
},
|
|
96
|
+
children: /* @__PURE__ */ jsx("svg", {
|
|
97
|
+
viewBox: "0 0 16 16",
|
|
98
|
+
"aria-hidden": "true",
|
|
99
|
+
focusable: "false",
|
|
100
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
101
|
+
d: "M4 4l8 8M12 4l-8 8",
|
|
102
|
+
stroke: "currentColor",
|
|
103
|
+
strokeWidth: "1.5",
|
|
104
|
+
strokeLinecap: "round"
|
|
105
|
+
})
|
|
106
|
+
})
|
|
107
|
+
}),
|
|
108
|
+
/* @__PURE__ */ jsx("button", {
|
|
109
|
+
ref: buttonRef,
|
|
110
|
+
type: "button",
|
|
111
|
+
className: cx("ds-date-picker__button", `ds-date-picker__button--${size}`),
|
|
112
|
+
"aria-label": chooseDateLabel,
|
|
113
|
+
"aria-haspopup": "dialog",
|
|
114
|
+
"aria-expanded": isOpen,
|
|
115
|
+
"aria-controls": isOpen ? dialogId : void 0,
|
|
116
|
+
disabled,
|
|
117
|
+
onClick: () => setOpen((prev) => !prev),
|
|
118
|
+
children: /* @__PURE__ */ jsxs("svg", {
|
|
119
|
+
viewBox: "0 0 16 16",
|
|
120
|
+
"aria-hidden": "true",
|
|
121
|
+
focusable: "false",
|
|
122
|
+
children: [/* @__PURE__ */ jsx("rect", {
|
|
123
|
+
x: "2.5",
|
|
124
|
+
y: "3.5",
|
|
125
|
+
width: "11",
|
|
126
|
+
height: "10",
|
|
127
|
+
rx: "1.5",
|
|
128
|
+
fill: "none",
|
|
129
|
+
stroke: "currentColor",
|
|
130
|
+
strokeWidth: "1.25"
|
|
131
|
+
}), /* @__PURE__ */ jsx("path", {
|
|
132
|
+
d: "M2.5 6.5h11M5.5 2v3M10.5 2v3",
|
|
133
|
+
stroke: "currentColor",
|
|
134
|
+
strokeWidth: "1.25",
|
|
135
|
+
strokeLinecap: "round"
|
|
136
|
+
})]
|
|
137
|
+
})
|
|
138
|
+
}),
|
|
139
|
+
isOpen && /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx("div", {
|
|
140
|
+
ref: popupCallbackRef,
|
|
141
|
+
id: dialogId,
|
|
142
|
+
role: "dialog",
|
|
143
|
+
"aria-modal": "false",
|
|
144
|
+
"aria-label": chooseDateLabel,
|
|
145
|
+
className: "ds-date-picker__popup",
|
|
146
|
+
onKeyDown: onPopupKeyDown,
|
|
147
|
+
style: {
|
|
148
|
+
top: position?.top ?? 0,
|
|
149
|
+
left: position?.left ?? 0,
|
|
150
|
+
opacity: position ? void 0 : 0
|
|
151
|
+
},
|
|
152
|
+
children: /* @__PURE__ */ jsx(Calendar, {
|
|
153
|
+
autoFocus: true,
|
|
154
|
+
value,
|
|
155
|
+
onChange: (date) => {
|
|
156
|
+
setValue(date);
|
|
157
|
+
close(true);
|
|
158
|
+
},
|
|
159
|
+
min,
|
|
160
|
+
max,
|
|
161
|
+
isDateDisabled,
|
|
162
|
+
locale,
|
|
163
|
+
weekStartsOn,
|
|
164
|
+
previousMonthLabel,
|
|
165
|
+
nextMonthLabel
|
|
166
|
+
})
|
|
167
|
+
}) })
|
|
168
|
+
]
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
export { Calendar, DatePicker as default };
|
|
172
|
+
|
|
173
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_jsxs","_jsx"],"sources":["../../../../src/components/organisms/date-picker/index.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n type InputHTMLAttributes,\n type KeyboardEvent as ReactKeyboardEvent,\n} from \"react\";\nimport TextInput, { type TextInputSize } from \"../../atoms/text-input\";\nimport { useClickOutside, useControllableState } from \"../../hooks\";\nimport { mergeRefs, useFloatingPosition } from \"../../molecules/popover/positioning\";\nimport { cx } from \"../../utils/cx\";\nimport Portal from \"../../utils/portal\";\nimport Calendar from \"./calendar\";\nimport { formatDate, isOutOfRange, isSameDay, parseDate, type WeekStart } from \"./date-utils\";\nimport \"./styles.css\";\n\nexport { default as Calendar } from \"./calendar\";\nexport type { CalendarProps, WeekStart } from \"./calendar\";\n\nexport interface DatePickerProps\n extends Omit<InputHTMLAttributes<HTMLInputElement>, \"value\" | \"defaultValue\" | \"onChange\" | \"size\" | \"min\" | \"max\"> {\n /** Selected date (controlled). `null` for empty */\n value?: Date | null;\n /** Initially selected date (uncontrolled) */\n defaultValue?: Date | null;\n /** Called when the date changes (picked, typed or cleared) */\n onChange?: (date: Date | null) => void;\n /** Whether the calendar popover is open (controlled) */\n open?: boolean;\n /** Initial open state (uncontrolled) */\n defaultOpen?: boolean;\n /** Called when the calendar popover opens or closes */\n onOpenChange?: (open: boolean) => void;\n /** Earliest selectable date */\n min?: Date | null;\n /** Latest selectable date */\n max?: Date | null;\n /** Return `true` to disable a specific date */\n isDateDisabled?: (date: Date) => boolean;\n /** BCP 47 locale for formatting, parsing and calendar labels */\n locale?: string;\n /** First day of the week: 0 = Sunday … 6 = Saturday */\n weekStartsOn?: WeekStart;\n /** Turns a date into the text shown in the input. Default: numeric date in `locale` */\n format?: (date: Date, locale: string) => string;\n /** Turns typed text into a date (or `null` if invalid). Default: ISO `yyyy-mm-dd`, then numeric date in `locale` */\n parse?: (text: string, locale: string) => Date | null;\n /** Show a button that clears the date */\n clearable?: boolean;\n /** Height and padding, from the control-size tokens */\n size?: TextInputSize;\n /** Marks the value as invalid */\n invalid?: boolean;\n /** Stretch to the container width */\n fullWidth?: boolean;\n /** Class name applied to the root wrapper */\n className?: string;\n /** Accessible label of the calendar button (and of the calendar dialog) */\n chooseDateLabel?: string;\n /** Accessible label of the clear button */\n clearLabel?: string;\n /** Accessible label of the previous-month button */\n previousMonthLabel?: string;\n /** Accessible label of the next-month button */\n nextMonthLabel?: string;\n}\n\n/** Date input with a calendar popover. Typed text is parsed on blur or Enter. */\nconst DatePicker = forwardRef<HTMLInputElement, DatePickerProps>(function DatePicker(\n {\n value: valueProp,\n defaultValue = null,\n onChange,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n min,\n max,\n isDateDisabled,\n locale = \"en-US\",\n weekStartsOn = 1,\n format = formatDate,\n parse = parseDate,\n clearable = false,\n size = \"md\",\n invalid = false,\n fullWidth = false,\n disabled,\n className,\n chooseDateLabel = \"Choose date\",\n clearLabel = \"Clear date\",\n previousMonthLabel,\n nextMonthLabel,\n onBlur,\n onKeyDown,\n ...rest\n },\n ref\n) {\n const [value, setValue] = useControllableState<Date | null>(valueProp, defaultValue, onChange);\n const [open, setOpen] = useControllableState(openProp, defaultOpen, onOpenChange);\n const formatted = value ? format(value, locale) : \"\";\n const [text, setText] = useState(formatted);\n const dialogId = useId();\n\n const wrapperRef = useRef<HTMLDivElement | null>(null);\n const buttonRef = useRef<HTMLButtonElement | null>(null);\n const inputRef = useRef<HTMLInputElement | null>(null);\n const popupRef = useRef<HTMLDivElement | null>(null);\n const [popup, setPopup] = useState<HTMLDivElement | null>(null);\n const isOpen = open && !disabled;\n const position = useFloatingPosition(wrapperRef, popup, isOpen, \"bottom-start\", 4);\n const inputCallbackRef = useMemo(() => mergeRefs<HTMLInputElement>(inputRef, ref), [ref]);\n\n useEffect(() => setText(formatted), [formatted]);\n\n useClickOutside([wrapperRef, popupRef], () => setOpen(false), isOpen);\n\n const popupCallbackRef = useCallback((node: HTMLDivElement | null) => {\n popupRef.current = node;\n setPopup(node);\n }, []);\n\n const isDisabled = (date: Date) => isOutOfRange(date, min, max) || Boolean(isDateDisabled?.(date));\n\n const commitText = () => {\n const trimmed = text.trim();\n if (trimmed === \"\") {\n setValue(null);\n setText(\"\");\n return;\n }\n const parsed = parse(trimmed, locale);\n if (parsed && !isDisabled(parsed)) {\n if (!isSameDay(parsed, value)) setValue(parsed);\n setText(format(parsed, locale));\n } else {\n setText(formatted);\n }\n };\n\n const close = (returnFocus: boolean) => {\n setOpen(false);\n if (returnFocus) buttonRef.current?.focus();\n };\n\n const onPopupKeyDown = (event: ReactKeyboardEvent<HTMLDivElement>) => {\n if (event.key === \"Escape\") {\n event.preventDefault();\n event.stopPropagation();\n close(true);\n }\n };\n\n return (\n <div\n ref={wrapperRef}\n className={cx(\"ds-date-picker\", fullWidth && \"ds-date-picker--full\", className)}\n >\n <TextInput\n {...rest}\n ref={inputCallbackRef}\n size={size}\n invalid={invalid}\n disabled={disabled}\n fullWidth={fullWidth}\n className=\"ds-date-picker__input\"\n value={text}\n onChange={(event) => setText(event.target.value)}\n onBlur={(event) => {\n commitText();\n onBlur?.(event);\n }}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (event.defaultPrevented) return;\n if (event.key === \"Enter\") commitText();\n else if (event.key === \"ArrowDown\" && event.altKey) {\n event.preventDefault();\n setOpen(true);\n }\n }}\n />\n {clearable && value && !disabled && (\n <button\n type=\"button\"\n className={cx(\"ds-date-picker__button\", `ds-date-picker__button--${size}`)}\n aria-label={clearLabel}\n onClick={() => {\n setValue(null);\n setText(\"\");\n inputRef.current?.focus();\n }}\n >\n <svg viewBox=\"0 0 16 16\" aria-hidden=\"true\" focusable=\"false\">\n <path d=\"M4 4l8 8M12 4l-8 8\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" />\n </svg>\n </button>\n )}\n <button\n ref={buttonRef}\n type=\"button\"\n className={cx(\"ds-date-picker__button\", `ds-date-picker__button--${size}`)}\n aria-label={chooseDateLabel}\n aria-haspopup=\"dialog\"\n aria-expanded={isOpen}\n aria-controls={isOpen ? dialogId : undefined}\n disabled={disabled}\n onClick={() => setOpen((prev) => !prev)}\n >\n <svg viewBox=\"0 0 16 16\" aria-hidden=\"true\" focusable=\"false\">\n <rect x=\"2.5\" y=\"3.5\" width=\"11\" height=\"10\" rx=\"1.5\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.25\" />\n <path d=\"M2.5 6.5h11M5.5 2v3M10.5 2v3\" stroke=\"currentColor\" strokeWidth=\"1.25\" strokeLinecap=\"round\" />\n </svg>\n </button>\n {isOpen && (\n <Portal>\n <div\n ref={popupCallbackRef}\n id={dialogId}\n role=\"dialog\"\n aria-modal=\"false\"\n aria-label={chooseDateLabel}\n className=\"ds-date-picker__popup\"\n onKeyDown={onPopupKeyDown}\n style={{\n top: position?.top ?? 0,\n left: position?.left ?? 0,\n // Not `visibility: hidden`: the calendar focuses its grid on mount, before the first measurement.\n opacity: position ? undefined : 0,\n }}\n >\n <Calendar\n autoFocus\n value={value}\n onChange={(date) => {\n setValue(date);\n close(true);\n }}\n min={min}\n max={max}\n isDateDisabled={isDateDisabled}\n locale={locale}\n weekStartsOn={weekStartsOn}\n previousMonthLabel={previousMonthLabel}\n nextMonthLabel={nextMonthLabel}\n />\n </div>\n </Portal>\n )}\n </div>\n );\n});\n\nexport default DatePicker;\n"],"mappings":"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"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/* Calendar */
|
|
2
|
+
.ds-calendar {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
gap: var(--space-2);
|
|
6
|
+
color: var(--color-text);
|
|
7
|
+
font-family: var(--font-sans);
|
|
8
|
+
font-size: var(--font-size-sm);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.ds-calendar__header {
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
justify-content: space-between;
|
|
15
|
+
gap: var(--space-2);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.ds-calendar__title {
|
|
19
|
+
margin: 0;
|
|
20
|
+
font-size: var(--font-size-sm);
|
|
21
|
+
font-weight: var(--font-weight-semibold);
|
|
22
|
+
line-height: var(--line-height-tight);
|
|
23
|
+
text-transform: capitalize;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.ds-calendar__nav-icon {
|
|
27
|
+
width: var(--icon-size-sm);
|
|
28
|
+
height: var(--icon-size-sm);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.ds-calendar__grid {
|
|
32
|
+
border-collapse: collapse;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.ds-calendar__weekday {
|
|
36
|
+
width: var(--control-height-md);
|
|
37
|
+
padding-bottom: var(--space-1);
|
|
38
|
+
color: var(--color-text-muted);
|
|
39
|
+
font-size: var(--font-size-xs);
|
|
40
|
+
font-weight: var(--font-weight-medium);
|
|
41
|
+
text-align: center;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.ds-calendar__day {
|
|
45
|
+
width: var(--control-height-md);
|
|
46
|
+
height: var(--control-height-md);
|
|
47
|
+
padding: 0;
|
|
48
|
+
border-radius: var(--radius-md);
|
|
49
|
+
text-align: center;
|
|
50
|
+
cursor: pointer;
|
|
51
|
+
transition: background-color var(--duration-fast) var(--easing-standard);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.ds-calendar__day:hover {
|
|
55
|
+
background: var(--color-neutral-hover);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.ds-calendar__day:focus-visible {
|
|
59
|
+
outline: var(--border-width-2) solid var(--color-focus-ring);
|
|
60
|
+
outline-offset: 2px;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.ds-calendar__day[aria-current="date"] {
|
|
64
|
+
font-weight: var(--font-weight-bold);
|
|
65
|
+
color: var(--color-primary-text);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.ds-calendar__day--outside {
|
|
69
|
+
color: var(--color-text-subtle);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.ds-calendar__day--selected,
|
|
73
|
+
.ds-calendar__day--selected:hover {
|
|
74
|
+
background: var(--color-primary);
|
|
75
|
+
color: var(--color-text-on-primary);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.ds-calendar__day--selected[aria-current="date"] {
|
|
79
|
+
color: var(--color-text-on-primary);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.ds-calendar__day--disabled,
|
|
83
|
+
.ds-calendar__day--disabled:hover {
|
|
84
|
+
background: transparent;
|
|
85
|
+
color: var(--color-text-disabled);
|
|
86
|
+
text-decoration: line-through;
|
|
87
|
+
cursor: not-allowed;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/* DatePicker */
|
|
91
|
+
.ds-date-picker {
|
|
92
|
+
display: inline-flex;
|
|
93
|
+
align-items: center;
|
|
94
|
+
gap: var(--space-1);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.ds-date-picker--full {
|
|
98
|
+
display: flex;
|
|
99
|
+
width: 100%;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.ds-date-picker--full .ds-date-picker__input {
|
|
103
|
+
flex: 1;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.ds-date-picker__button {
|
|
107
|
+
display: inline-flex;
|
|
108
|
+
align-items: center;
|
|
109
|
+
justify-content: center;
|
|
110
|
+
flex-shrink: 0;
|
|
111
|
+
width: var(--control-height-md);
|
|
112
|
+
height: var(--control-height-md);
|
|
113
|
+
padding: 0;
|
|
114
|
+
border: var(--border-width-1) solid var(--color-border-strong);
|
|
115
|
+
border-radius: var(--radius-md);
|
|
116
|
+
background: var(--color-surface);
|
|
117
|
+
color: var(--color-text-muted);
|
|
118
|
+
cursor: pointer;
|
|
119
|
+
transition: background-color var(--duration-fast) var(--easing-standard);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.ds-date-picker__button svg {
|
|
123
|
+
width: var(--icon-size-sm);
|
|
124
|
+
height: var(--icon-size-sm);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.ds-date-picker__button:hover:not(:disabled) {
|
|
128
|
+
background: var(--color-neutral);
|
|
129
|
+
color: var(--color-text);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.ds-date-picker__button:focus-visible {
|
|
133
|
+
outline: var(--border-width-2) solid var(--color-focus-ring);
|
|
134
|
+
outline-offset: 2px;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.ds-date-picker__button:disabled {
|
|
138
|
+
background: var(--color-bg-subtle);
|
|
139
|
+
color: var(--color-text-disabled);
|
|
140
|
+
cursor: not-allowed;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.ds-date-picker__button--sm {
|
|
144
|
+
width: var(--control-height-sm);
|
|
145
|
+
height: var(--control-height-sm);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.ds-date-picker__button--lg {
|
|
149
|
+
width: var(--control-height-lg);
|
|
150
|
+
height: var(--control-height-lg);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.ds-date-picker__popup {
|
|
154
|
+
position: fixed;
|
|
155
|
+
z-index: var(--z-popover);
|
|
156
|
+
padding: var(--space-3);
|
|
157
|
+
background: var(--color-surface-raised);
|
|
158
|
+
border: var(--border-width-1) solid var(--color-border);
|
|
159
|
+
border-radius: var(--radius-lg);
|
|
160
|
+
box-shadow: var(--shadow-lg);
|
|
161
|
+
animation: ds-date-picker-in var(--duration-fast) var(--easing-out);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
@keyframes ds-date-picker-in {
|
|
165
|
+
from {
|
|
166
|
+
opacity: 0;
|
|
167
|
+
}
|
|
168
|
+
to {
|
|
169
|
+
opacity: 1;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
@media (prefers-reduced-motion: reduce) {
|
|
174
|
+
.ds-date-picker__popup,
|
|
175
|
+
.ds-calendar__day {
|
|
176
|
+
animation: none;
|
|
177
|
+
transition: none;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type DialogBaseProps } from "../modal/dialog-base";
|
|
2
|
+
export type DrawerSide = "left" | "right" | "top" | "bottom";
|
|
3
|
+
export type DrawerSize = "sm" | "md" | "lg";
|
|
4
|
+
export interface DrawerProps extends DialogBaseProps {
|
|
5
|
+
/** Whether the drawer is shown */
|
|
6
|
+
open: boolean;
|
|
7
|
+
/** Called when the drawer asks to close (close button, overlay click or Escape) */
|
|
8
|
+
onClose: () => void;
|
|
9
|
+
/** Edge of the viewport the drawer slides in from */
|
|
10
|
+
side?: DrawerSide;
|
|
11
|
+
/** Width (left / right) or height (top / bottom) of the panel */
|
|
12
|
+
size?: DrawerSize;
|
|
13
|
+
}
|
|
14
|
+
/** Panel that slides in from an edge of the viewport, with the same dialog semantics as Modal. */
|
|
15
|
+
declare function Drawer({ side, size, ...rest }: DrawerProps): import("react").JSX.Element;
|
|
16
|
+
export default Drawer;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DialogBase } from "../modal/dialog-base.js";
|
|
2
|
+
import './styles.css';/* empty css */
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
// src/components/organisms/drawer/index.tsx
|
|
5
|
+
/** Panel that slides in from an edge of the viewport, with the same dialog semantics as Modal. */
|
|
6
|
+
function Drawer({ side = "right", size = "md", ...rest }) {
|
|
7
|
+
return /* @__PURE__ */ jsx(DialogBase, {
|
|
8
|
+
name: "drawer",
|
|
9
|
+
modifiers: [`ds-drawer--${side}`, `ds-drawer--${size}`],
|
|
10
|
+
...rest
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
export { Drawer as default };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_jsx"],"sources":["../../../../src/components/organisms/drawer/index.tsx"],"sourcesContent":["import { DialogBase, type DialogBaseProps } from \"../modal/dialog-base\";\nimport \"./styles.css\";\n\nexport type DrawerSide = \"left\" | \"right\" | \"top\" | \"bottom\";\nexport type DrawerSize = \"sm\" | \"md\" | \"lg\";\n\nexport interface DrawerProps extends DialogBaseProps {\n /** Whether the drawer is shown */\n open: boolean;\n /** Called when the drawer asks to close (close button, overlay click or Escape) */\n onClose: () => void;\n /** Edge of the viewport the drawer slides in from */\n side?: DrawerSide;\n /** Width (left / right) or height (top / bottom) of the panel */\n size?: DrawerSize;\n}\n\n/** Panel that slides in from an edge of the viewport, with the same dialog semantics as Modal. */\nfunction Drawer({ side = \"right\", size = \"md\", ...rest }: DrawerProps) {\n return <DialogBase name=\"drawer\" modifiers={[`ds-drawer--${side}`, `ds-drawer--${size}`]} {...rest} />;\n}\n\nexport default Drawer;\n"],"mappings":";;;;;AAkBA,SAAS,OAAO,EAAE,OAAO,SAAS,OAAO,MAAM,GAAG,QAAqB;CACrE,OAAOA,oBAAC,YAAD;EAAY,MAAK;EAAS,WAAW,CAAC,cAAc,QAAQ,cAAc,MAAM;EAAG,GAAI;CAAO,CAAA;AACvG"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
.ds-drawer__overlay {
|
|
2
|
+
position: fixed;
|
|
3
|
+
inset: 0;
|
|
4
|
+
z-index: var(--z-overlay);
|
|
5
|
+
background: var(--color-overlay);
|
|
6
|
+
animation: ds-drawer-fade var(--duration-normal) var(--easing-out);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.ds-drawer__positioner {
|
|
10
|
+
position: fixed;
|
|
11
|
+
inset: 0;
|
|
12
|
+
z-index: var(--z-modal);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.ds-drawer {
|
|
16
|
+
position: absolute;
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
background: var(--color-surface-raised);
|
|
20
|
+
color: var(--color-text);
|
|
21
|
+
box-shadow: var(--shadow-xl);
|
|
22
|
+
font-family: var(--font-sans);
|
|
23
|
+
animation: var(--duration-slow) var(--easing-out) both;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.ds-drawer:focus {
|
|
27
|
+
outline: none;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/* Sides */
|
|
31
|
+
.ds-drawer--left,
|
|
32
|
+
.ds-drawer--right {
|
|
33
|
+
top: 0;
|
|
34
|
+
bottom: 0;
|
|
35
|
+
width: 100%;
|
|
36
|
+
}
|
|
37
|
+
.ds-drawer--left { left: 0; animation-name: ds-drawer-in-left; }
|
|
38
|
+
.ds-drawer--right { right: 0; animation-name: ds-drawer-in-right; }
|
|
39
|
+
|
|
40
|
+
.ds-drawer--top,
|
|
41
|
+
.ds-drawer--bottom {
|
|
42
|
+
left: 0;
|
|
43
|
+
right: 0;
|
|
44
|
+
height: 100%;
|
|
45
|
+
}
|
|
46
|
+
.ds-drawer--top { top: 0; animation-name: ds-drawer-in-top; }
|
|
47
|
+
.ds-drawer--bottom { bottom: 0; animation-name: ds-drawer-in-bottom; }
|
|
48
|
+
|
|
49
|
+
/* Sizes */
|
|
50
|
+
.ds-drawer--left.ds-drawer--sm,
|
|
51
|
+
.ds-drawer--right.ds-drawer--sm { max-width: 320px; }
|
|
52
|
+
.ds-drawer--left.ds-drawer--md,
|
|
53
|
+
.ds-drawer--right.ds-drawer--md { max-width: 480px; }
|
|
54
|
+
.ds-drawer--left.ds-drawer--lg,
|
|
55
|
+
.ds-drawer--right.ds-drawer--lg { max-width: 720px; }
|
|
56
|
+
.ds-drawer--top.ds-drawer--sm,
|
|
57
|
+
.ds-drawer--bottom.ds-drawer--sm { max-height: 25vh; }
|
|
58
|
+
.ds-drawer--top.ds-drawer--md,
|
|
59
|
+
.ds-drawer--bottom.ds-drawer--md { max-height: 50vh; }
|
|
60
|
+
.ds-drawer--top.ds-drawer--lg,
|
|
61
|
+
.ds-drawer--bottom.ds-drawer--lg { max-height: 80vh; }
|
|
62
|
+
|
|
63
|
+
.ds-drawer__header {
|
|
64
|
+
display: flex;
|
|
65
|
+
align-items: flex-start;
|
|
66
|
+
gap: var(--space-4);
|
|
67
|
+
padding: var(--space-5) var(--space-6) var(--space-3);
|
|
68
|
+
border-bottom: var(--border-width-1) solid var(--color-border);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.ds-drawer__heading {
|
|
72
|
+
flex: 1;
|
|
73
|
+
min-width: 0;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.ds-drawer__title {
|
|
77
|
+
margin: 0;
|
|
78
|
+
font-size: var(--font-size-lg);
|
|
79
|
+
font-weight: var(--font-weight-semibold);
|
|
80
|
+
line-height: var(--line-height-tight);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.ds-drawer__description {
|
|
84
|
+
margin: var(--space-1) 0 0;
|
|
85
|
+
color: var(--color-text-muted);
|
|
86
|
+
font-size: var(--font-size-sm);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.ds-drawer__close {
|
|
90
|
+
display: inline-flex;
|
|
91
|
+
align-items: center;
|
|
92
|
+
justify-content: center;
|
|
93
|
+
flex-shrink: 0;
|
|
94
|
+
width: var(--control-height-sm);
|
|
95
|
+
height: var(--control-height-sm);
|
|
96
|
+
padding: 0;
|
|
97
|
+
border: 0;
|
|
98
|
+
border-radius: var(--radius-md);
|
|
99
|
+
background: transparent;
|
|
100
|
+
color: var(--color-text-muted);
|
|
101
|
+
cursor: pointer;
|
|
102
|
+
transition: background-color var(--duration-fast) var(--easing-standard);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.ds-drawer__close svg {
|
|
106
|
+
width: var(--icon-size-sm);
|
|
107
|
+
height: var(--icon-size-sm);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.ds-drawer__close:hover {
|
|
111
|
+
background: var(--color-neutral);
|
|
112
|
+
color: var(--color-text);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.ds-drawer__close:focus-visible {
|
|
116
|
+
outline: var(--border-width-2) solid var(--color-focus-ring);
|
|
117
|
+
outline-offset: 2px;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.ds-drawer__body {
|
|
121
|
+
flex: 1;
|
|
122
|
+
min-height: 0;
|
|
123
|
+
padding: var(--space-4) var(--space-6);
|
|
124
|
+
overflow-y: auto;
|
|
125
|
+
font-size: var(--font-size-sm);
|
|
126
|
+
line-height: var(--line-height-normal);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.ds-drawer__footer {
|
|
130
|
+
display: flex;
|
|
131
|
+
justify-content: flex-end;
|
|
132
|
+
gap: var(--space-2);
|
|
133
|
+
padding: var(--space-3) var(--space-6);
|
|
134
|
+
border-top: var(--border-width-1) solid var(--color-border);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
@keyframes ds-drawer-fade {
|
|
138
|
+
from { opacity: 0; }
|
|
139
|
+
to { opacity: 1; }
|
|
140
|
+
}
|
|
141
|
+
@keyframes ds-drawer-in-left {
|
|
142
|
+
from { transform: translateX(-100%); }
|
|
143
|
+
to { transform: none; }
|
|
144
|
+
}
|
|
145
|
+
@keyframes ds-drawer-in-right {
|
|
146
|
+
from { transform: translateX(100%); }
|
|
147
|
+
to { transform: none; }
|
|
148
|
+
}
|
|
149
|
+
@keyframes ds-drawer-in-top {
|
|
150
|
+
from { transform: translateY(-100%); }
|
|
151
|
+
to { transform: none; }
|
|
152
|
+
}
|
|
153
|
+
@keyframes ds-drawer-in-bottom {
|
|
154
|
+
from { transform: translateY(100%); }
|
|
155
|
+
to { transform: none; }
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
@media (prefers-reduced-motion: reduce) {
|
|
159
|
+
.ds-drawer,
|
|
160
|
+
.ds-drawer__overlay {
|
|
161
|
+
animation: none;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ClassicEditor } from "ckeditor5";
|
|
2
|
+
export interface EditorProps {
|
|
3
|
+
/** Value of editor content (HTML) */
|
|
4
|
+
value?: string;
|
|
5
|
+
/** Called with the editor HTML on each change */
|
|
6
|
+
onChange?: (data: string) => void;
|
|
7
|
+
/** Called when the editor loses focus */
|
|
8
|
+
onBlur?: (editor: ClassicEditor) => void;
|
|
9
|
+
/** Called when the editor gets focus */
|
|
10
|
+
onFocus?: (editor: ClassicEditor) => void;
|
|
11
|
+
}
|
|
12
|
+
declare function Editor({ onChange, onBlur, onFocus, value }: EditorProps): import("react").JSX.Element;
|
|
13
|
+
export default Editor;
|