@vuu-ui/vuu-layout 0.5.4 → 0.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/README.md +1 -0
  2. package/cjs/index.js +4 -7379
  3. package/cjs/index.js.map +7 -0
  4. package/esm/index.js +20 -0
  5. package/esm/index.js.map +7 -0
  6. package/index.css +1 -951
  7. package/index.css.map +3 -3
  8. package/package.json +5 -9
  9. package/src/Component.css +0 -2
  10. package/src/Component.tsx +0 -20
  11. package/src/DraggableLayout.css +0 -18
  12. package/src/DraggableLayout.tsx +0 -29
  13. package/src/__tests__/flexbox-utils.spec.js +0 -90
  14. package/src/action-buttons/index.ts +0 -1
  15. package/src/chest-of-drawers/Chest.css +0 -36
  16. package/src/chest-of-drawers/Chest.tsx +0 -42
  17. package/src/chest-of-drawers/Drawer.css +0 -159
  18. package/src/chest-of-drawers/Drawer.tsx +0 -118
  19. package/src/chest-of-drawers/index.ts +0 -2
  20. package/src/common-types.ts +0 -9
  21. package/src/debug.ts +0 -16
  22. package/src/dialog/Dialog.css +0 -16
  23. package/src/dialog/Dialog.tsx +0 -59
  24. package/src/dialog/index.ts +0 -1
  25. package/src/drag-drop/BoxModel.ts +0 -546
  26. package/src/drag-drop/DragState.ts +0 -222
  27. package/src/drag-drop/Draggable.ts +0 -282
  28. package/src/drag-drop/DropMenu.css +0 -71
  29. package/src/drag-drop/DropMenu.tsx +0 -61
  30. package/src/drag-drop/DropTarget.ts +0 -392
  31. package/src/drag-drop/DropTargetRenderer.css +0 -40
  32. package/src/drag-drop/DropTargetRenderer.tsx +0 -279
  33. package/src/drag-drop/dragDropTypes.ts +0 -49
  34. package/src/drag-drop/index.ts +0 -4
  35. package/src/editable-label/EditableLabel.css +0 -28
  36. package/src/editable-label/EditableLabel.tsx +0 -99
  37. package/src/editable-label/index.ts +0 -1
  38. package/src/flexbox/Flexbox.css +0 -45
  39. package/src/flexbox/Flexbox.tsx +0 -70
  40. package/src/flexbox/FlexboxLayout.jsx +0 -26
  41. package/src/flexbox/FluidGrid.css +0 -134
  42. package/src/flexbox/FluidGrid.tsx +0 -84
  43. package/src/flexbox/FluidGridLayout.tsx +0 -10
  44. package/src/flexbox/Splitter.css +0 -140
  45. package/src/flexbox/Splitter.tsx +0 -135
  46. package/src/flexbox/flexbox-utils.ts +0 -128
  47. package/src/flexbox/flexboxTypes.ts +0 -63
  48. package/src/flexbox/index.ts +0 -4
  49. package/src/flexbox/useResponsiveSizing.ts +0 -85
  50. package/src/flexbox/useSplitterResizing.ts +0 -272
  51. package/src/index.ts +0 -21
  52. package/src/layout-action.ts +0 -21
  53. package/src/layout-header/ActionButton.tsx +0 -23
  54. package/src/layout-header/Header.css +0 -8
  55. package/src/layout-header/Header.tsx +0 -222
  56. package/src/layout-header/index.ts +0 -1
  57. package/src/layout-provider/LayoutProvider.tsx +0 -160
  58. package/src/layout-provider/LayoutProviderContext.ts +0 -17
  59. package/src/layout-provider/index.ts +0 -2
  60. package/src/layout-provider/useLayoutDragDrop.ts +0 -241
  61. package/src/layout-reducer/flexUtils.ts +0 -281
  62. package/src/layout-reducer/index.ts +0 -4
  63. package/src/layout-reducer/insert-layout-element.ts +0 -365
  64. package/src/layout-reducer/layout-reducer.ts +0 -255
  65. package/src/layout-reducer/layoutTypes.ts +0 -151
  66. package/src/layout-reducer/layoutUtils.ts +0 -302
  67. package/src/layout-reducer/remove-layout-element.ts +0 -240
  68. package/src/layout-reducer/replace-layout-element.ts +0 -118
  69. package/src/layout-reducer/resize-flex-children.ts +0 -56
  70. package/src/layout-reducer/wrap-layout-element.ts +0 -317
  71. package/src/layout-view/View.css +0 -61
  72. package/src/layout-view/View.tsx +0 -149
  73. package/src/layout-view/ViewContext.ts +0 -31
  74. package/src/layout-view/index.ts +0 -4
  75. package/src/layout-view/useView.tsx +0 -104
  76. package/src/layout-view/useViewActionDispatcher.ts +0 -133
  77. package/src/layout-view/useViewResize.ts +0 -53
  78. package/src/layout-view/viewTypes.ts +0 -37
  79. package/src/menu/ContextMenu.css +0 -22
  80. package/src/menu/ContextMenu.jsx +0 -121
  81. package/src/menu/MenuList.css +0 -150
  82. package/src/menu/MenuList.jsx +0 -179
  83. package/src/menu/aim/aim.js +0 -92
  84. package/src/menu/aim/corners.js +0 -114
  85. package/src/menu/aim/point-in-polygon.js +0 -25
  86. package/src/menu/aim/utils.js +0 -19
  87. package/src/menu/context-menu-provider.jsx +0 -135
  88. package/src/menu/index.js +0 -4
  89. package/src/menu/key-code.js +0 -61
  90. package/src/menu/list-dom-utils.js +0 -22
  91. package/src/menu/use-cascade.js +0 -292
  92. package/src/menu/use-click-away.js +0 -22
  93. package/src/menu/use-items-with-ids.js +0 -75
  94. package/src/menu/use-keyboard-navigation.js +0 -162
  95. package/src/menu/utils.js +0 -5
  96. package/src/palette/Palette.css +0 -37
  97. package/src/palette/Palette.tsx +0 -140
  98. package/src/palette/PaletteSalt.css +0 -9
  99. package/src/palette/PaletteSalt.tsx +0 -79
  100. package/src/palette/index.ts +0 -2
  101. package/src/placeholder/Placeholder.css +0 -10
  102. package/src/placeholder/Placeholder.tsx +0 -39
  103. package/src/placeholder/index.ts +0 -1
  104. package/src/popup/index.js +0 -2
  105. package/src/popup/popup-provider.js +0 -0
  106. package/src/popup/popup-service.css +0 -15
  107. package/src/popup/popup-service.js +0 -281
  108. package/src/portal/Portal.jsx +0 -50
  109. package/src/portal/index.ts +0 -3
  110. package/src/portal/render-portal.jsx +0 -68
  111. package/src/portal/utils.js +0 -16
  112. package/src/registry/ComponentRegistry.ts +0 -35
  113. package/src/registry/index.ts +0 -1
  114. package/src/responsive/OverflowMenu.css +0 -31
  115. package/src/responsive/OverflowMenu.jsx +0 -56
  116. package/src/responsive/breakpoints.ts +0 -62
  117. package/src/responsive/index.ts +0 -4
  118. package/src/responsive/measureMinimumNodeSize.ts +0 -23
  119. package/src/responsive/overflowUtils.js +0 -14
  120. package/src/responsive/use-breakpoints.ts +0 -100
  121. package/src/responsive/useOverflowObserver.ts +0 -606
  122. package/src/responsive/useResizeObserver.ts +0 -154
  123. package/src/responsive/utils.ts +0 -37
  124. package/src/stack/Stack.css +0 -39
  125. package/src/stack/Stack.tsx +0 -161
  126. package/src/stack/StackLayout.tsx +0 -137
  127. package/src/stack/index.ts +0 -3
  128. package/src/stack/stackTypes.ts +0 -19
  129. package/src/tabs/TabPanel.css +0 -12
  130. package/src/tabs/TabPanel.tsx +0 -17
  131. package/src/tabs/index.ts +0 -1
  132. package/src/tools/config-wrapper/ConfigWrapper.jsx +0 -53
  133. package/src/tools/config-wrapper/index.js +0 -1
  134. package/src/tools/devtools-box/layout-configurator.css +0 -112
  135. package/src/tools/devtools-box/layout-configurator.jsx +0 -369
  136. package/src/tools/devtools-tree/layout-tree-viewer.css +0 -15
  137. package/src/tools/devtools-tree/layout-tree-viewer.jsx +0 -36
  138. package/src/tools/index.js +0 -3
  139. package/src/use-persistent-state.ts +0 -115
  140. package/src/utils/apply-handlers.js +0 -15
  141. package/src/utils/componentFromLayout.tsx +0 -30
  142. package/src/utils/index.ts +0 -6
  143. package/src/utils/pathUtils.ts +0 -294
  144. package/src/utils/propUtils.ts +0 -24
  145. package/src/utils/refUtils.ts +0 -16
  146. package/src/utils/styleUtils.ts +0 -14
  147. package/src/utils/typeOf.ts +0 -22
@@ -1,112 +0,0 @@
1
- [data-design-mode='true'] .Component {
2
- filter: grayscale(100%);
3
- opacity: 0.4;
4
- }
5
-
6
- [data-design-mode='true'] .Component:after {
7
- color: black;
8
- content: 'Component';
9
- height: 12px;
10
- background-color: yellow;
11
- }
12
-
13
- .LayoutConfigurator {
14
- --margin-color: #f3cea5;
15
- --border-color: #fddda0;
16
- --padding-color: #c6d092;
17
- --content-color: #8cb6c0;
18
- display: flex;
19
- flex-direction: column;
20
- align-items: stretch;
21
- background-color: var(--margin-color);
22
- }
23
-
24
- .LayoutConfigurator .layout-outer {
25
- flex: 1 1 auto;
26
- display: flex;
27
- flex-direction: column;
28
- align-items: stretch;
29
- }
30
-
31
- .LayoutBox {
32
- --hw-control-font-size: 13px;
33
- --hw-text-input-bg: rgba(255, 255, 255, 0.3);
34
- --hwTextInput-padding: 3px;
35
- --hw-text-input-position: absolute;
36
- --hwTextInput-width: 30px;
37
-
38
- flex: 1 1 auto;
39
- }
40
-
41
- .LayoutBox > .layout-top {
42
- flex: 0 0 40px;
43
- padding-left: 12px;
44
- display: flex;
45
- flex-direction: row;
46
- align-items: center;
47
- position: relative;
48
- }
49
-
50
- .LayoutBox > .layout-bottom {
51
- flex: 0 0 40px;
52
- position: relative;
53
- display: flex;
54
- flex-direction: row;
55
- align-items: center;
56
- }
57
-
58
- .LayoutBox > .layout-inner > .layout-right,
59
- .LayoutBox > .layout-inner > .layout-left {
60
- flex: 0 0 40px;
61
- display: flex;
62
- flex-direction: column;
63
- justify-content: center;
64
- align-items: center;
65
- }
66
-
67
- .layout-top,
68
- .layout-bottom {
69
- --hw-text-input-margin: 0 0 0 -15px;
70
- }
71
-
72
- .layout-top > .layout-input,
73
- .layout-bottom > .layout-input {
74
- left: 50%;
75
- }
76
-
77
- .LayoutBox > .layout-inner {
78
- flex: 1 1 auto;
79
- display: flex;
80
- flex-direction: row;
81
- align-items: stretch;
82
- }
83
-
84
- .LayoutBox.layout-margin {
85
- background-color: var(--margin-color);
86
- border: dashed 2px black;
87
- }
88
-
89
- .LayoutBox.layout-border {
90
- background-color: var(--border-color);
91
- border: solid 2px black;
92
- }
93
-
94
- .LayoutBox.layout-padding {
95
- background-color: var(--padding-color);
96
- border: dashed 2px black;
97
- }
98
-
99
- .LayoutBox .layout-content {
100
- flex: 1 1 auto;
101
- background-color: var(--content-color);
102
- border: solid 2px #808080;
103
- }
104
-
105
- .LayoutBox .layout-title {
106
- color: #161616;
107
- font-size: 11px;
108
- left: 4px;
109
- line-height: 15px;
110
- position: absolute;
111
- top: 1px;
112
- }
@@ -1,369 +0,0 @@
1
- import "./layout-configurator.css";
2
- import { FormField, Input } from "@heswell/salt-lab";
3
-
4
- const NO_STYLE = {};
5
-
6
- const DIMENSIONS = {
7
- margin: {
8
- top: "marginTop",
9
- right: "marginRight",
10
- bottom: "marginBottom",
11
- left: "marginLeft",
12
- },
13
- border: {
14
- top: "borderTopWidth",
15
- right: "borderRightWidth",
16
- bottom: "borderBottomWidth",
17
- left: "borderLeftWidth",
18
- },
19
- padding: {
20
- top: "paddingTop",
21
- right: "paddingRight",
22
- bottom: "paddingBottom",
23
- left: "paddingLeft",
24
- },
25
- };
26
-
27
- const LayoutBox = ({ feature, children, style, onChange }) => {
28
- return (
29
- <div className={`LayoutBox layout-${feature} layout-outer`}>
30
- <div className={`layout-top`}>
31
- <span className="layout-title">{feature}</span>
32
- <FormField className="layout-input" style={{ width: 30 }}>
33
- <Input
34
- value={style.top}
35
- onChange={(evt, value) => onChange(feature, "top", value)}
36
- />
37
- </FormField>
38
- </div>
39
- <div className={`layout-inner`}>
40
- <div className={`layout-left`}>
41
- <FormField className="layout-input" style={{ width: 30 }}>
42
- <Input
43
- value={style.left}
44
- onChange={(evt, value) => onChange(feature, "left", value)}
45
- />
46
- </FormField>
47
- </div>
48
- {children}
49
- <div className={`layout-right`}>
50
- <FormField className="layout-input" style={{ width: 30 }}>
51
- <Input
52
- value={style.right}
53
- onChange={(evt, value) => onChange(feature, "right", value)}
54
- />
55
- </FormField>
56
- </div>
57
- </div>
58
- <div className={`layout-bottom`}>
59
- <FormField className="layout-input" style={{ width: 30 }}>
60
- <Input
61
- value={style.bottom}
62
- onChange={(evt, value) => onChange(feature, "bottom", value)}
63
- />
64
- </FormField>
65
- </div>
66
- </div>
67
- );
68
- };
69
-
70
- export const MARGIN_STYLES = {
71
- margin: true,
72
- marginTop: true,
73
- marginRight: true,
74
- marginBottom: true,
75
- marginLeft: true,
76
- };
77
-
78
- export const PADDING_STYLES = {
79
- padding: true,
80
- paddingTop: true,
81
- paddingRight: true,
82
- paddingBottom: true,
83
- paddingLeft: true,
84
- };
85
-
86
- export const BORDER_STYLES = {
87
- border: true,
88
- borderColor: true,
89
- borderWidth: true,
90
- borderTopWidth: true,
91
- borderRightWidth: true,
92
- borderBottomWidth: true,
93
- borderLeftWidth: true,
94
- };
95
-
96
- const CSS_DIGIT = "(\\d+)(?:px)?";
97
- const CSS_MEASURE = `^(?:${CSS_DIGIT}(?:\\s${CSS_DIGIT}(?:\\s${CSS_DIGIT}(?:\\s${CSS_DIGIT})?)?)?)$`;
98
- const CSS_REX = new RegExp(CSS_MEASURE);
99
- const BORDER_REX = /^(?:(\d+)(?:px)\ssolid\s([a-zA-Z,0-9().]+))$/;
100
-
101
- export const LayoutConfigurator = ({
102
- height,
103
- managedStyle,
104
- onChange,
105
- style,
106
- width,
107
- }) => {
108
- const state = normalizeStyle(managedStyle);
109
-
110
- const handleChange = (feature, dimension, strValue) => {
111
- const value = parseInt(strValue || "0", 10);
112
- const property = DIMENSIONS[feature][dimension];
113
- onChange(property, value);
114
- };
115
-
116
- const {
117
- marginTop: mt = 0,
118
- marginRight: mr = 0,
119
- marginBottom: mb = 0,
120
- marginLeft: ml = 0,
121
- } = state;
122
- const {
123
- borderTopWidth: bt = 0,
124
- borderRightWidth: br = 0,
125
- borderBottomWidth: bb = 0,
126
- borderLeftWidth: bl = 0,
127
- } = state;
128
- const {
129
- paddingTop: pt = 0,
130
- paddingRight: pr = 0,
131
- paddingBottom: pb = 0,
132
- paddingLeft: pl = 0,
133
- } = state;
134
- return (
135
- <div className="LayoutConfigurator" style={{ width, height, ...style }}>
136
- <LayoutBox
137
- feature="margin"
138
- style={{ top: mt, right: mr, bottom: mb, left: ml }}
139
- onChange={handleChange}
140
- >
141
- <LayoutBox
142
- feature="border"
143
- style={{ top: bt, right: br, bottom: bb, left: bl }}
144
- onChange={handleChange}
145
- >
146
- <LayoutBox
147
- feature="padding"
148
- style={{ top: pt, right: pr, bottom: pb, left: pl }}
149
- onChange={handleChange}
150
- >
151
- <div className="layout-content" />
152
- </LayoutBox>
153
- </LayoutBox>
154
- </LayoutBox>
155
- </div>
156
- );
157
- };
158
-
159
- // TODO merge the following two functions
160
- export function XXXnormalizeStyles(
161
- layoutStyle = NO_STYLE,
162
- visualStyle = NO_STYLE
163
- ) {
164
- const {
165
- margin,
166
- marginTop,
167
- marginRight,
168
- marginBottom,
169
- marginLeft,
170
- padding,
171
- paddingTop,
172
- paddingRight,
173
- paddingBottom,
174
- paddingLeft,
175
- ...style
176
- } = layoutStyle;
177
-
178
- if (typeof margin === "number") {
179
- style.marginTop =
180
- style.marginRight =
181
- style.marginBottom =
182
- style.marginLeft =
183
- margin;
184
- } else if (typeof margin === "string") {
185
- const match = CSS_REX.exec(margin);
186
- if (match === null) {
187
- console.error(`Invalid css value for margin '${margin}'`);
188
- } else {
189
- const [, pos1, pos2, pos3, pos4] = match;
190
- const pos123 = pos1 && pos2 && pos3;
191
- if (pos123 && pos4) {
192
- style.marginTop = parseInt(pos1, 10);
193
- style.marginRight = parseInt(pos2, 10);
194
- style.marginBottom = parseInt(pos3, 10);
195
- style.marginLeft = parseInt(pos4, 10);
196
- } else if (pos123) {
197
- style.marginTop = parseInt(pos1, 10);
198
- style.marginRight = style.marginLeft = parseInt(pos2, 10);
199
- style.marginBottom = parseInt(pos3, 10);
200
- } else if (pos1 && pos2) {
201
- style.marginTop = style.marginBottom = parseInt(pos1, 10);
202
- style.marginRight = style.marginLeft = parseInt(pos2, 10);
203
- } else {
204
- style.marginTop =
205
- style.marginRight =
206
- style.marginBottom =
207
- style.marginLeft =
208
- parseInt(pos1, 10);
209
- }
210
- }
211
- }
212
- if (typeof marginTop === "number") style.marginTop = marginTop;
213
- if (typeof marginRight === "number") style.marginRight = marginRight;
214
- if (typeof marginBottom === "number") style.marginBottom = marginBottom;
215
- if (typeof marginLeft === "number") style.marginLeft = marginLeft;
216
-
217
- if (typeof padding === "number") {
218
- style.paddingTop =
219
- style.paddingRight =
220
- style.paddingBottom =
221
- style.paddingLeft =
222
- padding;
223
- } else if (typeof padding === "string") {
224
- const match = CSS_REX.exec(padding);
225
- if (match === null) {
226
- console.error(`Invalid css value for padding '${padding}'`);
227
- } else {
228
- const [, pos1, pos2, pos3, pos4] = match;
229
- const pos123 = pos1 && pos2 && pos3;
230
- if (pos123 && pos4) {
231
- style.paddingTop = parseInt(pos1, 10);
232
- style.paddingRight = parseInt(pos2, 10);
233
- style.paddingBottom = parseInt(pos3, 10);
234
- style.paddingLeft = parseInt(pos4, 10);
235
- } else if (pos123) {
236
- style.paddingTop = parseInt(pos1, 10);
237
- style.paddingRight = style.paddingLeft = parseInt(pos2, 10);
238
- style.paddingBottom = parseInt(pos3, 10);
239
- } else if (pos1 && pos2) {
240
- style.paddingTop = style.paddingBottom = parseInt(pos1, 10);
241
- style.paddingRight = style.paddingLeft = parseInt(pos2, 10);
242
- } else {
243
- style.paddingTop =
244
- style.paddingRight =
245
- style.paddingBottom =
246
- style.paddinggLeft =
247
- parseInt(pos1, 10);
248
- }
249
- }
250
- }
251
- if (typeof paddingTop === "number") style.paddingTop = paddingTop;
252
- if (typeof paddingRight === "number") style.paddingRight = paddingRight;
253
- if (typeof paddingBottom === "number") style.paddingBottom = paddingBottom;
254
- if (typeof paddingLeft === "number") style.paddingLeft = paddingLeft;
255
-
256
- return normalizeStyle(style, visualStyle);
257
- }
258
-
259
- function normalizeStyle(managedStyle = NO_STYLE) {
260
- const style = { ...managedStyle };
261
-
262
- // if (BORDER_LIST.some(bs => style[bs])) {
263
- let match;
264
-
265
- let {
266
- border,
267
- borderWidth,
268
- borderTopWidth,
269
- borderRightWidth,
270
- borderBottomWidth,
271
- borderLeftWidth,
272
- borderColor,
273
- margin,
274
- marginTop,
275
- marginRight,
276
- marginBottom,
277
- marginLeft,
278
- padding,
279
- paddingTop,
280
- paddingRight,
281
- paddingBottom,
282
- paddingLeft,
283
- ...rest
284
- } = style;
285
-
286
- let marginStyles = {};
287
- let paddingStyles = {};
288
-
289
- if (typeof margin === "number") {
290
- style.marginTop =
291
- style.marginRight =
292
- style.marginBottom =
293
- style.marginLeft =
294
- margin;
295
- marginStyles = {
296
- marginTop: margin,
297
- marginRight: margin,
298
- marginBottom: margin,
299
- marginLeft: margin,
300
- };
301
- }
302
-
303
- if (typeof padding === "number") {
304
- style.paddingTop =
305
- style.paddingRight =
306
- style.paddingBottom =
307
- style.paddingLeft =
308
- padding;
309
- paddingStyles = {
310
- paddingTop: padding,
311
- paddingRight: padding,
312
- paddingBottom: padding,
313
- paddingLeft: padding,
314
- };
315
- }
316
-
317
- if (
318
- border ||
319
- borderWidth ||
320
- borderTopWidth ||
321
- borderRightWidth ||
322
- borderBottomWidth ||
323
- borderLeftWidth
324
- ) {
325
- if (typeof border === "string" && (match = BORDER_REX.exec(border))) {
326
- // what if both border and borderWidth are specified ?
327
- [, borderWidth, borderColor] = match;
328
- borderWidth = parseInt(borderWidth, 10);
329
- }
330
-
331
- if (borderWidth) {
332
- borderTopWidth =
333
- borderTopWidth === undefined ? borderWidth : borderTopWidth;
334
- borderRightWidth =
335
- borderRightWidth === undefined ? borderWidth : borderRightWidth;
336
- borderBottomWidth =
337
- borderBottomWidth === undefined ? borderWidth : borderBottomWidth;
338
- borderLeftWidth =
339
- borderLeftWidth === undefined ? borderWidth : borderLeftWidth;
340
- }
341
-
342
- borderColor = borderColor || "black";
343
- const boxShadow = `
344
- ${borderColor} ${borderLeftWidth || 0}px ${
345
- borderTopWidth || 0
346
- }px 0 0 inset,
347
- ${borderColor} ${-borderRightWidth || 0}px ${
348
- -borderBottomWidth || 0
349
- }px 0 0 inset`;
350
-
351
- return {
352
- ...rest,
353
- ...marginStyles,
354
- ...paddingStyles,
355
- borderTopWidth,
356
- borderRightWidth,
357
- borderBottomWidth,
358
- borderLeftWidth,
359
- borderColor,
360
- borderStyle: "solid",
361
- boxShadow,
362
- };
363
- } else {
364
- return style;
365
- }
366
- // } else {
367
- // return style;
368
- // }
369
- }
@@ -1,15 +0,0 @@
1
- .hwLayoutTreeViewer {
2
- }
3
-
4
- .hwLayoutTreeNode {
5
- cursor: default;
6
- }
7
-
8
- .hwLayoutTreeNode:hover {
9
- background-color: rgba(255, 255, 255, 0.2);
10
- }
11
-
12
- .hwLayoutTreeNode[aria-selected='true'] {
13
- background-color: cornflowerblue;
14
- color: white;
15
- }
@@ -1,36 +0,0 @@
1
- import React from "react";
2
- import cx from "classnames";
3
- import { typeOf } from "../../utils";
4
-
5
- import "./layout-tree-viewer.css";
6
- import { Tree } from "@heswell/salt-lab";
7
-
8
- const classBaseTree = "hwLayoutTreeViewer";
9
-
10
- const toTreeJson = (component, path = "0") => {
11
- return {
12
- label: typeOf(component),
13
- path,
14
- childNodes: React.Children.map(component.props.children, (child, i) =>
15
- toTreeJson(child, path ? `${path}.${i}` : `${i}`)
16
- ),
17
- };
18
- };
19
-
20
- export const LayoutTreeViewer = ({ layout, onSelect, style }) => {
21
- const treeJson = [toTreeJson(layout)];
22
-
23
- const handleSelection = (evt, [{ path }]) => {
24
- onSelect(path);
25
- };
26
-
27
- return (
28
- <div className={cx(classBaseTree)} style={style}>
29
- <Tree
30
- source={treeJson}
31
- groupSelection="single"
32
- onSelectionChange={handleSelection}
33
- />
34
- </div>
35
- );
36
- };
@@ -1,3 +0,0 @@
1
- export * from './config-wrapper';
2
- export * from './devtools-box/layout-configurator';
3
- export * from './devtools-tree/layout-tree-viewer';
@@ -1,115 +0,0 @@
1
- import { useCallback } from "react";
2
-
3
- const persistentState = new Map<string, any>();
4
- const sessionState = new Map<string, any>();
5
-
6
- // These is not exported by package, only available within
7
- // layout. Used by LayoutProvider for layout serialization.
8
- export const getPersistentState = (id: string) => persistentState.get(id);
9
- export const hasPersistentState = (id: string) => persistentState.has(id);
10
- export const setPersistentState = (id: string, value: any) =>
11
- persistentState.set(id, value);
12
-
13
- export const usePersistentState = () => {
14
- //TODO create single set of methods that operate on either session or state
15
-
16
- const loadSessionState = useCallback((id, key) => {
17
- const state = sessionState.get(id);
18
- if (state) {
19
- if (key !== undefined && state[key] !== undefined) {
20
- return state[key];
21
- } else if (key !== undefined) {
22
- return undefined;
23
- } else {
24
- return state;
25
- }
26
- }
27
- }, []);
28
-
29
- const saveSessionState = useCallback((id, key, data) => {
30
- if (key === undefined) {
31
- sessionState.set(id, data);
32
- } else if (sessionState.has(id)) {
33
- const state = sessionState.get(id);
34
- sessionState.set(id, {
35
- ...state,
36
- [key]: data,
37
- });
38
- } else {
39
- sessionState.set(id, { [key]: data });
40
- }
41
- }, []);
42
-
43
- const purgeSessionState = useCallback((id: string, key?: string) => {
44
- if (sessionState.has(id)) {
45
- if (key === undefined) {
46
- sessionState.delete(id);
47
- } else {
48
- const state = sessionState.get(id);
49
- if (state[key]) {
50
- const { [key]: _doomedState, ...rest } = sessionState.get(id);
51
- if (Object.keys(rest).length > 0) {
52
- sessionState.set(id, rest);
53
- } else {
54
- sessionState.delete(id);
55
- }
56
- }
57
- }
58
- }
59
- }, []);
60
-
61
- const loadState = useCallback((id: string, key?: string) => {
62
- const state = persistentState.get(id);
63
- if (state) {
64
- if (key !== undefined) {
65
- return state[key];
66
- } else {
67
- return state;
68
- }
69
- }
70
- }, []);
71
-
72
- const saveState = useCallback(
73
- (id: string, key: string | undefined, data: any) => {
74
- if (key === undefined) {
75
- persistentState.set(id, data);
76
- } else if (persistentState.has(id)) {
77
- const state = persistentState.get(id);
78
- persistentState.set(id, {
79
- ...state,
80
- [key]: data,
81
- });
82
- } else {
83
- persistentState.set(id, { [key]: data });
84
- }
85
- },
86
- []
87
- );
88
-
89
- const purgeState = useCallback((id: string, key?: string) => {
90
- if (persistentState.has(id)) {
91
- if (key === undefined) {
92
- persistentState.delete(id);
93
- } else {
94
- const state = persistentState.get(id);
95
- if (state[key]) {
96
- const { [key]: _doomedState, ...rest } = persistentState.get(id);
97
- if (Object.keys(rest).length > 0) {
98
- persistentState.set(id, rest);
99
- } else {
100
- persistentState.delete(id);
101
- }
102
- }
103
- }
104
- }
105
- }, []);
106
-
107
- return {
108
- loadSessionState,
109
- loadState,
110
- saveSessionState,
111
- saveState,
112
- purgeState,
113
- purgeSessionState,
114
- };
115
- };
@@ -1,15 +0,0 @@
1
- export const applyHandlers = (props, evtName, ...params) => {
2
- const isPropagationStopped = () => params?.[0].isPropagationStopped?.();
3
-
4
- if (props.length > 0 && !isPropagationStopped()) {
5
- const additionalHandlers = props
6
- .filter((props) => props[evtName])
7
- .map((props) => props[evtName]);
8
- for (let handleEvent of additionalHandlers) {
9
- if (isPropagationStopped()) {
10
- break;
11
- }
12
- handleEvent(...params);
13
- }
14
- }
15
- };
@@ -1,30 +0,0 @@
1
- import React from 'react';
2
- import { LayoutJSON } from '../layout-reducer';
3
- import { ComponentRegistry } from '../registry/ComponentRegistry';
4
-
5
- export function componentFromLayout(layoutModel: LayoutJSON) {
6
-
7
- const { id, type, props, children: layoutChildren } = layoutModel;
8
- const ReactType = getComponentType(type);
9
- let children =
10
- !layoutChildren || layoutChildren.length === 0
11
- ? null
12
- : layoutChildren.length === 1
13
- ? componentFromLayout(layoutChildren[0])
14
- : layoutChildren.map(componentFromLayout);
15
-
16
- return (
17
- <ReactType {...props} key={id}>
18
- {children}
19
- </ReactType>
20
- );
21
- }
22
-
23
- // support for built-in react ttpes (div etc) removed here
24
- function getComponentType(type: string) {
25
- const reactType = ComponentRegistry[type];
26
- if (reactType === undefined){
27
- throw Error('componentFromLayout: unknown component type: ' + type);
28
- }
29
- return reactType;
30
- }
@@ -1,6 +0,0 @@
1
- export * from "./styleUtils";
2
- export * from "./pathUtils";
3
- export * from "./propUtils";
4
- export * from "./typeOf";
5
- export * from "./componentFromLayout";
6
- export * from "./refUtils";