react-native-molecules 0.5.0-beta.3 → 0.5.0-beta.31
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/components/Accordion/Accordion.tsx +2 -6
- package/components/Accordion/AccordionItem.tsx +16 -12
- package/components/Accordion/AccordionItemContent.tsx +6 -1
- package/components/Accordion/AccordionItemHeader.tsx +1 -1
- package/components/Accordion/utils.ts +6 -0
- package/components/ActivityIndicator/ActivityIndicator.tsx +6 -15
- package/components/Appbar/AppbarBase.tsx +18 -13
- package/components/Button/Button.tsx +211 -264
- package/components/Button/index.tsx +9 -3
- package/components/Button/types.ts +16 -2
- package/components/Button/utils.ts +230 -208
- package/components/Card/Card.tsx +1 -1
- package/components/Checkbox/Checkbox.tsx +125 -88
- package/components/Checkbox/CheckboxBase.ios.tsx +14 -23
- package/components/Checkbox/CheckboxBase.tsx +21 -137
- package/components/Checkbox/context.tsx +14 -0
- package/components/Checkbox/index.tsx +11 -4
- package/components/Checkbox/types.ts +63 -29
- package/components/Checkbox/utils.ts +25 -108
- package/components/Chip/Chip.tsx +41 -52
- package/components/Chip/utils.ts +3 -7
- package/components/DateField/DateField.tsx +111 -0
- package/components/DateField/index.tsx +6 -0
- package/components/{DatePickerInput/inputUtils.ts → DateField/useDateFieldState.ts} +19 -51
- package/components/DatePicker/DateCalendar.tsx +83 -0
- package/components/DatePicker/DatePickerActions.tsx +73 -0
- package/components/DatePicker/DatePickerModal.tsx +246 -0
- package/components/DatePicker/DatePickerPopover.tsx +79 -0
- package/components/DatePicker/DatePickerProvider.tsx +158 -0
- package/components/DatePicker/DatePickerTrigger.tsx +23 -0
- package/components/DatePicker/context.tsx +83 -0
- package/components/DatePicker/index.tsx +45 -0
- package/components/DatePicker/utils.ts +295 -0
- package/components/DatePickerInline/DatePickerDockedHeader.tsx +117 -0
- package/components/DatePickerInline/DatePickerInline.tsx +17 -16
- package/components/DatePickerInline/DatePickerInlineBase.tsx +11 -5
- package/components/DatePickerInline/DatePickerInlineHeader.tsx +50 -20
- package/components/DatePickerInline/Day.tsx +25 -1
- package/components/DatePickerInline/DayNames.tsx +13 -10
- package/components/DatePickerInline/DayRange.tsx +2 -4
- package/components/DatePickerInline/HeaderItem.tsx +44 -29
- package/components/DatePickerInline/Month.tsx +48 -67
- package/components/DatePickerInline/MonthPicker.tsx +80 -92
- package/components/DatePickerInline/Swiper.native.tsx +21 -4
- package/components/DatePickerInline/Swiper.tsx +169 -14
- package/components/DatePickerInline/SwiperUtils.ts +1 -1
- package/components/DatePickerInline/Week.tsx +6 -1
- package/components/DatePickerInline/YearPicker.tsx +220 -78
- package/components/DatePickerInline/dateUtils.tsx +18 -13
- package/components/DatePickerInline/store.tsx +27 -0
- package/components/DatePickerInline/types.ts +6 -2
- package/components/DatePickerInline/utils.ts +66 -29
- package/components/Divider/Divider.tsx +192 -0
- package/components/Divider/index.tsx +10 -0
- package/components/Drawer/Drawer.tsx +17 -6
- package/components/Drawer/DrawerItemGroup.tsx +3 -7
- package/components/ElementGroup/ElementGroup.tsx +1 -1
- package/components/FilePicker/FilePicker.tsx +48 -78
- package/components/FilePicker/index.tsx +2 -1
- package/components/FilePicker/utils.ts +9 -0
- package/components/HelperText/HelperText.tsx +0 -35
- package/components/Icon/iconFactory.tsx +5 -4
- package/components/Icon/index.tsx +1 -1
- package/components/Icon/types.ts +17 -6
- package/components/IconButton/IconButton.tsx +84 -84
- package/components/IconButton/index.tsx +1 -0
- package/components/IconButton/types.ts +10 -0
- package/components/IconButton/utils.ts +167 -33
- package/components/List/List.tsx +276 -0
- package/components/List/context.tsx +27 -0
- package/components/List/index.ts +8 -0
- package/components/List/types.ts +117 -0
- package/components/List/utils.ts +79 -0
- package/components/LoadingIndicator/LoadingIndicator.tsx +253 -0
- package/components/LoadingIndicator/LoadingIndicator.web.tsx +136 -0
- package/components/LoadingIndicator/index.tsx +13 -0
- package/components/LoadingIndicator/utils.ts +117 -0
- package/components/Menu/Menu.tsx +162 -39
- package/components/Menu/index.tsx +10 -7
- package/components/Menu/utils.ts +21 -70
- package/components/NavigationRail/NavigationRail.tsx +15 -9
- package/components/Popover/Popover.tsx +119 -145
- package/components/Popover/PopoverRoot.tsx +60 -0
- package/components/Popover/common.ts +54 -34
- package/components/Popover/index.ts +12 -1
- package/components/Popover/usePlatformMeasure.native.ts +90 -0
- package/components/Popover/usePlatformMeasure.ts +120 -0
- package/components/Popover/utils.ts +34 -0
- package/components/Portal/Portal.tsx +1 -2
- package/components/Radio/Radio.tsx +188 -0
- package/components/Radio/RadioBase.ios.tsx +69 -0
- package/components/Radio/RadioBase.tsx +136 -0
- package/components/Radio/context.tsx +23 -0
- package/components/Radio/index.tsx +20 -0
- package/components/Radio/types.ts +101 -0
- package/components/Radio/utils.ts +115 -0
- package/components/Rating/Rating.tsx +1 -1
- package/components/Select/Select.tsx +521 -785
- package/components/Select/context.tsx +81 -0
- package/components/Select/index.ts +26 -14
- package/components/Select/types.ts +65 -58
- package/components/Select/utils.ts +126 -0
- package/components/Slot/Slot.tsx +224 -0
- package/components/Slot/compose-refs.tsx +62 -0
- package/components/Slot/index.tsx +8 -0
- package/components/Surface/Surface.android.tsx +32 -7
- package/components/Surface/Surface.ios.tsx +34 -29
- package/components/Surface/Surface.tsx +31 -4
- package/components/Surface/utils.ts +44 -6
- package/components/Switch/Switch.ios.tsx +1 -1
- package/components/Switch/Switch.tsx +10 -3
- package/components/Tabs/TabItem.tsx +35 -58
- package/components/Tabs/TabLabel.tsx +5 -9
- package/components/Tabs/Tabs.tsx +156 -150
- package/components/Tabs/utils.ts +15 -2
- package/components/Text/textFactory.tsx +17 -5
- package/components/TextInput/TextInput.tsx +663 -579
- package/components/TextInput/index.tsx +19 -3
- package/components/TextInput/types.ts +77 -28
- package/components/TextInput/utils.ts +235 -145
- package/components/TimeField/TimeField.tsx +75 -0
- package/components/TimeField/index.tsx +6 -0
- package/components/TimeField/useTimeFieldState.ts +70 -0
- package/components/{TimePickerField/sanitizeTime.ts → TimeField/utils.ts} +77 -10
- package/components/TimePicker/AnalogClock.tsx +1 -1
- package/components/TimePicker/TimeInput.tsx +87 -42
- package/components/TimePicker/TimeInputs.tsx +138 -50
- package/components/TimePicker/TimePicker.tsx +74 -11
- package/components/TimePicker/TimePickerModal.tsx +186 -0
- package/components/TimePicker/context.tsx +17 -0
- package/components/TimePicker/index.tsx +15 -3
- package/components/TimePicker/utils.ts +93 -4
- package/components/Tooltip/Tooltip.tsx +42 -67
- package/components/Tooltip/TooltipContent.tsx +32 -5
- package/components/Tooltip/TooltipTrigger.tsx +21 -24
- package/components/Tooltip/index.tsx +1 -1
- package/components/TouchableRipple/TouchableRipple.native.tsx +83 -16
- package/components/TouchableRipple/TouchableRipple.tsx +150 -102
- package/components/TouchableRipple/rippleFromForegroundColor.ts +21 -0
- package/hocs/index.tsx +1 -1
- package/hocs/withKeyboardAccessibility.tsx +2 -3
- package/hocs/withPortal.tsx +1 -1
- package/hooks/index.tsx +2 -12
- package/hooks/useActionState.tsx +19 -8
- package/hooks/useContrastColor.ts +1 -2
- package/hooks/useFilePicker.tsx +7 -17
- package/hooks/useHandleNumberFormat.tsx +2 -2
- package/hooks/useMediaQuery.tsx +1 -2
- package/package.json +95 -111
- package/shortcuts-manager/ShortcutsManager/ShortcutsManager.tsx +6 -3
- package/shortcuts-manager/ShortcutsManager/utils.tsx +1 -1
- package/shortcuts-manager/useSetScopes/useSetScopes.tsx +1 -1
- package/shortcuts-manager/useShortcut/useShortcut.tsx +1 -1
- package/styles/shadow.ts +2 -1
- package/styles/themes/LightTheme.tsx +1 -1
- package/utils/DocumentPicker/documentPicker.ts +78 -27
- package/utils/DocumentPicker/types.ts +0 -1
- package/utils/extractSubcomponents.ts +89 -0
- package/utils/extractTextStyles.ts +1 -2
- package/utils/formatNumberWithMask/formatNumberWithMask.ts +2 -1
- package/utils/index.ts +0 -3
- package/utils/normalizeToNumberString/normalizeToNumberString.ts +1 -1
- package/components/DatePickerDocked/DatePickerDocked.tsx +0 -30
- package/components/DatePickerDocked/DatePickerDockedHeader.tsx +0 -129
- package/components/DatePickerDocked/index.tsx +0 -17
- package/components/DatePickerDocked/types.ts +0 -11
- package/components/DatePickerDocked/utils.ts +0 -157
- package/components/DatePickerInline/DatePickerContext.tsx +0 -21
- package/components/DatePickerInput/DatePickerInput.tsx +0 -139
- package/components/DatePickerInput/DatePickerInputModal.tsx +0 -48
- package/components/DatePickerInput/DatePickerInputWithoutModal.tsx +0 -77
- package/components/DatePickerInput/DateRangeInput.tsx +0 -88
- package/components/DatePickerInput/index.tsx +0 -10
- package/components/DatePickerInput/types.ts +0 -28
- package/components/DatePickerInput/utils.ts +0 -15
- package/components/DatePickerModal/AnimatedCrossView.tsx +0 -94
- package/components/DatePickerModal/CalendarEdit.tsx +0 -139
- package/components/DatePickerModal/DatePickerModal.tsx +0 -85
- package/components/DatePickerModal/DatePickerModalContent.tsx +0 -155
- package/components/DatePickerModal/DatePickerModalContentHeader.tsx +0 -213
- package/components/DatePickerModal/DatePickerModalHeader.tsx +0 -74
- package/components/DatePickerModal/DatePickerModalHeaderBackground.tsx +0 -13
- package/components/DatePickerModal/index.tsx +0 -16
- package/components/DatePickerModal/types.ts +0 -92
- package/components/DatePickerModal/utils.ts +0 -122
- package/components/DateTimePicker/DateTimePicker.tsx +0 -172
- package/components/DateTimePicker/index.tsx +0 -10
- package/components/DateTimePicker/utils.ts +0 -12
- package/components/HorizontalDivider/HorizontalDivider.tsx +0 -103
- package/components/HorizontalDivider/index.tsx +0 -9
- package/components/ListItem/ListItem.tsx +0 -136
- package/components/ListItem/ListItemDescription.tsx +0 -25
- package/components/ListItem/ListItemTitle.tsx +0 -25
- package/components/ListItem/index.tsx +0 -14
- package/components/ListItem/utils.ts +0 -115
- package/components/Menu/MenuDivider.tsx +0 -13
- package/components/Menu/MenuItem.tsx +0 -128
- package/components/Popover/Popover.native.tsx +0 -185
- package/components/RadioButton/RadioButton.tsx +0 -138
- package/components/RadioButton/RadioButtonAndroid.tsx +0 -188
- package/components/RadioButton/RadioButtonGroup.tsx +0 -98
- package/components/RadioButton/RadioButtonIOS.tsx +0 -106
- package/components/RadioButton/RadioButtonItem.tsx +0 -232
- package/components/RadioButton/index.ts +0 -22
- package/components/RadioButton/utils.ts +0 -165
- package/components/TimePickerField/TimePickerField.tsx +0 -152
- package/components/TimePickerField/index.tsx +0 -10
- package/components/TimePickerField/utils.ts +0 -94
- package/components/TimePickerModal/TimePickerModal.tsx +0 -115
- package/components/TimePickerModal/index.tsx +0 -10
- package/components/TimePickerModal/utils.ts +0 -47
- package/components/VerticalDivider/VerticalDivider.tsx +0 -100
- package/components/VerticalDivider/index.tsx +0 -9
- package/context-bridge/index.tsx +0 -87
- package/fast-context/index.tsx +0 -190
- package/hocs/typedMemo.tsx +0 -5
- package/hooks/useControlledValue.tsx +0 -68
- package/hooks/useLatest.tsx +0 -9
- package/hooks/useMergedRefs.ts +0 -14
- package/hooks/usePrevious.ts +0 -13
- package/hooks/useSearchable.tsx +0 -74
- package/hooks/useSubcomponents.tsx +0 -59
- package/hooks/useToggle.tsx +0 -24
- package/utils/color.ts +0 -22
- package/utils/compare/index.ts +0 -54
- package/utils/lodash.ts +0 -49
- package/utils/repository.ts +0 -53
package/package.json
CHANGED
|
@@ -1,112 +1,96 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
"
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
"
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
"
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
[
|
|
98
|
-
"module",
|
|
99
|
-
{
|
|
100
|
-
"configFile": true
|
|
101
|
-
}
|
|
102
|
-
],
|
|
103
|
-
[
|
|
104
|
-
"typescript",
|
|
105
|
-
{
|
|
106
|
-
"project": "tsconfig.build.json",
|
|
107
|
-
"rootDir": "src"
|
|
108
|
-
}
|
|
109
|
-
]
|
|
110
|
-
]
|
|
111
|
-
}
|
|
112
|
-
}
|
|
2
|
+
"name": "react-native-molecules",
|
|
3
|
+
"version": "0.5.0-beta.31",
|
|
4
|
+
"author": "Thet Aung <thetaung.dev@gmail.com>",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "index.ts",
|
|
7
|
+
"sideEffects": [
|
|
8
|
+
"components/DatePicker/context.tsx",
|
|
9
|
+
"components/DatePickerInline/store.tsx",
|
|
10
|
+
"components/List/context.tsx",
|
|
11
|
+
"components/Select/context.tsx",
|
|
12
|
+
"components/TimePicker/context.tsx",
|
|
13
|
+
"components/Popover/common.ts"
|
|
14
|
+
],
|
|
15
|
+
"files": [
|
|
16
|
+
"components",
|
|
17
|
+
"context-bridge",
|
|
18
|
+
"core",
|
|
19
|
+
"fast-context",
|
|
20
|
+
"hocs",
|
|
21
|
+
"hooks",
|
|
22
|
+
"shortcuts-manager",
|
|
23
|
+
"styles",
|
|
24
|
+
"types",
|
|
25
|
+
"utils",
|
|
26
|
+
"index.ts",
|
|
27
|
+
"!**/__tests__",
|
|
28
|
+
"!**/__fixtures__",
|
|
29
|
+
"!**/__mocks__"
|
|
30
|
+
],
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@gorhom/portal": "^1.0.14",
|
|
33
|
+
"@radix-ui/react-compose-refs": "^1.1.2",
|
|
34
|
+
"@react-native-vector-icons/feather": "^12.4.0",
|
|
35
|
+
"@react-native-vector-icons/material-design-icons": "^12.4.0",
|
|
36
|
+
"color": "^4.2.3",
|
|
37
|
+
"date-fns": "^4.1.0",
|
|
38
|
+
"eventemitter2": "^6.4.9",
|
|
39
|
+
"flubber": "^0.4.2",
|
|
40
|
+
"use-sync-external-store": "^1.2.0",
|
|
41
|
+
"@react-native-molecules/utils": "^1.0.0-beta.6"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"@react-native-documents/picker": "^10.1.2",
|
|
45
|
+
"react": ">=19",
|
|
46
|
+
"react-native": "0.81.4",
|
|
47
|
+
"react-native-svg": ">=12.1.0",
|
|
48
|
+
"react-native-unistyles": "^3.0.22",
|
|
49
|
+
"react-native-web": "~0.21.1",
|
|
50
|
+
"react-native-reanimated": ">=4.0.0",
|
|
51
|
+
"react-native-redash": ">=18.0.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@types/flubber": "^0.4.0",
|
|
55
|
+
"react-native-svg": "^15.10.1",
|
|
56
|
+
"@react-native-documents/picker": "^10.1.2",
|
|
57
|
+
"@types/color": "^3.0.3",
|
|
58
|
+
"@types/jest": "^29.1.2",
|
|
59
|
+
"@types/react": "~19.1.10",
|
|
60
|
+
"@types/use-sync-external-store": "^1.5.0",
|
|
61
|
+
"react": "19.1.0",
|
|
62
|
+
"react-native": "0.81.4",
|
|
63
|
+
"react-native-builder-bob": "^0.17.1",
|
|
64
|
+
"react-native-reanimated": "~4.1.1",
|
|
65
|
+
"react-native-unistyles": "^3.2.4",
|
|
66
|
+
"react-native-web": "~0.21.1"
|
|
67
|
+
},
|
|
68
|
+
"eslintIgnore": [
|
|
69
|
+
"node_modules/",
|
|
70
|
+
"lib/",
|
|
71
|
+
"test-cases/node_modules",
|
|
72
|
+
"dist",
|
|
73
|
+
"cache"
|
|
74
|
+
],
|
|
75
|
+
"scripts": {
|
|
76
|
+
"fix-typescript-output": "cd lib/typescript && mv src/* . && rm -rf src",
|
|
77
|
+
"example:expo": "pnpm --filter=expo-example run",
|
|
78
|
+
"start": "MOLECULES_ENV=storybook pnpm storybook",
|
|
79
|
+
"run:testcases": "pnpm workspace test-cases start",
|
|
80
|
+
"test": "MOLECULES_ENV=storybook jest && pnpm test-storybook",
|
|
81
|
+
"test-jest": "jest",
|
|
82
|
+
"bundle": "MOLECULES_ENV=release rm -rf dist && mkdir -p dist && pnpm pack --pack-destination=dist",
|
|
83
|
+
"do-release": "npm publish ./dist/react-native-molecules-$npm_package_version.tgz --access=public",
|
|
84
|
+
"release": "pnpm bundle && pnpm do-release",
|
|
85
|
+
"release:dev": "npm version prerelease --preid=dev --tag-version-prefix=\"react-native-molecules-v\" && pnpm release --tag=dev",
|
|
86
|
+
"release:beta": "npm version prerelease --preid=beta --tag-version-prefix=\"react-native-molecules-v\" && pnpm release --tag=beta",
|
|
87
|
+
"storybook": "MOLECULES_ENV=storybook storybook dev -p 6006",
|
|
88
|
+
"test-storybook": "test-storybook",
|
|
89
|
+
"coverage": "cp coverage/storybook/coverage-storybook.json coverage/coverage-storybook.json && npx nyc report --reporter=html -t coverage --report-dir coverage/lcov-report",
|
|
90
|
+
"test:coverage": "pnpm test-jest --coverage && pnpm test-storybook --coverage && pnpm coverage",
|
|
91
|
+
"build-storybook": "storybook build",
|
|
92
|
+
"chromatic:all": "MOLECULES_ENV=storybook npx chromatic --project-token=934368a7f6c9",
|
|
93
|
+
"chromatic": "MOLECULES_ENV=storybook pnpm chromatic:all --only-changed",
|
|
94
|
+
"perf": "npx reassure"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { keyBy } from '@react-native-molecules/utils/helpers/lodash';
|
|
1
2
|
import { memo, useContext, useEffect, useMemo, useRef } from 'react';
|
|
2
3
|
|
|
3
|
-
import { keyBy } from '../../utils/lodash';
|
|
4
4
|
import EventsManager from '../EventsManager';
|
|
5
5
|
import type { Shortcut } from '../types';
|
|
6
6
|
import {
|
|
@@ -10,9 +10,12 @@ import {
|
|
|
10
10
|
type ShortcutsManagerProps,
|
|
11
11
|
} from './utils';
|
|
12
12
|
|
|
13
|
+
const defaultScopes: ShortcutsManagerProps['scopes'] = [];
|
|
14
|
+
const defaultShortcuts: Shortcut[] = [];
|
|
15
|
+
|
|
13
16
|
const _ShortcutsManager = ({ shortcuts, scopes, children }: ShortcutsManagerProps) => {
|
|
14
|
-
const shortcutsRef = useRef<Shortcut[]>(shortcuts ||
|
|
15
|
-
const scopesRef = useRef(scopes);
|
|
17
|
+
const shortcutsRef = useRef<Shortcut[]>(shortcuts || defaultShortcuts);
|
|
18
|
+
const scopesRef = useRef(scopes || defaultScopes);
|
|
16
19
|
const parentContextRef = useContext(ShortcutsManagerContext);
|
|
17
20
|
|
|
18
21
|
const contextValue = useMemo(() => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { createFastContext } from '@react-native-molecules/utils/fast-context';
|
|
1
2
|
import type { ReactNode } from 'react';
|
|
2
3
|
|
|
3
|
-
import { createFastContext } from '../../fast-context';
|
|
4
4
|
import type { Scope, Shortcut } from '../types';
|
|
5
5
|
|
|
6
6
|
export type ShortcutsManagerContextType = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { keyBy } from '@react-native-molecules/utils/helpers/lodash';
|
|
1
2
|
import { useCallback } from 'react';
|
|
2
3
|
|
|
3
|
-
import { keyBy } from '../../utils/lodash';
|
|
4
4
|
import { useShortcutsManagerStoreRef } from '../ShortcutsManager/utils';
|
|
5
5
|
import type { Scope } from '../types';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { useLatest } from '@react-native-molecules/utils/hooks';
|
|
1
2
|
import { useCallback, useEffect } from 'react';
|
|
2
3
|
|
|
3
|
-
import useLatest from '../../hooks/useLatest';
|
|
4
4
|
import { useShortcutsManagerStoreRef } from '../ShortcutsManager';
|
|
5
5
|
import type { ShortcutEventDetail } from '../types';
|
|
6
6
|
import { calculateShortcutEventName } from '../utils';
|
package/styles/shadow.ts
CHANGED
|
@@ -8,7 +8,8 @@ export const inputRange: MD3Elevation[] = [0, 1, 2, 3, 4, 5];
|
|
|
8
8
|
export const shadowHeight = [0, 1, 2, 4, 6, 8];
|
|
9
9
|
export const shadowRadius = [0, 3, 6, 8, 10, 12];
|
|
10
10
|
|
|
11
|
-
export default function shadow(
|
|
11
|
+
export default function shadow(_elevation: number) {
|
|
12
|
+
const elevation = typeof _elevation === 'number' ? (_elevation > 5 ? 5 : _elevation) : 0;
|
|
12
13
|
return {
|
|
13
14
|
shadowColor: MD3_SHADOW_COLOR,
|
|
14
15
|
shadowOpacity: elevation ? MD3_SHADOW_OPACITY : 0,
|
|
@@ -25,7 +25,7 @@ export const generateLightThemeColors = (
|
|
|
25
25
|
error: palette.error40,
|
|
26
26
|
errorContainer: palette.error90,
|
|
27
27
|
onPrimary: palette.primary100,
|
|
28
|
-
onPrimaryContainer: palette.
|
|
28
|
+
onPrimaryContainer: palette.primary30,
|
|
29
29
|
onSecondary: palette.secondary100,
|
|
30
30
|
onSecondaryContainer: palette.secondary10,
|
|
31
31
|
onTertiary: palette.tertiary100,
|
|
@@ -2,6 +2,14 @@ import { Platform } from 'react-native';
|
|
|
2
2
|
|
|
3
3
|
import type { DocumentPickerOptions, DocumentResult } from './types';
|
|
4
4
|
|
|
5
|
+
class OperationCanceledError extends Error {
|
|
6
|
+
code = 'OPERATION_CANCELED';
|
|
7
|
+
constructor() {
|
|
8
|
+
super('user canceled the document picker');
|
|
9
|
+
this.name = 'OperationCanceledError';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
5
13
|
const resolveFileData = (file: File): Promise<DocumentResult> => {
|
|
6
14
|
return new Promise((resolve, reject) => {
|
|
7
15
|
const mimeType = file.type;
|
|
@@ -31,46 +39,89 @@ const resolveFileData = (file: File): Promise<DocumentResult> => {
|
|
|
31
39
|
const getDocumentAsyncWeb = async ({
|
|
32
40
|
type = '*/*',
|
|
33
41
|
multiple = false,
|
|
34
|
-
|
|
42
|
+
onCancel,
|
|
43
|
+
onError,
|
|
44
|
+
}: DocumentPickerOptions): Promise<DocumentResult[]> => {
|
|
35
45
|
// SSR guard
|
|
36
46
|
if (Platform.OS !== 'web') {
|
|
37
|
-
|
|
47
|
+
const error = new OperationCanceledError();
|
|
48
|
+
onCancel?.();
|
|
49
|
+
throw error;
|
|
38
50
|
}
|
|
39
51
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
52
|
+
return new Promise((resolve, reject) => {
|
|
53
|
+
try {
|
|
54
|
+
const input = document.createElement('input');
|
|
55
|
+
input.style.display = 'none';
|
|
56
|
+
input.setAttribute('type', 'file');
|
|
57
|
+
// @ts-expect-error
|
|
58
|
+
input.setAttribute('accept', Array.isArray(type) ? type.join(',') : type);
|
|
45
59
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
60
|
+
if (multiple) {
|
|
61
|
+
input.setAttribute('multiple', 'multiple');
|
|
62
|
+
}
|
|
49
63
|
|
|
50
|
-
|
|
64
|
+
document.body.appendChild(input);
|
|
51
65
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
66
|
+
const cleanup = () => {
|
|
67
|
+
try {
|
|
68
|
+
document.body.removeChild(input);
|
|
69
|
+
} catch (e) {
|
|
70
|
+
// Input already removed, ignore
|
|
71
|
+
}
|
|
72
|
+
};
|
|
56
73
|
|
|
57
|
-
|
|
74
|
+
input.addEventListener('change', async () => {
|
|
75
|
+
try {
|
|
76
|
+
if (input.files && input.files.length > 0) {
|
|
77
|
+
const response: Promise<DocumentResult>[] = [];
|
|
58
78
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
79
|
+
Array.from(input.files).forEach(file =>
|
|
80
|
+
response.push(resolveFileData(file)),
|
|
81
|
+
);
|
|
63
82
|
|
|
64
|
-
|
|
65
|
-
|
|
83
|
+
const results = await Promise.all(response);
|
|
84
|
+
resolve(results);
|
|
85
|
+
}
|
|
86
|
+
} catch (error) {
|
|
87
|
+
onError?.(error);
|
|
88
|
+
reject(error);
|
|
89
|
+
} finally {
|
|
90
|
+
cleanup();
|
|
91
|
+
}
|
|
92
|
+
});
|
|
66
93
|
|
|
67
|
-
|
|
68
|
-
|
|
94
|
+
input.addEventListener('cancel', () => {
|
|
95
|
+
const error = new OperationCanceledError();
|
|
96
|
+
onCancel?.();
|
|
97
|
+
cleanup();
|
|
98
|
+
reject(error);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
input.addEventListener('error', () => {
|
|
102
|
+
const error = new Error('File picker error occurred');
|
|
103
|
+
onError?.(error);
|
|
104
|
+
cleanup();
|
|
105
|
+
reject(error);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const event = new MouseEvent('click');
|
|
109
|
+
input.dispatchEvent(event);
|
|
110
|
+
} catch (error) {
|
|
111
|
+
// Handle errors from file picker setup or opening
|
|
112
|
+
onError?.(error);
|
|
113
|
+
reject(error);
|
|
114
|
+
}
|
|
69
115
|
});
|
|
70
116
|
};
|
|
71
117
|
|
|
118
|
+
const pickSingle = (options: DocumentPickerOptions = {}) =>
|
|
119
|
+
getDocumentAsyncWeb({ ...options, multiple: false });
|
|
120
|
+
|
|
121
|
+
const pickMultiple = (options: DocumentPickerOptions = {}) =>
|
|
122
|
+
getDocumentAsyncWeb({ ...options, multiple: true });
|
|
123
|
+
|
|
72
124
|
export default {
|
|
73
|
-
pickSingle
|
|
74
|
-
pickMultiple
|
|
75
|
-
getDocumentAsyncWeb({ type, multiple: true }),
|
|
125
|
+
pickSingle,
|
|
126
|
+
pickMultiple,
|
|
76
127
|
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { Children, type FC, isValidElement } from 'react';
|
|
3
|
+
|
|
4
|
+
export type ExtractSubcomponentsArgs<T extends string> = {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
/**
|
|
7
|
+
* array of displayName as string
|
|
8
|
+
* */
|
|
9
|
+
allowedChildren: (T | { name: T; allowMultiple?: boolean })[];
|
|
10
|
+
/**
|
|
11
|
+
* If true, also returns the remaining children that don't match any of the allowedChildren
|
|
12
|
+
* in a `rest` property
|
|
13
|
+
*/
|
|
14
|
+
includeRest?: boolean;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type ExtractSubcomponentsResult<T extends string, IncludeRest extends boolean = false> = {
|
|
18
|
+
[key in T]: ReactElement[];
|
|
19
|
+
} & (IncludeRest extends true ? { rest: ReactNode[] } : {});
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* This will return an object with the displayNames as the property names
|
|
23
|
+
* eg. allowedChildren: ['Drawer_Header', 'Drawer_Content', 'Drawer_Footer', 'DrawerItem'];
|
|
24
|
+
*
|
|
25
|
+
* return value -> {
|
|
26
|
+
* Drawer_Header: [],
|
|
27
|
+
* Drawer_Content: [],
|
|
28
|
+
* Drawer_Footer: [],
|
|
29
|
+
* DrawerItem: [],
|
|
30
|
+
* }
|
|
31
|
+
*
|
|
32
|
+
* If includeRest is true, also returns:
|
|
33
|
+
* {
|
|
34
|
+
* ...above,
|
|
35
|
+
* rest: [remaining children that don't match allowedChildren]
|
|
36
|
+
* }
|
|
37
|
+
* */
|
|
38
|
+
export function extractSubcomponents<
|
|
39
|
+
T extends string = string,
|
|
40
|
+
IncludeRest extends boolean = false,
|
|
41
|
+
>({
|
|
42
|
+
children,
|
|
43
|
+
allowedChildren,
|
|
44
|
+
includeRest,
|
|
45
|
+
}: ExtractSubcomponentsArgs<T> & { includeRest?: IncludeRest }): ExtractSubcomponentsResult<
|
|
46
|
+
T,
|
|
47
|
+
IncludeRest
|
|
48
|
+
> {
|
|
49
|
+
// Single map: name → allowMultiple
|
|
50
|
+
const allowedMap = new Map<T, boolean>();
|
|
51
|
+
for (const entry of allowedChildren) {
|
|
52
|
+
if (typeof entry === 'string') {
|
|
53
|
+
allowedMap.set(entry as T, true);
|
|
54
|
+
} else {
|
|
55
|
+
allowedMap.set(entry.name, entry.allowMultiple ?? true);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const result = (includeRest ? { rest: [] } : {}) as ExtractSubcomponentsResult<T, IncludeRest>;
|
|
60
|
+
for (const name of allowedMap.keys()) {
|
|
61
|
+
(result as any)[name] = [];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
Children.forEach(children, child => {
|
|
65
|
+
if (!isValidElement(child)) {
|
|
66
|
+
if (includeRest) (result as any).rest.push(child);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const displayName = (child.type as FC)?.displayName as T | undefined;
|
|
71
|
+
if (!displayName) {
|
|
72
|
+
if (includeRest) (result as any).rest.push(child);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const allowMultiple = allowedMap.get(displayName);
|
|
77
|
+
if (allowMultiple !== undefined) {
|
|
78
|
+
if (allowMultiple) {
|
|
79
|
+
(result as any)[displayName].push(child);
|
|
80
|
+
} else {
|
|
81
|
+
(result as any)[displayName] = [child];
|
|
82
|
+
}
|
|
83
|
+
} else if (includeRest) {
|
|
84
|
+
(result as any).rest.push(child);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { isNil } from '@react-native-molecules/utils/helpers/lodash';
|
|
2
|
+
|
|
1
3
|
import { createNumberMask, type CreateNumberMaskProps } from '../createNumberMask';
|
|
2
|
-
import { isNil } from '../lodash';
|
|
3
4
|
import { formatWithMask } from './formatWithMask';
|
|
4
5
|
|
|
5
6
|
export type FormatNumberWithMaskProps = CreateNumberMaskProps & {
|
package/utils/index.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
export { addEventListener, addListener } from './addEventListener';
|
|
2
2
|
export { BackgroundContext } from './backgroundContext';
|
|
3
|
-
export { default as color, resolveContrastColor } from './color';
|
|
4
|
-
export * from './compare';
|
|
5
3
|
export { default as composeEventHandlers } from './composeEventHandlers';
|
|
6
4
|
export { createNumberMask, type CreateNumberMaskProps } from './createNumberMask';
|
|
7
5
|
export * from './createSyntheticEvent';
|
|
@@ -16,5 +14,4 @@ export {
|
|
|
16
14
|
normalizeToNumberString,
|
|
17
15
|
type NormalizeToNumberStringProps,
|
|
18
16
|
} from './normalizeToNumberString';
|
|
19
|
-
export { Repository } from './repository';
|
|
20
17
|
export * from './resolveStateVariant';
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { memo } from 'react';
|
|
2
|
-
|
|
3
|
-
import DatePickerInlineBase from '../DatePickerInline/DatePickerInlineBase';
|
|
4
|
-
import { Popover } from '../Popover';
|
|
5
|
-
import DatePickerDockedHeader from './DatePickerDockedHeader';
|
|
6
|
-
import type { DatePickerDockedProps } from './types';
|
|
7
|
-
import { datePickerDockedMonthStyles } from './utils';
|
|
8
|
-
|
|
9
|
-
const DatePickerDocked = (props: DatePickerDockedProps) => {
|
|
10
|
-
const { triggerRef, isOpen, onToggle, onClose } = props;
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<Popover
|
|
14
|
-
triggerRef={triggerRef}
|
|
15
|
-
isOpen={isOpen}
|
|
16
|
-
onClose={onClose}
|
|
17
|
-
{...props.popoverContentProps}>
|
|
18
|
-
<DatePickerInlineBase
|
|
19
|
-
{...props}
|
|
20
|
-
// TODO - fix ts issues
|
|
21
|
-
// @ts-ignore
|
|
22
|
-
HeaderComponent={DatePickerDockedHeader}
|
|
23
|
-
onToggle={onToggle}
|
|
24
|
-
monthStyle={datePickerDockedMonthStyles}
|
|
25
|
-
/>
|
|
26
|
-
</Popover>
|
|
27
|
-
);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export default memo(DatePickerDocked);
|