@economic/taco 17.0.0-alpha-rules.0 → 17.0.1-EC-00234-table3-bundle.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.
Files changed (67) hide show
  1. package/dist/charts/components/types.d.ts +1 -1
  2. package/dist/charts/components/useChartData.cjs +2 -1
  3. package/dist/charts/components/useChartData.js +2 -1
  4. package/dist/components/Datepicker/useDatepicker.cjs +3 -3
  5. package/dist/components/Datepicker/useDatepicker.js +3 -3
  6. package/dist/components/Provider/Localization.cjs +18 -2
  7. package/dist/components/Provider/Localization.d.ts +20 -7
  8. package/dist/components/Provider/Localization.js +18 -2
  9. package/dist/components/Table3/components/Columns/Cell/Editing/NumberInput.cjs +39 -0
  10. package/dist/components/Table3/components/Columns/Cell/Editing/NumberInput.d.ts +10 -0
  11. package/dist/components/Table3/components/Columns/Cell/Editing/NumberInput.js +39 -0
  12. package/dist/components/Table3/components/Columns/Cell/EditingControlCell.cjs +17 -18
  13. package/dist/components/Table3/components/Columns/Cell/EditingControlCell.js +18 -19
  14. package/dist/index.cjs +4 -0
  15. package/dist/index.js +5 -1
  16. package/dist/primitives/Table/Core/components/Body/Body.cjs +1 -1
  17. package/dist/primitives/Table/Core/components/Body/Body.js +1 -1
  18. package/dist/primitives/Table/Core/components/Footer/Summary.cjs +6 -4
  19. package/dist/primitives/Table/Core/components/Footer/Summary.js +6 -4
  20. package/dist/primitives/Table/Core/components/Header/Header.cjs +7 -3
  21. package/dist/primitives/Table/Core/components/Header/Header.d.ts +4 -2
  22. package/dist/primitives/Table/Core/components/Header/Header.js +8 -4
  23. package/dist/primitives/Table/Core/components/Header/components/Resizer.cjs +11 -3
  24. package/dist/primitives/Table/Core/components/Header/components/Resizer.d.ts +6 -4
  25. package/dist/primitives/Table/Core/components/Header/components/Resizer.js +11 -3
  26. package/dist/primitives/Table/Core/components/Header/util.d.ts +3 -2
  27. package/dist/primitives/Table/Core/components/Toolbar/components/Filters/ManageFiltersPopover.cjs +7 -4
  28. package/dist/primitives/Table/Core/components/Toolbar/components/Filters/ManageFiltersPopover.js +7 -4
  29. package/dist/primitives/Table/Core/features/useTableRenderer.cjs +10 -0
  30. package/dist/primitives/Table/Core/features/useTableRenderer.js +10 -0
  31. package/dist/primitives/Table/Core/features/useTableStyleGrid.cjs +7 -2
  32. package/dist/primitives/Table/Core/features/useTableStyleGrid.js +8 -3
  33. package/dist/primitives/Table/types.d.ts +5 -2
  34. package/dist/primitives/Table/useTableManager/features/useTableColumnSizing.cjs +32 -0
  35. package/dist/primitives/Table/useTableManager/features/useTableColumnSizing.d.ts +5 -0
  36. package/dist/primitives/Table/useTableManager/features/useTableColumnSizing.js +32 -0
  37. package/dist/primitives/Table/useTableManager/listeners/useTableFontSizeListener.cjs +3 -0
  38. package/dist/primitives/Table/useTableManager/listeners/useTableFontSizeListener.js +3 -0
  39. package/dist/primitives/Table/useTableManager/useTableManager.cjs +3 -0
  40. package/dist/primitives/Table/useTableManager/useTableManager.d.ts +4 -2
  41. package/dist/primitives/Table/useTableManager/useTableManager.js +3 -0
  42. package/dist/primitives/Table/useTableManager/util/columns.cjs +8 -0
  43. package/dist/primitives/Table/useTableManager/util/columns.d.ts +5 -2
  44. package/dist/primitives/Table/useTableManager/util/columns.js +8 -0
  45. package/dist/primitives/Table/useTableManager/util/dataTypes.cjs +29 -10
  46. package/dist/primitives/Table/useTableManager/util/dataTypes.d.ts +5 -2
  47. package/dist/primitives/Table/useTableManager/util/dataTypes.js +31 -12
  48. package/dist/primitives/Table/useTableManager/util/filtering.cjs +1 -1
  49. package/dist/primitives/Table/useTableManager/util/filtering.js +2 -2
  50. package/dist/primitives/Table/useTableManager/util/rows.cjs +10 -2
  51. package/dist/primitives/Table/useTableManager/util/rows.d.ts +1 -4
  52. package/dist/primitives/Table/useTableManager/util/rows.js +10 -2
  53. package/dist/primitives/Table/useTableManager/util/search.cjs +1 -1
  54. package/dist/primitives/Table/useTableManager/util/search.js +1 -1
  55. package/dist/primitives/Table/useTableManager/util/settings.cjs +1 -1
  56. package/dist/primitives/Table/useTableManager/util/settings.d.ts +4 -3
  57. package/dist/primitives/Table/useTableManager/util/settings.js +1 -1
  58. package/dist/primitives/Table/useTableManager/util/setup.cjs +1 -0
  59. package/dist/primitives/Table/useTableManager/util/setup.d.ts +4 -4
  60. package/dist/primitives/Table/useTableManager/util/setup.js +1 -0
  61. package/dist/utils/dataTypes.cjs +84 -34
  62. package/dist/utils/dataTypes.d.ts +28 -4
  63. package/dist/utils/dataTypes.js +72 -22
  64. package/dist/utils/date.cjs +47 -4
  65. package/dist/utils/date.d.ts +5 -0
  66. package/dist/utils/date.js +47 -4
  67. package/package.json +5 -5
@@ -57,7 +57,7 @@ export type CartesianChartProps<TData extends object> = {
57
57
  } & ChartProps;
58
58
  export type PolarChartProps = {
59
59
  /** Format the displayed value
60
- * @default Intl.NumberFormat
60
+ * @default the localization's number formatting, with two decimals
61
61
  */
62
62
  formatter?: ChartValueFormatter;
63
63
  /** Text representation of data, used in tooltips and totals */
@@ -3,11 +3,12 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const React = require("react");
4
4
  const color = require("../utils/color.cjs");
5
5
  const Localization = require("../../components/Provider/Localization.cjs");
6
+ const dataTypes = require("../../utils/dataTypes.cjs");
6
7
  function useChart(children, options) {
7
8
  const [activeIndex, setActiveIndex] = React.useState();
8
9
  const [hiddenItems, toggleItem] = useChartDataHiddenState();
9
10
  const localization = Localization.useLocalization();
10
- const defaultFormatter = (value) => new Intl.NumberFormat(localization.locale, { minimumFractionDigits: 2 }).format(value);
11
+ const defaultFormatter = (value) => dataTypes.formatNumber(value, localization, { minimumFractionDigits: 2 });
11
12
  const globalFormatter = options?.formatter ?? defaultFormatter;
12
13
  const { items, shapes } = React.useMemo(() => {
13
14
  const items2 = React.Children.toArray(children).filter((child) => React.isValidElement(child)).map((child) => {
@@ -1,11 +1,12 @@
1
1
  import React__default from "react";
2
2
  import { getThemeColor } from "../utils/color.js";
3
3
  import { useLocalization } from "../../components/Provider/Localization.js";
4
+ import { formatNumber } from "../../utils/dataTypes.js";
4
5
  function useChart(children, options) {
5
6
  const [activeIndex, setActiveIndex] = React__default.useState();
6
7
  const [hiddenItems, toggleItem] = useChartDataHiddenState();
7
8
  const localization = useLocalization();
8
- const defaultFormatter = (value) => new Intl.NumberFormat(localization.locale, { minimumFractionDigits: 2 }).format(value);
9
+ const defaultFormatter = (value) => formatNumber(value, localization, { minimumFractionDigits: 2 });
9
10
  const globalFormatter = options?.formatter ?? defaultFormatter;
10
11
  const { items, shapes } = React__default.useMemo(() => {
11
12
  const items2 = React__default.Children.toArray(children).filter((child) => React__default.isValidElement(child)).map((child) => {
@@ -33,7 +33,7 @@ const useDatepicker = ({ defaultValue: _, calendar, onBlur, onChange, value, ...
33
33
  if (formattedValue !== internalValue) {
34
34
  setInternalValue(formattedValue ?? "");
35
35
  }
36
- }, [value]);
36
+ }, [value, formatting.date]);
37
37
  const isDisabledDay = React__namespace.useMemo(() => {
38
38
  if (originalValueAsDate && calendar?.disabledDays) {
39
39
  return reactDayPicker.isMatch(originalValueAsDate, calendar?.disabledDays);
@@ -44,11 +44,11 @@ const useDatepicker = ({ defaultValue: _, calendar, onBlur, onChange, value, ...
44
44
  event.persist();
45
45
  const valueAsDate = date.parseFromCustomString(
46
46
  event.target.value,
47
- "dd.mm.yy",
47
+ formatting.date,
48
48
  originalValueAsDate?.getMonth(),
49
49
  originalValueAsDate?.getFullYear()
50
50
  );
51
- const formattedValue = valueAsDate ? date.format(valueAsDate) || "" : "";
51
+ const formattedValue = valueAsDate ? date.format(valueAsDate, formatting.date) || "" : "";
52
52
  event.target.value = formattedValue;
53
53
  const isEmpty = !event.target.value.trim();
54
54
  if (onChange) {
@@ -14,7 +14,7 @@ const useDatepicker = ({ defaultValue: _, calendar, onBlur, onChange, value, ...
14
14
  if (formattedValue !== internalValue) {
15
15
  setInternalValue(formattedValue ?? "");
16
16
  }
17
- }, [value]);
17
+ }, [value, formatting.date]);
18
18
  const isDisabledDay = React.useMemo(() => {
19
19
  if (originalValueAsDate && calendar?.disabledDays) {
20
20
  return isMatch(originalValueAsDate, calendar?.disabledDays);
@@ -25,11 +25,11 @@ const useDatepicker = ({ defaultValue: _, calendar, onBlur, onChange, value, ...
25
25
  event.persist();
26
26
  const valueAsDate = parseFromCustomString(
27
27
  event.target.value,
28
- "dd.mm.yy",
28
+ formatting.date,
29
29
  originalValueAsDate?.getMonth(),
30
30
  originalValueAsDate?.getFullYear()
31
31
  );
32
- const formattedValue = valueAsDate ? format(valueAsDate) || "" : "";
32
+ const formattedValue = valueAsDate ? format(valueAsDate, formatting.date) || "" : "";
33
33
  event.target.value = formattedValue;
34
34
  const isEmpty = !event.target.value.trim();
35
35
  if (onChange) {
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const React = require("react");
4
+ const date = require("../../utils/date.cjs");
4
5
  function _interopNamespaceDefault(e) {
5
6
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
6
7
  if (e) {
@@ -348,12 +349,27 @@ const defaultLocalizationContext = {
348
349
  locale: "da-DK",
349
350
  texts: defaultLocalisationTexts,
350
351
  formatting: {
351
- date: "dd.mm.yy"
352
+ date: date.MASK_DATE,
353
+ time: date.MASK_TIME
352
354
  }
353
355
  };
354
356
  const LocalizationContext = React__namespace.createContext(defaultLocalizationContext);
357
+ const fillInFormattingDefaults = (localization) => ({
358
+ ...localization,
359
+ formatting: {
360
+ ...localization.formatting,
361
+ date: localization.formatting.date || date.MASK_DATE,
362
+ time: localization.formatting.time || date.MASK_TIME,
363
+ numberDecimalSeparator: localization.formatting.numberDecimalSeparator || void 0,
364
+ numberGroupSeparator: localization.formatting.numberGroupSeparator || void 0
365
+ }
366
+ });
355
367
  const LocalizationProvider = ({ localization, children }) => {
356
- return /* @__PURE__ */ React__namespace.createElement(LocalizationContext.Provider, { value: localization ?? defaultLocalizationContext }, children);
368
+ const value = React__namespace.useMemo(
369
+ () => localization ? fillInFormattingDefaults(localization) : defaultLocalizationContext,
370
+ [localization]
371
+ );
372
+ return /* @__PURE__ */ React__namespace.createElement(LocalizationContext.Provider, { value }, children);
357
373
  };
358
374
  const useLocalization = () => React__namespace.useContext(LocalizationContext);
359
375
  exports.LocalizationContext = LocalizationContext;
@@ -61,19 +61,32 @@ export type LocalizationTexts = {
61
61
  /** Localized texts and aria-labels for [Drawer](component:drawer) component */
62
62
  drawer: DrawerTexts;
63
63
  };
64
+ export type LocalizationFormatting = {
65
+ /**
66
+ * Date mask built from the `dd`, `mm`, `yy` and `yyyy` tokens.
67
+ * @default 'dd.mm.yy'
68
+ */
69
+ date: string;
70
+ /**
71
+ * Time mask built from the `HH`, `mm` and `ss` tokens.
72
+ * @default 'HH:mm'
73
+ */
74
+ time?: string;
75
+ /** Decimal separator, derived from `locale` when omitted or empty */
76
+ numberDecimalSeparator?: string;
77
+ /** Thousands separator, derived from `locale` when omitted or empty */
78
+ numberGroupSeparator?: string;
79
+ };
64
80
  export type Localization = {
65
81
  /**
66
- * Provide the language code used in application.
67
- * Default value is `en-GB`
82
+ * BCP-47 tag used only as a formatting fallback for what `formatting` cannot express, such as currency placement.
83
+ * Default value is `da-DK`
68
84
  */
69
85
  locale: string;
70
86
  /** Provide the texts and aria-labels for components used within the provider */
71
87
  texts: LocalizationTexts;
72
- /** Provide the formatting */
73
- formatting: {
74
- /** Default value is `dd.mm.yy` */
75
- date: string;
76
- };
88
+ /** Explicit formatting, takes precedence over `locale` */
89
+ formatting: LocalizationFormatting;
77
90
  };
78
91
  export declare const defaultLocalisationTexts: {
79
92
  banner: {
@@ -1,4 +1,5 @@
1
1
  import * as React from "react";
2
+ import { MASK_TIME, MASK_DATE } from "../../utils/date.js";
2
3
  const defaultLocalisationTexts = {
3
4
  banner: {
4
5
  close: "Close"
@@ -329,12 +330,27 @@ const defaultLocalizationContext = {
329
330
  locale: "da-DK",
330
331
  texts: defaultLocalisationTexts,
331
332
  formatting: {
332
- date: "dd.mm.yy"
333
+ date: MASK_DATE,
334
+ time: MASK_TIME
333
335
  }
334
336
  };
335
337
  const LocalizationContext = React.createContext(defaultLocalizationContext);
338
+ const fillInFormattingDefaults = (localization) => ({
339
+ ...localization,
340
+ formatting: {
341
+ ...localization.formatting,
342
+ date: localization.formatting.date || MASK_DATE,
343
+ time: localization.formatting.time || MASK_TIME,
344
+ numberDecimalSeparator: localization.formatting.numberDecimalSeparator || void 0,
345
+ numberGroupSeparator: localization.formatting.numberGroupSeparator || void 0
346
+ }
347
+ });
336
348
  const LocalizationProvider = ({ localization, children }) => {
337
- return /* @__PURE__ */ React.createElement(LocalizationContext.Provider, { value: localization ?? defaultLocalizationContext }, children);
349
+ const value = React.useMemo(
350
+ () => localization ? fillInFormattingDefaults(localization) : defaultLocalizationContext,
351
+ [localization]
352
+ );
353
+ return /* @__PURE__ */ React.createElement(LocalizationContext.Provider, { value }, children);
338
354
  };
339
355
  const useLocalization = () => React.useContext(LocalizationContext);
340
356
  export {
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const React = require("react");
4
+ const dataTypes = require("../../../../../../primitives/Table/useTableManager/util/dataTypes.cjs");
5
+ const dataTypes$1 = require("../../../../../../utils/dataTypes.cjs");
6
+ const Input = require("../../../../../Input/Input.cjs");
7
+ const NumberInput = React.forwardRef(function NumberInput2(props, ref) {
8
+ const { dataType, localization, onBlur, onChange, value, ...attributes } = props;
9
+ const { getEditableValue, parse } = dataTypes.getDataTypeProperties(dataType);
10
+ const getText = (nextValue) => getEditableValue?.(nextValue, localization) ?? "";
11
+ const [text, setText] = React.useState(() => getText(value));
12
+ const [reportedValue, setReportedValue] = React.useState(value);
13
+ if (!Object.is(value, reportedValue)) {
14
+ setReportedValue(value);
15
+ setText(getText(value));
16
+ }
17
+ const report = (nextValue) => {
18
+ setReportedValue(nextValue);
19
+ onChange(nextValue);
20
+ };
21
+ const handleChange = (event) => {
22
+ const nextText = dataTypes$1.stripNonNumericCharacters(event.target.value, localization);
23
+ setText(nextText);
24
+ if (!nextText.trim().length) {
25
+ report(null);
26
+ return;
27
+ }
28
+ const parsedValue = parse?.(nextText, localization);
29
+ if (typeof parsedValue === "number") {
30
+ report(parsedValue);
31
+ }
32
+ };
33
+ const handleBlur = (event) => {
34
+ setText(getText(value));
35
+ onBlur?.(event);
36
+ };
37
+ return /* @__PURE__ */ React.createElement(Input.Input, { ...attributes, inputMode: "decimal", onBlur: handleBlur, onChange: handleChange, ref, value: text });
38
+ });
39
+ exports.NumberInput = NumberInput;
@@ -0,0 +1,10 @@
1
+ import { default as React } from 'react';
2
+ import { InputProps, Localization } from '../../../../..';
3
+ import { TableColumnNumericDataType } from '../../../../../../primitives/Table/types';
4
+ /** Edits the text as typed: reprinting the parsed value would drop a trailing `,` and print a dot for the decimal separator */
5
+ export declare const NumberInput: React.ForwardRefExoticComponent<Omit<InputProps, "onChange" | "value"> & {
6
+ dataType: TableColumnNumericDataType;
7
+ localization: Localization;
8
+ onChange: (value: number | null) => void;
9
+ value: unknown;
10
+ } & React.RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,39 @@
1
+ import React__default from "react";
2
+ import { getDataTypeProperties } from "../../../../../../primitives/Table/useTableManager/util/dataTypes.js";
3
+ import { stripNonNumericCharacters } from "../../../../../../utils/dataTypes.js";
4
+ import { Input } from "../../../../../Input/Input.js";
5
+ const NumberInput = React__default.forwardRef(function NumberInput2(props, ref) {
6
+ const { dataType, localization, onBlur, onChange, value, ...attributes } = props;
7
+ const { getEditableValue, parse } = getDataTypeProperties(dataType);
8
+ const getText = (nextValue) => getEditableValue?.(nextValue, localization) ?? "";
9
+ const [text, setText] = React__default.useState(() => getText(value));
10
+ const [reportedValue, setReportedValue] = React__default.useState(value);
11
+ if (!Object.is(value, reportedValue)) {
12
+ setReportedValue(value);
13
+ setText(getText(value));
14
+ }
15
+ const report = (nextValue) => {
16
+ setReportedValue(nextValue);
17
+ onChange(nextValue);
18
+ };
19
+ const handleChange = (event) => {
20
+ const nextText = stripNonNumericCharacters(event.target.value, localization);
21
+ setText(nextText);
22
+ if (!nextText.trim().length) {
23
+ report(null);
24
+ return;
25
+ }
26
+ const parsedValue = parse?.(nextText, localization);
27
+ if (typeof parsedValue === "number") {
28
+ report(parsedValue);
29
+ }
30
+ };
31
+ const handleBlur = (event) => {
32
+ setText(getText(value));
33
+ onBlur?.(event);
34
+ };
35
+ return /* @__PURE__ */ React__default.createElement(Input, { ...attributes, inputMode: "decimal", onBlur: handleBlur, onChange: handleChange, ref, value: text });
36
+ });
37
+ export {
38
+ NumberInput
39
+ };
@@ -10,6 +10,7 @@ const rows = require("../../../../../primitives/Table/useTableManager/util/rows.
10
10
  const date = require("../../../../../utils/date.cjs");
11
11
  const dom = require("../../../../../utils/dom.cjs");
12
12
  const keyboard = require("../../../../../utils/keyboard.cjs");
13
+ const NumberInput = require("./Editing/NumberInput.cjs");
13
14
  const RowMoveIndicator = require("./Editing/RowMoveIndicator.cjs");
14
15
  const TextareaWithAutosizing = require("./Editing/TextareaWithAutosizing.cjs");
15
16
  const util = require("./util.cjs");
@@ -23,7 +24,7 @@ function EditingControlCell(props) {
23
24
  const { cell, cellRef, isHighlighted, index } = props;
24
25
  const { rowIndex } = React.useContext(RowContext.RowContext);
25
26
  const { table } = cell.getContext();
26
- const locale = Localization.useLocalization();
27
+ const localization = Localization.useLocalization();
27
28
  const tableMeta = rows.getTableMeta(table);
28
29
  const columnMeta = cell.column.columnDef.meta;
29
30
  const isActiveRow = tableMeta.rowActive.rowActiveIndex === rowIndex;
@@ -86,7 +87,7 @@ function EditingControlCell(props) {
86
87
  invalid: !!error,
87
88
  isDetailedMode: tableMeta.editing.isDetailedMode,
88
89
  isTruncated: !!columnMeta?.enableTruncate,
89
- locale: locale.locale,
90
+ localization,
90
91
  onBlur: handleBlur,
91
92
  onChange: handleChange,
92
93
  onExitDetailedMode: handleExitDetailedMode,
@@ -116,7 +117,7 @@ const MemoedEditingCell = React.memo(function MemoedEditingCell2(props) {
116
117
  invalid,
117
118
  isDetailedMode,
118
119
  isTruncated,
119
- locale,
120
+ localization,
120
121
  onBlur,
121
122
  onChange,
122
123
  onExitDetailedMode,
@@ -256,7 +257,7 @@ const MemoedEditingCell = React.memo(function MemoedEditingCell2(props) {
256
257
  }
257
258
  const handleChange = (event) => {
258
259
  const dataTypeProps = dataTypes.getDataTypeProperties(dataType);
259
- onChange(dataTypeProps.parse?.(event.target.value, locale) ?? event.target.value);
260
+ onChange(dataTypeProps.parse?.(event.target.value, localization) ?? event.target.value);
260
261
  };
261
262
  if (type === "textarea") {
262
263
  return /* @__PURE__ */ React.createElement(
@@ -275,19 +276,17 @@ const MemoedEditingCell = React.memo(function MemoedEditingCell2(props) {
275
276
  }
276
277
  );
277
278
  }
278
- return /* @__PURE__ */ React.createElement(
279
- Input.Input,
280
- {
281
- ...commonProps,
282
- invalid,
283
- onChange: handleChange,
284
- onFocus: handleFocus,
285
- onKeyDown: handleInputKeyDown,
286
- onPaste: handlePaste,
287
- ref: controlRef,
288
- type: dataType === "number" ? "number" : void 0,
289
- value: dataType === "number" ? value : String(value ?? "")
290
- }
291
- );
279
+ const inputProps = {
280
+ ...commonProps,
281
+ invalid,
282
+ onFocus: handleFocus,
283
+ onKeyDown: handleInputKeyDown,
284
+ onPaste: handlePaste,
285
+ ref: controlRef
286
+ };
287
+ if (dataTypes.isNumericDataType(dataType)) {
288
+ return /* @__PURE__ */ React.createElement(NumberInput.NumberInput, { ...inputProps, dataType, localization, onChange, value });
289
+ }
290
+ return /* @__PURE__ */ React.createElement(Input.Input, { ...inputProps, onChange: handleChange, value: String(value ?? "") });
292
291
  });
293
292
  exports.EditingControlCell = EditingControlCell;
@@ -3,11 +3,12 @@ import React__default from "react";
3
3
  import { useLazyEffect } from "../../../../../hooks/useLazyEffect.js";
4
4
  import { getCellAttributes } from "../../../../../primitives/Table/Core/components/Columns/Cell/util.js";
5
5
  import { RowContext } from "../../../../../primitives/Table/Core/components/Row/RowContext.js";
6
- import { getDataTypeProperties } from "../../../../../primitives/Table/useTableManager/util/dataTypes.js";
6
+ import { isNumericDataType, getDataTypeProperties } from "../../../../../primitives/Table/useTableManager/util/dataTypes.js";
7
7
  import { getTableMeta } from "../../../../../primitives/Table/useTableManager/util/rows.js";
8
8
  import { parse, isWeakEqual } from "../../../../../utils/date.js";
9
9
  import { isElementInsideOrTriggeredFromContainer } from "../../../../../utils/dom.js";
10
10
  import { isPressingMetaKey } from "../../../../../utils/keyboard.js";
11
+ import { NumberInput } from "./Editing/NumberInput.js";
11
12
  import { RowMoveIndicator } from "./Editing/RowMoveIndicator.js";
12
13
  import { TextareaWithAutosizing } from "./Editing/TextareaWithAutosizing.js";
13
14
  import { useEditingCellAutofocus } from "./util.js";
@@ -21,7 +22,7 @@ function EditingControlCell(props) {
21
22
  const { cell, cellRef, isHighlighted, index } = props;
22
23
  const { rowIndex } = React__default.useContext(RowContext);
23
24
  const { table } = cell.getContext();
24
- const locale = useLocalization();
25
+ const localization = useLocalization();
25
26
  const tableMeta = getTableMeta(table);
26
27
  const columnMeta = cell.column.columnDef.meta;
27
28
  const isActiveRow = tableMeta.rowActive.rowActiveIndex === rowIndex;
@@ -84,7 +85,7 @@ function EditingControlCell(props) {
84
85
  invalid: !!error,
85
86
  isDetailedMode: tableMeta.editing.isDetailedMode,
86
87
  isTruncated: !!columnMeta?.enableTruncate,
87
- locale: locale.locale,
88
+ localization,
88
89
  onBlur: handleBlur,
89
90
  onChange: handleChange,
90
91
  onExitDetailedMode: handleExitDetailedMode,
@@ -114,7 +115,7 @@ const MemoedEditingCell = React__default.memo(function MemoedEditingCell2(props)
114
115
  invalid,
115
116
  isDetailedMode,
116
117
  isTruncated,
117
- locale,
118
+ localization,
118
119
  onBlur,
119
120
  onChange,
120
121
  onExitDetailedMode,
@@ -254,7 +255,7 @@ const MemoedEditingCell = React__default.memo(function MemoedEditingCell2(props)
254
255
  }
255
256
  const handleChange = (event) => {
256
257
  const dataTypeProps = getDataTypeProperties(dataType);
257
- onChange(dataTypeProps.parse?.(event.target.value, locale) ?? event.target.value);
258
+ onChange(dataTypeProps.parse?.(event.target.value, localization) ?? event.target.value);
258
259
  };
259
260
  if (type === "textarea") {
260
261
  return /* @__PURE__ */ React__default.createElement(
@@ -273,20 +274,18 @@ const MemoedEditingCell = React__default.memo(function MemoedEditingCell2(props)
273
274
  }
274
275
  );
275
276
  }
276
- return /* @__PURE__ */ React__default.createElement(
277
- Input,
278
- {
279
- ...commonProps,
280
- invalid,
281
- onChange: handleChange,
282
- onFocus: handleFocus,
283
- onKeyDown: handleInputKeyDown,
284
- onPaste: handlePaste,
285
- ref: controlRef,
286
- type: dataType === "number" ? "number" : void 0,
287
- value: dataType === "number" ? value : String(value ?? "")
288
- }
289
- );
277
+ const inputProps = {
278
+ ...commonProps,
279
+ invalid,
280
+ onFocus: handleFocus,
281
+ onKeyDown: handleInputKeyDown,
282
+ onPaste: handlePaste,
283
+ ref: controlRef
284
+ };
285
+ if (isNumericDataType(dataType)) {
286
+ return /* @__PURE__ */ React__default.createElement(NumberInput, { ...inputProps, dataType, localization, onChange, value });
287
+ }
288
+ return /* @__PURE__ */ React__default.createElement(Input, { ...inputProps, onChange: handleChange, value: String(value ?? "") });
290
289
  });
291
290
  export {
292
291
  EditingControlCell
package/dist/index.cjs CHANGED
@@ -97,7 +97,11 @@ exports.TableFilterComparator = types$1.TableFilterComparator;
97
97
  exports.DEFAULT_PAGE_SIZE = useTableDataLoader.DEFAULT_PAGE_SIZE;
98
98
  exports.useTableDataLoader = useTableDataLoader.useTableDataLoader;
99
99
  exports.useTableDataLoader2 = useTableDataLoader2.useTableDataLoader2;
100
+ exports.DATETIME_SEPARATOR = date.DATETIME_SEPARATOR;
101
+ exports.MASK_DATE = date.MASK_DATE;
102
+ exports.MASK_TIME = date.MASK_TIME;
100
103
  exports.format = date.format;
104
+ exports.formatTime = date.formatTime;
101
105
  exports.isWeakEqual = date.isWeakEqual;
102
106
  exports.parse = date.parse;
103
107
  exports.parseFromCustomString = date.parseFromCustomString;
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import * as Collection from "./primitives/Collection/Collection.js";
5
5
  import { TableFilterComparator } from "./primitives/Table/types.js";
6
6
  import { DEFAULT_PAGE_SIZE, useTableDataLoader } from "./primitives/Table/useTableDataLoader.js";
7
7
  import { useTableDataLoader2 } from "./primitives/Table/useTableDataLoader2.js";
8
- import { format, isWeakEqual, parse, parseFromCustomString, parseFromISOString } from "./utils/date.js";
8
+ import { DATETIME_SEPARATOR, MASK_DATE, MASK_TIME, format, formatTime, isWeakEqual, parse, parseFromCustomString, parseFromISOString } from "./utils/date.js";
9
9
  import { createShortcutKeyDownHandler, isMacOs, isPressingMetaKey, shouldTriggerShortcut } from "./utils/keyboard.js";
10
10
  import { mergeRefs } from "./utils/mergeRefs.js";
11
11
  import { useBoundaryOverflowDetection } from "./hooks/useBoundaryOverflowDetection.js";
@@ -108,6 +108,7 @@ export {
108
108
  Checkbox,
109
109
  Collection as CollectionPrimitive,
110
110
  Combobox,
111
+ DATETIME_SEPARATOR,
111
112
  DEFAULT_PAGE_SIZE,
112
113
  Datepicker,
113
114
  Dialog,
@@ -134,6 +135,8 @@ export {
134
135
  List,
135
136
  LocalizationContext,
136
137
  LocalizationProvider,
138
+ MASK_DATE,
139
+ MASK_TIME,
137
140
  Menu,
138
141
  Navigation2,
139
142
  OverflowGroup,
@@ -172,6 +175,7 @@ export {
172
175
  defaultLocalizationContext,
173
176
  fixedForwardRef,
174
177
  format,
178
+ formatTime,
175
179
  getNavigationLinkClasses,
176
180
  getNextIndexFromKey,
177
181
  icons,
@@ -68,7 +68,7 @@ function Body(props) {
68
68
  };
69
69
  const handleMouseMove = React.useCallback(
70
70
  (event) => {
71
- if (!(event.target instanceof HTMLElement)) {
71
+ if (!(event.target instanceof Element)) {
72
72
  return;
73
73
  }
74
74
  const currentTable = ref.current?.closest("table");
@@ -66,7 +66,7 @@ function Body(props) {
66
66
  };
67
67
  const handleMouseMove = React__default.useCallback(
68
68
  (event) => {
69
- if (!(event.target instanceof HTMLElement)) {
69
+ if (!(event.target instanceof Element)) {
70
70
  return;
71
71
  }
72
72
  const currentTable = ref.current?.closest("table");
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const React = require("react");
4
+ const dataTypes = require("../../../../../utils/dataTypes.cjs");
4
5
  const rows = require("../../../useTableManager/util/rows.cjs");
5
6
  const Localization = require("../../../../../components/Provider/Localization.cjs");
6
7
  function Summary(props) {
7
8
  const { table } = props;
8
- const { locale, texts } = Localization.useLocalization();
9
+ const localization = Localization.useLocalization();
10
+ const { texts } = localization;
9
11
  const tableMeta = rows.getTableMeta(table);
10
12
  const length = tableMeta.length;
11
13
  const currentLength = table.getRowModel().rows.length;
@@ -14,14 +16,14 @@ function Summary(props) {
14
16
  const rowsSelectedLength = Object.keys(table.getState().rowSelection).length;
15
17
  if (rowsSelectedLength > 0) {
16
18
  label = texts.table.footer.summary.selected;
17
- count = /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("strong", null, new Intl.NumberFormat(locale).format(rowsSelectedLength)), " ", texts.table.footer.summary.count, " ", /* @__PURE__ */ React.createElement("strong", null, new Intl.NumberFormat(locale).format(length)));
19
+ count = /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("strong", null, dataTypes.formatNumber(rowsSelectedLength, localization)), " ", texts.table.footer.summary.count, " ", /* @__PURE__ */ React.createElement("strong", null, dataTypes.formatNumber(length, localization)));
18
20
  } else if (!tableMeta.server.isEnabled && (table.getState().columnFilters?.length || // filtered data
19
21
  !!table.getState().globalFilter && table.options.enableGlobalFilter)) {
20
22
  label = texts.table.footer.summary.records;
21
- count = /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("strong", { "data-taco": "table-footer-current-count" }, new Intl.NumberFormat(locale).format(currentLength)), " ", texts.table.footer.summary.count, " ", /* @__PURE__ */ React.createElement("strong", { "data-taco": "table-footer-total-count" }, new Intl.NumberFormat(locale).format(length)));
23
+ count = /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("strong", { "data-taco": "table-footer-current-count" }, dataTypes.formatNumber(currentLength, localization)), " ", texts.table.footer.summary.count, " ", /* @__PURE__ */ React.createElement("strong", { "data-taco": "table-footer-total-count" }, dataTypes.formatNumber(length, localization)));
22
24
  } else {
23
25
  label = texts.table.footer.summary.records;
24
- count = /* @__PURE__ */ React.createElement("strong", { "data-taco": "table-footer-total-count" }, new Intl.NumberFormat(locale).format(length));
26
+ count = /* @__PURE__ */ React.createElement("strong", { "data-taco": "table-footer-total-count" }, dataTypes.formatNumber(length, localization));
25
27
  }
26
28
  return /* @__PURE__ */ React.createElement(
27
29
  "div",
@@ -1,9 +1,11 @@
1
1
  import React__default from "react";
2
+ import { formatNumber } from "../../../../../utils/dataTypes.js";
2
3
  import { getTableMeta } from "../../../useTableManager/util/rows.js";
3
4
  import { useLocalization } from "../../../../../components/Provider/Localization.js";
4
5
  function Summary(props) {
5
6
  const { table } = props;
6
- const { locale, texts } = useLocalization();
7
+ const localization = useLocalization();
8
+ const { texts } = localization;
7
9
  const tableMeta = getTableMeta(table);
8
10
  const length = tableMeta.length;
9
11
  const currentLength = table.getRowModel().rows.length;
@@ -12,14 +14,14 @@ function Summary(props) {
12
14
  const rowsSelectedLength = Object.keys(table.getState().rowSelection).length;
13
15
  if (rowsSelectedLength > 0) {
14
16
  label = texts.table.footer.summary.selected;
15
- count = /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("strong", null, new Intl.NumberFormat(locale).format(rowsSelectedLength)), " ", texts.table.footer.summary.count, " ", /* @__PURE__ */ React__default.createElement("strong", null, new Intl.NumberFormat(locale).format(length)));
17
+ count = /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("strong", null, formatNumber(rowsSelectedLength, localization)), " ", texts.table.footer.summary.count, " ", /* @__PURE__ */ React__default.createElement("strong", null, formatNumber(length, localization)));
16
18
  } else if (!tableMeta.server.isEnabled && (table.getState().columnFilters?.length || // filtered data
17
19
  !!table.getState().globalFilter && table.options.enableGlobalFilter)) {
18
20
  label = texts.table.footer.summary.records;
19
- count = /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("strong", { "data-taco": "table-footer-current-count" }, new Intl.NumberFormat(locale).format(currentLength)), " ", texts.table.footer.summary.count, " ", /* @__PURE__ */ React__default.createElement("strong", { "data-taco": "table-footer-total-count" }, new Intl.NumberFormat(locale).format(length)));
21
+ count = /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("strong", { "data-taco": "table-footer-current-count" }, formatNumber(currentLength, localization)), " ", texts.table.footer.summary.count, " ", /* @__PURE__ */ React__default.createElement("strong", { "data-taco": "table-footer-total-count" }, formatNumber(length, localization)));
20
22
  } else {
21
23
  label = texts.table.footer.summary.records;
22
- count = /* @__PURE__ */ React__default.createElement("strong", { "data-taco": "table-footer-total-count" }, new Intl.NumberFormat(locale).format(length));
24
+ count = /* @__PURE__ */ React__default.createElement("strong", { "data-taco": "table-footer-total-count" }, formatNumber(length, localization));
23
25
  }
24
26
  return /* @__PURE__ */ React__default.createElement(
25
27
  "div",
@@ -63,9 +63,10 @@ function Header(props) {
63
63
  parentId: header.column.parent?.id,
64
64
  scrollToIndex,
65
65
  setRowActiveIndex: tableMeta.rowActive.setRowActiveIndex,
66
- setColumnSizing: table.setColumnSizing,
66
+ setColumnResized: tableMeta.columnSizing.setColumnResized,
67
+ setColumnSizing: columns.getColumnSizingSetter(table),
67
68
  tooltip: columnMeta?.tooltip,
68
- width: table.getState().columnSizing[header.id]
69
+ width: columns.getColumnWidth(table.getState().columnSizing, header.id)
69
70
  };
70
71
  if (header.isPlaceholder) {
71
72
  const nextHeader = header.headerGroup.headers[header.index + 1];
@@ -142,7 +143,7 @@ const MemoedHeader = React.memo(function MemoedHeader2(props) {
142
143
  isGroup,
143
144
  isPinned,
144
145
  isPlaceholder,
145
- isResizing,
146
+ isResizing = false,
146
147
  offset,
147
148
  onFilter: handleFilter,
148
149
  onGoto: handleGoto,
@@ -154,6 +155,7 @@ const MemoedHeader = React.memo(function MemoedHeader2(props) {
154
155
  resetSize: handleResetSize,
155
156
  scrollToIndex,
156
157
  setRowActiveIndex,
158
+ setColumnResized,
157
159
  setColumnSizing,
158
160
  sortDirection,
159
161
  tooltip,
@@ -213,11 +215,13 @@ const MemoedHeader = React.memo(function MemoedHeader2(props) {
213
215
  canResize ? /* @__PURE__ */ React.createElement(
214
216
  Resizer.Resizer,
215
217
  {
218
+ defaultWidth,
216
219
  headerRef: ref,
217
220
  id,
218
221
  isResizing,
219
222
  onResize: handleResize,
220
223
  onResetSize: handleResetSize,
224
+ setColumnResized,
221
225
  setColumnSizing,
222
226
  width
223
227
  }