@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.
Files changed (159) hide show
  1. package/Accordion/Accordion.cjs +13 -7
  2. package/Accordion/Accordion.d.ts +2 -0
  3. package/Accordion/Accordion.es.js +86 -65
  4. package/Autocomplete/Autocomplete.cjs +1 -1
  5. package/Autocomplete/Autocomplete.d.ts +1 -1
  6. package/Autocomplete/Autocomplete.es.js +235 -80
  7. package/BottomSheet/BottomSheet.cjs +5 -5
  8. package/BottomSheet/BottomSheet.d.ts +3 -0
  9. package/BottomSheet/BottomSheet.es.js +88 -70
  10. package/BottomSheet/BottomSheetText/BottomSheetText.cjs +2 -2
  11. package/BottomSheet/BottomSheetText/BottomSheetText.es.js +18 -6
  12. package/BottomSheet/BottomSheetTitle/BottomSheetTitle.cjs +6 -6
  13. package/BottomSheet/BottomSheetTitle/BottomSheetTitle.d.ts +2 -1
  14. package/BottomSheet/BottomSheetTitle/BottomSheetTitle.es.js +26 -15
  15. package/Button/Button.cjs +6 -6
  16. package/Button/Button.es.js +35 -29
  17. package/ChainPicker/ChainPicker.cjs +16 -6
  18. package/ChainPicker/ChainPicker.d.ts +4 -2
  19. package/ChainPicker/ChainPicker.es.js +155 -110
  20. package/ChainPicker/ChainPicker.stories.d.ts +1 -1
  21. package/Checkbox/Checkbox.cjs +3 -3
  22. package/Checkbox/Checkbox.es.js +12 -10
  23. package/CircularProgressIndicator/CircularProgressIndicator.cjs +5 -5
  24. package/CircularProgressIndicator/CircularProgressIndicator.es.js +26 -23
  25. package/DatePicker/DatePicker.cjs +37 -20
  26. package/DatePicker/DatePicker.d.ts +2 -1
  27. package/DatePicker/DatePicker.es.js +345 -320
  28. package/DatePicker/DatePicker.stories.d.ts +1 -0
  29. package/DatePicker/EventDot/EventDot.cjs +8 -0
  30. package/DatePicker/EventDot/EventDot.d.ts +8 -0
  31. package/DatePicker/EventDot/EventDot.es.js +19 -0
  32. package/DatePicker/EventDot/index.cjs +1 -0
  33. package/DatePicker/EventDot/index.d.ts +3 -0
  34. package/DatePicker/EventDot/index.es.js +4 -0
  35. package/DatePicker/EventDotGroup/EventDotGroup.cjs +8 -0
  36. package/DatePicker/EventDotGroup/EventDotGroup.d.ts +8 -0
  37. package/DatePicker/EventDotGroup/EventDotGroup.es.js +39 -0
  38. package/DatePicker/EventDotGroup/index.cjs +1 -0
  39. package/DatePicker/EventDotGroup/index.d.ts +3 -0
  40. package/DatePicker/EventDotGroup/index.es.js +4 -0
  41. package/DatePicker/index.cjs +1 -1
  42. package/DatePicker/index.d.ts +2 -0
  43. package/DatePicker/index.es.js +6 -2
  44. package/Dialog/Dialog.cjs +2 -2
  45. package/Dialog/Dialog.d.ts +2 -0
  46. package/Dialog/Dialog.es.js +45 -40
  47. package/Dialog/Dialog.stories.d.ts +10 -0
  48. package/Dialog/DialogText/DialogText.cjs +1 -1
  49. package/Dialog/DialogText/DialogText.es.js +1 -1
  50. package/Dialog/DialogTitle/DialogTitle.cjs +4 -4
  51. package/Dialog/DialogTitle/DialogTitle.d.ts +2 -1
  52. package/Dialog/DialogTitle/DialogTitle.es.js +17 -17
  53. package/FocusBoundary/FocusBoundary.cjs +1 -1
  54. package/FocusBoundary/FocusBoundary.d.ts +3 -1
  55. package/FocusBoundary/FocusBoundary.es.js +49 -42
  56. package/FormControlText/FormControlText.cjs +7 -5
  57. package/FormControlText/FormControlText.d.ts +2 -0
  58. package/FormControlText/FormControlText.es.js +50 -40
  59. package/Icon/Icon.cjs +1 -1
  60. package/Icon/Icon.es.js +1 -1
  61. package/IconButton/IconButton.cjs +8 -8
  62. package/IconButton/IconButton.es.js +32 -25
  63. package/LineProgressIndicator/LineProgressIndicator.cjs +6 -6
  64. package/LineProgressIndicator/LineProgressIndicator.es.js +35 -23
  65. package/Menu/Menu.cjs +16 -16
  66. package/Menu/Menu.d.ts +3 -2
  67. package/Menu/Menu.es.js +115 -81
  68. package/Menu/Menu.stories.d.ts +1 -0
  69. package/Menu/MenuBlock/MenuBlock.cjs +14 -7
  70. package/Menu/MenuBlock/MenuBlock.d.ts +1 -0
  71. package/Menu/MenuBlock/MenuBlock.es.js +47 -35
  72. package/Menu/MenuButton/MenuButton.cjs +1 -0
  73. package/Menu/MenuButton/MenuButton.d.ts +10 -0
  74. package/Menu/MenuButton/MenuButton.es.js +44 -0
  75. package/Menu/MenuButton/index.cjs +1 -0
  76. package/Menu/MenuButton/index.d.ts +3 -0
  77. package/Menu/MenuButton/index.es.js +4 -0
  78. package/Menu/index.cjs +1 -1
  79. package/Menu/index.d.ts +1 -0
  80. package/Menu/index.es.js +4 -2
  81. package/NumberKeypad/NumberKeypad.cjs +2 -2
  82. package/NumberKeypad/NumberKeypad.es.js +18 -16
  83. package/NumberKeypad/NumberKeypadBlock/NumberKeypadBlock.cjs +1 -1
  84. package/NumberKeypad/NumberKeypadBlock/NumberKeypadBlock.es.js +10 -1
  85. package/PageControl/PageControl.cjs +16 -5
  86. package/PageControl/PageControl.d.ts +3 -0
  87. package/PageControl/PageControl.es.js +77 -24
  88. package/PageControl/PageControl.stories.d.ts +1 -0
  89. package/Radio/Radio.cjs +3 -3
  90. package/Radio/Radio.es.js +22 -20
  91. package/RadioGroup/RadioGroup.cjs +1 -0
  92. package/RadioGroup/RadioGroup.d.ts +8 -0
  93. package/RadioGroup/RadioGroup.es.js +28 -0
  94. package/RadioGroup/RadioGroup.stories.d.ts +14 -0
  95. package/RadioGroup/index.cjs +1 -0
  96. package/RadioGroup/index.d.ts +3 -0
  97. package/RadioGroup/index.es.js +4 -0
  98. package/SegmentedButton/SegmentedButton.cjs +14 -3
  99. package/SegmentedButton/SegmentedButton.es.js +108 -34
  100. package/Select/Select.cjs +4 -4
  101. package/Select/Select.es.js +95 -86
  102. package/Slider/Slider.cjs +27 -12
  103. package/Slider/Slider.d.ts +1 -0
  104. package/Slider/Slider.es.js +177 -90
  105. package/Switch/Switch.cjs +28 -11
  106. package/Switch/Switch.d.ts +2 -0
  107. package/Switch/Switch.es.js +185 -65
  108. package/Switch/Switch.stories.d.ts +1 -0
  109. package/Tab/Tab.es.js +2 -4
  110. package/TextArea/TextArea.cjs +42 -34
  111. package/TextArea/TextArea.es.js +116 -82
  112. package/TextArea/TextArea.stories.d.ts +1 -1
  113. package/TextField/TextField.cjs +29 -13
  114. package/TextField/TextField.d.ts +2 -1
  115. package/TextField/TextField.es.js +122 -79
  116. package/TextField/TextField.stories.d.ts +1 -0
  117. package/Tooltip/Tooltip.cjs +7 -6
  118. package/Tooltip/Tooltip.d.ts +8 -3
  119. package/Tooltip/Tooltip.es.js +248 -146
  120. package/Tooltip/Tooltip.stories.d.ts +1 -0
  121. package/hooks/index.cjs +1 -1
  122. package/hooks/index.d.ts +3 -0
  123. package/hooks/index.es.js +7 -1
  124. package/hooks/useCheckHasFocus/useCheckHasFocus.cjs +1 -0
  125. package/hooks/useCheckHasFocus/useCheckHasFocus.d.ts +9 -0
  126. package/hooks/useCheckHasFocus/useCheckHasFocus.es.js +21 -0
  127. package/hooks/useCheckKeyboardMode/useCheckKeyboardMode.cjs +1 -0
  128. package/hooks/useCheckKeyboardMode/useCheckKeyboardMode.d.ts +4 -0
  129. package/hooks/useCheckKeyboardMode/useCheckKeyboardMode.es.js +30 -0
  130. package/hooks/useFocusBoundary/useFocusBoundary.cjs +1 -0
  131. package/hooks/useFocusBoundary/useFocusBoundary.d.ts +12 -0
  132. package/hooks/useFocusBoundary/useFocusBoundary.es.js +63 -0
  133. package/index.cjs +1 -1
  134. package/index.d.ts +2 -1
  135. package/index.es.js +97 -90
  136. package/package.json +3 -3
  137. package/resources/tictoccroc/icons/fill/certified-fill.svg-B_RVx6K_.cjs +1 -0
  138. package/resources/tictoccroc/icons/fill/certified-fill.svg-CK7UqYft.js +5 -0
  139. package/resources/tictoccroc/icons/fill/index.d.ts +3 -0
  140. package/resources/tictoccroc/icons/fill/location-fill.svg-DfSHAnsd.js +5 -0
  141. package/resources/tictoccroc/icons/fill/location-fill.svg-Die9mxQH.cjs +1 -0
  142. package/resources/tictoccroc/icons/fill/send-fill.svg-CItD_2L1.js +5 -0
  143. package/resources/tictoccroc/icons/fill/send-fill.svg-D197Lwl0.cjs +1 -0
  144. package/resources/tictoccroc/icons/index.ts-BmqvB_n6.cjs +1 -0
  145. package/resources/tictoccroc/icons/index.ts-CzTh-XsD.js +228 -0
  146. package/resources/tictoccroc/icons/line/index.d.ts +4 -0
  147. package/resources/tictoccroc/icons/line/list-line.svg-r5d5htjN.cjs +1 -0
  148. package/resources/tictoccroc/icons/line/list-line.svg-yFfhZxUp.js +5 -0
  149. package/resources/tictoccroc/icons/line/monthly-line.svg-BdyaJ1t_.cjs +1 -0
  150. package/resources/tictoccroc/icons/line/monthly-line.svg-DY5-Xv34.js +5 -0
  151. package/resources/tictoccroc/icons/line/review-line.svg-B4rfJrsO.js +5 -0
  152. package/resources/tictoccroc/icons/line/review-line.svg-DYUuUybx.cjs +1 -0
  153. package/resources/tictoccroc/icons/line/weekly-line.svg-BCO-LS_a.cjs +1 -0
  154. package/resources/tictoccroc/icons/line/weekly-line.svg-BUPmmgeE.js +5 -0
  155. package/utils/getIconLabel/getIconLabel.cjs +1 -1
  156. package/utils/getIconLabel/getIconLabel.es.js +8 -1
  157. package/utils/getSibling/getSibling.es.js +1 -2
  158. package/resources/tictoccroc/icons/index.ts-CarI_z7q.js +0 -214
  159. package/resources/tictoccroc/icons/index.ts-IVJAK4qr.cjs +0 -1
@@ -1,155 +1,242 @@
1
- import { jsxs as N, jsx as m } from "@emotion/react/jsx-runtime";
2
- import { forwardRef as B, useRef as S, useState as F, useEffect as G } from "react";
3
- import O from "../Flexbox/Flexbox.es.js";
4
- import i from "@emotion/styled";
5
- const U = i.div`
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: n } }) => `${n.content(2)}px 0px`};
13
+ margin: ${({ theme: { spacing: i } }) => `${i.content(2)}px 0px`};
12
14
  cursor: pointer;
13
15
  border-radius: 20px;
14
- `, W = i.div`
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: n } }) => n.grey[10]};
34
+ background: ${({ theme: { palette: i } }) => i.grey[10]};
19
35
  border-radius: inherit;
20
- `, _ = i.div`
36
+ `, V = u.div`
21
37
  position: absolute;
22
38
  height: 100%;
23
- background: ${({ theme: { palette: n } }) => n.brand.primary.main};
39
+ background: ${({ theme: { palette: i } }) => i.brand.primary.main};
24
40
  border-radius: inherit;
25
- `, z = i.div`
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: n } }) => `${n.content(2)}px ${n.content(3)}px`};
33
- background: ${({ theme: { palette: n } }) => n.grey[90]};
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
- `, H = i.div`
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: n }, marked: o, disabled: c, hasMarks: r }) => c || !r ? {
63
+ ${({ theme: { palette: i }, marked: n, disabled: c, hasMarks: o }) => c || !o ? {
44
64
  background: "transparent",
45
65
  opacity: 0
46
- } : o ? {
47
- background: n.grey.white
66
+ } : n ? {
67
+ background: i.grey.white
48
68
  } : {
49
- background: n.grey[30]
69
+ background: i.grey[30]
50
70
  }}
51
- `, T = 10, P = B(function({
52
- value: o,
71
+ `, X = 10, ce = z(function({
72
+ value: n,
53
73
  onChange: c,
54
- step: r = 1,
74
+ step: o = 1,
55
75
  min: s = 0,
56
- max: a = 100,
57
- hasMarks: R = !0,
58
- disabledValues: C = [],
76
+ max: l = 100,
77
+ hasMarks: C = !0,
78
+ disabledValues: a = [],
79
+ readValue: w,
59
80
  railProps: d,
60
- trackProps: u,
61
- thumbProps: f,
62
- inlineCSS: D,
63
- ...X
64
- }, A) {
65
- const l = S(null), y = S(null), L = S(null), [V, b] = F(!1), k = 100 / ((a - s) / r), M = (e) => {
66
- if (l.current) {
67
- const t = e - l.current.getBoundingClientRect().left, g = Array.from(
68
- l.current.querySelectorAll('[class^="slider-mark-"]:not([disabled])')
69
- ), v = g.reduce((x, p) => Math.abs(p.offsetLeft - t) < Math.abs(x.offsetLeft - t) ? p : x, g[0]).getAttribute("data-value");
70
- return v !== null ? Number(v) : null;
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
- }, $ = (e) => {
74
- b(!0);
75
- const t = M(e);
76
- t !== null && c(t);
77
- }, w = (e) => {
78
- if (!V)
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
- const t = M(e);
81
- t !== null && c(t);
82
- }, h = () => b(!1), j = (e) => $(e.clientX), E = (e) => $(e.touches[0].clientX), I = (e) => w(e.clientX), q = (e) => w(e.touches[0].clientX);
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 (l.current) {
85
- const e = l.current.querySelector(
86
- `[data-value="${o}"]`
148
+ if (f.current) {
149
+ const t = f.current.querySelector(
150
+ `[data-value="${n}"]`
87
151
  );
88
- if (y.current && e) {
89
- const { offsetLeft: t, offsetWidth: g } = e;
90
- y.current.style.width = `${t + g + T * 2}px`;
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
- }, [o, s, a, r]), /* @__PURE__ */ N(
94
- U,
157
+ }, [n, s, l, o]), /* @__PURE__ */ I(
158
+ Y,
95
159
  {
96
- ref: A,
97
- ...X,
160
+ ref: M || m,
161
+ ...v,
98
162
  className: "slider",
99
- onMouseDown: j,
100
- onMouseMove: I,
101
- onMouseUp: h,
102
- onMouseLeave: h,
103
- onTouchStart: E,
104
- onTouchMove: q,
105
- onTouchEnd: h,
106
- onTouchCancel: h,
107
- css: D,
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__ */ m(W, { ref: L, ...d, css: d == null ? void 0 : d.inlineCSS, className: "slider-rail" }),
110
- /* @__PURE__ */ m(
111
- _,
174
+ /* @__PURE__ */ k(
175
+ Z,
112
176
  {
113
- ref: y,
114
- ...u,
115
- css: u == null ? void 0 : u.inlineCSS,
116
- className: "slider-track"
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__ */ N(
120
- O,
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: l,
201
+ ref: f,
202
+ tabIndex: -1,
125
203
  inlineCSS: {
126
- margin: `0 ${T + 2}px`,
204
+ margin: `0 ${X + 2}px`,
127
205
  width: "100%",
128
206
  height: "24px",
129
207
  position: "relative"
130
208
  },
131
209
  children: [
132
- a > 0 && s < a && r > 0 && Array.from({ length: (a - s) / r + 1 }, (e, t) => /* @__PURE__ */ m(
133
- H,
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-${t} slider-mark`,
136
- marked: t <= (o - s) / r,
137
- hasMarks: R,
138
- disabled: C.includes(s + r * t),
139
- "data-value": s + r * t,
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: `${k * t}%`
142
- }
219
+ left: `${p * e}%`
220
+ },
221
+ "aria-hidden": !0
143
222
  },
144
- `slider-mark-${o}:${s + r * t}`
223
+ `slider-mark-${n}:${s + o * e}`
145
224
  )),
146
- /* @__PURE__ */ m(
147
- z,
225
+ /* @__PURE__ */ k(
226
+ P,
148
227
  {
149
- ...f,
228
+ ...y,
150
229
  className: "slider-thumb",
151
- css: f == null ? void 0 : f.inlineCSS,
152
- style: { left: `${k * (o - s) / r}%` }
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
- P as default
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 e=require("@emotion/react/jsx-runtime"),f=require("react"),h=require("@emotion/styled"),d=r=>r&&r.__esModule?r:{default:r},i=d(h),x=i.default.div`
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:r}})=>`${r.content(1)}px`};
6
+ padding: ${({theme:{spacing:t}})=>`${t.content(1)}px`};
7
7
  align-items: center;
8
8
  border-radius: 20px;
9
- transition: ${({transitionDuration:r})=>`background-color ${r}ms ease-in-out`};
10
- pointer-events: ${({disabled:r})=>r?"none":"auto"};
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:r,grey:n}},selected:t,disabled:o})=>t&&o?{backgroundColor:r.primary.bg}:t&&!o?{backgroundColor:r.primary.main}:!t&&o?{backgroundColor:n[20]}:!t&&!o?{backgroundColor:n[40]}:{}}
13
- `,g=i.default.div`
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:r})=>`all ${r}ms ease-in-out`};
19
+ transition: ${({transitionDuration:t})=>`all ${t}ms ease-in-out`};
18
20
  transition-property: background-color, transform, filter;
19
21
 
20
- ${({theme:{palette:{grey:r,background:n}},selected:t,disabled:o})=>t&&o?{backgroundColor:r.white,transform:"translateX(100%)"}:t&&!o?{backgroundColor:r.white,filter:"drop-shadow(0px 0px 16px rgba(0, 0, 0, 0.20))",transform:"translateX(100%)"}:!t&&o?{backgroundColor:n.primary}:!t&&!o?{backgroundColor:r.white,filter:"drop-shadow(0px 0px 16px rgba(0, 0, 0, 0.20))"}:{}}
21
- `,m=i.default.input`
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
- `,w=f.forwardRef(function({selected:n,disabled:t,onChange:o,transitionDuration:u=150,inputProps:a,thumbProps:p,inlineCSS:c,...s},l){return e.jsxs(x,{ref:l,selected:n,disabled:t,transitionDuration:u,css:c,...s,children:[e.jsx(g,{selected:n,disabled:t,transitionDuration:u,...p}),e.jsx(m,{type:"checkbox",role:"switch",checked:n,disabled:t,onChange:o,...a})]})});exports.default=w;
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;
@@ -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;