@jcsoftdev/ui 0.3.0 → 0.5.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/CHANGELOG.md +200 -1
- package/README.md +56 -3
- package/bin/ui-theme.mjs +13 -2
- package/dist/atoms/button/button.d.ts +8 -1
- package/dist/atoms/button/button.js +10 -3
- package/dist/atoms/checkbox/checkbox.js +3 -1
- package/dist/atoms/chip/chip.d.ts +11 -3
- package/dist/atoms/chip/chip.js +8 -1
- package/dist/atoms/chip/index.d.ts +1 -1
- package/dist/atoms/chip/index.js +2 -0
- package/dist/atoms/divider/divider.d.ts +15 -0
- package/dist/atoms/divider/divider.js +27 -0
- package/dist/atoms/divider/index.d.ts +1 -0
- package/dist/atoms/divider/index.js +1 -0
- package/dist/atoms/due-chip/due-chip.d.ts +31 -0
- package/dist/atoms/due-chip/due-chip.js +41 -0
- package/dist/atoms/due-chip/index.d.ts +2 -0
- package/dist/atoms/due-chip/index.js +6 -0
- package/dist/atoms/due-chip/model.d.ts +25 -0
- package/dist/atoms/due-chip/model.js +44 -0
- package/dist/atoms/icon-button/icon-button.d.ts +22 -0
- package/dist/atoms/icon-button/icon-button.js +38 -0
- package/dist/atoms/icon-button/index.d.ts +1 -0
- package/dist/atoms/icon-button/index.js +8 -0
- package/dist/atoms/index.d.ts +6 -0
- package/dist/atoms/index.js +6 -0
- package/dist/atoms/internal/hit-area.d.ts +6 -0
- package/dist/atoms/internal/hit-area.js +4 -0
- package/dist/atoms/kbd/index.d.ts +1 -0
- package/dist/atoms/kbd/index.js +4 -0
- package/dist/atoms/kbd/kbd.d.ts +7 -0
- package/dist/atoms/kbd/kbd.js +17 -0
- package/dist/atoms/radio-group/radio-group.js +6 -2
- package/dist/atoms/seal/index.d.ts +1 -0
- package/dist/atoms/seal/index.js +4 -0
- package/dist/atoms/seal/seal.d.ts +30 -0
- package/dist/atoms/seal/seal.js +71 -0
- package/dist/atoms/spinner/index.d.ts +1 -0
- package/dist/atoms/spinner/index.js +5 -0
- package/dist/atoms/spinner/spinner.d.ts +19 -0
- package/dist/atoms/spinner/spinner.js +31 -0
- package/dist/atoms/switch/switch.js +3 -1
- package/dist/auth/auth-illustration/auth-illustration.d.ts +35 -0
- package/dist/auth/auth-illustration/auth-illustration.js +72 -0
- package/dist/auth/auth-illustration/index.d.ts +3 -0
- package/dist/auth/auth-illustration/index.js +11 -0
- package/dist/auth/auth-illustration/look.d.ts +30 -0
- package/dist/auth/auth-illustration/look.js +0 -0
- package/dist/auth/auth-illustration/model.d.ts +133 -0
- package/dist/auth/auth-illustration/model.js +202 -0
- package/dist/auth/auth-illustration/use-art-pointer.d.ts +9 -0
- package/dist/auth/auth-illustration/use-art-pointer.js +69 -0
- package/dist/auth/auth-layout/auth-layout.d.ts +80 -0
- package/dist/auth/auth-layout/auth-layout.js +190 -0
- package/dist/auth/auth-layout/index.d.ts +1 -0
- package/dist/auth/auth-layout/index.js +1 -0
- package/dist/auth/character/character.d.ts +12 -0
- package/dist/auth/character/character.js +333 -0
- package/dist/auth/character/index.d.ts +1 -0
- package/dist/auth/character/index.js +1 -0
- package/dist/auth/index.d.ts +4 -0
- package/dist/auth/index.js +4 -0
- package/dist/auth/internal/auth-context.d.ts +17 -0
- package/dist/auth/internal/auth-context.js +10 -0
- package/dist/auth/internal/auth-styles.d.ts +1 -0
- package/dist/auth/internal/auth-styles.js +29 -0
- package/dist/auth/internal/portal-glyphs.d.ts +6 -0
- package/dist/auth/internal/portal-glyphs.js +39 -0
- package/dist/auth/login-form/context.d.ts +51 -0
- package/dist/auth/login-form/context.js +12 -0
- package/dist/auth/login-form/index.d.ts +2 -0
- package/dist/auth/login-form/index.js +23 -0
- package/dist/auth/login-form/login-form.d.ts +66 -0
- package/dist/auth/login-form/login-form.js +233 -0
- package/dist/auth/login-form/parts.d.ts +71 -0
- package/dist/auth/login-form/parts.js +371 -0
- package/dist/auth/looks/auth-illustration-any.d.ts +16 -0
- package/dist/auth/looks/auth-illustration-any.js +24 -0
- package/dist/auth/looks/index.d.ts +1 -0
- package/dist/auth/looks/index.js +1 -0
- package/dist/auth/mosaic/index.d.ts +1 -0
- package/dist/auth/mosaic/index.js +1 -0
- package/dist/auth/mosaic/mosaic.d.ts +11 -0
- package/dist/auth/mosaic/mosaic.js +195 -0
- package/dist/auth/slabs/index.d.ts +1 -0
- package/dist/auth/slabs/index.js +1 -0
- package/dist/auth/slabs/slabs.d.ts +13 -0
- package/dist/auth/slabs/slabs.js +136 -0
- package/dist/auth/stack/index.d.ts +1 -0
- package/dist/auth/stack/index.js +1 -0
- package/dist/auth/stack/stack.d.ts +6 -0
- package/dist/auth/stack/stack.js +222 -0
- package/dist/auth/statement/index.d.ts +1 -0
- package/dist/auth/statement/index.js +1 -0
- package/dist/auth/statement/statement.d.ts +13 -0
- package/dist/auth/statement/statement.js +99 -0
- package/dist/calendar/date-calendar/date-calendar.d.ts +32 -0
- package/dist/calendar/date-calendar/date-calendar.js +189 -0
- package/dist/calendar/date-calendar/index.d.ts +1 -0
- package/dist/calendar/date-calendar/index.js +6 -0
- package/dist/calendar/index.d.ts +1 -0
- package/dist/calendar/index.js +1 -0
- package/dist/calendar/internal/date-utils.d.ts +26 -0
- package/dist/calendar/internal/date-utils.js +95 -1
- package/dist/containers/aside/aside.d.ts +14 -0
- package/dist/containers/aside/aside.js +25 -0
- package/dist/containers/aside/index.d.ts +1 -0
- package/dist/containers/aside/index.js +5 -0
- package/dist/containers/banner/banner.d.ts +4 -1
- package/dist/containers/banner/banner.js +9 -1
- package/dist/containers/description-list/description-list.d.ts +29 -6
- package/dist/containers/description-list/description-list.js +47 -6
- package/dist/containers/feed/feed.d.ts +23 -0
- package/dist/containers/feed/feed.js +77 -0
- package/dist/containers/feed/index.d.ts +2 -0
- package/dist/containers/feed/index.js +10 -0
- package/dist/containers/feed/model.d.ts +19 -0
- package/dist/containers/feed/model.js +38 -0
- package/dist/containers/index.d.ts +6 -0
- package/dist/containers/index.js +6 -0
- package/dist/containers/kpi/kpi.d.ts +50 -8
- package/dist/containers/kpi/kpi.js +91 -39
- package/dist/containers/list-detail/index.d.ts +1 -0
- package/dist/containers/list-detail/index.js +20 -0
- package/dist/containers/list-detail/list-detail.d.ts +55 -0
- package/dist/containers/list-detail/list-detail.js +221 -0
- package/dist/containers/note/index.d.ts +1 -0
- package/dist/containers/note/index.js +4 -0
- package/dist/containers/note/note.d.ts +13 -0
- package/dist/containers/note/note.js +27 -0
- package/dist/containers/section/index.d.ts +1 -0
- package/dist/containers/section/index.js +6 -0
- package/dist/containers/section/section.d.ts +68 -0
- package/dist/containers/section/section.js +198 -0
- package/dist/containers/shortcuts/index.d.ts +1 -0
- package/dist/containers/shortcuts/index.js +8 -0
- package/dist/containers/shortcuts/shortcuts.d.ts +18 -0
- package/dist/containers/shortcuts/shortcuts.js +50 -0
- package/dist/containers/table/selection.d.ts +9 -0
- package/dist/containers/table/selection.js +20 -0
- package/dist/containers/table/table.d.ts +66 -4
- package/dist/containers/table/table.js +128 -7
- package/dist/containers/timeline/index.d.ts +1 -1
- package/dist/containers/timeline/index.js +4 -2
- package/dist/containers/timeline/timeline.d.ts +32 -5
- package/dist/containers/timeline/timeline.js +154 -90
- package/dist/forms/chip-group/chip-group.d.ts +54 -0
- package/dist/forms/chip-group/chip-group.js +114 -0
- package/dist/forms/chip-group/index.d.ts +1 -0
- package/dist/forms/chip-group/index.js +6 -0
- package/dist/forms/combobox/combobox.d.ts +60 -0
- package/dist/forms/combobox/combobox.js +281 -0
- package/dist/forms/combobox/index.d.ts +1 -0
- package/dist/forms/combobox/index.js +6 -0
- package/dist/forms/date-picker/date-picker.d.ts +40 -0
- package/dist/forms/date-picker/date-picker.js +183 -0
- package/dist/forms/date-picker/date-time-picker.d.ts +43 -0
- package/dist/forms/date-picker/date-time-picker.js +121 -0
- package/dist/forms/date-picker/index.d.ts +2 -0
- package/dist/forms/date-picker/index.js +10 -0
- package/dist/forms/date-picker/model.d.ts +35 -0
- package/dist/forms/date-picker/model.js +83 -0
- package/dist/forms/dropzone/dropzone.d.ts +30 -2
- package/dist/forms/dropzone/dropzone.js +153 -23
- package/dist/forms/field/field.d.ts +16 -10
- package/dist/forms/field/field.js +41 -5
- package/dist/forms/index.d.ts +5 -0
- package/dist/forms/index.js +5 -0
- package/dist/forms/input/index.d.ts +1 -1
- package/dist/forms/input/index.js +4 -1
- package/dist/forms/input/input.d.ts +21 -5
- package/dist/forms/input/input.js +75 -9
- package/dist/forms/input-icon/input-icon.d.ts +1 -1
- package/dist/forms/internal/listbox-items.d.ts +18 -0
- package/dist/forms/internal/listbox-items.js +88 -0
- package/dist/forms/internal/listbox.d.ts +44 -0
- package/dist/forms/internal/listbox.js +74 -0
- package/dist/forms/number-stepper/model.d.ts +16 -0
- package/dist/forms/number-stepper/model.js +23 -0
- package/dist/forms/number-stepper/number-stepper.d.ts +36 -6
- package/dist/forms/number-stepper/number-stepper.js +86 -37
- package/dist/forms/password-input/index.d.ts +1 -0
- package/dist/forms/password-input/index.js +1 -0
- package/dist/forms/password-input/password-input.d.ts +16 -0
- package/dist/forms/password-input/password-input.js +45 -0
- package/dist/forms/select-menu/index.d.ts +1 -0
- package/dist/forms/select-menu/index.js +6 -0
- package/dist/forms/select-menu/select-menu.d.ts +35 -0
- package/dist/forms/select-menu/select-menu.js +230 -0
- package/dist/i18n/strings.d.ts +153 -0
- package/dist/i18n/strings.js +86 -2
- package/dist/i18n/ui-strings-provider.d.ts +1 -1
- package/dist/i18n/ui-strings-provider.js +6 -2
- package/dist/icons/eye.d.ts +2 -0
- package/dist/icons/eye.js +11 -0
- package/dist/icons/graduation-cap.d.ts +2 -0
- package/dist/icons/graduation-cap.js +12 -0
- package/dist/icons/house.d.ts +2 -0
- package/dist/icons/house.js +11 -0
- package/dist/icons/index.d.ts +4 -0
- package/dist/icons/index.js +8 -0
- package/dist/icons/mail.d.ts +2 -0
- package/dist/icons/mail.js +11 -0
- package/dist/navigation/index.d.ts +1 -0
- package/dist/navigation/index.js +1 -0
- package/dist/navigation/stepper/index.d.ts +1 -1
- package/dist/navigation/stepper/index.js +3 -1
- package/dist/navigation/stepper/stepper.d.ts +8 -0
- package/dist/navigation/stepper/stepper.js +68 -45
- package/dist/navigation/tabs/index.d.ts +1 -0
- package/dist/navigation/tabs/index.js +6 -0
- package/dist/navigation/tabs/tabs-nav.d.ts +37 -0
- package/dist/navigation/tabs/tabs-nav.js +57 -0
- package/dist/navigation/wizard/index.d.ts +1 -0
- package/dist/navigation/wizard/index.js +6 -0
- package/dist/navigation/wizard/model.d.ts +33 -0
- package/dist/navigation/wizard/model.js +34 -0
- package/dist/navigation/wizard/wizard.d.ts +45 -0
- package/dist/navigation/wizard/wizard.js +169 -0
- package/dist/overlays/alert-dialog/alert-dialog.d.ts +103 -0
- package/dist/overlays/alert-dialog/alert-dialog.js +342 -0
- package/dist/overlays/alert-dialog/index.d.ts +1 -0
- package/dist/overlays/alert-dialog/index.js +26 -0
- package/dist/overlays/dropdown-menu/dropdown-menu.d.ts +17 -1
- package/dist/overlays/dropdown-menu/dropdown-menu.js +12 -4
- package/dist/overlays/dropdown-menu/index.d.ts +1 -1
- package/dist/overlays/dropdown-menu/index.js +8 -2
- package/dist/overlays/index.d.ts +2 -0
- package/dist/overlays/index.js +2 -0
- package/dist/overlays/testing/index.d.ts +5 -0
- package/dist/overlays/testing/index.js +4 -0
- package/dist/overlays/toaster/index.d.ts +2 -1
- package/dist/overlays/toaster/index.js +4 -2
- package/dist/overlays/toaster/toast-store.d.ts +6 -2
- package/dist/overlays/toaster/toast.d.ts +3 -0
- package/dist/overlays/toaster/toast.js +3 -0
- package/dist/overlays/toaster/toaster.d.ts +3 -0
- package/dist/overlays/toaster/toaster.js +36 -3
- package/dist/overlays/tooltip/index.d.ts +1 -0
- package/dist/overlays/tooltip/index.js +4 -0
- package/dist/overlays/tooltip/model.d.ts +10 -0
- package/dist/overlays/tooltip/model.js +13 -0
- package/dist/overlays/tooltip/tooltip.d.ts +41 -0
- package/dist/overlays/tooltip/tooltip.js +116 -0
- package/dist/primitives/use-dismissable-layer.js +1 -1
- package/dist/states/error-state/error-state.d.ts +6 -1
- package/dist/states/error-state/error-state.js +13 -9
- package/dist/states/skeleton/skeleton.d.ts +8 -2
- package/dist/states/skeleton/skeleton.js +44 -2
- package/icons/svg/eye.svg +4 -0
- package/icons/svg/graduation-cap.svg +5 -0
- package/icons/svg/house.svg +4 -0
- package/icons/svg/mail.svg +4 -0
- package/package.json +2 -2
- package/scripts/build-theme.mjs +12 -1
- package/src/atoms/button/button.tsx +25 -3
- package/src/atoms/checkbox/checkbox.tsx +3 -1
- package/src/atoms/chip/chip.tsx +18 -3
- package/src/atoms/chip/index.ts +2 -0
- package/src/atoms/divider/divider.tsx +40 -0
- package/src/atoms/divider/index.ts +1 -0
- package/src/atoms/due-chip/due-chip.tsx +75 -0
- package/src/atoms/due-chip/index.ts +2 -0
- package/src/atoms/due-chip/model.ts +67 -0
- package/src/atoms/icon-button/icon-button.tsx +58 -0
- package/src/atoms/icon-button/index.ts +6 -0
- package/src/atoms/index.ts +6 -0
- package/src/atoms/internal/hit-area.ts +7 -0
- package/src/atoms/kbd/index.ts +1 -0
- package/src/atoms/kbd/kbd.tsx +20 -0
- package/src/atoms/radio-group/radio-group.tsx +8 -2
- package/src/atoms/seal/index.ts +1 -0
- package/src/atoms/seal/seal.tsx +107 -0
- package/src/atoms/spinner/index.ts +1 -0
- package/src/atoms/spinner/spinner.tsx +49 -0
- package/src/atoms/switch/switch.tsx +3 -1
- package/src/auth/auth-illustration/auth-illustration.tsx +100 -0
- package/src/auth/auth-illustration/index.ts +8 -0
- package/src/auth/auth-illustration/look.ts +32 -0
- package/src/auth/auth-illustration/model.ts +330 -0
- package/src/auth/auth-illustration/use-art-pointer.ts +78 -0
- package/src/auth/auth-layout/auth-layout.tsx +282 -0
- package/src/auth/auth-layout/index.ts +1 -0
- package/src/auth/character/character.tsx +346 -0
- package/src/auth/character/index.ts +1 -0
- package/src/auth/index.ts +4 -0
- package/src/auth/internal/auth-context.ts +26 -0
- package/src/auth/internal/auth-styles.tsx +39 -0
- package/src/auth/internal/portal-glyphs.tsx +32 -0
- package/src/auth/login-form/context.ts +78 -0
- package/src/auth/login-form/index.ts +21 -0
- package/src/auth/login-form/login-form.tsx +330 -0
- package/src/auth/login-form/parts.tsx +457 -0
- package/src/auth/looks/auth-illustration-any.tsx +38 -0
- package/src/auth/looks/index.ts +1 -0
- package/src/auth/mosaic/index.ts +1 -0
- package/src/auth/mosaic/mosaic.tsx +255 -0
- package/src/auth/slabs/index.ts +1 -0
- package/src/auth/slabs/slabs.tsx +181 -0
- package/src/auth/stack/index.ts +1 -0
- package/src/auth/stack/stack.tsx +267 -0
- package/src/auth/statement/index.ts +1 -0
- package/src/auth/statement/statement.tsx +122 -0
- package/src/calendar/date-calendar/date-calendar.tsx +230 -0
- package/src/calendar/date-calendar/index.ts +5 -0
- package/src/calendar/index.ts +1 -0
- package/src/calendar/internal/date-utils.ts +115 -0
- package/src/containers/aside/aside.tsx +40 -0
- package/src/containers/aside/index.ts +1 -0
- package/src/containers/banner/banner.tsx +18 -1
- package/src/containers/description-list/description-list.tsx +85 -9
- package/src/containers/feed/feed.tsx +99 -0
- package/src/containers/feed/index.ts +8 -0
- package/src/containers/feed/model.ts +54 -0
- package/src/containers/index.ts +6 -0
- package/src/containers/kpi/kpi.tsx +161 -62
- package/src/containers/list-detail/index.ts +15 -0
- package/src/containers/list-detail/list-detail.tsx +293 -0
- package/src/containers/note/index.ts +1 -0
- package/src/containers/note/note.tsx +38 -0
- package/src/containers/section/index.ts +11 -0
- package/src/containers/section/section.tsx +281 -0
- package/src/containers/shortcuts/index.ts +6 -0
- package/src/containers/shortcuts/shortcuts.tsx +92 -0
- package/src/containers/table/selection.ts +26 -0
- package/src/containers/table/table.tsx +215 -13
- package/src/containers/timeline/index.ts +3 -0
- package/src/containers/timeline/timeline.tsx +204 -93
- package/src/forms/chip-group/chip-group.tsx +184 -0
- package/src/forms/chip-group/index.ts +8 -0
- package/src/forms/combobox/combobox.tsx +359 -0
- package/src/forms/combobox/index.ts +7 -0
- package/src/forms/date-picker/date-picker.tsx +239 -0
- package/src/forms/date-picker/date-time-picker.tsx +178 -0
- package/src/forms/date-picker/index.ts +10 -0
- package/src/forms/date-picker/model.ts +108 -0
- package/src/forms/dropzone/dropzone.tsx +217 -35
- package/src/forms/field/field.tsx +72 -7
- package/src/forms/index.ts +5 -0
- package/src/forms/input/index.ts +8 -1
- package/src/forms/input/input.tsx +99 -12
- package/src/forms/input-icon/input-icon.tsx +1 -1
- package/src/forms/internal/listbox-items.tsx +103 -0
- package/src/forms/internal/listbox.ts +124 -0
- package/src/forms/number-stepper/model.ts +35 -0
- package/src/forms/number-stepper/number-stepper.tsx +132 -42
- package/src/forms/password-input/index.ts +1 -0
- package/src/forms/password-input/password-input.tsx +57 -0
- package/src/forms/select-menu/index.ts +7 -0
- package/src/forms/select-menu/select-menu.tsx +280 -0
- package/src/i18n/strings.ts +153 -0
- package/src/i18n/ui-strings-provider.tsx +15 -4
- package/src/icons/eye.tsx +12 -0
- package/src/icons/graduation-cap.tsx +13 -0
- package/src/icons/house.tsx +12 -0
- package/src/icons/index.ts +4 -0
- package/src/icons/mail.tsx +12 -0
- package/src/navigation/index.ts +1 -0
- package/src/navigation/stepper/index.ts +7 -1
- package/src/navigation/stepper/stepper.tsx +41 -5
- package/src/navigation/tabs/index.ts +7 -0
- package/src/navigation/tabs/tabs-nav.tsx +131 -0
- package/src/navigation/wizard/index.ts +7 -0
- package/src/navigation/wizard/model.ts +61 -0
- package/src/navigation/wizard/wizard.tsx +222 -0
- package/src/overlays/alert-dialog/alert-dialog.tsx +486 -0
- package/src/overlays/alert-dialog/index.ts +19 -0
- package/src/overlays/dropdown-menu/dropdown-menu.tsx +29 -4
- package/src/overlays/dropdown-menu/index.ts +3 -0
- package/src/overlays/index.ts +2 -0
- package/src/overlays/testing/index.ts +5 -0
- package/src/overlays/toaster/index.ts +2 -0
- package/src/overlays/toaster/toast-store.ts +6 -2
- package/src/overlays/toaster/toast.ts +6 -0
- package/src/overlays/toaster/toaster.tsx +44 -2
- package/src/overlays/tooltip/index.ts +1 -0
- package/src/overlays/tooltip/model.ts +18 -0
- package/src/overlays/tooltip/tooltip.tsx +166 -0
- package/src/primitives/use-dismissable-layer.ts +7 -2
- package/src/states/error-state/error-state.tsx +19 -8
- package/src/states/skeleton/skeleton.tsx +68 -2
- package/styles/tailwind.css +33 -30
- package/styles/theme.css +33 -30
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo, useRef, useState } from "react";
|
|
4
|
+
import { DateCalendar } from "../../calendar/date-calendar/date-calendar.js";
|
|
5
|
+
import { isIsoDate } from "../../calendar/internal/date-utils.js";
|
|
6
|
+
import { useUiStrings } from "../../i18n/index.js";
|
|
7
|
+
import { Calendar as CalendarIcon, X } from "../../icons/index.js";
|
|
8
|
+
import * as PopoverPrimitive from "../../primitives/popover/popover.js";
|
|
9
|
+
import { cn } from "../../utils/cn.js";
|
|
10
|
+
import { useComposedRefs } from "../../utils/compose.js";
|
|
11
|
+
import { materialClass } from "../../utils/material.js";
|
|
12
|
+
import { useControllableState } from "../../utils/use-controllable-state.js";
|
|
13
|
+
import {
|
|
14
|
+
dateFormatFor,
|
|
15
|
+
displayPlaceholder,
|
|
16
|
+
formatDisplay,
|
|
17
|
+
maskDisplay,
|
|
18
|
+
parseDisplay
|
|
19
|
+
} from "./model.js";
|
|
20
|
+
const ICON_BUTTON = "flex w-8 items-center justify-center rounded-input text-ink-3 outline-none hover:text-ink focus-visible:focus-ring disabled:pointer-events-none disabled:opacity-50";
|
|
21
|
+
function DatePicker({
|
|
22
|
+
value: valueProp,
|
|
23
|
+
defaultValue = "",
|
|
24
|
+
onValueChange,
|
|
25
|
+
min,
|
|
26
|
+
max,
|
|
27
|
+
isDateDisabled,
|
|
28
|
+
locale: localeProp,
|
|
29
|
+
weekStartsOn,
|
|
30
|
+
clearable = true,
|
|
31
|
+
clearLabel,
|
|
32
|
+
name,
|
|
33
|
+
invalid,
|
|
34
|
+
container,
|
|
35
|
+
material,
|
|
36
|
+
disabled,
|
|
37
|
+
placeholder,
|
|
38
|
+
className,
|
|
39
|
+
classNames,
|
|
40
|
+
ref,
|
|
41
|
+
onBlur,
|
|
42
|
+
onKeyDown,
|
|
43
|
+
"aria-invalid": ariaInvalid,
|
|
44
|
+
...props
|
|
45
|
+
}) {
|
|
46
|
+
const strings = useUiStrings();
|
|
47
|
+
const locale = localeProp || strings.locale;
|
|
48
|
+
const format = useMemo(() => dateFormatFor(locale), [locale]);
|
|
49
|
+
const inputRef = useRef(null);
|
|
50
|
+
const composedRef = useComposedRefs(ref, inputRef);
|
|
51
|
+
const [current, setCurrent] = useControllableState({
|
|
52
|
+
prop: valueProp,
|
|
53
|
+
defaultProp: defaultValue,
|
|
54
|
+
onChange: onValueChange
|
|
55
|
+
});
|
|
56
|
+
const date = isIsoDate(current) ? current : "";
|
|
57
|
+
const [draft, setDraft] = useState(null);
|
|
58
|
+
const [open, setOpen] = useState(false);
|
|
59
|
+
const allowed = (iso) => !(min && iso < min) && !(max && iso > max) && !isDateDisabled?.(iso);
|
|
60
|
+
const typed = draft === null ? null : parseDisplay(draft, format);
|
|
61
|
+
const rejected = typed !== null && !allowed(typed);
|
|
62
|
+
const onChange = (raw) => {
|
|
63
|
+
const masked = maskDisplay(raw, format);
|
|
64
|
+
const iso = parseDisplay(masked, format);
|
|
65
|
+
if (iso && allowed(iso)) {
|
|
66
|
+
setCurrent(iso);
|
|
67
|
+
setDraft(null);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
setDraft(masked);
|
|
71
|
+
if (masked === "") setCurrent("");
|
|
72
|
+
};
|
|
73
|
+
const handleKeyDown = (event) => {
|
|
74
|
+
onKeyDown?.(event);
|
|
75
|
+
if (event.defaultPrevented) return;
|
|
76
|
+
if (event.key === "ArrowDown" && event.altKey && !disabled) {
|
|
77
|
+
event.preventDefault();
|
|
78
|
+
setOpen(true);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const hasClear = clearable && !disabled && date !== "";
|
|
82
|
+
return /* @__PURE__ */ jsxs(PopoverPrimitive.Root, { open, onOpenChange: setOpen, children: [
|
|
83
|
+
/* @__PURE__ */ jsx(PopoverPrimitive.Anchor, { asChild: true, children: /* @__PURE__ */ jsxs("div", { className: cn("relative flex w-full min-w-0", classNames?.root), children: [
|
|
84
|
+
/* @__PURE__ */ jsx(
|
|
85
|
+
"input",
|
|
86
|
+
{
|
|
87
|
+
...props,
|
|
88
|
+
ref: composedRef,
|
|
89
|
+
type: "text",
|
|
90
|
+
inputMode: "numeric",
|
|
91
|
+
autoComplete: "off",
|
|
92
|
+
maxLength: 10,
|
|
93
|
+
disabled,
|
|
94
|
+
placeholder: placeholder ?? displayPlaceholder(format, {
|
|
95
|
+
day: strings.dayPlaceholder,
|
|
96
|
+
month: strings.monthPlaceholder,
|
|
97
|
+
year: strings.yearPlaceholder
|
|
98
|
+
}),
|
|
99
|
+
"aria-invalid": ariaInvalid ?? (invalid || rejected || void 0),
|
|
100
|
+
value: draft ?? formatDisplay(date, format),
|
|
101
|
+
onChange: (event) => onChange(event.target.value),
|
|
102
|
+
onBlur: (event) => {
|
|
103
|
+
onBlur?.(event);
|
|
104
|
+
setDraft(null);
|
|
105
|
+
},
|
|
106
|
+
onKeyDown: handleKeyDown,
|
|
107
|
+
className: cn(
|
|
108
|
+
"h-input min-h-(--touch-target) w-full min-w-0 rounded-input border-control bg-surface-control pl-3 text-control text-ink tabular-nums placeholder:text-ink-3 focus:border-transparent focus:outline-2 focus:outline-accent-ink focus:-outline-offset-1 disabled:cursor-not-allowed disabled:opacity-50 aria-[invalid=true]:border-danger",
|
|
109
|
+
hasClear ? "pr-16" : "pr-9",
|
|
110
|
+
classNames?.input,
|
|
111
|
+
className
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
),
|
|
115
|
+
/* @__PURE__ */ jsxs("div", { className: "absolute inset-y-0 right-0 flex items-center", children: [
|
|
116
|
+
hasClear ? /* @__PURE__ */ jsx(
|
|
117
|
+
"button",
|
|
118
|
+
{
|
|
119
|
+
type: "button",
|
|
120
|
+
"aria-label": clearLabel ?? strings.clear,
|
|
121
|
+
onClick: () => {
|
|
122
|
+
setCurrent("");
|
|
123
|
+
setDraft(null);
|
|
124
|
+
inputRef.current?.focus();
|
|
125
|
+
},
|
|
126
|
+
className: cn(ICON_BUTTON, classNames?.clear),
|
|
127
|
+
children: /* @__PURE__ */ jsx(X, { "aria-hidden": "true", className: "size-3.5" })
|
|
128
|
+
}
|
|
129
|
+
) : null,
|
|
130
|
+
/* @__PURE__ */ jsx(
|
|
131
|
+
PopoverPrimitive.Trigger,
|
|
132
|
+
{
|
|
133
|
+
disabled,
|
|
134
|
+
"aria-label": strings.openCalendar,
|
|
135
|
+
className: cn(ICON_BUTTON, classNames?.trigger),
|
|
136
|
+
children: /* @__PURE__ */ jsx(CalendarIcon, { "aria-hidden": "true", className: "size-4" })
|
|
137
|
+
}
|
|
138
|
+
)
|
|
139
|
+
] }),
|
|
140
|
+
name ? /* @__PURE__ */ jsx("input", { type: "hidden", name, value: date, disabled }) : null
|
|
141
|
+
] }) }),
|
|
142
|
+
/* @__PURE__ */ jsx(PopoverPrimitive.Portal, { container, children: /* @__PURE__ */ jsx(
|
|
143
|
+
PopoverPrimitive.Content,
|
|
144
|
+
{
|
|
145
|
+
"aria-label": strings.calendar,
|
|
146
|
+
sideOffset: 4,
|
|
147
|
+
collisionPadding: 8,
|
|
148
|
+
align: "start",
|
|
149
|
+
onOpenAutoFocus: (event) => event.preventDefault(),
|
|
150
|
+
onCloseAutoFocus: (event) => {
|
|
151
|
+
event.preventDefault();
|
|
152
|
+
inputRef.current?.focus({ preventScroll: true });
|
|
153
|
+
},
|
|
154
|
+
className: cn(
|
|
155
|
+
"z-85 max-w-(--ui-popper-available-width) overflow-y-auto rounded-popover surface-overlay p-3 text-ink shadow-overlay",
|
|
156
|
+
materialClass(material, "surface-solid"),
|
|
157
|
+
classNames?.content
|
|
158
|
+
),
|
|
159
|
+
children: /* @__PURE__ */ jsx(
|
|
160
|
+
DateCalendar,
|
|
161
|
+
{
|
|
162
|
+
autoFocus: true,
|
|
163
|
+
value: date || void 0,
|
|
164
|
+
min,
|
|
165
|
+
max,
|
|
166
|
+
isDateDisabled,
|
|
167
|
+
locale,
|
|
168
|
+
weekStartsOn,
|
|
169
|
+
className: classNames?.calendar,
|
|
170
|
+
onSelect: (next) => {
|
|
171
|
+
setCurrent(next);
|
|
172
|
+
setDraft(null);
|
|
173
|
+
setOpen(false);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
)
|
|
177
|
+
}
|
|
178
|
+
) })
|
|
179
|
+
] });
|
|
180
|
+
}
|
|
181
|
+
export {
|
|
182
|
+
DatePicker
|
|
183
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type ComponentProps } from "react";
|
|
2
|
+
import { type WeekStart } from "../../calendar/internal/date-utils.js";
|
|
3
|
+
import type { ClassNames } from "../../utils/class-names.js";
|
|
4
|
+
import type { Material } from "../../utils/material.js";
|
|
5
|
+
export type DateTimePickerPart = "root" | "date" | "time";
|
|
6
|
+
export interface DateTimePickerProps extends Omit<ComponentProps<"div">, "defaultValue" | "onChange" | "children" | "role" | "id" | "aria-label" | "aria-labelledby"> {
|
|
7
|
+
/**
|
|
8
|
+
* "YYYY-MM-DDTHH:mm" (controlled), a wall-clock date and time with no zone: the component never
|
|
9
|
+
* converts it, so "2026-09-07T09:30" stays that string whatever the browser's time zone is.
|
|
10
|
+
* `""` while either half is missing or the pair is outside `min`/`max`.
|
|
11
|
+
*/
|
|
12
|
+
value?: string;
|
|
13
|
+
defaultValue?: string;
|
|
14
|
+
onValueChange?: (value: string) => void;
|
|
15
|
+
/** Earliest allowed value: a date ("2026-09-07", whole day) or a date-time. */
|
|
16
|
+
min?: string;
|
|
17
|
+
/** Latest allowed value: a date (whole day) or a date-time. */
|
|
18
|
+
max?: string;
|
|
19
|
+
isDateDisabled?: (date: string) => boolean;
|
|
20
|
+
locale?: string;
|
|
21
|
+
weekStartsOn?: WeekStart;
|
|
22
|
+
/** Minutes moved by ArrowUp / ArrowDown on the minutes of the time half. Default 5. */
|
|
23
|
+
step?: number;
|
|
24
|
+
/** Submits the combined value with a surrounding `<form>` through a hidden input. */
|
|
25
|
+
name?: string;
|
|
26
|
+
id?: string;
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
required?: boolean;
|
|
29
|
+
invalid?: boolean;
|
|
30
|
+
"aria-label"?: string;
|
|
31
|
+
"aria-labelledby"?: string;
|
|
32
|
+
"aria-describedby"?: string;
|
|
33
|
+
"aria-invalid"?: boolean | "true" | "false";
|
|
34
|
+
container?: HTMLElement | null;
|
|
35
|
+
material?: Material;
|
|
36
|
+
/** Per-part classes merged with `cn`; consumer classes win. `className` still targets the root and is merged last. */
|
|
37
|
+
classNames?: ClassNames<DateTimePickerPart>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Date field with calendar plus a 24h time field, as one value. Replaces
|
|
41
|
+
* `<input type="datetime-local">`; the value is "YYYY-MM-DDTHH:mm" without a time zone.
|
|
42
|
+
*/
|
|
43
|
+
export declare function DateTimePicker({ value: valueProp, defaultValue, onValueChange, min, max, isDateDisabled, locale, weekStartsOn, step, name, id, disabled, required, invalid, container, material, className, classNames, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, ...props }: DateTimePickerProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useId, useMemo, useState } from "react";
|
|
4
|
+
import { isIsoDate } from "../../calendar/internal/date-utils.js";
|
|
5
|
+
import { useUiStrings } from "../../i18n/index.js";
|
|
6
|
+
import { cn } from "../../utils/cn.js";
|
|
7
|
+
import { useControllableState } from "../../utils/use-controllable-state.js";
|
|
8
|
+
import { TimeInput } from "../time-input/time-input.js";
|
|
9
|
+
import { DatePicker } from "./date-picker.js";
|
|
10
|
+
import { dateTimeInRange, joinDateTime, splitDateTime } from "./model.js";
|
|
11
|
+
const EMPTY = { date: "", time: "" };
|
|
12
|
+
function DateTimePicker({
|
|
13
|
+
value: valueProp,
|
|
14
|
+
defaultValue = "",
|
|
15
|
+
onValueChange,
|
|
16
|
+
min,
|
|
17
|
+
max,
|
|
18
|
+
isDateDisabled,
|
|
19
|
+
locale,
|
|
20
|
+
weekStartsOn,
|
|
21
|
+
step,
|
|
22
|
+
name,
|
|
23
|
+
id,
|
|
24
|
+
disabled,
|
|
25
|
+
required,
|
|
26
|
+
invalid,
|
|
27
|
+
container,
|
|
28
|
+
material,
|
|
29
|
+
className,
|
|
30
|
+
classNames,
|
|
31
|
+
"aria-label": ariaLabel,
|
|
32
|
+
"aria-labelledby": ariaLabelledBy,
|
|
33
|
+
"aria-describedby": ariaDescribedBy,
|
|
34
|
+
"aria-invalid": ariaInvalid,
|
|
35
|
+
...props
|
|
36
|
+
}) {
|
|
37
|
+
const strings = useUiStrings();
|
|
38
|
+
const autoId = useId();
|
|
39
|
+
const dateId = id ?? autoId;
|
|
40
|
+
const [current, setCurrent] = useControllableState({
|
|
41
|
+
prop: valueProp,
|
|
42
|
+
defaultProp: defaultValue,
|
|
43
|
+
onChange: onValueChange
|
|
44
|
+
});
|
|
45
|
+
const [parts, setParts] = useState(() => splitDateTime(current) ?? EMPTY);
|
|
46
|
+
const [synced, setSynced] = useState(current);
|
|
47
|
+
const [timeLabel, setTimeLabel] = useState(strings.time);
|
|
48
|
+
const suffix = strings.time.toLowerCase();
|
|
49
|
+
if (synced !== current) {
|
|
50
|
+
setSynced(current);
|
|
51
|
+
if (joinDateTime(parts) !== current) setParts(splitDateTime(current) ?? EMPTY);
|
|
52
|
+
}
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
const label = ariaLabel ?? ariaLabelledBy?.split(" ").map((labelId) => document.getElementById(labelId)?.textContent ?? "").join(" ").trim() ?? document.getElementById(dateId)?.labels?.[0]?.textContent?.trim();
|
|
55
|
+
setTimeLabel(label ? `${label}, ${suffix}` : strings.time);
|
|
56
|
+
}, [ariaLabel, ariaLabelledBy, dateId, strings.time, suffix]);
|
|
57
|
+
const joined = joinDateTime(parts);
|
|
58
|
+
const outOfRange = joined !== "" && !dateTimeInRange(joined, min, max);
|
|
59
|
+
const dateMin = min && isIsoDate(min.slice(0, 10)) ? min.slice(0, 10) : void 0;
|
|
60
|
+
const dateMax = max && isIsoDate(max.slice(0, 10)) ? max.slice(0, 10) : void 0;
|
|
61
|
+
const update = useMemo(
|
|
62
|
+
() => (next) => {
|
|
63
|
+
setParts(next);
|
|
64
|
+
const value = joinDateTime(next);
|
|
65
|
+
const committed = value && dateTimeInRange(value, min, max) ? value : "";
|
|
66
|
+
setCurrent(committed);
|
|
67
|
+
},
|
|
68
|
+
[min, max, setCurrent]
|
|
69
|
+
);
|
|
70
|
+
const shared = {
|
|
71
|
+
disabled,
|
|
72
|
+
"aria-describedby": ariaDescribedBy,
|
|
73
|
+
"aria-invalid": ariaInvalid ?? (invalid || void 0)
|
|
74
|
+
};
|
|
75
|
+
return /* @__PURE__ */ jsxs(
|
|
76
|
+
"div",
|
|
77
|
+
{
|
|
78
|
+
...props,
|
|
79
|
+
className: cn("flex w-full min-w-0 flex-wrap gap-2", classNames?.root, className),
|
|
80
|
+
children: [
|
|
81
|
+
/* @__PURE__ */ jsx(
|
|
82
|
+
DatePicker,
|
|
83
|
+
{
|
|
84
|
+
...shared,
|
|
85
|
+
id: dateId,
|
|
86
|
+
value: parts.date,
|
|
87
|
+
onValueChange: (date) => update({ ...parts, date }),
|
|
88
|
+
min: dateMin,
|
|
89
|
+
max: dateMax,
|
|
90
|
+
isDateDisabled,
|
|
91
|
+
locale,
|
|
92
|
+
weekStartsOn,
|
|
93
|
+
required,
|
|
94
|
+
"aria-label": ariaLabel,
|
|
95
|
+
"aria-labelledby": ariaLabelledBy,
|
|
96
|
+
container,
|
|
97
|
+
material,
|
|
98
|
+
className: void 0,
|
|
99
|
+
classNames: { root: cn("flex-[3_1_10rem]", classNames?.date) }
|
|
100
|
+
}
|
|
101
|
+
),
|
|
102
|
+
/* @__PURE__ */ jsx("div", { className: cn("flex min-w-0 flex-[2_1_6rem]", classNames?.time), children: /* @__PURE__ */ jsx(
|
|
103
|
+
TimeInput,
|
|
104
|
+
{
|
|
105
|
+
...shared,
|
|
106
|
+
"aria-invalid": outOfRange ? true : shared["aria-invalid"],
|
|
107
|
+
"aria-label": timeLabel,
|
|
108
|
+
value: parts.time,
|
|
109
|
+
onValueChange: (time) => update({ ...parts, time }),
|
|
110
|
+
required,
|
|
111
|
+
step
|
|
112
|
+
}
|
|
113
|
+
) }),
|
|
114
|
+
name ? /* @__PURE__ */ jsx("input", { type: "hidden", name, value: current, disabled }) : null
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
export {
|
|
120
|
+
DateTimePicker
|
|
121
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** Typed-date and date-time rules for `DatePicker` / `DateTimePicker`. Strings in, strings out: no `Date` in local time. */
|
|
2
|
+
export type DatePart = "day" | "month" | "year";
|
|
3
|
+
export interface DateFormat {
|
|
4
|
+
order: DatePart[];
|
|
5
|
+
separator: string;
|
|
6
|
+
}
|
|
7
|
+
/** Field order and separator a locale writes numeric dates with: es-PE "dd/mm/yyyy", en-US "mm/dd/yyyy", sv-SE "yyyy-mm-dd". */
|
|
8
|
+
export declare function dateFormatFor(locale: string): DateFormat;
|
|
9
|
+
/** "2026-09-07" as the locale writes it, or "" for anything that is not an ISO date. */
|
|
10
|
+
export declare function formatDisplay(iso: string, format: DateFormat): string;
|
|
11
|
+
/** Keeps digits and inserts the separator once a segment is full and more digits follow. */
|
|
12
|
+
export declare function maskDisplay(raw: string, format: DateFormat): string;
|
|
13
|
+
/** Typed text to "YYYY-MM-DD"; null while it is incomplete or not a real date. */
|
|
14
|
+
export declare function parseDisplay(text: string, format: DateFormat): string | null;
|
|
15
|
+
/** "dd/mm/aaaa" built from the locale's order and the localized segment words. */
|
|
16
|
+
export declare function displayPlaceholder(format: DateFormat, words: {
|
|
17
|
+
day: string;
|
|
18
|
+
month: string;
|
|
19
|
+
year: string;
|
|
20
|
+
}): string;
|
|
21
|
+
export declare function isValidTime(time: string): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Splits "YYYY-MM-DDTHH:mm". The value is a wall-clock time with no zone: anything carrying a
|
|
24
|
+
* "Z", an offset or seconds is rejected instead of being silently reinterpreted.
|
|
25
|
+
*/
|
|
26
|
+
export declare function splitDateTime(value: string): {
|
|
27
|
+
date: string;
|
|
28
|
+
time: string;
|
|
29
|
+
} | null;
|
|
30
|
+
export declare function joinDateTime(parts: {
|
|
31
|
+
date: string;
|
|
32
|
+
time: string;
|
|
33
|
+
}): string;
|
|
34
|
+
/** `min`/`max` may be a date ("2026-09-07", whole day) or a date-time. Lexicographic compare is chronological. */
|
|
35
|
+
export declare function dateTimeInRange(value: string, min?: string, max?: string): boolean;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { isIsoDate, toIsoDate } from "../../calendar/internal/date-utils.js";
|
|
2
|
+
const FALLBACK = { order: ["day", "month", "year"], separator: "/" };
|
|
3
|
+
function dateFormatFor(locale) {
|
|
4
|
+
try {
|
|
5
|
+
const parts = new Intl.DateTimeFormat(locale, {
|
|
6
|
+
year: "numeric",
|
|
7
|
+
month: "2-digit",
|
|
8
|
+
day: "2-digit",
|
|
9
|
+
timeZone: "UTC"
|
|
10
|
+
}).formatToParts(new Date(Date.UTC(2006, 10, 22)));
|
|
11
|
+
const order = parts.map((part) => part.type).filter((type) => type === "day" || type === "month" || type === "year");
|
|
12
|
+
const separator = parts.find((part) => part.type === "literal")?.value.trim();
|
|
13
|
+
if (order.length !== 3) return FALLBACK;
|
|
14
|
+
return { order, separator: separator || "/" };
|
|
15
|
+
} catch {
|
|
16
|
+
return FALLBACK;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const SEGMENT = { day: 2, month: 2, year: 4 };
|
|
20
|
+
function formatDisplay(iso, format) {
|
|
21
|
+
if (!isIsoDate(iso)) return "";
|
|
22
|
+
const value = {
|
|
23
|
+
year: iso.slice(0, 4),
|
|
24
|
+
month: iso.slice(5, 7),
|
|
25
|
+
day: iso.slice(8, 10)
|
|
26
|
+
};
|
|
27
|
+
return format.order.map((part) => value[part]).join(format.separator);
|
|
28
|
+
}
|
|
29
|
+
function maskDisplay(raw, format) {
|
|
30
|
+
let rest = raw.replace(/\D/g, "").slice(0, 8);
|
|
31
|
+
const segments = [];
|
|
32
|
+
for (const part of format.order) {
|
|
33
|
+
if (!rest) break;
|
|
34
|
+
segments.push(rest.slice(0, SEGMENT[part]));
|
|
35
|
+
rest = rest.slice(SEGMENT[part]);
|
|
36
|
+
}
|
|
37
|
+
return segments.join(format.separator);
|
|
38
|
+
}
|
|
39
|
+
function parseDisplay(text, format) {
|
|
40
|
+
const pieces = text.trim().split(format.separator);
|
|
41
|
+
if (pieces.length !== 3) return null;
|
|
42
|
+
const value = {};
|
|
43
|
+
for (const [index, part] of format.order.entries()) {
|
|
44
|
+
const piece = pieces[index] ?? "";
|
|
45
|
+
const valid = part === "year" ? /^\d{4}$/.test(piece) : /^\d{1,2}$/.test(piece);
|
|
46
|
+
if (!valid) return null;
|
|
47
|
+
value[part] = piece;
|
|
48
|
+
}
|
|
49
|
+
const iso = toIsoDate(Number(value.year), Number(value.month), Number(value.day));
|
|
50
|
+
return isIsoDate(iso) ? iso : null;
|
|
51
|
+
}
|
|
52
|
+
function displayPlaceholder(format, words) {
|
|
53
|
+
return format.order.map((part) => words[part]).join(format.separator);
|
|
54
|
+
}
|
|
55
|
+
function isValidTime(time) {
|
|
56
|
+
return /^([01]\d|2[0-3]):[0-5]\d$/.test(time);
|
|
57
|
+
}
|
|
58
|
+
const DATE_TIME = /^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})$/;
|
|
59
|
+
function splitDateTime(value) {
|
|
60
|
+
const match = DATE_TIME.exec(value);
|
|
61
|
+
if (!match) return null;
|
|
62
|
+
const [, date = "", time = ""] = match;
|
|
63
|
+
return isIsoDate(date) && isValidTime(time) ? { date, time } : null;
|
|
64
|
+
}
|
|
65
|
+
function joinDateTime(parts) {
|
|
66
|
+
return parts.date && parts.time ? `${parts.date}T${parts.time}` : "";
|
|
67
|
+
}
|
|
68
|
+
function dateTimeInRange(value, min, max) {
|
|
69
|
+
if (min && value < (min.length === 10 ? `${min}T00:00` : min)) return false;
|
|
70
|
+
if (max && value > (max.length === 10 ? `${max}T23:59` : max)) return false;
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
export {
|
|
74
|
+
dateFormatFor,
|
|
75
|
+
dateTimeInRange,
|
|
76
|
+
displayPlaceholder,
|
|
77
|
+
formatDisplay,
|
|
78
|
+
isValidTime,
|
|
79
|
+
joinDateTime,
|
|
80
|
+
maskDisplay,
|
|
81
|
+
parseDisplay,
|
|
82
|
+
splitDateTime
|
|
83
|
+
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { type ChangeEventHandler } from "react";
|
|
1
2
|
import type { ClassNames } from "../../utils/class-names.js";
|
|
2
3
|
export type DropzoneRejectionReason = "type" | "size";
|
|
3
4
|
export interface DropzoneRejection {
|
|
4
5
|
file: File;
|
|
5
6
|
reason: DropzoneRejectionReason;
|
|
6
7
|
}
|
|
7
|
-
export type DropzonePart = "root" | "icon" | "title" | "hint" | "browse";
|
|
8
|
+
export type DropzonePart = "root" | "icon" | "title" | "hint" | "browse" | "list" | "file";
|
|
8
9
|
export interface DropzoneProps {
|
|
9
10
|
onFiles: (files: File[]) => void;
|
|
10
11
|
/** Called with the rejected files; the caller composes the user-facing message. */
|
|
@@ -16,8 +17,35 @@ export interface DropzoneProps {
|
|
|
16
17
|
title: string;
|
|
17
18
|
hint?: string;
|
|
18
19
|
browseLabel: string;
|
|
20
|
+
/**
|
|
21
|
+
* `zone` (default): a drop target with a browse button. `field`: a form control. The real
|
|
22
|
+
* `<input type="file">` is the focusable, labelled element (Tab to it, Enter or Space opens the picker, a
|
|
23
|
+
* `Field` label points at it), clicking anywhere in the box opens the picker, the selection stays in the
|
|
24
|
+
* input so `name` submits it, and the props below apply.
|
|
25
|
+
*/
|
|
26
|
+
mode?: "zone" | "field";
|
|
27
|
+
/**
|
|
28
|
+
* Accepted file types as the native `accept` attribute: MIME types, wildcards and extensions
|
|
29
|
+
* (".pdf,image/*"). Validated like `acceptedTypes`; both can be given.
|
|
30
|
+
*/
|
|
31
|
+
accept?: string;
|
|
32
|
+
/** Field mode: id of the file input (`Field` sets it). */
|
|
33
|
+
id?: string;
|
|
34
|
+
/** Field mode: name the selected files are submitted under. */
|
|
35
|
+
name?: string;
|
|
36
|
+
/** Field mode: native change event of the input, after rejected files were dropped from it. */
|
|
37
|
+
onChange?: ChangeEventHandler<HTMLInputElement>;
|
|
38
|
+
/** Field mode: lists the selected files, each with a remove button. */
|
|
39
|
+
showFiles?: boolean;
|
|
40
|
+
disabled?: boolean;
|
|
41
|
+
required?: boolean;
|
|
42
|
+
invalid?: boolean;
|
|
43
|
+
"aria-label"?: string;
|
|
44
|
+
"aria-labelledby"?: string;
|
|
45
|
+
"aria-describedby"?: string;
|
|
46
|
+
"aria-invalid"?: boolean;
|
|
19
47
|
className?: string;
|
|
20
48
|
/** Per-part classes merged with `cn`; consumer classes win. `className` still targets the root and is merged last. */
|
|
21
49
|
classNames?: ClassNames<DropzonePart>;
|
|
22
50
|
}
|
|
23
|
-
export declare function Dropzone({ onFiles, onReject, acceptedTypes, maxSizeBytes, multiple, title, hint, browseLabel, className, classNames, }: DropzoneProps): import("react").JSX.Element;
|
|
51
|
+
export declare function Dropzone({ onFiles, onReject, acceptedTypes, maxSizeBytes, multiple, title, hint, browseLabel, mode, accept, id, name, onChange, showFiles, disabled, required, invalid, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, className, classNames, }: DropzoneProps): import("react").JSX.Element;
|