d2coreui 23.0.57 → 23.0.59

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 (37) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +154 -154
  3. package/components/date/dateRangeInputAdvancedPanel.js +14 -14
  4. package/components/date/dateRangeInputAdvancedPanel.js.map +1 -1
  5. package/components/date/dateRangeInputConfirm.js +5 -5
  6. package/components/date/dateRangeInputConfirm.js.map +1 -1
  7. package/components/date/dateTimeInput.js +61 -61
  8. package/components/date/dateTimeInput.js.map +1 -1
  9. package/components/grid/config/columnTransfer.js +61 -43
  10. package/components/grid/config/columnTransfer.js.map +1 -1
  11. package/components/grid/dataGrid.d.ts +24 -1
  12. package/components/grid/dataGrid.js +106 -45
  13. package/components/grid/dataGrid.js.map +1 -1
  14. package/components/grid/export/worker/pdfExport.js.map +1 -1
  15. package/components/grid/extendedDataGrid.js +1 -0
  16. package/components/grid/extendedDataGrid.js.map +1 -1
  17. package/components/grid/header/simpleHeader.d.ts +1 -1
  18. package/components/grid/header/simpleHeader.js +3 -2
  19. package/components/grid/header/simpleHeader.js.map +1 -1
  20. package/components/grid/panel/dataGridPagination.d.ts +4 -1
  21. package/components/grid/panel/dataGridPagination.js +13 -8
  22. package/components/grid/panel/dataGridPagination.js.map +1 -1
  23. package/components/input/autoCompleteInput.d.ts +3 -0
  24. package/components/input/autoCompleteInput.js +18 -3
  25. package/components/input/autoCompleteInput.js.map +1 -1
  26. package/components/modal/impl/draggableModal.d.ts +1 -1
  27. package/components/modal/impl/draggableModal.js.map +1 -1
  28. package/components/modal/impl/draggableModalInner.js +1 -1
  29. package/components/modal/impl/draggableModalInner.js.map +1 -1
  30. package/components/modal/impl/draggableModalStyles.js +126 -126
  31. package/components/modal/impl/draggableModalStyles.js.map +1 -1
  32. package/components/modal/impl/resizeHandle.js.map +1 -1
  33. package/components/modal/modalDialog.d.ts +2 -2
  34. package/components/modal/modalDialog.js +2 -2
  35. package/components/modal/modalDialog.js.map +1 -1
  36. package/package.json +1 -1
  37. package/style/index.less +240 -240
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## 23.0.59
4
+
5
+ - `DataGrid` / `ExtendedDataGrid`: `toolbar.compact` for a narrow (mobile) screen - the export and table settings
6
+ buttons move into a popover opened by one button, the pager has only the previous, "page / pages" and next buttons,
7
+ and a pager that still does not fit moves to a line of its own under the toolbar.
8
+ - `DataGrid`: the toolbar line is aligned to the top, so the pager and the record range stay next to the toolbar
9
+ buttons when `toolbar.renderToolbar` adds content under them; `toolbar.extraContent` lower than a button is now at the
10
+ top of the line instead of in its middle.
11
+
12
+ ## 23.0.58
13
+
14
+ - `ModalDialog`: the maximize / restore button is shown only with `maximizable`, which is now `false` by default -
15
+ pass `maximizable` to keep the button in a dialog.
16
+ - `DataGrid` / `ExtendedDataGrid`: a column with ag-grid's `lockVisible` (also from `defaultColDef` or a column type)
17
+ can no longer be hidden or shown from the column menu ("Hide Column" is disabled), the columns configuration dialog
18
+ or the column tree of the table settings (the column is disabled there and left out when its whole group is moved
19
+ or checked). ag-grid applies `lockVisible` only to its own UI, which the grid does not use.
20
+ - `ColumnTransfer`: a column group in the tree (the `SIMPLE` layout and the hidden columns of the `FULL` layout) is
21
+ shown as fully checked only when all its columns are checked, including locked ones; otherwise it is half checked.
22
+ A click on a group checks its unlocked columns, or unchecks them when all of them are checked.
23
+
3
24
  ## 23.0.57
4
25
 
5
26
  - `DateTimeInput` / `DateRangeInput`: `autoWidth` measures the right width with a theme `fontFamily` that is not a
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).
@@ -6,25 +6,25 @@ import { createStyles } from "antd-style";
6
6
  import WithCss from "../style/withCss";
7
7
  const useStyles = createStyles(({ token, css }) => {
8
8
  return {
9
- panel: css `
10
- color: ${token.colorTextSecondary};
9
+ panel: css `
10
+ color: ${token.colorTextSecondary};
11
11
  `,
12
12
  // the popup grows with a long date-time mask - the columns share the extra width, never below their content
13
- columns: css `
14
- display: flex;
15
- align-items: flex-start;
16
- gap: 24px;
17
- margin-bottom: 8px;
13
+ columns: css `
14
+ display: flex;
15
+ align-items: flex-start;
16
+ gap: 24px;
17
+ margin-bottom: 8px;
18
18
  `,
19
- column: css `
20
- flex: 1 1 0;
21
- min-width: max-content;
19
+ column: css `
20
+ flex: 1 1 0;
21
+ min-width: max-content;
22
22
  `,
23
- timeShiftIcon: css `
24
- color: ${token.colorTextSecondary};
23
+ timeShiftIcon: css `
24
+ color: ${token.colorTextSecondary};
25
25
  `,
26
- timeShiftIconChecked: css `
27
- color: ${token.colorPrimary};
26
+ timeShiftIconChecked: css `
27
+ color: ${token.colorPrimary};
28
28
  `,
29
29
  };
30
30
  });
@@ -1 +1 @@
1
- {"version":3,"file":"dateRangeInputAdvancedPanel.js","sourceRoot":"","sources":["../../../../components/date/dateRangeInputAdvancedPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAC,MAAM,MAAM,CAAC;AAC5C,OAAO,IAAI,MAAM,kBAAkB,CAAC;AAGpC,OAAO,IAAI,MAAM,sCAAsC,CAAC;AACxD,OAAO,EAAC,YAAY,EAAC,MAAM,YAAY,CAAC;AACxC,OAAO,OAAO,MAAM,kBAAkB,CAAC;AAEvC,MAAM,SAAS,GAAG,YAAY,CAAC,CAAC,EAAC,KAAK,EAAE,GAAG,EAAC,EAAE,EAAE;IAC5C,OAAO;QACH,KAAK,EAAE,GAAG,CAAA;qBACG,KAAK,CAAC,kBAAkB;SACpC;QACD,4GAA4G;QAC5G,OAAO,EAAE,GAAG,CAAA;;;;;SAKX;QACD,MAAM,EAAE,GAAG,CAAA;;;SAGV;QACD,aAAa,EAAE,GAAG,CAAA;qBACL,KAAK,CAAC,kBAAkB;SACpC;QACD,oBAAoB,EAAE,GAAG,CAAA;qBACZ,KAAK,CAAC,YAAY;SAC9B;KACJ,CAAA;AACL,CAAC,CAAC,CAAC;AAEH,kFAAkF;AAClF,MAAM,CAAN,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC1B,8CAA8C;IAC9C,qEAAS,CAAA;IACT,+CAA+C;IAC/C,qEAAS,CAAA;AACb,CAAC,EALW,kBAAkB,KAAlB,kBAAkB,QAK7B;AAwCD;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,2BAA4B,SAAQ,KAAK,CAAC,SAA6E;IACxI,YAAY,KAAiD;QACzD,KAAK,CAAC,K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O,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAC;wBACxE,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC;wBACzC,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC;wBACxC,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,MAAM,CAAC,CACtC,CACF;gBACP,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO;oBAChB,oBAAC,KAAK,IAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,EAAC,UAAU;wBAChD,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;wBAC7C,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC;wBAC9E,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;wBAC7E,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CACxE,CAEV,CACJ,CACK,CACd,CAAC;IACN,CAAC;CAEJ","sourcesContent":["import React from \"react\";\nimport {Button, Divider, Space} from \"antd\";\nimport i18n from \"d2core/i18n/i18n\";\nimport {OpUnitType} from \"dayjs\";\nimport {DurationUnitType} from \"d2core/dayjs/duration\";\nimport Icon from \"@ant-design/icons/es/components/Icon\";\nimport {createStyles} from \"antd-style\";\nimport WithCss from \"../style/withCss\";\n\nconst useStyles = createStyles(({token, css}) => {\n return {\n panel: css`\n color: ${token.colorTextSecondary};\n `,\n // the popup grows with a long date-time mask - the columns share the extra width, never below their content\n columns: css`\n display: flex;\n align-items: flex-start;\n gap: 24px;\n margin-bottom: 8px;\n `,\n column: css`\n flex: 1 1 0;\n min-width: max-content;\n `,\n timeShiftIcon: css`\n color: ${token.colorTextSecondary};\n `,\n timeShiftIconChecked: css`\n color: ${token.colorPrimary};\n `,\n }\n});\n\n/** Direction of a time shift requested by {@link DateRangeInputAdvancedPanel}. */\nexport enum TimeShiftDirection {\n /** Shift forward in time (the \"+\" button). */\n INCREMENT,\n /** Shift backward in time (the \"-\" button). */\n DECREMENT,\n}\n\n/** Props of {@link DateRangeInputAdvancedPanel}. */\ninterface DateRangeInputAdvancedPanelProps {\n /** Hides the \"Interval End\" column. */\n compact?: boolean\n\n /**\n * Called by the \"Interval Begin\" buttons: `\"15minutes\"` (Now), `\"day\"` (Today), `\"week\"`, `\"month\"`, `\"year\"`.\n * `DateRangeInput` sets the begin to the start of that unit containing now (the current quarter-hour for `\"15minutes\"`).\n */\n onBeginIntervalChange(unit: OpUnitType | \"15minutes\"): void\n\n /**\n * Called by the duration buttons (`\"hour\"`, `\"day\"`, `\"week\"`, `\"month\"`, `\"year\"`).\n * `DateRangeInput` sets the end to begin + 1 unit - 1 ms.\n */\n onIntervalDurationChange(unitOfTime: DurationUnitType): void\n\n /**\n * Called by the \"-\"/\"+\" buttons beside a duration button.\n * @param shiftBegin whether the begin is to be shifted - per the begin/both/end toggle icons (both by default)\n * @param shiftEnd whether the end is to be shifted\n * @param unitOfTime shift by one of this unit\n */\n onTimeShift(shiftBegin: boolean, shiftEnd: boolean, unitOfTime: DurationUnitType, direction: TimeShiftDirection): void\n\n /**\n * Called by the \"Interval End\" buttons: `\"15minutes\"`, `\"hour\"`, `\"day\"`.\n * `DateRangeInput` sets the end to 1 ms before the start of that unit containing now.\n */\n onEndIntervalChange(unit: OpUnitType | \"15minutes\"): void\n}\n\ninterface DateRangeInputAdvancedPanelState {\n timeShiftBegin: boolean\n timeShiftBoth: boolean\n timeShiftEnd: boolean\n}\n\n/**\n * Shortcut buttons of the `DateRangeInputMode.ADVANCED` popup of `DateRangeInput`: interval begin,\n * duration with time shift, and interval end. It only reports which button was pressed; the caller computes the range.\n */\nexport default class DateRangeInputAdvancedPanel extends React.Component<DateRangeInputAdvancedPanelProps, DateRangeInputAdvancedPanelState> {\n constructor(props: Readonly<DateRangeInputAdvancedPanelProps>) {\n super(props);\n\n this.state = {\n timeShiftBegin: false,\n timeShiftBoth: true,\n timeShiftEnd: false,\n }\n }\n\n private renderSectionTitle(title: React.ReactNode) {\n return (\n <span style={{display: \"block\", fontWeight: \"bold\", textAlign: \"center\", marginBottom: 4}}>\n {title}\n </span>\n );\n }\n\n private renderButton(title: React.ReactNode, callback: () => void) {\n return (\n <Button\n size=\"small\"\n block\n onClick={callback}\n >\n {title}\n </Button>\n );\n }\n\n private renderButtonWithTimeShift(title: React.ReactNode, onClick: () => void, onTimeShift: (direction: TimeShiftDirection) => void) {\n const timeShiftDisabled = !this.state.timeShiftBegin && !this.state.timeShiftEnd && !this.state.timeShiftBoth;\n\n return (\n <Space.Compact block size=\"small\">\n <Button\n disabled={timeShiftDisabled}\n icon=\"-\"\n onClick={() => onTimeShift(TimeShiftDirection.DECREMENT)}\n />\n <Button\n size=\"small\"\n block\n onClick={onClick}\n >\n {title}\n </Button>\n <Button\n disabled={timeShiftDisabled}\n icon=\"+\"\n onClick={() => onTimeShift(TimeShiftDirection.INCREMENT)}\n />\n </Space.Compact>\n );\n }\n\n private renderTimeShiftIcon(shiftType: \"begin\" | \"both\" | \"end\", styles: ReturnType<typeof useStyles>[\"styles\"]) {\n let checked = false;\n if (shiftType === \"begin\") {\n checked = this.state.timeShiftBegin;\n } else if (shiftType === \"both\") {\n checked = this.state.timeShiftBoth;\n } else if (shiftType === \"end\") {\n checked = this.state.timeShiftEnd;\n }\n\n return (\n <Icon component={() =>\n <svg\n className={`icon ${checked ? styles.timeShiftIconChecked : styles.timeShiftIcon}`}\n viewBox=\"64 64 896 896\"\n version=\"1.1\"\n width={40}\n height={40}\n cursor=\"pointer\"\n onClick={() => {\n if (shiftType === \"begin\") {\n this.setState({\n timeShiftBegin: !this.state.timeShiftBegin,\n timeShiftBoth: false,\n timeShiftEnd: false\n });\n } else if (shiftType === \"both\") {\n this.setState({\n timeShiftBegin: false,\n timeShiftBoth: !this.state.timeShiftBoth,\n timeShiftEnd: false\n });\n } else if (shiftType === \"end\") {\n this.setState({\n timeShiftBegin: false,\n timeShiftBoth: false,\n timeShiftEnd: !this.state.timeShiftEnd\n });\n }\n }}\n >\n <path\n d=\"m 880.43128,184.00001 h -168 v -64 c 0,-4.4 -3.6,-8 -8,-8 h -56 c -4.4,0 -8,3.6 -8,8 v 64 h -256 v -64 c 0,-4.4 -3.6,-8 -8,-8 h -56 c -4.4,0 -8,3.6 -8,8 v 64 h -168 c -17.7,0 -32,14.3 -32,32 v 664 c 0,17.7 14.3,32 32,32 h 736 c 17.7,0 32,-14.3 32,-32 v -664 c 0,-17.7 -14.3,-32 -32,-32 z m -40,656 h -656 v -380 h 656 z m -656,-448 v -136 h 128 v 48 c 0,4.4 3.6,8 8,8 h 56 c 4.4,0 8,-3.6 8,-8 v -48 h 256 v 48 c 0,4.4 3.6,8 8,8 h 56 c 4.4,0 8,-3.6 8,-8 v -48 h 128 v 136 z\"\n id=\"path2231\"\n style={{fill: \"currentcolor\"}}\n />\n {[\"begin\", \"end\"].includes(shiftType) &&\n <g id=\"g41\">\n <g id=\"path2822\"/>\n <g id=\"path2824\"/>\n <g id=\"path2826\"\n transform={shiftType === \"end\" ? \"rotate(180,512.9334,646.24561)\" : \"unset\"}>\n <path\n id=\"path50\"\n style={{fill: \"currentcolor\"}}\n d=\"m 358.80859,510.14062 a 34.41795,34.41795 0 0 0 -23.58789,9.24219 L 226.40625,620.82422 a 34.41795,34.41795 0 0 0 -1.70508,48.64453 34.41795,34.41795 0 0 0 48.64453,1.70703 l 108.8125,-101.4414 a 34.41795,34.41795 0 0 0 1.70703,-48.64454 34.41795,34.41795 0 0 0 -25.05664,-10.94922 z M 249.87565,645.99998 358.68957,544.55871 M 249.7207,611.58203 a 34.41795,34.41795 0 0 0 -24.90625,10.82813 34.41795,34.41795 0 0 0 1.47071,48.65234 l 108.29492,101.93164 a 34.41795,34.41795 0 0 0 48.65234,-1.4707 34.41795,34.41795 0 0 0 -1.47265,-48.65235 L 273.46484,620.9375 a 34.41795,34.41795 0 0 0 -23.74414,-9.35547 z m 0.15495,34.41795 108.29422,101.93273 M 264.8125,610.01953 A 35.98045,35.98045 0 0 0 228.83203,646 35.98045,35.98045 0 0 0 264.8125,681.98047 H 550.48633 A 35.98045,35.98045 0 0 0 586.4668,646 35.98045,35.98045 0 0 0 550.48633,610.01953 Z m 285.67298,35.98045 h -285.6727\"/>\n </g>\n </g>\n }\n {shiftType === \"both\" &&\n <g id=\"g65\" transform=\"rotate(180,512.9334,646.0254)\">\n <path\n id=\"path63\"\n style={{fill: \"currentcolor\"}}\n d=\"m 358.80859,510.14062 a 34.41795,34.41795 0 0 0 -23.58789,9.24219 L 226.40625,620.82422 a 34.41795,34.41795 0 0 0 -1.70508,48.64453 34.41795,34.41795 0 0 0 48.64453,1.70703 l 108.8125,-101.4414 a 34.41795,34.41795 0 0 0 1.70703,-48.64454 34.41795,34.41795 0 0 0 -25.05664,-10.94922 z M 249.87565,645.99998 358.68957,544.55871 M 249.7207,611.58203 a 34.41795,34.41795 0 0 0 -24.90625,10.82813 34.41795,34.41795 0 0 0 1.47071,48.65234 l 108.29492,101.93164 a 34.41795,34.41795 0 0 0 48.65234,-1.4707 34.41795,34.41795 0 0 0 -1.47265,-48.65235 L 273.46484,620.9375 a 34.41795,34.41795 0 0 0 -23.74414,-9.35547 z m 0.15495,34.41795 108.29422,101.93273 M 264.8125,610.01953 A 35.98045,35.98045 0 0 0 228.83203,646 35.98045,35.98045 0 0 0 264.8125,681.98047 H 550.48633 A 35.98045,35.98045 0 0 0 586.4668,646 35.98045,35.98045 0 0 0 550.48633,610.01953 Z m 285.67298,35.98045 h -285.6727 m 402.24543,135.9102 a -34.41795,-34.41795 0 0 0 23.58789,-9.24219 L 799.46055,671.22658 a -34.41795,-34.41795 0 0 0 1.70508,-48.64453 -34.41795,-34.41795 0 0 0 -48.64453,-1.70703 l -108.8125,101.4414 a -34.41795,-34.41795 0 0 0 -1.70703,48.64454 -34.41795,-34.41795 0 0 0 25.05664,10.94922 z M 775.99115,646.05082 667.17723,747.49209 M 776.1461,680.46877 a -34.41795,-34.41795 0 0 0 24.90625,-10.82813 -34.41795,-34.41795 0 0 0 -1.47071,-48.65234 L 691.28672,519.05666 a -34.41795,-34.41795 0 0 0 -48.65234,1.4707 -34.41795,-34.41795 0 0 0 1.47265,48.65235 L 752.40196,671.1133 a -34.41795,-34.41795 0 0 0 23.74414,9.35547 z M 775.99115,646.05082 667.69693,544.11809 M 761.0543,682.03127 A -35.98045,-35.98045 0 0 0 797.03477,646.0508 -35.98045,-35.98045 0 0 0 761.0543,610.07033 H 475.38047 A -35.98045,-35.98045 0 0 0 439.4,646.0508 -35.98045,-35.98045 0 0 0 475.38047,682.03127 Z M 475.38132,646.05082 h 285.6727\"/>\n </g>\n }\n </svg>\n }/>\n );\n }\n\n render() {\n const timeShiftBegin = this.state.timeShiftBegin || this.state.timeShiftBoth;\n const timeShiftEnd = this.state.timeShiftEnd || this.state.timeShiftBoth;\n\n return (\n <WithCss useStyles={useStyles}>{({styles}) =>\n <div className={styles.panel}>\n <Divider style={{margin: \"8px 0px 6px\"}}/>\n <div className={styles.columns}>\n <Space className={styles.column} direction=\"vertical\">\n {this.renderSectionTitle(i18n(\"Interval Begin\"))}\n {this.renderButton(i18n(\"Now\"), () => this.props.onBeginIntervalChange(\"15minutes\"))}\n {this.renderButton(i18n(\"Today\"), () => this.props.onBeginIntervalChange(\"day\"))}\n {this.renderButton(i18n(\"Week\"), () => this.props.onBeginIntervalChange(\"week\"))}\n {this.renderButton(i18n(\"Month\"), () => this.props.onBeginIntervalChange(\"month\"))}\n {this.renderButton(i18n(\"Year\"), () => this.props.onBeginIntervalChange(\"year\"))}\n </Space>\n <Space className={styles.column} direction=\"vertical\">\n {this.renderSectionTitle(i18n(\"Duration and Time Shift\"))}\n {this.renderButtonWithTimeShift(i18n(\"Hour\"), () => this.props.onIntervalDurationChange(\"hour\"), (direction) => this.props.onTimeShift(timeShiftBegin, timeShiftEnd, \"hour\", direction))}\n {this.renderButtonWithTimeShift(i18n(\"Day\"), () => this.props.onIntervalDurationChange(\"day\"), (direction) => this.props.onTimeShift(timeShiftBegin, timeShiftEnd, \"day\", direction))}\n {this.renderButtonWithTimeShift(i18n(\"Week\"), () => this.props.onIntervalDurationChange(\"week\"), (direction) => this.props.onTimeShift(timeShiftBegin, timeShiftEnd, \"week\", direction))}\n {this.renderButtonWithTimeShift(i18n(\"Month\"), () => this.props.onIntervalDurationChange(\"month\"), (direction) => this.props.onTimeShift(timeShiftBegin, timeShiftEnd, \"month\", direction))}\n {this.renderButtonWithTimeShift(i18n(\"Year\"), () => this.props.onIntervalDurationChange(\"year\"), (direction) => this.props.onTimeShift(timeShiftBegin, timeShiftEnd, \"year\", direction))}\n <div style={{display: \"flex\", justifyContent: \"center\", alignItems: \"center\"}}>\n {this.renderTimeShiftIcon(\"begin\", styles)}\n {this.renderTimeShiftIcon(\"both\", styles)}\n {this.renderTimeShiftIcon(\"end\", styles)}\n </div>\n </Space>\n {!this.props.compact &&\n <Space className={styles.column} direction=\"vertical\">\n {this.renderSectionTitle(i18n(\"Interval End\"))}\n {this.renderButton(\"15 min\", () => this.props.onEndIntervalChange(\"15minutes\"))}\n {this.renderButton(i18n(\"Hour\"), () => this.props.onEndIntervalChange(\"hour\"))}\n {this.renderButton(i18n(\"Day\"), () => this.props.onEndIntervalChange(\"day\"))}\n </Space>\n }\n </div>\n </div>\n }</WithCss>\n );\n }\n\n}"]}
1
+ {"version":3,"file":"dateRangeInputAdvancedPanel.js","sourceRoot":"","sources":["../../../../components/date/dateRangeInputAdvancedPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,M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ChB,oBAAC,KAAK,IAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,EAAC,UAAU;wBAChD,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;wBAC7C,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC;wBAC9E,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;wBAC7E,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CACxE,CAEV,CACJ,CACK,CACd,CAAC;IACN,CAAC;CAEJ","sourcesContent":["import React from \"react\";\r\nimport {Button, Divider, Space} from \"antd\";\r\nimport i18n from \"d2core/i18n/i18n\";\r\nimport {OpUnitType} from \"dayjs\";\r\nimport {DurationUnitType} from \"d2core/dayjs/duration\";\r\nimport Icon from \"@ant-design/icons/es/components/Icon\";\r\nimport {createStyles} from \"antd-style\";\r\nimport WithCss from \"../style/withCss\";\r\n\r\nconst useStyles = createStyles(({token, css}) => {\r\n return {\r\n panel: css`\r\n color: ${token.colorTextSecondary};\r\n `,\r\n // the popup grows with a long date-time mask - the columns share the extra width, never below their content\r\n columns: css`\r\n display: flex;\r\n align-items: flex-start;\r\n gap: 24px;\r\n margin-bottom: 8px;\r\n `,\r\n column: css`\r\n flex: 1 1 0;\r\n min-width: max-content;\r\n `,\r\n timeShiftIcon: css`\r\n color: ${token.colorTextSecondary};\r\n `,\r\n timeShiftIconChecked: css`\r\n color: ${token.colorPrimary};\r\n `,\r\n }\r\n});\r\n\r\n/** Direction of a time shift requested by {@link DateRangeInputAdvancedPanel}. */\r\nexport enum TimeShiftDirection {\r\n /** Shift forward in time (the \"+\" button). */\r\n INCREMENT,\r\n /** Shift backward in time (the \"-\" button). */\r\n DECREMENT,\r\n}\r\n\r\n/** Props of {@link DateRangeInputAdvancedPanel}. */\r\ninterface DateRangeInputAdvancedPanelProps {\r\n /** Hides the \"Interval End\" column. */\r\n compact?: boolean\r\n\r\n /**\r\n * Called by the \"Interval Begin\" buttons: `\"15minutes\"` (Now), `\"day\"` (Today), `\"week\"`, `\"month\"`, `\"year\"`.\r\n * `DateRangeInput` sets the begin to the start of that unit containing now (the current quarter-hour for `\"15minutes\"`).\r\n */\r\n onBeginIntervalChange(unit: OpUnitType | \"15minutes\"): void\r\n\r\n /**\r\n * Called by the duration buttons (`\"hour\"`, `\"day\"`, `\"week\"`, `\"month\"`, `\"year\"`).\r\n * `DateRangeInput` sets the end to begin + 1 unit - 1 ms.\r\n */\r\n onIntervalDurationChange(unitOfTime: DurationUnitType): void\r\n\r\n /**\r\n * Called by the \"-\"/\"+\" buttons beside a duration button.\r\n * @param shiftBegin whether the begin is to be shifted - per the begin/both/end toggle icons (both by default)\r\n * @param shiftEnd whether the end is to be shifted\r\n * @param unitOfTime shift by one of this unit\r\n */\r\n onTimeShift(shiftBegin: boolean, shiftEnd: boolean, unitOfTime: DurationUnitType, direction: TimeShiftDirection): void\r\n\r\n /**\r\n * Called by the \"Interval End\" buttons: `\"15minutes\"`, `\"hour\"`, `\"day\"`.\r\n * `DateRangeInput` sets the end to 1 ms before the start of that unit containing now.\r\n */\r\n onEndIntervalChange(unit: OpUnitType | \"15minutes\"): void\r\n}\r\n\r\ninterface DateRangeInputAdvancedPanelState {\r\n timeShiftBegin: boolean\r\n timeShiftBoth: boolean\r\n timeShiftEnd: boolean\r\n}\r\n\r\n/**\r\n * Shortcut buttons of the `DateRangeInputMode.ADVANCED` popup of `DateRangeInput`: interval begin,\r\n * duration with time shift, and interval end. It only reports which button was pressed; the caller computes the range.\r\n */\r\nexport default class DateRangeInputAdvancedPanel extends React.Component<DateRangeInputAdvancedPanelProps, DateRangeInputAdvancedPanelState> {\r\n constructor(props: Readonly<DateRangeInputAdvancedPanelProps>) {\r\n super(props);\r\n\r\n this.state = {\r\n timeShiftBegin: false,\r\n timeShiftBoth: true,\r\n timeShiftEnd: false,\r\n }\r\n }\r\n\r\n private renderSectionTitle(title: React.ReactNode) {\r\n return (\r\n <span style={{display: \"block\", fontWeight: \"bold\", textAlign: \"center\", marginBottom: 4}}>\r\n {title}\r\n </span>\r\n );\r\n }\r\n\r\n private renderButton(title: React.ReactNode, callback: () => void) {\r\n return (\r\n <Button\r\n size=\"small\"\r\n block\r\n onClick={callback}\r\n >\r\n {title}\r\n </Button>\r\n );\r\n }\r\n\r\n private renderButtonWithTimeShift(title: React.ReactNode, onClick: () => void, onTimeShift: (direction: TimeShiftDirection) => void) {\r\n const timeShiftDisabled = !this.state.timeShiftBegin && !this.state.timeShiftEnd && !this.state.timeShiftBoth;\r\n\r\n return (\r\n <Space.Compact block size=\"small\">\r\n <Button\r\n disabled={timeShiftDisabled}\r\n icon=\"-\"\r\n onClick={() => onTimeShift(TimeShiftDirection.DECREMENT)}\r\n />\r\n <Button\r\n size=\"small\"\r\n block\r\n onClick={onClick}\r\n >\r\n {title}\r\n </Button>\r\n <Button\r\n disabled={timeShiftDisabled}\r\n icon=\"+\"\r\n onClick={() => onTimeShift(TimeShiftDirection.INCREMENT)}\r\n />\r\n </Space.Compact>\r\n );\r\n }\r\n\r\n private renderTimeShiftIcon(shiftType: \"begin\" | \"both\" | \"end\", styles: ReturnType<typeof useStyles>[\"styles\"]) {\r\n let checked = false;\r\n if (shiftType === \"begin\") {\r\n checked = this.state.timeShiftBegin;\r\n } else if (shiftType === \"both\") {\r\n checked = this.state.timeShiftBoth;\r\n } else if (shiftType === \"end\") {\r\n checked = this.state.timeShiftEnd;\r\n }\r\n\r\n return (\r\n <Icon component={() =>\r\n <svg\r\n className={`icon ${checked ? styles.timeShiftIconChecked : styles.timeShiftIcon}`}\r\n viewBox=\"64 64 896 896\"\r\n version=\"1.1\"\r\n width={40}\r\n height={40}\r\n cursor=\"pointer\"\r\n onClick={() => {\r\n if (shiftType === \"begin\") {\r\n this.setState({\r\n timeShiftBegin: !this.state.timeShiftBegin,\r\n timeShiftBoth: false,\r\n timeShiftEnd: false\r\n });\r\n } else if (shiftType === \"both\") {\r\n this.setState({\r\n timeShiftBegin: false,\r\n timeShiftBoth: !this.state.timeShiftBoth,\r\n timeShiftEnd: false\r\n });\r\n } else if (shiftType === \"end\") {\r\n this.setState({\r\n timeShiftBegin: false,\r\n timeShiftBoth: false,\r\n timeShiftEnd: !this.state.timeShiftEnd\r\n });\r\n }\r\n }}\r\n >\r\n <path\r\n d=\"m 880.43128,184.00001 h -168 v -64 c 0,-4.4 -3.6,-8 -8,-8 h -56 c -4.4,0 -8,3.6 -8,8 v 64 h -256 v -64 c 0,-4.4 -3.6,-8 -8,-8 h -56 c -4.4,0 -8,3.6 -8,8 v 64 h -168 c -17.7,0 -32,14.3 -32,32 v 664 c 0,17.7 14.3,32 32,32 h 736 c 17.7,0 32,-14.3 32,-32 v -664 c 0,-17.7 -14.3,-32 -32,-32 z m -40,656 h -656 v -380 h 656 z m -656,-448 v -136 h 128 v 48 c 0,4.4 3.6,8 8,8 h 56 c 4.4,0 8,-3.6 8,-8 v -48 h 256 v 48 c 0,4.4 3.6,8 8,8 h 56 c 4.4,0 8,-3.6 8,-8 v -48 h 128 v 136 z\"\r\n id=\"path2231\"\r\n style={{fill: \"currentcolor\"}}\r\n />\r\n {[\"begin\", \"end\"].includes(shiftType) &&\r\n <g id=\"g41\">\r\n <g id=\"path2822\"/>\r\n <g id=\"path2824\"/>\r\n <g id=\"path2826\"\r\n transform={shiftType === \"end\" ? \"rotate(180,512.9334,646.24561)\" : \"unset\"}>\r\n <path\r\n id=\"path50\"\r\n style={{fill: \"currentcolor\"}}\r\n d=\"m 358.80859,510.14062 a 34.41795,34.41795 0 0 0 -23.58789,9.24219 L 226.40625,620.82422 a 34.41795,34.41795 0 0 0 -1.70508,48.64453 34.41795,34.41795 0 0 0 48.64453,1.70703 l 108.8125,-101.4414 a 34.41795,34.41795 0 0 0 1.70703,-48.64454 34.41795,34.41795 0 0 0 -25.05664,-10.94922 z M 249.87565,645.99998 358.68957,544.55871 M 249.7207,611.58203 a 34.41795,34.41795 0 0 0 -24.90625,10.82813 34.41795,34.41795 0 0 0 1.47071,48.65234 l 108.29492,101.93164 a 34.41795,34.41795 0 0 0 48.65234,-1.4707 34.41795,34.41795 0 0 0 -1.47265,-48.65235 L 273.46484,620.9375 a 34.41795,34.41795 0 0 0 -23.74414,-9.35547 z m 0.15495,34.41795 108.29422,101.93273 M 264.8125,610.01953 A 35.98045,35.98045 0 0 0 228.83203,646 35.98045,35.98045 0 0 0 264.8125,681.98047 H 550.48633 A 35.98045,35.98045 0 0 0 586.4668,646 35.98045,35.98045 0 0 0 550.48633,610.01953 Z m 285.67298,35.98045 h -285.6727\"/>\r\n </g>\r\n </g>\r\n }\r\n {shiftType === \"both\" &&\r\n <g id=\"g65\" transform=\"rotate(180,512.9334,646.0254)\">\r\n <path\r\n id=\"path63\"\r\n style={{fill: \"currentcolor\"}}\r\n d=\"m 358.80859,510.14062 a 34.41795,34.41795 0 0 0 -23.58789,9.24219 L 226.40625,620.82422 a 34.41795,34.41795 0 0 0 -1.70508,48.64453 34.41795,34.41795 0 0 0 48.64453,1.70703 l 108.8125,-101.4414 a 34.41795,34.41795 0 0 0 1.70703,-48.64454 34.41795,34.41795 0 0 0 -25.05664,-10.94922 z M 249.87565,645.99998 358.68957,544.55871 M 249.7207,611.58203 a 34.41795,34.41795 0 0 0 -24.90625,10.82813 34.41795,34.41795 0 0 0 1.47071,48.65234 l 108.29492,101.93164 a 34.41795,34.41795 0 0 0 48.65234,-1.4707 34.41795,34.41795 0 0 0 -1.47265,-48.65235 L 273.46484,620.9375 a 34.41795,34.41795 0 0 0 -23.74414,-9.35547 z m 0.15495,34.41795 108.29422,101.93273 M 264.8125,610.01953 A 35.98045,35.98045 0 0 0 228.83203,646 35.98045,35.98045 0 0 0 264.8125,681.98047 H 550.48633 A 35.98045,35.98045 0 0 0 586.4668,646 35.98045,35.98045 0 0 0 550.48633,610.01953 Z m 285.67298,35.98045 h -285.6727 m 402.24543,135.9102 a -34.41795,-34.41795 0 0 0 23.58789,-9.24219 L 799.46055,671.22658 a -34.41795,-34.41795 0 0 0 1.70508,-48.64453 -34.41795,-34.41795 0 0 0 -48.64453,-1.70703 l -108.8125,101.4414 a -34.41795,-34.41795 0 0 0 -1.70703,48.64454 -34.41795,-34.41795 0 0 0 25.05664,10.94922 z M 775.99115,646.05082 667.17723,747.49209 M 776.1461,680.46877 a -34.41795,-34.41795 0 0 0 24.90625,-10.82813 -34.41795,-34.41795 0 0 0 -1.47071,-48.65234 L 691.28672,519.05666 a -34.41795,-34.41795 0 0 0 -48.65234,1.4707 -34.41795,-34.41795 0 0 0 1.47265,48.65235 L 752.40196,671.1133 a -34.41795,-34.41795 0 0 0 23.74414,9.35547 z M 775.99115,646.05082 667.69693,544.11809 M 761.0543,682.03127 A -35.98045,-35.98045 0 0 0 797.03477,646.0508 -35.98045,-35.98045 0 0 0 761.0543,610.07033 H 475.38047 A -35.98045,-35.98045 0 0 0 439.4,646.0508 -35.98045,-35.98045 0 0 0 475.38047,682.03127 Z M 475.38132,646.05082 h 285.6727\"/>\r\n </g>\r\n }\r\n </svg>\r\n }/>\r\n );\r\n }\r\n\r\n render() {\r\n const timeShiftBegin = this.state.timeShiftBegin || this.state.timeShiftBoth;\r\n const timeShiftEnd = this.state.timeShiftEnd || this.state.timeShiftBoth;\r\n\r\n return (\r\n <WithCss useStyles={useStyles}>{({styles}) =>\r\n <div className={styles.panel}>\r\n <Divider style={{margin: \"8px 0px 6px\"}}/>\r\n <div className={styles.columns}>\r\n <Space className={styles.column} direction=\"vertical\">\r\n {this.renderSectionTitle(i18n(\"Interval Begin\"))}\r\n {this.renderButton(i18n(\"Now\"), () => this.props.onBeginIntervalChange(\"15minutes\"))}\r\n {this.renderButton(i18n(\"Today\"), () => this.props.onBeginIntervalChange(\"day\"))}\r\n {this.renderButton(i18n(\"Week\"), () => this.props.onBeginIntervalChange(\"week\"))}\r\n {this.renderButton(i18n(\"Month\"), () => this.props.onBeginIntervalChange(\"month\"))}\r\n {this.renderButton(i18n(\"Year\"), () => this.props.onBeginIntervalChange(\"year\"))}\r\n </Space>\r\n <Space className={styles.column} direction=\"vertical\">\r\n {this.renderSectionTitle(i18n(\"Duration and Time Shift\"))}\r\n {this.renderButtonWithTimeShift(i18n(\"Hour\"), () => this.props.onIntervalDurationChange(\"hour\"), (direction) => this.props.onTimeShift(timeShiftBegin, timeShiftEnd, \"hour\", direction))}\r\n {this.renderButtonWithTimeShift(i18n(\"Day\"), () => this.props.onIntervalDurationChange(\"day\"), (direction) => this.props.onTimeShift(timeShiftBegin, timeShiftEnd, \"day\", direction))}\r\n {this.renderButtonWithTimeShift(i18n(\"Week\"), () => this.props.onIntervalDurationChange(\"week\"), (direction) => this.props.onTimeShift(timeShiftBegin, timeShiftEnd, \"week\", direction))}\r\n {this.renderButtonWithTimeShift(i18n(\"Month\"), () => this.props.onIntervalDurationChange(\"month\"), (direction) => this.props.onTimeShift(timeShiftBegin, timeShiftEnd, \"month\", direction))}\r\n {this.renderButtonWithTimeShift(i18n(\"Year\"), () => this.props.onIntervalDurationChange(\"year\"), (direction) => this.props.onTimeShift(timeShiftBegin, timeShiftEnd, \"year\", direction))}\r\n <div style={{display: \"flex\", justifyContent: \"center\", alignItems: \"center\"}}>\r\n {this.renderTimeShiftIcon(\"begin\", styles)}\r\n {this.renderTimeShiftIcon(\"both\", styles)}\r\n {this.renderTimeShiftIcon(\"end\", styles)}\r\n </div>\r\n </Space>\r\n {!this.props.compact &&\r\n <Space className={styles.column} direction=\"vertical\">\r\n {this.renderSectionTitle(i18n(\"Interval End\"))}\r\n {this.renderButton(\"15 min\", () => this.props.onEndIntervalChange(\"15minutes\"))}\r\n {this.renderButton(i18n(\"Hour\"), () => this.props.onEndIntervalChange(\"hour\"))}\r\n {this.renderButton(i18n(\"Day\"), () => this.props.onEndIntervalChange(\"day\"))}\r\n </Space>\r\n }\r\n </div>\r\n </div>\r\n }</WithCss>\r\n );\r\n }\r\n\r\n}"]}
@@ -22,13 +22,13 @@ import WithCss from "../style/withCss";
22
22
  const useStyles = createStyles(({ token, css }) => {
23
23
  return {
24
24
  // the confirm buttons float above the page on a transparent tooltip, so they need their own surface
25
- buttonsSurface: css `
26
- background: ${token.colorBgElevated};
25
+ buttonsSurface: css `
26
+ background: ${token.colorBgElevated};
27
27
  `,
28
28
  // ghost button is transparent by default - give it the same opaque surface
29
- revertButton: css `
30
- background: ${token.colorBgElevated};
31
- border-right-width: 2px;
29
+ revertButton: css `
30
+ background: ${token.colorBgElevated};
31
+ border-right-width: 2px;
32
32
  `,
33
33
  };
34
34
  });
@@ -1 +1 @@
1
- {"version":3,"file":"dateRangeInputConfirm.js","sourceRoot":"","sources":["../../../../components/date/dateRangeInputConfirm.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAC,MAAM,MAAM,CAAC;AAC5C,OAAO,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAChD,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,OAAO,cAAc,EAAE,EAAC,kBAAkB,EAAsB,MAAM,kBAAkB,CAAC;AAGzF,OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAC,GAAG,EAAC,MAAM,aAAa,CAAC;AAChC,OAAO,EAAC,YAAY,EAAC,MAAM,YAAY,CAAC;AACxC,OAAO,OAAO,MAAM,kBAAkB,CAAC;AAEvC,MAAM,SAAS,GAAG,YAAY,CAAC,CAAC,EAAC,K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BACX,GAAG,EAAE,SAAS,CAAC,EAAE,CAAC,IAAI,CAAC,cAAc,GAAG,SAAS,EACjD,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,gBAAgB,EACtC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,EAClC,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,CAAC,CAAC,EAAE,EAAE;wBAClB,IAAI,CAAC,QAAQ,CAAC,EAAC,mBAAmB,EAAE,IAAI,EAAC,CAAC,CAAC;oBAC/C,CAAC,EACD,QAAQ,EAAE,CAAC,SAAuB,EAAE,OAAqB,EAAE,EAAE;wBACzD,IAAI,CAAC,QAAQ,CAAC;4BACV,gBAAgB,EAAE,SAAS;4BAC3B,cAAc,EAAE,OAAO;4BACvB,mBAAmB,EAAE,KAAK;yBAC7B,CAAC,CAAA;oBACN,CAAC,EACD,sBAAsB,EAAE,GAAG,EAAE;wBACzB,IAAI,IAAI,CAAC,qBAAqB,EAAE,EAAE,CAAC;4BAC/B,OAAO,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;wBAC9C,CAAC;wBACD,OAAO,SAAS,CAAC;oBACrB,CAAC,EACD,oBAAoB,EAAE,OAAO,CAAC,EAAE;wBAC5B,IAAI,CAAC,QAAQ,CAAC,EAAC,YAAY,EAAE,OAAO,EAAC,CAAC,CAAC;oBAC3C,CAAC,EACD,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EAC5B,YAAY,EAAE,IAAI,CAAC,EAAE;wBACjB,IAAI,CAAC,QAAQ,CAAC,EAAC,IAAI,EAAE,IAAI,EAAC,CAAC,CAAC;oBAChC,CAAC,IACG,IAAI,EACV,CACI,CACP,CACV,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React, {createRef} from \"react\";\nimport {Dayjs} from \"dayjs\";\nimport {Button, Space, Tooltip} from \"antd\";\nimport {DateTimeUtils} from \"d2core/utils/dateTimeUtils\";\nimport {CheckOutlined} from \"@ant-design/icons\";\nimport i18n from \"d2core/i18n/i18n\";\nimport DateRangeInput, {DateRangeInputMode, DateRangeInputProps} from \"./dateRangeInput\";\nimport {TooltipPlacement} from \"antd/es/tooltip\";\nimport {AlignType} from \"@rc-component/trigger/lib/interface\";\nimport {UndoIcon} from \"../icons/undoIcon\";\nimport {SizeType} from \"antd/lib/config-provider/SizeContext\";\nimport {Key} from \"ts-key-enum\";\nimport {createStyles} from \"antd-style\";\nimport WithCss from \"../style/withCss\";\n\nconst useStyles = createStyles(({token, css}) => {\n return {\n // the confirm buttons float above the page on a transparent tooltip, so they need their own surface\n buttonsSurface: css`\n background: ${token.colorBgElevated};\n `,\n // ghost button is transparent by default - give it the same opaque surface\n revertButton: css`\n background: ${token.colorBgElevated};\n border-right-width: 2px;\n `,\n }\n});\n\n/**\n * Props of {@link DateRangeInputConfirm} - those of {@link DateRangeInput}, except that `onChange` is called only\n * on confirmation. `onInvalidValue`, `onPopupVisibleChange`, `onModeChange`, `defaultMode` and\n * `confirmButtonsRenderer` are used internally and passing them overrides the confirm behaviour.\n */\ninterface DateRangeInputConfirmProps extends DateRangeInputProps {\n /** Shows the confirm buttons from the start, even before anything is changed, until the first confirmation. */\n requireConfirmationAtStart?: boolean\n /**\n * Where the floating confirm buttons are shown next to the input: `\"right\"`, `\"topRight\"`; any other value\n * (or none) means below the right edge.\n */\n confirmPlacement?: TooltipPlacement\n}\n\ninterface DateRangeInputConfirmState {\n originalFromValue: Dayjs | null\n originalToValue: Dayjs | null\n currentFromValue: Dayjs | null\n currentToValue: Dayjs | null\n invalidDatesPresent: boolean\n requireConfirmation: boolean\n\n popupVisible: boolean\n mode: DateRangeInputMode\n}\n\n/**\n * {@link DateRangeInput} that buffers edits and reports them through `onChange` only when confirmed with the\n * Apply button or Enter; the Revert button or Escape restores the last value from props. The Revert/Apply buttons\n * float next to the input (and appear in the popup footer) while the range differs from the props, contains an\n * invalid text or {@link DateRangeInputConfirmProps.requireConfirmationAtStart} is pending. A change of\n * `fromValue`/`toValue` from props discards the buffered edit.\n */\nexport default class DateRangeInputConfirm extends React.Component<DateRangeInputConfirmProps, DateRangeInputConfirmState> {\n private dateRangeInput: DateRangeInput | null = null;\n private parentRef: React.RefObject<HTMLSpanElement> = createRef();\n\n constructor(props: Readonly<DateRangeInputConfirmProps>) {\n super(props);\n this.state = {\n originalFromValue: props.fromValue ?? null,\n originalToValue: props.toValue ?? null,\n currentFromValue: props.fromValue ?? null,\n currentToValue: props.toValue ?? null,\n invalidDatesPresent: false,\n requireConfirmation: !!props.requireConfirmationAtStart,\n\n popupVisible: false,\n mode: props.defaultMode ?? DateRangeInputMode.SIMPLE,\n };\n\n this.onKeyDown = this.onKeyDown.bind(this);\n this.onConfirm = this.onConfirm.bind(this);\n this.onRevert = this.onRevert.bind(this);\n }\n\n /** Confirms on Enter and reverts on Escape; attached to the wrapping element. */\n onKeyDown(event: React.KeyboardEvent) {\n if (event.key === Key.Enter) {\n this.onConfirm();\n } else if (event.key === Key.Escape) {\n this.onRevert();\n }\n }\n\n componentDidUpdate(prevProps: Readonly<DateRangeInputProps>) {\n const preFromValueUnixTime = DateTimeUtils.toUnixTime(prevProps.fromValue);\n const currentFromValueUnixTime = DateTimeUtils.toUnixTime(this.props.fromValue);\n const prevToValueUnixTime = DateTimeUtils.toUnixTime(prevProps.toValue);\n const currentToValueUnixTime = DateTimeUtils.toUnixTime(this.props.toValue);\n if (preFromValueUnixTime !== currentFromValueUnixTime ||\n prevToValueUnixTime !== currentToValueUnixTime) {\n this.setState({\n originalFromValue: this.props.fromValue ?? null,\n originalToValue: this.props.toValue ?? null,\n currentFromValue: this.props.fromValue ?? null,\n currentToValue: this.props.toValue ?? null\n })\n }\n }\n\n private onConfirm() {\n this.setState({requireConfirmation: false});\n this.props.onChange?.(this.state.currentFromValue, this.state.currentToValue);\n this.dateRangeInput?.closePopup();\n }\n\n private onRevert() {\n this.setState({\n currentFromValue: this.state.originalFromValue ?? null,\n currentToValue: this.state.originalToValue ?? null,\n invalidDatesPresent: false,\n });\n this.dateRangeInput?.closePopup();\n }\n\n private renderConfirmButtons(size?: SizeType) {\n const validInterval = this.props.allowClear ?\n (!this.state.currentFromValue || this.state.currentFromValue.isValid()) && (!this.state.currentToValue || this.state.currentToValue.isValid()) :\n this.state.currentFromValue && this.state.currentFromValue.isValid() && this.state.currentToValue && this.state.currentToValue.isValid();\n\n return (\n <WithCss useStyles={useStyles} props={{size}}>{({styles}, {size: mergedSize}) => {\n const buttonWidth = mergedSize === \"small\" ? 48 : undefined;\n return (\n <Space.Compact className={styles.buttonsSurface}>\n <Button\n className={styles.revertButton}\n style={{width: buttonWidth}}\n size={size}\n title={i18n(\"Revert\")}\n key=\"revert\"\n danger\n ghost\n onClick={this.onRevert}\n >\n <UndoIcon/>\n </Button>\n <Button\n style={{width: buttonWidth}}\n title={i18n(\"Apply\")} key=\"apply-button\"\n size={size}\n type=\"primary\"\n disabled={!validInterval || this.state.invalidDatesPresent}\n onClick={this.onConfirm}\n >\n <CheckOutlined/>\n </Button>\n </Space.Compact>\n );\n }}</WithCss>\n );\n }\n\n private confirmButtonsVisible() {\n const {originalFromValue, originalToValue, currentFromValue, currentToValue} = this.state;\n const valueChanged = DateTimeUtils.toUnixTime(currentFromValue) !== DateTimeUtils.toUnixTime(originalFromValue) ||\n DateTimeUtils.toUnixTime(currentToValue) !== DateTimeUtils.toUnixTime(originalToValue);\n\n return valueChanged || this.state.invalidDatesPresent || this.state.requireConfirmation;\n }\n\n render(): any {\n const {\n fromValue,\n toValue,\n onChange,\n allowClear,\n requireConfirmationAtStart,\n confirmPlacement,\n compact,\n ...rest\n } = this.props;\n let align: AlignType;\n if (confirmPlacement === \"right\") {\n align = {points: [\"tl\", \"tr\"], offset: [-8, 0]};\n } else if (confirmPlacement === \"topRight\") {\n align = {points: [\"br\", \"tr\"], offset: [0, 8]};\n } else {\n // default bottomRight\n align = {points: [\"tr\", \"br\"], offset: [0, -6]};\n }\n return (\n <span onKeyDown={this.onKeyDown} ref={this.parentRef}>\n <Tooltip\n color={\"transparent\"}\n styles={{body: {boxShadow: \"none\"}}}\n open={this.confirmButtonsVisible() && !this.state.popupVisible}\n align={align}\n title={this.renderConfirmButtons(rest.size)}\n getPopupContainer={() => {\n // very nasty trick how remove error of ResizeObservers infinite cycling - because popover (with dynamic size) is placed in resizable panel\n const parentNode = (this.parentRef.current?.parentNode ?? document.body) as HTMLElement;\n return parentNode;\n }}\n >\n <DateRangeInput\n ref={component => this.dateRangeInput = component}\n fromValue={this.state.currentFromValue}\n toValue={this.state.currentToValue}\n allowClear={allowClear}\n compact={compact}\n onInvalidValue={(_) => {\n this.setState({invalidDatesPresent: true});\n }}\n onChange={(fromValue: Dayjs | null, toValue: Dayjs | null) => {\n this.setState({\n currentFromValue: fromValue,\n currentToValue: toValue,\n invalidDatesPresent: false,\n })\n }}\n confirmButtonsRenderer={() => {\n if (this.confirmButtonsVisible()) {\n return this.renderConfirmButtons(\"small\");\n }\n return undefined;\n }}\n onPopupVisibleChange={visible => {\n this.setState({popupVisible: visible});\n }}\n defaultMode={this.state.mode}\n onModeChange={mode => {\n this.setState({mode: mode});\n }}\n {...rest}\n />\n </Tooltip>\n </span>\n );\n }\n}"]}
1
+ {"version":3,"file":"dateRangeInputConfirm.js","sourceRoot":"","sources":["../../../../components/date/dateRangeInputConfirm.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAC,MAAM,MAAM,CAAC;AAC5C,OAAO,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAChD,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,OAAO,cAAc,EAAE,EAAC,kBAAkB,EAAsB,MAAM,kBAAkB,CAAC;AAGzF,OAAO,EAAC,QAAQ,EAAC,MAAM,m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;oBAChC,CAAC,IACG,IAAI,EACV,CACI,CACP,CACV,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React, {createRef} from \"react\";\r\nimport {Dayjs} from \"dayjs\";\r\nimport {Button, Space, Tooltip} from \"antd\";\r\nimport {DateTimeUtils} from \"d2core/utils/dateTimeUtils\";\r\nimport {CheckOutlined} from \"@ant-design/icons\";\r\nimport i18n from \"d2core/i18n/i18n\";\r\nimport DateRangeInput, {DateRangeInputMode, DateRangeInputProps} from \"./dateRangeInput\";\r\nimport {TooltipPlacement} from \"antd/es/tooltip\";\r\nimport {AlignType} from \"@rc-component/trigger/lib/interface\";\r\nimport {UndoIcon} from \"../icons/undoIcon\";\r\nimport {SizeType} from \"antd/lib/config-provider/SizeContext\";\r\nimport {Key} from \"ts-key-enum\";\r\nimport {createStyles} from \"antd-style\";\r\nimport WithCss from \"../style/withCss\";\r\n\r\nconst useStyles = createStyles(({token, css}) => {\r\n return {\r\n // the confirm buttons float above the page on a transparent tooltip, so they need their own surface\r\n buttonsSurface: css`\r\n background: ${token.colorBgElevated};\r\n `,\r\n // ghost button is transparent by default - give it the same opaque surface\r\n revertButton: css`\r\n background: ${token.colorBgElevated};\r\n border-right-width: 2px;\r\n `,\r\n }\r\n});\r\n\r\n/**\r\n * Props of {@link DateRangeInputConfirm} - those of {@link DateRangeInput}, except that `onChange` is called only\r\n * on confirmation. `onInvalidValue`, `onPopupVisibleChange`, `onModeChange`, `defaultMode` and\r\n * `confirmButtonsRenderer` are used internally and passing them overrides the confirm behaviour.\r\n */\r\ninterface DateRangeInputConfirmProps extends DateRangeInputProps {\r\n /** Shows the confirm buttons from the start, even before anything is changed, until the first confirmation. */\r\n requireConfirmationAtStart?: boolean\r\n /**\r\n * Where the floating confirm buttons are shown next to the input: `\"right\"`, `\"topRight\"`; any other value\r\n * (or none) means below the right edge.\r\n */\r\n confirmPlacement?: TooltipPlacement\r\n}\r\n\r\ninterface DateRangeInputConfirmState {\r\n originalFromValue: Dayjs | null\r\n originalToValue: Dayjs | null\r\n currentFromValue: Dayjs | null\r\n currentToValue: Dayjs | null\r\n invalidDatesPresent: boolean\r\n requireConfirmation: boolean\r\n\r\n popupVisible: boolean\r\n mode: DateRangeInputMode\r\n}\r\n\r\n/**\r\n * {@link DateRangeInput} that buffers edits and reports them through `onChange` only when confirmed with the\r\n * Apply button or Enter; the Revert button or Escape restores the last value from props. The Revert/Apply buttons\r\n * float next to the input (and appear in the popup footer) while the range differs from the props, contains an\r\n * invalid text or {@link DateRangeInputConfirmProps.requireConfirmationAtStart} is pending. A change of\r\n * `fromValue`/`toValue` from props discards the buffered edit.\r\n */\r\nexport default class DateRangeInputConfirm extends React.Component<DateRangeInputConfirmProps, DateRangeInputConfirmState> {\r\n private dateRangeInput: DateRangeInput | null = null;\r\n private parentRef: React.RefObject<HTMLSpanElement> = createRef();\r\n\r\n constructor(props: Readonly<DateRangeInputConfirmProps>) {\r\n super(props);\r\n this.state = {\r\n originalFromValue: props.fromValue ?? null,\r\n originalToValue: props.toValue ?? null,\r\n currentFromValue: props.fromValue ?? null,\r\n currentToValue: props.toValue ?? null,\r\n invalidDatesPresent: false,\r\n requireConfirmation: !!props.requireConfirmationAtStart,\r\n\r\n popupVisible: false,\r\n mode: props.defaultMode ?? DateRangeInputMode.SIMPLE,\r\n };\r\n\r\n this.onKeyDown = this.onKeyDown.bind(this);\r\n this.onConfirm = this.onConfirm.bind(this);\r\n this.onRevert = this.onRevert.bind(this);\r\n }\r\n\r\n /** Confirms on Enter and reverts on Escape; attached to the wrapping element. */\r\n onKeyDown(event: React.KeyboardEvent) {\r\n if (event.key === Key.Enter) {\r\n this.onConfirm();\r\n } else if (event.key === Key.Escape) {\r\n this.onRevert();\r\n }\r\n }\r\n\r\n componentDidUpdate(prevProps: Readonly<DateRangeInputProps>) {\r\n const preFromValueUnixTime = DateTimeUtils.toUnixTime(prevProps.fromValue);\r\n const currentFromValueUnixTime = DateTimeUtils.toUnixTime(this.props.fromValue);\r\n const prevToValueUnixTime = DateTimeUtils.toUnixTime(prevProps.toValue);\r\n const currentToValueUnixTime = DateTimeUtils.toUnixTime(this.props.toValue);\r\n if (preFromValueUnixTime !== currentFromValueUnixTime ||\r\n prevToValueUnixTime !== currentToValueUnixTime) {\r\n this.setState({\r\n originalFromValue: this.props.fromValue ?? null,\r\n originalToValue: this.props.toValue ?? null,\r\n currentFromValue: this.props.fromValue ?? null,\r\n currentToValue: this.props.toValue ?? null\r\n })\r\n }\r\n }\r\n\r\n private onConfirm() {\r\n this.setState({requireConfirmation: false});\r\n this.props.onChange?.(this.state.currentFromValue, this.state.currentToValue);\r\n this.dateRangeInput?.closePopup();\r\n }\r\n\r\n private onRevert() {\r\n this.setState({\r\n currentFromValue: this.state.originalFromValue ?? null,\r\n currentToValue: this.state.originalToValue ?? null,\r\n invalidDatesPresent: false,\r\n });\r\n this.dateRangeInput?.closePopup();\r\n }\r\n\r\n private renderConfirmButtons(size?: SizeType) {\r\n const validInterval = this.props.allowClear ?\r\n (!this.state.currentFromValue || this.state.currentFromValue.isValid()) && (!this.state.currentToValue || this.state.currentToValue.isValid()) :\r\n this.state.currentFromValue && this.state.currentFromValue.isValid() && this.state.currentToValue && this.state.currentToValue.isValid();\r\n\r\n return (\r\n <WithCss useStyles={useStyles} props={{size}}>{({styles}, {size: mergedSize}) => {\r\n const buttonWidth = mergedSize === \"small\" ? 48 : undefined;\r\n return (\r\n <Space.Compact className={styles.buttonsSurface}>\r\n <Button\r\n className={styles.revertButton}\r\n style={{width: buttonWidth}}\r\n size={size}\r\n title={i18n(\"Revert\")}\r\n key=\"revert\"\r\n danger\r\n ghost\r\n onClick={this.onRevert}\r\n >\r\n <UndoIcon/>\r\n </Button>\r\n <Button\r\n style={{width: buttonWidth}}\r\n title={i18n(\"Apply\")} key=\"apply-button\"\r\n size={size}\r\n type=\"primary\"\r\n disabled={!validInterval || this.state.invalidDatesPresent}\r\n onClick={this.onConfirm}\r\n >\r\n <CheckOutlined/>\r\n </Button>\r\n </Space.Compact>\r\n );\r\n }}</WithCss>\r\n );\r\n }\r\n\r\n private confirmButtonsVisible() {\r\n const {originalFromValue, originalToValue, currentFromValue, currentToValue} = this.state;\r\n const valueChanged = DateTimeUtils.toUnixTime(currentFromValue) !== DateTimeUtils.toUnixTime(originalFromValue) ||\r\n DateTimeUtils.toUnixTime(currentToValue) !== DateTimeUtils.toUnixTime(originalToValue);\r\n\r\n return valueChanged || this.state.invalidDatesPresent || this.state.requireConfirmation;\r\n }\r\n\r\n render(): any {\r\n const {\r\n fromValue,\r\n toValue,\r\n onChange,\r\n allowClear,\r\n requireConfirmationAtStart,\r\n confirmPlacement,\r\n compact,\r\n ...rest\r\n } = this.props;\r\n let align: AlignType;\r\n if (confirmPlacement === \"right\") {\r\n align = {points: [\"tl\", \"tr\"], offset: [-8, 0]};\r\n } else if (confirmPlacement === \"topRight\") {\r\n align = {points: [\"br\", \"tr\"], offset: [0, 8]};\r\n } else {\r\n // default bottomRight\r\n align = {points: [\"tr\", \"br\"], offset: [0, -6]};\r\n }\r\n return (\r\n <span onKeyDown={this.onKeyDown} ref={this.parentRef}>\r\n <Tooltip\r\n color={\"transparent\"}\r\n styles={{body: {boxShadow: \"none\"}}}\r\n open={this.confirmButtonsVisible() && !this.state.popupVisible}\r\n align={align}\r\n title={this.renderConfirmButtons(rest.size)}\r\n getPopupContainer={() => {\r\n // very nasty trick how remove error of ResizeObservers infinite cycling - because popover (with dynamic size) is placed in resizable panel\r\n const parentNode = (this.parentRef.current?.parentNode ?? document.body) as HTMLElement;\r\n return parentNode;\r\n }}\r\n >\r\n <DateRangeInput\r\n ref={component => this.dateRangeInput = component}\r\n fromValue={this.state.currentFromValue}\r\n toValue={this.state.currentToValue}\r\n allowClear={allowClear}\r\n compact={compact}\r\n onInvalidValue={(_) => {\r\n this.setState({invalidDatesPresent: true});\r\n }}\r\n onChange={(fromValue: Dayjs | null, toValue: Dayjs | null) => {\r\n this.setState({\r\n currentFromValue: fromValue,\r\n currentToValue: toValue,\r\n invalidDatesPresent: false,\r\n })\r\n }}\r\n confirmButtonsRenderer={() => {\r\n if (this.confirmButtonsVisible()) {\r\n return this.renderConfirmButtons(\"small\");\r\n }\r\n return undefined;\r\n }}\r\n onPopupVisibleChange={visible => {\r\n this.setState({popupVisible: visible});\r\n }}\r\n defaultMode={this.state.mode}\r\n onModeChange={mode => {\r\n this.setState({mode: mode});\r\n }}\r\n {...rest}\r\n />\r\n </Tooltip>\r\n </span>\r\n );\r\n }\r\n}"]}