@tedi-design-system/react 17.0.0 → 17.1.0-rc.2
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/bundle-stats.html +1 -1
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.development.cjs.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.development.es.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.production.min.cjs.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.production.min.es.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/index.cjs.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/index.es.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.development.cjs.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.development.es.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.production.min.cjs.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.production.min.es.js +1 -1
- package/external/prop-types/external/react-is/index.cjs.js +1 -1
- package/external/prop-types/external/react-is/index.es.js +1 -1
- package/index.css +1 -1
- package/package.json +5 -17
- package/src/tedi/components/form/field/field.cjs.js +1 -0
- package/src/tedi/components/form/field/field.d.ts +88 -0
- package/src/tedi/components/form/field/field.es.js +54 -0
- package/src/tedi/components/form/field/field.module.scss.cjs.js +1 -0
- package/src/tedi/components/form/field/field.module.scss.es.js +6 -0
- package/src/tedi/components/form/file-upload/file-upload.cjs.js +1 -1
- package/src/tedi/components/form/file-upload/file-upload.d.ts +14 -2
- package/src/tedi/components/form/file-upload/file-upload.es.js +97 -90
- package/src/tedi/components/form/input-group/components/input/input.cjs.js +1 -0
- package/src/tedi/components/form/input-group/components/input/input.d.ts +19 -0
- package/src/tedi/components/form/input-group/components/input/input.es.js +20 -0
- package/src/tedi/components/form/input-group/components/prefix/prefix.cjs.js +1 -0
- package/src/tedi/components/form/input-group/components/prefix/prefix.d.ts +18 -0
- package/src/tedi/components/form/input-group/components/prefix/prefix.es.js +26 -0
- package/src/tedi/components/form/input-group/components/suffix/suffix.cjs.js +1 -0
- package/src/tedi/components/form/input-group/components/suffix/suffix.d.ts +18 -0
- package/src/tedi/components/form/input-group/components/suffix/suffix.es.js +26 -0
- package/src/tedi/components/form/input-group/index.d.ts +4 -0
- package/src/tedi/components/form/input-group/input-group.cjs.js +1 -0
- package/src/tedi/components/form/input-group/input-group.d.ts +87 -0
- package/src/tedi/components/form/input-group/input-group.es.js +61 -0
- package/src/tedi/components/form/input-group/input-group.module.scss.cjs.js +1 -0
- package/src/tedi/components/form/input-group/input-group.module.scss.es.js +16 -0
- package/src/tedi/components/form/search/search.cjs.js +1 -1
- package/src/tedi/components/form/search/search.es.js +35 -25
- package/src/tedi/components/form/select/components/select-control.cjs.js +1 -1
- package/src/tedi/components/form/select/components/select-control.es.js +7 -3
- package/src/tedi/components/form/select/select.cjs.js +1 -1
- package/src/tedi/components/form/select/select.d.ts +3 -2
- package/src/tedi/components/form/select/select.es.js +168 -166
- package/src/tedi/components/form/slider/slider.cjs.js +1 -0
- package/src/tedi/components/form/slider/slider.d.ts +116 -0
- package/src/tedi/components/form/slider/slider.es.js +145 -0
- package/src/tedi/components/form/slider/slider.module.scss.cjs.js +1 -0
- package/src/tedi/components/form/slider/slider.module.scss.es.js +18 -0
- package/src/tedi/components/form/textfield/textfield.cjs.js +1 -1
- package/src/tedi/components/form/textfield/textfield.d.ts +118 -36
- package/src/tedi/components/form/textfield/textfield.es.js +134 -172
- package/src/tedi/components/overlays/overlay/overlay.cjs.js +1 -1
- package/src/tedi/components/overlays/overlay/overlay.d.ts +12 -0
- package/src/tedi/components/overlays/overlay/overlay.es.js +75 -74
- package/src/tedi/index.d.ts +3 -0
- package/tedi.cjs.js +1 -1
- package/tedi.es.js +170 -156
|
@@ -1,163 +1,165 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { FeedbackText as
|
|
7
|
-
import { FormLabel as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
1
|
+
import { jsx as l, jsxs as w } from "react/jsx-runtime";
|
|
2
|
+
import Oe from "../../../../../external/classnames/index.es.js";
|
|
3
|
+
import c, { forwardRef as ve } from "react";
|
|
4
|
+
import Ce from "../../../../../external/react-select/dist/react-select.esm.es.js";
|
|
5
|
+
import Le from "../../../../../external/react-select/async/dist/react-select-async.esm.es.js";
|
|
6
|
+
import { FeedbackText as he } from "../feedback-text/feedback-text.es.js";
|
|
7
|
+
import { FormLabel as ye } from "../form-label/form-label.es.js";
|
|
8
|
+
import { useOptionalInputGroup as Ne } from "../input-group/input-group.es.js";
|
|
9
|
+
import { SelectClearIndicator as Ve } from "./components/select-clear-indicator.es.js";
|
|
10
|
+
import { SelectControl as Re } from "./components/select-control.es.js";
|
|
11
|
+
import { SelectDropDownIndicator as we } from "./components/select-dropdown-indicator.es.js";
|
|
12
|
+
import { SelectGroup as _e } from "./components/select-group.es.js";
|
|
13
|
+
import { SelectGroupHeading as $e } from "./components/select-group-heading.es.js";
|
|
14
|
+
import { SelectIndicatorsContainer as xe } from "./components/select-indicators-container.es.js";
|
|
15
|
+
import { SelectInput as He } from "./components/select-input.es.js";
|
|
16
|
+
import { SelectLoadingIndicator as Pe } from "./components/select-loading-indicator.es.js";
|
|
17
|
+
import { SelectMenu as Te } from "./components/select-menu.es.js";
|
|
18
|
+
import { SelectMenuList as De } from "./components/select-menu-list.es.js";
|
|
19
|
+
import { SelectMenuPortal as Fe } from "./components/select-menu-portal.es.js";
|
|
20
|
+
import { SelectMultiValue as je } from "./components/select-multi-value.es.js";
|
|
21
|
+
import { SelectMultiValueRemove as ke } from "./components/select-multi-value-remove.es.js";
|
|
22
|
+
import { SelectOption as Ee } from "./components/select-option.es.js";
|
|
23
|
+
import { SelectValueContainer as Be } from "./components/select-value-container.es.js";
|
|
23
24
|
import o from "./select.module.scss.es.js";
|
|
24
|
-
import { useLabels as
|
|
25
|
-
const
|
|
26
|
-
(
|
|
25
|
+
import { useLabels as Ge } from "../../../providers/label-provider/use-labels.es.js";
|
|
26
|
+
const qe = ve(
|
|
27
|
+
(g, _) => {
|
|
28
|
+
var R;
|
|
27
29
|
const {
|
|
28
|
-
options:
|
|
29
|
-
defaultOptions:
|
|
30
|
-
id:
|
|
31
|
-
name:
|
|
32
|
-
iconName:
|
|
33
|
-
label:
|
|
34
|
-
required:
|
|
35
|
-
value:
|
|
36
|
-
defaultValue:
|
|
37
|
-
tagsDirection:
|
|
38
|
-
onChange:
|
|
39
|
-
onInputChange:
|
|
40
|
-
inputValue:
|
|
41
|
-
loadOptions:
|
|
42
|
-
isLoading:
|
|
30
|
+
options: $,
|
|
31
|
+
defaultOptions: x,
|
|
32
|
+
id: S,
|
|
33
|
+
name: H,
|
|
34
|
+
iconName: P = "arrow_drop_down",
|
|
35
|
+
label: T,
|
|
36
|
+
required: b,
|
|
37
|
+
value: D,
|
|
38
|
+
defaultValue: F,
|
|
39
|
+
tagsDirection: M = "row",
|
|
40
|
+
onChange: d,
|
|
41
|
+
onInputChange: j,
|
|
42
|
+
inputValue: k,
|
|
43
|
+
loadOptions: E,
|
|
44
|
+
isLoading: B,
|
|
43
45
|
openMenuOnFocus: G = !1,
|
|
44
|
-
openMenuOnClick:
|
|
45
|
-
tabSelectsValue:
|
|
46
|
-
disabled:
|
|
47
|
-
className:
|
|
48
|
-
hideLabel:
|
|
46
|
+
openMenuOnClick: q = !0,
|
|
47
|
+
tabSelectsValue: z = !1,
|
|
48
|
+
disabled: I = !1,
|
|
49
|
+
className: O,
|
|
50
|
+
hideLabel: A = !1,
|
|
49
51
|
helper: t,
|
|
50
|
-
placeholder:
|
|
51
|
-
invalid:
|
|
52
|
-
valid:
|
|
53
|
-
size:
|
|
54
|
-
async:
|
|
55
|
-
renderOption:
|
|
56
|
-
renderMessageListFooter:
|
|
57
|
-
noOptionsMessage:
|
|
58
|
-
loadingMessage:
|
|
59
|
-
multiple:
|
|
60
|
-
closeMenuOnSelect:
|
|
61
|
-
blurInputOnSelect:
|
|
62
|
-
autoFocus:
|
|
63
|
-
isClearable:
|
|
64
|
-
isClearIndicatorVisible:
|
|
65
|
-
isSearchable:
|
|
66
|
-
menuIsOpen:
|
|
67
|
-
onMenuClose:
|
|
68
|
-
onMenuOpen:
|
|
69
|
-
onBlur:
|
|
70
|
-
inputIsHidden:
|
|
71
|
-
isTagRemovable:
|
|
72
|
-
optionGroupHeadingText:
|
|
73
|
-
cacheOptions:
|
|
74
|
-
showRadioButtons:
|
|
75
|
-
renderWithoutLabel:
|
|
76
|
-
tooltip:
|
|
77
|
-
classNames:
|
|
78
|
-
} =
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
() =>
|
|
52
|
+
placeholder: W,
|
|
53
|
+
invalid: J,
|
|
54
|
+
valid: K,
|
|
55
|
+
size: m,
|
|
56
|
+
async: Q = !1,
|
|
57
|
+
renderOption: U,
|
|
58
|
+
renderMessageListFooter: v,
|
|
59
|
+
noOptionsMessage: X,
|
|
60
|
+
loadingMessage: Y,
|
|
61
|
+
multiple: u = !1,
|
|
62
|
+
closeMenuOnSelect: Z = !u,
|
|
63
|
+
blurInputOnSelect: C = !1,
|
|
64
|
+
autoFocus: ee = !1,
|
|
65
|
+
isClearable: te = !0,
|
|
66
|
+
isClearIndicatorVisible: oe = !1,
|
|
67
|
+
isSearchable: L = !0,
|
|
68
|
+
menuIsOpen: ae,
|
|
69
|
+
onMenuClose: ne,
|
|
70
|
+
onMenuOpen: re,
|
|
71
|
+
onBlur: ie,
|
|
72
|
+
inputIsHidden: se,
|
|
73
|
+
isTagRemovable: h = !1,
|
|
74
|
+
optionGroupHeadingText: le = { modifiers: "small", color: "tertiary" },
|
|
75
|
+
cacheOptions: ce = !0,
|
|
76
|
+
showRadioButtons: de = !1,
|
|
77
|
+
renderWithoutLabel: me,
|
|
78
|
+
tooltip: ue,
|
|
79
|
+
classNames: y
|
|
80
|
+
} = g, a = (R = Ne) == null ? void 0 : R(), pe = c.useId(), fe = a == null ? void 0 : a.hasExternalLabel, p = g.id ?? (a == null ? void 0 : a.inputId) ?? pe, N = t ? (t == null ? void 0 : t.id) ?? `${p}-helper` : void 0, r = c.useRef(null), { getLabel: V } = Ge();
|
|
81
|
+
c.useImperativeHandle(
|
|
82
|
+
_,
|
|
83
|
+
() => r.current
|
|
82
84
|
);
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
var
|
|
86
|
-
return (
|
|
85
|
+
const ge = (n) => {
|
|
86
|
+
d == null || d(n), !C && r.current && setTimeout(() => {
|
|
87
|
+
var i, s;
|
|
88
|
+
return (s = (i = r.current) == null ? void 0 : i.inputRef) == null ? void 0 : s.focus();
|
|
87
89
|
}, 0);
|
|
88
|
-
},
|
|
89
|
-
(
|
|
90
|
-
[
|
|
91
|
-
),
|
|
92
|
-
const
|
|
93
|
-
ClearIndicator: (e) =>
|
|
94
|
-
DropdownIndicator: () =>
|
|
90
|
+
}, Se = c.useCallback(
|
|
91
|
+
(n) => /* @__PURE__ */ l(De, { ...n, renderMessageListFooter: v }),
|
|
92
|
+
[v]
|
|
93
|
+
), be = () => {
|
|
94
|
+
const n = {
|
|
95
|
+
ClearIndicator: (e) => Ve({ isClearIndicatorVisible: oe, ...e }),
|
|
96
|
+
DropdownIndicator: () => we({ iconName: P }),
|
|
95
97
|
IndicatorSeparator: () => null,
|
|
96
|
-
MenuPortal:
|
|
97
|
-
Menu:
|
|
98
|
-
MenuList:
|
|
99
|
-
Option: (e) =>
|
|
100
|
-
Control:
|
|
101
|
-
Input:
|
|
102
|
-
MultiValue: (e) =>
|
|
103
|
-
MultiValueRemove:
|
|
104
|
-
Group:
|
|
105
|
-
GroupHeading: (e) =>
|
|
106
|
-
IndicatorsContainer:
|
|
107
|
-
ValueContainer:
|
|
108
|
-
LoadingIndicator:
|
|
109
|
-
},
|
|
110
|
-
return /* @__PURE__ */
|
|
111
|
-
|
|
98
|
+
MenuPortal: Fe,
|
|
99
|
+
Menu: Te,
|
|
100
|
+
MenuList: Se,
|
|
101
|
+
Option: (e) => Ee({ renderOption: U, multiple: u, showRadioButtons: de, ...e }),
|
|
102
|
+
Control: (e) => Re({ ...e, className: O }),
|
|
103
|
+
Input: He,
|
|
104
|
+
MultiValue: (e) => je({ isTagRemovable: h, ...e }),
|
|
105
|
+
MultiValueRemove: ke,
|
|
106
|
+
Group: _e,
|
|
107
|
+
GroupHeading: (e) => $e({ optionGroupHeadingText: le, ...e }),
|
|
108
|
+
IndicatorsContainer: xe,
|
|
109
|
+
ValueContainer: Be,
|
|
110
|
+
LoadingIndicator: Pe
|
|
111
|
+
}, i = Q ? Le : Ce, s = () => V("select.no-options"), Ie = () => V("select.loading");
|
|
112
|
+
return /* @__PURE__ */ l(
|
|
113
|
+
i,
|
|
112
114
|
{
|
|
113
|
-
id:
|
|
114
|
-
"aria-describedby":
|
|
115
|
-
autoFocus:
|
|
116
|
-
ref:
|
|
117
|
-
instanceId:
|
|
115
|
+
id: p,
|
|
116
|
+
"aria-describedby": N,
|
|
117
|
+
autoFocus: ee,
|
|
118
|
+
ref: r,
|
|
119
|
+
instanceId: S,
|
|
118
120
|
className: "tedi-select__wrapper",
|
|
119
|
-
name:
|
|
120
|
-
options:
|
|
121
|
-
defaultOptions:
|
|
122
|
-
value:
|
|
123
|
-
defaultValue:
|
|
124
|
-
cacheOptions:
|
|
125
|
-
onChange:
|
|
126
|
-
onInputChange:
|
|
127
|
-
onBlur:
|
|
128
|
-
inputValue:
|
|
129
|
-
inputId: `${
|
|
130
|
-
loadOptions:
|
|
131
|
-
isLoading:
|
|
132
|
-
noOptionsMessage:
|
|
133
|
-
loadingMessage:
|
|
121
|
+
name: H,
|
|
122
|
+
options: $,
|
|
123
|
+
defaultOptions: x,
|
|
124
|
+
value: D,
|
|
125
|
+
defaultValue: F,
|
|
126
|
+
cacheOptions: ce,
|
|
127
|
+
onChange: ge,
|
|
128
|
+
onInputChange: j,
|
|
129
|
+
onBlur: ie,
|
|
130
|
+
inputValue: k,
|
|
131
|
+
inputId: `${S}-input`,
|
|
132
|
+
loadOptions: E,
|
|
133
|
+
isLoading: B,
|
|
134
|
+
noOptionsMessage: X || s,
|
|
135
|
+
loadingMessage: Y || Ie,
|
|
134
136
|
classNamePrefix: "select",
|
|
135
|
-
components:
|
|
136
|
-
isDisabled:
|
|
137
|
-
isSearchable:
|
|
138
|
-
menuIsOpen:
|
|
137
|
+
components: n,
|
|
138
|
+
isDisabled: I,
|
|
139
|
+
isSearchable: L,
|
|
140
|
+
menuIsOpen: ae,
|
|
139
141
|
openMenuOnFocus: G,
|
|
140
|
-
openMenuOnClick:
|
|
141
|
-
tabSelectsValue:
|
|
142
|
-
onMenuClose:
|
|
143
|
-
onMenuOpen:
|
|
144
|
-
placeholder:
|
|
145
|
-
isClearable:
|
|
146
|
-
backspaceRemovesValue:
|
|
142
|
+
openMenuOnClick: q,
|
|
143
|
+
tabSelectsValue: z,
|
|
144
|
+
onMenuClose: ne,
|
|
145
|
+
onMenuOpen: re,
|
|
146
|
+
placeholder: W || "",
|
|
147
|
+
isClearable: te,
|
|
148
|
+
backspaceRemovesValue: h,
|
|
147
149
|
menuShouldScrollIntoView: !0,
|
|
148
|
-
isMulti:
|
|
150
|
+
isMulti: u,
|
|
149
151
|
hideSelectedOptions: !1,
|
|
150
|
-
closeMenuOnSelect:
|
|
151
|
-
blurInputOnSelect:
|
|
152
|
+
closeMenuOnSelect: Z,
|
|
153
|
+
blurInputOnSelect: C,
|
|
152
154
|
menuPlacement: "auto",
|
|
153
|
-
inputIsHidden:
|
|
154
|
-
required:
|
|
155
|
+
inputIsHidden: se,
|
|
156
|
+
required: b,
|
|
155
157
|
menuPortalTarget: document.body,
|
|
156
158
|
menuPosition: "absolute",
|
|
157
|
-
classNames:
|
|
158
|
-
Object.entries(
|
|
159
|
+
classNames: y ? Object.fromEntries(
|
|
160
|
+
Object.entries(y).map(([e, f]) => [
|
|
159
161
|
e,
|
|
160
|
-
typeof
|
|
162
|
+
typeof f == "string" ? () => f : f
|
|
161
163
|
])
|
|
162
164
|
) : void 0,
|
|
163
165
|
theme: (e) => ({
|
|
@@ -177,37 +179,37 @@ const Fe = Se(
|
|
|
177
179
|
}
|
|
178
180
|
}
|
|
179
181
|
);
|
|
180
|
-
},
|
|
182
|
+
}, Me = Oe(
|
|
181
183
|
o["tedi-select"],
|
|
182
|
-
|
|
183
|
-
{ [o["tedi-select--invalid"]]:
|
|
184
|
-
{ [o["tedi-select--valid"]]:
|
|
185
|
-
{ [o[`tedi-select--${
|
|
186
|
-
{ [o[`tedi-select--tags-${
|
|
187
|
-
{ [o["tedi-select--searchable"]]:
|
|
188
|
-
{ [o["tedi-select--disabled"]]:
|
|
184
|
+
O,
|
|
185
|
+
{ [o["tedi-select--invalid"]]: J || (t == null ? void 0 : t.type) === "error" },
|
|
186
|
+
{ [o["tedi-select--valid"]]: K || (t == null ? void 0 : t.type) === "valid" },
|
|
187
|
+
{ [o[`tedi-select--${m}`]]: m },
|
|
188
|
+
{ [o[`tedi-select--tags-${M}`]]: M },
|
|
189
|
+
{ [o["tedi-select--searchable"]]: L },
|
|
190
|
+
{ [o["tedi-select--disabled"]]: I }
|
|
189
191
|
);
|
|
190
|
-
return /* @__PURE__ */
|
|
191
|
-
/* @__PURE__ */
|
|
192
|
-
/* @__PURE__ */
|
|
193
|
-
|
|
192
|
+
return /* @__PURE__ */ w("div", { "data-name": "select", className: Me, children: [
|
|
193
|
+
/* @__PURE__ */ w("div", { className: o["tedi-select__inner"], children: [
|
|
194
|
+
!fe && /* @__PURE__ */ l(
|
|
195
|
+
ye,
|
|
194
196
|
{
|
|
195
|
-
id: `${
|
|
196
|
-
label:
|
|
197
|
-
required:
|
|
198
|
-
hideLabel:
|
|
199
|
-
size:
|
|
200
|
-
renderWithoutLabel:
|
|
201
|
-
tooltip:
|
|
197
|
+
id: `${p}-input`,
|
|
198
|
+
label: T,
|
|
199
|
+
required: b,
|
|
200
|
+
hideLabel: A,
|
|
201
|
+
size: m,
|
|
202
|
+
renderWithoutLabel: me,
|
|
203
|
+
tooltip: ue
|
|
202
204
|
}
|
|
203
205
|
),
|
|
204
|
-
|
|
206
|
+
be()
|
|
205
207
|
] }),
|
|
206
|
-
t && /* @__PURE__ */
|
|
208
|
+
t && /* @__PURE__ */ l(he, { ...t, id: N })
|
|
207
209
|
] });
|
|
208
210
|
}
|
|
209
211
|
);
|
|
210
|
-
|
|
212
|
+
qe.displayName = "Select";
|
|
211
213
|
export {
|
|
212
|
-
|
|
214
|
+
qe as Select
|
|
213
215
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),m=require("../../../../../external/classnames/index.cjs.js"),e=require("react"),ne=require("../../overlays/tooltip/tooltip.cjs.js"),de=require("../../overlays/tooltip/tooltip-content.cjs.js"),oe=require("../../overlays/tooltip/tooltip-trigger.cjs.js"),ue=require("../feedback-text/feedback-text.cjs.js"),ce=require("../form-label/form-label.cjs.js"),t=require("./slider.module.scss.cjs.js"),fe=require("../../../helpers/hooks/use-breakpoint-props.cjs.js"),F=e.forwardRef((h,M)=>{const{getCurrentBreakpointProps:V}=fe.useBreakpointProps(h.defaultServerBreakpoint),{id:E,name:P,label:x,hideLabel:R,required:_,min:l=0,max:d=100,step:D=1,value:c,defaultValue:$,onChange:o,disabled:s=!1,invalid:H=!1,minLabel:f,maxLabel:O,showCurrentValue:p=!1,valueFormatter:k,tooltip:U=!0,addonRight:j,helper:r,className:z,"aria-label":A,"aria-labelledby":G,"aria-valuetext":J}=V(h),K=e.useId(),b=E??`tedi-slider-${K}`,w=r?r.id??`${b}-helper`:void 0,[Q,W]=e.useState($??l),u=Math.min(d,Math.max(l,c??Q)),[X,L]=e.useState(!1),[Y,N]=e.useState(!1),[i,C]=e.useState(!1),S=!!U&&!s,Z=S&&(X||Y||i),ee=e.useCallback(()=>L(!0),[]),ae=e.useCallback(()=>L(!1),[]),te=e.useCallback(()=>N(!0),[]),re=e.useCallback(()=>N(!1),[]),T=e.useRef(null),n=e.useCallback(()=>{T.current=null,C(!1)},[]);e.useEffect(()=>{if(i)return window.addEventListener("pointerup",n),window.addEventListener("pointercancel",n),()=>{window.removeEventListener("pointerup",n),window.removeEventListener("pointercancel",n)}},[i,n]);const le=e.useCallback(g=>{s||(T.current=g.pointerId,C(!0))},[s]),se=e.useCallback(g=>{const B=Number(g.target.value);c===void 0&&W(B),o==null||o(B)},[o,c]),q=H||(r==null?void 0:r.type)==="error",I=d===l?0:(u-l)/(d-l)*100,y=k?k(u):u,v=p?y:O,ie=m.default(t.default["tedi-slider"],{[t.default["tedi-slider--disabled"]]:s,[t.default["tedi-slider--invalid"]]:q,[t.default["tedi-slider--dragging"]]:i&&!s},z);return a.jsxs("div",{"data-name":"slider",className:ie,children:[x&&a.jsx(ce.FormLabel,{id:b,label:x,required:_,hideLabel:R}),a.jsxs("div",{className:t.default["tedi-slider__container"],children:[a.jsxs("div",{className:t.default["tedi-slider__track-row"],children:[f!=null&&a.jsx("span",{className:t.default["tedi-slider__range-label"],"aria-hidden":"true",children:f}),a.jsxs("div",{className:t.default["tedi-slider__track"],style:{"--tedi-slider-progress":`${I}%`,"--tedi-slider-progress-ratio":`${I/100}`},children:[a.jsx("input",{ref:M,id:b,name:P,type:"range",min:l,max:d,step:D,value:u,disabled:s,required:_,"aria-invalid":q?"true":void 0,"aria-describedby":w,"aria-label":A,"aria-labelledby":G,"aria-valuetext":J,onChange:se,onMouseEnter:ee,onMouseLeave:ae,onPointerDown:le,onFocus:te,onBlur:re,className:m.default(t.default["tedi-slider__input"],{[t.default["tedi-slider__input--dragging"]]:i})}),S&&a.jsxs(ne.Tooltip,{open:Z,onToggle:()=>{},focusManager:{returnFocus:!1,initialFocus:-1},placement:"top",trackReferencePosition:!0,children:[a.jsx(oe.TooltipTrigger,{children:a.jsx("span",{className:t.default["tedi-slider__thumb-anchor"],"aria-hidden":"true",tabIndex:-1})}),a.jsx(de.TooltipContent,{children:y})]})]}),v!=null&&a.jsx("span",{className:t.default["tedi-slider__range-label"],"aria-hidden":p?void 0:"true","aria-live":p?"polite":void 0,children:v})]}),j&&a.jsx("div",{className:t.default["tedi-slider__addon"],children:j})]}),r&&a.jsx(ue.FeedbackText,{...r,id:w,className:m.default(t.default["tedi-slider__feedback"],r.className)})]})});F.displayName="Slider";exports.Slider=F;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { BreakpointSupport } from '../../../helpers';
|
|
3
|
+
import { FeedbackTextProps } from '../feedback-text/feedback-text';
|
|
4
|
+
type SliderBreakpointProps = {
|
|
5
|
+
/**
|
|
6
|
+
* Text/element rendered to the left of the track (e.g. the minimum value).
|
|
7
|
+
*/
|
|
8
|
+
minLabel?: React.ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* Text/element rendered to the right of the track (e.g. the maximum value).
|
|
11
|
+
* Ignored when `showCurrentValue` is `true`.
|
|
12
|
+
*/
|
|
13
|
+
maxLabel?: React.ReactNode;
|
|
14
|
+
/**
|
|
15
|
+
* When `true`, renders the current value to the right of the track instead of `maxLabel`.
|
|
16
|
+
* @default false
|
|
17
|
+
*/
|
|
18
|
+
showCurrentValue?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Formats the current value, used by both the thumb tooltip and the `showCurrentValue` label.
|
|
21
|
+
* @default (value) => value
|
|
22
|
+
*/
|
|
23
|
+
valueFormatter?: (value: number) => React.ReactNode;
|
|
24
|
+
/**
|
|
25
|
+
* Renders a tooltip above the thumb showing the current value. Shown only while the slider is
|
|
26
|
+
* hovered, focused, or being dragged. Value is formatted via `valueFormatter`.
|
|
27
|
+
* @default true
|
|
28
|
+
*/
|
|
29
|
+
tooltip?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Node rendered to the right of the slider, typically a NumberField used to edit the same value.
|
|
32
|
+
*/
|
|
33
|
+
addonRight?: React.ReactNode;
|
|
34
|
+
/**
|
|
35
|
+
* Helper text rendered below the slider.
|
|
36
|
+
*/
|
|
37
|
+
helper?: FeedbackTextProps;
|
|
38
|
+
/**
|
|
39
|
+
* Additional class name(s) applied to the root element.
|
|
40
|
+
*/
|
|
41
|
+
className?: string;
|
|
42
|
+
};
|
|
43
|
+
export interface SliderProps extends BreakpointSupport<SliderBreakpointProps> {
|
|
44
|
+
/**
|
|
45
|
+
* Unique identifier for the underlying input element.
|
|
46
|
+
* Generated automatically if not provided.
|
|
47
|
+
*/
|
|
48
|
+
id?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Name attribute of the underlying input element.
|
|
51
|
+
*/
|
|
52
|
+
name?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Label text rendered above the slider.
|
|
55
|
+
*/
|
|
56
|
+
label?: React.ReactNode;
|
|
57
|
+
/**
|
|
58
|
+
* Controls the visibility of the label. Pass `true` to hide it visually while keeping it
|
|
59
|
+
* available to assistive technology, or `'keep-space'` to reserve the vertical space.
|
|
60
|
+
*/
|
|
61
|
+
hideLabel?: boolean | 'keep-space';
|
|
62
|
+
/**
|
|
63
|
+
* Marks the field as required.
|
|
64
|
+
*/
|
|
65
|
+
required?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Minimum allowed value.
|
|
68
|
+
* @default 0
|
|
69
|
+
*/
|
|
70
|
+
min?: number;
|
|
71
|
+
/**
|
|
72
|
+
* Maximum allowed value.
|
|
73
|
+
* @default 100
|
|
74
|
+
*/
|
|
75
|
+
max?: number;
|
|
76
|
+
/**
|
|
77
|
+
* Step size.
|
|
78
|
+
* @default 1
|
|
79
|
+
*/
|
|
80
|
+
step?: number;
|
|
81
|
+
/**
|
|
82
|
+
* Controlled value. Use together with `onChange`.
|
|
83
|
+
*/
|
|
84
|
+
value?: number;
|
|
85
|
+
/**
|
|
86
|
+
* Default value for uncontrolled usage.
|
|
87
|
+
* @default min
|
|
88
|
+
*/
|
|
89
|
+
defaultValue?: number;
|
|
90
|
+
/**
|
|
91
|
+
* Callback fired when the value changes.
|
|
92
|
+
*/
|
|
93
|
+
onChange?: (value: number) => void;
|
|
94
|
+
/**
|
|
95
|
+
* Disables the slider.
|
|
96
|
+
*/
|
|
97
|
+
disabled?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Marks the slider as invalid for validation purposes.
|
|
100
|
+
*/
|
|
101
|
+
invalid?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Accessible label used when no visible `label` is provided.
|
|
104
|
+
*/
|
|
105
|
+
'aria-label'?: string;
|
|
106
|
+
/**
|
|
107
|
+
* ID of an element that labels the slider, used when no visible `label` is provided.
|
|
108
|
+
*/
|
|
109
|
+
'aria-labelledby'?: string;
|
|
110
|
+
/**
|
|
111
|
+
* Human-readable text alternative of the current value.
|
|
112
|
+
*/
|
|
113
|
+
'aria-valuetext'?: string;
|
|
114
|
+
}
|
|
115
|
+
export declare const Slider: React.ForwardRefExoticComponent<SliderProps & React.RefAttributes<HTMLInputElement>>;
|
|
116
|
+
export default Slider;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { jsxs as o, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import _ from "../../../../../external/classnames/index.es.js";
|
|
3
|
+
import { forwardRef as oe, useId as de, useState as m, useCallback as i, useRef as ce, useEffect as ue } from "react";
|
|
4
|
+
import { Tooltip as me } from "../../overlays/tooltip/tooltip.es.js";
|
|
5
|
+
import { TooltipContent as pe } from "../../overlays/tooltip/tooltip-content.es.js";
|
|
6
|
+
import { TooltipTrigger as fe } from "../../overlays/tooltip/tooltip-trigger.es.js";
|
|
7
|
+
import { FeedbackText as ve } from "../feedback-text/feedback-text.es.js";
|
|
8
|
+
import { FormLabel as ge } from "../form-label/form-label.es.js";
|
|
9
|
+
import e from "./slider.module.scss.es.js";
|
|
10
|
+
import { useBreakpointProps as he } from "../../../helpers/hooks/use-breakpoint-props.es.js";
|
|
11
|
+
const be = oe((N, S) => {
|
|
12
|
+
const { getCurrentBreakpointProps: D } = he(N.defaultServerBreakpoint), {
|
|
13
|
+
id: R,
|
|
14
|
+
name: $,
|
|
15
|
+
label: w,
|
|
16
|
+
hideLabel: j,
|
|
17
|
+
required: L,
|
|
18
|
+
min: t = 0,
|
|
19
|
+
max: d = 100,
|
|
20
|
+
step: H = 1,
|
|
21
|
+
value: p,
|
|
22
|
+
defaultValue: q,
|
|
23
|
+
onChange: c,
|
|
24
|
+
disabled: n = !1,
|
|
25
|
+
invalid: O = !1,
|
|
26
|
+
minLabel: f,
|
|
27
|
+
maxLabel: U,
|
|
28
|
+
showCurrentValue: v = !1,
|
|
29
|
+
valueFormatter: x,
|
|
30
|
+
tooltip: z = !0,
|
|
31
|
+
addonRight: I,
|
|
32
|
+
helper: a,
|
|
33
|
+
className: A,
|
|
34
|
+
"aria-label": G,
|
|
35
|
+
"aria-labelledby": J,
|
|
36
|
+
"aria-valuetext": K
|
|
37
|
+
} = D(N), Q = de(), g = R ?? `tedi-slider-${Q}`, k = a ? a.id ?? `${g}-helper` : void 0, [W, X] = m(q ?? t), u = Math.min(d, Math.max(t, p ?? W)), [Y, y] = m(!1), [Z, F] = m(!1), [l, T] = m(!1), V = !!z && !n, ee = V && (Y || Z || l), re = i(() => y(!0), []), ae = i(() => y(!1), []), ie = i(() => F(!0), []), te = i(() => F(!1), []), B = ce(null), s = i(() => {
|
|
38
|
+
B.current = null, T(!1);
|
|
39
|
+
}, []);
|
|
40
|
+
ue(() => {
|
|
41
|
+
if (l)
|
|
42
|
+
return window.addEventListener("pointerup", s), window.addEventListener("pointercancel", s), () => {
|
|
43
|
+
window.removeEventListener("pointerup", s), window.removeEventListener("pointercancel", s);
|
|
44
|
+
};
|
|
45
|
+
}, [l, s]);
|
|
46
|
+
const ne = i(
|
|
47
|
+
(b) => {
|
|
48
|
+
n || (B.current = b.pointerId, T(!0));
|
|
49
|
+
},
|
|
50
|
+
[n]
|
|
51
|
+
), le = i(
|
|
52
|
+
(b) => {
|
|
53
|
+
const P = Number(b.target.value);
|
|
54
|
+
p === void 0 && X(P), c == null || c(P);
|
|
55
|
+
},
|
|
56
|
+
[c, p]
|
|
57
|
+
), E = O || (a == null ? void 0 : a.type) === "error", M = d === t ? 0 : (u - t) / (d - t) * 100, C = x ? x(u) : u, h = v ? C : U, se = _(
|
|
58
|
+
e["tedi-slider"],
|
|
59
|
+
{
|
|
60
|
+
[e["tedi-slider--disabled"]]: n,
|
|
61
|
+
[e["tedi-slider--invalid"]]: E,
|
|
62
|
+
[e["tedi-slider--dragging"]]: l && !n
|
|
63
|
+
},
|
|
64
|
+
A
|
|
65
|
+
);
|
|
66
|
+
return /* @__PURE__ */ o("div", { "data-name": "slider", className: se, children: [
|
|
67
|
+
w && /* @__PURE__ */ r(ge, { id: g, label: w, required: L, hideLabel: j }),
|
|
68
|
+
/* @__PURE__ */ o("div", { className: e["tedi-slider__container"], children: [
|
|
69
|
+
/* @__PURE__ */ o("div", { className: e["tedi-slider__track-row"], children: [
|
|
70
|
+
f != null && /* @__PURE__ */ r("span", { className: e["tedi-slider__range-label"], "aria-hidden": "true", children: f }),
|
|
71
|
+
/* @__PURE__ */ o(
|
|
72
|
+
"div",
|
|
73
|
+
{
|
|
74
|
+
className: e["tedi-slider__track"],
|
|
75
|
+
style: {
|
|
76
|
+
"--tedi-slider-progress": `${M}%`,
|
|
77
|
+
"--tedi-slider-progress-ratio": `${M / 100}`
|
|
78
|
+
},
|
|
79
|
+
children: [
|
|
80
|
+
/* @__PURE__ */ r(
|
|
81
|
+
"input",
|
|
82
|
+
{
|
|
83
|
+
ref: S,
|
|
84
|
+
id: g,
|
|
85
|
+
name: $,
|
|
86
|
+
type: "range",
|
|
87
|
+
min: t,
|
|
88
|
+
max: d,
|
|
89
|
+
step: H,
|
|
90
|
+
value: u,
|
|
91
|
+
disabled: n,
|
|
92
|
+
required: L,
|
|
93
|
+
"aria-invalid": E ? "true" : void 0,
|
|
94
|
+
"aria-describedby": k,
|
|
95
|
+
"aria-label": G,
|
|
96
|
+
"aria-labelledby": J,
|
|
97
|
+
"aria-valuetext": K,
|
|
98
|
+
onChange: le,
|
|
99
|
+
onMouseEnter: re,
|
|
100
|
+
onMouseLeave: ae,
|
|
101
|
+
onPointerDown: ne,
|
|
102
|
+
onFocus: ie,
|
|
103
|
+
onBlur: te,
|
|
104
|
+
className: _(e["tedi-slider__input"], {
|
|
105
|
+
[e["tedi-slider__input--dragging"]]: l
|
|
106
|
+
})
|
|
107
|
+
}
|
|
108
|
+
),
|
|
109
|
+
V && /* @__PURE__ */ o(
|
|
110
|
+
me,
|
|
111
|
+
{
|
|
112
|
+
open: ee,
|
|
113
|
+
onToggle: () => {
|
|
114
|
+
},
|
|
115
|
+
focusManager: { returnFocus: !1, initialFocus: -1 },
|
|
116
|
+
placement: "top",
|
|
117
|
+
trackReferencePosition: !0,
|
|
118
|
+
children: [
|
|
119
|
+
/* @__PURE__ */ r(fe, { children: /* @__PURE__ */ r("span", { className: e["tedi-slider__thumb-anchor"], "aria-hidden": "true", tabIndex: -1 }) }),
|
|
120
|
+
/* @__PURE__ */ r(pe, { children: C })
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
)
|
|
124
|
+
]
|
|
125
|
+
}
|
|
126
|
+
),
|
|
127
|
+
h != null && /* @__PURE__ */ r(
|
|
128
|
+
"span",
|
|
129
|
+
{
|
|
130
|
+
className: e["tedi-slider__range-label"],
|
|
131
|
+
"aria-hidden": v ? void 0 : "true",
|
|
132
|
+
"aria-live": v ? "polite" : void 0,
|
|
133
|
+
children: h
|
|
134
|
+
}
|
|
135
|
+
)
|
|
136
|
+
] }),
|
|
137
|
+
I && /* @__PURE__ */ r("div", { className: e["tedi-slider__addon"], children: I })
|
|
138
|
+
] }),
|
|
139
|
+
a && /* @__PURE__ */ r(ve, { ...a, id: k, className: _(e["tedi-slider__feedback"], a.className) })
|
|
140
|
+
] });
|
|
141
|
+
});
|
|
142
|
+
be.displayName = "Slider";
|
|
143
|
+
export {
|
|
144
|
+
be as Slider
|
|
145
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e={"tedi-slider":"tedi-slider-90e24e7d","tedi-slider__container":"tedi-slider__container-525c4b64","tedi-slider__track-row":"tedi-slider__track-row-95e9c2d5","tedi-slider__range-label":"tedi-slider__range-label-a2a6a43b","tedi-slider__track":"tedi-slider__track-a7afc8d6","tedi-slider__thumb-anchor":"tedi-slider__thumb-anchor-7e282370","tedi-slider__input":"tedi-slider__input-b2d1c042","tedi-slider__input--dragging":"tedi-slider__input--dragging-6a2f5f85","tedi-slider__addon":"tedi-slider__addon-6b259d81","tedi-slider__feedback":"tedi-slider__feedback-dad1545e","tedi-slider--disabled":"tedi-slider--disabled-d1da914a","tedi-slider--dragging":"tedi-slider--dragging-c82f4f25","tedi-slider--invalid":"tedi-slider--invalid-e5adda94"};exports.default=e;
|