@hero-design/rn 8.105.4-alpha.1 → 8.106.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/.turbo/turbo-build.log +3 -3
- package/CHANGELOG.md +22 -6
- package/es/index.js +2797 -2453
- package/lib/index.js +2800 -2456
- package/package.json +2 -2
- package/src/components/Button/Button.tsx +70 -44
- package/src/components/Button/LoadingIndicator/StyledLoadingIndicator.tsx +12 -33
- package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/StyledLoadingIndicator.spec.tsx.snap +4 -4
- package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/index.spec.tsx.snap +12 -12
- package/src/components/Button/LoadingIndicator/index.tsx +4 -1
- package/src/components/Button/StyledButton.tsx +461 -313
- package/src/components/Button/__tests__/__snapshots__/Button.spec.tsx.snap +102 -86
- package/src/components/Button/__tests__/__snapshots__/StyledButton.spec.tsx.snap +19 -18
- package/src/components/Chart/Line/__tests__/__snapshots__/index.spec.tsx.snap +2 -2
- package/src/components/Checkbox/{index.tsx → DefaultCheckBox.tsx} +6 -31
- package/src/components/Checkbox/InlineCheckBox.tsx +97 -0
- package/src/components/Checkbox/{StyledCheckbox.tsx → StyledDefaultCheckBox.tsx} +1 -0
- package/src/components/Checkbox/StyledInlineCheckBox.tsx +49 -0
- package/src/components/Checkbox/__tests__/{index.spec.tsx → DefaultCheckBox.spec.tsx} +21 -20
- package/src/components/Checkbox/__tests__/InlineCheckBox.spec.tsx +93 -0
- package/src/components/Checkbox/__tests__/{StyledCheckbox.spec.tsx → StyledDefaultCheckbox.spec.tsx} +2 -2
- package/src/components/Checkbox/__tests__/__snapshots__/{index.spec.tsx.snap → DefaultCheckBox.spec.tsx.snap} +6 -0
- package/src/components/Checkbox/__tests__/__snapshots__/InlineCheckBox.spec.tsx.snap +988 -0
- package/src/components/Checkbox/__tests__/__snapshots__/{StyledCheckbox.spec.tsx.snap → StyledDefaultCheckbox.spec.tsx.snap} +4 -0
- package/src/components/Checkbox/__tests__/utils.spec.ts +20 -0
- package/src/components/Checkbox/index.ts +9 -0
- package/src/components/Checkbox/utils.ts +25 -0
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +2 -2
- package/src/components/Drawer/__tests__/__snapshots__/index.spec.tsx.snap +11 -8
- package/src/components/Drawer/__tests__/index.spec.tsx +15 -1
- package/src/components/Drawer/index.tsx +5 -2
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +5 -5
- package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +1 -1
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +59 -19
- package/src/theme/components/button.ts +52 -19
- package/src/theme/components/checkbox.ts +7 -0
- package/src/theme/components/drawer.ts +1 -1
- package/src/utils/__tests__/helpers.spec.ts +37 -1
- package/src/utils/helpers.ts +14 -0
- package/stats/8.105.4/rn-stats.html +4844 -0
- package/stats/8.106.0/rn-stats.html +4844 -0
- package/types/components/Button/Button.d.ts +5 -4
- package/types/components/Button/LoadingIndicator/StyledLoadingIndicator.d.ts +3 -4
- package/types/components/Button/LoadingIndicator/index.d.ts +1 -1
- package/types/components/Button/StyledButton.d.ts +8 -4
- package/types/components/Checkbox/DefaultCheckBox.d.ts +40 -0
- package/types/components/Checkbox/InlineCheckBox.d.ts +38 -0
- package/types/components/Checkbox/StyledInlineCheckBox.d.ts +45 -0
- package/types/components/Checkbox/index.d.ts +5 -45
- package/types/components/Checkbox/utils.d.ts +6 -0
- package/types/theme/components/button.d.ts +49 -15
- package/types/theme/components/checkbox.d.ts +6 -0
- package/types/theme/components/drawer.d.ts +1 -1
- package/types/utils/helpers.d.ts +2 -0
- /package/types/components/Checkbox/{StyledCheckbox.d.ts → StyledDefaultCheckBox.d.ts} +0 -0
|
@@ -222,6 +222,7 @@ exports[`StyledWrapper renders correctly when disabled is false, readonly is fal
|
|
|
222
222
|
"borderRadius": 8,
|
|
223
223
|
"borderWidth": 1,
|
|
224
224
|
"flexDirection": "row",
|
|
225
|
+
"gap": 8,
|
|
225
226
|
"opacity": 1,
|
|
226
227
|
"padding": 16,
|
|
227
228
|
}
|
|
@@ -292,6 +293,7 @@ exports[`StyledWrapper renders correctly when disabled is false, readonly is tru
|
|
|
292
293
|
"borderRadius": 8,
|
|
293
294
|
"borderWidth": 1,
|
|
294
295
|
"flexDirection": "row",
|
|
296
|
+
"gap": 8,
|
|
295
297
|
"opacity": 1,
|
|
296
298
|
"padding": 16,
|
|
297
299
|
}
|
|
@@ -362,6 +364,7 @@ exports[`StyledWrapper renders correctly when disabled is true, readonly is fals
|
|
|
362
364
|
"borderRadius": 8,
|
|
363
365
|
"borderWidth": 1,
|
|
364
366
|
"flexDirection": "row",
|
|
367
|
+
"gap": 8,
|
|
365
368
|
"opacity": 1,
|
|
366
369
|
"padding": 16,
|
|
367
370
|
}
|
|
@@ -432,6 +435,7 @@ exports[`StyledWrapper renders correctly when disabled is true, readonly is true
|
|
|
432
435
|
"borderRadius": 8,
|
|
433
436
|
"borderWidth": 1,
|
|
434
437
|
"flexDirection": "row",
|
|
438
|
+
"gap": 8,
|
|
435
439
|
"opacity": 1,
|
|
436
440
|
"padding": 16,
|
|
437
441
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { getThemeState } from '../utils';
|
|
2
|
+
|
|
3
|
+
describe('getThemeState', () => {
|
|
4
|
+
it.each`
|
|
5
|
+
disabled | readonly | checked | expected
|
|
6
|
+
${false} | ${false} | ${false} | ${'default'}
|
|
7
|
+
${false} | ${false} | ${true} | ${'checked'}
|
|
8
|
+
${false} | ${true} | ${false} | ${'readonly'}
|
|
9
|
+
${false} | ${true} | ${true} | ${'readonly'}
|
|
10
|
+
${true} | ${false} | ${false} | ${'disabled'}
|
|
11
|
+
${true} | ${false} | ${true} | ${'disabled'}
|
|
12
|
+
${true} | ${true} | ${false} | ${'disabled'}
|
|
13
|
+
${true} | ${true} | ${true} | ${'disabled'}
|
|
14
|
+
`(
|
|
15
|
+
`should return correctly if disabled is $disabled and readonly is $readonly`,
|
|
16
|
+
({ disabled, readonly, checked, expected }) => {
|
|
17
|
+
expect(getThemeState({ disabled, readonly, checked })).toBe(expected);
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import DefaultCheckBox from './DefaultCheckBox';
|
|
2
|
+
import type { DefaultCheckboxProps } from './DefaultCheckBox';
|
|
3
|
+
import InlineCheckbox from './InlineCheckBox';
|
|
4
|
+
|
|
5
|
+
export type { DefaultCheckboxProps as CheckboxProps };
|
|
6
|
+
|
|
7
|
+
export default Object.assign(DefaultCheckBox, {
|
|
8
|
+
Inline: InlineCheckbox,
|
|
9
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type getStateType = {
|
|
2
|
+
disabled: boolean;
|
|
3
|
+
readonly: boolean;
|
|
4
|
+
checked?: boolean;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export const getThemeState = ({
|
|
8
|
+
disabled,
|
|
9
|
+
readonly,
|
|
10
|
+
checked,
|
|
11
|
+
}: getStateType) => {
|
|
12
|
+
if (disabled) {
|
|
13
|
+
return 'disabled';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (readonly) {
|
|
17
|
+
return 'readonly';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (checked) {
|
|
21
|
+
return 'checked';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return 'default';
|
|
25
|
+
};
|
|
@@ -591,7 +591,7 @@ exports[`DatePickerIOS renders correctly 1`] = `
|
|
|
591
591
|
{
|
|
592
592
|
"alignItems": "center",
|
|
593
593
|
"backgroundColor": "transparent",
|
|
594
|
-
"borderRadius":
|
|
594
|
+
"borderRadius": 999,
|
|
595
595
|
"borderWidth": 0,
|
|
596
596
|
"flexDirection": "row",
|
|
597
597
|
"height": 60,
|
|
@@ -1262,7 +1262,7 @@ exports[`DatePickerIOS renders correctly with custom locale 1`] = `
|
|
|
1262
1262
|
{
|
|
1263
1263
|
"alignItems": "center",
|
|
1264
1264
|
"backgroundColor": "transparent",
|
|
1265
|
-
"borderRadius":
|
|
1265
|
+
"borderRadius": 999,
|
|
1266
1266
|
"borderWidth": 0,
|
|
1267
1267
|
"flexDirection": "row",
|
|
1268
1268
|
"height": 60,
|
|
@@ -67,7 +67,7 @@ exports[`Drawer renders correctly in invisible state 1`] = `
|
|
|
67
67
|
pointerEvents="box-none"
|
|
68
68
|
style={
|
|
69
69
|
{
|
|
70
|
-
"backgroundColor": "#
|
|
70
|
+
"backgroundColor": "#000000",
|
|
71
71
|
"bottom": 0,
|
|
72
72
|
"left": 0,
|
|
73
73
|
"opacity": 0,
|
|
@@ -76,6 +76,7 @@ exports[`Drawer renders correctly in invisible state 1`] = `
|
|
|
76
76
|
"top": 0,
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
+
testID="undefined-backdrop"
|
|
79
80
|
/>
|
|
80
81
|
<View
|
|
81
82
|
collapsable={false}
|
|
@@ -133,7 +134,7 @@ exports[`Drawer renders correctly in visible state 1`] = `
|
|
|
133
134
|
}
|
|
134
135
|
>
|
|
135
136
|
<View
|
|
136
|
-
enableShadow={
|
|
137
|
+
enableShadow={true}
|
|
137
138
|
pointerEvents="box-none"
|
|
138
139
|
style={
|
|
139
140
|
[
|
|
@@ -144,7 +145,7 @@ exports[`Drawer renders correctly in visible state 1`] = `
|
|
|
144
145
|
"overflow": "hidden",
|
|
145
146
|
"position": "absolute",
|
|
146
147
|
"right": 0,
|
|
147
|
-
"shadowColor": "
|
|
148
|
+
"shadowColor": "#001f23",
|
|
148
149
|
"shadowOffset": {
|
|
149
150
|
"height": 3,
|
|
150
151
|
"width": 0,
|
|
@@ -191,26 +192,27 @@ exports[`Drawer renders correctly in visible state 1`] = `
|
|
|
191
192
|
pointerEvents="auto"
|
|
192
193
|
style={
|
|
193
194
|
{
|
|
194
|
-
"backgroundColor": "#
|
|
195
|
+
"backgroundColor": "#000000",
|
|
195
196
|
"bottom": 0,
|
|
196
197
|
"left": 0,
|
|
197
|
-
"opacity": 0.
|
|
198
|
+
"opacity": 0.56,
|
|
198
199
|
"position": "absolute",
|
|
199
200
|
"right": 0,
|
|
200
201
|
"top": 0,
|
|
201
202
|
}
|
|
202
203
|
}
|
|
204
|
+
testID="undefined-backdrop"
|
|
203
205
|
/>
|
|
204
206
|
<View
|
|
205
207
|
collapsable={false}
|
|
206
|
-
enableShadow={
|
|
208
|
+
enableShadow={true}
|
|
207
209
|
onLayout={[Function]}
|
|
208
210
|
style={
|
|
209
211
|
{
|
|
210
212
|
"backgroundColor": "#ffffff",
|
|
211
213
|
"borderBottomLeftRadius": 16,
|
|
212
214
|
"borderBottomRightRadius": 16,
|
|
213
|
-
"elevation":
|
|
215
|
+
"elevation": 10,
|
|
214
216
|
"overflow": "hidden",
|
|
215
217
|
"transform": [
|
|
216
218
|
{
|
|
@@ -315,7 +317,7 @@ exports[`Drawer renders correctly with no backdrop 1`] = `
|
|
|
315
317
|
pointerEvents="box-none"
|
|
316
318
|
style={
|
|
317
319
|
{
|
|
318
|
-
"backgroundColor": "#
|
|
320
|
+
"backgroundColor": "#000000",
|
|
319
321
|
"bottom": 0,
|
|
320
322
|
"left": 0,
|
|
321
323
|
"opacity": 0,
|
|
@@ -324,6 +326,7 @@ exports[`Drawer renders correctly with no backdrop 1`] = `
|
|
|
324
326
|
"top": 0,
|
|
325
327
|
}
|
|
326
328
|
}
|
|
329
|
+
testID="undefined-backdrop"
|
|
327
330
|
/>
|
|
328
331
|
<View
|
|
329
332
|
collapsable={false}
|
|
@@ -26,12 +26,26 @@ describe('Drawer', () => {
|
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
it('renders correctly with no backdrop', () => {
|
|
29
|
-
const { toJSON } = renderWithTheme(
|
|
29
|
+
const { queryByTestId, toJSON } = renderWithTheme(
|
|
30
30
|
<Drawer hasBackdrop={false} visible={false}>
|
|
31
31
|
<Text>Drawer Content</Text>
|
|
32
32
|
</Drawer>
|
|
33
33
|
);
|
|
34
34
|
|
|
35
|
+
const backdrop = queryByTestId('drawer-backdrop');
|
|
36
|
+
expect(backdrop).toBeNull();
|
|
37
|
+
|
|
35
38
|
expect(toJSON()).toMatchSnapshot();
|
|
36
39
|
});
|
|
40
|
+
|
|
41
|
+
it('renders correctly with backdrop', () => {
|
|
42
|
+
const { getByTestId } = renderWithTheme(
|
|
43
|
+
<Drawer visible testID="drawer">
|
|
44
|
+
<Text>Drawer Content</Text>
|
|
45
|
+
</Drawer>
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const backdrop = getByTestId('drawer-backdrop');
|
|
49
|
+
expect(backdrop).toBeVisible();
|
|
50
|
+
});
|
|
37
51
|
});
|
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
StyledDrawerContainer,
|
|
10
10
|
} from './StyledDrawer';
|
|
11
11
|
|
|
12
|
+
const BACKDROP_OPACITY = 0.56;
|
|
13
|
+
|
|
12
14
|
interface DrawerProps {
|
|
13
15
|
/**
|
|
14
16
|
* Drawer's visibility.
|
|
@@ -42,7 +44,7 @@ const Drawer = ({
|
|
|
42
44
|
const animatedValue = useRef(new Animated.Value(visible ? 1 : 0)).current;
|
|
43
45
|
const [height, setHeight] = useState(Dimensions.get('window').height);
|
|
44
46
|
|
|
45
|
-
const enableShadow = visible &&
|
|
47
|
+
const enableShadow = visible && hasBackdrop;
|
|
46
48
|
|
|
47
49
|
const interpolateTranslateY = animatedValue.interpolate({
|
|
48
50
|
inputRange: [0, 1],
|
|
@@ -52,7 +54,7 @@ const Drawer = ({
|
|
|
52
54
|
const interpolateBackdropOpacity = hasBackdrop
|
|
53
55
|
? animatedValue.interpolate({
|
|
54
56
|
inputRange: [0, 1],
|
|
55
|
-
outputRange: [0,
|
|
57
|
+
outputRange: [0, BACKDROP_OPACITY],
|
|
56
58
|
})
|
|
57
59
|
: 0;
|
|
58
60
|
|
|
@@ -75,6 +77,7 @@ const Drawer = ({
|
|
|
75
77
|
pointerEvents="box-none"
|
|
76
78
|
>
|
|
77
79
|
<StyledBackdrop
|
|
80
|
+
testID={`${testID}-backdrop`}
|
|
78
81
|
pointerEvents={visible ? 'auto' : 'box-none'}
|
|
79
82
|
onPress={onDismiss}
|
|
80
83
|
style={{ opacity: interpolateBackdropOpacity }}
|
|
@@ -1454,7 +1454,7 @@ exports[`rendering allows custom renderer 1`] = `
|
|
|
1454
1454
|
{
|
|
1455
1455
|
"alignItems": "center",
|
|
1456
1456
|
"backgroundColor": "transparent",
|
|
1457
|
-
"borderRadius":
|
|
1457
|
+
"borderRadius": 999,
|
|
1458
1458
|
"borderWidth": 0,
|
|
1459
1459
|
"flexDirection": "row",
|
|
1460
1460
|
"height": 60,
|
|
@@ -3169,7 +3169,7 @@ exports[`rendering renders correct floating bottom sheet variant 1`] = `
|
|
|
3169
3169
|
{
|
|
3170
3170
|
"alignItems": "center",
|
|
3171
3171
|
"backgroundColor": "transparent",
|
|
3172
|
-
"borderRadius":
|
|
3172
|
+
"borderRadius": 999,
|
|
3173
3173
|
"borderWidth": 0,
|
|
3174
3174
|
"flexDirection": "row",
|
|
3175
3175
|
"height": 60,
|
|
@@ -5192,7 +5192,7 @@ exports[`rendering renders correctly when bottom sheet is visible 1`] = `
|
|
|
5192
5192
|
{
|
|
5193
5193
|
"alignItems": "center",
|
|
5194
5194
|
"backgroundColor": "transparent",
|
|
5195
|
-
"borderRadius":
|
|
5195
|
+
"borderRadius": 999,
|
|
5196
5196
|
"borderWidth": 0,
|
|
5197
5197
|
"flexDirection": "row",
|
|
5198
5198
|
"height": 60,
|
|
@@ -6815,7 +6815,7 @@ exports[`rendering renders correctly when receives sections 1`] = `
|
|
|
6815
6815
|
{
|
|
6816
6816
|
"alignItems": "center",
|
|
6817
6817
|
"backgroundColor": "transparent",
|
|
6818
|
-
"borderRadius":
|
|
6818
|
+
"borderRadius": 999,
|
|
6819
6819
|
"borderWidth": 0,
|
|
6820
6820
|
"flexDirection": "row",
|
|
6821
6821
|
"height": 60,
|
|
@@ -8105,7 +8105,7 @@ exports[`rendering renders correctly when receives sections 2`] = `
|
|
|
8105
8105
|
{
|
|
8106
8106
|
"alignItems": "center",
|
|
8107
8107
|
"backgroundColor": "transparent",
|
|
8108
|
-
"borderRadius":
|
|
8108
|
+
"borderRadius": 999,
|
|
8109
8109
|
"borderWidth": 0,
|
|
8110
8110
|
"flexDirection": "row",
|
|
8111
8111
|
"height": 60,
|
|
@@ -267,37 +267,63 @@ exports[`theme returns correct theme object 1`] = `
|
|
|
267
267
|
"default": 2,
|
|
268
268
|
},
|
|
269
269
|
"colors": {
|
|
270
|
-
"
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
270
|
+
"background": {
|
|
271
|
+
"filledDanger": "#f46363",
|
|
272
|
+
"filledInverted": "#ffffff",
|
|
273
|
+
"filledPrimary": "#401960",
|
|
274
|
+
"filledSecondary": "#f6f6f7",
|
|
275
|
+
"filledWhite": "#ffffff",
|
|
276
|
+
},
|
|
277
|
+
"border": {
|
|
278
|
+
"outlinedDanger": "#cb300a",
|
|
279
|
+
"outlinedInverted": "#ffffff",
|
|
280
|
+
"outlinedPrimary": "#401960",
|
|
281
|
+
"outlinedSecondary": "#e8e9ea",
|
|
282
|
+
"outlinedWhite": "#ffffff",
|
|
283
|
+
},
|
|
275
284
|
"invertedText": "#ffffff",
|
|
276
285
|
"pressedBackground": {
|
|
277
|
-
"filledDanger": "#
|
|
286
|
+
"filledDanger": "#f68282",
|
|
287
|
+
"filledInverted": "#ece8ef",
|
|
278
288
|
"filledPrimary": "#33144d",
|
|
279
|
-
"filledSecondary": "#
|
|
289
|
+
"filledSecondary": "#dadbde",
|
|
280
290
|
"filledWhite": "#ece8ef",
|
|
281
|
-
"
|
|
282
|
-
"
|
|
291
|
+
"outlinedDanger": "#fcebe7",
|
|
292
|
+
"outlinedInverted": "#33144d",
|
|
283
293
|
"outlinedPrimary": "#ece8ef",
|
|
284
294
|
"outlinedSecondary": "#ece8ef",
|
|
295
|
+
"outlinedWhite": "#33144d",
|
|
285
296
|
"textDanger": "#fcebe7",
|
|
297
|
+
"textInverted": "#33144d",
|
|
286
298
|
"textPrimary": "#ece8ef",
|
|
287
|
-
"textSecondary": "#
|
|
299
|
+
"textSecondary": "#ece8ef",
|
|
288
300
|
"textWhite": "#33144d",
|
|
289
301
|
},
|
|
290
302
|
"pressedText": {
|
|
291
|
-
"
|
|
292
|
-
"
|
|
293
|
-
"
|
|
294
|
-
"
|
|
303
|
+
"inlineTextDanger": "#f46363",
|
|
304
|
+
"inlineTextInverted": "#795e90",
|
|
305
|
+
"inlineTextPrimary": "#795e90",
|
|
306
|
+
"inlineTextSecondary": "#606065",
|
|
307
|
+
"inlineTextWhite": "#795e90",
|
|
308
|
+
},
|
|
309
|
+
"text": {
|
|
310
|
+
"filledDanger": "#ffffff",
|
|
311
|
+
"filledInverted": "#401960",
|
|
312
|
+
"filledPrimary": "#ffffff",
|
|
313
|
+
"filledSecondary": "#001f23",
|
|
314
|
+
"filledWhite": "#401960",
|
|
315
|
+
"outlinedDanger": "#cb300a",
|
|
316
|
+
"outlinedInverted": "#ffffff",
|
|
317
|
+
"outlinedPrimary": "#401960",
|
|
318
|
+
"outlinedSecondary": "#001f23",
|
|
319
|
+
"outlinedWhite": "#ffffff",
|
|
320
|
+
"textDanger": "#cb300a",
|
|
321
|
+
"textInverted": "#ffffff",
|
|
322
|
+
"textPrimary": "#401960",
|
|
323
|
+
"textSecondary": "#001f23",
|
|
324
|
+
"textWhite": "#ffffff",
|
|
295
325
|
},
|
|
296
|
-
"primary": "#401960",
|
|
297
|
-
"secondary": "#4d6265",
|
|
298
|
-
"textLoadingBackground": "#ece8ef",
|
|
299
326
|
"utilityBackground": "#ffffff",
|
|
300
|
-
"white": "#ffffff",
|
|
301
327
|
},
|
|
302
328
|
"fontSize": {
|
|
303
329
|
"default": 18,
|
|
@@ -319,6 +345,7 @@ exports[`theme returns correct theme object 1`] = `
|
|
|
319
345
|
},
|
|
320
346
|
"radii": {
|
|
321
347
|
"default": 32,
|
|
348
|
+
"rounded": 999,
|
|
322
349
|
"text": 4,
|
|
323
350
|
"utilityRadii": 8,
|
|
324
351
|
},
|
|
@@ -339,6 +366,13 @@ exports[`theme returns correct theme object 1`] = `
|
|
|
339
366
|
"iconPadding": 12,
|
|
340
367
|
"textButtonPadding": 12,
|
|
341
368
|
},
|
|
369
|
+
"medium": {
|
|
370
|
+
"buttonPadding": 16,
|
|
371
|
+
"buttonPaddingHorizontal": 16,
|
|
372
|
+
"buttonPaddingVertical": 8,
|
|
373
|
+
"iconPadding": 12,
|
|
374
|
+
"textButtonPadding": 32,
|
|
375
|
+
},
|
|
342
376
|
"utilityPadding": 8,
|
|
343
377
|
},
|
|
344
378
|
},
|
|
@@ -475,10 +509,16 @@ exports[`theme returns correct theme object 1`] = `
|
|
|
475
509
|
},
|
|
476
510
|
"sizes": {
|
|
477
511
|
"icon": 24,
|
|
512
|
+
"inlineCheckbox": {
|
|
513
|
+
"large": 16,
|
|
514
|
+
"medium": 14.67,
|
|
515
|
+
},
|
|
478
516
|
},
|
|
479
517
|
"space": {
|
|
480
518
|
"iconDescriptionPadding": 12,
|
|
481
519
|
"iconTop": 0,
|
|
520
|
+
"inlineCheckboxGap": 8,
|
|
521
|
+
"inlineCheckboxMargin": 8,
|
|
482
522
|
"wrapperPadding": 16,
|
|
483
523
|
},
|
|
484
524
|
},
|
|
@@ -558,7 +598,7 @@ exports[`theme returns correct theme object 1`] = `
|
|
|
558
598
|
},
|
|
559
599
|
"drawer": {
|
|
560
600
|
"colors": {
|
|
561
|
-
"backdrop": "#
|
|
601
|
+
"backdrop": "#000000",
|
|
562
602
|
"background": "#ffffff",
|
|
563
603
|
"handler": "#001f23",
|
|
564
604
|
"shadow": "#001f23",
|
|
@@ -28,6 +28,13 @@ const getButtonTheme = (theme: GlobalTheme) => {
|
|
|
28
28
|
buttonPaddingHorizontal: theme.space.medium,
|
|
29
29
|
iconPadding: theme.space.small,
|
|
30
30
|
},
|
|
31
|
+
medium: {
|
|
32
|
+
buttonPaddingVertical: theme.space.small,
|
|
33
|
+
buttonPaddingHorizontal: theme.space.medium,
|
|
34
|
+
iconPadding: theme.space.smallMedium,
|
|
35
|
+
buttonPadding: theme.space.medium,
|
|
36
|
+
textButtonPadding: theme.space.xlarge,
|
|
37
|
+
},
|
|
31
38
|
utilityPadding: theme.space.small,
|
|
32
39
|
};
|
|
33
40
|
|
|
@@ -40,44 +47,70 @@ const getButtonTheme = (theme: GlobalTheme) => {
|
|
|
40
47
|
|
|
41
48
|
const radii = {
|
|
42
49
|
default: theme.radii['5xlarge'],
|
|
50
|
+
rounded: theme.radii.rounded,
|
|
43
51
|
utilityRadii: theme.radii.medium,
|
|
44
52
|
text: theme.radii.base,
|
|
45
53
|
};
|
|
46
54
|
|
|
47
55
|
const colors = {
|
|
48
|
-
primary: theme.colors.primary,
|
|
49
|
-
secondary: theme.colors.mutedOnDefaultGlobalSurface,
|
|
50
|
-
danger: theme.colors.onErrorSurface,
|
|
51
|
-
white: theme.colors.defaultGlobalSurface,
|
|
52
|
-
defaultText: theme.colors.onDefaultGlobalSurface,
|
|
53
|
-
disabledText: theme.colors.disabledOnDefaultGlobalSurface,
|
|
54
|
-
disabledBorder: theme.colors.disabledOnDefaultGlobalSurface,
|
|
55
|
-
disabledBackground: theme.colors.disabledOnDefaultGlobalSurface,
|
|
56
56
|
invertedText: theme.colors.onDarkGlobalSurface,
|
|
57
57
|
utilityBackground: theme.colors.defaultGlobalSurface,
|
|
58
|
-
|
|
58
|
+
background: {
|
|
59
|
+
filledPrimary: theme.colors.primary,
|
|
60
|
+
filledSecondary: theme.colors.neutralGlobalSurface,
|
|
61
|
+
filledDanger: theme.colors.error,
|
|
62
|
+
filledWhite: theme.colors.defaultGlobalSurface,
|
|
63
|
+
filledInverted: theme.colors.defaultGlobalSurface,
|
|
64
|
+
},
|
|
65
|
+
text: {
|
|
66
|
+
filledPrimary: theme.colors.onDarkGlobalSurface,
|
|
67
|
+
filledSecondary: theme.colors.onDefaultGlobalSurface,
|
|
68
|
+
filledDanger: theme.colors.white,
|
|
69
|
+
filledWhite: theme.colors.primary,
|
|
70
|
+
filledInverted: theme.colors.primary,
|
|
71
|
+
outlinedPrimary: theme.colors.primary,
|
|
72
|
+
outlinedSecondary: theme.colors.onDefaultGlobalSurface,
|
|
73
|
+
outlinedDanger: theme.colors.onErrorSurface,
|
|
74
|
+
outlinedWhite: theme.colors.onDarkGlobalSurface,
|
|
75
|
+
outlinedInverted: theme.colors.onDarkGlobalSurface,
|
|
76
|
+
textPrimary: theme.colors.primary,
|
|
77
|
+
textSecondary: theme.colors.onDefaultGlobalSurface,
|
|
78
|
+
textDanger: theme.colors.onErrorSurface,
|
|
79
|
+
textWhite: theme.colors.onDarkGlobalSurface,
|
|
80
|
+
textInverted: theme.colors.onDarkGlobalSurface,
|
|
81
|
+
},
|
|
82
|
+
border: {
|
|
83
|
+
outlinedPrimary: theme.colors.primary,
|
|
84
|
+
outlinedSecondary: theme.colors.secondaryOutline,
|
|
85
|
+
outlinedDanger: theme.colors.onErrorSurface,
|
|
86
|
+
outlinedWhite: theme.colors.defaultGlobalSurface,
|
|
87
|
+
outlinedInverted: theme.colors.defaultGlobalSurface,
|
|
88
|
+
},
|
|
59
89
|
pressedBackground: {
|
|
60
90
|
filledPrimary: theme.colors.pressedSurface,
|
|
61
|
-
filledSecondary: theme.colors.
|
|
62
|
-
filledDanger: theme.colors.
|
|
91
|
+
filledSecondary: theme.colors.archivedSurface,
|
|
92
|
+
filledDanger: theme.colors.mutedError,
|
|
63
93
|
filledWhite: theme.colors.highlightedSurface,
|
|
94
|
+
filledInverted: theme.colors.highlightedSurface,
|
|
64
95
|
outlinedPrimary: theme.colors.highlightedSurface,
|
|
65
96
|
outlinedSecondary: theme.colors.highlightedSurface,
|
|
66
|
-
|
|
67
|
-
|
|
97
|
+
outlinedDanger: theme.colors.errorSurface,
|
|
98
|
+
outlinedWhite: theme.colors.pressedSurface,
|
|
99
|
+
outlinedInverted: theme.colors.pressedSurface,
|
|
68
100
|
textPrimary: theme.colors.highlightedSurface,
|
|
69
|
-
textSecondary: theme.colors.
|
|
101
|
+
textSecondary: theme.colors.highlightedSurface,
|
|
70
102
|
textDanger: theme.colors.errorSurface,
|
|
71
103
|
textWhite: theme.colors.pressedSurface,
|
|
104
|
+
textInverted: theme.colors.pressedSurface,
|
|
72
105
|
},
|
|
73
106
|
pressedText: {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
107
|
+
inlineTextPrimary: theme.colors.secondary,
|
|
108
|
+
inlineTextSecondary: theme.colors.onArchivedSurface,
|
|
109
|
+
inlineTextDanger: theme.colors.error,
|
|
110
|
+
inlineTextWhite: theme.colors.secondary,
|
|
111
|
+
inlineTextInverted: theme.colors.secondary,
|
|
78
112
|
},
|
|
79
113
|
};
|
|
80
|
-
|
|
81
114
|
const lineHeights = {
|
|
82
115
|
titleOfTextVariant: {
|
|
83
116
|
default: theme.lineHeights.medium,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { scale } from '../../utils/scale';
|
|
1
2
|
import type { GlobalTheme } from '../global';
|
|
2
3
|
|
|
3
4
|
const getCheckboxTheme = (theme: GlobalTheme) => {
|
|
@@ -20,10 +21,16 @@ const getCheckboxTheme = (theme: GlobalTheme) => {
|
|
|
20
21
|
iconTop: 0,
|
|
21
22
|
wrapperPadding: theme.space.medium,
|
|
22
23
|
iconDescriptionPadding: theme.space.smallMedium,
|
|
24
|
+
inlineCheckboxGap: theme.space.small,
|
|
25
|
+
inlineCheckboxMargin: theme.space.small,
|
|
23
26
|
};
|
|
24
27
|
|
|
25
28
|
const sizes = {
|
|
26
29
|
icon: theme.sizes.large,
|
|
30
|
+
inlineCheckbox: {
|
|
31
|
+
medium: scale(14.67),
|
|
32
|
+
large: theme.sizes.medium,
|
|
33
|
+
},
|
|
27
34
|
};
|
|
28
35
|
|
|
29
36
|
const radii = {
|
|
@@ -4,7 +4,7 @@ const getDrawerTheme = (theme: GlobalTheme) => {
|
|
|
4
4
|
const colors = {
|
|
5
5
|
shadow: theme.colors.primaryOutline,
|
|
6
6
|
background: theme.colors.defaultGlobalSurface,
|
|
7
|
-
backdrop: theme.colors.
|
|
7
|
+
backdrop: theme.colors.black,
|
|
8
8
|
handler: theme.colors.onDefaultGlobalSurface,
|
|
9
9
|
};
|
|
10
10
|
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
deepCompareValue,
|
|
3
|
+
omit,
|
|
4
|
+
pick,
|
|
5
|
+
transformKebabCaseToCamelCase,
|
|
6
|
+
} from '../helpers';
|
|
2
7
|
|
|
3
8
|
describe('pick', () => {
|
|
4
9
|
it('works', () => {
|
|
@@ -78,3 +83,34 @@ describe('deepCompareValue', () => {
|
|
|
78
83
|
expect(deepCompareValue(a, b)).toBe(expected);
|
|
79
84
|
});
|
|
80
85
|
});
|
|
86
|
+
|
|
87
|
+
describe('transformKebabCaseToCamelCase', () => {
|
|
88
|
+
it.each`
|
|
89
|
+
input | expected
|
|
90
|
+
${'kebab-case'} | ${'kebabCase'}
|
|
91
|
+
${'simple'} | ${'simple'}
|
|
92
|
+
${'multi-word-string'} | ${'multiWordString'}
|
|
93
|
+
${'very-long-train-case'} | ${'veryLongTrainCase'}
|
|
94
|
+
${'single-word'} | ${'singleWord'}
|
|
95
|
+
${'data-attribute'} | ${'dataAttribute'}
|
|
96
|
+
${'user-id'} | ${'userId'}
|
|
97
|
+
${'component-name'} | ${'componentName'}
|
|
98
|
+
${'api-endpoint-url'} | ${'apiEndpointUrl'}
|
|
99
|
+
${'background-color'} | ${'backgroundColor'}
|
|
100
|
+
${'font-size'} | ${'fontSize'}
|
|
101
|
+
${'margin-top'} | ${'marginTop'}
|
|
102
|
+
${'border-radius'} | ${'borderRadius'}
|
|
103
|
+
${'text-decoration-line'} | ${'textDecorationLine'}
|
|
104
|
+
${'a-b-c-d-e'} | ${'aBCDE'}
|
|
105
|
+
${'test-123-value'} | ${'test123Value'}
|
|
106
|
+
${'api-v2-endpoint'} | ${'apiV2Endpoint'}
|
|
107
|
+
${'item-1-name'} | ${'item1Name'}
|
|
108
|
+
${'version-2-api'} | ${'version2Api'}
|
|
109
|
+
${'api-v2-endpoint'} | ${'apiV2Endpoint'}
|
|
110
|
+
`(
|
|
111
|
+
'should transform valid kebab-case "$input" to camelCase "$expected"',
|
|
112
|
+
({ input, expected }) => {
|
|
113
|
+
expect(transformKebabCaseToCamelCase(input)).toBe(expected);
|
|
114
|
+
}
|
|
115
|
+
);
|
|
116
|
+
});
|
package/src/utils/helpers.ts
CHANGED
|
@@ -111,3 +111,17 @@ export const useKeyboard = () => {
|
|
|
111
111
|
|
|
112
112
|
return { isKeyboardVisible, keyboardHeight };
|
|
113
113
|
};
|
|
114
|
+
|
|
115
|
+
export type CamelCase<S extends string> = S extends `${infer F}-${infer R}`
|
|
116
|
+
? R extends `${string}-${string}`
|
|
117
|
+
? `${F}${Capitalize<CamelCase<R>>}`
|
|
118
|
+
: `${F}${Capitalize<R>}`
|
|
119
|
+
: never;
|
|
120
|
+
|
|
121
|
+
export const transformKebabCaseToCamelCase = <T extends string>(
|
|
122
|
+
string: T
|
|
123
|
+
): CamelCase<T> => {
|
|
124
|
+
return string.replace(/-([a-z0-9])/g, (_, char: string) =>
|
|
125
|
+
/[a-z]/.test(char) ? char.toUpperCase() : char
|
|
126
|
+
) as CamelCase<T>;
|
|
127
|
+
};
|