@dt-dds/react-checkbox 1.0.0-beta.60 → 1.0.0-beta.62
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 +24 -0
- package/dist/index.js +24 -1
- package/dist/index.mjs +30 -2
- package/package.json +4 -4
- /package/{LICENSE.md → LICENSE} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @dt-ui/react-checkbox
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.62
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- feat: change theme icons to sharp
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- fix: checkbox label alignment
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
- @dt-dds/react-icon@1.0.0-beta.62
|
|
14
|
+
- @dt-dds/themes@1.0.0-beta.14
|
|
15
|
+
- @dt-dds/react-core@1.0.0-beta.59
|
|
16
|
+
|
|
17
|
+
## 1.0.0-beta.61
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- chore: standardise license file naming
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
- @dt-dds/react-core@1.0.0-beta.58
|
|
24
|
+
- @dt-dds/react-icon@1.0.0-beta.61
|
|
25
|
+
- @dt-dds/themes@1.0.0-beta.13
|
|
26
|
+
|
|
3
27
|
## 1.0.0-beta.60
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -74,6 +74,11 @@ var SIZES = {
|
|
|
74
74
|
small: 20,
|
|
75
75
|
large: 24
|
|
76
76
|
};
|
|
77
|
+
var LABEL_HEIGHT_BUFFER = 1;
|
|
78
|
+
var LABEL_LINE_HEIGHT = {
|
|
79
|
+
small: 16,
|
|
80
|
+
large: 20
|
|
81
|
+
};
|
|
77
82
|
|
|
78
83
|
// src/Checkbox.styled.ts
|
|
79
84
|
var getCheckboxColors = (theme) => ({
|
|
@@ -242,11 +247,21 @@ var Checkbox = (0, import_react.forwardRef)(
|
|
|
242
247
|
const theme = (0, import_react2.useTheme)();
|
|
243
248
|
const internalRef = (0, import_react.useRef)(null);
|
|
244
249
|
const mergedRef = mergeRefs(internalRef, ref);
|
|
250
|
+
const labelRef = (0, import_react.useRef)(null);
|
|
245
251
|
(0, import_react.useEffect)(() => {
|
|
246
252
|
if (internalRef.current) {
|
|
247
253
|
internalRef.current.indeterminate = isIndeterminate;
|
|
248
254
|
}
|
|
249
255
|
}, [isIndeterminate]);
|
|
256
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
257
|
+
if (!labelRef.current) return;
|
|
258
|
+
const labelContainer = labelRef.current.closest("label");
|
|
259
|
+
if (!labelContainer) return;
|
|
260
|
+
const el = labelRef.current;
|
|
261
|
+
const maxSingleLineHeight = LABEL_LINE_HEIGHT[size] + LABEL_HEIGHT_BUFFER;
|
|
262
|
+
const isWrapped = el.offsetHeight > maxSingleLineHeight;
|
|
263
|
+
labelContainer.style.alignItems = isWrapped ? "flex-start" : "center";
|
|
264
|
+
}, [label, children]);
|
|
250
265
|
const handleChange = (event) => {
|
|
251
266
|
if (isDisabled) return;
|
|
252
267
|
onChange == null ? void 0 : onChange(event);
|
|
@@ -301,7 +316,15 @@ var Checkbox = (0, import_react.forwardRef)(
|
|
|
301
316
|
) : null
|
|
302
317
|
}
|
|
303
318
|
),
|
|
304
|
-
hasLabel ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
319
|
+
hasLabel ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
320
|
+
CheckboxLabelStyled,
|
|
321
|
+
{
|
|
322
|
+
$disabled: isDisabled,
|
|
323
|
+
$size: size,
|
|
324
|
+
ref: labelRef,
|
|
325
|
+
children: label || children
|
|
326
|
+
}
|
|
327
|
+
) : null
|
|
305
328
|
]
|
|
306
329
|
}
|
|
307
330
|
);
|
package/dist/index.mjs
CHANGED
|
@@ -28,7 +28,12 @@ var __objRest = (source, exclude) => {
|
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
// src/Checkbox.tsx
|
|
31
|
-
import {
|
|
31
|
+
import {
|
|
32
|
+
forwardRef,
|
|
33
|
+
useEffect,
|
|
34
|
+
useLayoutEffect,
|
|
35
|
+
useRef
|
|
36
|
+
} from "react";
|
|
32
37
|
import { useTheme } from "@emotion/react";
|
|
33
38
|
import { Icon } from "@dt-dds/react-icon";
|
|
34
39
|
|
|
@@ -41,6 +46,11 @@ var SIZES = {
|
|
|
41
46
|
small: 20,
|
|
42
47
|
large: 24
|
|
43
48
|
};
|
|
49
|
+
var LABEL_HEIGHT_BUFFER = 1;
|
|
50
|
+
var LABEL_LINE_HEIGHT = {
|
|
51
|
+
small: 16,
|
|
52
|
+
large: 20
|
|
53
|
+
};
|
|
44
54
|
|
|
45
55
|
// src/Checkbox.styled.ts
|
|
46
56
|
var getCheckboxColors = (theme) => ({
|
|
@@ -209,11 +219,21 @@ var Checkbox = forwardRef(
|
|
|
209
219
|
const theme = useTheme();
|
|
210
220
|
const internalRef = useRef(null);
|
|
211
221
|
const mergedRef = mergeRefs(internalRef, ref);
|
|
222
|
+
const labelRef = useRef(null);
|
|
212
223
|
useEffect(() => {
|
|
213
224
|
if (internalRef.current) {
|
|
214
225
|
internalRef.current.indeterminate = isIndeterminate;
|
|
215
226
|
}
|
|
216
227
|
}, [isIndeterminate]);
|
|
228
|
+
useLayoutEffect(() => {
|
|
229
|
+
if (!labelRef.current) return;
|
|
230
|
+
const labelContainer = labelRef.current.closest("label");
|
|
231
|
+
if (!labelContainer) return;
|
|
232
|
+
const el = labelRef.current;
|
|
233
|
+
const maxSingleLineHeight = LABEL_LINE_HEIGHT[size] + LABEL_HEIGHT_BUFFER;
|
|
234
|
+
const isWrapped = el.offsetHeight > maxSingleLineHeight;
|
|
235
|
+
labelContainer.style.alignItems = isWrapped ? "flex-start" : "center";
|
|
236
|
+
}, [label, children]);
|
|
217
237
|
const handleChange = (event) => {
|
|
218
238
|
if (isDisabled) return;
|
|
219
239
|
onChange == null ? void 0 : onChange(event);
|
|
@@ -268,7 +288,15 @@ var Checkbox = forwardRef(
|
|
|
268
288
|
) : null
|
|
269
289
|
}
|
|
270
290
|
),
|
|
271
|
-
hasLabel ? /* @__PURE__ */ jsx(
|
|
291
|
+
hasLabel ? /* @__PURE__ */ jsx(
|
|
292
|
+
CheckboxLabelStyled,
|
|
293
|
+
{
|
|
294
|
+
$disabled: isDisabled,
|
|
295
|
+
$size: size,
|
|
296
|
+
ref: labelRef,
|
|
297
|
+
children: label || children
|
|
298
|
+
}
|
|
299
|
+
) : null
|
|
272
300
|
]
|
|
273
301
|
}
|
|
274
302
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dt-dds/react-checkbox",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.62",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js"
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"test:update:snapshot": "jest -u"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@dt-dds/react-core": "1.0.0-beta.
|
|
24
|
-
"@dt-dds/react-icon": "1.0.0-beta.
|
|
25
|
-
"@dt-dds/themes": "1.0.0-beta.
|
|
23
|
+
"@dt-dds/react-core": "1.0.0-beta.59",
|
|
24
|
+
"@dt-dds/react-icon": "1.0.0-beta.62",
|
|
25
|
+
"@dt-dds/themes": "1.0.0-beta.14"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@babel/core": "^7.22.9",
|
/package/{LICENSE.md → LICENSE}
RENAMED
|
File without changes
|