@stenajs-webui/core 17.6.0 → 17.9.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/CHANGELOG.md +36 -0
- package/dist/components/decorators/separatorline/SeparatorLine.d.ts +9 -9
- package/dist/components/deprecated-text/HeaderText.d.ts +6 -6
- package/dist/components/deprecated-text/LargeText.d.ts +6 -6
- package/dist/components/deprecated-text/SmallText.d.ts +6 -6
- package/dist/components/deprecated-text/SmallerText.d.ts +6 -6
- package/dist/components/deprecated-text/StandardText.d.ts +6 -6
- package/dist/components/heading/Heading.d.ts +11 -11
- package/dist/components/interaction/Clickable.d.ts +48 -48
- package/dist/components/layout/box/Box.d.ts +75 -75
- package/dist/components/layout/box/ResizeAwareBox.d.ts +7 -7
- package/dist/components/layout/column/Column.d.ts +3 -3
- package/dist/components/layout/indent/Indent.d.ts +7 -7
- package/dist/components/layout/row/Row.d.ts +3 -3
- package/dist/components/layout/space/Space.d.ts +8 -8
- package/dist/components/layout/spacing/Spacing.d.ts +7 -7
- package/dist/components/text/Text.d.ts +15 -15
- package/dist/components/util/Nest.d.ts +9 -9
- package/dist/hooks/UseArraySet.d.ts +9 -9
- package/dist/hooks/UseBoolean.d.ts +7 -7
- package/dist/hooks/UseDebounce.d.ts +1 -1
- package/dist/hooks/UseDelayedFalse.d.ts +1 -1
- package/dist/hooks/UseDomId.d.ts +2 -1
- package/dist/hooks/UseElementDimensions.d.ts +15 -15
- package/dist/hooks/UseElementFocus.d.ts +6 -6
- package/dist/hooks/UseEventListener.d.ts +4 -4
- package/dist/hooks/UseForwardedRef.d.ts +2 -2
- package/dist/hooks/UseMouseIsEntered.d.ts +2 -2
- package/dist/hooks/UseMouseIsOver.d.ts +2 -2
- package/dist/hooks/UseMultiOnClickOutside.d.ts +2 -2
- package/dist/hooks/UseOnClickOutside.d.ts +2 -2
- package/dist/hooks/UseOnNoMouseInput.d.ts +1 -1
- package/dist/hooks/UseOnScreen.d.ts +2 -2
- package/dist/hooks/UseTimeoutState.d.ts +1 -1
- package/dist/index.d.ts +44 -44
- package/dist/index.es.js +711 -690
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +80 -793
- package/dist/index.js.map +1 -1
- package/dist/storybook-helpers/storybook-controls.d.ts +46 -46
- package/dist/types/DeepPartial.d.ts +3 -3
- package/dist/types/ElementProps.d.ts +18 -18
- package/dist/types/FlattenUnion.d.ts +5 -5
- package/dist/types/Omit.d.ts +1 -1
- package/dist/types/PickByValue.d.ts +3 -3
- package/dist/utils/BooleanOrNumberToNumber.d.ts +1 -1
- package/dist/utils/PropsForwarder.d.ts +1 -1
- package/dist/utils/SwitchCaseExhauster.d.ts +2 -2
- package/dist/utils/TruthyKeysAsList.d.ts +1 -1
- package/dist/utils/parsers/NumberParser.d.ts +2 -2
- package/package.json +7 -10
- package/dist/components/decorators/separatorline/SeparatorLine.stories.d.ts +0 -29
- package/dist/components/heading/Heading.stories.d.ts +0 -16
- package/dist/components/interaction/Clickable.stories.d.ts +0 -13
- package/dist/components/layout/box/Box.stories.d.ts +0 -68
- package/dist/components/layout/box/ResponsiveBox.stories.d.ts +0 -10
- package/dist/components/layout/column/Column.stories.d.ts +0 -13
- package/dist/components/layout/indent/Indent.stories.d.ts +0 -8
- package/dist/components/layout/row/Row.stories.d.ts +0 -8
- package/dist/components/layout/space/Space.stories.d.ts +0 -8
- package/dist/components/layout/spacing/Spacing.stories.d.ts +0 -8
- package/dist/components/text/Text.stories.d.ts +0 -31
- package/dist/components/util/__tests__/Nest.test.d.ts +0 -0
- package/dist/hooks/__tests__/UseArraySet.test.d.ts +0 -1
- package/dist/hooks/__tests__/UseBoolean.test.d.ts +0 -1
- package/dist/hooks/__tests__/UseDebounce.test.d.ts +0 -1
- package/dist/hooks/__tests__/UseMultiOnClickOutside.test.d.ts +0 -1
- package/dist/hooks/__tests__/UseOnClickOutside.test.d.ts +0 -1
- package/dist/utils/__tests__/PropsForwarder.test.d.ts +0 -1
- package/dist/utils/__tests__/TruthyKeysAsList.test.d.ts +0 -1
package/dist/index.es.js
CHANGED
|
@@ -1,726 +1,747 @@
|
|
|
1
|
-
import
|
|
2
|
-
import styled from
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import isPropValid from
|
|
6
|
-
import { system, background, border, borderRight, borderLeft, borderTop, borderBottom, borderColor, borderRadius, borderStyle, borderWidth, boxShadow, flexbox, overflow, position, layout, zIndex, left, right, top, bottom } from
|
|
7
|
-
import cx from
|
|
8
|
-
import * as ReactDOM from
|
|
9
|
-
import { debounce, pickBy } from
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
return num;
|
|
1
|
+
(function(){ try {var elementStyle = document.createElement('style'); elementStyle.appendChild(document.createTextNode("._text_1iisw_1{--swui-text-color: var(--swui-text-primary-color);--swui-text-color-caption: var(--lhds-color-ui-600);--swui-text-color-overline: var(--lhds-color-ui-600);--swui-text-font-family: var(--swui-font-primary);--swui-text-font-weight: var(--swui-font-weight-text);--current-color: var(--swui-text-color);--current-font-size: var(--swui-font-size-medium);--current-line-height: var(--swui-line-height-medium);--current-font-weight: var(--swui-text-font-weight);--current-letter-spacing: var(--swui-text-letter-spacing);font-size:var(--current-font-size);line-height:var(--current-line-height);color:var(--current-color);letter-spacing:var(--current-letter-spacing);font-family:var(--swui-text-font-family);font-weight:var(--current-font-weight)}._text_1iisw_1._bold_1iisw_27{--current-font-weight: var(--swui-font-weight-text-bold)}._text_1iisw_1._caption_1iisw_31{--current-font-size: var(--swui-font-size-small);--current-line-height: var(--swui-line-height-small);--current-color: var(--swui-text-color-caption);--current-letter-spacing: 0;font-style:italic}._text_1iisw_1._overline_1iisw_39{--current-font-size: var(--swui-font-size-smaller);--current-line-height: var(--swui-line-height-smaller);--current-color: var(--swui-text-color-overline);--current-font-weight: var(--swui-font-weight-text-bold);--current-letter-spacing: .1rem;text-transform:uppercase}._text_1iisw_1._large_1iisw_48{--current-font-size: var(--swui-font-size-large);--current-line-height: var(--swui-line-height-large)}._text_1iisw_1._medium_1iisw_53{--current-font-size: var(--swui-font-size-medium);--current-line-height: var(--swui-line-height-medium)}._text_1iisw_1._small_1iisw_58{--current-font-size: var(--swui-font-size-small);--current-line-height: var(--swui-line-height-small)}._text_1iisw_1._smaller_1iisw_63{--current-font-size: var(--swui-font-size-smaller);--current-line-height: var(--swui-line-height-smaller)}._heading_1u7xw_1{font-size:var(--swui-heading-font-size);color:var(--lhds-color-ui-900);letter-spacing:0;margin:0;line-height:var(--swui-heading-line-height);font-family:var(--swui-font-primary);font-weight:var(--swui-font-weight-text)}._heading_1u7xw_1._h1_1u7xw_10{--swui-heading-font-size: 2.8rem;--swui-heading-line-height: 4rem}._heading_1u7xw_1._h2_1u7xw_15{--swui-heading-font-size: 2.4rem;--swui-heading-line-height: 3.2rem}._heading_1u7xw_1._h3_1u7xw_20{--swui-heading-font-size: 2rem;--swui-heading-line-height: 2.4rem}._heading_1u7xw_1._h4_1u7xw_25{--swui-heading-font-size: 1.6rem;--swui-heading-line-height: 2.4rem;font-weight:var(--swui-font-weight-text-bold)}._heading_1u7xw_1._h5_1u7xw_31{--swui-heading-font-size: 1.4rem;--swui-heading-line-height: 1.6rem;font-weight:var(--swui-font-weight-text-bold)}._heading_1u7xw_1._h6_1u7xw_37{--swui-heading-font-size: 1.2rem;--swui-heading-line-height: 1.6rem;font-weight:var(--swui-font-weight-text-bold)}")); document.head.appendChild(elementStyle);} catch(e) {console.error('vite-plugin-css-injected-by-js', e);} })();import "@stenajs-webui/theme";
|
|
2
|
+
import styled from "@emotion/styled";
|
|
3
|
+
import { forwardRef, useState, useCallback, useLayoutEffect, useRef, useEffect, useMemo } from "react";
|
|
4
|
+
import { jsx, Fragment } from "react/jsx-runtime";
|
|
5
|
+
import isPropValid from "@emotion/is-prop-valid";
|
|
6
|
+
import { system, background, border, borderRight, borderLeft, borderTop, borderBottom, borderColor, borderRadius, borderStyle, borderWidth, boxShadow, flexbox, overflow, position, layout, zIndex, left, right, top, bottom } from "styled-system";
|
|
7
|
+
import cx from "classnames";
|
|
8
|
+
import * as ReactDOM from "react-dom";
|
|
9
|
+
import { debounce, pickBy } from "lodash";
|
|
10
|
+
const SeparatorLineComponent = styled.hr`
|
|
11
|
+
display: flex;
|
|
12
|
+
border: 0;
|
|
13
|
+
margin: 0;
|
|
14
|
+
flex: none;
|
|
15
|
+
background-color: ${(props) => props.color};
|
|
16
|
+
height: ${(props) => props.vertical ? props.size || "100%" : props.width || "1px"};
|
|
17
|
+
width: ${(props) => props.vertical ? props.width || "1px" : props.size || "100%"};
|
|
18
|
+
`;
|
|
19
|
+
const SeparatorLine = forwardRef(({
|
|
20
|
+
color = "var(--lhds-color-ui-300)",
|
|
21
|
+
size = "100%",
|
|
22
|
+
width = "1px",
|
|
23
|
+
vertical = false
|
|
24
|
+
}, ref) => {
|
|
25
|
+
return /* @__PURE__ */ jsx(SeparatorLineComponent, {
|
|
26
|
+
color,
|
|
27
|
+
size,
|
|
28
|
+
width,
|
|
29
|
+
vertical,
|
|
30
|
+
ref
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
const ClickableElement = styled.button`
|
|
34
|
+
display: inline-block;
|
|
35
|
+
user-select: none;
|
|
36
|
+
border: 0;
|
|
37
|
+
padding: 0;
|
|
38
|
+
background: ${({
|
|
39
|
+
background: background2
|
|
40
|
+
}) => background2};
|
|
41
|
+
${({
|
|
42
|
+
pointer
|
|
43
|
+
}) => pointer ? "cursor: pointer;" : ""}
|
|
44
|
+
|
|
45
|
+
:hover {
|
|
46
|
+
${(props) => props.opacityOnHover ? "opacity: 0.7;" : ""};
|
|
47
|
+
${({
|
|
48
|
+
hoverBackground
|
|
49
|
+
}) => `background: ${hoverBackground};`}
|
|
50
|
+
}
|
|
51
|
+
:active {
|
|
52
|
+
${({
|
|
53
|
+
disableOpacityOnClick
|
|
54
|
+
}) => !disableOpacityOnClick ? "opacity: 0.5;" : ""}
|
|
55
|
+
}
|
|
56
|
+
:focus {
|
|
57
|
+
outline: 0;
|
|
58
|
+
${({
|
|
59
|
+
disableFocusHighlight
|
|
60
|
+
}) => disableFocusHighlight ? "" : "box-shadow: 0 0 3pt 2pt rgba(0, 0, 100, 0.3);"}
|
|
61
|
+
${({
|
|
62
|
+
focusBackground
|
|
63
|
+
}) => `background: ${focusBackground};`}
|
|
64
|
+
}
|
|
65
|
+
${({
|
|
66
|
+
width
|
|
67
|
+
}) => width ? `width: ${width};` : ""}
|
|
68
|
+
${({
|
|
69
|
+
height
|
|
70
|
+
}) => height ? `height: ${height};` : ""}
|
|
71
|
+
${({
|
|
72
|
+
borderRadius: borderRadius2
|
|
73
|
+
}) => borderRadius2 ? `border-radius: ${borderRadius2};` : ""}
|
|
74
|
+
`;
|
|
75
|
+
const Clickable = forwardRef(({
|
|
76
|
+
disableFocusHighlight,
|
|
77
|
+
onClick,
|
|
78
|
+
onDblClick,
|
|
79
|
+
tooltip,
|
|
80
|
+
disableOpacityOnClick,
|
|
81
|
+
disablePointer,
|
|
82
|
+
opacityOnHover,
|
|
83
|
+
disabled,
|
|
84
|
+
children,
|
|
85
|
+
background: background2 = "transparent",
|
|
86
|
+
hoverBackground,
|
|
87
|
+
focusBackground,
|
|
88
|
+
type = "button",
|
|
89
|
+
...restProps
|
|
90
|
+
}, ref) => {
|
|
91
|
+
const hasClickHandler = !!(onClick || onDblClick);
|
|
92
|
+
return /* @__PURE__ */ jsx(ClickableElement, {
|
|
93
|
+
opacityOnHover,
|
|
94
|
+
title: tooltip,
|
|
95
|
+
disabled,
|
|
96
|
+
disableOpacityOnClick,
|
|
97
|
+
onClick,
|
|
98
|
+
onDoubleClick: onDblClick,
|
|
99
|
+
disableFocusHighlight,
|
|
100
|
+
pointer: hasClickHandler && !disablePointer,
|
|
101
|
+
ref,
|
|
102
|
+
background: background2,
|
|
103
|
+
hoverBackground,
|
|
104
|
+
focusBackground,
|
|
105
|
+
type,
|
|
106
|
+
...restProps,
|
|
107
|
+
children
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
const booleanOrNumberToNumber = (num) => {
|
|
111
|
+
if (num == null) {
|
|
112
|
+
return 0;
|
|
113
|
+
}
|
|
114
|
+
if (typeof num === "boolean") {
|
|
115
|
+
return num ? 1 : 0;
|
|
116
|
+
}
|
|
117
|
+
return num;
|
|
120
118
|
};
|
|
121
|
-
|
|
122
|
-
var
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
"
|
|
131
|
-
"
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
"
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
transform: booleanOrNumberToNumber,
|
|
153
|
-
},
|
|
154
|
-
gap: {
|
|
155
|
-
// @ts-ignore
|
|
156
|
-
property: "--current-gap",
|
|
157
|
-
transform: booleanOrNumberToNumber,
|
|
158
|
-
},
|
|
159
|
-
shadow: {
|
|
160
|
-
property: "boxShadow",
|
|
161
|
-
transform: function (value) { var _a; return (_a = shadows[value]) !== null && _a !== void 0 ? _a : value; },
|
|
162
|
-
},
|
|
163
|
-
});
|
|
164
|
-
var Box = styled("div", {
|
|
165
|
-
shouldForwardProp: function (propName) {
|
|
166
|
-
return typeof propName === "string"
|
|
167
|
-
? isExcludedWebUiProp(propName)
|
|
168
|
-
? false
|
|
169
|
-
: isPropValid(propName)
|
|
170
|
-
: false;
|
|
171
|
-
},
|
|
172
|
-
})(templateObject_1$1 || (templateObject_1$1 = __makeTemplateObject(["\n --current-spacing: 0;\n --current-indent: 0;\n --current-gap: 0;\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n\n gap: calc(var(--current-gap) * var(--swui-metrics-space));\n\n padding: calc(var(--current-spacing) * var(--swui-metrics-spacing))\n calc(var(--current-indent) * var(--swui-metrics-indent));\n :hover {\n ", "\n ", "\n }\n :focus {\n ", "\n ", "\n }\n :focus-within {\n ", "\n ", "\n }\n"], ["\n --current-spacing: 0;\n --current-indent: 0;\n --current-gap: 0;\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n\n gap: calc(var(--current-gap) * var(--swui-metrics-space));\n\n padding: calc(var(--current-spacing) * var(--swui-metrics-spacing))\n calc(var(--current-indent) * var(--swui-metrics-indent));\n :hover {\n ", "\n ", "\n }\n :focus {\n ", "\n ", "\n }\n :focus-within {\n ", "\n ", "\n }\n"])), box, background, border, borderRight, borderLeft, borderTop, borderBottom, borderColor, borderRadius, borderStyle, borderWidth, boxShadow, flexbox, overflow, position, layout, zIndex, left, right, top, bottom, function (_a) {
|
|
173
|
-
var hoverBackground = _a.hoverBackground;
|
|
174
|
-
return hoverBackground ? "background: ".concat(hoverBackground, ";") : "";
|
|
175
|
-
}, function (_a) {
|
|
176
|
-
var hoverBorder = _a.hoverBorder;
|
|
177
|
-
return (hoverBorder ? "border: ".concat(hoverBorder, ";") : "");
|
|
178
|
-
}, function (_a) {
|
|
179
|
-
var focusBackground = _a.focusBackground;
|
|
180
|
-
return focusBackground ? "background: ".concat(focusBackground, ";") : "";
|
|
181
|
-
}, function (_a) {
|
|
182
|
-
var focusBorder = _a.focusBorder;
|
|
183
|
-
return (focusBorder ? "border: ".concat(focusBorder, ";") : "");
|
|
184
|
-
}, function (_a) {
|
|
185
|
-
var focusWithinBackground = _a.focusWithinBackground;
|
|
186
|
-
return focusWithinBackground ? "background: ".concat(focusWithinBackground, ";") : "";
|
|
187
|
-
}, function (_a) {
|
|
188
|
-
var focusWithinBorder = _a.focusWithinBorder;
|
|
189
|
-
return focusWithinBorder ? "border: ".concat(focusWithinBorder, ";") : "";
|
|
190
|
-
});
|
|
191
|
-
var templateObject_1$1;
|
|
192
|
-
|
|
193
|
-
var Column = forwardRef(function Column(props, ref) {
|
|
194
|
-
return React.createElement(Box, __assign({ ref: ref }, props));
|
|
119
|
+
const shadows = {
|
|
120
|
+
box: "var(--swui-shadow-box)",
|
|
121
|
+
popover: "var(--swui-shadow-popover)",
|
|
122
|
+
modal: "var(--swui-shadow-modal)"
|
|
123
|
+
};
|
|
124
|
+
const excludedProps = ["spacing", "indent", "gap", "width", "height", "overflow", "display"];
|
|
125
|
+
const isExcludedWebUiProp = (propName) => excludedProps.includes(propName);
|
|
126
|
+
const box = system({
|
|
127
|
+
row: {
|
|
128
|
+
property: "flexDirection",
|
|
129
|
+
transform: (row) => row ? "row" : "column"
|
|
130
|
+
},
|
|
131
|
+
indent: {
|
|
132
|
+
property: "--current-indent",
|
|
133
|
+
transform: booleanOrNumberToNumber
|
|
134
|
+
},
|
|
135
|
+
spacing: {
|
|
136
|
+
property: "--current-spacing",
|
|
137
|
+
transform: booleanOrNumberToNumber
|
|
138
|
+
},
|
|
139
|
+
gap: {
|
|
140
|
+
property: "--current-gap",
|
|
141
|
+
transform: booleanOrNumberToNumber
|
|
142
|
+
},
|
|
143
|
+
shadow: {
|
|
144
|
+
property: "boxShadow",
|
|
145
|
+
transform: (value) => {
|
|
146
|
+
var _a;
|
|
147
|
+
return (_a = shadows[value]) != null ? _a : value;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
195
150
|
});
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
151
|
+
const Box = styled("div", {
|
|
152
|
+
shouldForwardProp: (propName) => typeof propName === "string" ? isExcludedWebUiProp(propName) ? false : isPropValid(propName) : false
|
|
153
|
+
})`
|
|
154
|
+
--current-spacing: 0;
|
|
155
|
+
--current-indent: 0;
|
|
156
|
+
--current-gap: 0;
|
|
157
|
+
box-sizing: border-box;
|
|
158
|
+
display: flex;
|
|
159
|
+
flex-direction: column;
|
|
160
|
+
${box};
|
|
161
|
+
${background};
|
|
162
|
+
${border};
|
|
163
|
+
${borderRight};
|
|
164
|
+
${borderLeft};
|
|
165
|
+
${borderTop};
|
|
166
|
+
${borderBottom};
|
|
167
|
+
${borderColor};
|
|
168
|
+
${borderRadius};
|
|
169
|
+
${borderStyle};
|
|
170
|
+
${borderWidth};
|
|
171
|
+
${boxShadow};
|
|
172
|
+
${flexbox};
|
|
173
|
+
${overflow};
|
|
174
|
+
${position};
|
|
175
|
+
${layout};
|
|
176
|
+
${zIndex};
|
|
177
|
+
${left};
|
|
178
|
+
${right};
|
|
179
|
+
${top};
|
|
180
|
+
${bottom};
|
|
181
|
+
|
|
182
|
+
gap: calc(var(--current-gap) * var(--swui-metrics-space));
|
|
183
|
+
|
|
184
|
+
padding: calc(var(--current-spacing) * var(--swui-metrics-spacing))
|
|
185
|
+
calc(var(--current-indent) * var(--swui-metrics-indent));
|
|
186
|
+
:hover {
|
|
187
|
+
${({
|
|
188
|
+
hoverBackground
|
|
189
|
+
}) => hoverBackground ? `background: ${hoverBackground};` : ""}
|
|
190
|
+
${({
|
|
191
|
+
hoverBorder
|
|
192
|
+
}) => hoverBorder ? `border: ${hoverBorder};` : ""}
|
|
193
|
+
}
|
|
194
|
+
:focus {
|
|
195
|
+
${({
|
|
196
|
+
focusBackground
|
|
197
|
+
}) => focusBackground ? `background: ${focusBackground};` : ""}
|
|
198
|
+
${({
|
|
199
|
+
focusBorder
|
|
200
|
+
}) => focusBorder ? `border: ${focusBorder};` : ""}
|
|
201
|
+
}
|
|
202
|
+
:focus-within {
|
|
203
|
+
${({
|
|
204
|
+
focusWithinBackground
|
|
205
|
+
}) => focusWithinBackground ? `background: ${focusWithinBackground};` : ""}
|
|
206
|
+
${({
|
|
207
|
+
focusWithinBorder
|
|
208
|
+
}) => focusWithinBorder ? `border: ${focusWithinBorder};` : ""}
|
|
209
|
+
}
|
|
210
|
+
`;
|
|
211
|
+
const Column = forwardRef(function Column2(props, ref) {
|
|
212
|
+
return /* @__PURE__ */ jsx(Box, {
|
|
213
|
+
ref,
|
|
214
|
+
...props
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
const getDimensionObject = (node) => {
|
|
218
|
+
const { x, y, width, height, bottom: bottom2, top: top2, left: left2, right: right2 } = node.getBoundingClientRect();
|
|
219
|
+
return {
|
|
220
|
+
width,
|
|
221
|
+
height,
|
|
222
|
+
top: top2,
|
|
223
|
+
left: left2,
|
|
224
|
+
x,
|
|
225
|
+
y,
|
|
226
|
+
right: right2,
|
|
227
|
+
bottom: bottom2
|
|
228
|
+
};
|
|
241
229
|
};
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
230
|
+
const isEqualDimensions = (a, b) => a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height && a.bottom === b.bottom && a.top === b.top && a.left === b.left && a.right === b.right;
|
|
231
|
+
const useElementDimensions = (ref, onResizeElement) => {
|
|
232
|
+
const [dimensions, setDimensions] = useState();
|
|
233
|
+
const updateDimensions = useCallback(() => {
|
|
234
|
+
window.requestAnimationFrame(() => {
|
|
235
|
+
if (ref.current) {
|
|
236
|
+
const newDimensions = getDimensionObject(ref.current);
|
|
237
|
+
if (!dimensions || !isEqualDimensions(dimensions, newDimensions)) {
|
|
238
|
+
if (onResizeElement) {
|
|
239
|
+
onResizeElement(newDimensions);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
setDimensions(newDimensions);
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
}, [ref, dimensions, setDimensions, onResizeElement]);
|
|
246
|
+
useLayoutEffect(() => {
|
|
247
|
+
updateDimensions();
|
|
248
|
+
}, [updateDimensions]);
|
|
249
|
+
return {
|
|
250
|
+
dimensions
|
|
251
|
+
};
|
|
252
|
+
};
|
|
253
|
+
const ResizeAwareBox = forwardRef(function ResizeAwareBox2({
|
|
254
|
+
onResize,
|
|
255
|
+
...boxProps
|
|
256
|
+
}, ref) {
|
|
257
|
+
const localRef = useRef(null);
|
|
258
|
+
const currentRef = ref != null ? ref : localRef;
|
|
259
|
+
useElementDimensions(currentRef, onResize);
|
|
260
|
+
return /* @__PURE__ */ jsx(Box, {
|
|
261
|
+
...boxProps,
|
|
262
|
+
ref
|
|
263
|
+
});
|
|
250
264
|
});
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
265
|
+
const Row = forwardRef(function Row2(props, ref) {
|
|
266
|
+
return /* @__PURE__ */ jsx(Box, {
|
|
267
|
+
row: true,
|
|
268
|
+
ref,
|
|
269
|
+
...props
|
|
270
|
+
});
|
|
254
271
|
});
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
272
|
+
const Indent = forwardRef(function Indent2({
|
|
273
|
+
num = 1,
|
|
274
|
+
...props
|
|
275
|
+
}, ref) {
|
|
276
|
+
return /* @__PURE__ */ jsx(Box, {
|
|
277
|
+
indent: num,
|
|
278
|
+
ref,
|
|
279
|
+
...props
|
|
280
|
+
});
|
|
259
281
|
});
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
282
|
+
const Spacing = forwardRef(function Spacing2({
|
|
283
|
+
num = 1,
|
|
284
|
+
...props
|
|
285
|
+
}, ref) {
|
|
286
|
+
return /* @__PURE__ */ jsx(Box, {
|
|
287
|
+
spacing: num,
|
|
288
|
+
ref,
|
|
289
|
+
...props
|
|
290
|
+
});
|
|
264
291
|
});
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}
|
|
284
|
-
return React.createElement(React.Fragment, null, children);
|
|
285
|
-
};
|
|
286
|
-
|
|
287
|
-
function styleInject(css, ref) {
|
|
288
|
-
if ( ref === void 0 ) ref = {};
|
|
289
|
-
var insertAt = ref.insertAt;
|
|
290
|
-
|
|
291
|
-
if (!css || typeof document === 'undefined') { return; }
|
|
292
|
-
|
|
293
|
-
var head = document.head || document.getElementsByTagName('head')[0];
|
|
294
|
-
var style = document.createElement('style');
|
|
295
|
-
style.type = 'text/css';
|
|
296
|
-
|
|
297
|
-
if (insertAt === 'top') {
|
|
298
|
-
if (head.firstChild) {
|
|
299
|
-
head.insertBefore(style, head.firstChild);
|
|
300
|
-
} else {
|
|
301
|
-
head.appendChild(style);
|
|
292
|
+
const InnerSpace = styled.div`
|
|
293
|
+
--current-size: 1;
|
|
294
|
+
flex: none;
|
|
295
|
+
width: calc(var(--current-size) * var(--swui-metrics-space));
|
|
296
|
+
height: calc(var(--current-size) * var(--swui-metrics-space));
|
|
297
|
+
`;
|
|
298
|
+
const Space = ({
|
|
299
|
+
half = false,
|
|
300
|
+
horizontal = false,
|
|
301
|
+
num = 1,
|
|
302
|
+
vertical = false
|
|
303
|
+
}) => {
|
|
304
|
+
const size = num * (half ? 0.5 : 1);
|
|
305
|
+
return /* @__PURE__ */ jsx(InnerSpace, {
|
|
306
|
+
style: {
|
|
307
|
+
["--current-size"]: size,
|
|
308
|
+
height: horizontal ? 1 : void 0,
|
|
309
|
+
width: vertical ? 1 : void 0
|
|
302
310
|
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
+
});
|
|
312
|
+
};
|
|
313
|
+
const Nest = ({
|
|
314
|
+
children,
|
|
315
|
+
nest,
|
|
316
|
+
render
|
|
317
|
+
}) => {
|
|
318
|
+
if (nest) {
|
|
319
|
+
return /* @__PURE__ */ jsx(Fragment, {
|
|
320
|
+
children: render(children)
|
|
321
|
+
});
|
|
311
322
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
var styles$1 = {"text":"Text-module_text__2FYaC","standard":"Text-module_standard__2-bur","bold":"Text-module_bold__1Knlz","caption":"Text-module_caption__153CS","overline":"Text-module_overline__22jee","large":"Text-module_large__3TF1O","medium":"Text-module_medium__1yeKe","small":"Text-module_small__3KAee","smaller":"Text-module_smaller__1mD_7"};
|
|
316
|
-
styleInject(css_248z$1);
|
|
317
|
-
|
|
318
|
-
var Text = forwardRef(function (_a, ref) {
|
|
319
|
-
var children = _a.children, _b = _a.variant, variant = _b === void 0 ? "standard" : _b, _c = _a.size, size = _c === void 0 ? "medium" : _c, className = _a.className, color = _a.color, userSelect = _a.userSelect, whiteSpace = _a.whiteSpace, wordBreak = _a.wordBreak, style = _a.style, spanProps = __rest(_a, ["children", "variant", "size", "className", "color", "userSelect", "whiteSpace", "wordBreak", "style"]);
|
|
320
|
-
return (React.createElement("span", __assign({ className: cx(styles$1.text, styles$1[variant], styles$1[size], className), ref: ref, style: __assign({ color: color, userSelect: userSelect, whiteSpace: whiteSpace, wordBreak: wordBreak }, style) }, spanProps), children));
|
|
321
|
-
});
|
|
322
|
-
var Txt = Text;
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* @deprecated Please use `Text` instead.
|
|
326
|
-
*/
|
|
327
|
-
var SmallText = function (props) {
|
|
328
|
-
return React.createElement(Text, __assign({ size: "small" }, props));
|
|
323
|
+
return /* @__PURE__ */ jsx(Fragment, {
|
|
324
|
+
children
|
|
325
|
+
});
|
|
329
326
|
};
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
327
|
+
const text = "_text_1iisw_1";
|
|
328
|
+
const standard = "_standard_1iisw_24";
|
|
329
|
+
const bold = "_bold_1iisw_27";
|
|
330
|
+
const caption = "_caption_1iisw_31";
|
|
331
|
+
const overline = "_overline_1iisw_39";
|
|
332
|
+
const large = "_large_1iisw_48";
|
|
333
|
+
const medium = "_medium_1iisw_53";
|
|
334
|
+
const small = "_small_1iisw_58";
|
|
335
|
+
const smaller = "_smaller_1iisw_63";
|
|
336
|
+
var styles$1 = {
|
|
337
|
+
text,
|
|
338
|
+
standard,
|
|
339
|
+
bold,
|
|
340
|
+
caption,
|
|
341
|
+
overline,
|
|
342
|
+
large,
|
|
343
|
+
medium,
|
|
344
|
+
small,
|
|
345
|
+
smaller
|
|
336
346
|
};
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
347
|
+
const Text = forwardRef(({
|
|
348
|
+
children,
|
|
349
|
+
variant = "standard",
|
|
350
|
+
size = "medium",
|
|
351
|
+
className,
|
|
352
|
+
color,
|
|
353
|
+
userSelect,
|
|
354
|
+
whiteSpace,
|
|
355
|
+
wordBreak,
|
|
356
|
+
style,
|
|
357
|
+
...spanProps
|
|
358
|
+
}, ref) => {
|
|
359
|
+
return /* @__PURE__ */ jsx("span", {
|
|
360
|
+
className: cx(styles$1.text, styles$1[variant], styles$1[size], className),
|
|
361
|
+
ref,
|
|
362
|
+
style: {
|
|
363
|
+
color,
|
|
364
|
+
userSelect,
|
|
365
|
+
whiteSpace,
|
|
366
|
+
wordBreak,
|
|
367
|
+
...style
|
|
368
|
+
},
|
|
369
|
+
...spanProps,
|
|
370
|
+
children
|
|
371
|
+
});
|
|
372
|
+
});
|
|
373
|
+
const Txt = Text;
|
|
374
|
+
const SmallText = (props) => {
|
|
375
|
+
return /* @__PURE__ */ jsx(Text, {
|
|
376
|
+
size: "small",
|
|
377
|
+
...props
|
|
378
|
+
});
|
|
343
379
|
};
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
return React.createElement(Text, __assign({ size: "large" }, props));
|
|
380
|
+
const SmallerText = (props) => {
|
|
381
|
+
return /* @__PURE__ */ jsx(Text, {
|
|
382
|
+
size: "smaller",
|
|
383
|
+
...props
|
|
384
|
+
});
|
|
350
385
|
};
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
386
|
+
const StandardText = (props) => {
|
|
387
|
+
return /* @__PURE__ */ jsx(Text, {
|
|
388
|
+
size: "medium",
|
|
389
|
+
...props
|
|
390
|
+
});
|
|
391
|
+
};
|
|
392
|
+
const LargeText = (props) => {
|
|
393
|
+
return /* @__PURE__ */ jsx(Text, {
|
|
394
|
+
size: "large",
|
|
395
|
+
...props
|
|
396
|
+
});
|
|
397
|
+
};
|
|
398
|
+
const heading = "_heading_1u7xw_1";
|
|
399
|
+
const h1 = "_h1_1u7xw_10";
|
|
400
|
+
const h2 = "_h2_1u7xw_15";
|
|
401
|
+
const h3 = "_h3_1u7xw_20";
|
|
402
|
+
const h4 = "_h4_1u7xw_25";
|
|
403
|
+
const h5 = "_h5_1u7xw_31";
|
|
404
|
+
const h6 = "_h6_1u7xw_37";
|
|
405
|
+
var styles = {
|
|
406
|
+
heading,
|
|
407
|
+
h1,
|
|
408
|
+
h2,
|
|
409
|
+
h3,
|
|
410
|
+
h4,
|
|
411
|
+
h5,
|
|
412
|
+
h6
|
|
413
|
+
};
|
|
414
|
+
const Heading = forwardRef(({
|
|
415
|
+
variant = "h3",
|
|
416
|
+
className,
|
|
417
|
+
color,
|
|
418
|
+
whiteSpace,
|
|
419
|
+
wordBreak,
|
|
420
|
+
style,
|
|
421
|
+
children,
|
|
422
|
+
as,
|
|
423
|
+
...hProps
|
|
424
|
+
}, ref) => {
|
|
425
|
+
const Element = as != null ? as : variant;
|
|
426
|
+
return /* @__PURE__ */ jsx(Element, {
|
|
427
|
+
className: cx(styles.heading, styles[variant], className),
|
|
428
|
+
style: {
|
|
429
|
+
color,
|
|
430
|
+
whiteSpace,
|
|
431
|
+
wordBreak,
|
|
432
|
+
...style
|
|
433
|
+
},
|
|
434
|
+
ref,
|
|
435
|
+
...hProps,
|
|
436
|
+
children
|
|
437
|
+
});
|
|
360
438
|
});
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
return React.createElement(Heading, __assign({ variant: "h2" }, props));
|
|
439
|
+
const HeaderText = (props) => {
|
|
440
|
+
return /* @__PURE__ */ jsx(Heading, {
|
|
441
|
+
variant: "h2",
|
|
442
|
+
...props
|
|
443
|
+
});
|
|
367
444
|
};
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
if (
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
removeMultiple: removeMultiple,
|
|
408
|
-
toggle: toggle,
|
|
409
|
-
};
|
|
445
|
+
const defaultComparator = (a, b) => a === b;
|
|
446
|
+
const useArraySet = (list, setList, comparator = defaultComparator) => {
|
|
447
|
+
const add = useCallback((item) => {
|
|
448
|
+
if (!list.some((l) => comparator(l, item))) {
|
|
449
|
+
setList([...list, item]);
|
|
450
|
+
}
|
|
451
|
+
}, [list, setList, comparator]);
|
|
452
|
+
const addMultiple = useCallback((items) => {
|
|
453
|
+
setList(items.reduce((list2, item) => {
|
|
454
|
+
if (!list2.some((l) => comparator(l, item))) {
|
|
455
|
+
return [...list2, item];
|
|
456
|
+
}
|
|
457
|
+
return list2;
|
|
458
|
+
}, list));
|
|
459
|
+
}, [list, setList, comparator]);
|
|
460
|
+
const remove = useCallback((item) => {
|
|
461
|
+
const index = list.findIndex((l) => comparator(l, item));
|
|
462
|
+
if (index >= 0) {
|
|
463
|
+
setList(list.filter((_, i) => i !== index));
|
|
464
|
+
}
|
|
465
|
+
}, [list, setList, comparator]);
|
|
466
|
+
const removeMultiple = useCallback((items) => {
|
|
467
|
+
setList(list.filter((item) => !items.some((l) => comparator(l, item))));
|
|
468
|
+
}, [list, setList, comparator]);
|
|
469
|
+
const toggle = useCallback((item) => {
|
|
470
|
+
const found = list.some((l) => comparator(l, item));
|
|
471
|
+
if (found) {
|
|
472
|
+
remove(item);
|
|
473
|
+
} else {
|
|
474
|
+
add(item);
|
|
475
|
+
}
|
|
476
|
+
}, [list, add, remove, comparator]);
|
|
477
|
+
return {
|
|
478
|
+
add,
|
|
479
|
+
addMultiple,
|
|
480
|
+
remove,
|
|
481
|
+
removeMultiple,
|
|
482
|
+
toggle
|
|
483
|
+
};
|
|
410
484
|
};
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
return [value, setTrue, setFalse, toggle];
|
|
485
|
+
const useBoolean = (initialValue) => {
|
|
486
|
+
const [value, setValue] = useState(initialValue);
|
|
487
|
+
const setTrue = useCallback(() => {
|
|
488
|
+
setValue(true);
|
|
489
|
+
}, [setValue]);
|
|
490
|
+
const setFalse = useCallback(() => {
|
|
491
|
+
setValue(false);
|
|
492
|
+
}, [setValue]);
|
|
493
|
+
const toggle = useCallback(() => {
|
|
494
|
+
setValue((v) => !v);
|
|
495
|
+
}, [setValue]);
|
|
496
|
+
return [value, setTrue, setFalse, toggle];
|
|
424
497
|
};
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
// .. within the delay period. Timeout gets cleared and restarted.
|
|
437
|
-
return function () {
|
|
438
|
-
clearTimeout(handler);
|
|
439
|
-
};
|
|
440
|
-
}, [value, delay]); // Only re-call effect if value or delay changes
|
|
441
|
-
return debouncedValue;
|
|
498
|
+
const useDebounce = (value, delay) => {
|
|
499
|
+
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
500
|
+
useEffect(() => {
|
|
501
|
+
const handler = setTimeout(() => {
|
|
502
|
+
setDebouncedValue(value);
|
|
503
|
+
}, delay);
|
|
504
|
+
return () => {
|
|
505
|
+
clearTimeout(handler);
|
|
506
|
+
};
|
|
507
|
+
}, [value, delay]);
|
|
508
|
+
return debouncedValue;
|
|
442
509
|
};
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
return debouncedValue;
|
|
510
|
+
const useDelayedFalse = (value, delay) => {
|
|
511
|
+
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
512
|
+
useEffect(() => {
|
|
513
|
+
if (value) {
|
|
514
|
+
setDebouncedValue(true);
|
|
515
|
+
}
|
|
516
|
+
const handler = setTimeout(() => {
|
|
517
|
+
if (!value) {
|
|
518
|
+
setDebouncedValue(value);
|
|
519
|
+
}
|
|
520
|
+
}, delay);
|
|
521
|
+
return () => {
|
|
522
|
+
clearTimeout(handler);
|
|
523
|
+
};
|
|
524
|
+
}, [value, delay]);
|
|
525
|
+
return debouncedValue;
|
|
460
526
|
};
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
var _a = useState(function () { return genId(componentName); }), id = _a[0], setId = _a[1];
|
|
468
|
-
useEffect(function () { return setId(genId(componentName)); }, [componentName]);
|
|
469
|
-
return id;
|
|
527
|
+
let id = 0;
|
|
528
|
+
const genId = (componentName) => `webui-${componentName ? componentName + "-" : ""}${++id}`;
|
|
529
|
+
const useDomId = (componentName) => {
|
|
530
|
+
const [id2, setId] = useState(() => genId(componentName));
|
|
531
|
+
useEffect(() => setId(genId(componentName)), [componentName]);
|
|
532
|
+
return id2;
|
|
470
533
|
};
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
}
|
|
497
|
-
var element = ref.current;
|
|
498
|
-
element.addEventListener(eventName, eventListener);
|
|
499
|
-
// Remove event listener on cleanup
|
|
500
|
-
return function () {
|
|
501
|
-
if (element) {
|
|
502
|
-
element.removeEventListener(eventName, eventListener);
|
|
503
|
-
}
|
|
504
|
-
};
|
|
505
|
-
}, [eventName, ref]); // Re-run if eventName or element changes
|
|
534
|
+
const useEventListener = (ref, eventName, handler) => {
|
|
535
|
+
const savedHandler = useRef();
|
|
536
|
+
useEffect(() => {
|
|
537
|
+
savedHandler.current = handler;
|
|
538
|
+
}, [handler]);
|
|
539
|
+
useEffect(() => {
|
|
540
|
+
const isSupported = ref.current && ref.current.addEventListener;
|
|
541
|
+
if (!isSupported)
|
|
542
|
+
return;
|
|
543
|
+
const eventListener = (event) => {
|
|
544
|
+
if (savedHandler.current) {
|
|
545
|
+
return savedHandler.current(event);
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
if (!ref.current) {
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
const element = ref.current;
|
|
552
|
+
element.addEventListener(eventName, eventListener);
|
|
553
|
+
return () => {
|
|
554
|
+
if (element) {
|
|
555
|
+
element.removeEventListener(eventName, eventListener);
|
|
556
|
+
}
|
|
557
|
+
};
|
|
558
|
+
}, [eventName, ref]);
|
|
506
559
|
};
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
}, [ref]);
|
|
530
|
-
return { isInFocus: isInFocus, focus: focus, blur: blur };
|
|
560
|
+
const useElementFocus = (ref) => {
|
|
561
|
+
const [isInFocus, setIsInFocus, setIsNotInFocus] = useBoolean(false);
|
|
562
|
+
useEffect(() => {
|
|
563
|
+
if (document.activeElement === ReactDOM.findDOMNode(ref.current)) {
|
|
564
|
+
setIsInFocus();
|
|
565
|
+
} else {
|
|
566
|
+
setIsNotInFocus();
|
|
567
|
+
}
|
|
568
|
+
}, [ref, setIsNotInFocus, setIsInFocus]);
|
|
569
|
+
useEventListener(ref, "focus", setIsInFocus);
|
|
570
|
+
useEventListener(ref, "blur", setIsNotInFocus);
|
|
571
|
+
const focus = useCallback(() => {
|
|
572
|
+
if (ref.current) {
|
|
573
|
+
ref.current.focus();
|
|
574
|
+
}
|
|
575
|
+
}, [ref]);
|
|
576
|
+
const blur = useCallback(() => {
|
|
577
|
+
if (ref.current) {
|
|
578
|
+
ref.current.blur();
|
|
579
|
+
}
|
|
580
|
+
}, [ref]);
|
|
581
|
+
return { isInFocus, focus, blur };
|
|
531
582
|
};
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
return mouseIsOver;
|
|
583
|
+
const useMouseIsOver = (ref) => {
|
|
584
|
+
const [mouseIsOver, setMouseIsOver, setMouseIsNotOver] = useBoolean(false);
|
|
585
|
+
useEventListener(ref, "mouseover", setMouseIsOver);
|
|
586
|
+
useEventListener(ref, "mouseout", setMouseIsNotOver);
|
|
587
|
+
return mouseIsOver;
|
|
538
588
|
};
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
return mouseIsEntered;
|
|
589
|
+
const useMouseIsEntered = (ref) => {
|
|
590
|
+
const [mouseIsEntered, setMouseIsEntered, setMouseIsNotEntered] = useBoolean(false);
|
|
591
|
+
useEventListener(ref, "mouseenter", setMouseIsEntered);
|
|
592
|
+
useEventListener(ref, "mouseleave", setMouseIsNotEntered);
|
|
593
|
+
return mouseIsEntered;
|
|
545
594
|
};
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
document.removeEventListener("mousedown", listener);
|
|
571
|
-
document.removeEventListener("touchstart", listener);
|
|
572
|
-
};
|
|
573
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
574
|
-
}, __spreadArray([], refs, true));
|
|
595
|
+
const useMultiOnClickOutside = (refs, handler) => {
|
|
596
|
+
const eventHandler = useRef(() => {
|
|
597
|
+
return;
|
|
598
|
+
});
|
|
599
|
+
useEffect(() => {
|
|
600
|
+
eventHandler.current = handler;
|
|
601
|
+
}, [handler]);
|
|
602
|
+
useEffect(() => {
|
|
603
|
+
const listener = (event) => {
|
|
604
|
+
const allNotContains = refs.filter((ref) => ref.current).every((ref) => {
|
|
605
|
+
return ref.current && !ref.current.contains(event.target);
|
|
606
|
+
});
|
|
607
|
+
if (!allNotContains) {
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
eventHandler.current(event);
|
|
611
|
+
};
|
|
612
|
+
document.addEventListener("mousedown", listener);
|
|
613
|
+
document.addEventListener("touchstart", listener);
|
|
614
|
+
return () => {
|
|
615
|
+
document.removeEventListener("mousedown", listener);
|
|
616
|
+
document.removeEventListener("touchstart", listener);
|
|
617
|
+
};
|
|
618
|
+
}, [...refs]);
|
|
575
619
|
};
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
};
|
|
598
|
-
}, [ref, options]);
|
|
620
|
+
const useOnClickOutside = (ref, handler, options) => {
|
|
621
|
+
const eventHandler = useRef(() => {
|
|
622
|
+
return;
|
|
623
|
+
});
|
|
624
|
+
useEffect(() => {
|
|
625
|
+
eventHandler.current = handler;
|
|
626
|
+
}, [handler]);
|
|
627
|
+
useEffect(() => {
|
|
628
|
+
const listener = (event) => {
|
|
629
|
+
if (!ref.current || ref.current.contains(event.target)) {
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
632
|
+
eventHandler.current(event);
|
|
633
|
+
};
|
|
634
|
+
document.addEventListener("mousedown", listener, options);
|
|
635
|
+
document.addEventListener("touchstart", listener, options);
|
|
636
|
+
return () => {
|
|
637
|
+
document.removeEventListener("mousedown", listener, options);
|
|
638
|
+
document.removeEventListener("touchstart", listener, options);
|
|
639
|
+
};
|
|
640
|
+
}, [ref, options]);
|
|
599
641
|
};
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
});
|
|
616
|
-
};
|
|
617
|
-
}, [delay]);
|
|
642
|
+
const events = ["mousemove", "mousedown", "keydown", "touchstart", "scroll"];
|
|
643
|
+
const useOnNoMouseMovement = (callback, delay) => {
|
|
644
|
+
const eventHandler = useRef(() => {
|
|
645
|
+
return;
|
|
646
|
+
});
|
|
647
|
+
useEffect(() => {
|
|
648
|
+
eventHandler.current = callback;
|
|
649
|
+
}, [callback]);
|
|
650
|
+
useEffect(() => {
|
|
651
|
+
const onIdleChange = debounce(eventHandler.current, delay);
|
|
652
|
+
events.forEach((event) => window.addEventListener(event, onIdleChange));
|
|
653
|
+
return () => {
|
|
654
|
+
events.forEach((event) => window.removeEventListener(event, onIdleChange));
|
|
655
|
+
};
|
|
656
|
+
}, [delay]);
|
|
618
657
|
};
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
observer.disconnect();
|
|
639
|
-
};
|
|
640
|
-
}, [observer, ref]);
|
|
641
|
-
return isVisible;
|
|
658
|
+
const useOnScreen = (ref, options) => {
|
|
659
|
+
const [isVisible, setIsVisible] = useState(false);
|
|
660
|
+
const { rootMargin, root, threshold } = options || {};
|
|
661
|
+
const observer = useMemo(() => {
|
|
662
|
+
return new IntersectionObserver(([entry]) => setIsVisible(entry.isIntersecting), {
|
|
663
|
+
rootMargin,
|
|
664
|
+
root,
|
|
665
|
+
threshold
|
|
666
|
+
});
|
|
667
|
+
}, [setIsVisible, rootMargin, root, threshold]);
|
|
668
|
+
useEffect(() => {
|
|
669
|
+
if (ref.current) {
|
|
670
|
+
observer.observe(ref.current);
|
|
671
|
+
}
|
|
672
|
+
return () => {
|
|
673
|
+
observer.disconnect();
|
|
674
|
+
};
|
|
675
|
+
}, [observer, ref]);
|
|
676
|
+
return isVisible;
|
|
642
677
|
};
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
});
|
|
656
|
-
return innerRef;
|
|
678
|
+
const useForwardedRef = (ref) => {
|
|
679
|
+
const innerRef = useRef(null);
|
|
680
|
+
useEffect(() => {
|
|
681
|
+
if (!ref)
|
|
682
|
+
return;
|
|
683
|
+
if (typeof ref === "function") {
|
|
684
|
+
ref(innerRef.current);
|
|
685
|
+
} else {
|
|
686
|
+
ref.current = innerRef.current;
|
|
687
|
+
}
|
|
688
|
+
});
|
|
689
|
+
return innerRef;
|
|
657
690
|
};
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
};
|
|
675
|
-
}, []);
|
|
676
|
-
return [value, wrappedSetter];
|
|
691
|
+
const useTimeoutState = (initialValue, defaultTimeout, clearTimeoutOnSetValue = true) => {
|
|
692
|
+
const [value, setValue] = useState(initialValue);
|
|
693
|
+
const timeoutRef = useRef();
|
|
694
|
+
const wrappedSetter = useCallback((newValue, timeout = defaultTimeout) => {
|
|
695
|
+
setValue(newValue);
|
|
696
|
+
if (clearTimeoutOnSetValue) {
|
|
697
|
+
clearTimeout(timeoutRef.current);
|
|
698
|
+
}
|
|
699
|
+
timeoutRef.current = setTimeout(() => setValue(initialValue), timeout);
|
|
700
|
+
}, [defaultTimeout, clearTimeoutOnSetValue, initialValue]);
|
|
701
|
+
useEffect(() => {
|
|
702
|
+
return () => {
|
|
703
|
+
clearTimeout(timeoutRef.current);
|
|
704
|
+
};
|
|
705
|
+
}, []);
|
|
706
|
+
return [value, wrappedSetter];
|
|
677
707
|
};
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
throw new Error("Switch unhandled case: ".concat(arg));
|
|
681
|
-
};
|
|
682
|
-
var exhaustSwitchCase = function (_arg, fallback) {
|
|
683
|
-
return fallback;
|
|
708
|
+
const exhaustSwitchCaseElseThrow = (arg) => {
|
|
709
|
+
throw new Error(`Switch unhandled case: ${arg}`);
|
|
684
710
|
};
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
return Object.keys(r).filter(function (key) { return r[key]; });
|
|
711
|
+
const exhaustSwitchCase = (_arg, fallback) => {
|
|
712
|
+
return fallback;
|
|
688
713
|
};
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
714
|
+
const truthyKeysAsList = (r) => Object.keys(r).filter((key) => r[key]);
|
|
715
|
+
const getDataProps = (props) => pickBy(props, isDataPropMapper);
|
|
716
|
+
const isDataPropMapper = (_, key) => isDataProp(key);
|
|
717
|
+
const isDataProp = (propName) => propName.startsWith("data-") || propName.startsWith("aria-");
|
|
718
|
+
const parseFloatElseUndefined = (s) => {
|
|
719
|
+
try {
|
|
720
|
+
const f = parseFloat(s);
|
|
721
|
+
if (isNaN(f)) {
|
|
722
|
+
return void 0;
|
|
723
|
+
}
|
|
724
|
+
if (f == null) {
|
|
725
|
+
return void 0;
|
|
726
|
+
}
|
|
727
|
+
return f;
|
|
728
|
+
} catch (e) {
|
|
729
|
+
}
|
|
730
|
+
return void 0;
|
|
694
731
|
};
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
return undefined;
|
|
709
|
-
};
|
|
710
|
-
var parseIntElseUndefined = function (s) {
|
|
711
|
-
try {
|
|
712
|
-
var f = parseInt(s, 10);
|
|
713
|
-
if (isNaN(f)) {
|
|
714
|
-
return undefined;
|
|
715
|
-
}
|
|
716
|
-
if (f == null) {
|
|
717
|
-
return undefined;
|
|
718
|
-
}
|
|
719
|
-
return f;
|
|
720
|
-
}
|
|
721
|
-
catch (e) { }
|
|
722
|
-
return undefined;
|
|
732
|
+
const parseIntElseUndefined = (s) => {
|
|
733
|
+
try {
|
|
734
|
+
const f = parseInt(s, 10);
|
|
735
|
+
if (isNaN(f)) {
|
|
736
|
+
return void 0;
|
|
737
|
+
}
|
|
738
|
+
if (f == null) {
|
|
739
|
+
return void 0;
|
|
740
|
+
}
|
|
741
|
+
return f;
|
|
742
|
+
} catch (e) {
|
|
743
|
+
}
|
|
744
|
+
return void 0;
|
|
723
745
|
};
|
|
724
|
-
|
|
725
746
|
export { Box, Clickable, Column, HeaderText, Heading, Indent, LargeText, Nest, ResizeAwareBox, Row, SeparatorLine, SmallText, SmallerText, Space, Spacing, StandardText, Text, Txt, booleanOrNumberToNumber, exhaustSwitchCase, exhaustSwitchCaseElseThrow, getDataProps, getDimensionObject, parseFloatElseUndefined, parseIntElseUndefined, truthyKeysAsList, useArraySet, useBoolean, useDebounce, useDelayedFalse, useDomId, useElementDimensions, useElementFocus, useEventListener, useForwardedRef, useMouseIsEntered, useMouseIsOver, useMultiOnClickOutside, useOnClickOutside, useOnNoMouseMovement, useOnScreen, useTimeoutState };
|
|
726
747
|
//# sourceMappingURL=index.es.js.map
|