d2coreui 23.0.54 → 23.0.55

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 CHANGED
@@ -1,40 +1,47 @@
1
- # Changelog
2
-
3
- ## 23.0.54
4
-
5
- - `DataGrid` / `ExtendedDataGrid`: typed by the row data type. `DataGridProps<TData>` and
6
- `ExtendedDataGridProps<TData>` pass it to the ag-grid `GridOptions` (`rowData`, `getRowId`, events, `gridRef`), and
7
- `DataGrid<TData>` uses it for `gridApi` and `columnTypes`. Without an explicit type argument the type is inferred from
8
- `rowData` and the handlers, so rows must have an `id` of type `number | string`, and handlers typed for another row
9
- type no longer compile. The default type argument is `any`.
10
- - `DataGrid` / `ExtendedDataGrid`: `columnDefs` may contain column groups (`DataGridColGroupDef`). The group is only a
11
- header; its children are adapted like top-level columns (header menu, resizing, cell style, drag & drop in the grid
12
- header) and the columns configuration dialog lists them by their own `group`. Reordering in the dialog does not
13
- respect group boundaries.
14
- - `DataGrid`: the fill-handle highlight uses the displayed column order, the same as the filled range.
15
-
16
- ## 23.0.53
17
-
18
- - `DateRangeInput`: time shift by month or year keeps an interval end that lies at the end of a month at the end of
19
- the target month (30.09. 23:59:59.999 - 1 month = 31.08. 23:59:59.999, not 30.08.). Other values shift as before.
20
- - The public API is documented with JSDoc and the published declaration files (`.d.ts`) keep the comments.
21
- - The package ships `README.md` and `CHANGELOG.md`.
22
-
23
- ## 23.0.52
24
-
25
- - `ExtendedDataGrid`: optional `detailPanel.onVisibleChange(visible)` handler, called when the splitter collapses or
26
- expands the detail panel (collapse arrow or dragging the divider).
27
-
28
- ## 23.0.51
29
-
30
- - pdfmake 0.2.23: `pdfmake/build/vfs_fonts` is a regular CommonJS module, vite applications need no workaround for
31
- the PDF export worker anymore.
32
- - `style/index.less` imports `antd/dist/reset.css` without the webpack-only `~` prefix.
33
- - codemirror 5.65.20.
34
- - Removed the unused `react-codemirror-runmode` dependency.
35
- - The package no longer ships `tsconfig.json` and `tsconfig.build.json`.
36
-
37
- ## 23.0.50
38
-
39
- - Grid export workers are standard `new Worker(new URL(...))` entry points: a webpack application emitting its
40
- chunks into a subdirectory needs `output.publicPath: "auto"`.
1
+ # Changelog
2
+
3
+ ## 23.0.55
4
+
5
+ - `DateTimeInput`, `DateRangeInput`: optional `autoWidth` prop sizes the component to the rendered mask instead of
6
+ filling the parent.
7
+ - `DateRangeInput`: the separator between the two inputs is the antd `SwapRightOutlined` icon with the antd range
8
+ picker spacing instead of the `⟷` character.
9
+
10
+ ## 23.0.54
11
+
12
+ - `DataGrid` / `ExtendedDataGrid`: typed by the row data type. `DataGridProps<TData>` and
13
+ `ExtendedDataGridProps<TData>` pass it to the ag-grid `GridOptions` (`rowData`, `getRowId`, events, `gridRef`), and
14
+ `DataGrid<TData>` uses it for `gridApi` and `columnTypes`. Without an explicit type argument the type is inferred from
15
+ `rowData` and the handlers, so rows must have an `id` of type `number | string`, and handlers typed for another row
16
+ type no longer compile. The default type argument is `any`.
17
+ - `DataGrid` / `ExtendedDataGrid`: `columnDefs` may contain column groups (`DataGridColGroupDef`). The group is only a
18
+ header; its children are adapted like top-level columns (header menu, resizing, cell style, drag & drop in the grid
19
+ header) and the columns configuration dialog lists them by their own `group`. Reordering in the dialog does not
20
+ respect group boundaries.
21
+ - `DataGrid`: the fill-handle highlight uses the displayed column order, the same as the filled range.
22
+
23
+ ## 23.0.53
24
+
25
+ - `DateRangeInput`: time shift by month or year keeps an interval end that lies at the end of a month at the end of
26
+ the target month (30.09. 23:59:59.999 - 1 month = 31.08. 23:59:59.999, not 30.08.). Other values shift as before.
27
+ - The public API is documented with JSDoc and the published declaration files (`.d.ts`) keep the comments.
28
+ - The package ships `README.md` and `CHANGELOG.md`.
29
+
30
+ ## 23.0.52
31
+
32
+ - `ExtendedDataGrid`: optional `detailPanel.onVisibleChange(visible)` handler, called when the splitter collapses or
33
+ expands the detail panel (collapse arrow or dragging the divider).
34
+
35
+ ## 23.0.51
36
+
37
+ - pdfmake 0.2.23: `pdfmake/build/vfs_fonts` is a regular CommonJS module, vite applications need no workaround for
38
+ the PDF export worker anymore.
39
+ - `style/index.less` imports `antd/dist/reset.css` without the webpack-only `~` prefix.
40
+ - codemirror 5.65.20.
41
+ - Removed the unused `react-codemirror-runmode` dependency.
42
+ - The package no longer ships `tsconfig.json` and `tsconfig.build.json`.
43
+
44
+ ## 23.0.50
45
+
46
+ - Grid export workers are standard `new Worker(new URL(...))` entry points: a webpack application emitting its
47
+ chunks into a subdirectory needs `output.publicPath: "auto"`.
package/README.md CHANGED
@@ -1,154 +1,154 @@
1
- # d2coreui
2
-
3
- Reusable React components of the [Ipesoft D2000](https://www.ipesoft.com) HTML5 UI, built on
4
- [antd 5](https://ant.design) and [ag-grid 34](https://www.ag-grid.com): data grid, date/time and duration inputs,
5
- masked inputs, draggable modal dialogs, color pickers and smaller helpers.
6
-
7
- The components are D2000-agnostic UI; they rely on [`d2core`](https://www.npmjs.com/package/d2core) for localization
8
- and date/time handling.
9
-
10
- ## Installation
11
-
12
- ```bash
13
- npm install d2coreui d2core react@18 react-dom@18
14
- ```
15
-
16
- antd, ag-grid, dayjs and the other libraries the components use are regular dependencies of the package. React and
17
- React DOM (18) are provided by the application. The package is published as ES modules with TypeScript declarations.
18
-
19
- ## Setup
20
-
21
- 1. **Locale** - set the language once at startup, before rendering. It also calls `LocaleHolder.setLocale` of
22
- `d2core` and loads the component translations (`sk`, `cs`, `uk`; other languages use the built-in English texts).
23
- 2. **Modal provider** - render `DraggableModalProvider` around the application; `ModalDialog` and the dialogs of other
24
- components throw without it.
25
- 3. **Styles** - components import their own CSS, so the bundler needs a CSS loader. Global styles are optional:
26
- `d2coreui/style/index.less` (less, includes `antd/dist/reset.css`), `d2coreui/style/loading.css`,
27
- `d2coreui/style/splitPane/splitPane.css` and `d2coreui/style/flexLayout/flexLayout.scss` (sass).
28
-
29
- ```tsx
30
- import {createRoot} from "react-dom/client";
31
- import {ComponentsLocaleHolder} from "d2coreui/i18n/componentsLocaleHolder";
32
- import {DraggableModalProvider} from "d2coreui/components/modal/draggableModalProvider";
33
-
34
- await ComponentsLocaleHolder.setLocale("sk", "sk-SK");
35
-
36
- createRoot(document.getElementById("root")!).render(
37
- <DraggableModalProvider>
38
- <App/>
39
- </DraggableModalProvider>
40
- );
41
- ```
42
-
43
- ### Bundler notes
44
-
45
- - The grid export (CSV, TXT, PDF, clipboard) runs in web workers created as `new Worker(new URL(..., import.meta.url))`
46
- - Vite and webpack 5 handle this natively. A webpack application emitting its chunks into a subdirectory needs
47
- `output.publicPath: "auto"`.
48
- - With Vite, add `node_modules/d2coreui/components/grid/export/worker/*.js` to `optimizeDeps.entries`, otherwise the
49
- CommonJS dependencies of the workers (`threads`, `pdfmake`, `lodash`) are not pre-bundled in dev mode.
50
-
51
- ### Host integration
52
-
53
- Some components call into the hosting application (saving grid configuration, reloading the window, saving exported
54
- files). The default `PlatformSpecific` is a browser-only fallback; replace it at startup to customize the behavior:
55
-
56
- ```ts
57
- import PlatformSpecific from "d2coreui/components/platformSpecific";
58
-
59
- class MyPlatformSpecific extends PlatformSpecific {
60
- getCurrentWindowName() {
61
- return "Alarms";
62
- }
63
- }
64
-
65
- PlatformSpecific.INSTANCE = new MyPlatformSpecific();
66
- ```
67
-
68
- ## Usage
69
-
70
- There is no index module - import each component by its path. Every exported component, its props and public
71
- methods are documented with JSDoc, so your editor shows the details on hover.
72
-
73
- ```tsx
74
- import {useState} from "react";
75
- import {Dayjs} from "dayjs";
76
- import DateTimeInput from "d2coreui/components/date/dateTimeInput";
77
- import {ModalDialog, ModalDialogMode} from "d2coreui/components/modal/modalDialog";
78
- import {LocaleHolder} from "d2core/i18n/localeHolder";
79
-
80
- function Example() {
81
- const [value, setValue] = useState<Dayjs | null>(null);
82
- return <DateTimeInput mask={LocaleHolder.getDateTimeFormat(true, true)} value={value} onChange={setValue} allowClear/>;
83
- }
84
-
85
- ModalDialog.confirm({
86
- mode: ModalDialogMode.YES_NO,
87
- title: "Delete the record?",
88
- onOk: () => deleteRecord(),
89
- });
90
- ```
91
-
92
- ## Components
93
-
94
- All paths are relative to `d2coreui/components/`.
95
-
96
- ### Data grid
97
-
98
- | Module | Contents |
99
- |---|---|
100
- | `grid/dataGrid` | `DataGrid` - ag-grid based table with D2000 column types, paging, search, toolbar, export and settings menus, row styling, keyboard navigation. |
101
- | `grid/extendedDataGrid` | `ExtendedDataGrid` - `DataGrid` with filter and detail side panels, keeping the whole grid configuration (columns, paging, row styles) as one object reported through `onChangeConfiguration`; applies pushed record changes. |
102
- | `grid/cell/*CellEditor` | ag-grid cell editors: text, number, big number (64-bit), duration, date, hexadecimal value / octet string, enumeration, status text. |
103
- | `grid/cell/tableDefaultRowStyleRules` | `RowStyleRule`, `GridRowStyle` and the default row style rules. |
104
- | `grid/config/*` | Table configuration UI: `DataGridEditor`, `ColumnTransfer`, `RowStylePicker`, row height helpers. |
105
- | `grid/filter/*` | Column filters and `WildcardQuickFilterEngine` (`*` / `?` quick filter). |
106
- | `grid/export/contextMenu` | `getContextMenu` - row context menu with export (CSV, TXT, PDF, clipboard). |
107
- | `grid/export/progressPopup` | Export progress notification. |
108
- | `grid/header/simpleHeader`, `grid/panel/*`, `grid/detail/*` | Header, pagination, overlay and detail panel components used by the grids. |
109
- | `grid/columnUtils` | `ColumnUtils.mergeColumnsState`. |
110
-
111
- ### Date and time
112
-
113
- | Module | Contents |
114
- |---|---|
115
- | `date/dateTimeInput` | `DateTimeInput` - masked date-time input with a calendar popup, stepping by arrow keys and mouse wheel, DST-aware UTC offset field. |
116
- | `date/dateRangeInput` | `DateRangeInput` - from/to range input with predefined and saved intervals, time shift and an advanced panel. |
117
- | `date/dateRangeInputConfirm` | `DateRangeInputConfirm` - `DateRangeInput` whose changes are applied by a confirm button. |
118
- | `date/durationInput` | `DurationInput` - masked duration input (`d2core/dayjs` durations). |
119
- | `date/savedIntervals`, `date/savedIntervalsDialog` | User-defined intervals: model, storage and management dialog. |
120
-
121
- ### Inputs and pickers
122
-
123
- | Module | Contents |
124
- |---|---|
125
- | `input/maskedInput` | `MaskedInput` - antd input with an editable mask (`input/mask/*` holds the mask engine). |
126
- | `input/autoCompleteInput` | `AutoCompleteInput` - text input with a history dropdown. |
127
- | `input/simpleAutoComplete` | `SimpleAutoComplete` - antd `AutoComplete` with a clearable input and options opened by a dropdown arrow. |
128
- | `input/passwordInput` | `PasswordInput` - password input that reveals the password only while the eye icon is held down. |
129
- | `input/hexaFormattedInput` | `HexaFormattedInput` - input accepting hexadecimal digits only, normalized on blur. |
130
- | `input/textarea/mentionsWithHighlighting` | `MentionsWithHighlighting` - antd `Mentions` textarea with highlighted parts of the text. |
131
- | `input/draftUtils` | `DraftUtils` - helpers for Draft.js / Draftail rich-text content. |
132
- | `picker/enumValuePicker` | `EnumValuePicker` - antd `Select` offering the values of an enum. |
133
- | `color/colorPicker`, `color/colorSwatch`, `color/colorUtils` | Color picker, color swatch and color helpers. |
134
-
135
- ### Dialogs, layout and utilities
136
-
137
- | Module | Contents |
138
- |---|---|
139
- | `modal/modalDialog` | `ModalDialog` - draggable, resizable antd modal with button sets (`ModalDialogMode`) and static `confirm`, `info`, `success`, `error`, `delete`. |
140
- | `modal/draggableModalProvider` | `DraggableModalProvider` - required ancestor of draggable dialogs. |
141
- | `form/NiceFormItem` | `NiceFormItem` - antd `Form.Item` with a floating label. |
142
- | `table/dragSortingTable` | `DragSortingTable` - antd `Table` with rows reordered by drag and drop. |
143
- | `collapse/expandable` | `Expandable` - section with animated collapsible extra content. |
144
- | `scrollTo/scrollTo` | `ScrollTo`, `ScrollToItem` - keyboard-navigable list with type-ahead search. |
145
- | `text/textFit` | `TextFit` - fits text to its container by adjusting the font size. |
146
- | `codemirror/SyntaxHighlighter` | `SyntaxHighlighter` - read-only syntax highlighting by CodeMirror `runMode` (no editor instance). |
147
- | `icons/*` | `DropdownArrow`, `UndoIcon`. |
148
- | `style/withCss` | `WithCss` - lets class components use antd-style `createStyles` hooks. |
149
- | `clipboard/clipboardUtils`, `keyboard/keyboardUtils` | Clipboard and keyboard helpers. |
150
- | `platformSpecific` | `PlatformSpecific` - host integration hooks (see above). |
151
-
152
- ## Changelog
153
-
154
- See [CHANGELOG.md](CHANGELOG.md).
1
+ # d2coreui
2
+
3
+ Reusable React components of the [Ipesoft D2000](https://www.ipesoft.com) HTML5 UI, built on
4
+ [antd 5](https://ant.design) and [ag-grid 34](https://www.ag-grid.com): data grid, date/time and duration inputs,
5
+ masked inputs, draggable modal dialogs, color pickers and smaller helpers.
6
+
7
+ The components are D2000-agnostic UI; they rely on [`d2core`](https://www.npmjs.com/package/d2core) for localization
8
+ and date/time handling.
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ npm install d2coreui d2core react@18 react-dom@18
14
+ ```
15
+
16
+ antd, ag-grid, dayjs and the other libraries the components use are regular dependencies of the package. React and
17
+ React DOM (18) are provided by the application. The package is published as ES modules with TypeScript declarations.
18
+
19
+ ## Setup
20
+
21
+ 1. **Locale** - set the language once at startup, before rendering. It also calls `LocaleHolder.setLocale` of
22
+ `d2core` and loads the component translations (`sk`, `cs`, `uk`; other languages use the built-in English texts).
23
+ 2. **Modal provider** - render `DraggableModalProvider` around the application; `ModalDialog` and the dialogs of other
24
+ components throw without it.
25
+ 3. **Styles** - components import their own CSS, so the bundler needs a CSS loader. Global styles are optional:
26
+ `d2coreui/style/index.less` (less, includes `antd/dist/reset.css`), `d2coreui/style/loading.css`,
27
+ `d2coreui/style/splitPane/splitPane.css` and `d2coreui/style/flexLayout/flexLayout.scss` (sass).
28
+
29
+ ```tsx
30
+ import {createRoot} from "react-dom/client";
31
+ import {ComponentsLocaleHolder} from "d2coreui/i18n/componentsLocaleHolder";
32
+ import {DraggableModalProvider} from "d2coreui/components/modal/draggableModalProvider";
33
+
34
+ await ComponentsLocaleHolder.setLocale("sk", "sk-SK");
35
+
36
+ createRoot(document.getElementById("root")!).render(
37
+ <DraggableModalProvider>
38
+ <App/>
39
+ </DraggableModalProvider>
40
+ );
41
+ ```
42
+
43
+ ### Bundler notes
44
+
45
+ - The grid export (CSV, TXT, PDF, clipboard) runs in web workers created as `new Worker(new URL(..., import.meta.url))`
46
+ - Vite and webpack 5 handle this natively. A webpack application emitting its chunks into a subdirectory needs
47
+ `output.publicPath: "auto"`.
48
+ - With Vite, add `node_modules/d2coreui/components/grid/export/worker/*.js` to `optimizeDeps.entries`, otherwise the
49
+ CommonJS dependencies of the workers (`threads`, `pdfmake`, `lodash`) are not pre-bundled in dev mode.
50
+
51
+ ### Host integration
52
+
53
+ Some components call into the hosting application (saving grid configuration, reloading the window, saving exported
54
+ files). The default `PlatformSpecific` is a browser-only fallback; replace it at startup to customize the behavior:
55
+
56
+ ```ts
57
+ import PlatformSpecific from "d2coreui/components/platformSpecific";
58
+
59
+ class MyPlatformSpecific extends PlatformSpecific {
60
+ getCurrentWindowName() {
61
+ return "Alarms";
62
+ }
63
+ }
64
+
65
+ PlatformSpecific.INSTANCE = new MyPlatformSpecific();
66
+ ```
67
+
68
+ ## Usage
69
+
70
+ There is no index module - import each component by its path. Every exported component, its props and public
71
+ methods are documented with JSDoc, so your editor shows the details on hover.
72
+
73
+ ```tsx
74
+ import {useState} from "react";
75
+ import {Dayjs} from "dayjs";
76
+ import DateTimeInput from "d2coreui/components/date/dateTimeInput";
77
+ import {ModalDialog, ModalDialogMode} from "d2coreui/components/modal/modalDialog";
78
+ import {LocaleHolder} from "d2core/i18n/localeHolder";
79
+
80
+ function Example() {
81
+ const [value, setValue] = useState<Dayjs | null>(null);
82
+ return <DateTimeInput mask={LocaleHolder.getDateTimeFormat(true, true)} value={value} onChange={setValue} allowClear/>;
83
+ }
84
+
85
+ ModalDialog.confirm({
86
+ mode: ModalDialogMode.YES_NO,
87
+ title: "Delete the record?",
88
+ onOk: () => deleteRecord(),
89
+ });
90
+ ```
91
+
92
+ ## Components
93
+
94
+ All paths are relative to `d2coreui/components/`.
95
+
96
+ ### Data grid
97
+
98
+ | Module | Contents |
99
+ |---|---|
100
+ | `grid/dataGrid` | `DataGrid` - ag-grid based table with D2000 column types, paging, search, toolbar, export and settings menus, row styling, keyboard navigation. |
101
+ | `grid/extendedDataGrid` | `ExtendedDataGrid` - `DataGrid` with filter and detail side panels, keeping the whole grid configuration (columns, paging, row styles) as one object reported through `onChangeConfiguration`; applies pushed record changes. |
102
+ | `grid/cell/*CellEditor` | ag-grid cell editors: text, number, big number (64-bit), duration, date, hexadecimal value / octet string, enumeration, status text. |
103
+ | `grid/cell/tableDefaultRowStyleRules` | `RowStyleRule`, `GridRowStyle` and the default row style rules. |
104
+ | `grid/config/*` | Table configuration UI: `DataGridEditor`, `ColumnTransfer`, `RowStylePicker`, row height helpers. |
105
+ | `grid/filter/*` | Column filters and `WildcardQuickFilterEngine` (`*` / `?` quick filter). |
106
+ | `grid/export/contextMenu` | `getContextMenu` - row context menu with export (CSV, TXT, PDF, clipboard). |
107
+ | `grid/export/progressPopup` | Export progress notification. |
108
+ | `grid/header/simpleHeader`, `grid/panel/*`, `grid/detail/*` | Header, pagination, overlay and detail panel components used by the grids. |
109
+ | `grid/columnUtils` | `ColumnUtils.mergeColumnsState`. |
110
+
111
+ ### Date and time
112
+
113
+ | Module | Contents |
114
+ |---|---|
115
+ | `date/dateTimeInput` | `DateTimeInput` - masked date-time input with a calendar popup, stepping by arrow keys and mouse wheel, DST-aware UTC offset field. |
116
+ | `date/dateRangeInput` | `DateRangeInput` - from/to range input with predefined and saved intervals, time shift and an advanced panel. |
117
+ | `date/dateRangeInputConfirm` | `DateRangeInputConfirm` - `DateRangeInput` whose changes are applied by a confirm button. |
118
+ | `date/durationInput` | `DurationInput` - masked duration input (`d2core/dayjs` durations). |
119
+ | `date/savedIntervals`, `date/savedIntervalsDialog` | User-defined intervals: model, storage and management dialog. |
120
+
121
+ ### Inputs and pickers
122
+
123
+ | Module | Contents |
124
+ |---|---|
125
+ | `input/maskedInput` | `MaskedInput` - antd input with an editable mask (`input/mask/*` holds the mask engine). |
126
+ | `input/autoCompleteInput` | `AutoCompleteInput` - text input with a history dropdown. |
127
+ | `input/simpleAutoComplete` | `SimpleAutoComplete` - antd `AutoComplete` with a clearable input and options opened by a dropdown arrow. |
128
+ | `input/passwordInput` | `PasswordInput` - password input that reveals the password only while the eye icon is held down. |
129
+ | `input/hexaFormattedInput` | `HexaFormattedInput` - input accepting hexadecimal digits only, normalized on blur. |
130
+ | `input/textarea/mentionsWithHighlighting` | `MentionsWithHighlighting` - antd `Mentions` textarea with highlighted parts of the text. |
131
+ | `input/draftUtils` | `DraftUtils` - helpers for Draft.js / Draftail rich-text content. |
132
+ | `picker/enumValuePicker` | `EnumValuePicker` - antd `Select` offering the values of an enum. |
133
+ | `color/colorPicker`, `color/colorSwatch`, `color/colorUtils` | Color picker, color swatch and color helpers. |
134
+
135
+ ### Dialogs, layout and utilities
136
+
137
+ | Module | Contents |
138
+ |---|---|
139
+ | `modal/modalDialog` | `ModalDialog` - draggable, resizable antd modal with button sets (`ModalDialogMode`) and static `confirm`, `info`, `success`, `error`, `delete`. |
140
+ | `modal/draggableModalProvider` | `DraggableModalProvider` - required ancestor of draggable dialogs. |
141
+ | `form/NiceFormItem` | `NiceFormItem` - antd `Form.Item` with a floating label. |
142
+ | `table/dragSortingTable` | `DragSortingTable` - antd `Table` with rows reordered by drag and drop. |
143
+ | `collapse/expandable` | `Expandable` - section with animated collapsible extra content. |
144
+ | `scrollTo/scrollTo` | `ScrollTo`, `ScrollToItem` - keyboard-navigable list with type-ahead search. |
145
+ | `text/textFit` | `TextFit` - fits text to its container by adjusting the font size. |
146
+ | `codemirror/SyntaxHighlighter` | `SyntaxHighlighter` - read-only syntax highlighting by CodeMirror `runMode` (no editor instance). |
147
+ | `icons/*` | `DropdownArrow`, `UndoIcon`. |
148
+ | `style/withCss` | `WithCss` - lets class components use antd-style `createStyles` hooks. |
149
+ | `clipboard/clipboardUtils`, `keyboard/keyboardUtils` | Clipboard and keyboard helpers. |
150
+ | `platformSpecific` | `PlatformSpecific` - host integration hooks (see above). |
151
+
152
+ ## Changelog
153
+
154
+ See [CHANGELOG.md](CHANGELOG.md).
@@ -55,6 +55,11 @@ export interface DateRangeInputProps extends Omit<HTMLAttributes<HTMLDivElement>
55
55
  * column; {@link DateRangeInputProps.defaultMode} is ignored.
56
56
  */
57
57
  compact?: boolean;
58
+ /**
59
+ * Sizes the component to the rendered {@link DateRangeInputProps.mask} instead of filling the parent: both
60
+ * inputs are as wide as the formatted value and the box shrinks around them. A `width` in `style` still wins.
61
+ */
62
+ autoWidth?: boolean;
58
63
  /** Renders only the two inputs - no calendar icon and no popup. */
59
64
  hidePopup?: boolean;
60
65
  /** Renders only the popup content inline, without the inputs. */
@@ -11,7 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import React from "react";
13
13
  import dayjs from "dayjs";
14
- import { CalendarOutlined, FieldTimeOutlined } from "@ant-design/icons";
14
+ import { CalendarOutlined, FieldTimeOutlined, SwapRightOutlined } from "@ant-design/icons";
15
15
  import { Divider, Dropdown, Spin, Switch, Tag, Tooltip } from "antd";
16
16
  import DateTimeInput from "./dateTimeInput";
17
17
  import memoizeOne from "memoize-one";
@@ -316,8 +316,16 @@ const useStyles = createStyles(({ token, css }, props) => {
316
316
  }
317
317
  ` : ""}
318
318
  `,
319
+ // mirrors antd `.ant-picker-range-separator` + `.ant-picker-separator`
319
320
  rangeSeparator: css `
321
+ display: inline-flex;
320
322
  align-self: center;
323
+ align-items: center;
324
+ justify-content: center;
325
+ box-sizing: content-box;
326
+ width: 1em;
327
+ height: ${token.fontSizeLG}px;
328
+ padding: 0 ${token.paddingXS}px;
321
329
  color: ${token.colorTextQuaternary};
322
330
  /* antd fixes the separator at fontSizeLG for every size */
323
331
  font-size: ${token.fontSizeLG}px;
@@ -583,7 +591,7 @@ export default class DateRangeInput extends React.Component {
583
591
  (_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, fromValue, toValue);
584
592
  }
585
593
  renderSimplePart() {
586
- const _a = this.props, { fromValue, toValue, onChange, style, allowClear, renderAsCalendar, hidePopup, align, defaultMode, onModeChange, confirmButtonsRenderer, onPopupVisibleChange, showCustomIntervals, intervalStorage } = _a, props = __rest(_a, ["fromValue", "toValue", "onChange", "style", "allowClear", "renderAsCalendar", "hidePopup", "align", "defaultMode", "onModeChange", "confirmButtonsRenderer", "onPopupVisibleChange", "showCustomIntervals", "intervalStorage"]);
594
+ const _a = this.props, { fromValue, toValue, onChange, style, allowClear, renderAsCalendar, hidePopup, align, defaultMode, onModeChange, confirmButtonsRenderer, onPopupVisibleChange, showCustomIntervals, intervalStorage, autoWidth } = _a, props = __rest(_a, ["fromValue", "toValue", "onChange", "style", "allowClear", "renderAsCalendar", "hidePopup", "align", "defaultMode", "onModeChange", "confirmButtonsRenderer", "onPopupVisibleChange", "showCustomIntervals", "intervalStorage", "autoWidth"]);
587
595
  const markedDateInterval = this.props.fromValue && this.props.toValue ? [this.props.fromValue, this.props.toValue] : undefined;
588
596
  return (React.createElement(WithCss, { useStyles: usePopupStyles }, (context) => React.createElement("div", null,
589
597
  React.createElement("div", { style: { display: "flex" } },
@@ -666,7 +674,7 @@ export default class DateRangeInput extends React.Component {
666
674
  })))));
667
675
  }
668
676
  renderAdvancedPart() {
669
- const _a = this.props, { fromValue, toValue, onChange, style, allowClear, renderAsCalendar, hidePopup, align, defaultMode, compact, onModeChange, confirmButtonsRenderer, onPopupVisibleChange, showCustomIntervals, intervalStorage } = _a, props = __rest(_a, ["fromValue", "toValue", "onChange", "style", "allowClear", "renderAsCalendar", "hidePopup", "align", "defaultMode", "compact", "onModeChange", "confirmButtonsRenderer", "onPopupVisibleChange", "showCustomIntervals", "intervalStorage"]);
677
+ const _a = this.props, { fromValue, toValue, onChange, style, allowClear, renderAsCalendar, hidePopup, align, defaultMode, compact, onModeChange, confirmButtonsRenderer, onPopupVisibleChange, showCustomIntervals, intervalStorage, autoWidth } = _a, props = __rest(_a, ["fromValue", "toValue", "onChange", "style", "allowClear", "renderAsCalendar", "hidePopup", "align", "defaultMode", "compact", "onModeChange", "confirmButtonsRenderer", "onPopupVisibleChange", "showCustomIntervals", "intervalStorage", "autoWidth"]);
670
678
  return (React.createElement(WithCss, { useStyles: usePopupStyles }, (context) => React.createElement("div", null,
671
679
  React.createElement("div", { style: { display: "flex", gap: 8 } },
672
680
  React.createElement(DateTimeInput, Object.assign({}, props, { style: { flexGrow: 1 }, value: fromValue, onChange: (value) => {
@@ -737,20 +745,21 @@ export default class DateRangeInput extends React.Component {
737
745
  }
738
746
  /** Renders the two inputs with their icons and the saved-intervals dialog, without the popup. */
739
747
  renderInput() {
740
- const _a = this.props, { className, fromValue, toValue, onChange, style, allowClear, renderAsCalendar, hidePopup, align, disabled, defaultMode, onModeChange, confirmButtonsRenderer, onPopupVisibleChange, showCustomIntervals, intervalStorage, size, status, variant } = _a, props = __rest(_a, ["className", "fromValue", "toValue", "onChange", "style", "allowClear", "renderAsCalendar", "hidePopup", "align", "disabled", "defaultMode", "onModeChange", "confirmButtonsRenderer", "onPopupVisibleChange", "showCustomIntervals", "intervalStorage", "size", "status", "variant"]);
741
- return (React.createElement("div", { style: Object.assign(Object.assign({}, style), { padding: 0, position: "relative" }), className: className, onFocus: this.props.onFocus, onBlur: this.props.onBlur },
748
+ const _a = this.props, { className, fromValue, toValue, onChange, style, allowClear, renderAsCalendar, hidePopup, align, disabled, defaultMode, onModeChange, confirmButtonsRenderer, onPopupVisibleChange, showCustomIntervals, intervalStorage, size, status, variant, autoWidth } = _a, props = __rest(_a, ["className", "fromValue", "toValue", "onChange", "style", "allowClear", "renderAsCalendar", "hidePopup", "align", "disabled", "defaultMode", "onModeChange", "confirmButtonsRenderer", "onPopupVisibleChange", "showCustomIntervals", "intervalStorage", "size", "status", "variant", "autoWidth"]);
749
+ return (React.createElement("div", { style: Object.assign(Object.assign(Object.assign({}, (autoWidth ? { width: "fit-content" } : {})), style), { padding: 0, position: "relative" }), className: className, onFocus: this.props.onFocus, onBlur: this.props.onBlur },
742
750
  React.createElement(WithCss, { useStyles: useStyles, props: { size, variant } }, (context) => React.createElement("div", { style: { display: "flex", justifyContent: "space-between" }, className: context.cx(context.styles.baseLayout, {
743
751
  disabled: !!disabled,
744
752
  focused: !disabled && this.state.popupVisible,
745
753
  "status-error": status === "error",
746
754
  "status-warning": status === "warning",
747
755
  }) },
748
- React.createElement(DateTimeInput, Object.assign({ value: fromValue }, props, { disabled: disabled, inputDisabled: this.state.popupVisible, allowClear: allowClear, variant: "borderless", hidePopup: true, size: size, style: { width: "auto" }, inputStyle: { paddingRight: 2 }, onChange: (value) => {
756
+ React.createElement(DateTimeInput, Object.assign({ value: fromValue }, props, { disabled: disabled, inputDisabled: this.state.popupVisible, allowClear: allowClear, variant: "borderless", hidePopup: true, size: size, style: { width: "auto" }, autoWidth: autoWidth, inputStyle: { paddingRight: 0 }, onChange: (value) => {
749
757
  var _a, _b;
750
758
  (_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, value, this.props.toValue);
751
759
  } })),
752
- React.createElement("span", { className: context.styles.rangeSeparator }, "\u27F7"),
753
- React.createElement(DateTimeInput, Object.assign({ value: toValue }, props, { disabled: disabled, inputDisabled: this.state.popupVisible, allowClear: allowClear, variant: "borderless", hidePopup: true, size: size, style: { width: "auto" }, inputStyle: { paddingLeft: 2 }, onChange: (value) => {
760
+ React.createElement("span", { "aria-label": "to", className: context.styles.rangeSeparator },
761
+ React.createElement(SwapRightOutlined, null)),
762
+ React.createElement(DateTimeInput, Object.assign({ value: toValue }, props, { disabled: disabled, inputDisabled: this.state.popupVisible, allowClear: allowClear, variant: "borderless", hidePopup: true, size: size, style: { width: "auto" }, autoWidth: autoWidth, inputStyle: { paddingLeft: 0 }, onChange: (value) => {
754
763
  var _a, _b;
755
764
  (_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, this.props.fromValue, value);
756
765
  } })),