@povio/ui 3.2.4-rc.4 → 3.3.0-rc.2

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.
Files changed (42) hide show
  1. package/dist/components/buttons/Button/button.cva.d.ts +1 -1
  2. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +0 -1
  3. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +127 -142
  4. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +17 -2
  5. package/dist/components/inputs/DateTime/shared/DateField.js +87 -92
  6. package/dist/components/inputs/DateTime/shared/DatePickerInput.js +0 -2
  7. package/dist/components/inputs/DateTime/shared/TimePickerInput.js +134 -144
  8. package/dist/components/inputs/FormField/FormField.js +47 -34
  9. package/dist/components/inputs/FormField/formField.cva.d.ts +11 -0
  10. package/dist/components/inputs/FormField/formField.cva.js +16 -0
  11. package/dist/components/inputs/Input/NumberInput/NumberInput.js +1 -2
  12. package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +1 -2
  13. package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +2 -54
  14. package/dist/components/inputs/Selection/Select/QuerySelect.js +46 -99
  15. package/dist/components/inputs/Selection/shared/querySelect.utils.d.ts +0 -1
  16. package/dist/components/inputs/Selection/shared/querySelect.utils.js +0 -1
  17. package/dist/components/inputs/Selection/shared/select.context.js +9 -19
  18. package/dist/components/inputs/shared/InputClear.js +40 -24
  19. package/dist/components/inputs/shared/input.cva.js +1 -1
  20. package/dist/components/shared/pagination/minWidth.cva.d.ts +1 -1
  21. package/dist/components/table/Table.d.ts +8 -2
  22. package/dist/components/table/Table.js +55 -33
  23. package/dist/components/table/TableColumnFilterInput.d.ts +9 -0
  24. package/dist/components/table/TableColumnFilterInput.js +108 -0
  25. package/dist/components/table/TableColumnFilterPlaceholder.d.ts +5 -0
  26. package/dist/components/table/TableColumnFilterPlaceholder.js +41 -0
  27. package/dist/components/table/TableColumnFilterRow.d.ts +16 -0
  28. package/dist/components/table/TableColumnFilterRow.js +68 -0
  29. package/dist/config/uiConfig.context.d.ts +0 -1
  30. package/dist/config/uiConfig.context.js +1 -2
  31. package/dist/config/uiOverrides.context.d.ts +1 -0
  32. package/dist/helpers/dynamicColumns.js +1 -2
  33. package/dist/index.d.ts +1 -1
  34. package/dist/index.js +2 -2
  35. package/dist/utils/date-time.utils.d.ts +1 -0
  36. package/dist/utils/date-time.utils.js +45 -21
  37. package/package.json +1 -1
  38. package/dist/components/inputs/DateTime/shared/useFirefoxDateSegmentSelectionGuard.d.ts +0 -2
  39. package/dist/components/inputs/DateTime/shared/useFirefoxDateSegmentSelectionGuard.js +0 -33
  40. package/dist/utils/intl.utils.d.ts +0 -7
  41. package/dist/utils/intl.utils.js +0 -38
  42. package/dist/utils/intl.utils.spec.d.ts +0 -1
@@ -0,0 +1,5 @@
1
+ interface TableColumnFilterPlaceholderProps {
2
+ label?: string;
3
+ }
4
+ export declare const TableColumnFilterPlaceholder: ({ label }: TableColumnFilterPlaceholderProps) => import("react/jsx-runtime").JSX.Element;
5
+ export {};
@@ -0,0 +1,41 @@
1
+ import { c } from "react/compiler-runtime";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { clsx } from "clsx";
4
+ //#region src/components/table/TableColumnFilterPlaceholder.tsx
5
+ var columnFilterPlaceholderClassName = clsx("h-[calc(var(--spacing-input-height-xs)*2+var(--text-label-2)*var(--text-label-2--line-height)+2px)]", "flex w-full min-w-0 items-center overflow-hidden", "rounded-input-rounding-default border border-solid border-input-outlined-outline-disabled/50", "bg-input-filled-idle px-input-side-xs text-label-2");
6
+ var TableColumnFilterPlaceholder = (t0) => {
7
+ const $ = c(8);
8
+ const { label } = t0;
9
+ const t1 = label ? void 0 : true;
10
+ const t2 = label && "text-text-default-2";
11
+ let t3;
12
+ if ($[0] !== t2) {
13
+ t3 = clsx(columnFilterPlaceholderClassName, t2);
14
+ $[0] = t2;
15
+ $[1] = t3;
16
+ } else t3 = $[1];
17
+ let t4;
18
+ if ($[2] !== label) {
19
+ t4 = label ? /* @__PURE__ */ jsx("span", {
20
+ className: "min-w-0 truncate",
21
+ children: label
22
+ }) : null;
23
+ $[2] = label;
24
+ $[3] = t4;
25
+ } else t4 = $[3];
26
+ let t5;
27
+ if ($[4] !== t1 || $[5] !== t3 || $[6] !== t4) {
28
+ t5 = /* @__PURE__ */ jsx("div", {
29
+ "aria-hidden": t1,
30
+ className: t3,
31
+ children: t4
32
+ });
33
+ $[4] = t1;
34
+ $[5] = t3;
35
+ $[6] = t4;
36
+ $[7] = t5;
37
+ } else t5 = $[7];
38
+ return t5;
39
+ };
40
+ //#endregion
41
+ export { TableColumnFilterPlaceholder };
@@ -0,0 +1,16 @@
1
+ import { Header } from '@tanstack/react-table';
2
+ import { UseFormReturn } from 'react-hook-form';
3
+ import { InputDef } from '../inputs/Inputs/InputItem';
4
+ import { UIOverrides } from '../../config/uiOverrides.context';
5
+ import { TableHeadDataVariantProps } from './table.cva';
6
+ interface TableColumnFilterRowProps<T> {
7
+ headers: Header<T, unknown>[];
8
+ filterForm: UseFormReturn<Record<string, any>>;
9
+ filterDefs: InputDef<any>[];
10
+ tableHeadDataCva: UIOverrides.Cva<TableHeadDataVariantProps>;
11
+ rowClassName?: string;
12
+ cellClassName?: string;
13
+ showCellBorder?: boolean;
14
+ }
15
+ export declare const TableColumnFilterRow: <T>({ headers, filterForm, filterDefs, tableHeadDataCva, rowClassName, cellClassName, showCellBorder, }: TableColumnFilterRowProps<T>) => import("react/jsx-runtime").JSX.Element;
16
+ export {};
@@ -0,0 +1,68 @@
1
+ import { TableColumnFilterInput } from "./TableColumnFilterInput.js";
2
+ import { TableColumnFilterPlaceholder } from "./TableColumnFilterPlaceholder.js";
3
+ import { c } from "react/compiler-runtime";
4
+ import { jsx } from "react/jsx-runtime";
5
+ import { clsx } from "clsx";
6
+ //#region src/components/table/TableColumnFilterRow.tsx
7
+ var getColumnMeta = (header) => header.column.columnDef.meta ?? {};
8
+ var TableColumnFilterRow = (t0) => {
9
+ const $ = c(18);
10
+ const { headers, filterForm, filterDefs, tableHeadDataCva, rowClassName, cellClassName, showCellBorder } = t0;
11
+ let t1;
12
+ if ($[0] !== filterDefs) {
13
+ t1 = new Map((filterDefs ?? []).map(_temp));
14
+ $[0] = filterDefs;
15
+ $[1] = t1;
16
+ } else t1 = $[1];
17
+ const inputDefsByName = t1;
18
+ let t2;
19
+ if ($[2] !== cellClassName || $[3] !== filterForm || $[4] !== headers || $[5] !== inputDefsByName || $[6] !== showCellBorder || $[7] !== tableHeadDataCva) {
20
+ let t3;
21
+ if ($[9] !== cellClassName || $[10] !== filterForm || $[11] !== inputDefsByName || $[12] !== showCellBorder || $[13] !== tableHeadDataCva) {
22
+ t3 = (header, index) => {
23
+ const columnMeta = getColumnMeta(header);
24
+ const filterKey = columnMeta.filterKey ?? header.column.id;
25
+ const filterDef_0 = inputDefsByName.get(filterKey);
26
+ return /* @__PURE__ */ jsx("th", {
27
+ colSpan: header.colSpan,
28
+ tabIndex: -1,
29
+ className: clsx(tableHeadDataCva({ hasRightBorder: index > 0 && showCellBorder }), "min-w-0 max-w-full overflow-hidden", cellClassName, columnMeta.width),
30
+ children: filterDef_0 ? /* @__PURE__ */ jsx(TableColumnFilterInput, {
31
+ form: filterForm,
32
+ inputDef: filterDef_0
33
+ }) : /* @__PURE__ */ jsx(TableColumnFilterPlaceholder, {})
34
+ }, `${header.id}-filter`);
35
+ };
36
+ $[9] = cellClassName;
37
+ $[10] = filterForm;
38
+ $[11] = inputDefsByName;
39
+ $[12] = showCellBorder;
40
+ $[13] = tableHeadDataCva;
41
+ $[14] = t3;
42
+ } else t3 = $[14];
43
+ t2 = headers.map(t3);
44
+ $[2] = cellClassName;
45
+ $[3] = filterForm;
46
+ $[4] = headers;
47
+ $[5] = inputDefsByName;
48
+ $[6] = showCellBorder;
49
+ $[7] = tableHeadDataCva;
50
+ $[8] = t2;
51
+ } else t2 = $[8];
52
+ let t3;
53
+ if ($[15] !== rowClassName || $[16] !== t2) {
54
+ t3 = /* @__PURE__ */ jsx("tr", {
55
+ className: rowClassName,
56
+ children: t2
57
+ });
58
+ $[15] = rowClassName;
59
+ $[16] = t2;
60
+ $[17] = t3;
61
+ } else t3 = $[17];
62
+ return t3;
63
+ };
64
+ function _temp(filterDef) {
65
+ return [String(filterDef.name), filterDef];
66
+ }
67
+ //#endregion
68
+ export { TableColumnFilterRow };
@@ -48,7 +48,6 @@ export declare namespace UIConfig {
48
48
  setDateValueOnDateSelection?: boolean;
49
49
  timeZone?: string;
50
50
  todayIconButtonComponent?: DatePickerProps["todayIconButtonComponent"];
51
- allowPartialRange?: boolean;
52
51
  };
53
52
  actionModal: Pick<ActionModalProps, "titleTypography" | "descriptionTypography">;
54
53
  bottomSheet: Pick<BottomSheetProps, "closeDragThreshold" | "closeVelocityThreshold" | "hideThumb" | "headerTypography">;
@@ -78,8 +78,7 @@ var UIConfig;
78
78
  setDateValueOnDateSelection: false,
79
79
  timeZone: "clientLocal",
80
80
  granularity: "day",
81
- shouldUpdateDateOnMonthYearChange: false,
82
- allowPartialRange: false
81
+ shouldUpdateDateOnMonthYearChange: false
83
82
  },
84
83
  actionModal: {
85
84
  titleTypography: {
@@ -158,6 +158,7 @@ export declare namespace UIOverrides {
158
158
  cva?: GenericCvaOption;
159
159
  };
160
160
  formField: {
161
+ cva?: GenericCvaOption;
161
162
  headerCva?: GenericCvaOption;
162
163
  errorLabelCva?: GenericCvaOption;
163
164
  helperLabelCva?: GenericCvaOption;
@@ -1,4 +1,3 @@
1
- import { IntlUtils } from "../utils/intl.utils.js";
2
1
  import { StringUtils } from "../utils/string.utils.js";
3
2
  import { ZodUtils } from "../utils/zod.utils.js";
4
3
  import { DateUtils } from "../utils/date.utils.js";
@@ -12,7 +11,7 @@ var FORMAT_MAP = {
12
11
  return `${DateUtils.formatDate(new Date(value.start))} - ${DateUtils.formatDate(new Date(value.end))}`;
13
12
  },
14
13
  enum: (value) => StringUtils.capitalize(value),
15
- number: (value) => IntlUtils.getNumberFormatter(i18next.language).format(value),
14
+ number: (value) => value.toLocaleString(i18next.language),
16
15
  string: (value) => String(value),
17
16
  boolean: (value) => {
18
17
  const key = `${DEFAULT_NAMESPACE}.${value ? "yes" : "no"}`;
package/dist/index.d.ts CHANGED
@@ -193,6 +193,7 @@ export { inputUploadButtonDefinition, inputUploadDropZoneDefinition, } from './c
193
193
  export { progressBarDefinition, progressBarFillDefinition, progressBarTrackDefinition, progressBarTrackWrapperDefinition, progressBarValueDefinition, } from './components/inputs/File/shared/progressBar.cva';
194
194
  export type { ProgressBarConfig, ProgressBarTrackConfig, ProgressBarVariantProps, } from './components/inputs/File/shared/progressBar.cva';
195
195
  export { formFieldHeaderDefinition } from './components/inputs/FormField/formFieldHeader.cva';
196
+ export { formFieldDefinition } from './components/inputs/FormField/formField.cva';
196
197
  export { formFieldErrorDefinition } from './components/inputs/FormField/formFieldError.cva';
197
198
  export { formFieldHelperDefinition } from './components/inputs/FormField/formFieldHelper.cva';
198
199
  export { textAreaWrapperDefinition } from './components/inputs/Input/TextArea/TextArea.cva';
@@ -253,7 +254,6 @@ export { DateTimeUtils } from './utils/date-time.utils';
253
254
  export { DomUtils } from './utils/dom.utils';
254
255
  export { FileUtils } from './utils/file.utils';
255
256
  export { isEqual } from './utils/isEqual';
256
- export { IntlUtils } from './utils/intl.utils';
257
257
  export { logger } from './utils/logger';
258
258
  export { ObjectUtils } from './utils/object.utils';
259
259
  export { QueriesUtils } from './utils/queries.utils';
package/dist/index.js CHANGED
@@ -77,12 +77,12 @@ import { Checkbox } from "./components/inputs/Checkbox/Checkbox.js";
77
77
  import { formFieldHeaderDefinition } from "./components/inputs/FormField/formFieldHeader.cva.js";
78
78
  import { labelDefinition } from "./components/inputs/shared/label.cva.js";
79
79
  import { formFieldHelperDefinition } from "./components/inputs/FormField/formFieldHelper.cva.js";
80
+ import { formFieldDefinition } from "./components/inputs/FormField/formField.cva.js";
80
81
  import { FormField } from "./components/inputs/FormField/FormField.js";
81
82
  import { inputBaseDefinition, inputClearClassDefinition, inputContentWrapperDefinition, inputSideDefinition, inputSizeDefinition } from "./components/inputs/shared/input.cva.js";
82
83
  import { CheckboxGroup } from "./components/inputs/Checkbox/CheckboxGroup.js";
83
84
  import { useLongPressRepeat } from "./hooks/useLongPressRepeat.js";
84
85
  import { useScrollableListBox } from "./hooks/useScrollableListBox.js";
85
- import { IntlUtils } from "./utils/intl.utils.js";
86
86
  import { DateTimeUtils } from "./utils/date-time.utils.js";
87
87
  import { datePickerInputContentRowDefinition } from "./components/inputs/DateTime/shared/datePickerInput.cva.js";
88
88
  import { popoverDefinition } from "./components/shared/popover.cva.js";
@@ -177,4 +177,4 @@ import { useSorting } from "./hooks/useSorting.js";
177
177
  import { useTableColumnConfig } from "./hooks/useTableColumnConfig.js";
178
178
  import { ArrayUtils } from "./utils/array.utils.js";
179
179
  import { QueriesUtils } from "./utils/queries.utils.js";
180
- export { Accordion, ActionModal, Alert, AlignCenterIcon, AlignLeftIcon, AlignLeftRightIcon, AlignRightIcon, ArrayUtils, ArrowDropDownIcon, ArrowDropUpIcon, ArrowLeftIcon, ArrowRightIcon, Autocomplete, BoldIcon, BottomSheet, Breadcrumbs, BulletedListIcon, Button, CalendarIcon, CellText, CheckIcon, Checkbox, CheckboxCheckmarkIcon, CheckboxGroup, CheckboxIndeterminateIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, ChevronsLeftIcon, ChevronsRightIcon, ClockIcon, CloseIcon, ColumnConfigModal, Confirmation, DatePicker, DateRangePicker, DateTimeIcon, DateTimePicker, DateTimeUtils, DateUtils, DomUtils, Drawer, FileUpload, FileUploadContainer, FileUtils, Form, FormField, HeaderText, HighlightIcon, HighlightOnIcon, HomeIcon, IconButton, InfiniteTable, InfoIcon, InlineIconButton, InputUpload, Inputs, IntlUtils, ItalicIcon, Link, LinkContext, LinkIcon, Loader, Menu, MenuIcon, MenuItem, MenuPopover, Modal, NumberInput, NumberRangeInput, NumberedListIcon, ObjectUtils, PaginatedTable, Pagination, PaginationList, PasswordInput, Pill, PillButton, PointerHorizontalIcon, PointerVerticalIcon, ProgressBar, QueriesUtils, QueryAutocomplete, QuerySelect, RadioGroup, ResponsivePopover, RestUtils, RoutingUtils, Segment, Select, SendIcon, Slider, SplitButton, Stepper, StrikethroughIcon, StringUtils, Table, Tag, TextArea, TextButton, TextColorIcon, TextInput, ThemeContext, TimePicker, Toast, ToastContainer, Toggle, ToggleButton, Tooltip, TooltipEllipsis, Typography, UIConfig, UIOverrides, UIRouter, UnderlinedIcon, VisibilityIcon, VisibilityOffIcon, ZodUtils, accordionChevronDefinition, accordionDefinition, accordionHeadingDefinition, accordionHeadingSubtitleDefinition, accordionHeadingTitleDefinition, accordionIconDefinition, accordionItemDefinition, accordionPanelContentDefinition, accordionPanelDefinition, accordionTriggerDefinition, alertDefinition, breadcrumbChevronDefinition, breadcrumbIconDefinition, breadcrumbItemDefinition, breadcrumbSegmentDefinition, breadcrumbsDefinition, buttonContentDefinition, buttonDefinition, buttonIconSizeDefinition, buttonSizeDefinition, checkboxContentRowDefinition, checkboxContentWrapperDefinition, checkboxDefinition, checkboxGroupLabelDefinition, checkboxIconDefinition, compoundMapper, createKeyInteractionsHandler, datePickerInputContentRowDefinition, dynamicColumns, dynamicInputs, fileUploadDropZoneDefinition, formFieldErrorDefinition, formFieldHeaderDefinition, formFieldHelperDefinition, getKeyInteractionAction, inputBaseDefinition, inputClearClassDefinition, inputContentWrapperDefinition, inputSideDefinition, inputSizeDefinition, inputUploadButtonDefinition, inputUploadDropZoneDefinition, isEqual, labelDefinition, linkDefinition, loaderDefinition, loaderWrapperDefinition, logger, menuDefinition, menuItemDefinition, menuPopoverDefinition, menuPopoverWrapperDefinition, modalContentDefinition, modalMainDefinition, modalOverlayDefinition, ns, pillButtonContentDefinition, pillButtonDefinition, popoverDefinition, progressBarDefinition, progressBarFillDefinition, progressBarTrackDefinition, progressBarTrackWrapperDefinition, progressBarValueDefinition, radioContentRowDefinition, radioContentWrapperDefinition, radioDefinition, resources, segmentDefinition, segmentItemDefinition, selectInputTagsContentWrapperDefinition, selectListBoxItemDefinition, selectPopoverDefinition, statusIconDefinition, statusSeparatorDefinition, stepperDefinition, stepperIconDefinition, stepperItemDefinition, stepperNumberDefinition, stepperSeparatorDefinition, stepperSubtextDefinition, stepperTitleDefinition, tableCellTextDefinition, tableDataDefinition, tableHeadDataDefinition, tableHeadRowDefinition, tableHeaderTextDefinition, tableRowDefinition, tagDefinition, textAreaWrapperDefinition, toastDefinition, statusIconDefinition$1 as toastStatusIconDefinition, statusSeparatorDefinition$1 as toastStatusSeparatorDefinition, toggleDefinition, tooltipDefinition, tooltipPointerHorizontalDefinition, tooltipPointerVerticalDefinition, tooltipTextDefinition, tooltipWrapperTriggerDefinition, typographyDefinition, uiOutlineClass, useAutosave, useBreakpoint, useDebounceCallback, useDeepCompareEffect, useDeepCompareLayoutEffect, useDeepCompareMemo, useFilters, useForm, useFormAutosave, useIntersectionObserver, useKeyInteractions, useLocalStorage, useLongPressRepeat, usePagination, useScrollableListBox, useSorting, useStateAndRef, useTableColumnConfig, useTableNav, useToast, useTranslationMemo };
180
+ export { Accordion, ActionModal, Alert, AlignCenterIcon, AlignLeftIcon, AlignLeftRightIcon, AlignRightIcon, ArrayUtils, ArrowDropDownIcon, ArrowDropUpIcon, ArrowLeftIcon, ArrowRightIcon, Autocomplete, BoldIcon, BottomSheet, Breadcrumbs, BulletedListIcon, Button, CalendarIcon, CellText, CheckIcon, Checkbox, CheckboxCheckmarkIcon, CheckboxGroup, CheckboxIndeterminateIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, ChevronsLeftIcon, ChevronsRightIcon, ClockIcon, CloseIcon, ColumnConfigModal, Confirmation, DatePicker, DateRangePicker, DateTimeIcon, DateTimePicker, DateTimeUtils, DateUtils, DomUtils, Drawer, FileUpload, FileUploadContainer, FileUtils, Form, FormField, HeaderText, HighlightIcon, HighlightOnIcon, HomeIcon, IconButton, InfiniteTable, InfoIcon, InlineIconButton, InputUpload, Inputs, ItalicIcon, Link, LinkContext, LinkIcon, Loader, Menu, MenuIcon, MenuItem, MenuPopover, Modal, NumberInput, NumberRangeInput, NumberedListIcon, ObjectUtils, PaginatedTable, Pagination, PaginationList, PasswordInput, Pill, PillButton, PointerHorizontalIcon, PointerVerticalIcon, ProgressBar, QueriesUtils, QueryAutocomplete, QuerySelect, RadioGroup, ResponsivePopover, RestUtils, RoutingUtils, Segment, Select, SendIcon, Slider, SplitButton, Stepper, StrikethroughIcon, StringUtils, Table, Tag, TextArea, TextButton, TextColorIcon, TextInput, ThemeContext, TimePicker, Toast, ToastContainer, Toggle, ToggleButton, Tooltip, TooltipEllipsis, Typography, UIConfig, UIOverrides, UIRouter, UnderlinedIcon, VisibilityIcon, VisibilityOffIcon, ZodUtils, accordionChevronDefinition, accordionDefinition, accordionHeadingDefinition, accordionHeadingSubtitleDefinition, accordionHeadingTitleDefinition, accordionIconDefinition, accordionItemDefinition, accordionPanelContentDefinition, accordionPanelDefinition, accordionTriggerDefinition, alertDefinition, breadcrumbChevronDefinition, breadcrumbIconDefinition, breadcrumbItemDefinition, breadcrumbSegmentDefinition, breadcrumbsDefinition, buttonContentDefinition, buttonDefinition, buttonIconSizeDefinition, buttonSizeDefinition, checkboxContentRowDefinition, checkboxContentWrapperDefinition, checkboxDefinition, checkboxGroupLabelDefinition, checkboxIconDefinition, compoundMapper, createKeyInteractionsHandler, datePickerInputContentRowDefinition, dynamicColumns, dynamicInputs, fileUploadDropZoneDefinition, formFieldDefinition, formFieldErrorDefinition, formFieldHeaderDefinition, formFieldHelperDefinition, getKeyInteractionAction, inputBaseDefinition, inputClearClassDefinition, inputContentWrapperDefinition, inputSideDefinition, inputSizeDefinition, inputUploadButtonDefinition, inputUploadDropZoneDefinition, isEqual, labelDefinition, linkDefinition, loaderDefinition, loaderWrapperDefinition, logger, menuDefinition, menuItemDefinition, menuPopoverDefinition, menuPopoverWrapperDefinition, modalContentDefinition, modalMainDefinition, modalOverlayDefinition, ns, pillButtonContentDefinition, pillButtonDefinition, popoverDefinition, progressBarDefinition, progressBarFillDefinition, progressBarTrackDefinition, progressBarTrackWrapperDefinition, progressBarValueDefinition, radioContentRowDefinition, radioContentWrapperDefinition, radioDefinition, resources, segmentDefinition, segmentItemDefinition, selectInputTagsContentWrapperDefinition, selectListBoxItemDefinition, selectPopoverDefinition, statusIconDefinition, statusSeparatorDefinition, stepperDefinition, stepperIconDefinition, stepperItemDefinition, stepperNumberDefinition, stepperSeparatorDefinition, stepperSubtextDefinition, stepperTitleDefinition, tableCellTextDefinition, tableDataDefinition, tableHeadDataDefinition, tableHeadRowDefinition, tableHeaderTextDefinition, tableRowDefinition, tagDefinition, textAreaWrapperDefinition, toastDefinition, statusIconDefinition$1 as toastStatusIconDefinition, statusSeparatorDefinition$1 as toastStatusSeparatorDefinition, toggleDefinition, tooltipDefinition, tooltipPointerHorizontalDefinition, tooltipPointerVerticalDefinition, tooltipTextDefinition, tooltipWrapperTriggerDefinition, typographyDefinition, uiOutlineClass, useAutosave, useBreakpoint, useDebounceCallback, useDeepCompareEffect, useDeepCompareLayoutEffect, useDeepCompareMemo, useFilters, useForm, useFormAutosave, useIntersectionObserver, useKeyInteractions, useLocalStorage, useLongPressRepeat, usePagination, useScrollableListBox, useSorting, useStateAndRef, useTableColumnConfig, useTableNav, useToast, useTranslationMemo };
@@ -38,5 +38,6 @@ export declare namespace DateTimeUtils {
38
38
  export function fromUTCISOToCalendarDate(isoString: string): CalendarDate;
39
39
  export function fromCalendarDateTimeToUTCISO(calendarDateTime: CalendarDateTime): string;
40
40
  export function fromUTCISOToCalendarDateTime(isoString: string, timeZone?: string): CalendarDateTime;
41
+ export function formatTextDateToCalendarDateTime(textDate: string | null, timeZone?: string, locale?: string): CalendarDateTime | null;
41
42
  export {};
42
43
  }
@@ -1,4 +1,3 @@
1
- import { IntlUtils } from "./intl.utils.js";
2
1
  import { CalendarDate, CalendarDateTime, DateFormatter, fromDate, getLocalTimeZone, parseAbsolute } from "@internationalized/date";
3
2
  import { DateTime } from "luxon";
4
3
  //#region src/utils/date-time.utils.ts
@@ -6,42 +5,33 @@ var DateTimeUtils;
6
5
  (function(_DateTimeUtils) {
7
6
  const DATE_SAMPLE_DATE_UTC = new Date(Date.UTC(2e3, 10, 22));
8
7
  const TIME_SAMPLE_DATE_UTC = new Date(Date.UTC(2e3, 10, 22, 6, 45));
9
- const timeFormatters = /* @__PURE__ */ new Map();
10
8
  const getDayMonthFormat = (shouldForceLeadingZeros = false) => shouldForceLeadingZeros ? "2-digit" : "numeric";
11
9
  const getTimeHourFormat = (shouldForceLeadingZeros = false) => shouldForceLeadingZeros ? "2-digit" : "numeric";
12
- const getDatePlaceholderFormatter = (locale, options) => IntlUtils.getDateTimeFormatter(locale, {
10
+ const getDatePlaceholderFormatter = (locale, options) => new Intl.DateTimeFormat(locale, {
13
11
  day: getDayMonthFormat(options?.shouldForceLeadingZeros),
14
12
  month: getDayMonthFormat(options?.shouldForceLeadingZeros),
15
13
  year: "numeric"
16
14
  });
17
- const getTimePlaceholderFormatter = (locale) => IntlUtils.getDateTimeFormatter(locale, {
15
+ const getTimePlaceholderFormatter = (locale) => new Intl.DateTimeFormat(locale, {
18
16
  hour: "2-digit",
19
17
  minute: "2-digit"
20
18
  });
21
19
  const getResolvedLocale = (locale) => {
22
20
  if (locale) return locale;
23
- return IntlUtils.getDateTimeFormatter().resolvedOptions().locale;
21
+ return new Intl.DateTimeFormat().resolvedOptions().locale;
24
22
  };
25
- const getDateFormatter = (locale, options) => IntlUtils.getDateTimeFormatter(getResolvedLocale(locale), {
23
+ const getDateFormatter = (locale, options) => new Intl.DateTimeFormat(getResolvedLocale(locale), {
26
24
  day: getDayMonthFormat(options?.shouldForceLeadingZeros),
27
25
  month: getDayMonthFormat(options?.shouldForceLeadingZeros),
28
26
  year: "numeric",
29
27
  timeZone: "UTC"
30
28
  });
31
- const getTimeFormatter = (locale, options) => {
32
- const resolvedLocale = getResolvedLocale(locale);
33
- const key = `${resolvedLocale}|${options?.shouldForceLeadingZeros ?? false}`;
34
- const cachedFormatter = timeFormatters.get(key);
35
- if (cachedFormatter) return cachedFormatter;
36
- const formatter = new DateFormatter(resolvedLocale, {
37
- hour: getTimeHourFormat(options?.shouldForceLeadingZeros),
38
- minute: "2-digit",
39
- timeZone: "UTC"
40
- });
41
- timeFormatters.set(key, formatter);
42
- return formatter;
43
- };
44
- const getDateTimeFormatter = (locale, options) => IntlUtils.getDateTimeFormatter(getResolvedLocale(locale), {
29
+ const getTimeFormatter = (locale, options) => new DateFormatter(getResolvedLocale(locale), {
30
+ hour: getTimeHourFormat(options?.shouldForceLeadingZeros),
31
+ minute: "2-digit",
32
+ timeZone: "UTC"
33
+ });
34
+ const getDateTimeFormatter = (locale, options) => new Intl.DateTimeFormat(getResolvedLocale(locale), {
45
35
  day: getDayMonthFormat(options?.shouldForceLeadingZeros),
46
36
  month: getDayMonthFormat(options?.shouldForceLeadingZeros),
47
37
  year: "numeric",
@@ -49,8 +39,22 @@ var DateTimeUtils;
49
39
  minute: "2-digit",
50
40
  timeZone: "UTC"
51
41
  });
42
+ const getLocaleDateFormat = (locale) => {
43
+ const sampleDate = new Date(Date.UTC(2e3, 10, 22));
44
+ return new Intl.DateTimeFormat(locale, {
45
+ day: "2-digit",
46
+ month: "2-digit",
47
+ year: "numeric",
48
+ timeZone: "UTC"
49
+ }).formatToParts(sampleDate).map((part) => {
50
+ if (part.type === "day") return "dd";
51
+ if (part.type === "month") return "MM";
52
+ if (part.type === "year") return "yyyy";
53
+ return part.value;
54
+ }).join("");
55
+ };
52
56
  const repeatLocalizedFieldLabel = (type, length, locale) => {
53
- const placeholderChar = IntlUtils.getDisplayNamesFormatter(getResolvedLocale(locale), { type: "dateTimeField" }).of(type)?.trim().charAt(0).toLocaleLowerCase(getResolvedLocale(locale));
57
+ const placeholderChar = new Intl.DisplayNames(getResolvedLocale(locale), { type: "dateTimeField" }).of(type)?.trim().charAt(0).toLocaleLowerCase(getResolvedLocale(locale));
54
58
  if (!placeholderChar) return null;
55
59
  return placeholderChar.repeat(length);
56
60
  };
@@ -187,6 +191,26 @@ var DateTimeUtils;
187
191
  return new CalendarDateTime(zonedDateTime.year, zonedDateTime.month, zonedDateTime.day, zonedDateTime.hour, zonedDateTime.minute, zonedDateTime.second, zonedDateTime.millisecond);
188
192
  }
189
193
  _DateTimeUtils.fromUTCISOToCalendarDateTime = fromUTCISOToCalendarDateTime;
194
+ function formatTextDateToCalendarDateTime(textDate, timeZone, locale) {
195
+ if (!textDate?.includes("hh")) return null;
196
+ const datePart = textDate.split(",").at(0)?.trim();
197
+ if (!datePart) return null;
198
+ const resolvedTimeZone = resolveTimeZone(timeZone);
199
+ const resolvedLocale = locale || Intl.DateTimeFormat().resolvedOptions().locale;
200
+ const localeDateFormat = getLocaleDateFormat(resolvedLocale);
201
+ const parseOptions = {
202
+ zone: resolvedTimeZone,
203
+ locale: resolvedLocale
204
+ };
205
+ let parsedDateTime = DateTime.fromFormat(datePart, localeDateFormat, parseOptions);
206
+ if (!parsedDateTime.isValid && localeDateFormat.includes("yyyy")) {
207
+ const shortYearFormat = localeDateFormat.replace("yyyy", "yy");
208
+ parsedDateTime = DateTime.fromFormat(datePart, shortYearFormat, parseOptions);
209
+ }
210
+ if (!parsedDateTime.isValid) return null;
211
+ return new CalendarDateTime(parsedDateTime.year, parsedDateTime.month, parsedDateTime.day, 0, 0, 0, 0);
212
+ }
213
+ _DateTimeUtils.formatTextDateToCalendarDateTime = formatTextDateToCalendarDateTime;
190
214
  })(DateTimeUtils || (DateTimeUtils = {}));
191
215
  //#endregion
192
216
  export { DateTimeUtils };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@povio/ui",
3
- "version": "3.2.4-rc.4",
3
+ "version": "3.3.0-rc.2",
4
4
  "type": "module",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,2 +0,0 @@
1
- import { RefObject } from 'react';
2
- export declare const useFirefoxDateSegmentSelectionGuard: (containerRef: RefObject<HTMLElement | null>) => void;
@@ -1,33 +0,0 @@
1
- import { c } from "react/compiler-runtime";
2
- import { useLayoutEffect } from "react";
3
- import { isFirefox } from "@react-aria/utils";
4
- //#region src/components/inputs/DateTime/shared/useFirefoxDateSegmentSelectionGuard.ts
5
- var isEditableElement = (element) => element instanceof HTMLElement && (element.matches("input, textarea") || element.isContentEditable);
6
- var useFirefoxDateSegmentSelectionGuard = (containerRef) => {
7
- const $ = c(3);
8
- let t0;
9
- let t1;
10
- if ($[0] !== containerRef) {
11
- t0 = () => {
12
- const container = containerRef.current;
13
- if (!container || !isFirefox()) return;
14
- const onSelectionChange = (event) => {
15
- const activeElement = document.activeElement;
16
- const selection = window.getSelection();
17
- if (isEditableElement(activeElement) && !container.contains(activeElement) && selection?.anchorNode && container.contains(selection.anchorNode)) event.stopImmediatePropagation();
18
- };
19
- document.addEventListener("selectionchange", onSelectionChange, true);
20
- return () => document.removeEventListener("selectionchange", onSelectionChange, true);
21
- };
22
- t1 = [containerRef];
23
- $[0] = containerRef;
24
- $[1] = t0;
25
- $[2] = t1;
26
- } else {
27
- t0 = $[1];
28
- t1 = $[2];
29
- }
30
- useLayoutEffect(t0, t1);
31
- };
32
- //#endregion
33
- export { useFirefoxDateSegmentSelectionGuard };
@@ -1,7 +0,0 @@
1
- type IntlLocale = Intl.LocalesArgument;
2
- export declare namespace IntlUtils {
3
- const getDateTimeFormatter: (locale?: IntlLocale, options?: Intl.DateTimeFormatOptions) => Intl.DateTimeFormat;
4
- const getDisplayNamesFormatter: (locale: IntlLocale, options: Intl.DisplayNamesOptions) => Intl.DisplayNames;
5
- const getNumberFormatter: (locale?: IntlLocale, options?: Intl.NumberFormatOptions) => Intl.NumberFormat;
6
- }
7
- export {};
@@ -1,38 +0,0 @@
1
- //#region src/utils/intl.utils.ts
2
- var formatterCacheKey = (locale, options) => {
3
- const locales = Array.isArray(locale) ? locale.map(String) : locale ? [String(locale)] : [];
4
- const normalizedOptions = Object.entries(options ?? {}).sort(([left], [right]) => left.localeCompare(right));
5
- return JSON.stringify([locales, normalizedOptions]);
6
- };
7
- var IntlUtils;
8
- (function(_IntlUtils) {
9
- const dateTimeFormatters = /* @__PURE__ */ new Map();
10
- const displayNamesFormatters = /* @__PURE__ */ new Map();
11
- const numberFormatters = /* @__PURE__ */ new Map();
12
- _IntlUtils.getDateTimeFormatter = (locale, options) => {
13
- const key = formatterCacheKey(locale, options);
14
- const cachedFormatter = dateTimeFormatters.get(key);
15
- if (cachedFormatter) return cachedFormatter;
16
- const formatter = new Intl.DateTimeFormat(locale, options);
17
- dateTimeFormatters.set(key, formatter);
18
- return formatter;
19
- };
20
- _IntlUtils.getDisplayNamesFormatter = (locale, options) => {
21
- const key = formatterCacheKey(locale, options);
22
- const cachedFormatter = displayNamesFormatters.get(key);
23
- if (cachedFormatter) return cachedFormatter;
24
- const formatter = new Intl.DisplayNames(locale, options);
25
- displayNamesFormatters.set(key, formatter);
26
- return formatter;
27
- };
28
- _IntlUtils.getNumberFormatter = (locale, options) => {
29
- const key = formatterCacheKey(locale, options);
30
- const cachedFormatter = numberFormatters.get(key);
31
- if (cachedFormatter) return cachedFormatter;
32
- const formatter = new Intl.NumberFormat(locale, options);
33
- numberFormatters.set(key, formatter);
34
- return formatter;
35
- };
36
- })(IntlUtils || (IntlUtils = {}));
37
- //#endregion
38
- export { IntlUtils };
@@ -1 +0,0 @@
1
- export {};