@dotss/ui 0.0.10 → 0.0.11
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/Accordion/Accordion.cjs +13 -7
- package/Accordion/Accordion.d.ts +2 -0
- package/Accordion/Accordion.es.js +86 -65
- package/Autocomplete/Autocomplete.cjs +1 -1
- package/Autocomplete/Autocomplete.d.ts +1 -1
- package/Autocomplete/Autocomplete.es.js +235 -80
- package/BottomSheet/BottomSheet.cjs +5 -5
- package/BottomSheet/BottomSheet.d.ts +3 -0
- package/BottomSheet/BottomSheet.es.js +88 -70
- package/BottomSheet/BottomSheetText/BottomSheetText.cjs +2 -2
- package/BottomSheet/BottomSheetText/BottomSheetText.es.js +18 -6
- package/BottomSheet/BottomSheetTitle/BottomSheetTitle.cjs +6 -6
- package/BottomSheet/BottomSheetTitle/BottomSheetTitle.d.ts +2 -1
- package/BottomSheet/BottomSheetTitle/BottomSheetTitle.es.js +26 -15
- package/Button/Button.cjs +6 -6
- package/Button/Button.es.js +35 -29
- package/ChainPicker/ChainPicker.cjs +16 -6
- package/ChainPicker/ChainPicker.d.ts +4 -2
- package/ChainPicker/ChainPicker.es.js +155 -110
- package/ChainPicker/ChainPicker.stories.d.ts +1 -1
- package/Checkbox/Checkbox.cjs +3 -3
- package/Checkbox/Checkbox.es.js +12 -10
- package/CircularProgressIndicator/CircularProgressIndicator.cjs +5 -5
- package/CircularProgressIndicator/CircularProgressIndicator.es.js +26 -23
- package/DatePicker/DatePicker.cjs +37 -20
- package/DatePicker/DatePicker.d.ts +2 -1
- package/DatePicker/DatePicker.es.js +345 -320
- package/DatePicker/DatePicker.stories.d.ts +1 -0
- package/DatePicker/EventDot/EventDot.cjs +8 -0
- package/DatePicker/EventDot/EventDot.d.ts +8 -0
- package/DatePicker/EventDot/EventDot.es.js +19 -0
- package/DatePicker/EventDot/index.cjs +1 -0
- package/DatePicker/EventDot/index.d.ts +3 -0
- package/DatePicker/EventDot/index.es.js +4 -0
- package/DatePicker/EventDotGroup/EventDotGroup.cjs +8 -0
- package/DatePicker/EventDotGroup/EventDotGroup.d.ts +8 -0
- package/DatePicker/EventDotGroup/EventDotGroup.es.js +39 -0
- package/DatePicker/EventDotGroup/index.cjs +1 -0
- package/DatePicker/EventDotGroup/index.d.ts +3 -0
- package/DatePicker/EventDotGroup/index.es.js +4 -0
- package/DatePicker/index.cjs +1 -1
- package/DatePicker/index.d.ts +2 -0
- package/DatePicker/index.es.js +6 -2
- package/Dialog/Dialog.cjs +2 -2
- package/Dialog/Dialog.d.ts +2 -0
- package/Dialog/Dialog.es.js +45 -40
- package/Dialog/Dialog.stories.d.ts +10 -0
- package/Dialog/DialogText/DialogText.cjs +1 -1
- package/Dialog/DialogText/DialogText.es.js +1 -1
- package/Dialog/DialogTitle/DialogTitle.cjs +4 -4
- package/Dialog/DialogTitle/DialogTitle.d.ts +2 -1
- package/Dialog/DialogTitle/DialogTitle.es.js +17 -17
- package/FocusBoundary/FocusBoundary.cjs +1 -1
- package/FocusBoundary/FocusBoundary.d.ts +3 -1
- package/FocusBoundary/FocusBoundary.es.js +49 -42
- package/FormControlText/FormControlText.cjs +7 -5
- package/FormControlText/FormControlText.d.ts +2 -0
- package/FormControlText/FormControlText.es.js +50 -40
- package/Icon/Icon.cjs +1 -1
- package/Icon/Icon.es.js +1 -1
- package/IconButton/IconButton.cjs +8 -8
- package/IconButton/IconButton.es.js +32 -25
- package/LineProgressIndicator/LineProgressIndicator.cjs +6 -6
- package/LineProgressIndicator/LineProgressIndicator.es.js +35 -23
- package/Menu/Menu.cjs +16 -16
- package/Menu/Menu.d.ts +3 -2
- package/Menu/Menu.es.js +115 -81
- package/Menu/Menu.stories.d.ts +1 -0
- package/Menu/MenuBlock/MenuBlock.cjs +14 -7
- package/Menu/MenuBlock/MenuBlock.d.ts +1 -0
- package/Menu/MenuBlock/MenuBlock.es.js +47 -35
- package/Menu/MenuButton/MenuButton.cjs +1 -0
- package/Menu/MenuButton/MenuButton.d.ts +10 -0
- package/Menu/MenuButton/MenuButton.es.js +44 -0
- package/Menu/MenuButton/index.cjs +1 -0
- package/Menu/MenuButton/index.d.ts +3 -0
- package/Menu/MenuButton/index.es.js +4 -0
- package/Menu/index.cjs +1 -1
- package/Menu/index.d.ts +1 -0
- package/Menu/index.es.js +4 -2
- package/NumberKeypad/NumberKeypad.cjs +2 -2
- package/NumberKeypad/NumberKeypad.es.js +18 -16
- package/NumberKeypad/NumberKeypadBlock/NumberKeypadBlock.cjs +1 -1
- package/NumberKeypad/NumberKeypadBlock/NumberKeypadBlock.es.js +10 -1
- package/PageControl/PageControl.cjs +16 -5
- package/PageControl/PageControl.d.ts +3 -0
- package/PageControl/PageControl.es.js +77 -24
- package/PageControl/PageControl.stories.d.ts +1 -0
- package/Radio/Radio.cjs +3 -3
- package/Radio/Radio.es.js +22 -20
- package/RadioGroup/RadioGroup.cjs +1 -0
- package/RadioGroup/RadioGroup.d.ts +8 -0
- package/RadioGroup/RadioGroup.es.js +28 -0
- package/RadioGroup/RadioGroup.stories.d.ts +14 -0
- package/RadioGroup/index.cjs +1 -0
- package/RadioGroup/index.d.ts +3 -0
- package/RadioGroup/index.es.js +4 -0
- package/SegmentedButton/SegmentedButton.cjs +14 -3
- package/SegmentedButton/SegmentedButton.es.js +108 -34
- package/Select/Select.cjs +4 -4
- package/Select/Select.es.js +95 -86
- package/Slider/Slider.cjs +27 -12
- package/Slider/Slider.d.ts +1 -0
- package/Slider/Slider.es.js +177 -90
- package/Switch/Switch.cjs +28 -11
- package/Switch/Switch.d.ts +2 -0
- package/Switch/Switch.es.js +185 -65
- package/Switch/Switch.stories.d.ts +1 -0
- package/Tab/Tab.es.js +2 -4
- package/TextArea/TextArea.cjs +42 -34
- package/TextArea/TextArea.es.js +116 -82
- package/TextArea/TextArea.stories.d.ts +1 -1
- package/TextField/TextField.cjs +29 -13
- package/TextField/TextField.d.ts +2 -1
- package/TextField/TextField.es.js +122 -79
- package/TextField/TextField.stories.d.ts +1 -0
- package/Tooltip/Tooltip.cjs +7 -6
- package/Tooltip/Tooltip.d.ts +8 -3
- package/Tooltip/Tooltip.es.js +248 -146
- package/Tooltip/Tooltip.stories.d.ts +1 -0
- package/hooks/index.cjs +1 -1
- package/hooks/index.d.ts +3 -0
- package/hooks/index.es.js +7 -1
- package/hooks/useCheckHasFocus/useCheckHasFocus.cjs +1 -0
- package/hooks/useCheckHasFocus/useCheckHasFocus.d.ts +9 -0
- package/hooks/useCheckHasFocus/useCheckHasFocus.es.js +21 -0
- package/hooks/useCheckKeyboardMode/useCheckKeyboardMode.cjs +1 -0
- package/hooks/useCheckKeyboardMode/useCheckKeyboardMode.d.ts +4 -0
- package/hooks/useCheckKeyboardMode/useCheckKeyboardMode.es.js +30 -0
- package/hooks/useFocusBoundary/useFocusBoundary.cjs +1 -0
- package/hooks/useFocusBoundary/useFocusBoundary.d.ts +12 -0
- package/hooks/useFocusBoundary/useFocusBoundary.es.js +63 -0
- package/index.cjs +1 -1
- package/index.d.ts +2 -1
- package/index.es.js +97 -90
- package/package.json +3 -3
- package/resources/tictoccroc/icons/fill/certified-fill.svg-B_RVx6K_.cjs +1 -0
- package/resources/tictoccroc/icons/fill/certified-fill.svg-CK7UqYft.js +5 -0
- package/resources/tictoccroc/icons/fill/index.d.ts +3 -0
- package/resources/tictoccroc/icons/fill/location-fill.svg-DfSHAnsd.js +5 -0
- package/resources/tictoccroc/icons/fill/location-fill.svg-Die9mxQH.cjs +1 -0
- package/resources/tictoccroc/icons/fill/send-fill.svg-CItD_2L1.js +5 -0
- package/resources/tictoccroc/icons/fill/send-fill.svg-D197Lwl0.cjs +1 -0
- package/resources/tictoccroc/icons/index.ts-BmqvB_n6.cjs +1 -0
- package/resources/tictoccroc/icons/index.ts-CzTh-XsD.js +228 -0
- package/resources/tictoccroc/icons/line/index.d.ts +4 -0
- package/resources/tictoccroc/icons/line/list-line.svg-r5d5htjN.cjs +1 -0
- package/resources/tictoccroc/icons/line/list-line.svg-yFfhZxUp.js +5 -0
- package/resources/tictoccroc/icons/line/monthly-line.svg-BdyaJ1t_.cjs +1 -0
- package/resources/tictoccroc/icons/line/monthly-line.svg-DY5-Xv34.js +5 -0
- package/resources/tictoccroc/icons/line/review-line.svg-B4rfJrsO.js +5 -0
- package/resources/tictoccroc/icons/line/review-line.svg-DYUuUybx.cjs +1 -0
- package/resources/tictoccroc/icons/line/weekly-line.svg-BCO-LS_a.cjs +1 -0
- package/resources/tictoccroc/icons/line/weekly-line.svg-BUPmmgeE.js +5 -0
- package/utils/getIconLabel/getIconLabel.cjs +1 -1
- package/utils/getIconLabel/getIconLabel.es.js +8 -1
- package/utils/getSibling/getSibling.es.js +1 -2
- package/resources/tictoccroc/icons/index.ts-CarI_z7q.js +0 -214
- package/resources/tictoccroc/icons/index.ts-IVJAK4qr.cjs +0 -1
package/Slider/Slider.es.js
CHANGED
|
@@ -1,155 +1,242 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
1
|
+
import { jsxs as I, jsx as k } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { forwardRef as z, useRef as b, useState as B, useEffect as G } from "react";
|
|
3
|
+
import _ from "../Flexbox/Flexbox.es.js";
|
|
4
|
+
import u from "@emotion/styled";
|
|
5
|
+
import J from "../hooks/useCheckKeyboardMode/useCheckKeyboardMode.es.js";
|
|
6
|
+
import Q from "../hooks/useCheckHasFocus/useCheckHasFocus.es.js";
|
|
7
|
+
const Y = u.div`
|
|
6
8
|
display: flex;
|
|
7
9
|
align-items: center;
|
|
8
10
|
position: relative;
|
|
9
11
|
width: 100%;
|
|
10
12
|
height: 12px;
|
|
11
|
-
margin: ${({ theme: { spacing:
|
|
13
|
+
margin: ${({ theme: { spacing: i } }) => `${i.content(2)}px 0px`};
|
|
12
14
|
cursor: pointer;
|
|
13
15
|
border-radius: 20px;
|
|
14
|
-
|
|
16
|
+
|
|
17
|
+
@supports selector(:has(:focus-visible)) {
|
|
18
|
+
&:has(:focus-visible) {
|
|
19
|
+
outline: ${({ theme: i }) => i.palette.grey[100]} solid 2px;
|
|
20
|
+
outline-offset: 2px;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@supports not selector(:has(:focus-visible)) {
|
|
25
|
+
${({ focusWithin: i, theme: n }) => i ? {
|
|
26
|
+
outline: `${n.palette.grey[100]} solid 2px`,
|
|
27
|
+
outlineOffset: 2
|
|
28
|
+
} : {}}
|
|
29
|
+
}
|
|
30
|
+
`, Z = u.div`
|
|
15
31
|
position: absolute;
|
|
16
32
|
width: 100%;
|
|
17
33
|
height: 100%;
|
|
18
|
-
background: ${({ theme: { palette:
|
|
34
|
+
background: ${({ theme: { palette: i } }) => i.grey[10]};
|
|
19
35
|
border-radius: inherit;
|
|
20
|
-
`,
|
|
36
|
+
`, V = u.div`
|
|
21
37
|
position: absolute;
|
|
22
38
|
height: 100%;
|
|
23
|
-
background: ${({ theme: { palette:
|
|
39
|
+
background: ${({ theme: { palette: i } }) => i.brand.primary.main};
|
|
24
40
|
border-radius: inherit;
|
|
25
|
-
`,
|
|
41
|
+
`, P = u.div`
|
|
26
42
|
position: absolute;
|
|
27
43
|
display: flex;
|
|
28
44
|
width: 24px;
|
|
29
45
|
height: 24px;
|
|
30
46
|
justify-content: space-between;
|
|
31
47
|
align-items: center;
|
|
32
|
-
padding: ${({ theme: { spacing:
|
|
33
|
-
background: ${({ theme: { palette:
|
|
48
|
+
padding: ${({ theme: { spacing: i } }) => `${i.content(2)}px ${i.content(3)}px`};
|
|
49
|
+
background: ${({ theme: { palette: i } }) => i.grey[90]};
|
|
34
50
|
transform: translateX(-50%);
|
|
35
51
|
border-radius: 50%;
|
|
36
|
-
|
|
52
|
+
|
|
53
|
+
&:focus {
|
|
54
|
+
outline-offset: 2px;
|
|
55
|
+
}
|
|
56
|
+
`, ee = u.div`
|
|
37
57
|
position: absolute;
|
|
38
58
|
width: 4px;
|
|
39
59
|
height: 4px;
|
|
40
60
|
transform: translateX(-50%);
|
|
41
61
|
border-radius: 50%;
|
|
42
62
|
|
|
43
|
-
${({ theme: { palette:
|
|
63
|
+
${({ theme: { palette: i }, marked: n, disabled: c, hasMarks: o }) => c || !o ? {
|
|
44
64
|
background: "transparent",
|
|
45
65
|
opacity: 0
|
|
46
|
-
} :
|
|
47
|
-
background:
|
|
66
|
+
} : n ? {
|
|
67
|
+
background: i.grey.white
|
|
48
68
|
} : {
|
|
49
|
-
background:
|
|
69
|
+
background: i.grey[30]
|
|
50
70
|
}}
|
|
51
|
-
`,
|
|
52
|
-
value:
|
|
71
|
+
`, X = 10, ce = z(function({
|
|
72
|
+
value: n,
|
|
53
73
|
onChange: c,
|
|
54
|
-
step:
|
|
74
|
+
step: o = 1,
|
|
55
75
|
min: s = 0,
|
|
56
|
-
max:
|
|
57
|
-
hasMarks:
|
|
58
|
-
disabledValues:
|
|
76
|
+
max: l = 100,
|
|
77
|
+
hasMarks: C = !0,
|
|
78
|
+
disabledValues: a = [],
|
|
79
|
+
readValue: w,
|
|
59
80
|
railProps: d,
|
|
60
|
-
trackProps:
|
|
61
|
-
thumbProps:
|
|
62
|
-
inlineCSS:
|
|
63
|
-
...
|
|
64
|
-
},
|
|
65
|
-
const
|
|
66
|
-
if (
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
),
|
|
70
|
-
return
|
|
81
|
+
trackProps: h,
|
|
82
|
+
thumbProps: y,
|
|
83
|
+
inlineCSS: L,
|
|
84
|
+
...v
|
|
85
|
+
}, M) {
|
|
86
|
+
const m = b(null), { isKeyboardMode: E } = J(), { hasFocus: K } = Q({ ref: M || m }), f = b(null), S = b(null), j = b(null), [F, $] = B(!1), p = 100 / ((l - s) / o), x = (t) => {
|
|
87
|
+
if (f.current) {
|
|
88
|
+
const e = t - f.current.getBoundingClientRect().left, r = Array.from(
|
|
89
|
+
f.current.querySelectorAll('[class^="slider-mark-"]:not([disabled])')
|
|
90
|
+
), R = r.reduce((N, T) => Math.abs(T.offsetLeft - e) < Math.abs(N.offsetLeft - e) ? T : N, r[0]).getAttribute("data-value");
|
|
91
|
+
return R !== null ? Number(R) : null;
|
|
71
92
|
}
|
|
72
93
|
return null;
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (
|
|
94
|
+
}, U = (t) => {
|
|
95
|
+
let e = n;
|
|
96
|
+
if (t.key === "ArrowRight" || t.key === "ArrowUp") {
|
|
97
|
+
if (n === l) return;
|
|
98
|
+
e = n + o;
|
|
99
|
+
} else if (t.key === "ArrowLeft" || t.key === "ArrowDown") {
|
|
100
|
+
if (n === s) return;
|
|
101
|
+
e = n - o;
|
|
102
|
+
} else if (t.key === "PageUp") {
|
|
103
|
+
if (n === l) return;
|
|
104
|
+
e = Math.min(n + o * 5, l);
|
|
105
|
+
} else if (t.key === "PageDown") {
|
|
106
|
+
if (n === s) return;
|
|
107
|
+
e = Math.max(n - o * 5, s);
|
|
108
|
+
} else if (t.key === "Home") {
|
|
109
|
+
for (let r = s; r <= l; r += o)
|
|
110
|
+
if (!a.includes(r)) {
|
|
111
|
+
e = r;
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
} else if (t.key === "End") {
|
|
115
|
+
for (let r = l; r >= s; r -= o)
|
|
116
|
+
if (!a.includes(r)) {
|
|
117
|
+
e = r;
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (a.includes(e)) {
|
|
122
|
+
if (e > n) {
|
|
123
|
+
for (let r = e; r <= l; r += o)
|
|
124
|
+
if (!a.includes(r)) {
|
|
125
|
+
c(r);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
} else if (e < n) {
|
|
129
|
+
for (let r = e; r >= s; r -= o)
|
|
130
|
+
if (!a.includes(r)) {
|
|
131
|
+
c(r);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
79
135
|
return;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
},
|
|
136
|
+
}
|
|
137
|
+
c(e);
|
|
138
|
+
}, D = (t) => {
|
|
139
|
+
$(!0);
|
|
140
|
+
const e = x(t);
|
|
141
|
+
e !== null && c(e);
|
|
142
|
+
}, A = (t) => {
|
|
143
|
+
if (!F) return;
|
|
144
|
+
const e = x(t);
|
|
145
|
+
e !== null && c(e);
|
|
146
|
+
}, g = () => $(!1), q = (t) => D(t.clientX), H = (t) => D(t.touches[0].clientX), O = (t) => A(t.clientX), W = (t) => A(t.touches[0].clientX);
|
|
83
147
|
return G(() => {
|
|
84
|
-
if (
|
|
85
|
-
const
|
|
86
|
-
`[data-value="${
|
|
148
|
+
if (f.current) {
|
|
149
|
+
const t = f.current.querySelector(
|
|
150
|
+
`[data-value="${n}"]`
|
|
87
151
|
);
|
|
88
|
-
if (
|
|
89
|
-
const { offsetLeft:
|
|
90
|
-
|
|
152
|
+
if (S.current && t) {
|
|
153
|
+
const { offsetLeft: e, offsetWidth: r } = t;
|
|
154
|
+
S.current.style.width = `${e + r + X * 2}px`;
|
|
91
155
|
}
|
|
92
156
|
}
|
|
93
|
-
}, [
|
|
94
|
-
|
|
157
|
+
}, [n, s, l, o]), /* @__PURE__ */ I(
|
|
158
|
+
Y,
|
|
95
159
|
{
|
|
96
|
-
ref:
|
|
97
|
-
...
|
|
160
|
+
ref: M || m,
|
|
161
|
+
...v,
|
|
98
162
|
className: "slider",
|
|
99
|
-
onMouseDown:
|
|
100
|
-
onMouseMove:
|
|
101
|
-
onMouseUp:
|
|
102
|
-
onMouseLeave:
|
|
103
|
-
onTouchStart:
|
|
104
|
-
onTouchMove:
|
|
105
|
-
onTouchEnd:
|
|
106
|
-
onTouchCancel:
|
|
107
|
-
css:
|
|
163
|
+
onMouseDown: q,
|
|
164
|
+
onMouseMove: O,
|
|
165
|
+
onMouseUp: g,
|
|
166
|
+
onMouseLeave: g,
|
|
167
|
+
onTouchStart: H,
|
|
168
|
+
onTouchMove: W,
|
|
169
|
+
onTouchEnd: g,
|
|
170
|
+
onTouchCancel: g,
|
|
171
|
+
css: L,
|
|
172
|
+
focusWithin: E && K,
|
|
108
173
|
children: [
|
|
109
|
-
/* @__PURE__ */
|
|
110
|
-
|
|
111
|
-
_,
|
|
174
|
+
/* @__PURE__ */ k(
|
|
175
|
+
Z,
|
|
112
176
|
{
|
|
113
|
-
ref:
|
|
114
|
-
...
|
|
115
|
-
css:
|
|
116
|
-
className: "slider-
|
|
177
|
+
ref: j,
|
|
178
|
+
...d,
|
|
179
|
+
css: d == null ? void 0 : d.inlineCSS,
|
|
180
|
+
className: "slider-rail",
|
|
181
|
+
tabIndex: -1,
|
|
182
|
+
"aria-hidden": !0
|
|
117
183
|
}
|
|
118
184
|
),
|
|
119
|
-
/* @__PURE__ */
|
|
120
|
-
|
|
185
|
+
/* @__PURE__ */ k(
|
|
186
|
+
V,
|
|
187
|
+
{
|
|
188
|
+
ref: S,
|
|
189
|
+
...h,
|
|
190
|
+
css: h == null ? void 0 : h.inlineCSS,
|
|
191
|
+
className: "slider-track",
|
|
192
|
+
tabIndex: -1,
|
|
193
|
+
"aria-hidden": !0
|
|
194
|
+
}
|
|
195
|
+
),
|
|
196
|
+
/* @__PURE__ */ I(
|
|
197
|
+
_,
|
|
121
198
|
{
|
|
122
199
|
className: "slider-mark-wrapper",
|
|
123
200
|
alignItems: "center",
|
|
124
|
-
ref:
|
|
201
|
+
ref: f,
|
|
202
|
+
tabIndex: -1,
|
|
125
203
|
inlineCSS: {
|
|
126
|
-
margin: `0 ${
|
|
204
|
+
margin: `0 ${X + 2}px`,
|
|
127
205
|
width: "100%",
|
|
128
206
|
height: "24px",
|
|
129
207
|
position: "relative"
|
|
130
208
|
},
|
|
131
209
|
children: [
|
|
132
|
-
|
|
133
|
-
|
|
210
|
+
l > 0 && s < l && o > 0 && Array.from({ length: (l - s) / o + 1 }, (t, e) => /* @__PURE__ */ k(
|
|
211
|
+
ee,
|
|
134
212
|
{
|
|
135
|
-
className: `slider-mark-${
|
|
136
|
-
marked:
|
|
137
|
-
hasMarks:
|
|
138
|
-
disabled:
|
|
139
|
-
"data-value": s +
|
|
213
|
+
className: `slider-mark-${e} slider-mark`,
|
|
214
|
+
marked: e <= (n - s) / o,
|
|
215
|
+
hasMarks: C,
|
|
216
|
+
disabled: a.includes(s + o * e),
|
|
217
|
+
"data-value": s + o * e,
|
|
140
218
|
style: {
|
|
141
|
-
left: `${
|
|
142
|
-
}
|
|
219
|
+
left: `${p * e}%`
|
|
220
|
+
},
|
|
221
|
+
"aria-hidden": !0
|
|
143
222
|
},
|
|
144
|
-
`slider-mark-${
|
|
223
|
+
`slider-mark-${n}:${s + o * e}`
|
|
145
224
|
)),
|
|
146
|
-
/* @__PURE__ */
|
|
147
|
-
|
|
225
|
+
/* @__PURE__ */ k(
|
|
226
|
+
P,
|
|
148
227
|
{
|
|
149
|
-
...
|
|
228
|
+
...y,
|
|
150
229
|
className: "slider-thumb",
|
|
151
|
-
css:
|
|
152
|
-
|
|
230
|
+
css: y == null ? void 0 : y.inlineCSS,
|
|
231
|
+
onKeyDown: U,
|
|
232
|
+
role: "slider",
|
|
233
|
+
"aria-orientation": "horizontal",
|
|
234
|
+
tabIndex: 0,
|
|
235
|
+
"aria-valuemin": s,
|
|
236
|
+
"aria-valuemax": l,
|
|
237
|
+
"aria-valuenow": n,
|
|
238
|
+
"aria-valuetext": w && typeof w == "function" ? w(n) : n.toString(),
|
|
239
|
+
style: { left: `${p * (n - s) / o}%` }
|
|
153
240
|
}
|
|
154
241
|
)
|
|
155
242
|
]
|
|
@@ -160,5 +247,5 @@ const U = i.div`
|
|
|
160
247
|
);
|
|
161
248
|
});
|
|
162
249
|
export {
|
|
163
|
-
|
|
250
|
+
ce as default
|
|
164
251
|
};
|
package/Switch/Switch.cjs
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("@emotion/react/jsx-runtime"),c=require("react"),X=require("@emotion/styled"),q=require("../core/useTheme.cjs"),H=t=>t&&t.__esModule?t:{default:t},s=H(X),L=s.default.div`
|
|
2
2
|
position: relative;
|
|
3
3
|
display: flex;
|
|
4
|
-
width: 56px;
|
|
4
|
+
min-width: 56px;
|
|
5
5
|
height: 32px;
|
|
6
|
-
padding: ${({theme:{spacing:
|
|
6
|
+
padding: ${({theme:{spacing:t}})=>`${t.content(1)}px`};
|
|
7
7
|
align-items: center;
|
|
8
8
|
border-radius: 20px;
|
|
9
|
-
transition: ${({transitionDuration:
|
|
10
|
-
pointer-events: ${({disabled:
|
|
9
|
+
transition: ${({transitionDuration:t})=>`background-color ${t}ms ease-in-out`};
|
|
10
|
+
pointer-events: ${({disabled:t})=>t?"none":"auto"};
|
|
11
11
|
|
|
12
|
-
${({theme:{palette:{brand:
|
|
13
|
-
`,
|
|
12
|
+
${({theme:{palette:{brand:t,grey:r}},selected:n,disabled:e})=>n&&e?{backgroundColor:t.primary.bg}:n&&!e?{backgroundColor:t.primary.main}:!n&&e?{backgroundColor:r[20]}:!n&&!e?{backgroundColor:r[40]}:{}}
|
|
13
|
+
`,E=s.default.div`
|
|
14
|
+
position: absolute;
|
|
15
|
+
right: ${({withLabel:t})=>t?"24px":"auto"};
|
|
14
16
|
width: 24px;
|
|
15
17
|
height: 24px;
|
|
16
18
|
border-radius: 50%;
|
|
17
|
-
transition: ${({transitionDuration:
|
|
19
|
+
transition: ${({transitionDuration:t})=>`all ${t}ms ease-in-out`};
|
|
18
20
|
transition-property: background-color, transform, filter;
|
|
19
21
|
|
|
20
|
-
${({theme:{palette:{grey:
|
|
21
|
-
`,
|
|
22
|
+
${({theme:{palette:{grey:t,background:r},spacing:n},selected:e,disabled:o,labelWidth:h,withLabel:f})=>{if(f){if(e&&o)return{backgroundColor:t.white,transform:`translateX(calc(100% - ${n.content(1)}px))`};if(e&&!o)return{backgroundColor:t.white,filter:"drop-shadow(0px 0px 16px rgba(69, 55, 55, 0.2))",transform:`translateX(calc(100% - ${n.content(1)}px))`};if(!e&&o)return{backgroundColor:r.primary,transform:`translateX(calc(100% - ${h+n.content(1)}px))`};if(!e&&!o)return{backgroundColor:t.white,filter:"drop-shadow(0px 0px 16px rgba(0, 0, 0, 0.20))",transform:`translateX(calc(100% - ${h+n.content(1)}px))`}}else{if(e&&o)return{backgroundColor:t.white,transform:"translateX(100%)"};if(e&&!o)return{backgroundColor:t.white,filter:"drop-shadow(0px 0px 16px rgba(69, 55, 55, 0.2))",transform:"translateX(100%)"};if(!e&&o)return{backgroundColor:r.primary};if(!e&&!o)return{backgroundColor:t.white,filter:"drop-shadow(0px 0px 16px rgba(0, 0, 0, 0.20))"}}return{}}}
|
|
23
|
+
`,T=s.default.input`
|
|
22
24
|
position: absolute;
|
|
23
25
|
appearance: none;
|
|
24
26
|
width: 100%;
|
|
@@ -27,4 +29,19 @@
|
|
|
27
29
|
left: 0;
|
|
28
30
|
border-radius: 20px;
|
|
29
31
|
cursor: pointer;
|
|
30
|
-
`,
|
|
32
|
+
`,v=s.default.div`
|
|
33
|
+
position: absolute;
|
|
34
|
+
opacity: ${({selected:t})=>t?1:0};
|
|
35
|
+
pointer-events: none;
|
|
36
|
+
transition: opacity 0.2s;
|
|
37
|
+
|
|
38
|
+
${({theme:{spacing:t},variant:r})=>{switch(r){case"unselected":return{right:t.content(2)};case"selected":return{left:t.content(2)};default:return{}}}}
|
|
39
|
+
|
|
40
|
+
${({theme:{typography:t,palette:{grey:r}}})=>({fontSize:t.c2M.size,fontWeight:t.c2M.weight,lineHeight:t.c2M.lineHeight,color:r.white})}
|
|
41
|
+
`,S=s.default.div`
|
|
42
|
+
${({theme:{spacing:t},variant:r})=>{switch(r){case"unselected":return{marginRight:`${t.content(8)}px`};case"selected":return{marginRight:`${t.content(8)}px`};default:return{}}}}
|
|
43
|
+
|
|
44
|
+
visibility: hidden;
|
|
45
|
+
|
|
46
|
+
${({theme:{typography:t,palette:{grey:r}}})=>({fontSize:t.c2M.size,fontWeight:t.c2M.weight,lineHeight:t.c2M.lineHeight,color:r.white})}
|
|
47
|
+
`,y=c.forwardRef(function({selected:r,disabled:n,onChange:e,transitionDuration:o=150,inputProps:h,thumbProps:f,inlineCSS:C,selectedLabel:a,unselectedLabel:u,...R},W){const{spacing:l}=q.default(),[p,j]=c.useState(0),[x,M]=c.useState(0),w=c.useRef(null),m=c.useRef(null),z=!!a||!!u,_=r?x||p:p||x;return c.useEffect(()=>{const d=()=>{var b,k;const g=((b=m.current)==null?void 0:b.offsetWidth)??0,$=((k=w.current)==null?void 0:k.offsetWidth)??0;g>0&&M(g+l.content(2)),$>0&&j($+l.content(2))};return d(),window.addEventListener("resize",d),()=>{window.removeEventListener("resize",d)}},[l,u,a,r]),i.jsxs(L,{ref:W,selected:r,disabled:n,transitionDuration:o,css:C,...R,children:[i.jsx(E,{selected:r,disabled:n,labelWidth:_,withLabel:z,transitionDuration:o,...f}),i.jsx(T,{type:"checkbox",role:"switch",checked:r,disabled:n,onChange:e,...h}),u&&!r&&i.jsx(S,{ref:w,variant:"unselected","aria-hidden":!0,children:u}),a&&r&&i.jsx(S,{ref:m,variant:"selected","aria-hidden":!0,children:a}),u&&i.jsx(v,{variant:"unselected",selected:!r,"aria-hidden":r,children:u}),a&&i.jsx(v,{variant:"selected",selected:r,"aria-hidden":!r,children:a})]})});exports.default=y;
|
package/Switch/Switch.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export interface SwitchProps extends GeneralComponentProps<HTMLAttributes<HTMLDi
|
|
|
8
8
|
transitionDuration?: number;
|
|
9
9
|
inputProps?: HTMLAttributes<HTMLInputElement>;
|
|
10
10
|
thumbProps?: HTMLAttributes<HTMLDivElement>;
|
|
11
|
+
selectedLabel?: string;
|
|
12
|
+
unselectedLabel?: string;
|
|
11
13
|
}
|
|
12
14
|
declare const Switch: import('react').ForwardRefExoticComponent<SwitchProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
13
15
|
export default Switch;
|