d2coreui 23.0.52 → 23.0.53
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 +27 -0
- package/README.md +154 -0
- package/components/clipboard/clipboardUtils.d.ts +11 -0
- package/components/clipboard/clipboardUtils.js +16 -4
- package/components/clipboard/clipboardUtils.js.map +1 -1
- package/components/codemirror/SyntaxHighlighter.d.ts +13 -0
- package/components/codemirror/SyntaxHighlighter.js +6 -1
- package/components/codemirror/SyntaxHighlighter.js.map +1 -1
- package/components/collapse/expandable.d.ts +10 -0
- package/components/collapse/expandable.js +4 -0
- package/components/collapse/expandable.js.map +1 -1
- package/components/color/colorPicker.d.ts +16 -0
- package/components/color/colorPicker.js +4 -0
- package/components/color/colorPicker.js.map +1 -1
- package/components/color/colorSwatch.d.ts +16 -0
- package/components/color/colorSwatch.js +23 -2
- package/components/color/colorSwatch.js.map +1 -1
- package/components/color/colorUtils.d.ts +9 -0
- package/components/color/colorUtils.js +15 -0
- package/components/color/colorUtils.js.map +1 -1
- package/components/date/dateRangeInput.d.ts +76 -0
- package/components/date/dateRangeInput.js +63 -12
- package/components/date/dateRangeInput.js.map +1 -1
- package/components/date/dateRangeInputAdvancedPanel.d.ts +27 -0
- package/components/date/dateRangeInputAdvancedPanel.js +7 -0
- package/components/date/dateRangeInputAdvancedPanel.js.map +1 -1
- package/components/date/dateRangeInputConfirm.d.ts +18 -0
- package/components/date/dateRangeInputConfirm.js +12 -0
- package/components/date/dateRangeInputConfirm.js.map +1 -1
- package/components/date/dateTimeInput.d.ts +99 -0
- package/components/date/dateTimeInput.js +78 -6
- package/components/date/dateTimeInput.js.map +1 -1
- package/components/date/durationInput.d.ts +37 -0
- package/components/date/durationInput.js +26 -3
- package/components/date/durationInput.js.map +1 -1
- package/components/date/savedIntervals.d.ts +63 -0
- package/components/date/savedIntervals.js +37 -0
- package/components/date/savedIntervals.js.map +1 -1
- package/components/date/savedIntervalsDialog.d.ts +13 -0
- package/components/date/savedIntervalsDialog.js +7 -2
- package/components/date/savedIntervalsDialog.js.map +1 -1
- package/components/form/NiceFormItem.d.ts +9 -0
- package/components/form/NiceFormItem.js +4 -0
- package/components/form/NiceFormItem.js.map +1 -1
- package/components/grid/cell/beanAccessor.d.ts +12 -0
- package/components/grid/cell/beanAccessor.js +8 -0
- package/components/grid/cell/beanAccessor.js.map +1 -1
- package/components/grid/cell/bigNumberCellEditor.d.ts +9 -0
- package/components/grid/cell/bigNumberCellEditor.js +19 -0
- package/components/grid/cell/bigNumberCellEditor.js.map +1 -1
- package/components/grid/cell/cellControl.d.ts +4 -0
- package/components/grid/cell/cellControl.js +14 -0
- package/components/grid/cell/cellControl.js.map +1 -1
- package/components/grid/cell/cellEditorUtils.d.ts +6 -0
- package/components/grid/cell/cellEditorUtils.js +6 -0
- package/components/grid/cell/cellEditorUtils.js.map +1 -1
- package/components/grid/cell/customEnumCellEditor.d.ts +6 -0
- package/components/grid/cell/customEnumCellEditor.js +10 -0
- package/components/grid/cell/customEnumCellEditor.js.map +1 -1
- package/components/grid/cell/dataGridCellEditorComponent.d.ts +26 -0
- package/components/grid/cell/dataGridCellEditorComponent.js +21 -0
- package/components/grid/cell/dataGridCellEditorComponent.js.map +1 -1
- package/components/grid/cell/dateCellEditor.d.ts +6 -0
- package/components/grid/cell/dateCellEditor.js +10 -0
- package/components/grid/cell/dateCellEditor.js.map +1 -1
- package/components/grid/cell/dragListenerFeature.d.ts +6 -0
- package/components/grid/cell/dragListenerFeature.js +6 -0
- package/components/grid/cell/dragListenerFeature.js.map +1 -1
- package/components/grid/cell/durationCellEditor.d.ts +6 -0
- package/components/grid/cell/durationCellEditor.js +14 -0
- package/components/grid/cell/durationCellEditor.js.map +1 -1
- package/components/grid/cell/hexaOctetStringCellEditor.d.ts +6 -0
- package/components/grid/cell/hexaOctetStringCellEditor.js +14 -0
- package/components/grid/cell/hexaOctetStringCellEditor.js.map +1 -1
- package/components/grid/cell/hexaValueCellEditor.d.ts +6 -0
- package/components/grid/cell/hexaValueCellEditor.js +14 -0
- package/components/grid/cell/hexaValueCellEditor.js.map +1 -1
- package/components/grid/cell/numberCellEditor.d.ts +6 -0
- package/components/grid/cell/numberCellEditor.js +15 -0
- package/components/grid/cell/numberCellEditor.js.map +1 -1
- package/components/grid/cell/rangeSelector.d.ts +7 -0
- package/components/grid/cell/rangeSelector.js +59 -5
- package/components/grid/cell/rangeSelector.js.map +1 -1
- package/components/grid/cell/simpleStatusTextCellEditor.d.ts +7 -0
- package/components/grid/cell/simpleStatusTextCellEditor.js +11 -0
- package/components/grid/cell/simpleStatusTextCellEditor.js.map +1 -1
- package/components/grid/cell/statusTextCellEditor.d.ts +7 -0
- package/components/grid/cell/statusTextCellEditor.js +17 -0
- package/components/grid/cell/statusTextCellEditor.js.map +1 -1
- package/components/grid/cell/tableDefaultRowStyleRules.d.ts +31 -0
- package/components/grid/cell/tableDefaultRowStyleRules.js +5 -0
- package/components/grid/cell/tableDefaultRowStyleRules.js.map +1 -1
- package/components/grid/cell/textCellEditor.d.ts +6 -0
- package/components/grid/cell/textCellEditor.js +15 -0
- package/components/grid/cell/textCellEditor.js.map +1 -1
- package/components/grid/cell/withAgGridHooks.d.ts +8 -0
- package/components/grid/cell/withAgGridHooks.js +8 -0
- package/components/grid/cell/withAgGridHooks.js.map +1 -1
- package/components/grid/columnUtils.d.ts +7 -0
- package/components/grid/columnUtils.js +7 -0
- package/components/grid/columnUtils.js.map +1 -1
- package/components/grid/config/columnTransfer.d.ts +18 -0
- package/components/grid/config/columnTransfer.js +14 -3
- package/components/grid/config/columnTransfer.js.map +1 -1
- package/components/grid/config/dataGridEditor.d.ts +31 -0
- package/components/grid/config/dataGridEditor.js +14 -2
- package/components/grid/config/dataGridEditor.js.map +1 -1
- package/components/grid/config/rowHeightCalculator.d.ts +11 -0
- package/components/grid/config/rowHeightCalculator.js +11 -0
- package/components/grid/config/rowHeightCalculator.js.map +1 -1
- package/components/grid/config/rowStylePicker.d.ts +19 -0
- package/components/grid/config/rowStylePicker.js +12 -0
- package/components/grid/config/rowStylePicker.js.map +1 -1
- package/components/grid/dataGrid.d.ts +331 -0
- package/components/grid/dataGrid.js +168 -11
- package/components/grid/dataGrid.js.map +1 -1
- package/components/grid/detail/detailHeaderPanel.d.ts +11 -0
- package/components/grid/detail/detailHeaderPanel.js +5 -0
- package/components/grid/detail/detailHeaderPanel.js.map +1 -1
- package/components/grid/export/contextMenu.d.ts +31 -0
- package/components/grid/export/contextMenu.js +8 -0
- package/components/grid/export/contextMenu.js.map +1 -1
- package/components/grid/export/progressPopup.d.ts +21 -0
- package/components/grid/export/progressPopup.js +17 -0
- package/components/grid/export/progressPopup.js.map +1 -1
- package/components/grid/export/worker/pdfExport.js +5 -0
- package/components/grid/export/worker/pdfExport.js.map +1 -1
- package/components/grid/extendedDataGrid.d.ts +240 -0
- package/components/grid/extendedDataGrid.js +116 -2
- package/components/grid/extendedDataGrid.js.map +1 -1
- package/components/grid/filter/customColumnFilter.d.ts +5 -0
- package/components/grid/filter/customColumnFilter.js +5 -0
- package/components/grid/filter/customColumnFilter.js.map +1 -1
- package/components/grid/filter/dataGridColumnFilter.d.ts +19 -0
- package/components/grid/filter/dataGridColumnFilter.js +19 -0
- package/components/grid/filter/dataGridColumnFilter.js.map +1 -1
- package/components/grid/filter/dateColumnFilter.d.ts +6 -0
- package/components/grid/filter/dateColumnFilter.js +6 -0
- package/components/grid/filter/dateColumnFilter.js.map +1 -1
- package/components/grid/filter/textColumnFilter.d.ts +6 -0
- package/components/grid/filter/textColumnFilter.js +6 -0
- package/components/grid/filter/textColumnFilter.js.map +1 -1
- package/components/grid/filter/wildcardQuickFilterEngine.d.ts +21 -0
- package/components/grid/filter/wildcardQuickFilterEngine.js +21 -0
- package/components/grid/filter/wildcardQuickFilterEngine.js.map +1 -1
- package/components/grid/header/simpleHeader.d.ts +17 -0
- package/components/grid/header/simpleHeader.js +20 -0
- package/components/grid/header/simpleHeader.js.map +1 -1
- package/components/grid/panel/dataGridPagination.d.ts +10 -0
- package/components/grid/panel/dataGridPagination.js +5 -0
- package/components/grid/panel/dataGridPagination.js.map +1 -1
- package/components/grid/panel/loadingOverlay.d.ts +5 -0
- package/components/grid/panel/loadingOverlay.js +4 -0
- package/components/grid/panel/loadingOverlay.js.map +1 -1
- package/components/grid/panel/noRecordsOverlay.d.ts +6 -0
- package/components/grid/panel/noRecordsOverlay.js +5 -0
- package/components/grid/panel/noRecordsOverlay.js.map +1 -1
- package/components/grid/panel/tablePagination.d.ts +4 -0
- package/components/grid/panel/tablePagination.js +4 -0
- package/components/grid/panel/tablePagination.js.map +1 -1
- package/components/icons/dropdownArrow.d.ts +3 -0
- package/components/icons/dropdownArrow.js +2 -0
- package/components/icons/dropdownArrow.js.map +1 -1
- package/components/icons/undoIcon.d.ts +2 -0
- package/components/icons/undoIcon.js +2 -0
- package/components/icons/undoIcon.js.map +1 -1
- package/components/input/autoCompleteInput.d.ts +29 -0
- package/components/input/autoCompleteInput.js +7 -0
- package/components/input/autoCompleteInput.js.map +1 -1
- package/components/input/draftUtils.d.ts +7 -0
- package/components/input/draftUtils.js +9 -0
- package/components/input/draftUtils.js.map +1 -1
- package/components/input/hexaFormattedInput.d.ts +9 -0
- package/components/input/hexaFormattedInput.js +3 -0
- package/components/input/hexaFormattedInput.js.map +1 -1
- package/components/input/mask/helpers.d.ts +27 -0
- package/components/input/mask/helpers.js +27 -0
- package/components/input/mask/helpers.js.map +1 -1
- package/components/input/mask/inputMaskCore.d.ts +80 -0
- package/components/input/mask/inputMaskCore.js +90 -0
- package/components/input/mask/inputMaskCore.js.map +1 -1
- package/components/input/mask/pattern.d.ts +24 -0
- package/components/input/mask/pattern.js +26 -0
- package/components/input/mask/pattern.js.map +1 -1
- package/components/input/maskedInput.d.ts +53 -0
- package/components/input/maskedInput.js +44 -4
- package/components/input/maskedInput.js.map +1 -1
- package/components/input/passwordInput.d.ts +7 -0
- package/components/input/passwordInput.js +8 -0
- package/components/input/passwordInput.js.map +1 -1
- package/components/input/simpleAutoComplete.d.ts +6 -0
- package/components/input/simpleAutoComplete.js +6 -0
- package/components/input/simpleAutoComplete.js.map +1 -1
- package/components/input/textarea/extractSpansOfClasses.d.ts +17 -0
- package/components/input/textarea/extractSpansOfClasses.js +26 -1
- package/components/input/textarea/extractSpansOfClasses.js.map +1 -1
- package/components/input/textarea/getRanges.d.ts +7 -0
- package/components/input/textarea/getRanges.js +11 -0
- package/components/input/textarea/getRanges.js.map +1 -1
- package/components/input/textarea/getType.d.ts +5 -0
- package/components/input/textarea/getType.js +5 -0
- package/components/input/textarea/getType.js.map +1 -1
- package/components/input/textarea/highlighedContents.d.ts +4 -0
- package/components/input/textarea/highlighedContents.js +5 -0
- package/components/input/textarea/highlighedContents.js.map +1 -1
- package/components/input/textarea/mentionsWithHighlighting.d.ts +25 -0
- package/components/input/textarea/mentionsWithHighlighting.js +14 -0
- package/components/input/textarea/mentionsWithHighlighting.js.map +1 -1
- package/components/keyboard/keyboardUtils.d.ts +6 -0
- package/components/keyboard/keyboardUtils.js +6 -0
- package/components/keyboard/keyboardUtils.js.map +1 -1
- package/components/modal/draggableModalProvider.d.ts +6 -0
- package/components/modal/draggableModalProvider.js +7 -0
- package/components/modal/draggableModalProvider.js.map +1 -1
- package/components/modal/impl/clamp.js +1 -0
- package/components/modal/impl/clamp.js.map +1 -1
- package/components/modal/impl/draggableModal.d.ts +1 -0
- package/components/modal/impl/draggableModal.js +6 -0
- package/components/modal/impl/draggableModal.js.map +1 -1
- package/components/modal/impl/draggableModalContext.js +1 -0
- package/components/modal/impl/draggableModalContext.js.map +1 -1
- package/components/modal/impl/draggableModalInner.js +12 -1
- package/components/modal/impl/draggableModalInner.js.map +1 -1
- package/components/modal/impl/draggableModalReducer.d.ts +7 -1
- package/components/modal/impl/draggableModalReducer.js +6 -1
- package/components/modal/impl/draggableModalReducer.js.map +1 -1
- package/components/modal/impl/draggableModalStyles.d.ts +17 -0
- package/components/modal/impl/draggableModalStyles.js +31 -0
- package/components/modal/impl/draggableModalStyles.js.map +1 -1
- package/components/modal/impl/getWindowSize.js +1 -0
- package/components/modal/impl/getWindowSize.js.map +1 -1
- package/components/modal/impl/index.js +1 -0
- package/components/modal/impl/index.js.map +1 -1
- package/components/modal/impl/resizeHandle.d.ts +1 -0
- package/components/modal/impl/resizeHandle.js +4 -1
- package/components/modal/impl/resizeHandle.js.map +1 -1
- package/components/modal/impl/useDrag.js +1 -0
- package/components/modal/impl/useDrag.js.map +1 -1
- package/components/modal/impl/usePrevious.js +1 -0
- package/components/modal/impl/usePrevious.js.map +1 -1
- package/components/modal/impl/useResize.js +1 -0
- package/components/modal/impl/useResize.js.map +1 -1
- package/components/modal/modalDialog.d.ts +85 -0
- package/components/modal/modalDialog.js +80 -10
- package/components/modal/modalDialog.js.map +1 -1
- package/components/picker/enumValuePicker.d.ts +17 -0
- package/components/picker/enumValuePicker.js +4 -0
- package/components/picker/enumValuePicker.js.map +1 -1
- package/components/platformSpecific.d.ts +17 -0
- package/components/platformSpecific.js +16 -0
- package/components/platformSpecific.js.map +1 -1
- package/components/scrollTo/onlyText.d.ts +5 -0
- package/components/scrollTo/onlyText.js +5 -0
- package/components/scrollTo/onlyText.js.map +1 -1
- package/components/scrollTo/scrollTo.d.ts +56 -0
- package/components/scrollTo/scrollTo.js +40 -3
- package/components/scrollTo/scrollTo.js.map +1 -1
- package/components/style/withCss.d.ts +15 -0
- package/components/style/withCss.js +6 -0
- package/components/style/withCss.js.map +1 -1
- package/components/table/dragSortingTable.d.ts +15 -0
- package/components/table/dragSortingTable.js +12 -0
- package/components/table/dragSortingTable.js.map +1 -1
- package/components/text/impl/innerSize.js +2 -0
- package/components/text/impl/innerSize.js.map +1 -1
- package/components/text/impl/series.d.ts +10 -0
- package/components/text/impl/series.js +10 -0
- package/components/text/impl/series.js.map +1 -1
- package/components/text/impl/shallowEqual.js +1 -0
- package/components/text/impl/shallowEqual.js.map +1 -1
- package/components/text/impl/whilst.d.ts +7 -0
- package/components/text/impl/whilst.js +7 -0
- package/components/text/impl/whilst.js.map +1 -1
- package/components/text/textFit.d.ts +24 -0
- package/components/text/textFit.js +29 -1
- package/components/text/textFit.js.map +1 -1
- package/i18n/componentsLocaleHolder.d.ts +9 -0
- package/i18n/componentsLocaleHolder.js +9 -0
- package/i18n/componentsLocaleHolder.js.map +1 -1
- package/package.json +66 -65
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 23.0.53
|
|
4
|
+
|
|
5
|
+
- `DateRangeInput`: time shift by month or year keeps an interval end that lies at the end of a month at the end of
|
|
6
|
+
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.
|
|
7
|
+
- The public API is documented with JSDoc and the published declaration files (`.d.ts`) keep the comments.
|
|
8
|
+
- The package ships `README.md` and `CHANGELOG.md`.
|
|
9
|
+
|
|
10
|
+
## 23.0.52
|
|
11
|
+
|
|
12
|
+
- `ExtendedDataGrid`: optional `detailPanel.onVisibleChange(visible)` handler, called when the splitter collapses or
|
|
13
|
+
expands the detail panel (collapse arrow or dragging the divider).
|
|
14
|
+
|
|
15
|
+
## 23.0.51
|
|
16
|
+
|
|
17
|
+
- pdfmake 0.2.23: `pdfmake/build/vfs_fonts` is a regular CommonJS module, vite applications need no workaround for
|
|
18
|
+
the PDF export worker anymore.
|
|
19
|
+
- `style/index.less` imports `antd/dist/reset.css` without the webpack-only `~` prefix.
|
|
20
|
+
- codemirror 5.65.20.
|
|
21
|
+
- Removed the unused `react-codemirror-runmode` dependency.
|
|
22
|
+
- The package no longer ships `tsconfig.json` and `tsconfig.build.json`.
|
|
23
|
+
|
|
24
|
+
## 23.0.50
|
|
25
|
+
|
|
26
|
+
- Grid export workers are standard `new Worker(new URL(...))` entry points: a webpack application emitting its
|
|
27
|
+
chunks into a subdirectory needs `output.publicPath: "auto"`.
|
package/README.md
ADDED
|
@@ -0,0 +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,4 +1,15 @@
|
|
|
1
|
+
/** Clipboard helpers. */
|
|
1
2
|
export declare class ClipboardUtils {
|
|
3
|
+
/**
|
|
4
|
+
* Copies text to the clipboard using a temporary `textarea` and `document.execCommand("copy")`.
|
|
5
|
+
* Must be called from a user event handler (e.g. click).
|
|
6
|
+
* @returns `true` when the copy succeeded; `false` when it failed or is not supported (failure is not always detectable)
|
|
7
|
+
*/
|
|
2
8
|
static copyToClipboard(text: string): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Reads text from the clipboard via the async Clipboard API (requires a secure context and the `clipboard-read`
|
|
11
|
+
* permission; the browser may prompt the user). On failure shows a localized error {@link ModalDialog}.
|
|
12
|
+
* @returns the clipboard text, or `undefined` when reading is not possible
|
|
13
|
+
*/
|
|
3
14
|
static readFromClipboard(): Promise<string | undefined>;
|
|
4
15
|
}
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import { ModalDialog } from "../modal/modalDialog";
|
|
2
2
|
import i18n from "d2core/i18n/i18n";
|
|
3
|
+
/** Clipboard helpers. */
|
|
3
4
|
export class ClipboardUtils {
|
|
5
|
+
/**
|
|
6
|
+
* Copies text to the clipboard using a temporary `textarea` and `document.execCommand("copy")`.
|
|
7
|
+
* Must be called from a user event handler (e.g. click).
|
|
8
|
+
* @returns `true` when the copy succeeded; `false` when it failed or is not supported (failure is not always detectable)
|
|
9
|
+
*/
|
|
4
10
|
static copyToClipboard(text) {
|
|
5
11
|
if (document.queryCommandSupported && document.queryCommandSupported("copy")) {
|
|
6
12
|
var textarea = document.createElement("textarea");
|
|
7
13
|
textarea.textContent = text;
|
|
8
|
-
textarea.style.position = "fixed";
|
|
14
|
+
textarea.style.position = "fixed"; // Prevent scrolling to bottom of page in MS Edge.
|
|
9
15
|
document.body.appendChild(textarea);
|
|
10
16
|
textarea.select();
|
|
11
17
|
try {
|
|
12
|
-
return document.execCommand("copy");
|
|
18
|
+
return document.execCommand("copy"); // Security exception may be thrown by some browsers.
|
|
13
19
|
}
|
|
14
20
|
catch (ex) {
|
|
15
21
|
console.warn("Copy to clipboard failed.", ex);
|
|
@@ -21,15 +27,21 @@ export class ClipboardUtils {
|
|
|
21
27
|
}
|
|
22
28
|
return false;
|
|
23
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Reads text from the clipboard via the async Clipboard API (requires a secure context and the `clipboard-read`
|
|
32
|
+
* permission; the browser may prompt the user). On failure shows a localized error {@link ModalDialog}.
|
|
33
|
+
* @returns the clipboard text, or `undefined` when reading is not possible
|
|
34
|
+
*/
|
|
24
35
|
static async readFromClipboard() {
|
|
25
36
|
if (navigator.clipboard && window.isSecureContext) {
|
|
37
|
+
// @ts-ignore
|
|
26
38
|
const permission = await navigator.permissions.query({ name: "clipboard-read" });
|
|
27
39
|
if (permission.state === "granted" || permission.state === "prompt") {
|
|
28
40
|
return await navigator.clipboard.readText();
|
|
29
41
|
}
|
|
30
42
|
else {
|
|
31
43
|
ModalDialog.error({
|
|
32
|
-
mode: "OK"
|
|
44
|
+
mode: "OK" /* ModalDialogMode.OK */,
|
|
33
45
|
title: i18n("Error reading data from clipboard"),
|
|
34
46
|
content: i18n("Clipboard not permitted")
|
|
35
47
|
});
|
|
@@ -37,7 +49,7 @@ export class ClipboardUtils {
|
|
|
37
49
|
}
|
|
38
50
|
else {
|
|
39
51
|
ModalDialog.error({
|
|
40
|
-
mode: "OK"
|
|
52
|
+
mode: "OK" /* ModalDialogMode.OK */,
|
|
41
53
|
title: i18n("Error reading data from clipboard"),
|
|
42
54
|
content: i18n("Secure context not available")
|
|
43
55
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clipboardUtils.js","sourceRoot":"","sources":["../../../../components/clipboard/clipboardUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAkB,MAAM,sBAAsB,CAAC;AAClE,OAAO,IAAI,MAAM,kBAAkB,CAAC;AAEpC,MAAM,OAAO,cAAc;
|
|
1
|
+
{"version":3,"file":"clipboardUtils.js","sourceRoot":"","sources":["../../../../components/clipboard/clipboardUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAkB,MAAM,sBAAsB,CAAC;AAClE,OAAO,IAAI,MAAM,kBAAkB,CAAC;AAEpC,yBAAyB;AACzB,MAAM,OAAO,cAAc;IACvB;;;;OAIG;IACH,MAAM,CAAC,eAAe,CAAC,IAAY;QAC/B,I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CAAC,mCAAmC,CAAC;oBAChD,OAAO,EAAE,IAAI,CAAC,yBAAyB,CAAC;iBAC3C,CAAC,CAAA;YACN,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,WAAW,CAAC,KAAK,CAAC;gBACd,IAAI,+BAAoB;gBACxB,KAAK,EAAE,IAAI,CAAC,mCAAmC,CAAC;gBAChD,OAAO,EAAE,IAAI,CAAC,8BAA8B,CAAC;aAChD,CAAC,CAAA;QACN,CAAC;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ","sourcesContent":["import {ModalDialog, ModalDialogMode} from \"../modal/modalDialog\";\r\nimport i18n from \"d2core/i18n/i18n\";\r\n\r\n/** Clipboard helpers. */\r\nexport class ClipboardUtils {\r\n /**\r\n * Copies text to the clipboard using a temporary `textarea` and `document.execCommand(\"copy\")`.\r\n * Must be called from a user event handler (e.g. click).\r\n * @returns `true` when the copy succeeded; `false` when it failed or is not supported (failure is not always detectable)\r\n */\r\n static copyToClipboard(text: string): boolean {\r\n if (document.queryCommandSupported && document.queryCommandSupported(\"copy\")) {\r\n var textarea = document.createElement(\"textarea\");\r\n textarea.textContent = text;\r\n textarea.style.position = \"fixed\"; // Prevent scrolling to bottom of page in MS Edge.\r\n document.body.appendChild(textarea);\r\n textarea.select();\r\n try {\r\n return document.execCommand(\"copy\"); // Security exception may be thrown by some browsers.\r\n } catch (ex) {\r\n console.warn(\"Copy to clipboard failed.\", ex);\r\n return false;\r\n } finally {\r\n document.body.removeChild(textarea);\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * Reads text from the clipboard via the async Clipboard API (requires a secure context and the `clipboard-read`\r\n * permission; the browser may prompt the user). On failure shows a localized error {@link ModalDialog}.\r\n * @returns the clipboard text, or `undefined` when reading is not possible\r\n */\r\n static async readFromClipboard(): Promise<string | undefined> {\r\n if (navigator.clipboard && window.isSecureContext) {\r\n // @ts-ignore\r\n const permission = await navigator.permissions.query({ name: \"clipboard-read\" });\r\n if (permission.state === \"granted\" || permission.state === \"prompt\") {\r\n return await navigator.clipboard.readText();\r\n } else {\r\n ModalDialog.error({\r\n mode: ModalDialogMode.OK,\r\n title: i18n(\"Error reading data from clipboard\"),\r\n content: i18n(\"Clipboard not permitted\")\r\n })\r\n }\r\n } else {\r\n ModalDialog.error({\r\n mode: ModalDialogMode.OK,\r\n title: i18n(\"Error reading data from clipboard\"),\r\n content: i18n(\"Secure context not available\")\r\n })\r\n }\r\n return undefined;\r\n }\r\n}"]}
|
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import 'codemirror/addon/runmode/runmode';
|
|
3
3
|
import 'codemirror/mode/meta';
|
|
4
|
+
/** Props of {@link SyntaxHighlighter}. */
|
|
4
5
|
interface SyntaxHighlighterProps {
|
|
6
|
+
/** Extra class of the `<pre>` element (block mode only). */
|
|
5
7
|
className?: string;
|
|
8
|
+
/** CodeMirror theme name; adds the `${prefix}s-${theme}` class. */
|
|
6
9
|
theme?: string;
|
|
10
|
+
/** Renders just a `<code>` element (inline) instead of `<pre><code>` (block). */
|
|
7
11
|
inline?: boolean;
|
|
12
|
+
/** CodeMirror mode (language) used for tokenizing, e.g. `"javascript"`; the mode must be loaded. */
|
|
8
13
|
mode: string;
|
|
14
|
+
/** Prefix of the CSS classes generated for token styles. @default 'cm-' */
|
|
9
15
|
prefix?: string;
|
|
16
|
+
/** Source code to highlight. */
|
|
10
17
|
value: string;
|
|
18
|
+
/** When set, text longer than 100 characters is truncated with `" ..."` and the full text is shown as the element title. */
|
|
11
19
|
tooltip?: boolean;
|
|
12
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Read-only syntax highlighter: tokenizes `value` with CodeMirror's `runMode` and renders the tokens as `<span>`s
|
|
23
|
+
* with `${prefix}${style}` classes (styling comes from the CodeMirror theme CSS). No editor instance is created.
|
|
24
|
+
*/
|
|
13
25
|
export default class SyntaxHighlighter extends React.Component<SyntaxHighlighterProps> {
|
|
26
|
+
/** Default prop values. */
|
|
14
27
|
static defaultProps: {
|
|
15
28
|
className: string;
|
|
16
29
|
prefix: string;
|
|
@@ -2,6 +2,10 @@ import React from 'react';
|
|
|
2
2
|
import CodeMirror from 'codemirror';
|
|
3
3
|
import 'codemirror/addon/runmode/runmode';
|
|
4
4
|
import 'codemirror/mode/meta';
|
|
5
|
+
/**
|
|
6
|
+
* Read-only syntax highlighter: tokenizes `value` with CodeMirror's `runMode` and renders the tokens as `<span>`s
|
|
7
|
+
* with `${prefix}${style}` classes (styling comes from the CodeMirror theme CSS). No editor instance is created.
|
|
8
|
+
*/
|
|
5
9
|
class SyntaxHighlighter extends React.Component {
|
|
6
10
|
constructor(props) {
|
|
7
11
|
super(props);
|
|
@@ -32,12 +36,13 @@ class SyntaxHighlighter extends React.Component {
|
|
|
32
36
|
elements.push(React.createElement("span", { className: lastStyle ? prefix + lastStyle : '', key: ++index }, tokenBuf));
|
|
33
37
|
let tooltipText = undefined;
|
|
34
38
|
if (tooltip && trimmedValue !== value) {
|
|
35
|
-
tooltipText = value;
|
|
39
|
+
tooltipText = value; //.replace("\t","	").replace("\n","
");
|
|
36
40
|
}
|
|
37
41
|
const code = (React.createElement("code", { title: tooltipText, className: inline ? `inline ${prefix}s-${theme}` : '' }, elements));
|
|
38
42
|
return inline ? (code) : (React.createElement("pre", { className: `${className} ${prefix}s-${theme}` }, code));
|
|
39
43
|
}
|
|
40
44
|
}
|
|
45
|
+
/** Default prop values. */
|
|
41
46
|
SyntaxHighlighter.defaultProps = {
|
|
42
47
|
className: '',
|
|
43
48
|
prefix: 'cm-'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SyntaxHighlighter.js","sourceRoot":"","sources":["../../../../components/codemirror/SyntaxHighlighter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,kCAAkC,CAAA;AACzC,OAAO,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,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AAG,QAAQ,CAAQ,CAAC,CAAC;gBACzG,CAAC;gBACD,QAAQ,GAAG,KAAK,CAAA;gBAChB,SAAS,GAAG,KAAK,CAAA;YACrB,CAAC;QACL,CAAC,CAAC,CAAA;QACF,QAAQ,CAAC,IAAI,CAAC,8BAAM,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,KAAK,IAAG,QAAQ,CAAQ,CAAC,CAAC;QAErG,IAAI,WAAW,GAAuB,SAAS,CAAC;QAChD,IAAG,OAAO,IAAI,YAAY,KAAK,KAAK,EAAE,CAAC;YACnC,WAAW,GAAG,KAAK,CAAC,CAAA,uDAAuD;QAC/E,CAAC;QACD,MAAM,IAAI,GAAG,CAAC,8BAAM,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,UAAU,MAAM,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,IAAG,QAAQ,CAAQ,CAAC,CAAC;QAClH,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,6BAAK,SAAS,EAAE,GAAG,SAAS,IAAI,MAAM,KAAK,KAAK,EAAE,IAAG,IAAI,CAAO,CAAC,CAAC;IAChG,CAAC;;AAxCD,2BAA2B;AACpB,8BAAY,GAAG;IAClB,SAAS,EAAE,EAAE;IACb,MAAM,EAAE,KAAK;CAChB,CAAA;eALgB,iBAAiB","sourcesContent":["import React from 'react'\r\nimport CodeMirror from 'codemirror';\r\nimport 'codemirror/addon/runmode/runmode'\r\nimport 'codemirror/mode/meta'\r\n\r\n/** Props of {@link SyntaxHighlighter}. */\r\ninterface SyntaxHighlighterProps {\r\n // codeMirror: typeof CodeMirror\r\n /** Extra class of the `<pre>` element (block mode only). */\r\n className?: string\r\n /** CodeMirror theme name; adds the `${prefix}s-${theme}` class. */\r\n theme?: string\r\n /** Renders just a `<code>` element (inline) instead of `<pre><code>` (block). */\r\n inline?: boolean\r\n /** CodeMirror mode (language) used for tokenizing, e.g. `\"javascript\"`; the mode must be loaded. */\r\n mode: string\r\n /** Prefix of the CSS classes generated for token styles. @default 'cm-' */\r\n prefix?: string\r\n /** Source code to highlight. */\r\n value: string\r\n /** When set, text longer than 100 characters is truncated with `\" ...\"` and the full text is shown as the element title. */\r\n tooltip?:boolean\r\n}\r\n\r\n/**\r\n * Read-only syntax highlighter: tokenizes `value` with CodeMirror's `runMode` and renders the tokens as `<span>`s\r\n * with `${prefix}${style}` classes (styling comes from the CodeMirror theme CSS). No editor instance is created.\r\n */\r\nexport default class SyntaxHighlighter extends React.Component<SyntaxHighlighterProps> {\r\n /** Default prop values. */\r\n static defaultProps = {\r\n className: '',\r\n prefix: 'cm-'\r\n }\r\n\r\n constructor(props: Readonly<SyntaxHighlighterProps>) {\r\n super(props);\r\n }\r\n\r\n render() {\r\n const {inline, value, mode, className, prefix, theme, tooltip} = this.props\r\n const elements: React.ReactNode[] = []\r\n let index = 0\r\n let lastStyle: string | null | undefined = null\r\n let tokenBuf = ''\r\n let trimmedValue = value;\r\n if( tooltip && value.length > 100) {\r\n trimmedValue = value.substring(0, 100) + \" ...\";\r\n }\r\n CodeMirror.runMode(trimmedValue, mode, (token, style) => {\r\n if (lastStyle === style) {\r\n tokenBuf += token\r\n lastStyle = style\r\n } else {\r\n if (tokenBuf) {\r\n elements.push(<span className={lastStyle ? prefix + lastStyle : ''} key={++index}>{tokenBuf}</span>);\r\n }\r\n tokenBuf = token\r\n lastStyle = style\r\n }\r\n })\r\n elements.push(<span className={lastStyle ? prefix + lastStyle : ''} key={++index}>{tokenBuf}</span>);\r\n\r\n let tooltipText: undefined | string = undefined;\r\n if(tooltip && trimmedValue !== value) {\r\n tooltipText = value;//.replace(\"\\t\",\"	\").replace(\"\\n\",\"
\");\r\n }\r\n const code = (<code title={tooltipText} className={inline ? `inline ${prefix}s-${theme}` : ''}>{elements}</code>);\r\n return inline ? (code) : (<pre className={`${className} ${prefix}s-${theme}`}>{code}</pre>);\r\n }\r\n}"]}
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
/** Props of {@link Expandable}. */
|
|
2
3
|
interface ExpandableProps {
|
|
4
|
+
/** Content shown in the animated collapsible section; when missing, no expand toggle is rendered. */
|
|
3
5
|
extraContent?: React.ReactNode;
|
|
6
|
+
/** Whether the extra content is expanded (controlled). */
|
|
4
7
|
expanded?: boolean;
|
|
8
|
+
/** Uses smaller vertical margins around the divider (8px instead of 20px). */
|
|
5
9
|
compact?: boolean;
|
|
10
|
+
/** Always visible content, rendered above the collapsible section. */
|
|
6
11
|
children?: React.ReactNode;
|
|
12
|
+
/** Called with the requested new state when the toggle arrow in the divider is clicked. */
|
|
7
13
|
onExpand?(expanded: boolean): void;
|
|
8
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Section with always visible content (`children`) and an animated collapsible `extraContent`, followed by a divider
|
|
17
|
+
* with an arrow toggle. Controlled: the parent must update `expanded` in {@link ExpandableProps.onExpand}.
|
|
18
|
+
*/
|
|
9
19
|
export default class Expandable extends React.Component<ExpandableProps> {
|
|
10
20
|
constructor(props: Readonly<ExpandableProps>);
|
|
11
21
|
render(): React.ReactNode;
|
|
@@ -2,6 +2,10 @@ import React from "react";
|
|
|
2
2
|
import { Divider } from "antd";
|
|
3
3
|
import { DoubleRightOutlined } from "@ant-design/icons";
|
|
4
4
|
import { Collapse } from 'react-collapse';
|
|
5
|
+
/**
|
|
6
|
+
* Section with always visible content (`children`) and an animated collapsible `extraContent`, followed by a divider
|
|
7
|
+
* with an arrow toggle. Controlled: the parent must update `expanded` in {@link ExpandableProps.onExpand}.
|
|
8
|
+
*/
|
|
5
9
|
export default class Expandable extends React.Component {
|
|
6
10
|
constructor(props) {
|
|
7
11
|
super(props);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expandable.js","sourceRoot":"","sources":["../../../../components/collapse/expandable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IAAI,oBAAC,mBAAmB,IAC5C,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EACtC,OAAO,EAAE,GAAG,EAAE;;oBACV,MAAM,QAAQ,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;oBACtC,MAAA,MAAA,IAAI,CAAC,KAAK,EAAC,QAAQ,mDAAG,QAAQ,CAAC,CAAC;gBACpC,CAAC,GACH,CACI,CACR,CACT,CAAA;IACL,CAAC;CAEJ","sourcesContent":["import React from \"react\";\r\nimport {Divider} from \"antd\";\r\nimport {DoubleRightOutlined} from \"@ant-design/icons\";\r\nimport {Collapse} from 'react-collapse';\r\n\r\n/** Props of {@link Expandable}. */\r\ninterface ExpandableProps {\r\n /** Content shown in the animated collapsible section; when missing, no expand toggle is rendered. */\r\n extraContent?: React.ReactNode\r\n /** Whether the extra content is expanded (controlled). */\r\n expanded?: boolean\r\n /** Uses smaller vertical margins around the divider (8px instead of 20px). */\r\n compact?: boolean\r\n /** Always visible content, rendered above the collapsible section. */\r\n children?: React.ReactNode;\r\n\r\n /** Called with the requested new state when the toggle arrow in the divider is clicked. */\r\n onExpand?(expanded: boolean): void\r\n}\r\n\r\n/**\r\n * Section with always visible content (`children`) and an animated collapsible `extraContent`, followed by a divider\r\n * with an arrow toggle. Controlled: the parent must update `expanded` in {@link ExpandableProps.onExpand}.\r\n */\r\nexport default class Expandable extends React.Component<ExpandableProps> {\r\n constructor(props: Readonly<ExpandableProps>) {\r\n super(props);\r\n }\r\n\r\n render(): React.ReactNode {\r\n return (\r\n <div style={{transition: \"height .5s\"}}>\r\n <header>\r\n {this.props.children}\r\n </header>\r\n <Collapse isOpened={!!this.props.expanded}>\r\n <section style={{marginTop: 5}}>\r\n {this.props.extraContent}\r\n </section>\r\n </Collapse>\r\n <Divider\r\n style={{margin: this.props.compact ? \"8px 0px\" : \"20px 0px\"}}\r\n className={this.props.extraContent ? \"stronger-divider-with-text\" : \"stronger-divider\"}\r\n plain\r\n >\r\n {this.props.extraContent && <DoubleRightOutlined\r\n rotate={this.props.expanded ? -90 : 90}\r\n onClick={() => {\r\n const expanded = !this.props.expanded;\r\n this.props.onExpand?.(expanded);\r\n }}\r\n />}\r\n </Divider>\r\n </div>\r\n )\r\n }\r\n\r\n}"]}
|
|
@@ -1,17 +1,33 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { SketchPickerProps } from "react-color/lib/components/sketch/Sketch";
|
|
3
3
|
import { TooltipPlacement } from "antd/lib/tooltip";
|
|
4
|
+
/**
|
|
5
|
+
* Props of {@link ColorPicker}. The inherited `color`, `onChange`, `onChangeComplete` and `className` props
|
|
6
|
+
* are used; `color` is controlled.
|
|
7
|
+
*/
|
|
4
8
|
interface ColorPickerProps extends SketchPickerProps {
|
|
9
|
+
/** Optional icon shown as a badge on the color button. */
|
|
5
10
|
badgeIcon?: React.ReactNode;
|
|
11
|
+
/** Title of the popover and tooltip of the color button. */
|
|
6
12
|
title: string;
|
|
13
|
+
/** Placement of the popover relative to the button. */
|
|
7
14
|
placement?: TooltipPlacement;
|
|
15
|
+
/** Disables the button and prevents opening the popover. */
|
|
8
16
|
disabled?: boolean;
|
|
17
|
+
/** Adds `"transparent"` to the preset colors. */
|
|
9
18
|
transparentColorAllowed?: boolean;
|
|
19
|
+
/** Called when the "Set No Color" button is clicked; the popover is closed afterwards. */
|
|
10
20
|
onResetColor(): void;
|
|
11
21
|
}
|
|
22
|
+
/** State of {@link ColorPicker}. */
|
|
12
23
|
interface ColorPickerState {
|
|
24
|
+
/** Whether the popover is open. */
|
|
13
25
|
popupVisible: boolean;
|
|
14
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Button filled with the current color (a checkerboard when no color is set) that opens a popover with
|
|
29
|
+
* a react-color `SketchPicker` (antd palette presets), a "Set No Color" button and a close button.
|
|
30
|
+
*/
|
|
15
31
|
export default class ColorPicker extends React.Component<ColorPickerProps, ColorPickerState> {
|
|
16
32
|
constructor(props: Readonly<ColorPickerProps>);
|
|
17
33
|
private getColorString;
|
|
@@ -14,6 +14,10 @@ const presetColors = [
|
|
|
14
14
|
"#e6f7ff", "#bae7ff", "#91d5ff", "#69c0ff", "#40a9ff", "#1890ff", "#096dd9", "#0050b3", "#003a8c", "#002766",
|
|
15
15
|
"#ffffff", "#fafafa", "#f5f5f5", "#e8e8e8", "#d9d9d9", "#bfbfbf", "#8c8c8c", "#595959", "#262626", "#000000",
|
|
16
16
|
];
|
|
17
|
+
/**
|
|
18
|
+
* Button filled with the current color (a checkerboard when no color is set) that opens a popover with
|
|
19
|
+
* a react-color `SketchPicker` (antd palette presets), a "Set No Color" button and a close button.
|
|
20
|
+
*/
|
|
17
21
|
export default class ColorPicker extends React.Component {
|
|
18
22
|
constructor(props) {
|
|
19
23
|
super(props);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colorPicker.js","sourceRoot":"","sources":["../../../../components/color/colorPicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,OAAO,EAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAC,MAAM,MAAM,CAAC;AAC5C,OAAO,EAAC,aAAa,EAAE,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAW,YAAY,EAAC,MAAM,aAAa,CAAC;AAInD,MAAM,0BAA0B,GAAG,6LAA6L,CAAA;AAChO,MAAM,YAAY,GAAG;IACjB,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS;IAC5G,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS;IAC5G,SAAS,EAAE,SA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AE,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,GAAG,YAAY,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,YAAY,EAClG,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAC7B,gBAAgB,EAAE,IAAI,CAAC,KAAK,CAAC,gBAAgB,GAC/C;YAGN,oBAAC,KAAK,IACF,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAC/B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;oBACzB,8BACI,SAAS,EAAC,iBAAiB,EAC3B,KAAK,EAAE,EAAC,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAC,IAEnE,IAAI,CAAC,KAAK,CAAC,SAAS,CAClB;oBACX,CAAC,CAAC,SAAS;gBAGf,oBAAC,MAAM,IACH,KAAK,EAAE,EAAC,UAAU,EAAE,MAAA,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,KAAsC,CAAC,mCAAI,0BAA0B,EAAC,EACzH,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAC7B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK;oBAEvB,8BAAM,IAAI,EAAC,KAAK,EAAC,SAAS,EAAC,SAAS,GAAE,CACjC,CACL,CACF,CACb,CAAC;IACN,CAAC;CAEJ","sourcesContent":["import React from \"react\";\r\nimport i18n from \"d2core/i18n/i18n\";\r\nimport {Badge, Button, Popover} from \"antd\";\r\nimport {CloseOutlined, StopOutlined} from \"@ant-design/icons\";\r\nimport {RGBColor, SketchPicker} from \"react-color\";\r\nimport {SketchPickerProps} from \"react-color/lib/components/sketch/Sketch\";\r\nimport {TooltipPlacement} from \"antd/lib/tooltip\";\r\n\r\nconst transparentBackgroundStyle = \"url(\\\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAMUlEQVQ4T2NkYGAQYcAP3uCTZhw1gGGYhAGBZIA/nYDCgBDAm9BGDWAAJyRCgLaBCAAgXwixzAS0pgAAAABJRU5ErkJggg==\\\") left center\"\r\nconst presetColors = [\r\n \"#fff1f0\", \"#ffccc7\", \"#ffa39e\", \"#ff7875\", \"#ff4d4f\", \"#f5222d\", \"#cf1322\", \"#a8071a\", \"#820014\", \"#5c0011\",\r\n \"#fff2e8\", \"#ffd8bf\", \"#ffbb96\", \"#ff9c6e\", \"#ff7a45\", \"#fa541c\", \"#d4380d\", \"#ad2102\", \"#871400\", \"#610b00\",\r\n \"#fff7e6\", \"#ffe7ba\", \"#ffd591\", \"#ffc069\", \"#ffa940\", \"#fa8c16\", \"#d46b08\", \"#ad4e00\", \"#873800\", \"#612500\",\r\n \"#feffe6\", \"#ffffb8\", \"#fffb8f\", \"#fff566\", \"#ffec3d\", \"#fadb14\", \"#d4b106\", \"#ad8b00\", \"#876800\", \"#614700\",\r\n \"#f6ffed\", \"#d9f7be\", \"#b7eb8f\", \"#95de64\", \"#73d13d\", \"#52c41a\", \"#389e0d\", \"#237804\", \"#135200\", \"#092b00\",\r\n \"#e6fffb\", \"#b5f5ec\", \"#87e8de\", \"#5cdbd3\", \"#36cfc9\", \"#13c2c2\", \"#08979c\", \"#006d75\", \"#00474f\", \"#002329\",\r\n \"#e6f7ff\", \"#bae7ff\", \"#91d5ff\", \"#69c0ff\", \"#40a9ff\", \"#1890ff\", \"#096dd9\", \"#0050b3\", \"#003a8c\", \"#002766\",\r\n \"#ffffff\", \"#fafafa\", \"#f5f5f5\", \"#e8e8e8\", \"#d9d9d9\", \"#bfbfbf\", \"#8c8c8c\", \"#595959\", \"#262626\", \"#000000\",\r\n];\r\n\r\ninterface ColorPickerProps extends SketchPickerProps {\r\n badgeIcon?: React.ReactNode\r\n title: string\r\n placement?: TooltipPlacement\r\n disabled?: boolean\r\n transparentColorAllowed?: boolean\r\n\r\n onResetColor(): void\r\n}\r\n\r\ninterface ColorPickerState {\r\n popupVisible: boolean\r\n}\r\n\r\nexport default class ColorPicker extends React.Component<ColorPickerProps, ColorPickerState> {\r\n constructor(props: Readonly<ColorPickerProps>) {\r\n super(props);\r\n\r\n this.state = {\r\n popupVisible: false,\r\n }\r\n }\r\n\r\n private getColorString(color: RGBColor | string | undefined): string | undefined {\r\n if (typeof color === \"object\") {\r\n return `rgba(${color.r},${color.g},${color.b},${color.a})`;\r\n } else {\r\n return color;\r\n }\r\n }\r\n\r\n render() {\r\n return (\r\n <Popover\r\n placement={this.props.placement}\r\n trigger={this.props.disabled ? [] : \"click\"}\r\n open={this.state.popupVisible}\r\n onOpenChange={(visible) => {\r\n this.setState({popupVisible: visible});\r\n }}\r\n title={\r\n <div>\r\n {this.props.title}\r\n <Button\r\n style={{float: \"right\", paddingLeft: 8, border: \"none\"}}\r\n size=\"small\"\r\n title={i18n(\"Close\")}\r\n onClick={() => {\r\n this.setState({popupVisible: false});\r\n }}\r\n >\r\n <CloseOutlined/>\r\n </Button>\r\n <Button\r\n style={{background: transparentBackgroundStyle, float: \"right\"}}\r\n size=\"small\"\r\n title={i18n(\"Set No Color\")}\r\n onClick={() => {\r\n this.props.onResetColor();\r\n this.setState({popupVisible: false});\r\n }}\r\n >\r\n <StopOutlined style={{color: \"rgba(0,0,0,0.85)\"}}/>\r\n </Button>\r\n </div>\r\n }\r\n content={\r\n <SketchPicker\r\n color={this.props.color}\r\n width={\"250px\"}\r\n presetColors={this.props.transparentColorAllowed ? [...presetColors, \"transparent\"] : presetColors}\r\n onChange={this.props.onChange}\r\n onChangeComplete={this.props.onChangeComplete}\r\n />\r\n }\r\n >\r\n <Badge\r\n className={this.props.className}\r\n count={this.props.badgeIcon ?\r\n <span\r\n className=\"ant-badge-count\"\r\n style={{color: \"#1890ff\", background: \"#e6f7ff\", borderColor: \"#91d5ff\"}}\r\n >\r\n {this.props.badgeIcon}\r\n </span>\r\n : undefined\r\n }\r\n >\r\n <Button\r\n style={{background: this.getColorString(this.props.color as RGBColor | string | undefined) ?? transparentBackgroundStyle}}\r\n disabled={this.props.disabled}\r\n title={this.props.title}\r\n >\r\n <span role=\"img\" className=\"anticon\"/>\r\n </Button>\r\n </Badge>\r\n </Popover>\r\n );\r\n }\r\n\r\n}"]}
|
|
1
|
+
{"version":3,"file":"colorPicker.js","sourceRoot":"","sources":["../../../../components/color/colorPicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,OAAO,EAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAC,MAAM,MAAM,CAAC;AAC5C,OAAO,EAAC,aAAa,EAAE,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAW,YAAY,EAAC,MAAM,aAAa,CAAC;AAInD,MAAM,0BAA0B,GAAG,6LAA6L,CAAA;AAChO,MAAM,YAAY,GAAG;IACjB,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS;IAC5G,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS;IAC5G,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS;IAC5G,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS;IAC5G,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS;IAC5G,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SA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AC,iBAAiB,EAC3B,KAAK,EAAE,EAAC,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAC,IAEnE,IAAI,CAAC,KAAK,CAAC,SAAS,CAClB;oBACX,CAAC,CAAC,SAAS;gBAGf,oBAAC,MAAM,IACH,KAAK,EAAE,EAAC,UAAU,EAAE,MAAA,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,KAAsC,CAAC,mCAAI,0BAA0B,EAAC,EACzH,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAC7B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK;oBAEvB,8BAAM,IAAI,EAAC,KAAK,EAAC,SAAS,EAAC,SAAS,GAAE,CACjC,CACL,CACF,CACb,CAAC;IACN,CAAC;CAEJ","sourcesContent":["import React from \"react\";\r\nimport i18n from \"d2core/i18n/i18n\";\r\nimport {Badge, Button, Popover} from \"antd\";\r\nimport {CloseOutlined, StopOutlined} from \"@ant-design/icons\";\r\nimport {RGBColor, SketchPicker} from \"react-color\";\r\nimport {SketchPickerProps} from \"react-color/lib/components/sketch/Sketch\";\r\nimport {TooltipPlacement} from \"antd/lib/tooltip\";\r\n\r\nconst transparentBackgroundStyle = \"url(\\\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAMUlEQVQ4T2NkYGAQYcAP3uCTZhw1gGGYhAGBZIA/nYDCgBDAm9BGDWAAJyRCgLaBCAAgXwixzAS0pgAAAABJRU5ErkJggg==\\\") left center\"\r\nconst presetColors = [\r\n \"#fff1f0\", \"#ffccc7\", \"#ffa39e\", \"#ff7875\", \"#ff4d4f\", \"#f5222d\", \"#cf1322\", \"#a8071a\", \"#820014\", \"#5c0011\",\r\n \"#fff2e8\", \"#ffd8bf\", \"#ffbb96\", \"#ff9c6e\", \"#ff7a45\", \"#fa541c\", \"#d4380d\", \"#ad2102\", \"#871400\", \"#610b00\",\r\n \"#fff7e6\", \"#ffe7ba\", \"#ffd591\", \"#ffc069\", \"#ffa940\", \"#fa8c16\", \"#d46b08\", \"#ad4e00\", \"#873800\", \"#612500\",\r\n \"#feffe6\", \"#ffffb8\", \"#fffb8f\", \"#fff566\", \"#ffec3d\", \"#fadb14\", \"#d4b106\", \"#ad8b00\", \"#876800\", \"#614700\",\r\n \"#f6ffed\", \"#d9f7be\", \"#b7eb8f\", \"#95de64\", \"#73d13d\", \"#52c41a\", \"#389e0d\", \"#237804\", \"#135200\", \"#092b00\",\r\n \"#e6fffb\", \"#b5f5ec\", \"#87e8de\", \"#5cdbd3\", \"#36cfc9\", \"#13c2c2\", \"#08979c\", \"#006d75\", \"#00474f\", \"#002329\",\r\n \"#e6f7ff\", \"#bae7ff\", \"#91d5ff\", \"#69c0ff\", \"#40a9ff\", \"#1890ff\", \"#096dd9\", \"#0050b3\", \"#003a8c\", \"#002766\",\r\n \"#ffffff\", \"#fafafa\", \"#f5f5f5\", \"#e8e8e8\", \"#d9d9d9\", \"#bfbfbf\", \"#8c8c8c\", \"#595959\", \"#262626\", \"#000000\",\r\n];\r\n\r\n/**\r\n * Props of {@link ColorPicker}. The inherited `color`, `onChange`, `onChangeComplete` and `className` props\r\n * are used; `color` is controlled.\r\n */\r\ninterface ColorPickerProps extends SketchPickerProps {\r\n /** Optional icon shown as a badge on the color button. */\r\n badgeIcon?: React.ReactNode\r\n /** Title of the popover and tooltip of the color button. */\r\n title: string\r\n /** Placement of the popover relative to the button. */\r\n placement?: TooltipPlacement\r\n /** Disables the button and prevents opening the popover. */\r\n disabled?: boolean\r\n /** Adds `\"transparent\"` to the preset colors. */\r\n transparentColorAllowed?: boolean\r\n\r\n /** Called when the \"Set No Color\" button is clicked; the popover is closed afterwards. */\r\n onResetColor(): void\r\n}\r\n\r\n/** State of {@link ColorPicker}. */\r\ninterface ColorPickerState {\r\n /** Whether the popover is open. */\r\n popupVisible: boolean\r\n}\r\n\r\n/**\r\n * Button filled with the current color (a checkerboard when no color is set) that opens a popover with\r\n * a react-color `SketchPicker` (antd palette presets), a \"Set No Color\" button and a close button.\r\n */\r\nexport default class ColorPicker extends React.Component<ColorPickerProps, ColorPickerState> {\r\n constructor(props: Readonly<ColorPickerProps>) {\r\n super(props);\r\n\r\n this.state = {\r\n popupVisible: false,\r\n }\r\n }\r\n\r\n private getColorString(color: RGBColor | string | undefined): string | undefined {\r\n if (typeof color === \"object\") {\r\n return `rgba(${color.r},${color.g},${color.b},${color.a})`;\r\n } else {\r\n return color;\r\n }\r\n }\r\n\r\n render() {\r\n return (\r\n <Popover\r\n placement={this.props.placement}\r\n trigger={this.props.disabled ? [] : \"click\"}\r\n open={this.state.popupVisible}\r\n onOpenChange={(visible) => {\r\n this.setState({popupVisible: visible});\r\n }}\r\n title={\r\n <div>\r\n {this.props.title}\r\n <Button\r\n style={{float: \"right\", paddingLeft: 8, border: \"none\"}}\r\n size=\"small\"\r\n title={i18n(\"Close\")}\r\n onClick={() => {\r\n this.setState({popupVisible: false});\r\n }}\r\n >\r\n <CloseOutlined/>\r\n </Button>\r\n <Button\r\n style={{background: transparentBackgroundStyle, float: \"right\"}}\r\n size=\"small\"\r\n title={i18n(\"Set No Color\")}\r\n onClick={() => {\r\n this.props.onResetColor();\r\n this.setState({popupVisible: false});\r\n }}\r\n >\r\n <StopOutlined style={{color: \"rgba(0,0,0,0.85)\"}}/>\r\n </Button>\r\n </div>\r\n }\r\n content={\r\n <SketchPicker\r\n color={this.props.color}\r\n width={\"250px\"}\r\n presetColors={this.props.transparentColorAllowed ? [...presetColors, \"transparent\"] : presetColors}\r\n onChange={this.props.onChange}\r\n onChangeComplete={this.props.onChangeComplete}\r\n />\r\n }\r\n >\r\n <Badge\r\n className={this.props.className}\r\n count={this.props.badgeIcon ?\r\n <span\r\n className=\"ant-badge-count\"\r\n style={{color: \"#1890ff\", background: \"#e6f7ff\", borderColor: \"#91d5ff\"}}\r\n >\r\n {this.props.badgeIcon}\r\n </span>\r\n : undefined\r\n }\r\n >\r\n <Button\r\n style={{background: this.getColorString(this.props.color as RGBColor | string | undefined) ?? transparentBackgroundStyle}}\r\n disabled={this.props.disabled}\r\n title={this.props.title}\r\n >\r\n <span role=\"img\" className=\"anticon\"/>\r\n </Button>\r\n </Badge>\r\n </Popover>\r\n );\r\n }\r\n\r\n}"]}
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single color square (based on react-color's `Swatch`) that can be marked as selected. The default export adds the
|
|
3
|
+
* hover zoom; this named export is the bare component that receives `hover` from outside.
|
|
4
|
+
*
|
|
5
|
+
* Props:
|
|
6
|
+
* - `color` - color of the swatch; must be a hex string (e.g. `"#ff0000"`) when `active` is set.
|
|
7
|
+
* - `active` - marks the swatch as selected: it is enlarged and shows a check mark in black or white, whichever
|
|
8
|
+
* contrasts better.
|
|
9
|
+
* - `small` - renders a 15px swatch without the hover zoom instead of the default 22px one.
|
|
10
|
+
* - `onClick(color, event)` - called on click or Enter key; receives the `color` prop value as passed (not a converted
|
|
11
|
+
* react-color `ColorResult`).
|
|
12
|
+
* - `onSwatchHover(color, event)` - called when the mouse enters the swatch; receives the `color` prop value as passed.
|
|
13
|
+
* - `title` - tooltip of the swatch; defaults to the color value.
|
|
14
|
+
* - `style` - style of the inner swatch element.
|
|
15
|
+
* - `hover` - whether the swatch is hovered (enlarges it unless `small`); supplied by the default export.
|
|
16
|
+
*/
|
|
1
17
|
export function ColorSwatch({ hover, color, onClick, onSwatchHover, style, title, active, small }: {
|
|
2
18
|
hover: any;
|
|
3
19
|
color: any;
|
|
@@ -5,6 +5,7 @@ function invertColor(hex, bw) {
|
|
|
5
5
|
if (hex.indexOf('#') === 0) {
|
|
6
6
|
hex = hex.slice(1);
|
|
7
7
|
}
|
|
8
|
+
// convert 3-digit hex to 6-digits.
|
|
8
9
|
if (hex.length === 3) {
|
|
9
10
|
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
|
|
10
11
|
}
|
|
@@ -13,16 +14,35 @@ function invertColor(hex, bw) {
|
|
|
13
14
|
}
|
|
14
15
|
var r = parseInt(hex.slice(0, 2), 16), g = parseInt(hex.slice(2, 4), 16), b = parseInt(hex.slice(4, 6), 16);
|
|
15
16
|
if (bw) {
|
|
17
|
+
// http://stackoverflow.com/a/3943023/112731
|
|
16
18
|
return (r * 0.299 + g * 0.587 + b * 0.114) > 186
|
|
17
19
|
? '#000000'
|
|
18
20
|
: '#FFFFFF';
|
|
19
21
|
}
|
|
22
|
+
// invert color components
|
|
20
23
|
r = (255 - r).toString(16);
|
|
21
24
|
g = (255 - g).toString(16);
|
|
22
25
|
b = (255 - b).toString(16);
|
|
26
|
+
// pad each with zeros and return
|
|
23
27
|
return "#" + padZero(r) + padZero(g) + padZero(b);
|
|
24
28
|
}
|
|
25
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Single color square (based on react-color's `Swatch`) that can be marked as selected. The default export adds the
|
|
31
|
+
* hover zoom; this named export is the bare component that receives `hover` from outside.
|
|
32
|
+
*
|
|
33
|
+
* Props:
|
|
34
|
+
* - `color` - color of the swatch; must be a hex string (e.g. `"#ff0000"`) when `active` is set.
|
|
35
|
+
* - `active` - marks the swatch as selected: it is enlarged and shows a check mark in black or white, whichever
|
|
36
|
+
* contrasts better.
|
|
37
|
+
* - `small` - renders a 15px swatch without the hover zoom instead of the default 22px one.
|
|
38
|
+
* - `onClick(color, event)` - called on click or Enter key; receives the `color` prop value as passed (not a converted
|
|
39
|
+
* react-color `ColorResult`).
|
|
40
|
+
* - `onSwatchHover(color, event)` - called when the mouse enters the swatch; receives the `color` prop value as passed.
|
|
41
|
+
* - `title` - tooltip of the swatch; defaults to the color value.
|
|
42
|
+
* - `style` - style of the inner swatch element.
|
|
43
|
+
* - `hover` - whether the swatch is hovered (enlarges it unless `small`); supplied by the default export.
|
|
44
|
+
*/
|
|
45
|
+
export function ColorSwatch({ hover, color, onClick, onSwatchHover, style, title, active, small }) {
|
|
26
46
|
const hoverSwatch = {
|
|
27
47
|
transform: "scale(1.5)",
|
|
28
48
|
position: 'relative',
|
|
@@ -58,6 +78,7 @@ export const ColorSwatch = ({ hover, color, onClick, onSwatchHover, style, title
|
|
|
58
78
|
React.createElement("svg", { viewBox: "0 0 24 24", style: { width: 20, height: 20 } },
|
|
59
79
|
React.createElement("path", { d: "M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" }))),
|
|
60
80
|
React.createElement(Swatch, { color: color, onClick: onClick, onHover: onSwatchHover, focus: active, focusStyle: focusSwatch, style: style, title: title })));
|
|
61
|
-
}
|
|
81
|
+
}
|
|
82
|
+
/** {@link ColorSwatch} that zooms on hover; see it for the props. */
|
|
62
83
|
export default handleHover(ColorSwatch);
|
|
63
84
|
//# sourceMappingURL=colorSwatch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colorSwatch.js","sourceRoot":"","sources":["../../../../components/color/colorSwatch.jsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,QAAQ,EAAE,EAAC,WAAW,EAAC,MAAM,UAAU,CAAA;AAC9C,OAAO,EAAC,MAAM,EAAC,MAAM,0CAA0C,CAAA;AAE/D,SAAS,WAAW,CAAC,GAAG,EAAE,EAAE;IACxB,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;
|
|
1
|
+
{"version":3,"file":"colorSwatch.js","sourceRoot":"","sources":["../../../../components/color/colorSwatch.jsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,QAAQ,EAAE,EAAC,WAAW,EAAC,MAAM,UAAU,CAAA;AAC9C,OAAO,EAAC,MAAM,EAAC,MAAM,0CAA0C,CAAA;AAE/D,SAAS,WAAW,CAAC,GAAG,EAAE,EAAE;IACxB,I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E,MAAM,CAAC,MAAM;QACpB,MAAM;YACP,6BAAK,KAAK,EAAE,EAAC,IAAI,EAAE,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,GAAE;gBAC5F,6BAAK,OAAO,EAAC,WAAW,EAAC,KAAK,EAAE,EAAC,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAC;oBACnD,8BAAM,CAAC,EAAC,yDAAyD,GAAE,CACjE,CACJ;QACN,oBAAC,MAAM,IACH,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,aAAa,EACtB,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,WAAW,EACvB,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,KAAK,GACd,CACA,CACT,CAAA;AACL,CAAC;AAED,qEAAqE;AACrE,eAAe,WAAW,CAAC,WAAW,CAAC,CAAA","sourcesContent":["import React from 'react'\r\nimport reactCSS, {handleHover} from 'reactcss'\r\nimport {Swatch} from 'react-color/lib/components/common/Swatch'\r\n\r\nfunction invertColor(hex, bw) {\r\n if (hex.indexOf('#') === 0) {\r\n hex = hex.slice(1);\r\n }\r\n // convert 3-digit hex to 6-digits.\r\n if (hex.length === 3) {\r\n hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];\r\n }\r\n if (hex.length !== 6) {\r\n throw new Error('Invalid HEX color.');\r\n }\r\n var r = parseInt(hex.slice(0, 2), 16),\r\n g = parseInt(hex.slice(2, 4), 16),\r\n b = parseInt(hex.slice(4, 6), 16);\r\n if (bw) {\r\n // http://stackoverflow.com/a/3943023/112731\r\n return (r * 0.299 + g * 0.587 + b * 0.114) > 186\r\n ? '#000000'\r\n : '#FFFFFF';\r\n }\r\n // invert color components\r\n r = (255 - r).toString(16);\r\n g = (255 - g).toString(16);\r\n b = (255 - b).toString(16);\r\n // pad each with zeros and return\r\n return \"#\" + padZero(r) + padZero(g) + padZero(b);\r\n}\r\n\r\n/**\r\n * Single color square (based on react-color's `Swatch`) that can be marked as selected. The default export adds the\r\n * hover zoom; this named export is the bare component that receives `hover` from outside.\r\n *\r\n * Props:\r\n * - `color` - color of the swatch; must be a hex string (e.g. `\"#ff0000\"`) when `active` is set.\r\n * - `active` - marks the swatch as selected: it is enlarged and shows a check mark in black or white, whichever\r\n * contrasts better.\r\n * - `small` - renders a 15px swatch without the hover zoom instead of the default 22px one.\r\n * - `onClick(color, event)` - called on click or Enter key; receives the `color` prop value as passed (not a converted\r\n * react-color `ColorResult`).\r\n * - `onSwatchHover(color, event)` - called when the mouse enters the swatch; receives the `color` prop value as passed.\r\n * - `title` - tooltip of the swatch; defaults to the color value.\r\n * - `style` - style of the inner swatch element.\r\n * - `hover` - whether the swatch is hovered (enlarges it unless `small`); supplied by the default export.\r\n */\r\nexport function ColorSwatch({hover, color, onClick, onSwatchHover, style, title, active, small}) {\r\n const hoverSwatch = {\r\n transform: \"scale(1.5)\",\r\n position: 'relative',\r\n zIndex: '3',\r\n }\r\n const focusSwatch = {\r\n position: 'relative',\r\n zIndex: '2',\r\n transform: \"scale(1.2)\",\r\n boxShadow: '0 0 5px 2px rgba(0,0,0,0.25)',\r\n cursor:\"pointer\"\r\n }\r\n\r\n const styles = reactCSS({\r\n 'default': {\r\n swatch: {\r\n display: \"inline-block\",\r\n transform: \"scale(1)\",\r\n width: !!small ? '15px' : '22px',\r\n height: !!small ? '15px' : '22px',\r\n margin: '2px',\r\n marginTop: 0,\r\n marginBottom: 0,\r\n fontSize: '0',\r\n },\r\n },\r\n 'hover': {\r\n swatch: small ? {} : hoverSwatch,\r\n },\r\n }, {hover})\r\n\r\n\r\n return (\r\n <div style={styles.swatch}>\r\n {active &&\r\n <div style={{fill: invertColor(color, true), position: \"absolute\", left: 1, top: 1, zIndex: 10,}}>\r\n <svg viewBox=\"0 0 24 24\" style={{width: 20, height: 20}}>\r\n <path d=\"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z\"/>\r\n </svg>\r\n </div>}\r\n <Swatch\r\n color={color}\r\n onClick={onClick}\r\n onHover={onSwatchHover}\r\n focus={active}\r\n focusStyle={focusSwatch}\r\n style={style}\r\n title={title}\r\n />\r\n </div>\r\n )\r\n}\r\n\r\n/** {@link ColorSwatch} that zooms on hover; see it for the props. */\r\nexport default handleHover(ColorSwatch)"]}
|