@oslokommune/punkt-react 19.15.6 → 19.16.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 +19 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/components/accordion/Accordion.js +28 -0
- package/dist/components/accordion/AccordionItem.js +60 -0
- package/dist/components/alert/Alert.js +76 -0
- package/dist/components/backlink/BackLink.js +35 -0
- package/dist/components/breadcrumbs/Breadcrumbs.js +67 -0
- package/dist/components/button/Button.js +54 -0
- package/dist/components/calendar/Calendar.js +49 -0
- package/dist/components/calendar/CalendarGrid.js +99 -0
- package/dist/components/calendar/CalendarNav.js +89 -0
- package/dist/components/calendar/calendar-utils.js +44 -0
- package/dist/components/calendar/useCalendarState.js +214 -0
- package/dist/components/card/Card.js +99 -0
- package/dist/components/checkbox/Checkbox.js +101 -0
- package/dist/components/checkboxgroup/CheckboxGroup.js +88 -0
- package/dist/components/checkboxgroup/CheckboxGroupContext.js +5 -0
- package/dist/components/combobox/Combobox.js +65 -0
- package/dist/components/combobox/ComboboxInput.js +87 -0
- package/dist/components/combobox/ComboboxTags.js +82 -0
- package/dist/components/combobox/Listbox.js +136 -0
- package/dist/components/combobox/useComboboxState.js +577 -0
- package/dist/components/consent/Consent.js +110 -0
- package/dist/components/datepicker/DateTags.js +28 -0
- package/dist/components/datepicker/Datepicker.js +79 -0
- package/dist/components/datepicker/DatepickerInputs.js +149 -0
- package/dist/components/datepicker/DatepickerPopup.js +41 -0
- package/dist/components/datepicker/useDatepickerState.js +243 -0
- package/dist/components/fileupload/DropZone.js +131 -0
- package/dist/components/fileupload/FileUpload.js +223 -0
- package/dist/components/fileupload/FileUploadContext.d.ts +2 -0
- package/dist/components/fileupload/FileUploadContext.js +6 -0
- package/dist/components/fileupload/QueueDisplay.js +67 -0
- package/dist/components/fileupload/QueueItemContent.js +88 -0
- package/dist/components/fileupload/Subcomponents.js +265 -0
- package/dist/components/fileupload/Truncate.js +22 -0
- package/dist/components/fileupload/extensions/Comments.js +128 -0
- package/dist/components/fileupload/extensions/Remove.js +9 -0
- package/dist/components/fileupload/extensions/Rename.js +66 -0
- package/dist/components/fileupload/hooks/useFileAttributes.js +25 -0
- package/dist/components/fileupload/hooks/useImageObjectUrl.js +15 -0
- package/dist/components/fileupload/hooks/useImagePreview.js +24 -0
- package/dist/components/fileupload/hooks/useOperationState.js +31 -0
- package/dist/components/fileupload/hooks/useRequiredFormValidation.js +23 -0
- package/dist/components/fileupload/types.d.ts +0 -1
- package/dist/components/fileupload/types.js +12 -0
- package/dist/components/footer/Footer.js +134 -0
- package/dist/components/footer/FooterGlobal.js +105 -0
- package/dist/components/footerSimple/FooterSimple.js +87 -0
- package/dist/components/header/Header.js +15 -0
- package/dist/components/header/HeaderGlobal.js +286 -0
- package/dist/components/header/HeaderService.js +281 -0
- package/dist/components/header-menu/HeaderMenu.js +197 -0
- package/dist/components/headerUserMenu/UserMenu.js +134 -0
- package/dist/components/heading/Heading.js +37 -0
- package/dist/components/helptext/Helptext.js +50 -0
- package/dist/components/icon/Icon.d.ts +6 -0
- package/dist/components/icon/Icon.js +69 -0
- package/dist/components/input/Input.js +23 -0
- package/dist/components/inputwrapper/InputWrapper.js +128 -0
- package/dist/components/link/Link.js +34 -0
- package/dist/components/linkcard/LinkCard.js +38 -0
- package/dist/components/loader/Loader.js +47 -0
- package/dist/components/messagebox/Messagebox.js +50 -0
- package/dist/components/modal/Modal.js +89 -0
- package/dist/components/progressbar/Progressbar.js +62 -0
- package/dist/components/radio/RadioButton.js +85 -0
- package/dist/components/radiogroup/RadioGroup.js +70 -0
- package/dist/components/radiogroup/RadioGroupContext.js +5 -0
- package/dist/components/searchinput/SearchInput.js +102 -0
- package/dist/components/select/Select.js +56 -0
- package/dist/components/stepper/Step.js +78 -0
- package/dist/components/stepper/Stepper.js +21 -0
- package/dist/components/strings/PktStringsProvider.js +21 -0
- package/dist/components/table/Table.js +19 -0
- package/dist/components/table/TableBody.js +13 -0
- package/dist/components/table/TableDataCell.js +14 -0
- package/dist/components/table/TableHeader.js +12 -0
- package/dist/components/table/TableHeaderCell.js +12 -0
- package/dist/components/table/TableRow.js +12 -0
- package/dist/components/tabs/TabItem.js +60 -0
- package/dist/components/tabs/Tabs.js +90 -0
- package/dist/components/tag/Tag.js +76 -0
- package/dist/components/textarea/Textarea.js +74 -0
- package/dist/components/textinput/Textinput.js +106 -0
- package/dist/components/timepicker/Timepicker.js +224 -0
- package/dist/components/timepicker/useTimepickerState.js +483 -0
- package/dist/hooks/useElementWidth.js +23 -0
- package/dist/hooks/useFocusModality.js +28 -0
- package/dist/hooks/useGeneratedId.js +8 -0
- package/dist/hooks/useHeaderChrome.js +36 -0
- package/dist/hooks/useOptionGroupField.js +70 -0
- package/dist/hooks/useOwnerForm.js +15 -0
- package/dist/hooks/usePktStrings.js +16 -0
- package/dist/hooks/useScrollLock.js +12 -0
- package/dist/node_modules/@date-fns/tz/date/index.js +57 -0
- package/dist/node_modules/@date-fns/tz/date/mini.js +75 -0
- package/dist/node_modules/@date-fns/tz/index.js +6 -0
- package/dist/node_modules/@date-fns/tz/tz/index.js +1 -0
- package/dist/node_modules/@date-fns/tz/tzName/index.js +10 -0
- package/dist/node_modules/@date-fns/tz/tzOffset/index.js +22 -0
- package/dist/node_modules/classnames/index.js +32 -0
- package/dist/node_modules/date-fns/_lib/addLeadingZeros.js +6 -0
- package/dist/node_modules/date-fns/_lib/defaultOptions.js +7 -0
- package/dist/node_modules/date-fns/_lib/format/formatters.js +389 -0
- package/dist/node_modules/date-fns/_lib/format/lightFormatters.js +43 -0
- package/dist/node_modules/date-fns/_lib/format/longFormatters.js +38 -0
- package/dist/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js +8 -0
- package/dist/node_modules/date-fns/_lib/normalizeDates.js +8 -0
- package/dist/node_modules/date-fns/_lib/normalizeInterval.js +11 -0
- package/dist/node_modules/date-fns/_lib/protectedTokens.js +23 -0
- package/dist/node_modules/date-fns/addDays.js +9 -0
- package/dist/node_modules/date-fns/constants.js +10 -0
- package/dist/node_modules/date-fns/constructFrom.js +7 -0
- package/dist/node_modules/date-fns/differenceInCalendarDays.js +11 -0
- package/dist/node_modules/date-fns/eachDayOfInterval.js +15 -0
- package/dist/node_modules/date-fns/endOfDay.js +8 -0
- package/dist/node_modules/date-fns/format.js +59 -0
- package/dist/node_modules/date-fns/getDayOfYear.js +10 -0
- package/dist/node_modules/date-fns/getISODay.js +8 -0
- package/dist/node_modules/date-fns/getISOWeek.js +11 -0
- package/dist/node_modules/date-fns/getISOWeekYear.js +14 -0
- package/dist/node_modules/date-fns/getWeek.js +11 -0
- package/dist/node_modules/date-fns/getWeekYear.js +15 -0
- package/dist/node_modules/date-fns/isDate.js +6 -0
- package/dist/node_modules/date-fns/isValid.js +8 -0
- package/dist/node_modules/date-fns/locale/_lib/buildFormatLongFn.js +9 -0
- package/dist/node_modules/date-fns/locale/_lib/buildLocalizeFn.js +17 -0
- package/dist/node_modules/date-fns/locale/_lib/buildMatchFn.js +22 -0
- package/dist/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js +18 -0
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatDistance.js +69 -0
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatLong.js +32 -0
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatRelative.js +11 -0
- package/dist/node_modules/date-fns/locale/en-US/_lib/localize.js +202 -0
- package/dist/node_modules/date-fns/locale/en-US/_lib/match.js +124 -0
- package/dist/node_modules/date-fns/locale/en-US.js +20 -0
- package/dist/node_modules/date-fns/startOfDay.js +8 -0
- package/dist/node_modules/date-fns/startOfISOWeek.js +10 -0
- package/dist/node_modules/date-fns/startOfISOWeekYear.js +10 -0
- package/dist/node_modules/date-fns/startOfWeek.js +9 -0
- package/dist/node_modules/date-fns/startOfWeekYear.js +11 -0
- package/dist/node_modules/date-fns/startOfYear.js +8 -0
- package/dist/node_modules/date-fns/toDate.js +7 -0
- package/dist/punkt-react.cjs +1 -1
- package/dist/punkt-react.js +55 -9388
- package/dist/shared-strings/consent.js +113 -0
- package/dist/shared-strings/format.js +18 -0
- package/dist/shared-strings/nb.js +201 -0
- package/dist/shared-strings/resolve.js +40 -0
- package/dist/shared-strings/store.js +35 -0
- package/dist/shared-types/accordion.js +4 -0
- package/dist/shared-types/calendar.js +12 -0
- package/dist/shared-types/card.js +15 -0
- package/dist/shared-types/checkbox.js +15 -0
- package/dist/shared-types/combobox.js +19 -0
- package/dist/shared-types/consent.js +8 -0
- package/dist/shared-types/footer.js +4 -0
- package/dist/shared-types/header-footer.js +4 -0
- package/dist/shared-types/icon.js +7 -0
- package/dist/shared-types/messagebox.js +8 -0
- package/dist/shared-types/option-group.js +14 -0
- package/dist/shared-types/radiobutton.js +11 -0
- package/dist/shared-types/select.js +14 -0
- package/dist/shared-types/table.js +8 -0
- package/dist/shared-utils/calendar/calendar-grid.js +19 -0
- package/dist/shared-utils/calendar/date-validation.js +19 -0
- package/dist/shared-utils/calendar/keyboard-navigation.js +26 -0
- package/dist/shared-utils/calendar/selection-manager.js +52 -0
- package/dist/shared-utils/combobox/input-utils.js +39 -0
- package/dist/shared-utils/combobox/keyboard-navigation.js +41 -0
- package/dist/shared-utils/combobox/option-utils.js +48 -0
- package/dist/shared-utils/date-utils.js +71 -0
- package/dist/shared-utils/datepicker-utils.js +32 -0
- package/dist/shared-utils/device-utils.js +7 -0
- package/dist/shared-utils/fileupload/announcements.js +21 -0
- package/dist/shared-utils/fileupload/filename.js +8 -0
- package/dist/shared-utils/fileupload/focus-trap.js +2 -0
- package/dist/shared-utils/fileupload/formats.js +29 -0
- package/dist/shared-utils/fileupload/index.js +11 -0
- package/dist/shared-utils/fileupload/navigation.js +6 -0
- package/dist/shared-utils/fileupload/size.js +25 -0
- package/dist/shared-utils/fileupload/transfers.js +23 -0
- package/dist/shared-utils/fileupload/truncate.js +9 -0
- package/dist/shared-utils/fileupload/validation.js +32 -0
- package/dist/shared-utils/focus-trap/index.js +60 -0
- package/dist/shared-utils/forms/described-by.js +7 -0
- package/dist/shared-utils/header-footer/external-domain.js +30 -0
- package/dist/shared-utils/header-footer/fetch-header-footer-data.js +29 -0
- package/dist/shared-utils/header-footer/icon-map.js +55 -0
- package/dist/shared-utils/header-footer/select-megamenu.js +7 -0
- package/dist/shared-utils/scroll-lock/index.js +21 -0
- package/dist/shared-utils/timepicker/options.js +10 -0
- package/dist/shared-utils/timepicker/stepper.js +10 -0
- package/dist/shared-utils/timepicker/time-utils.js +7 -0
- package/dist/shared-utils/value-utils.js +12 -0
- package/dist/utils/nativeInputValue.js +6 -0
- package/dist/utils/stableKeys.js +13 -0
- package/dist/utils/stringutils.js +7 -0
- package/package.json +3 -2
- package/src/components/checkbox/Checkbox.tsx +2 -0
- package/src/components/combobox/types.ts +0 -2
- package/src/components/fileupload/FileUpload.tsx +3 -1
- package/src/components/fileupload/FileUploadContext.ts +7 -0
- package/src/components/fileupload/QueueDisplay.tsx +3 -3
- package/src/components/fileupload/Subcomponents.tsx +2 -7
- package/src/components/fileupload/extensions/Comments.tsx +2 -1
- package/src/components/fileupload/extensions/Rename.tsx +2 -1
- package/src/components/fileupload/types.ts +1 -2
- package/src/components/header/Header.test.tsx +0 -7
- package/src/components/header/Header.tsx +0 -2
- package/src/components/heading/Heading.tsx +0 -2
- package/src/components/icon/Icon.test.tsx +0 -7
- package/src/components/icon/Icon.tsx +7 -0
- package/src/components/input/Input.tsx +0 -2
- package/src/components/link/Link.tsx +0 -2
- package/src/components/radio/RadioButton.tsx +2 -0
- package/src/components/server-components.test.ts +69 -0
- package/src/components/stepper/Step.tsx +0 -2
- package/src/components/stepper/Stepper.tsx +0 -2
- package/src/components/strings/PktStringsProvider.tsx +2 -0
- package/src/components/table/Table.tsx +0 -2
- package/src/components/table/TableBody.tsx +1 -3
- package/src/components/table/TableDataCell.tsx +0 -2
- package/src/components/table/TableHeader.tsx +0 -2
- package/src/components/table/TableHeaderCell.tsx +0 -2
- package/src/components/table/TableRow.tsx +0 -2
- package/dist/components/accordion/Accordion.test.d.ts +0 -0
- package/dist/components/alert/Alert.test.d.ts +0 -0
- package/dist/components/backlink/BackLink.test.d.ts +0 -0
- package/dist/components/breadcrumbs/Breadcrumbs.test.d.ts +0 -1
- package/dist/components/button/Button.test.d.ts +0 -0
- package/dist/components/calendar/Calendar.accessibility.test.d.ts +0 -0
- package/dist/components/calendar/Calendar.constraints.test.d.ts +0 -0
- package/dist/components/calendar/Calendar.core.test.d.ts +0 -0
- package/dist/components/calendar/Calendar.interaction.test.d.ts +0 -0
- package/dist/components/calendar/Calendar.selection.test.d.ts +0 -0
- package/dist/components/card/Card.test.d.ts +0 -0
- package/dist/components/checkbox/Checkbox.test.d.ts +0 -0
- package/dist/components/checkboxgroup/CheckboxGroup.forms.test.d.ts +0 -0
- package/dist/components/checkboxgroup/CheckboxGroup.test.d.ts +0 -0
- package/dist/components/combobox/Combobox.accessibility.test.d.ts +0 -0
- package/dist/components/combobox/Combobox.core.test.d.ts +0 -0
- package/dist/components/combobox/Combobox.interaction.test.d.ts +0 -0
- package/dist/components/combobox/Combobox.preselection.test.d.ts +0 -0
- package/dist/components/combobox/Combobox.selection.test.d.ts +0 -0
- package/dist/components/consent/Consent.test.d.ts +0 -0
- package/dist/components/datepicker/Datepicker.accessibility.test.d.ts +0 -0
- package/dist/components/datepicker/Datepicker.core.test.d.ts +0 -0
- package/dist/components/datepicker/Datepicker.input.test.d.ts +0 -0
- package/dist/components/datepicker/Datepicker.selection.test.d.ts +0 -0
- package/dist/components/datepicker/Datepicker.validation.test.d.ts +0 -0
- package/dist/components/fileupload/FileUpload.test.d.ts +0 -0
- package/dist/components/fileupload/QueueDisplay.test.d.ts +0 -0
- package/dist/components/fileupload/Truncate.test.d.ts +0 -0
- package/dist/components/footer/Footer.accessibility.test.d.ts +0 -0
- package/dist/components/footer/Footer.test.d.ts +0 -1
- package/dist/components/footerSimple/FooterSimple.test.d.ts +0 -1
- package/dist/components/formAttribute.test.d.ts +0 -1
- package/dist/components/header/Header.test.d.ts +0 -0
- package/dist/components/header/HeaderGlobal.accessibility.test.d.ts +0 -0
- package/dist/components/header/HeaderGlobal.test.d.ts +0 -0
- package/dist/components/header/HeaderService.accessibility.test.d.ts +0 -0
- package/dist/components/header/HeaderService.test.d.ts +0 -0
- package/dist/components/header-menu/HeaderMenu.test.d.ts +0 -0
- package/dist/components/headerUserMenu/UserMenu.test.d.ts +0 -0
- package/dist/components/heading/Heading.test.d.ts +0 -0
- package/dist/components/helptext/Helptext.test.d.ts +0 -0
- package/dist/components/helptext/helptextAssociation.test.d.ts +0 -1
- package/dist/components/hydration.test.d.ts +0 -1
- package/dist/components/icon/Icon.test.d.ts +0 -9
- package/dist/components/inputwrapper/InputWrapper.test.d.ts +0 -0
- package/dist/components/link/Link.test.d.ts +0 -1
- package/dist/components/linkcard/LinkCard.test.d.ts +0 -0
- package/dist/components/loader/Loader.test.d.ts +0 -0
- package/dist/components/messagebox/Messagebox.test.d.ts +0 -1
- package/dist/components/modal/Modal.test.d.ts +0 -0
- package/dist/components/progressbar/Progressbar.test.d.ts +0 -0
- package/dist/components/radio/RadioButton.test.d.ts +0 -0
- package/dist/components/radiogroup/RadioGroup.forms.test.d.ts +0 -0
- package/dist/components/radiogroup/RadioGroup.test.d.ts +0 -0
- package/dist/components/searchinput/SearchInput.test.d.ts +0 -0
- package/dist/components/select/Select.test.d.ts +0 -0
- package/dist/components/ssr.test.d.ts +0 -1
- package/dist/components/stepper/Stepper.test.d.ts +0 -0
- package/dist/components/strings/strings-override.test.d.ts +0 -1
- package/dist/components/table/Table.test.d.ts +0 -0
- package/dist/components/tabs/Tabs.test.d.ts +0 -0
- package/dist/components/tag/Tag.test.d.ts +0 -0
- package/dist/components/textarea/Textarea.test.d.ts +0 -0
- package/dist/components/textinput/Textinput.test.d.ts +0 -0
- package/dist/components/timepicker/Timepicker.test.d.ts +0 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { PktInputWrapper as e } from "../inputwrapper/InputWrapper.js";
|
|
3
|
+
import { DatepickerPopup as t } from "./DatepickerPopup.js";
|
|
4
|
+
import { DatepickerInputs as n } from "./DatepickerInputs.js";
|
|
5
|
+
import { useDatepickerState as r } from "./useDatepickerState.js";
|
|
6
|
+
import { forwardRef as i } from "react";
|
|
7
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
8
|
+
//#region src/components/datepicker/Datepicker.tsx
|
|
9
|
+
var s = i((i, s) => {
|
|
10
|
+
let c = r(i, s), l = [
|
|
11
|
+
"pkt-datepicker",
|
|
12
|
+
`pkt-datepicker--${c.inputSize}`,
|
|
13
|
+
c.fullwidth ? "pkt-datepicker--fullwidth" : "",
|
|
14
|
+
c.className
|
|
15
|
+
].filter(Boolean).join(" ");
|
|
16
|
+
return /* @__PURE__ */ o("div", {
|
|
17
|
+
className: l,
|
|
18
|
+
id: c.id || void 0,
|
|
19
|
+
children: [
|
|
20
|
+
/* @__PURE__ */ a(e, {
|
|
21
|
+
strings: c.stringsOverride,
|
|
22
|
+
ref: c.wrapperRef,
|
|
23
|
+
ariaDescribedby: i.ariaDescribedby,
|
|
24
|
+
forId: c.inputId,
|
|
25
|
+
label: c.label,
|
|
26
|
+
hasFieldset: c.hasFieldset,
|
|
27
|
+
inline: c.inline,
|
|
28
|
+
helptext: c.helptext,
|
|
29
|
+
helptextDropdown: c.helptextDropdown,
|
|
30
|
+
helptextDropdownButton: c.helptextDropdownButton,
|
|
31
|
+
hasError: c.hasError,
|
|
32
|
+
errorMessage: c.errorMessage,
|
|
33
|
+
disabled: c.disabled,
|
|
34
|
+
optionalTag: c.optionalTag,
|
|
35
|
+
optionalText: c.optionalText,
|
|
36
|
+
requiredTag: c.requiredTag,
|
|
37
|
+
requiredText: c.requiredText,
|
|
38
|
+
tagText: c.tagText,
|
|
39
|
+
useWrapper: c.useWrapper,
|
|
40
|
+
size: c.inputSize,
|
|
41
|
+
counter: c.hasCounter,
|
|
42
|
+
counterCurrent: c.values.length,
|
|
43
|
+
counterMaxLength: c.maxlength,
|
|
44
|
+
children: /* @__PURE__ */ a(n, { state: c })
|
|
45
|
+
}),
|
|
46
|
+
/* @__PURE__ */ a(t, {
|
|
47
|
+
open: c.calendarOpen,
|
|
48
|
+
multiple: c.multiple,
|
|
49
|
+
range: c.range,
|
|
50
|
+
weeknumbers: c.weeknumbers,
|
|
51
|
+
withcontrols: c.withcontrols,
|
|
52
|
+
selected: c.values,
|
|
53
|
+
earliest: c.minStr,
|
|
54
|
+
latest: c.maxStr,
|
|
55
|
+
excludedates: c.excludedates,
|
|
56
|
+
excludeweekdays: c.excludeweekdays,
|
|
57
|
+
maxMultiple: c.maxlength,
|
|
58
|
+
currentmonth: c.effectiveCurrentMonth,
|
|
59
|
+
today: c.today,
|
|
60
|
+
inputRef: c.inputRef,
|
|
61
|
+
hasCounter: c.hasCounter,
|
|
62
|
+
onDateSelected: c.handleDateSelected,
|
|
63
|
+
onClose: c.handleCalendarClose
|
|
64
|
+
}),
|
|
65
|
+
/* @__PURE__ */ a("input", {
|
|
66
|
+
ref: c.changeInputRef,
|
|
67
|
+
type: "text",
|
|
68
|
+
name: c.name,
|
|
69
|
+
onChange: c.onChange,
|
|
70
|
+
tabIndex: -1,
|
|
71
|
+
"aria-hidden": "true",
|
|
72
|
+
className: "pkt-visually-hidden"
|
|
73
|
+
})
|
|
74
|
+
]
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
s.displayName = "PktDatepicker";
|
|
78
|
+
//#endregion
|
|
79
|
+
export { s as PktDatepicker };
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { PktIcon as e } from "../icon/Icon.js";
|
|
2
|
+
import { DateTags as t } from "./DateTags.js";
|
|
3
|
+
import { Fragment as n, jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/datepicker/DatepickerInputs.tsx
|
|
5
|
+
var a = ({ state: a }) => {
|
|
6
|
+
let { id: o, inputId: s, values: c, dateformat: l, multiple: u, range: d, showRangeLabels: f, disabled: p, readOnly: m, required: h, label: g, name: _, placeholder: v, hasError: y, helptext: b, minStr: x, maxStr: S, inputType: C, isIOSDevice: w, strings: T, inputClasses: E, buttonClasses: D, rangeLabelClasses: O, datepickerInputsClasses: k, isInputDisabled: A, inputRef: j, inputToRef: M, btnRef: N, toggleCalendar: P, handleFocus: F, handleSingleInputChange: I, handleRangeFromChange: L, handleRangeToChange: R, handleRangeBlur: z, handleMultipleBlur: B, handleTagRemoved: V, handleSingleKeydown: H, handleRangeFromKeydown: U, handleRangeToKeydown: W, handleMultipleKeydown: G, restProps: K } = a, q = (e) => {
|
|
7
|
+
e.preventDefault(), P();
|
|
8
|
+
}, J = (e) => {
|
|
9
|
+
e.preventDefault(), P();
|
|
10
|
+
}, Y = () => /* @__PURE__ */ i("button", {
|
|
11
|
+
ref: N,
|
|
12
|
+
className: D,
|
|
13
|
+
type: "button",
|
|
14
|
+
onClick: P,
|
|
15
|
+
disabled: p,
|
|
16
|
+
children: [/* @__PURE__ */ r(e, { name: "calendar" }), /* @__PURE__ */ r("span", {
|
|
17
|
+
className: "pkt-btn__text",
|
|
18
|
+
children: T.datepicker.openPicker
|
|
19
|
+
})]
|
|
20
|
+
});
|
|
21
|
+
return u ? /* @__PURE__ */ i(n, { children: [/* @__PURE__ */ r(t, {
|
|
22
|
+
dates: c,
|
|
23
|
+
dateformat: l,
|
|
24
|
+
idBase: o,
|
|
25
|
+
strings: T,
|
|
26
|
+
onDateRemoved: V
|
|
27
|
+
}), /* @__PURE__ */ r("div", {
|
|
28
|
+
className: "pkt-datepicker__inputs",
|
|
29
|
+
children: /* @__PURE__ */ i("div", {
|
|
30
|
+
className: "pkt-input__container",
|
|
31
|
+
children: [/* @__PURE__ */ r("input", {
|
|
32
|
+
...K,
|
|
33
|
+
ref: j,
|
|
34
|
+
className: E,
|
|
35
|
+
type: C,
|
|
36
|
+
id: s,
|
|
37
|
+
name: _ ?? o,
|
|
38
|
+
placeholder: v,
|
|
39
|
+
readOnly: m || w && !m,
|
|
40
|
+
disabled: A,
|
|
41
|
+
"aria-describedby": b ? `${s}-helptext` : void 0,
|
|
42
|
+
"aria-invalid": y,
|
|
43
|
+
"aria-errormessage": y ? `${s}-error` : void 0,
|
|
44
|
+
onClick: q,
|
|
45
|
+
onTouchEnd: J,
|
|
46
|
+
onKeyDown: G,
|
|
47
|
+
onFocus: F,
|
|
48
|
+
onBlur: B
|
|
49
|
+
}), Y()]
|
|
50
|
+
})
|
|
51
|
+
})] }) : d ? /* @__PURE__ */ r("div", {
|
|
52
|
+
className: k,
|
|
53
|
+
children: /* @__PURE__ */ i("div", {
|
|
54
|
+
className: "pkt-input__container",
|
|
55
|
+
children: [
|
|
56
|
+
f && /* @__PURE__ */ r("div", {
|
|
57
|
+
className: "pkt-input-prefix",
|
|
58
|
+
children: T.generic.from
|
|
59
|
+
}),
|
|
60
|
+
/* @__PURE__ */ r("input", {
|
|
61
|
+
...K,
|
|
62
|
+
ref: j,
|
|
63
|
+
className: E,
|
|
64
|
+
type: C,
|
|
65
|
+
id: s,
|
|
66
|
+
name: _ ? `${_}-from` : `${o}-from`,
|
|
67
|
+
value: c[0] ?? "",
|
|
68
|
+
min: x,
|
|
69
|
+
max: S,
|
|
70
|
+
placeholder: v,
|
|
71
|
+
readOnly: m || w && !m,
|
|
72
|
+
disabled: p,
|
|
73
|
+
required: h,
|
|
74
|
+
"aria-label": `${g} ${T.generic.from}`,
|
|
75
|
+
"aria-describedby": b ? `${s}-helptext` : void 0,
|
|
76
|
+
"aria-invalid": y,
|
|
77
|
+
"aria-errormessage": y ? `${s}-error` : void 0,
|
|
78
|
+
onClick: q,
|
|
79
|
+
onTouchEnd: J,
|
|
80
|
+
onKeyDown: U,
|
|
81
|
+
onFocus: F,
|
|
82
|
+
onBlur: z,
|
|
83
|
+
onChange: L
|
|
84
|
+
}),
|
|
85
|
+
/* @__PURE__ */ r("div", {
|
|
86
|
+
className: O,
|
|
87
|
+
id: `${o}-to-label`,
|
|
88
|
+
children: T.generic.to
|
|
89
|
+
}),
|
|
90
|
+
!f && /* @__PURE__ */ r("div", {
|
|
91
|
+
className: "pkt-input-separator",
|
|
92
|
+
children: "–"
|
|
93
|
+
}),
|
|
94
|
+
/* @__PURE__ */ r("input", {
|
|
95
|
+
ref: M,
|
|
96
|
+
className: E,
|
|
97
|
+
type: C,
|
|
98
|
+
id: `${o}-to`,
|
|
99
|
+
name: _ ? `${_}-to` : `${o}-to`,
|
|
100
|
+
value: c[1] ?? "",
|
|
101
|
+
min: x,
|
|
102
|
+
max: S,
|
|
103
|
+
readOnly: m || w && !m,
|
|
104
|
+
disabled: p,
|
|
105
|
+
"aria-label": `${g} ${T.generic.to}`,
|
|
106
|
+
"aria-invalid": y,
|
|
107
|
+
onClick: q,
|
|
108
|
+
onTouchEnd: J,
|
|
109
|
+
onKeyDown: W,
|
|
110
|
+
onFocus: F,
|
|
111
|
+
onBlur: z,
|
|
112
|
+
onChange: R
|
|
113
|
+
}),
|
|
114
|
+
Y()
|
|
115
|
+
]
|
|
116
|
+
})
|
|
117
|
+
}) : /* @__PURE__ */ r("div", {
|
|
118
|
+
className: "pkt-datepicker__inputs",
|
|
119
|
+
children: /* @__PURE__ */ i("div", {
|
|
120
|
+
className: "pkt-input__container",
|
|
121
|
+
children: [/* @__PURE__ */ r("input", {
|
|
122
|
+
...K,
|
|
123
|
+
ref: j,
|
|
124
|
+
className: E,
|
|
125
|
+
type: C,
|
|
126
|
+
id: s,
|
|
127
|
+
name: _ ?? o,
|
|
128
|
+
value: c[0] ?? "",
|
|
129
|
+
min: x,
|
|
130
|
+
max: S,
|
|
131
|
+
placeholder: v,
|
|
132
|
+
readOnly: m || w && !m,
|
|
133
|
+
disabled: p,
|
|
134
|
+
required: h,
|
|
135
|
+
"aria-describedby": b ? `${s}-helptext` : void 0,
|
|
136
|
+
"aria-invalid": y,
|
|
137
|
+
"aria-errormessage": y ? `${s}-error` : void 0,
|
|
138
|
+
onClick: q,
|
|
139
|
+
onTouchEnd: J,
|
|
140
|
+
onKeyDown: H,
|
|
141
|
+
onFocus: F,
|
|
142
|
+
onBlur: void 0,
|
|
143
|
+
onChange: I
|
|
144
|
+
}), Y()]
|
|
145
|
+
})
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
//#endregion
|
|
149
|
+
export { a as DatepickerInputs };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { PktCalendar as e } from "../calendar/Calendar.js";
|
|
3
|
+
import { handleCalendarPosition as t } from "../../shared-utils/datepicker-utils.js";
|
|
4
|
+
import { useEffect as n, useRef as r } from "react";
|
|
5
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/datepicker/DatepickerPopup.tsx
|
|
7
|
+
var a = ({ open: a, multiple: o = !1, range: s = !1, weeknumbers: c = !1, withcontrols: l = !1, selected: u = [], earliest: d, latest: f, excludedates: p, excludeweekdays: m, maxMultiple: h, currentmonth: g, today: _, inputRef: v, hasCounter: y = !1, onDateSelected: b, onClose: x }) => {
|
|
8
|
+
let S = r(null), C = r(!1);
|
|
9
|
+
a && (C.current = !0), n(() => {
|
|
10
|
+
a && t(S.current, v?.current ?? null, y);
|
|
11
|
+
}, [
|
|
12
|
+
a,
|
|
13
|
+
v,
|
|
14
|
+
y
|
|
15
|
+
]);
|
|
16
|
+
let w = ["pkt-calendar-popup", a ? "show" : "hide"].join(" "), T = a || C.current;
|
|
17
|
+
return /* @__PURE__ */ i("div", {
|
|
18
|
+
ref: S,
|
|
19
|
+
className: w,
|
|
20
|
+
hidden: !a,
|
|
21
|
+
"aria-hidden": !a,
|
|
22
|
+
children: T && /* @__PURE__ */ i(e, {
|
|
23
|
+
multiple: o,
|
|
24
|
+
range: s,
|
|
25
|
+
weeknumbers: c,
|
|
26
|
+
withcontrols: l,
|
|
27
|
+
selected: u,
|
|
28
|
+
earliest: d,
|
|
29
|
+
latest: f,
|
|
30
|
+
excludedates: p,
|
|
31
|
+
excludeweekdays: m,
|
|
32
|
+
maxMultiple: h,
|
|
33
|
+
currentmonth: g,
|
|
34
|
+
today: _,
|
|
35
|
+
onDateSelected: b,
|
|
36
|
+
onClose: x
|
|
37
|
+
})
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
//#endregion
|
|
41
|
+
export { a as DatepickerPopup };
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { usePktStrings as e } from "../../hooks/usePktStrings.js";
|
|
2
|
+
import { filterSelectableDates as t, newDate as n } from "../../shared-utils/date-utils.js";
|
|
3
|
+
import { setNativeInputValue as r } from "../../utils/nativeInputValue.js";
|
|
4
|
+
import { isIOS as i } from "../../shared-utils/device-utils.js";
|
|
5
|
+
import { getDatepickerButtonClasses as a, getDatepickerInputClasses as ee, getDatepickerInputType as te, getRangeLabelClasses as ne, handleDatepickerKeydown as o, processDateSelection as re, validateRangeOrder as ie } from "../../shared-utils/datepicker-utils.js";
|
|
6
|
+
import { valueToArray as ae } from "../../shared-utils/value-utils.js";
|
|
7
|
+
import { useCallback as s, useEffect as c, useImperativeHandle as oe, useMemo as l, useRef as u, useState as d } from "react";
|
|
8
|
+
//#region src/components/datepicker/useDatepickerState.ts
|
|
9
|
+
function f(f, se) {
|
|
10
|
+
let { id: p, label: ce, value: m, defaultValue: h, dateformat: le = "dd.MM.yyyy", multiple: g = !1, maxlength: _, range: v = !1, showRangeLabels: y = !1, weeknumbers: ue = !1, withcontrols: de = !1, excludedates: b, excludeweekdays: x, currentmonth: S, today: fe, calendarOpen: C, timezone: w, fullwidth: T = !1, inputSize: E = "medium", hasFieldset: pe = !1, counter: me, inline: he = !1, helptext: ge, helptextDropdown: _e, helptextDropdownButton: ve, hasError: ye = !1, errorMessage: be, optionalTag: xe = !1, optionalText: Se, requiredTag: Ce = !1, requiredText: we, tagText: Te, useWrapper: Ee = !0, strings: D, disabled: O = !1, readOnly: k = !1, required: De = !1, name: Oe, min: A, max: j, placeholder: ke, onChange: Ae, onValueChange: M, className: je, ...Me } = f, N = s((e) => e === void 0 ? [] : ae(e), []), P = m !== void 0, Ne = typeof h == "number" ? void 0 : h, [F, I] = d(() => N(m ?? Ne)), L = P ? N(m) : F, Pe = u(F), [Fe, Ie] = d(m);
|
|
11
|
+
P && m !== Fe && (Ie(m), I(N(m)));
|
|
12
|
+
let [R, z] = d(C ?? !1), [Le, Re] = d(C);
|
|
13
|
+
C !== Le && (Re(C), C !== void 0 && z(C));
|
|
14
|
+
let B = u(null), V = u(null), H = u(null), ze = u(null), U = u(null), W = l(() => te(), []), G = l(() => i(), []), Be = e([
|
|
15
|
+
"generic",
|
|
16
|
+
"datepicker",
|
|
17
|
+
"validation"
|
|
18
|
+
], D), Ve = D, K = typeof A == "string" ? A : A === void 0 ? void 0 : String(A), q = typeof j == "string" ? j : j === void 0 ? void 0 : String(j), He = l(() => {
|
|
19
|
+
let e = ee(T, y, g, v, k, W, E);
|
|
20
|
+
return Object.entries(e).filter(([, e]) => e).map(([e]) => e).join(" ");
|
|
21
|
+
}, [
|
|
22
|
+
T,
|
|
23
|
+
y,
|
|
24
|
+
g,
|
|
25
|
+
v,
|
|
26
|
+
k,
|
|
27
|
+
W,
|
|
28
|
+
E
|
|
29
|
+
]), Ue = Object.entries(a(E)).filter(([, e]) => e).map(([e]) => e).join(" "), We = l(() => {
|
|
30
|
+
let e = ne(y);
|
|
31
|
+
return Object.entries(e).filter(([, e]) => e).map(([e]) => e).join(" ");
|
|
32
|
+
}, [y]), Ge = l(() => ["pkt-datepicker__inputs", v && "pkt-input__range-inputs"].filter(Boolean).join(" "), [v, y]), Ke = l(() => {
|
|
33
|
+
if (S) return S;
|
|
34
|
+
if (q) return q.slice(0, 7);
|
|
35
|
+
}, [S, q]), qe = O || g && _ != null && L.length >= _, Je = me ?? (g && _ != null), Ye = `${p}-input`, Xe = L.join(",");
|
|
36
|
+
c(() => {
|
|
37
|
+
H.current && (H.current.value = Xe);
|
|
38
|
+
}, [Xe]), c(() => {
|
|
39
|
+
w && typeof window < "u" && w !== window.pktTz && (window.pktTz = w);
|
|
40
|
+
}, [w]);
|
|
41
|
+
let J = s((e, t = !0) => {
|
|
42
|
+
P || I(e), t && M?.(e);
|
|
43
|
+
}, [P, M]), Y = s((e) => {
|
|
44
|
+
if (v && e.length === 1) return;
|
|
45
|
+
let t = H.current;
|
|
46
|
+
t && (r(t, e.join(",")), t.dispatchEvent(new Event("input", { bubbles: !0 })));
|
|
47
|
+
}, [v]), X = s(() => {
|
|
48
|
+
O || z((e) => !e);
|
|
49
|
+
}, [O]), Z = s(() => {
|
|
50
|
+
z(!1);
|
|
51
|
+
}, []);
|
|
52
|
+
c(() => {
|
|
53
|
+
if (!R) return;
|
|
54
|
+
let e = (e) => {
|
|
55
|
+
let t = e.target;
|
|
56
|
+
U.current && !U.current.contains(t) && !t.closest?.(".pkt-calendar-popup") && Z();
|
|
57
|
+
}, t = (e) => {
|
|
58
|
+
e.key === "Escape" && (Z(), B.current?.focus());
|
|
59
|
+
};
|
|
60
|
+
return document.addEventListener("click", e, !0), document.addEventListener("keydown", t), () => {
|
|
61
|
+
document.removeEventListener("click", e, !0), document.removeEventListener("keydown", t);
|
|
62
|
+
};
|
|
63
|
+
}, [R, Z]);
|
|
64
|
+
let Ze = s(() => {
|
|
65
|
+
G && !R && z(!0);
|
|
66
|
+
}, [G, R]), Qe = s((e) => {
|
|
67
|
+
let t = re(e, g, v), n = ae(t);
|
|
68
|
+
J(n), Y(n), !g && !v && (Z(), B.current?.focus());
|
|
69
|
+
}, [
|
|
70
|
+
g,
|
|
71
|
+
v,
|
|
72
|
+
J,
|
|
73
|
+
Y,
|
|
74
|
+
Z
|
|
75
|
+
]), $e = s(() => {
|
|
76
|
+
Z(), B.current?.focus();
|
|
77
|
+
}, [Z]), et = s((e) => {
|
|
78
|
+
let t = e.target.value, n = t ? [t] : [];
|
|
79
|
+
J(n), Y(n);
|
|
80
|
+
}, [J, Y]), tt = s((e) => {
|
|
81
|
+
let t = [e.target.value, L[1] ?? ""].filter(Boolean);
|
|
82
|
+
J(t), Y(t);
|
|
83
|
+
}, [
|
|
84
|
+
L,
|
|
85
|
+
J,
|
|
86
|
+
Y
|
|
87
|
+
]), nt = s((e) => {
|
|
88
|
+
let t = [L[0] ?? "", e.target.value].filter(Boolean);
|
|
89
|
+
J(t), Y(t);
|
|
90
|
+
}, [
|
|
91
|
+
L,
|
|
92
|
+
J,
|
|
93
|
+
Y
|
|
94
|
+
]), rt = s(() => {
|
|
95
|
+
L.length === 2 && !ie(L) && (J([L[0]]), Y([L[0]]));
|
|
96
|
+
}, [
|
|
97
|
+
L,
|
|
98
|
+
J,
|
|
99
|
+
Y
|
|
100
|
+
]), Q = s((e) => {
|
|
101
|
+
let r = n(e), i = K ? n(K) : null, a = q ? n(q) : null;
|
|
102
|
+
if (r && !isNaN(r.getTime()) && (!i || r >= i) && (!a || r <= a)) {
|
|
103
|
+
let n = t([...L, e], K, q, b, x), r = [...new Set(n)];
|
|
104
|
+
J(r), Y(r);
|
|
105
|
+
}
|
|
106
|
+
}, [
|
|
107
|
+
L,
|
|
108
|
+
K,
|
|
109
|
+
q,
|
|
110
|
+
b,
|
|
111
|
+
x,
|
|
112
|
+
J,
|
|
113
|
+
Y
|
|
114
|
+
]), it = s((e) => {
|
|
115
|
+
let t = e.target;
|
|
116
|
+
t.value &&= (Q(t.value.split(",")[0]), "");
|
|
117
|
+
}, [Q]), at = s((e) => {
|
|
118
|
+
let t = e.target;
|
|
119
|
+
t.value &&= (Q(t.value.split(",")[0]), "");
|
|
120
|
+
}, [Q]), ot = s((e) => {
|
|
121
|
+
let t = L.filter((t) => t !== e);
|
|
122
|
+
J(t), Y(t);
|
|
123
|
+
}, [
|
|
124
|
+
L,
|
|
125
|
+
J,
|
|
126
|
+
Y
|
|
127
|
+
]), $ = s((e) => {
|
|
128
|
+
let t = e?.closest("form");
|
|
129
|
+
t ? t.requestSubmit() : e?.blur();
|
|
130
|
+
}, []), st = s((e) => {
|
|
131
|
+
o(e.nativeEvent, () => X(), () => $(B.current), void 0, () => B.current?.blur());
|
|
132
|
+
}, [X, $]), ct = s((e) => {
|
|
133
|
+
o(e.nativeEvent, () => X(), () => $(B.current), () => V.current?.focus(), () => B.current?.blur());
|
|
134
|
+
}, [X, $]), lt = s((e) => {
|
|
135
|
+
o(e.nativeEvent, () => X(), () => $(V.current), void 0, () => V.current?.blur());
|
|
136
|
+
}, [X, $]), ut = s((e) => {
|
|
137
|
+
o(e.nativeEvent, () => X(), () => $(B.current), void 0, () => B.current?.blur(), at);
|
|
138
|
+
}, [
|
|
139
|
+
X,
|
|
140
|
+
$,
|
|
141
|
+
at
|
|
142
|
+
]);
|
|
143
|
+
return c(() => {
|
|
144
|
+
let e = U.current?.closest("form");
|
|
145
|
+
if (!e) return;
|
|
146
|
+
let t, n = () => {
|
|
147
|
+
window.clearTimeout(t), t = window.setTimeout(() => {
|
|
148
|
+
I(Pe.current), z(!1), H.current && (H.current.value = Pe.current.join(","));
|
|
149
|
+
}, 0);
|
|
150
|
+
};
|
|
151
|
+
return e.addEventListener("reset", n), () => {
|
|
152
|
+
e.removeEventListener("reset", n), window.clearTimeout(t);
|
|
153
|
+
};
|
|
154
|
+
}, []), oe(se, () => ({
|
|
155
|
+
get value() {
|
|
156
|
+
return H.current?.value ?? "";
|
|
157
|
+
},
|
|
158
|
+
set value(e) {
|
|
159
|
+
let t = e ? e.split(",").filter(Boolean) : [];
|
|
160
|
+
I(t), H.current && (H.current.value = e ?? "");
|
|
161
|
+
},
|
|
162
|
+
focus() {
|
|
163
|
+
B.current?.focus();
|
|
164
|
+
},
|
|
165
|
+
blur() {
|
|
166
|
+
B.current?.blur();
|
|
167
|
+
}
|
|
168
|
+
}), []), {
|
|
169
|
+
id: p,
|
|
170
|
+
inputId: Ye,
|
|
171
|
+
label: ce,
|
|
172
|
+
values: L,
|
|
173
|
+
calendarOpen: R,
|
|
174
|
+
dateformat: le,
|
|
175
|
+
multiple: g,
|
|
176
|
+
maxlength: _,
|
|
177
|
+
range: v,
|
|
178
|
+
showRangeLabels: y,
|
|
179
|
+
weeknumbers: ue,
|
|
180
|
+
withcontrols: de,
|
|
181
|
+
excludedates: b,
|
|
182
|
+
excludeweekdays: x,
|
|
183
|
+
disabled: O,
|
|
184
|
+
readOnly: k,
|
|
185
|
+
required: De,
|
|
186
|
+
name: Oe,
|
|
187
|
+
placeholder: ke,
|
|
188
|
+
fullwidth: T,
|
|
189
|
+
inputSize: E,
|
|
190
|
+
hasFieldset: pe,
|
|
191
|
+
inline: he,
|
|
192
|
+
helptext: ge,
|
|
193
|
+
helptextDropdown: _e,
|
|
194
|
+
helptextDropdownButton: ve,
|
|
195
|
+
hasError: ye,
|
|
196
|
+
errorMessage: be,
|
|
197
|
+
optionalTag: xe,
|
|
198
|
+
optionalText: Se,
|
|
199
|
+
requiredTag: Ce,
|
|
200
|
+
requiredText: we,
|
|
201
|
+
tagText: Te,
|
|
202
|
+
useWrapper: Ee,
|
|
203
|
+
className: je,
|
|
204
|
+
minStr: K,
|
|
205
|
+
maxStr: q,
|
|
206
|
+
effectiveCurrentMonth: Ke,
|
|
207
|
+
today: fe,
|
|
208
|
+
inputType: W,
|
|
209
|
+
isIOSDevice: G,
|
|
210
|
+
strings: Be,
|
|
211
|
+
stringsOverride: Ve,
|
|
212
|
+
inputClasses: He,
|
|
213
|
+
buttonClasses: Ue,
|
|
214
|
+
rangeLabelClasses: We,
|
|
215
|
+
datepickerInputsClasses: Ge,
|
|
216
|
+
isInputDisabled: qe,
|
|
217
|
+
hasCounter: Je,
|
|
218
|
+
inputRef: B,
|
|
219
|
+
inputToRef: V,
|
|
220
|
+
changeInputRef: H,
|
|
221
|
+
btnRef: ze,
|
|
222
|
+
wrapperRef: U,
|
|
223
|
+
onChange: Ae,
|
|
224
|
+
toggleCalendar: X,
|
|
225
|
+
hideCalendar: Z,
|
|
226
|
+
handleDateSelected: Qe,
|
|
227
|
+
handleCalendarClose: $e,
|
|
228
|
+
handleFocus: Ze,
|
|
229
|
+
handleSingleInputChange: et,
|
|
230
|
+
handleRangeFromChange: tt,
|
|
231
|
+
handleRangeToChange: nt,
|
|
232
|
+
handleRangeBlur: rt,
|
|
233
|
+
handleMultipleBlur: it,
|
|
234
|
+
handleTagRemoved: ot,
|
|
235
|
+
handleSingleKeydown: st,
|
|
236
|
+
handleRangeFromKeydown: ct,
|
|
237
|
+
handleRangeToKeydown: lt,
|
|
238
|
+
handleMultipleKeydown: ut,
|
|
239
|
+
restProps: Me
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
//#endregion
|
|
243
|
+
export { f as useDatepickerState };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { __toESM as e } from "../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { require_classnames as t } from "../../node_modules/classnames/index.js";
|
|
3
|
+
import { PktIcon as n } from "../icon/Icon.js";
|
|
4
|
+
import { usePktStrings as r } from "../../hooks/usePktStrings.js";
|
|
5
|
+
import { FileItem as i } from "./types.js";
|
|
6
|
+
import { forwardRef as a, useCallback as o, useEffect as s, useImperativeHandle as c, useMemo as l, useRef as u, useState as d } from "react";
|
|
7
|
+
import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
8
|
+
//#region src/components/fileupload/DropZone.tsx
|
|
9
|
+
var h = /* @__PURE__ */ e(t(), 1), g = a(({ id: e, multiple: t, value: a, onFilesAdded: g = () => {}, name: v, uploadStrategy: y, accept: b, isThumbnailView: x = !1, disabled: S = !1, hasVisibleLabel: C = !1, strings: w, ...T }, E) => {
|
|
10
|
+
let D = u(null), O = typeof b == "string" && b.trim().length > 0 ? b : void 0, k = l(() => O ? O.split(/\s*,\s*/).map((e) => e.trim()).filter(Boolean).join(", ").toUpperCase() : "", [O]);
|
|
11
|
+
c(E, () => D.current);
|
|
12
|
+
let [A, j] = d(!1), M = r(["fileupload"], w), N = l(() => x ? t ? {
|
|
13
|
+
dragInactive: M.fileupload.dropZoneDragMultipleThumbnail,
|
|
14
|
+
dragActive: M.fileupload.dropZoneDragActiveMultipleThumbnail,
|
|
15
|
+
openFileDialog: M.fileupload.dropZoneOpenFileDialogMultipleThumbnail
|
|
16
|
+
} : {
|
|
17
|
+
dragInactive: M.fileupload.dropZoneDragSingleThumbnail,
|
|
18
|
+
dragActive: M.fileupload.dropZoneDragActiveSingleThumbnail,
|
|
19
|
+
openFileDialog: M.fileupload.dropZoneOpenFileDialogSingleThumbnail
|
|
20
|
+
} : t ? {
|
|
21
|
+
dragInactive: M.fileupload.dropZoneDragMultiple,
|
|
22
|
+
dragActive: M.fileupload.dropZoneDragActiveMultiple,
|
|
23
|
+
openFileDialog: M.fileupload.dropZoneOpenFileDialogMultiple
|
|
24
|
+
} : {
|
|
25
|
+
dragInactive: M.fileupload.dropZoneDragSingle,
|
|
26
|
+
dragActive: M.fileupload.dropZoneDragActiveSingle,
|
|
27
|
+
openFileDialog: M.fileupload.dropZoneOpenFileDialogSingle
|
|
28
|
+
}, [
|
|
29
|
+
t,
|
|
30
|
+
x,
|
|
31
|
+
M
|
|
32
|
+
]), P = o((e) => {
|
|
33
|
+
if (D.current) try {
|
|
34
|
+
D.current.files = _(e);
|
|
35
|
+
} catch {}
|
|
36
|
+
}, [D.current, a]);
|
|
37
|
+
s(() => {
|
|
38
|
+
P(a);
|
|
39
|
+
}, [D, a]);
|
|
40
|
+
let F = o((e) => {
|
|
41
|
+
g(e.map((e) => new i(e))), D.current && (D.current.value = "");
|
|
42
|
+
}, [g]), I = (e) => {
|
|
43
|
+
let t = e.target.files;
|
|
44
|
+
if (t.length === 0) {
|
|
45
|
+
P(a);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
F(Array.from(t));
|
|
49
|
+
}, L = (e) => {
|
|
50
|
+
F(e);
|
|
51
|
+
}, R = (e) => {
|
|
52
|
+
if (e.preventDefault(), j(!1), S) return;
|
|
53
|
+
let t = e.dataTransfer.files, n = Array.from(t);
|
|
54
|
+
L(n);
|
|
55
|
+
}, z = (e) => {
|
|
56
|
+
e.preventDefault(), !S && j(!0);
|
|
57
|
+
}, B = () => {
|
|
58
|
+
j(!1);
|
|
59
|
+
}, V = o((e) => {
|
|
60
|
+
S || e.target.closest(".pkt-fileupload__drop-zone__placeholder__title__open-file-dialog") || D.current?.click();
|
|
61
|
+
}, [S]);
|
|
62
|
+
return /* @__PURE__ */ m("div", {
|
|
63
|
+
onDrop: R,
|
|
64
|
+
onDragOver: z,
|
|
65
|
+
onDragLeave: B,
|
|
66
|
+
onClick: V,
|
|
67
|
+
className: (0, h.default)("pkt-fileupload__drop-zone", {
|
|
68
|
+
"pkt-fileupload__drop-zone--drag-active": A,
|
|
69
|
+
"pkt-fileupload__drop-zone--disabled": S
|
|
70
|
+
}),
|
|
71
|
+
children: [
|
|
72
|
+
/* @__PURE__ */ p("input", {
|
|
73
|
+
...T,
|
|
74
|
+
id: e,
|
|
75
|
+
type: "file",
|
|
76
|
+
ref: D,
|
|
77
|
+
multiple: t,
|
|
78
|
+
onChange: I,
|
|
79
|
+
accept: O,
|
|
80
|
+
disabled: S,
|
|
81
|
+
name: y === "form" && v || void 0,
|
|
82
|
+
"aria-label": C ? void 0 : t ? M.fileupload.openFileDialogLabelMultiple : M.fileupload.openFileDialogLabelSingle
|
|
83
|
+
}),
|
|
84
|
+
y === "custom" && /* @__PURE__ */ p(f, { children: a?.map((e) => /* @__PURE__ */ p("input", {
|
|
85
|
+
type: "hidden",
|
|
86
|
+
name: v,
|
|
87
|
+
form: T.form,
|
|
88
|
+
value: e.fileId
|
|
89
|
+
}, e.fileId)) }),
|
|
90
|
+
/* @__PURE__ */ m("div", {
|
|
91
|
+
className: "pkt-fileupload__drop-zone__placeholder",
|
|
92
|
+
children: [
|
|
93
|
+
/* @__PURE__ */ p(n, {
|
|
94
|
+
name: "attachment",
|
|
95
|
+
className: "pkt-fileupload__drop-zone__placeholder__icon",
|
|
96
|
+
"aria-hidden": "true"
|
|
97
|
+
}),
|
|
98
|
+
/* @__PURE__ */ p("p", {
|
|
99
|
+
className: "pkt-fileupload__drop-zone__placeholder__title",
|
|
100
|
+
children: A ? `${N.dragActive} ...` : /* @__PURE__ */ m(f, { children: [
|
|
101
|
+
N.dragInactive,
|
|
102
|
+
" ",
|
|
103
|
+
/* @__PURE__ */ p("button", {
|
|
104
|
+
className: "pkt-fileupload__drop-zone__placeholder__title__open-file-dialog",
|
|
105
|
+
onClick: (e) => {
|
|
106
|
+
e.preventDefault(), e.stopPropagation(), D.current?.click();
|
|
107
|
+
},
|
|
108
|
+
type: "button",
|
|
109
|
+
children: N.openFileDialog
|
|
110
|
+
})
|
|
111
|
+
] })
|
|
112
|
+
}),
|
|
113
|
+
k ? /* @__PURE__ */ m("p", {
|
|
114
|
+
className: "pkt-fileupload__drop-zone__placeholder__formats",
|
|
115
|
+
children: [
|
|
116
|
+
M.fileupload.supportedFormatsPrefix,
|
|
117
|
+
" ",
|
|
118
|
+
k
|
|
119
|
+
]
|
|
120
|
+
}) : null
|
|
121
|
+
]
|
|
122
|
+
})
|
|
123
|
+
]
|
|
124
|
+
});
|
|
125
|
+
}), _ = (e) => {
|
|
126
|
+
let t = new DataTransfer();
|
|
127
|
+
for (let n of e) t.items.add(n.file);
|
|
128
|
+
return t.files;
|
|
129
|
+
};
|
|
130
|
+
//#endregion
|
|
131
|
+
export { g as DropZone, _ as createFileList };
|