@rettangoli/ui 0.1.31 → 0.1.32-rc1
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 -85
- package/dist/rettangoli-iife-layout.min.js +113 -173
- package/dist/rettangoli-iife-ui.min.js +123 -183
- package/package.json +5 -4
- package/src/common/dimensions.js +72 -0
- package/src/common/link.js +111 -0
- package/src/common/responsive.js +8 -0
- package/src/common.js +43 -8
- package/src/components/accordionItem/accordionItem.handlers.js +1 -1
- package/src/components/accordionItem/accordionItem.schema.yaml +14 -0
- package/src/components/accordionItem/accordionItem.store.js +8 -8
- package/src/components/accordionItem/accordionItem.view.yaml +5 -35
- package/src/components/breadcrumb/breadcrumb.handlers.js +24 -3
- package/src/components/breadcrumb/breadcrumb.schema.yaml +51 -0
- package/src/components/breadcrumb/breadcrumb.store.js +66 -10
- package/src/components/breadcrumb/breadcrumb.view.yaml +18 -58
- package/src/components/dropdownMenu/dropdownMenu.handlers.js +17 -3
- package/src/components/dropdownMenu/dropdownMenu.schema.yaml +64 -0
- package/src/components/dropdownMenu/dropdownMenu.store.js +48 -6
- package/src/components/dropdownMenu/dropdownMenu.view.yaml +24 -46
- package/src/components/form/form.handlers.js +25 -108
- package/src/components/form/form.schema.yaml +283 -0
- package/src/components/form/form.store.js +19 -14
- package/src/components/form/form.view.yaml +28 -319
- package/src/components/globalUi/globalUi.handlers.js +2 -2
- package/src/components/globalUi/globalUi.schema.yaml +8 -0
- package/src/components/globalUi/globalUi.store.js +8 -8
- package/src/components/globalUi/globalUi.view.yaml +9 -46
- package/src/components/navbar/navbar.handlers.js +1 -1
- package/src/components/navbar/navbar.schema.yaml +25 -0
- package/src/components/navbar/navbar.store.js +28 -14
- package/src/components/navbar/navbar.view.yaml +21 -65
- package/src/components/pageOutline/pageOutline.handlers.js +17 -11
- package/src/components/pageOutline/pageOutline.schema.yaml +16 -0
- package/src/components/pageOutline/pageOutline.store.js +6 -7
- package/src/components/pageOutline/pageOutline.view.yaml +1 -29
- package/src/components/popoverInput/popoverInput.handlers.js +31 -31
- package/src/components/popoverInput/popoverInput.schema.yaml +18 -0
- package/src/components/popoverInput/popoverInput.store.js +9 -9
- package/src/components/popoverInput/popoverInput.view.yaml +5 -22
- package/src/components/select/select.handlers.js +31 -35
- package/src/components/select/select.schema.yaml +36 -0
- package/src/components/select/select.store.js +34 -35
- package/src/components/select/select.view.yaml +13 -56
- package/src/components/sidebar/sidebar.handlers.js +5 -5
- package/src/components/sidebar/sidebar.schema.yaml +57 -0
- package/src/components/sidebar/sidebar.store.js +45 -23
- package/src/components/sidebar/sidebar.view.yaml +79 -174
- package/src/components/sliderInput/sliderInput.handlers.js +28 -8
- package/src/components/sliderInput/sliderInput.schema.yaml +27 -0
- package/src/components/sliderInput/sliderInput.store.js +9 -9
- package/src/components/sliderInput/sliderInput.view.yaml +8 -33
- package/src/components/table/table.handlers.js +3 -3
- package/src/components/table/table.schema.yaml +27 -0
- package/src/components/table/table.store.js +8 -8
- package/src/components/table/table.view.yaml +16 -62
- package/src/components/tabs/tabs.schema.yaml +26 -0
- package/src/components/tabs/tabs.store.js +12 -9
- package/src/components/tabs/tabs.view.yaml +4 -60
- package/src/components/tooltip/tooltip.schema.yaml +18 -0
- package/src/components/tooltip/tooltip.store.js +7 -7
- package/src/components/tooltip/tooltip.view.yaml +4 -22
- package/src/components/waveform/waveform.handlers.js +6 -6
- package/src/components/waveform/waveform.schema.yaml +25 -0
- package/src/components/waveform/waveform.store.js +6 -6
- package/src/components/waveform/waveform.view.yaml +6 -34
- package/src/deps/createGlobalUI.js +2 -2
- package/src/primitives/button.js +200 -114
- package/src/primitives/colorPicker.js +56 -50
- package/src/primitives/dialog.js +2 -1
- package/src/primitives/image.js +73 -103
- package/src/primitives/input-number.js +139 -93
- package/src/primitives/input.js +87 -64
- package/src/primitives/popover.js +36 -28
- package/src/primitives/slider.js +6 -4
- package/src/primitives/svg.js +9 -10
- package/src/primitives/text.js +26 -47
- package/src/primitives/textarea.js +25 -9
- package/src/primitives/view.js +49 -90
- package/src/setup.js +1 -7
- package/src/styles/buttonMarginStyles.js +1 -13
- package/src/styles/cursorStyles.js +1 -5
- package/src/styles/flexDirectionStyles.js +4 -4
- package/src/styles/marginStylesForTarget.js +13 -0
- package/src/styles/textColorStyles.js +14 -6
- package/src/styles/textStyles.js +4 -4
- package/src/styles/viewStyles.js +6 -6
- package/src/styles/viewStylesForTarget.js +58 -0
- package/src/styles/flexChildStyles.js +0 -43
|
@@ -2,7 +2,7 @@ import { deepEqual } from '../../common.js';
|
|
|
2
2
|
|
|
3
3
|
// Attributes that should not be passed through to the container
|
|
4
4
|
// These are either handled internally or have special meaning
|
|
5
|
-
const
|
|
5
|
+
const blacklistedProps = [
|
|
6
6
|
"id",
|
|
7
7
|
"class",
|
|
8
8
|
"style",
|
|
@@ -10,15 +10,15 @@ const blacklistedAttrs = [
|
|
|
10
10
|
// Select-specific props that are handled separately
|
|
11
11
|
"placeholder",
|
|
12
12
|
"selectedValue",
|
|
13
|
-
"selected-value",
|
|
14
13
|
"onChange",
|
|
15
|
-
"
|
|
16
|
-
"
|
|
14
|
+
"options",
|
|
15
|
+
"noClear",
|
|
16
|
+
"addOption",
|
|
17
17
|
];
|
|
18
18
|
|
|
19
|
-
const
|
|
20
|
-
return Object.entries(
|
|
21
|
-
.filter(([key]) => !
|
|
19
|
+
const stringifyProps = (props = {}) => {
|
|
20
|
+
return Object.entries(props)
|
|
21
|
+
.filter(([key]) => !blacklistedProps.includes(key))
|
|
22
22
|
.map(([key, value]) => `${key}=${value}`)
|
|
23
23
|
.join(" ");
|
|
24
24
|
};
|
|
@@ -34,15 +34,15 @@ export const createInitialState = () => Object.freeze({
|
|
|
34
34
|
hoveredAddOption: false,
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
export const selectViewData = ({ state, props
|
|
37
|
+
export const selectViewData = ({ state, props }) => {
|
|
38
38
|
// Generate container attribute string
|
|
39
|
-
const containerAttrString =
|
|
39
|
+
const containerAttrString = stringifyProps(props);
|
|
40
40
|
|
|
41
41
|
// Use state's selected value if available, otherwise use props.selectedValue
|
|
42
42
|
const currentValue = state.selectedValue !== null ? state.selectedValue : props.selectedValue;
|
|
43
43
|
|
|
44
44
|
// Calculate display label from value
|
|
45
|
-
let displayLabel = props.placeholder ||
|
|
45
|
+
let displayLabel = props.placeholder || "Select an option";
|
|
46
46
|
let isPlaceholderLabel = true;
|
|
47
47
|
|
|
48
48
|
const options = props.options || [];
|
|
@@ -72,22 +72,22 @@ export const selectViewData = ({ state, props, attrs }) => {
|
|
|
72
72
|
selectedLabel: displayLabel,
|
|
73
73
|
selectedLabelColor: isPlaceholderLabel ? "mu-fg" : "fg",
|
|
74
74
|
hasValue: currentValue !== null && currentValue !== undefined,
|
|
75
|
-
showClear: !
|
|
75
|
+
showClear: !props.noClear && (currentValue !== null && currentValue !== undefined),
|
|
76
76
|
showAddOption: !!props.addOption,
|
|
77
|
-
addOptionLabel: props.addOption?.label ? `+ ${props.addOption.label}` :
|
|
78
|
-
addOptionBgc: state.hoveredAddOption ?
|
|
77
|
+
addOptionLabel: props.addOption?.label ? `+ ${props.addOption.label}` : "+ Add",
|
|
78
|
+
addOptionBgc: state.hoveredAddOption ? "ac" : "",
|
|
79
79
|
};
|
|
80
|
-
}
|
|
80
|
+
};
|
|
81
81
|
|
|
82
82
|
export const selectState = ({ state }) => {
|
|
83
83
|
return state;
|
|
84
|
-
}
|
|
84
|
+
};
|
|
85
85
|
|
|
86
86
|
export const selectSelectedValue = ({ state }) => {
|
|
87
87
|
return state.selectedValue;
|
|
88
|
-
}
|
|
88
|
+
};
|
|
89
89
|
|
|
90
|
-
export const openOptionsPopover = (state, payload) => {
|
|
90
|
+
export const openOptionsPopover = ({ state }, payload = {}) => {
|
|
91
91
|
const { position, selectedIndex } = payload;
|
|
92
92
|
state.position = position;
|
|
93
93
|
state.isOpen = true;
|
|
@@ -95,36 +95,35 @@ export const openOptionsPopover = (state, payload) => {
|
|
|
95
95
|
if (selectedIndex !== undefined && selectedIndex !== null) {
|
|
96
96
|
state.hoveredOptionId = selectedIndex;
|
|
97
97
|
}
|
|
98
|
-
}
|
|
98
|
+
};
|
|
99
99
|
|
|
100
|
-
export const closeOptionsPopover = (state) => {
|
|
100
|
+
export const closeOptionsPopover = ({ state }) => {
|
|
101
101
|
state.isOpen = false;
|
|
102
|
-
}
|
|
102
|
+
};
|
|
103
103
|
|
|
104
|
-
export const updateSelectedValue = (state, payload) => {
|
|
104
|
+
export const updateSelectedValue = ({ state }, payload = {}) => {
|
|
105
105
|
state.selectedValue = payload.value;
|
|
106
106
|
state.isOpen = false;
|
|
107
|
-
}
|
|
107
|
+
};
|
|
108
108
|
|
|
109
|
-
export const resetSelection = (state) => {
|
|
109
|
+
export const resetSelection = ({ state }) => {
|
|
110
110
|
state.selectedValue = undefined;
|
|
111
|
-
}
|
|
111
|
+
};
|
|
112
112
|
|
|
113
|
-
export const setHoveredOption = (state,
|
|
114
|
-
state.hoveredOptionId = optionId;
|
|
115
|
-
}
|
|
113
|
+
export const setHoveredOption = ({ state }, payload = {}) => {
|
|
114
|
+
state.hoveredOptionId = payload.optionId;
|
|
115
|
+
};
|
|
116
116
|
|
|
117
|
-
export const clearHoveredOption = (state) => {
|
|
117
|
+
export const clearHoveredOption = ({ state }) => {
|
|
118
118
|
state.hoveredOptionId = null;
|
|
119
|
-
}
|
|
119
|
+
};
|
|
120
120
|
|
|
121
|
-
export const clearSelectedValue = (state) => {
|
|
121
|
+
export const clearSelectedValue = ({ state }) => {
|
|
122
122
|
state.selectedValue = undefined;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export const setHoveredAddOption = (state, isHovered) => {
|
|
126
|
-
state.hoveredAddOption = isHovered;
|
|
127
|
-
}
|
|
123
|
+
};
|
|
128
124
|
|
|
125
|
+
export const setHoveredAddOption = ({ state }, payload = {}) => {
|
|
126
|
+
state.hoveredAddOption = !!payload.isHovered;
|
|
127
|
+
};
|
|
129
128
|
|
|
130
129
|
|
|
@@ -1,48 +1,9 @@
|
|
|
1
|
-
elementName: rtgl-select
|
|
2
|
-
|
|
3
|
-
viewDataSchema:
|
|
4
|
-
type: object
|
|
5
|
-
|
|
6
|
-
attrsSchema:
|
|
7
|
-
type: object
|
|
8
|
-
properties:
|
|
9
|
-
placeholder:
|
|
10
|
-
type: string
|
|
11
|
-
|
|
12
|
-
propsSchema:
|
|
13
|
-
type: object
|
|
14
|
-
properties:
|
|
15
|
-
placeholder:
|
|
16
|
-
type: string
|
|
17
|
-
options:
|
|
18
|
-
type: array
|
|
19
|
-
items:
|
|
20
|
-
type: object
|
|
21
|
-
properties:
|
|
22
|
-
label:
|
|
23
|
-
type: string
|
|
24
|
-
value:
|
|
25
|
-
type: any
|
|
26
|
-
testId:
|
|
27
|
-
type: string
|
|
28
|
-
selectedValue:
|
|
29
|
-
type: any
|
|
30
|
-
onChange:
|
|
31
|
-
type: function
|
|
32
|
-
no-clear:
|
|
33
|
-
type: boolean
|
|
34
|
-
addOption:
|
|
35
|
-
type: object
|
|
36
|
-
properties:
|
|
37
|
-
label:
|
|
38
|
-
type: string
|
|
39
|
-
|
|
40
1
|
refs:
|
|
41
|
-
|
|
2
|
+
selectButton:
|
|
42
3
|
eventListeners:
|
|
43
4
|
click:
|
|
44
5
|
handler: handleButtonClick
|
|
45
|
-
|
|
6
|
+
clearButton:
|
|
46
7
|
eventListeners:
|
|
47
8
|
click:
|
|
48
9
|
handler: handleClearClick
|
|
@@ -50,7 +11,7 @@ refs:
|
|
|
50
11
|
eventListeners:
|
|
51
12
|
close:
|
|
52
13
|
handler: handleClickOptionsPopoverOverlay
|
|
53
|
-
option
|
|
14
|
+
option*:
|
|
54
15
|
eventListeners:
|
|
55
16
|
click:
|
|
56
17
|
handler: handleOptionClick
|
|
@@ -58,7 +19,7 @@ refs:
|
|
|
58
19
|
handler: handleOptionMouseEnter
|
|
59
20
|
mouseleave:
|
|
60
21
|
handler: handleOptionMouseLeave
|
|
61
|
-
|
|
22
|
+
optionAdd:
|
|
62
23
|
eventListeners:
|
|
63
24
|
click:
|
|
64
25
|
handler: handleAddOptionClick
|
|
@@ -66,23 +27,19 @@ refs:
|
|
|
66
27
|
handler: handleAddOptionMouseEnter
|
|
67
28
|
mouseleave:
|
|
68
29
|
handler: handleAddOptionMouseLeave
|
|
69
|
-
|
|
70
|
-
events: {}
|
|
71
|
-
|
|
72
30
|
template:
|
|
73
|
-
- rtgl-button#
|
|
31
|
+
- rtgl-button#selectButton v=ol ${containerAttrString} data-testid="select-button":
|
|
74
32
|
- rtgl-view d=h av=c w=f:
|
|
75
|
-
- rtgl-text c=${selectedLabelColor} ellipsis: ${selectedLabel}
|
|
76
|
-
- rtgl-view mh=md flex=1:
|
|
33
|
+
- rtgl-text w=1fg c=${selectedLabelColor} ellipsis: ${selectedLabel}
|
|
77
34
|
- $if showClear:
|
|
78
|
-
- rtgl-svg#
|
|
79
|
-
- rtgl-svg svg=chevronDown wh=16 c=mu-fg:
|
|
80
|
-
- rtgl-popover#popover ?open=${isOpen} x=${position.x} y=${position.y}
|
|
81
|
-
- rtgl-view wh=300 g=xs slot=content bgc=
|
|
35
|
+
- rtgl-svg#clearButton ml=md svg=x wh=16 c=mu-fg cur=pointer data-testid="select-clear-button": null
|
|
36
|
+
- rtgl-svg ml=md svg=chevronDown wh=16 c=mu-fg: null
|
|
37
|
+
- rtgl-popover#popover ?open=${isOpen} x=${position.x} y=${position.y} place=rs:
|
|
38
|
+
- rtgl-view wh=300 g=xs slot=content bgc=mu br=md sv=true:
|
|
82
39
|
- $for option, i in options:
|
|
83
|
-
- rtgl-view#option
|
|
40
|
+
- rtgl-view#option${i} w=f ph=lg pv=md cur=pointer br=md bgc=${option.bgc} data-testid=${option.testId}:
|
|
84
41
|
- rtgl-text: ${option.label}
|
|
85
42
|
- $if showAddOption:
|
|
86
|
-
- rtgl-view w=f bw=xs bc=mu
|
|
87
|
-
- rtgl-view#
|
|
43
|
+
- rtgl-view w=f bw=xs bc=mu bwt=sm: null
|
|
44
|
+
- rtgl-view#optionAdd w=f ph=lg pv=md cur=pointer br=md bgc=${addOptionBgc} data-testid="select-add-option":
|
|
88
45
|
- rtgl-text c=ac: ${addOptionLabel}
|
|
@@ -6,15 +6,15 @@ export const handleHeaderClick = (deps, payload) => {
|
|
|
6
6
|
|
|
7
7
|
const header = store.selectHeader();
|
|
8
8
|
|
|
9
|
-
if (event.currentTarget.id === '
|
|
9
|
+
if (event.currentTarget.id === 'headerLabel') {
|
|
10
10
|
path = header.labelPath;
|
|
11
|
-
} else if (event.currentTarget.id === '
|
|
11
|
+
} else if (event.currentTarget.id === 'headerImage') {
|
|
12
12
|
path = header.image.path;
|
|
13
13
|
} else if (event.currentTarget.id === 'header') {
|
|
14
14
|
path = header.path;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
dispatchEvent(new CustomEvent('
|
|
17
|
+
dispatchEvent(new CustomEvent('header-click', {
|
|
18
18
|
detail: {
|
|
19
19
|
path
|
|
20
20
|
},
|
|
@@ -26,9 +26,9 @@ export const handleHeaderClick = (deps, payload) => {
|
|
|
26
26
|
export const handleItemClick = (deps, payload) => {
|
|
27
27
|
const { store, dispatchEvent } = deps;
|
|
28
28
|
const event = payload._event;
|
|
29
|
-
const id = event.currentTarget.id.
|
|
29
|
+
const id = event.currentTarget.dataset.itemId || event.currentTarget.id.slice('item'.length);
|
|
30
30
|
const item = store.selectItem(id);
|
|
31
|
-
dispatchEvent(new CustomEvent('
|
|
31
|
+
dispatchEvent(new CustomEvent('item-click', {
|
|
32
32
|
detail: {
|
|
33
33
|
item,
|
|
34
34
|
},
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
componentName: rtgl-sidebar
|
|
2
|
+
propsSchema:
|
|
3
|
+
type: object
|
|
4
|
+
properties:
|
|
5
|
+
mode:
|
|
6
|
+
type: string
|
|
7
|
+
selectedItemId:
|
|
8
|
+
type: string
|
|
9
|
+
header:
|
|
10
|
+
type: object
|
|
11
|
+
properties:
|
|
12
|
+
label:
|
|
13
|
+
type: string
|
|
14
|
+
href:
|
|
15
|
+
type: string
|
|
16
|
+
testId:
|
|
17
|
+
type: string
|
|
18
|
+
image:
|
|
19
|
+
type: object
|
|
20
|
+
properties:
|
|
21
|
+
src:
|
|
22
|
+
type: string
|
|
23
|
+
width:
|
|
24
|
+
type: number
|
|
25
|
+
height:
|
|
26
|
+
type: number
|
|
27
|
+
alt:
|
|
28
|
+
type: string
|
|
29
|
+
items:
|
|
30
|
+
type: array
|
|
31
|
+
items:
|
|
32
|
+
type: object
|
|
33
|
+
properties:
|
|
34
|
+
title:
|
|
35
|
+
type: string
|
|
36
|
+
slug:
|
|
37
|
+
type: string
|
|
38
|
+
type:
|
|
39
|
+
type: string
|
|
40
|
+
items:
|
|
41
|
+
type: array
|
|
42
|
+
testId:
|
|
43
|
+
type: string
|
|
44
|
+
events:
|
|
45
|
+
header-click:
|
|
46
|
+
type: object
|
|
47
|
+
properties:
|
|
48
|
+
path:
|
|
49
|
+
type: string
|
|
50
|
+
item-click:
|
|
51
|
+
type: object
|
|
52
|
+
properties:
|
|
53
|
+
item:
|
|
54
|
+
type: object
|
|
55
|
+
methods:
|
|
56
|
+
type: object
|
|
57
|
+
properties: {}
|
|
@@ -1,11 +1,33 @@
|
|
|
1
1
|
export const createInitialState = () => Object.freeze({});
|
|
2
2
|
|
|
3
|
-
const blacklistedAttrs = ['id', 'class', 'style', 'slot'];
|
|
3
|
+
const blacklistedAttrs = ['id', 'class', 'style', 'slot', 'header', 'items', 'selectedItemId', 'mode'];
|
|
4
4
|
|
|
5
|
-
const stringifyAttrs = (
|
|
6
|
-
return Object.entries(
|
|
5
|
+
const stringifyAttrs = (props = {}) => {
|
|
6
|
+
return Object.entries(props).filter(([key]) => !blacklistedAttrs.includes(key)).map(([key, value]) => `${key}=${value}`).join(' ');
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
const parseMaybeEncodedJson = (value) => {
|
|
10
|
+
if (value === undefined || value === null) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
if (typeof value === "object") {
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
if (typeof value !== "string") {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
return JSON.parse(decodeURIComponent(value));
|
|
22
|
+
} catch {
|
|
23
|
+
try {
|
|
24
|
+
return JSON.parse(value);
|
|
25
|
+
} catch {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
9
31
|
function flattenItems(items, selectedItemId = null) {
|
|
10
32
|
let result = [];
|
|
11
33
|
|
|
@@ -50,14 +72,14 @@ function flattenItems(items, selectedItemId = null) {
|
|
|
50
72
|
return result;
|
|
51
73
|
}
|
|
52
74
|
|
|
53
|
-
export const selectViewData = ({
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
const selectedItemId =
|
|
75
|
+
export const selectViewData = ({ props }) => {
|
|
76
|
+
const resolvedHeader = parseMaybeEncodedJson(props.header) || props.header;
|
|
77
|
+
const resolvedItems = parseMaybeEncodedJson(props.items) || props.items;
|
|
78
|
+
const selectedItemId = props.selectedItemId;
|
|
57
79
|
|
|
58
|
-
const containerAttrString = stringifyAttrs(
|
|
59
|
-
const mode =
|
|
60
|
-
const header =
|
|
80
|
+
const containerAttrString = stringifyAttrs(props);
|
|
81
|
+
const mode = props.mode || 'full';
|
|
82
|
+
const header = resolvedHeader || {
|
|
61
83
|
label: '',
|
|
62
84
|
path: '',
|
|
63
85
|
image: {
|
|
@@ -68,7 +90,7 @@ export const selectViewData = ({ state, props, attrs }) => {
|
|
|
68
90
|
},
|
|
69
91
|
};
|
|
70
92
|
|
|
71
|
-
const items =
|
|
93
|
+
const items = resolvedItems ? flattenItems(resolvedItems, selectedItemId) : [];
|
|
72
94
|
|
|
73
95
|
// Computed values based on mode
|
|
74
96
|
const sidebarWidth = mode === 'full' ? 272 : 64;
|
|
@@ -121,22 +143,22 @@ export const selectViewData = ({ state, props, attrs }) => {
|
|
|
121
143
|
};
|
|
122
144
|
}
|
|
123
145
|
|
|
124
|
-
export const selectHeader = ({
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
146
|
+
export const selectHeader = ({ props }) => {
|
|
147
|
+
return parseMaybeEncodedJson(props.header) || props.header;
|
|
148
|
+
};
|
|
128
149
|
|
|
129
150
|
export const selectActiveItem = ({ state, props }) => {
|
|
130
|
-
const
|
|
151
|
+
const resolvedItems = parseMaybeEncodedJson(props.items) || props.items;
|
|
152
|
+
const items = resolvedItems ? flattenItems(resolvedItems) : [];
|
|
131
153
|
return items.find(item => item.active);
|
|
132
|
-
}
|
|
154
|
+
};
|
|
133
155
|
|
|
134
|
-
export const selectItem = ({
|
|
135
|
-
const
|
|
136
|
-
const items =
|
|
156
|
+
export const selectItem = ({ props }, id) => {
|
|
157
|
+
const resolvedItems = parseMaybeEncodedJson(props.items) || props.items;
|
|
158
|
+
const items = resolvedItems ? flattenItems(resolvedItems) : [];
|
|
137
159
|
return items.find(item => item.id === id);
|
|
138
|
-
}
|
|
160
|
+
};
|
|
139
161
|
|
|
140
|
-
export const setState = (state) => {
|
|
162
|
+
export const setState = ({ state }) => {
|
|
141
163
|
// State management if needed
|
|
142
|
-
}
|
|
164
|
+
};
|