@gravity-ui/dashkit 10.5.1 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -1
- package/build/cjs/components/ActionPanel/ActionPanel.css +7 -5
- package/build/cjs/components/ActionPanel/ActionPanel.js +7 -9
- package/build/cjs/components/ActionPanel/ActionPanel.js.map +1 -1
- package/build/cjs/components/DashKit/DashKit.d.ts +1 -2
- package/build/cjs/components/DashKit/DashKit.js +50 -52
- package/build/cjs/components/DashKit/DashKit.js.map +1 -1
- package/build/cjs/components/DashKitDnDWrapper/DashKitDnDWrapper.js +2 -2
- package/build/cjs/components/DashKitDnDWrapper/DashKitDnDWrapper.js.map +1 -1
- package/build/cjs/components/DashKitView/DashKitView.js +1 -1
- package/build/cjs/components/DashKitView/DashKitView.js.map +1 -1
- package/build/cjs/components/GridItem/GridItem.js +79 -75
- package/build/cjs/components/GridItem/GridItem.js.map +1 -1
- package/build/cjs/components/GridLayout/GridLayout.d.ts +2 -2
- package/build/cjs/components/GridLayout/GridLayout.js +184 -187
- package/build/cjs/components/GridLayout/GridLayout.js.map +1 -1
- package/build/cjs/components/GridLayout/GroupLayout.js +1 -1
- package/build/cjs/components/GridLayout/GroupLayout.js.map +1 -1
- package/build/cjs/components/GridLayout/ReactGridLayout.js +303 -299
- package/build/cjs/components/GridLayout/ReactGridLayout.js.map +1 -1
- package/build/cjs/components/GridLayout/types.d.ts +1 -1
- package/build/cjs/components/GridLayout/types.js.map +1 -1
- package/build/cjs/components/Item/Item.js +8 -11
- package/build/cjs/components/Item/Item.js.map +1 -1
- package/build/cjs/components/MobileLayout/MobileLayout.d.ts +2 -2
- package/build/cjs/components/MobileLayout/MobileLayout.js +14 -14
- package/build/cjs/components/MobileLayout/MobileLayout.js.map +1 -1
- package/build/cjs/components/OverlayControls/OverlayControls.css +1 -1
- package/build/cjs/components/OverlayControls/OverlayControls.d.ts +7 -32
- package/build/cjs/components/OverlayControls/OverlayControls.js +164 -151
- package/build/cjs/components/OverlayControls/OverlayControls.js.map +1 -1
- package/build/cjs/hocs/prepareItem.js +65 -70
- package/build/cjs/hocs/prepareItem.js.map +1 -1
- package/build/cjs/hocs/withContext.js +27 -17
- package/build/cjs/hocs/withContext.js.map +1 -1
- package/build/cjs/hooks/useDeepEqualMemo.js +1 -1
- package/build/cjs/hooks/useDeepEqualMemo.js.map +1 -1
- package/build/cjs/i18n/index.d.ts +8 -0
- package/build/cjs/package.json +1 -1
- package/build/cjs/plugins/Text/Text.js +14 -17
- package/build/cjs/plugins/Text/Text.js.map +1 -1
- package/build/cjs/plugins/Title/Title.js +3 -4
- package/build/cjs/plugins/Title/Title.js.map +1 -1
- package/build/cjs/plugins/Title/index.d.ts +1 -1
- package/build/cjs/plugins/Title/index.js.map +1 -1
- package/build/cjs/shared/modules/helpers.js +34 -23
- package/build/cjs/shared/modules/helpers.js.map +1 -1
- package/build/cjs/shared/modules/state-and-params.js +30 -14
- package/build/cjs/shared/modules/state-and-params.js.map +1 -1
- package/build/cjs/shared/units/datalens/index.js +5 -2
- package/build/cjs/shared/units/datalens/index.js.map +1 -1
- package/build/cjs/utils/enrichLayoutWithDefaults.d.ts +1 -1
- package/build/cjs/utils/enrichLayoutWithDefaults.js +4 -1
- package/build/cjs/utils/enrichLayoutWithDefaults.js.map +1 -1
- package/build/cjs/utils/events.js +1 -1
- package/build/cjs/utils/events.js.map +1 -1
- package/build/cjs/utils/get-layout-patches.js +1 -1
- package/build/cjs/utils/get-layout-patches.js.map +1 -1
- package/build/cjs/utils/register-manager.js +25 -24
- package/build/cjs/utils/register-manager.js.map +1 -1
- package/build/cjs/utils/update-manager.js +103 -66
- package/build/cjs/utils/update-manager.js.map +1 -1
- package/build/docs/INDEX.md +24 -1
- package/build/docs/guides/migration-to-v11.md +122 -0
- package/build/esm/components/ActionPanel/ActionPanel.css +7 -5
- package/build/esm/components/ActionPanel/ActionPanel.js +7 -10
- package/build/esm/components/ActionPanel/ActionPanel.js.map +1 -1
- package/build/esm/components/DashKit/DashKit.d.ts +1 -2
- package/build/esm/components/DashKit/DashKit.js +50 -52
- package/build/esm/components/DashKit/DashKit.js.map +1 -1
- package/build/esm/components/DashKitDnDWrapper/DashKitDnDWrapper.js +2 -2
- package/build/esm/components/DashKitDnDWrapper/DashKitDnDWrapper.js.map +1 -1
- package/build/esm/components/DashKitView/DashKitView.js +1 -1
- package/build/esm/components/DashKitView/DashKitView.js.map +1 -1
- package/build/esm/components/GridItem/GridItem.js +79 -75
- package/build/esm/components/GridItem/GridItem.js.map +1 -1
- package/build/esm/components/GridLayout/GridLayout.d.ts +2 -2
- package/build/esm/components/GridLayout/GridLayout.js +185 -189
- package/build/esm/components/GridLayout/GridLayout.js.map +1 -1
- package/build/esm/components/GridLayout/GroupLayout.js +1 -1
- package/build/esm/components/GridLayout/GroupLayout.js.map +1 -1
- package/build/esm/components/GridLayout/ReactGridLayout.js +303 -300
- package/build/esm/components/GridLayout/ReactGridLayout.js.map +1 -1
- package/build/esm/components/GridLayout/types.d.ts +1 -1
- package/build/esm/components/GridLayout/types.js.map +1 -1
- package/build/esm/components/Item/Item.js +8 -11
- package/build/esm/components/Item/Item.js.map +1 -1
- package/build/esm/components/MobileLayout/MobileLayout.d.ts +2 -2
- package/build/esm/components/MobileLayout/MobileLayout.js +15 -16
- package/build/esm/components/MobileLayout/MobileLayout.js.map +1 -1
- package/build/esm/components/OverlayControls/OverlayControls.css +1 -1
- package/build/esm/components/OverlayControls/OverlayControls.d.ts +7 -32
- package/build/esm/components/OverlayControls/OverlayControls.js +165 -152
- package/build/esm/components/OverlayControls/OverlayControls.js.map +1 -1
- package/build/esm/hocs/prepareItem.js +65 -70
- package/build/esm/hocs/prepareItem.js.map +1 -1
- package/build/esm/hocs/withContext.js +27 -18
- package/build/esm/hocs/withContext.js.map +1 -1
- package/build/esm/hooks/useDeepEqualMemo.js +1 -1
- package/build/esm/hooks/useDeepEqualMemo.js.map +1 -1
- package/build/esm/i18n/index.d.ts +8 -0
- package/build/esm/package.json +1 -1
- package/build/esm/plugins/Text/Text.js +14 -17
- package/build/esm/plugins/Text/Text.js.map +1 -1
- package/build/esm/plugins/Title/Title.js +3 -4
- package/build/esm/plugins/Title/Title.js.map +1 -1
- package/build/esm/plugins/Title/index.d.ts +1 -1
- package/build/esm/plugins/Title/index.js.map +1 -1
- package/build/esm/shared/modules/helpers.js +34 -23
- package/build/esm/shared/modules/helpers.js.map +1 -1
- package/build/esm/shared/modules/state-and-params.js +30 -14
- package/build/esm/shared/modules/state-and-params.js.map +1 -1
- package/build/esm/shared/units/datalens/index.js +5 -2
- package/build/esm/shared/units/datalens/index.js.map +1 -1
- package/build/esm/utils/enrichLayoutWithDefaults.d.ts +1 -1
- package/build/esm/utils/enrichLayoutWithDefaults.js +4 -1
- package/build/esm/utils/enrichLayoutWithDefaults.js.map +1 -1
- package/build/esm/utils/events.js +1 -1
- package/build/esm/utils/events.js.map +1 -1
- package/build/esm/utils/get-layout-patches.js +1 -1
- package/build/esm/utils/get-layout-patches.js.map +1 -1
- package/build/esm/utils/register-manager.js +25 -24
- package/build/esm/utils/register-manager.js.map +1 -1
- package/build/esm/utils/update-manager.js +103 -66
- package/build/esm/utils/update-manager.js.map +1 -1
- package/package.json +25 -19
- package/build/cjs/components/DashKit/__tests__/controlled-layout.test.d.ts +0 -4
- package/build/cjs/components/DashKit/__tests__/controlled-layout.test.js +0 -260
- package/build/cjs/components/DashKit/__tests__/controlled-layout.test.js.map +0 -1
- package/build/cjs/components/DashKit/__tests__/events.test.d.ts +0 -1
- package/build/cjs/components/DashKit/__tests__/events.test.js +0 -227
- package/build/cjs/components/DashKit/__tests__/events.test.js.map +0 -1
- package/build/cjs/components/GridLayout/__tests__/passive-resize.test.d.ts +0 -2
- package/build/cjs/components/GridLayout/__tests__/passive-resize.test.js +0 -386
- package/build/cjs/components/GridLayout/__tests__/passive-resize.test.js.map +0 -1
- package/build/cjs/hooks/__tests__/useDnDItemProps.test.d.ts +0 -2
- package/build/cjs/hooks/__tests__/useDnDItemProps.test.js +0 -45
- package/build/cjs/hooks/__tests__/useDnDItemProps.test.js.map +0 -1
- package/build/cjs/shared/modules/__tests__/global-items.test.d.ts +0 -1
- package/build/cjs/shared/modules/__tests__/global-items.test.js +0 -372
- package/build/cjs/shared/modules/__tests__/global-items.test.js.map +0 -1
- package/build/cjs/shared/modules/__tests__/helpers.test.d.ts +0 -1
- package/build/cjs/shared/modules/__tests__/helpers.test.js +0 -505
- package/build/cjs/shared/modules/__tests__/helpers.test.js.map +0 -1
- package/build/cjs/shared/modules/__tests__/uniq-id.test.d.ts +0 -1
- package/build/cjs/shared/modules/__tests__/uniq-id.test.js +0 -78
- package/build/cjs/shared/modules/__tests__/uniq-id.test.js.map +0 -1
- package/build/cjs/shared/units/__tests__/state-and-params.test.d.ts +0 -241
- package/build/cjs/shared/units/__tests__/state-and-params.test.js +0 -724
- package/build/cjs/shared/units/__tests__/state-and-params.test.js.map +0 -1
- package/build/cjs/utils/__tests__/get-layout-patches.test.d.ts +0 -1
- package/build/cjs/utils/__tests__/get-layout-patches.test.js +0 -51
- package/build/cjs/utils/__tests__/get-layout-patches.test.js.map +0 -1
- package/build/cjs/utils/__tests__/update-manager.test.d.ts +0 -1
- package/build/cjs/utils/__tests__/update-manager.test.js +0 -824
- package/build/cjs/utils/__tests__/update-manager.test.js.map +0 -1
- package/build/esm/components/DashKit/__tests__/controlled-layout.test.d.ts +0 -4
- package/build/esm/components/DashKit/__tests__/controlled-layout.test.js +0 -257
- package/build/esm/components/DashKit/__tests__/controlled-layout.test.js.map +0 -1
- package/build/esm/components/DashKit/__tests__/events.test.d.ts +0 -1
- package/build/esm/components/DashKit/__tests__/events.test.js +0 -225
- package/build/esm/components/DashKit/__tests__/events.test.js.map +0 -1
- package/build/esm/components/GridLayout/__tests__/passive-resize.test.d.ts +0 -2
- package/build/esm/components/GridLayout/__tests__/passive-resize.test.js +0 -383
- package/build/esm/components/GridLayout/__tests__/passive-resize.test.js.map +0 -1
- package/build/esm/hooks/__tests__/useDnDItemProps.test.d.ts +0 -2
- package/build/esm/hooks/__tests__/useDnDItemProps.test.js +0 -42
- package/build/esm/hooks/__tests__/useDnDItemProps.test.js.map +0 -1
- package/build/esm/shared/modules/__tests__/global-items.test.d.ts +0 -1
- package/build/esm/shared/modules/__tests__/global-items.test.js +0 -370
- package/build/esm/shared/modules/__tests__/global-items.test.js.map +0 -1
- package/build/esm/shared/modules/__tests__/helpers.test.d.ts +0 -1
- package/build/esm/shared/modules/__tests__/helpers.test.js +0 -503
- package/build/esm/shared/modules/__tests__/helpers.test.js.map +0 -1
- package/build/esm/shared/modules/__tests__/uniq-id.test.d.ts +0 -1
- package/build/esm/shared/modules/__tests__/uniq-id.test.js +0 -75
- package/build/esm/shared/modules/__tests__/uniq-id.test.js.map +0 -1
- package/build/esm/shared/units/__tests__/state-and-params.test.d.ts +0 -241
- package/build/esm/shared/units/__tests__/state-and-params.test.js +0 -720
- package/build/esm/shared/units/__tests__/state-and-params.test.js.map +0 -1
- package/build/esm/utils/__tests__/get-layout-patches.test.d.ts +0 -1
- package/build/esm/utils/__tests__/get-layout-patches.test.js +0 -49
- package/build/esm/utils/__tests__/get-layout-patches.test.js.map +0 -1
- package/build/esm/utils/__tests__/update-manager.test.d.ts +0 -1
- package/build/esm/utils/__tests__/update-manager.test.js +0 -822
- package/build/esm/utils/__tests__/update-manager.test.js.map +0 -1
package/build/docs/INDEX.md
CHANGED
|
@@ -35,6 +35,16 @@ A dashboard grid composer that arranges resizable, draggable widgets in a respon
|
|
|
35
35
|
npm i @gravity-ui/dashkit @gravity-ui/uikit
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
+
Render `DashKit` inside the uikit `Provider` (or `ThemeProvider`): its components need the theme.
|
|
39
|
+
|
|
40
|
+
```tsx
|
|
41
|
+
import {Provider} from '@gravity-ui/uikit';
|
|
42
|
+
|
|
43
|
+
<Provider theme="light">
|
|
44
|
+
<DashKit {...props} />
|
|
45
|
+
</Provider>;
|
|
46
|
+
```
|
|
47
|
+
|
|
38
48
|
## Usage
|
|
39
49
|
|
|
40
50
|
### DashKit configuration
|
|
@@ -49,6 +59,8 @@ Before using `DashKit` as a react component, it must be configured.
|
|
|
49
59
|
configure({lang: Lang.En});
|
|
50
60
|
```
|
|
51
61
|
|
|
62
|
+
Under the uikit `Provider` with the `lang` prop, DashKit follows that language instead.
|
|
63
|
+
|
|
52
64
|
- DashKit.setSettings
|
|
53
65
|
|
|
54
66
|
Used for global DashKit settings (such as margins between widgets, default widget sizes and widget overlay menu)
|
|
@@ -389,7 +401,7 @@ type MenuItem = {
|
|
|
389
401
|
id: string; // uniq id
|
|
390
402
|
title?: string; // string title
|
|
391
403
|
icon?: ReactNode; // node of icon
|
|
392
|
-
iconSize?: number | string; //
|
|
404
|
+
iconSize?: number | string; // deprecated: not applied, set the size on the icon element
|
|
393
405
|
handler?: (item: ConfigItem) => void; // custom item action handler
|
|
394
406
|
visible?: (item: ConfigItem) => boolean; // optional visibility handler for filtering menu items
|
|
395
407
|
className?: string; // custom class property
|
|
@@ -403,6 +415,13 @@ type MenuItem = {
|
|
|
403
415
|
DashKit.setSettings({menu: [] as Array<MenuItem>});
|
|
404
416
|
```
|
|
405
417
|
|
|
418
|
+
Default items are `copy`, `delete` and `settings` (`MenuItems`):
|
|
419
|
+
|
|
420
|
+
- given as a string, `copy` and `delete` keep their default text and action, also next to custom items in any
|
|
421
|
+
order; `settings` as a string is not shown, because the gear button opens the settings;
|
|
422
|
+
- given as an object without `title`, a default item gets its default text, and without `handler` its default
|
|
423
|
+
action; this way `settings` is shown too.
|
|
424
|
+
|
|
406
425
|
### Draggable items from ActionPanel
|
|
407
426
|
|
|
408
427
|
#### DashKitDnDWrapper
|
|
@@ -534,3 +553,7 @@ const CustomThemeWrapper = (props: {
|
|
|
534
553
|
);
|
|
535
554
|
};
|
|
536
555
|
```
|
|
556
|
+
|
|
557
|
+
## Guides
|
|
558
|
+
|
|
559
|
+
- [Migration to DashKit 11](./guides/migration-to-v11.md) — DashKit 11 moves to @gravity-ui/uikit 8 and compiles to ES2022. This page lists what changes for an application and what to do about each change.
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# Migration to DashKit 11
|
|
2
|
+
|
|
3
|
+
DashKit 11 moves to `@gravity-ui/uikit` 8 and compiles to ES2022. This page lists what changes for an application
|
|
4
|
+
and what to do about each change.
|
|
5
|
+
|
|
6
|
+
## Requirements
|
|
7
|
+
|
|
8
|
+
| Package | DashKit 10 | DashKit 11 |
|
|
9
|
+
| :------------------- | :----------------------------------- | :--------------------- |
|
|
10
|
+
| `@gravity-ui/uikit` | `^7.0.0` | `^8.0.0` |
|
|
11
|
+
| `@gravity-ui/icons` | `^2.13.0` | `^2.20.0` |
|
|
12
|
+
| `react`, `react-dom` | `^16.8.0 \|\| ^17 \|\| ^18 \|\| ^19` | `^18.0.0 \|\| ^19.0.0` |
|
|
13
|
+
|
|
14
|
+
Upgrade the application to uikit 8 first: see the
|
|
15
|
+
[uikit migration guide](https://github.com/gravity-ui/uikit/blob/main/docs/migration-to-v8.md), also installed
|
|
16
|
+
as `node_modules/@gravity-ui/uikit/build/docs/guides/migration-to-v8.md`. Two uikit majors in one bundle are two
|
|
17
|
+
sets of providers, and DashKit would not see the theme of the application.
|
|
18
|
+
|
|
19
|
+
## Theme provider
|
|
20
|
+
|
|
21
|
+
DashKit must be rendered inside the uikit `Provider` or `ThemeProvider`. In edit mode the widget menu now needs
|
|
22
|
+
the theme as soon as it renders, so without a provider the dashboard throws "useTheme\* hooks must be used within
|
|
23
|
+
ThemeProvider". Before, the menu needed the theme only when it was opened.
|
|
24
|
+
|
|
25
|
+
## Widget overlay menu
|
|
26
|
+
|
|
27
|
+
The menu behind the "…" button of a widget is the uikit 8 `Menu` instead of the legacy `DropdownMenu`. The API of
|
|
28
|
+
DashKit did not change: `overlayMenuItems`, `Settings.menu`, and the `title`, `handler`, `visible`, `className` and
|
|
29
|
+
`qa` of a custom item work as before.
|
|
30
|
+
|
|
31
|
+
`iconSize` of a menu item is deprecated: the menu never applied it. Set the size on the icon element. `iconSize`
|
|
32
|
+
of an `overlayControls` button still works.
|
|
33
|
+
|
|
34
|
+
What changes is the markup, so check your CSS overrides and tests:
|
|
35
|
+
|
|
36
|
+
- Items are `button.g-menu-item[role="menuitem"]` inside `.g-menu`. The `.g-dropdown-menu__*` classes and the
|
|
37
|
+
`li > div[role="menuitem"]` structure are gone.
|
|
38
|
+
- `role="menu"` is on the popup element around `.g-menu`, not on `.g-menu` itself: find the menu by its role
|
|
39
|
+
(`getByRole('menu')`), not with `.g-menu[role="menu"]`.
|
|
40
|
+
- `qa` of a custom item is the `data-qa` of that button.
|
|
41
|
+
- `icon` of a custom item is rendered inside `div.g-menu-item__icon`, a 16px box. An `<Icon>` without `size` and an
|
|
42
|
+
`<svg>` without `width` and `height` get 16px. Items without an icon are indented to line up with the ones that
|
|
43
|
+
have it.
|
|
44
|
+
- To recolor an item through its `className`, set `--g-list-item-view-text-color`: a plain `color` has the same
|
|
45
|
+
specificity as the uikit rule, so the order of the stylesheets decides.
|
|
46
|
+
- The "…" button is no longer wrapped in `div.g-dropdown-menu__switcher-wrapper`.
|
|
47
|
+
- The `dashkit_draggable_cancel` class is on `.g-menu` instead of the popup element.
|
|
48
|
+
- Rows follow the uikit 8 heights, see
|
|
49
|
+
[Row heights of List, Select and Menu](https://github.com/gravity-ui/uikit/blob/main/docs/migration-to-v8.md#row-heights-of-list-select-and-menu).
|
|
50
|
+
- The menu no longer closes when an ancestor scrolls: it stays open and follows the button.
|
|
51
|
+
|
|
52
|
+
## Language
|
|
53
|
+
|
|
54
|
+
DashKit texts (the overlay menu, the error of the Text plugin) follow the language of the uikit `Provider`:
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
<Provider theme="light" lang="ru">
|
|
58
|
+
<DashKit {...props} />
|
|
59
|
+
</Provider>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Without `lang` on a `Provider` they follow `configure({lang})`, as before. An application that only calls
|
|
63
|
+
`configure` needs no change.
|
|
64
|
+
|
|
65
|
+
The texts now re-render when the language changes, from either source. A DashKit 10 application had to remount
|
|
66
|
+
DashKit or pass it a new `context` to see the new language; for the texts of DashKit itself that workaround can be
|
|
67
|
+
removed. The texts of the application, such as the titles of its menu items or plugins that take the language from
|
|
68
|
+
`context`, stay its own.
|
|
69
|
+
|
|
70
|
+
## ActionPanel
|
|
71
|
+
|
|
72
|
+
The default hover background of an item is `--g-color-base-contrast-light-simple-hover`: uikit 8 removed
|
|
73
|
+
`--g-color-base-light-simple-hover`. If a theme of yours set the old token to restyle the panel, set
|
|
74
|
+
`--dashkit-action-panel-item-color-hover` instead.
|
|
75
|
+
|
|
76
|
+
## Build output
|
|
77
|
+
|
|
78
|
+
- The package is compiled to ES2022. If the application supports browsers without ES2022, transpile
|
|
79
|
+
`@gravity-ui/dashkit` in its build, as uikit 8 already requires.
|
|
80
|
+
- `lodash` is replaced with `es-toolkit`. `es-toolkit`, `tslib` and `@gravity-ui/i18n` are dependencies of DashKit,
|
|
81
|
+
so nothing has to be installed next to it.
|
|
82
|
+
- Unit tests are no longer published in the package.
|
|
83
|
+
- The types of DashKit compile with `skipLibCheck: false`; DashKit 10 needed `skipLibCheck: true`. They need
|
|
84
|
+
`@types/react` 18.2.6 or later (they use `React.JSX`), and with `moduleResolution: node10` also
|
|
85
|
+
`esModuleInterop` or `allowSyntheticDefaultImports`, because they default-import `react` and
|
|
86
|
+
`react-grid-layout`; `bundler`, `node16` and `nodenext` work as they are. This is about the types of DashKit
|
|
87
|
+
itself: in an ES module project with `node16` or `nodenext`, the types of uikit 8.0.0 do not compile with
|
|
88
|
+
`skipLibCheck: false` (relative imports without extensions in `Menu.d.ts`, a deep `rc-slider` import in
|
|
89
|
+
`Slider/types.d.ts`), so such a project still needs `skipLibCheck: true`.
|
|
90
|
+
- `@types/react-grid-layout` is a dependency: the public types import `react-grid-layout`. It accepts any
|
|
91
|
+
`@types/react`; if the package manager installs a second copy of `@types/react` for it next to the application's
|
|
92
|
+
one, dedupe it (`overrides` in npm, `resolutions` in yarn).
|
|
93
|
+
- uikit 8 brings two dependencies that ship only ES modules, `colors-named` and `colors-named-hex`, and they load
|
|
94
|
+
with any import of `@gravity-ui/uikit`. Bundlers are not affected.
|
|
95
|
+
|
|
96
|
+
- In Jest, a test that imports `@gravity-ui/uikit` or DashKit without mocking uikit fails to load them: Jest 29
|
|
97
|
+
reports "SyntaxError: Unexpected token 'export'", Jest 30 "Must use import to load ES Module". Take the two
|
|
98
|
+
packages out of `transformIgnorePatterns` and let a transformer that turns ES modules into CommonJS handle
|
|
99
|
+
their `.js` files. Keep the rest of the configuration, such as the CSS stub and jsdom. Transformers that do it:
|
|
100
|
+
|
|
101
|
+
- `ts-jest` 29.3.2 or later, by itself; 29.3.0 and 29.3.1 only with `"isolatedModules": true`; older versions
|
|
102
|
+
leave the files as they are;
|
|
103
|
+
- `babel-jest` with `@babel/preset-env` or `@babel/plugin-transform-modules-commonjs` 7.x in a project-wide
|
|
104
|
+
`babel.config.js`: a `.babelrc` does not apply to files in `node_modules`;
|
|
105
|
+
- a small transformer for these two packages only, which works with any `ts-jest`; `jest/esmTransform.js` in
|
|
106
|
+
the DashKit repository is one (it calls `typescript.transpileModule`).
|
|
107
|
+
|
|
108
|
+
```js
|
|
109
|
+
// jest.config.js (jest.config.cjs in a package with "type": "module"), with ts-jest 29.3.2 or later
|
|
110
|
+
module.exports = {
|
|
111
|
+
transform: {
|
|
112
|
+
'^.+\\.[jt]sx?$': 'ts-jest',
|
|
113
|
+
},
|
|
114
|
+
transformIgnorePatterns: ['/node_modules/(?!(colors-named|colors-named-hex)/)'],
|
|
115
|
+
// with pnpm, whose packages live in node_modules/.pnpm:
|
|
116
|
+
// transformIgnorePatterns: ['/node_modules/\\.pnpm/(?!(colors-named|colors-named-hex)@)'],
|
|
117
|
+
};
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
- In Node, the CommonJS build needs `require(esm)` for them (Node 20.19 or 22.12 and later). The main entry
|
|
121
|
+
also imports CSS and needs a DOM, so it loads only under a bundler or a test runner that stubs CSS;
|
|
122
|
+
`@gravity-ui/dashkit/helpers` loads in plain Node.
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
);
|
|
50
50
|
--_--dashkit-action-panel-item-color-hover: var(
|
|
51
51
|
--dashkit-action-panel-item-color-hover,
|
|
52
|
-
var(--g-color-base-light-simple-hover)
|
|
52
|
+
var(--g-color-base-contrast-light-simple-hover)
|
|
53
53
|
);
|
|
54
54
|
--_--dashkit-action-panel-item-color-dragging: var(
|
|
55
55
|
--dashkit-action-panel-item-color-dragging,
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
max-width: 200px;
|
|
64
64
|
flex: 0 0 auto;
|
|
65
65
|
display: flex;
|
|
66
|
-
gap:
|
|
66
|
+
gap: 8px;
|
|
67
67
|
justify-content: center;
|
|
68
68
|
align-items: center;
|
|
69
69
|
border-radius: var(--g-border-radius-xl);
|
|
@@ -73,6 +73,7 @@
|
|
|
73
73
|
background-color: var(--_--dashkit-action-panel-item-color);
|
|
74
74
|
color: var(--_--dashkit-action-panel-item-text-color);
|
|
75
75
|
cursor: pointer;
|
|
76
|
+
transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
|
|
76
77
|
}
|
|
77
78
|
.dashkit-action-panel__item:hover, .dashkit-action-panel__item:focus-visible {
|
|
78
79
|
background-color: var(--_--dashkit-action-panel-item-color-hover);
|
|
@@ -105,10 +106,11 @@
|
|
|
105
106
|
justify-content: center;
|
|
106
107
|
}
|
|
107
108
|
.dashkit-action-panel__title {
|
|
109
|
+
font-family: var(--g-text-subheader-font-family);
|
|
110
|
+
font-weight: var(--g-text-subheader-font-weight);
|
|
111
|
+
font-size: var(--g-text-subheader-1-font-size);
|
|
112
|
+
line-height: var(--g-text-subheader-1-line-height);
|
|
108
113
|
min-width: 0;
|
|
109
|
-
font-size: 12px;
|
|
110
|
-
font-weight: 400;
|
|
111
|
-
line-height: 16px;
|
|
112
114
|
overflow: hidden;
|
|
113
115
|
text-overflow: ellipsis;
|
|
114
116
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __rest } from "tslib";
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import { CSSTransition } from 'react-transition-group';
|
|
4
3
|
import { useDnDItemProps } from "../../hooks/useDnDItemProps.js";
|
|
@@ -18,7 +17,7 @@ export const ActionPanelItemContainer = ({ item }) => {
|
|
|
18
17
|
const onDragStart = (event) => {
|
|
19
18
|
const source = event.currentTarget;
|
|
20
19
|
source.classList.add(draggingClassName);
|
|
21
|
-
dndProps
|
|
20
|
+
dndProps?.onDragStart(event);
|
|
22
21
|
// The native drag image captures the solid item before the panel source is disabled.
|
|
23
22
|
disableSourceTimer.current = setTimeout(() => {
|
|
24
23
|
source.classList.add(disabledSourceClassName);
|
|
@@ -31,22 +30,20 @@ export const ActionPanelItemContainer = ({ item }) => {
|
|
|
31
30
|
disableSourceTimer.current = null;
|
|
32
31
|
}
|
|
33
32
|
event.currentTarget.classList.remove(draggingClassName, disabledSourceClassName);
|
|
34
|
-
dndProps
|
|
33
|
+
dndProps?.onDragEnd(event);
|
|
35
34
|
};
|
|
36
|
-
return (React.createElement("div",
|
|
35
|
+
return (React.createElement("div", { role: "button", className: b('item', { draggable: Boolean(dndProps) }, item.className), onClick: item.onClick, "data-qa": item.qa, ...dndProps, onDragStart: dndProps ? onDragStart : undefined, onDragEnd: dndProps ? onDragEnd : undefined },
|
|
37
36
|
React.createElement("div", { className: b('icon') }, item.icon),
|
|
38
37
|
React.createElement("div", { className: b('title'), title: item.title }, item.title)));
|
|
39
38
|
};
|
|
40
39
|
export const ActionPanel = (props) => {
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
const isAnimated = (_b = props.toggleAnimation) !== null && _b !== void 0 ? _b : false;
|
|
40
|
+
const isDisabled = props.disable ?? false;
|
|
41
|
+
const isAnimated = props.toggleAnimation ?? false;
|
|
44
42
|
const nodeRef = React.useRef(null);
|
|
45
|
-
const content = (React.createElement("div", { ref: nodeRef, className: b(null, props.className) }, props.items.map((
|
|
46
|
-
var { wrapTo } = _a, item = __rest(_a, ["wrapTo"]);
|
|
43
|
+
const content = (React.createElement("div", { ref: nodeRef, className: b(null, props.className) }, props.items.map(({ wrapTo, ...item }) => {
|
|
47
44
|
const key = `dk-action-panel-${item.id}`;
|
|
48
45
|
const children = React.createElement(ActionPanelItemContainer, { key: key, item: item });
|
|
49
|
-
return wrapTo ? wrapTo(
|
|
46
|
+
return wrapTo ? wrapTo({ ...item, key, children }) : children;
|
|
50
47
|
})));
|
|
51
48
|
if (isAnimated) {
|
|
52
49
|
return (React.createElement(CSSTransition, { in: !isDisabled, nodeRef: nodeRef, classNames: b(null), timeout: 300, unmountOnExit: true }, content));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionPanel.js","sourceRoot":"../../../../src","sources":["components/ActionPanel/ActionPanel.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ActionPanel.js","sourceRoot":"../../../../src","sources":["components/ActionPanel/ActionPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAC,eAAe,EAAC,uCAAoC;AAC5D,OAAO,EAAC,EAAE,EAAC,0BAAuB;AAIlC,2BAA4B;AAE5B,MAAM,CAAC,GAAG,EAAE,CAAC,sBAAsB,CAAC,CAAC;AAErC,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,EAAC,IAAI,EAA0B,EAAE,EAAE;IACxE,MAAM,QAAQ,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACvC,MAAM,iBAAiB,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC;IAClD,MAAM,uBAAuB,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC,2BAA2B,CAAC;IAC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AQ,CAAC;IAChE,CAAC,CAAC,CACA,CACT,CAAC;IAEF,IAAI,UAAU,EAAE,CAAC;QACb,OAAO,CACH,oBAAC,aAAa,IACV,EAAE,EAAE,CAAC,UAAU,EACf,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,EACnB,OAAO,EAAE,GAAG,EACZ,aAAa,UAEZ,OAAO,CACI,CACnB,CAAC;IACN,CAAC;SAAM,CAAC;QACJ,OAAO,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;IACvC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import React from 'react';\n\nimport {CSSTransition} from 'react-transition-group';\n\nimport {useDnDItemProps} from '../../hooks/useDnDItemProps';\nimport {cn} from '../../utils/cn';\n\nimport {ActionPanelItem, ActionPanelProps} from './types';\n\nimport './ActionPanel.scss';\n\nconst b = cn('dashkit-action-panel');\n\nexport const ActionPanelItemContainer = ({item}: {item: ActionPanelItem}) => {\n const dndProps = useDnDItemProps(item);\n const draggingClassName = `${b('item')}_dragging`;\n const disabledSourceClassName = `${b('item')}_dragging-source-disabled`;\n const disableSourceTimer = React.useRef<ReturnType<typeof setTimeout> | null>(null);\n\n React.useEffect(\n () => () => {\n if (disableSourceTimer.current !== null) {\n clearTimeout(disableSourceTimer.current);\n }\n },\n [],\n );\n\n const onDragStart = (event: React.DragEvent<HTMLDivElement>) => {\n const source = event.currentTarget;\n source.classList.add(draggingClassName);\n dndProps?.onDragStart(event);\n // The native drag image captures the solid item before the panel source is disabled.\n disableSourceTimer.current = setTimeout(() => {\n source.classList.add(disabledSourceClassName);\n disableSourceTimer.current = null;\n }, 0);\n };\n\n const onDragEnd = (event: React.DragEvent<HTMLDivElement>) => {\n if (disableSourceTimer.current !== null) {\n clearTimeout(disableSourceTimer.current);\n disableSourceTimer.current = null;\n }\n event.currentTarget.classList.remove(draggingClassName, disabledSourceClassName);\n dndProps?.onDragEnd(event);\n };\n\n return (\n <div\n role=\"button\"\n className={b('item', {draggable: Boolean(dndProps)}, item.className)}\n onClick={item.onClick}\n data-qa={item.qa}\n {...dndProps}\n onDragStart={dndProps ? onDragStart : undefined}\n onDragEnd={dndProps ? onDragEnd : undefined}\n >\n <div className={b('icon')}>{item.icon}</div>\n <div className={b('title')} title={item.title}>\n {item.title}\n </div>\n </div>\n );\n};\n\nexport const ActionPanel = (props: ActionPanelProps) => {\n const isDisabled = props.disable ?? false;\n const isAnimated = props.toggleAnimation ?? false;\n const nodeRef = React.useRef<HTMLDivElement | null>(null);\n\n const content = (\n <div ref={nodeRef} className={b(null, props.className)}>\n {props.items.map(({wrapTo, ...item}) => {\n const key = `dk-action-panel-${item.id}`;\n const children = <ActionPanelItemContainer key={key} item={item} />;\n\n return wrapTo ? wrapTo({...item, key, children}) : children;\n })}\n </div>\n );\n\n if (isAnimated) {\n return (\n <CSSTransition\n in={!isDisabled}\n nodeRef={nodeRef}\n classNames={b(null)}\n timeout={300}\n unmountOnExit\n >\n {content}\n </CSSTransition>\n );\n } else {\n return isDisabled ? null : content;\n }\n};\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { Config, ConfigItem, ConfigLayout, GlobalParams, ItemDropProps, ItemsStateAndParams } from "../../shared/index.js";
|
|
3
|
-
import type { AddNewItemOptions, ContextProps, DashKitEventHandler,
|
|
3
|
+
import type { AddNewItemOptions, ContextProps, DashKitEventHandler, DashKitEventName, DashKitGroup, ItemManipulationCallback, MenuItem, Plugin, SetConfigItem, Settings, SettingsProps } from "../../typings/index.js";
|
|
4
4
|
import GridLayout from "../GridLayout/GridLayout.js";
|
|
5
5
|
import type { OverlayControlItem, PreparedCopyItemOptions } from "../OverlayControls/OverlayControls.js";
|
|
6
6
|
interface DashKitGeneralProps {
|
|
@@ -86,7 +86,6 @@ export declare class DashKit extends React.PureComponent<DashKitInnerProps> {
|
|
|
86
86
|
* @returns Unsubscribe callback.
|
|
87
87
|
*/
|
|
88
88
|
on<T extends DashKitEventName>(eventName: T, handler: DashKitEventHandler<T>): () => void;
|
|
89
|
-
[_emitSymbol]: <T extends DashKitEventName>(eventName: T, event: DashKitEventMap[T]) => void;
|
|
90
89
|
private _off;
|
|
91
90
|
}
|
|
92
91
|
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
var _a;
|
|
2
1
|
import React from 'react';
|
|
3
|
-
import noop from
|
|
4
|
-
import pick from
|
|
2
|
+
import noop from 'es-toolkit/compat/noop';
|
|
3
|
+
import pick from 'es-toolkit/compat/pick';
|
|
5
4
|
import { DEFAULT_GROUP, DEFAULT_NAMESPACE } from "../../constants/index.js";
|
|
6
5
|
import { DashKitDnDContext } from "../../context/index.js";
|
|
7
6
|
import { RegisterManager, UpdateManager, reflowLayout } from "../../utils/index.js";
|
|
@@ -10,8 +9,8 @@ import DashKitView from "../DashKitView/DashKitView.js";
|
|
|
10
9
|
const registerManager = new RegisterManager();
|
|
11
10
|
/**
|
|
12
11
|
* @internal Not part of the public API. Do not use in production code.
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* A symbol instead of a method name, so that a ref to DashKit does not offer `_emit`. It is exported
|
|
13
|
+
* for tests and left out of the types, but the package root still exports it at runtime.
|
|
15
14
|
*/
|
|
16
15
|
export const _emitSymbol = Symbol('DashKit._emit');
|
|
17
16
|
const getReflowProps = (props) => Object.assign({ compactType: 'vertical', cols: 36 }, pick(props, 'cols', 'maxRows', 'compactType'));
|
|
@@ -29,26 +28,22 @@ const getReflowGroupsConfig = (groups = []) => {
|
|
|
29
28
|
};
|
|
30
29
|
};
|
|
31
30
|
export class DashKit extends React.PureComponent {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
}
|
|
31
|
+
static defaultProps = {
|
|
32
|
+
onItemEdit: noop,
|
|
33
|
+
onChange: noop,
|
|
34
|
+
onDrop: noop,
|
|
35
|
+
defaultGlobalParams: {},
|
|
36
|
+
globalParams: {},
|
|
37
|
+
itemsStateAndParams: {},
|
|
38
|
+
settings: {
|
|
39
|
+
autoupdateInterval: 0,
|
|
40
|
+
silentLoading: false,
|
|
41
|
+
},
|
|
42
|
+
context: {},
|
|
43
|
+
noOverlay: false,
|
|
44
|
+
focusable: false,
|
|
45
|
+
};
|
|
46
|
+
static contextType = DashKitDnDContext;
|
|
52
47
|
static registerPlugins(...plugins) {
|
|
53
48
|
plugins.forEach((plugin) => {
|
|
54
49
|
registerManager.registerPlugin(plugin);
|
|
@@ -74,9 +69,9 @@ export class DashKit extends React.PureComponent {
|
|
|
74
69
|
else {
|
|
75
70
|
const item = setItem;
|
|
76
71
|
const registerManagerItem = registerManager.getItem(item.type);
|
|
77
|
-
const layout =
|
|
72
|
+
const layout = { ...registerManagerItem.defaultLayout };
|
|
78
73
|
const reflowLayoutOptions = getReflowGroupsConfig(groups);
|
|
79
|
-
const copyItem =
|
|
74
|
+
const copyItem = { ...item };
|
|
80
75
|
if (copyItem.layout) {
|
|
81
76
|
Object.assign(layout, copyItem.layout);
|
|
82
77
|
delete copyItem.layout;
|
|
@@ -86,7 +81,7 @@ export class DashKit extends React.PureComponent {
|
|
|
86
81
|
namespace,
|
|
87
82
|
config,
|
|
88
83
|
layout,
|
|
89
|
-
options:
|
|
84
|
+
options: { ...options, reflowLayoutOptions },
|
|
90
85
|
});
|
|
91
86
|
}
|
|
92
87
|
}
|
|
@@ -100,20 +95,20 @@ export class DashKit extends React.PureComponent {
|
|
|
100
95
|
reflowLayoutOptions: getReflowGroupsConfig(groups),
|
|
101
96
|
});
|
|
102
97
|
}
|
|
98
|
+
metaRef = React.createRef();
|
|
99
|
+
_handlers = new Map();
|
|
103
100
|
render() {
|
|
104
|
-
const content = (React.createElement(DashKitView,
|
|
101
|
+
const content = (React.createElement(DashKitView, { registerManager: registerManager, ref: this.metaRef, ...this.props, emitDashKitEvent: this[_emitSymbol] }));
|
|
105
102
|
if (!this.context && this.props.groups) {
|
|
106
103
|
return React.createElement(DashKitDnDWrapper, null, content);
|
|
107
104
|
}
|
|
108
105
|
return content;
|
|
109
106
|
}
|
|
110
107
|
getItemsMeta() {
|
|
111
|
-
|
|
112
|
-
return (_c = (_b = this.metaRef.current) === null || _b === void 0 ? void 0 : _b.getItemsMeta()) !== null && _c !== void 0 ? _c : [];
|
|
108
|
+
return this.metaRef.current?.getItemsMeta() ?? [];
|
|
113
109
|
}
|
|
114
110
|
reloadItems(options) {
|
|
115
|
-
|
|
116
|
-
(_b = this.metaRef.current) === null || _b === void 0 ? void 0 : _b.reloadItems(options);
|
|
111
|
+
this.metaRef.current?.reloadItems(options);
|
|
117
112
|
}
|
|
118
113
|
/**
|
|
119
114
|
* @experimental This API can change in minor releases.
|
|
@@ -122,13 +117,33 @@ export class DashKit extends React.PureComponent {
|
|
|
122
117
|
* @returns Unsubscribe callback.
|
|
123
118
|
*/
|
|
124
119
|
on(eventName, handler) {
|
|
125
|
-
var _b;
|
|
126
120
|
if (!this._handlers.has(eventName)) {
|
|
127
121
|
this._handlers.set(eventName, new Set());
|
|
128
122
|
}
|
|
129
|
-
|
|
123
|
+
this._handlers.get(eventName)?.add(handler);
|
|
130
124
|
return () => this._off(eventName, handler);
|
|
131
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* @internal
|
|
128
|
+
* @param eventName the event to emit
|
|
129
|
+
* @param event the object passed to its handlers
|
|
130
|
+
* @returns nothing
|
|
131
|
+
*/
|
|
132
|
+
[_emitSymbol] = (eventName, event) => {
|
|
133
|
+
const handlers = this._handlers.get(eventName);
|
|
134
|
+
if (!handlers) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
for (const handler of handlers) {
|
|
138
|
+
try {
|
|
139
|
+
handler(event);
|
|
140
|
+
}
|
|
141
|
+
catch (e) {
|
|
142
|
+
// eslint-disable-next-line no-console
|
|
143
|
+
console.error('DashKit: event handler error', e);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
};
|
|
132
147
|
_off(eventName, handler) {
|
|
133
148
|
const handlers = this._handlers.get(eventName);
|
|
134
149
|
if (handlers) {
|
|
@@ -139,21 +154,4 @@ export class DashKit extends React.PureComponent {
|
|
|
139
154
|
}
|
|
140
155
|
}
|
|
141
156
|
}
|
|
142
|
-
_a = _emitSymbol;
|
|
143
|
-
DashKit.defaultProps = {
|
|
144
|
-
onItemEdit: noop,
|
|
145
|
-
onChange: noop,
|
|
146
|
-
onDrop: noop,
|
|
147
|
-
defaultGlobalParams: {},
|
|
148
|
-
globalParams: {},
|
|
149
|
-
itemsStateAndParams: {},
|
|
150
|
-
settings: {
|
|
151
|
-
autoupdateInterval: 0,
|
|
152
|
-
silentLoading: false,
|
|
153
|
-
},
|
|
154
|
-
context: {},
|
|
155
|
-
noOverlay: false,
|
|
156
|
-
focusable: false,
|
|
157
|
-
};
|
|
158
|
-
DashKit.contextType = DashKitDnDContext;
|
|
159
157
|
//# sourceMappingURL=DashKit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashKit.js","sourceRoot":"../../../../src","sources":["components/DashKit/DashKit.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,IAAI,uBAAoB;AAC/B,OAAO,IAAI,uBAAoB;AAE/B,OAAO,EAAC,aAAa,EAAE,iBAAiB,EAAC,iCAAwB;AACjE,OAAO,EAAC,iBAAiB,EAAC,+BAAsB;AA0BhD,OAAO,EAAC,eAAe,EAAE,aAAa,EAAE,YAAY,EAAC,6BAAoB;AACzE,OAAO,EAAC,iBAAiB,EAAC,kDAA+C;AACzE,OAAO,WAAW,sCAAmC;AAoDrD,MAAM,eAAe,GAAG,IAAI,eAAe,EA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KACvB;IACD,OAAO,EAAE,EAAE;IACX,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,KAAK;CACnB,AAdkB,CAcjB;AAEK,mBAAW,GAAG,iBAAiB,AAApB,CAAqB","sourcesContent":["import React from 'react';\n\nimport noop from 'lodash/noop';\nimport pick from 'lodash/pick';\n\nimport {DEFAULT_GROUP, DEFAULT_NAMESPACE} from '../../constants';\nimport {DashKitDnDContext} from '../../context';\nimport type {\n Config,\n ConfigItem,\n ConfigLayout,\n GlobalParams,\n ItemDropProps,\n ItemsStateAndParams,\n} from '../../shared';\nimport type {\n AddConfigItem,\n AddNewItemOptions,\n ContextProps,\n DashKitEventHandler,\n DashKitEventMap,\n DashKitEventName,\n DashKitGroup,\n GridReflowOptions,\n ItemManipulationCallback,\n MenuItem,\n Plugin,\n ReactGridLayoutProps,\n SetConfigItem,\n Settings,\n SettingsProps,\n} from '../../typings';\nimport {RegisterManager, UpdateManager, reflowLayout} from '../../utils';\nimport {DashKitDnDWrapper} from '../DashKitDnDWrapper/DashKitDnDWrapper';\nimport DashKitView from '../DashKitView/DashKitView';\nimport GridLayout from '../GridLayout/GridLayout';\nimport type {OverlayControlItem, PreparedCopyItemOptions} from '../OverlayControls/OverlayControls';\n\ninterface DashKitGeneralProps {\n config: Config;\n editMode: boolean;\n draggableHandleClassName?: string;\n overlayControls?: Record<string, OverlayControlItem[]> | null;\n overlayMenuItems?: MenuItem[] | null;\n}\n\ninterface DashKitDefaultProps {\n defaultGlobalParams: GlobalParams;\n globalParams: GlobalParams;\n itemsStateAndParams: ItemsStateAndParams;\n settings: SettingsProps;\n context: ContextProps;\n noOverlay: boolean;\n focusable?: boolean;\n groups?: DashKitGroup[];\n\n onItemEdit: (item: ConfigItem) => void;\n onChange: (data: {\n config: Config;\n itemsStateAndParams: ItemsStateAndParams;\n groups?: DashKitGroup[];\n }) => void;\n\n onDrop: (dropProps: ItemDropProps) => void;\n\n onItemMountChange?: (item: ConfigItem, state: {isAsync: boolean; isMounted: boolean}) => void;\n onItemRender?: (item: ConfigItem) => void;\n\n getPreparedCopyItemOptions?: (options: PreparedCopyItemOptions) => PreparedCopyItemOptions;\n onCopyFulfill?: (error: null | Error, data?: PreparedCopyItemOptions) => void;\n\n onItemFocus?: (item: ConfigItem) => void;\n onItemBlur?: (item: ConfigItem) => void;\n\n onDragStart?: ItemManipulationCallback;\n onDrag?: ItemManipulationCallback;\n onDragStop?: ItemManipulationCallback;\n onResizeStart?: ItemManipulationCallback;\n onResize?: ItemManipulationCallback;\n onResizeStop?: ItemManipulationCallback;\n}\n\nexport interface DashKitProps extends DashKitGeneralProps, Partial<DashKitDefaultProps> {}\n\ntype DashKitInnerProps = DashKitGeneralProps & DashKitDefaultProps;\n\nconst registerManager = new RegisterManager();\n\n/**\n * @internal Not part of the public API. Do not use in production code.\n * Module-scoped symbol — not accessible to external consumers holding a ref,\n * preventing synthetic event injection via instance._emit.\n */\nexport const _emitSymbol = Symbol('DashKit._emit');\n\nconst getReflowProps = (props: ReactGridLayoutProps): GridReflowOptions =>\n Object.assign(\n {compactType: 'vertical', cols: 36},\n pick(props, 'cols', 'maxRows', 'compactType'),\n );\n\nconst getReflowGroupsConfig = (groups: DashKitGroup[] = []) => {\n const defaultGridProps = getReflowProps(registerManager.gridLayout);\n\n return {\n defaultProps: defaultGridProps,\n groups: groups.reduce<Record<string, GridReflowOptions>>((memo, g) => {\n const groupId = g.id || DEFAULT_GROUP;\n memo[groupId] = g.gridProperties\n ? getReflowProps(g.gridProperties(defaultGridProps))\n : defaultGridProps;\n\n return memo;\n }, {}),\n };\n};\n\nexport class DashKit extends React.PureComponent<DashKitInnerProps> {\n static defaultProps: DashKitDefaultProps = {\n onItemEdit: noop,\n onChange: noop,\n onDrop: noop,\n defaultGlobalParams: {},\n globalParams: {},\n itemsStateAndParams: {},\n settings: {\n autoupdateInterval: 0,\n silentLoading: false,\n },\n context: {},\n noOverlay: false,\n focusable: false,\n };\n\n static contextType = DashKitDnDContext;\n\n static registerPlugins(...plugins: Plugin[]) {\n plugins.forEach((plugin) => {\n registerManager.registerPlugin(plugin);\n });\n }\n\n static reloadPlugins(...plugins: Plugin[]) {\n plugins.forEach((plugin) => {\n registerManager.reloadPlugin(plugin);\n });\n }\n\n static setSettings(settings: Settings) {\n registerManager.setSettings(settings);\n }\n\n static setItem({\n item: setItem,\n namespace = DEFAULT_NAMESPACE,\n config,\n options = {},\n groups = [],\n }: {\n item: SetConfigItem;\n namespace?: string;\n config: Config;\n options?: Omit<AddNewItemOptions, 'reflowLayoutOptions'>;\n groups?: DashKitGroup[];\n }): Config {\n if (setItem.id) {\n return UpdateManager.editItem({\n item: setItem,\n namespace,\n config,\n options,\n });\n } else {\n const item = setItem as AddConfigItem;\n const registerManagerItem = registerManager.getItem(item.type);\n\n const layout = {...registerManagerItem.defaultLayout};\n\n const reflowLayoutOptions = getReflowGroupsConfig(groups);\n\n const copyItem = {...item};\n\n if (copyItem.layout) {\n Object.assign(layout, copyItem.layout);\n delete copyItem.layout;\n }\n\n return UpdateManager.addItem({\n item: copyItem,\n namespace,\n config,\n layout,\n options: {...options, reflowLayoutOptions},\n });\n }\n }\n\n static removeItem({\n id,\n config,\n itemsStateAndParams,\n }: {\n id: string;\n config: Config;\n itemsStateAndParams: ItemsStateAndParams;\n }): {config: Config; itemsStateAndParams: ItemsStateAndParams} {\n return UpdateManager.removeItem({id, config, itemsStateAndParams});\n }\n\n static reflowLayout({\n newLayoutItem,\n layout,\n groups,\n }: {\n newLayoutItem?: ConfigLayout;\n layout: ConfigLayout[];\n groups?: DashKitGroup[];\n }) {\n return reflowLayout({\n newLayoutItem,\n layout,\n reflowLayoutOptions: getReflowGroupsConfig(groups),\n });\n }\n\n metaRef = React.createRef<GridLayout>();\n\n private _handlers = new Map<string, Set<(...args: any[]) => void>>();\n\n render() {\n const content = (\n <DashKitView\n registerManager={registerManager}\n ref={this.metaRef}\n {...this.props}\n emitDashKitEvent={this[_emitSymbol]}\n />\n );\n\n if (!this.context && this.props.groups) {\n return <DashKitDnDWrapper>{content}</DashKitDnDWrapper>;\n }\n\n return content;\n }\n\n getItemsMeta() {\n return this.metaRef.current?.getItemsMeta() ?? [];\n }\n\n reloadItems(options?: {targetIds?: string[]; force?: boolean}) {\n this.metaRef.current?.reloadItems(options);\n }\n\n /**\n * @experimental This API can change in minor releases.\n * @param eventName Event name.\n * @param handler Event handler.\n * @returns Unsubscribe callback.\n */\n on<T extends DashKitEventName>(eventName: T, handler: DashKitEventHandler<T>): () => void {\n if (!this._handlers.has(eventName)) {\n this._handlers.set(eventName, new Set());\n }\n this._handlers.get(eventName)?.add(handler);\n return () => this._off(eventName, handler);\n }\n\n [_emitSymbol] = <T extends DashKitEventName>(eventName: T, event: DashKitEventMap[T]): void => {\n const handlers = this._handlers.get(eventName);\n if (!handlers) {\n return;\n }\n for (const handler of handlers) {\n try {\n (handler as DashKitEventHandler<T>)(event);\n } catch (e) {\n // eslint-disable-next-line no-console\n console.error('DashKit: event handler error', e);\n }\n }\n };\n\n private _off<T extends DashKitEventName>(eventName: T, handler: DashKitEventHandler<T>): void {\n const handlers = this._handlers.get(eventName);\n if (handlers) {\n handlers.delete(handler);\n if (handlers.size === 0) {\n this._handlers.delete(eventName);\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DashKit.js","sourceRoot":"../../../../src","sources":["components/DashKit/DashKit.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,IAAI,MAAM,wBAAwB,CAAC;AAC1C,OAAO,IAAI,MAAM,wBAAwB,CAAC;AAE1C,OAAO,EAAC,aAAa,EAAE,iBAAiB,EAAC,iCAAwB;AACjE,OAAO,EAAC,iBAAiB,EAAC,+BAAsB;AA0BhD,OAAO,EAAC,eAAe,EAAE,aAAa,EAAE,YAAY,EAAC,6BAAoB;AACzE,OAAO,EAAC,iBAAiB,EAAC,kDAA+C;AACzE,OAAO,WAAW,sCAAmC;AAoDrD,MAAM,eAAe,GAAG,IAAI,eAA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,IAAI,KAAK,CAAC,EAAE,CAAC;gBACtB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YACrC,CAAC;QACL,CAAC;IACL,CAAC","sourcesContent":["import React from 'react';\n\nimport noop from 'es-toolkit/compat/noop';\nimport pick from 'es-toolkit/compat/pick';\n\nimport {DEFAULT_GROUP, DEFAULT_NAMESPACE} from '../../constants';\nimport {DashKitDnDContext} from '../../context';\nimport type {\n Config,\n ConfigItem,\n ConfigLayout,\n GlobalParams,\n ItemDropProps,\n ItemsStateAndParams,\n} from '../../shared';\nimport type {\n AddConfigItem,\n AddNewItemOptions,\n ContextProps,\n DashKitEventHandler,\n DashKitEventMap,\n DashKitEventName,\n DashKitGroup,\n GridReflowOptions,\n ItemManipulationCallback,\n MenuItem,\n Plugin,\n ReactGridLayoutProps,\n SetConfigItem,\n Settings,\n SettingsProps,\n} from '../../typings';\nimport {RegisterManager, UpdateManager, reflowLayout} from '../../utils';\nimport {DashKitDnDWrapper} from '../DashKitDnDWrapper/DashKitDnDWrapper';\nimport DashKitView from '../DashKitView/DashKitView';\nimport GridLayout from '../GridLayout/GridLayout';\nimport type {OverlayControlItem, PreparedCopyItemOptions} from '../OverlayControls/OverlayControls';\n\ninterface DashKitGeneralProps {\n config: Config;\n editMode: boolean;\n draggableHandleClassName?: string;\n overlayControls?: Record<string, OverlayControlItem[]> | null;\n overlayMenuItems?: MenuItem[] | null;\n}\n\ninterface DashKitDefaultProps {\n defaultGlobalParams: GlobalParams;\n globalParams: GlobalParams;\n itemsStateAndParams: ItemsStateAndParams;\n settings: SettingsProps;\n context: ContextProps;\n noOverlay: boolean;\n focusable?: boolean;\n groups?: DashKitGroup[];\n\n onItemEdit: (item: ConfigItem) => void;\n onChange: (data: {\n config: Config;\n itemsStateAndParams: ItemsStateAndParams;\n groups?: DashKitGroup[];\n }) => void;\n\n onDrop: (dropProps: ItemDropProps) => void;\n\n onItemMountChange?: (item: ConfigItem, state: {isAsync: boolean; isMounted: boolean}) => void;\n onItemRender?: (item: ConfigItem) => void;\n\n getPreparedCopyItemOptions?: (options: PreparedCopyItemOptions) => PreparedCopyItemOptions;\n onCopyFulfill?: (error: null | Error, data?: PreparedCopyItemOptions) => void;\n\n onItemFocus?: (item: ConfigItem) => void;\n onItemBlur?: (item: ConfigItem) => void;\n\n onDragStart?: ItemManipulationCallback;\n onDrag?: ItemManipulationCallback;\n onDragStop?: ItemManipulationCallback;\n onResizeStart?: ItemManipulationCallback;\n onResize?: ItemManipulationCallback;\n onResizeStop?: ItemManipulationCallback;\n}\n\nexport interface DashKitProps extends DashKitGeneralProps, Partial<DashKitDefaultProps> {}\n\ntype DashKitInnerProps = DashKitGeneralProps & DashKitDefaultProps;\n\nconst registerManager = new RegisterManager();\n\n/**\n * @internal Not part of the public API. Do not use in production code.\n * A symbol instead of a method name, so that a ref to DashKit does not offer `_emit`. It is exported\n * for tests and left out of the types, but the package root still exports it at runtime.\n */\nexport const _emitSymbol = Symbol('DashKit._emit');\n\nconst getReflowProps = (props: ReactGridLayoutProps): GridReflowOptions =>\n Object.assign(\n {compactType: 'vertical', cols: 36},\n pick(props, 'cols', 'maxRows', 'compactType'),\n );\n\nconst getReflowGroupsConfig = (groups: DashKitGroup[] = []) => {\n const defaultGridProps = getReflowProps(registerManager.gridLayout);\n\n return {\n defaultProps: defaultGridProps,\n groups: groups.reduce<Record<string, GridReflowOptions>>((memo, g) => {\n const groupId = g.id || DEFAULT_GROUP;\n memo[groupId] = g.gridProperties\n ? getReflowProps(g.gridProperties(defaultGridProps))\n : defaultGridProps;\n\n return memo;\n }, {}),\n };\n};\n\nexport class DashKit extends React.PureComponent<DashKitInnerProps> {\n static defaultProps: DashKitDefaultProps = {\n onItemEdit: noop,\n onChange: noop,\n onDrop: noop,\n defaultGlobalParams: {},\n globalParams: {},\n itemsStateAndParams: {},\n settings: {\n autoupdateInterval: 0,\n silentLoading: false,\n },\n context: {},\n noOverlay: false,\n focusable: false,\n };\n\n static contextType = DashKitDnDContext;\n\n static registerPlugins(...plugins: Plugin[]) {\n plugins.forEach((plugin) => {\n registerManager.registerPlugin(plugin);\n });\n }\n\n static reloadPlugins(...plugins: Plugin[]) {\n plugins.forEach((plugin) => {\n registerManager.reloadPlugin(plugin);\n });\n }\n\n static setSettings(settings: Settings) {\n registerManager.setSettings(settings);\n }\n\n static setItem({\n item: setItem,\n namespace = DEFAULT_NAMESPACE,\n config,\n options = {},\n groups = [],\n }: {\n item: SetConfigItem;\n namespace?: string;\n config: Config;\n options?: Omit<AddNewItemOptions, 'reflowLayoutOptions'>;\n groups?: DashKitGroup[];\n }): Config {\n if (setItem.id) {\n return UpdateManager.editItem({\n item: setItem,\n namespace,\n config,\n options,\n });\n } else {\n const item = setItem as AddConfigItem;\n const registerManagerItem = registerManager.getItem(item.type);\n\n const layout = {...registerManagerItem.defaultLayout};\n\n const reflowLayoutOptions = getReflowGroupsConfig(groups);\n\n const copyItem = {...item};\n\n if (copyItem.layout) {\n Object.assign(layout, copyItem.layout);\n delete copyItem.layout;\n }\n\n return UpdateManager.addItem({\n item: copyItem,\n namespace,\n config,\n layout,\n options: {...options, reflowLayoutOptions},\n });\n }\n }\n\n static removeItem({\n id,\n config,\n itemsStateAndParams,\n }: {\n id: string;\n config: Config;\n itemsStateAndParams: ItemsStateAndParams;\n }): {config: Config; itemsStateAndParams: ItemsStateAndParams} {\n return UpdateManager.removeItem({id, config, itemsStateAndParams});\n }\n\n static reflowLayout({\n newLayoutItem,\n layout,\n groups,\n }: {\n newLayoutItem?: ConfigLayout;\n layout: ConfigLayout[];\n groups?: DashKitGroup[];\n }) {\n return reflowLayout({\n newLayoutItem,\n layout,\n reflowLayoutOptions: getReflowGroupsConfig(groups),\n });\n }\n\n metaRef = React.createRef<GridLayout>();\n\n private _handlers = new Map<string, Set<(...args: any[]) => void>>();\n\n render() {\n const content = (\n <DashKitView\n registerManager={registerManager}\n ref={this.metaRef}\n {...this.props}\n emitDashKitEvent={this[_emitSymbol]}\n />\n );\n\n if (!this.context && this.props.groups) {\n return <DashKitDnDWrapper>{content}</DashKitDnDWrapper>;\n }\n\n return content;\n }\n\n getItemsMeta() {\n return this.metaRef.current?.getItemsMeta() ?? [];\n }\n\n reloadItems(options?: {targetIds?: string[]; force?: boolean}) {\n this.metaRef.current?.reloadItems(options);\n }\n\n /**\n * @experimental This API can change in minor releases.\n * @param eventName Event name.\n * @param handler Event handler.\n * @returns Unsubscribe callback.\n */\n on<T extends DashKitEventName>(eventName: T, handler: DashKitEventHandler<T>): () => void {\n if (!this._handlers.has(eventName)) {\n this._handlers.set(eventName, new Set());\n }\n this._handlers.get(eventName)?.add(handler);\n return () => this._off(eventName, handler);\n }\n\n /**\n * @internal\n * @param eventName the event to emit\n * @param event the object passed to its handlers\n * @returns nothing\n */\n [_emitSymbol] = <T extends DashKitEventName>(eventName: T, event: DashKitEventMap[T]): void => {\n const handlers = this._handlers.get(eventName);\n if (!handlers) {\n return;\n }\n for (const handler of handlers) {\n try {\n (handler as DashKitEventHandler<T>)(event);\n } catch (e) {\n // eslint-disable-next-line no-console\n console.error('DashKit: event handler error', e);\n }\n }\n };\n\n private _off<T extends DashKitEventName>(eventName: T, handler: DashKitEventHandler<T>): void {\n const handlers = this._handlers.get(eventName);\n if (handlers) {\n handlers.delete(handler);\n if (handlers.size === 0) {\n this._handlers.delete(eventName);\n }\n }\n }\n}\n"]}
|
|
@@ -13,12 +13,12 @@ export const DashKitDnDWrapper = (props) => {
|
|
|
13
13
|
const onDragStartProp = props.onDragStart;
|
|
14
14
|
const onDragStart = React.useCallback((_, itemDragProps) => {
|
|
15
15
|
setDragProps(itemDragProps);
|
|
16
|
-
onDragStartProp
|
|
16
|
+
onDragStartProp?.(itemDragProps);
|
|
17
17
|
}, [setDragProps, onDragStartProp]);
|
|
18
18
|
const onDragEndProp = props.onDragEnd;
|
|
19
19
|
const onDragEnd = React.useCallback((_) => {
|
|
20
20
|
setDragProps(null);
|
|
21
|
-
onDragEndProp
|
|
21
|
+
onDragEndProp?.();
|
|
22
22
|
}, [setDragProps, onDragEndProp]);
|
|
23
23
|
const contextValue = React.useMemo(() => {
|
|
24
24
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashKitDnDWrapper.js","sourceRoot":"../../../../src","sources":["components/DashKitDnDWrapper/DashKitDnDWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,iBAAiB,EAAC,+BAAsB;AAchD,MAAM,CAAC,MAAM,iBAAiB,GAAqC,CAAC,KAAK,EAAE,EAAE;IACzE,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAuB,IAAI,CAAC,CAAC;IAE7E,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACxC,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,MAAM,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;QACxB,GAAG,CAAC,GAAG,GAAG,KAAK,CAAC,YAAY,CAAC;QAC7B,OAAO,GAAG,CAAC;IACf,CAAC,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;IAEzB,MAAM,eAAe,GAAG,KAAK,CAAC,WAAW,CAAC;IAC1C,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,CACjC,CAAC,CAA2B,EAAE,aAA4B,EAAE,EAAE;QAC1D,YAAY,CAAC,aAAa,CAAC,CAAC;QAC5B,eAAe,
|
|
1
|
+
{"version":3,"file":"DashKitDnDWrapper.js","sourceRoot":"../../../../src","sources":["components/DashKitDnDWrapper/DashKitDnDWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,iBAAiB,EAAC,+BAAsB;AAchD,MAAM,CAAC,MAAM,iBAAiB,GAAqC,CAAC,KAAK,EAAE,EAAE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hF,OAAO,CACH,oBAAC,iBAAiB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,IAC1C,KAAK,CAAC,QAAQ,CACU,CAChC,CAAC;AACN,CAAC,CAAC","sourcesContent":["import React from 'react';\n\nimport {DashKitDnDContext} from '../../context';\nimport type {DraggedOverItem, ItemDragProps} from '../../shared';\n\ntype DashKitDnDWrapperProps = {\n dragImageSrc?: string;\n onDropDragOver?: (\n draggedItem: DraggedOverItem,\n sharedItem: DraggedOverItem | null,\n ) => void | boolean;\n onDragStart?: (dragProps: ItemDragProps) => void;\n onDragEnd?: () => void;\n children: React.ReactElement;\n};\n\nexport const DashKitDnDWrapper: React.FC<DashKitDnDWrapperProps> = (props) => {\n const [dragProps, setDragProps] = React.useState<ItemDragProps | null>(null);\n\n const dragImagePreview = React.useMemo(() => {\n if (!props.dragImageSrc) {\n return null;\n }\n\n const img = new Image();\n img.src = props.dragImageSrc;\n return img;\n }, [props.dragImageSrc]);\n\n const onDragStartProp = props.onDragStart;\n const onDragStart = React.useCallback(\n (_: React.DragEvent<Element>, itemDragProps: ItemDragProps) => {\n setDragProps(itemDragProps);\n onDragStartProp?.(itemDragProps);\n },\n [setDragProps, onDragStartProp],\n );\n\n const onDragEndProp = props.onDragEnd;\n const onDragEnd = React.useCallback(\n (_: React.DragEvent<Element>) => {\n setDragProps(null);\n onDragEndProp?.();\n },\n [setDragProps, onDragEndProp],\n );\n\n const contextValue = React.useMemo(() => {\n return {\n dragProps,\n dragImagePreview,\n onDragStart,\n onDragEnd,\n onDropDragOver: props.onDropDragOver,\n };\n }, [dragProps, dragImagePreview, onDragStart, onDragEnd, props.onDropDragOver]);\n\n return (\n <DashKitDnDContext.Provider value={contextValue}>\n {props.children}\n </DashKitDnDContext.Provider>\n );\n};\n"]}
|
|
@@ -13,7 +13,7 @@ function DashKitView() {
|
|
|
13
13
|
}
|
|
14
14
|
const DashKitViewWithContext = withContext(DashKitView);
|
|
15
15
|
const DashKitViewForwardedMeta = React.forwardRef((props, ref) => {
|
|
16
|
-
return React.createElement(DashKitViewWithContext,
|
|
16
|
+
return React.createElement(DashKitViewWithContext, { ...props, forwardedMetaRef: ref });
|
|
17
17
|
});
|
|
18
18
|
DashKitViewForwardedMeta.displayName = 'DashKitViewForwardedMeta';
|
|
19
19
|
export default DashKitViewForwardedMeta;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashKitView.js","sourceRoot":"../../../../src","sources":["components/DashKitView/DashKitView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,cAAc,EAAC,+BAAsB;AAC7C,OAAO,EAAC,WAAW,EAAC,kCAA+B;AAEnD,OAAO,EAAC,EAAE,EAAC,0BAAuB;AAClC,OAAO,UAAU,oCAAiC;AAClD,OAAO,YAAY,wCAAqC;AAExD,2BAA4B;AAE5B,MAAM,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;AAIxB,SAAS,WAAW;IAChB,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;IACjD,MAAM,EAAC,eAAe,EAAE,gBAAgB,EAAC,GAAG,OAAO,CAAC;IAEpD,OAAO,CACH,6BAAK,SAAS,EAAE,CAAC,CAAC,EAAC,KAAK,EAAE,eAAe,CAAC,QAAQ,CAAC,KAAK,EAAC,CAAC,IACrD,eAAe,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CACjC,oBAAC,YAAY,OAAG,CACnB,CAAC,CAAC,CAAC,CACA,oBAAC,UAAU,IAAC,GAAG,EAAE,gBAAgB,GAAI,CACxC,CACC,CACT,CAAC;AACN,CAAC;AAED,MAAM,sBAAsB,GAAG,WAAW,CAAC,WAAW,CAAC,CAAC;AAExD,MAAM,wBAAwB,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,KAAuB,EAAE,GAAG,EAAE,EAAE;IAC/E,OAAO,oBAAC,sBAAsB,
|
|
1
|
+
{"version":3,"file":"DashKitView.js","sourceRoot":"../../../../src","sources":["components/DashKitView/DashKitView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,cAAc,EAAC,+BAAsB;AAC7C,OAAO,EAAC,WAAW,EAAC,kCAA+B;AAEnD,OAAO,EAAC,EAAE,EAAC,0BAAuB;AAClC,OAAO,UAAU,oCAAiC;AAClD,OAAO,YAAY,wCAAqC;AAExD,2BAA4B;AAE5B,MAAM,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;AAIxB,SAAS,WAAW;IAChB,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;IACjD,MAAM,EAAC,eAAe,EAAE,gBAAgB,EAAC,GAAG,OAAO,CAAC;IAEpD,OAAO,CACH,6BAAK,SAAS,EAAE,CAAC,CAAC,EAAC,KAAK,EAAE,eAAe,CAAC,QAAQ,CAAC,KAAK,EAAC,CAAC,IACrD,eAAe,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CACjC,oBAAC,YAAY,OAAG,CACnB,CAAC,CAAC,CAAC,CACA,oBAAC,UAAU,IAAC,GAAG,EAAE,gBAAgB,GAAI,CACxC,CACC,CACT,CAAC;AACN,CAAC;AAED,MAAM,sBAAsB,GAAG,WAAW,CAAC,WAAW,CAAC,CAAC;AAExD,MAAM,wBAAwB,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,KAAuB,EAAE,GAAG,EAAE,EAAE;IAC/E,OAAO,oBAAC,sBAAsB,OAAK,KAAK,EAAE,gBAAgB,EAAE,GAAG,GAAI,CAAC;AACxE,CAAC,CAAC,CAAC;AAEH,wBAAwB,CAAC,WAAW,GAAG,0BAA0B,CAAC;AAElE,eAAe,wBAAwB,CAAC","sourcesContent":["import React from 'react';\n\nimport {DashKitContext} from '../../context';\nimport {withContext} from '../../hocs/withContext';\nimport type {DashKitWithContextProps} from '../../hocs/withContext';\nimport {cn} from '../../utils/cn';\nimport GridLayout from '../GridLayout/GridLayout';\nimport MobileLayout from '../MobileLayout/MobileLayout';\n\nimport './DashKitView.scss';\n\nconst b = cn('dashkit');\n\ntype DashKitViewProps = Omit<DashKitWithContextProps, 'forwardedMetaRef'>;\n\nfunction DashKitView() {\n const context = React.useContext(DashKitContext);\n const {registerManager, forwardedMetaRef} = context;\n\n return (\n <div className={b({theme: registerManager.settings.theme})}>\n {registerManager.settings.isMobile ? (\n <MobileLayout />\n ) : (\n <GridLayout ref={forwardedMetaRef} />\n )}\n </div>\n );\n}\n\nconst DashKitViewWithContext = withContext(DashKitView);\n\nconst DashKitViewForwardedMeta = React.forwardRef((props: DashKitViewProps, ref) => {\n return <DashKitViewWithContext {...props} forwardedMetaRef={ref} />;\n});\n\nDashKitViewForwardedMeta.displayName = 'DashKitViewForwardedMeta';\n\nexport default DashKitViewForwardedMeta;\n"]}
|