react-native-system-ui 1.0.0 → 1.0.1
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/dist/cjs/components/action-sheet/ActionSheet.js +45 -51
- package/dist/cjs/components/area/Area.js +22 -22
- package/dist/cjs/components/avatar/Avatar.js +23 -23
- package/dist/cjs/components/badge/Badge.js +56 -61
- package/dist/cjs/components/button/Button.js +87 -92
- package/dist/cjs/components/button/ButtonGroup.js +4 -4
- package/dist/cjs/components/calendar/Calendar.js +28 -28
- package/dist/cjs/components/cascader/Cascader.js +205 -212
- package/dist/cjs/components/cell/Cell.js +54 -51
- package/dist/cjs/components/cell/CellGroup.js +26 -25
- package/dist/cjs/components/checkbox/Checkbox.js +1 -0
- package/dist/cjs/components/checkbox/CheckboxGroup.js +20 -19
- package/dist/cjs/components/circle/Circle.js +66 -54
- package/dist/cjs/components/collapse/Collapse.js +18 -18
- package/dist/cjs/components/config-provider/ConfigProvider.js +5 -5
- package/dist/cjs/components/count-down/CountDown.js +17 -17
- package/dist/cjs/components/datetime-picker/DatetimePicker.js +34 -35
- package/dist/cjs/components/dialog/Dialog.js +16 -10
- package/dist/cjs/components/dialog/imperative.js +8 -14
- package/dist/cjs/components/dialog/tokens.js +1 -0
- package/dist/cjs/components/divider/Divider.js +48 -51
- package/dist/cjs/components/empty/Empty.js +30 -25
- package/dist/cjs/components/error-boundary/ErrorBoundary.js +3 -2
- package/dist/cjs/components/flex/Flex.js +27 -27
- package/dist/cjs/components/flex/FlexItem.js +1 -0
- package/dist/cjs/components/form/Form.js +93 -92
- package/dist/cjs/components/form/FormItem.js +60 -54
- package/dist/cjs/components/form/FormList.js +35 -35
- package/dist/cjs/components/grid/Grid.js +48 -48
- package/dist/cjs/components/grid/GridItem.js +9 -2
- package/dist/cjs/components/image/Image.js +25 -24
- package/dist/cjs/components/image/tokens.js +3 -1
- package/dist/cjs/components/image-preview/ImagePreview.js +19 -19
- package/dist/cjs/components/image-preview/tokens.js +3 -1
- package/dist/cjs/components/input/Input.js +16 -19
- package/dist/cjs/components/loading/Loading.js +27 -27
- package/dist/cjs/components/nav-bar/NavBar.js +21 -18
- package/dist/cjs/components/nav-bar/tokens.js +3 -1
- package/dist/cjs/components/notice-bar/NoticeBar.js +7 -3
- package/dist/cjs/components/notice-bar/tokens.js +3 -1
- package/dist/cjs/components/notify/Notify.js +2 -1
- package/dist/cjs/components/notify/imperative.js +17 -17
- package/dist/cjs/components/notify/tokens.js +1 -0
- package/dist/cjs/components/number-keyboard/NumberKeyboard.js +217 -201
- package/dist/cjs/components/number-keyboard/tokens.js +7 -1
- package/dist/cjs/components/overlay/Overlay.js +15 -15
- package/dist/cjs/components/password-input/PasswordInput.js +49 -49
- package/dist/cjs/components/picker/Picker.js +50 -58
- package/dist/cjs/components/popup/Popup.js +10 -10
- package/dist/cjs/components/popup/tokens.js +1 -0
- package/dist/cjs/components/portal/Portal.js +3 -4
- package/dist/cjs/components/progress/Progress.js +94 -95
- package/dist/cjs/components/progress/tokens.js +1 -0
- package/dist/cjs/components/radio/Radio.js +67 -63
- package/dist/cjs/components/radio/RadioGroup.js +6 -6
- package/dist/cjs/components/safe-area-view/SafeAreaView.js +7 -7
- package/dist/cjs/components/search/Search.js +28 -28
- package/dist/cjs/components/selector/Selector.js +19 -26
- package/dist/cjs/components/share-sheet/ShareSheet.js +6 -1
- package/dist/cjs/components/share-sheet/tokens.js +3 -1
- package/dist/cjs/components/sidebar/Sidebar.js +22 -16
- package/dist/cjs/components/sidebar/SidebarItem.js +9 -8
- package/dist/cjs/components/sidebar/tokens.js +3 -1
- package/dist/cjs/components/skeleton/Skeleton.js +43 -42
- package/dist/cjs/components/space/Space.js +45 -41
- package/dist/cjs/components/space/tokens.js +7 -1
- package/dist/cjs/components/stepper/Stepper.js +17 -15
- package/dist/cjs/components/stepper/tokens.js +1 -0
- package/dist/cjs/components/swiper/Swiper.js +10 -7
- package/dist/cjs/components/swiper/SwiperPagIndicator.js +3 -2
- package/dist/cjs/components/switch/Switch.js +23 -23
- package/dist/cjs/components/tabbar/Tabbar.js +26 -26
- package/dist/cjs/components/tabs/Tabs.js +143 -153
- package/dist/cjs/components/tabs/tokens.js +3 -1
- package/dist/cjs/components/tag/Tag.js +38 -38
- package/dist/cjs/components/toast/Toast.js +3 -2
- package/dist/cjs/components/toast/tokens.js +1 -0
- package/dist/cjs/components/typography/Typography.js +23 -21
- package/dist/cjs/components/water-mark/WaterMark.js +65 -65
- package/dist/cjs/design-system/Text.js +38 -0
- package/dist/cjs/design-system/createComponentTokensHook.js +2 -2
- package/dist/cjs/design-system/index.js +7 -0
- package/dist/cjs/design-system/mergeTokensOverride.js +1 -4
- package/dist/cjs/hooks/useControllableValue.js +11 -11
- package/dist/cjs/hooks/useCountDown.js +18 -18
- package/dist/cjs/platform/measure.js +4 -2
- package/dist/cjs/utils/color.js +2 -7
- package/dist/cjs/utils/compare.js +3 -3
- package/dist/cjs/utils/date.js +2 -2
- package/dist/cjs/utils/deepMerge.js +5 -5
- package/dist/cjs/utils/hairline.js +1 -0
- package/dist/cjs/utils/render.js +2 -8
- package/dist/cjs/utils/validate.js +2 -4
- package/dist/es/components/action-sheet/ActionSheet.js +45 -51
- package/dist/es/components/area/Area.js +22 -22
- package/dist/es/components/avatar/Avatar.js +23 -23
- package/dist/es/components/badge/Badge.js +56 -61
- package/dist/es/components/button/Button.js +87 -92
- package/dist/es/components/button/ButtonGroup.js +4 -4
- package/dist/es/components/calendar/Calendar.js +28 -28
- package/dist/es/components/cascader/Cascader.js +205 -212
- package/dist/es/components/cell/Cell.js +55 -52
- package/dist/es/components/cell/CellGroup.js +26 -25
- package/dist/es/components/checkbox/Checkbox.js +1 -0
- package/dist/es/components/checkbox/CheckboxGroup.js +20 -19
- package/dist/es/components/circle/Circle.js +66 -54
- package/dist/es/components/collapse/Collapse.js +18 -18
- package/dist/es/components/config-provider/ConfigProvider.js +5 -5
- package/dist/es/components/count-down/CountDown.js +17 -17
- package/dist/es/components/datetime-picker/DatetimePicker.js +34 -35
- package/dist/es/components/dialog/Dialog.js +16 -10
- package/dist/es/components/dialog/imperative.js +8 -14
- package/dist/es/components/dialog/tokens.js +1 -0
- package/dist/es/components/divider/Divider.js +48 -51
- package/dist/es/components/empty/Empty.js +30 -25
- package/dist/es/components/error-boundary/ErrorBoundary.js +3 -2
- package/dist/es/components/flex/Flex.js +27 -27
- package/dist/es/components/flex/FlexItem.js +1 -0
- package/dist/es/components/form/Form.js +93 -92
- package/dist/es/components/form/FormItem.js +60 -54
- package/dist/es/components/form/FormList.js +35 -35
- package/dist/es/components/grid/Grid.js +48 -48
- package/dist/es/components/grid/GridItem.js +10 -3
- package/dist/es/components/image/Image.js +25 -24
- package/dist/es/components/image/tokens.js +3 -1
- package/dist/es/components/image-preview/ImagePreview.js +19 -19
- package/dist/es/components/image-preview/tokens.js +3 -1
- package/dist/es/components/input/Input.js +16 -19
- package/dist/es/components/loading/Loading.js +27 -27
- package/dist/es/components/nav-bar/NavBar.js +21 -18
- package/dist/es/components/nav-bar/tokens.js +3 -1
- package/dist/es/components/notice-bar/NoticeBar.js +7 -3
- package/dist/es/components/notice-bar/tokens.js +3 -1
- package/dist/es/components/notify/Notify.js +2 -1
- package/dist/es/components/notify/imperative.js +17 -17
- package/dist/es/components/notify/tokens.js +1 -0
- package/dist/es/components/number-keyboard/NumberKeyboard.js +217 -201
- package/dist/es/components/number-keyboard/tokens.js +7 -1
- package/dist/es/components/overlay/Overlay.js +15 -15
- package/dist/es/components/password-input/PasswordInput.js +49 -49
- package/dist/es/components/picker/Picker.js +50 -58
- package/dist/es/components/popup/Popup.js +10 -10
- package/dist/es/components/popup/tokens.js +1 -0
- package/dist/es/components/portal/Portal.js +3 -4
- package/dist/es/components/progress/Progress.js +94 -95
- package/dist/es/components/progress/tokens.js +1 -0
- package/dist/es/components/radio/Radio.js +67 -63
- package/dist/es/components/radio/RadioGroup.js +6 -6
- package/dist/es/components/safe-area-view/SafeAreaView.js +7 -7
- package/dist/es/components/search/Search.js +28 -28
- package/dist/es/components/selector/Selector.js +19 -26
- package/dist/es/components/share-sheet/ShareSheet.js +6 -1
- package/dist/es/components/share-sheet/tokens.js +3 -1
- package/dist/es/components/sidebar/Sidebar.js +22 -16
- package/dist/es/components/sidebar/SidebarItem.js +9 -8
- package/dist/es/components/sidebar/tokens.js +3 -1
- package/dist/es/components/skeleton/Skeleton.js +43 -42
- package/dist/es/components/space/Space.js +45 -41
- package/dist/es/components/space/tokens.js +7 -1
- package/dist/es/components/stepper/Stepper.js +17 -15
- package/dist/es/components/stepper/tokens.js +1 -0
- package/dist/es/components/swiper/Swiper.js +11 -8
- package/dist/es/components/swiper/SwiperPagIndicator.js +3 -2
- package/dist/es/components/switch/Switch.js +23 -23
- package/dist/es/components/tabbar/Tabbar.js +26 -26
- package/dist/es/components/tabs/Tabs.js +144 -154
- package/dist/es/components/tabs/tokens.js +3 -1
- package/dist/es/components/tag/Tag.js +38 -38
- package/dist/es/components/toast/Toast.js +3 -2
- package/dist/es/components/toast/tokens.js +1 -0
- package/dist/es/components/typography/Typography.js +23 -21
- package/dist/es/components/water-mark/WaterMark.js +65 -65
- package/dist/es/design-system/Text.js +19 -0
- package/dist/es/design-system/createComponentTokensHook.js +2 -2
- package/dist/es/design-system/index.js +1 -0
- package/dist/es/design-system/mergeTokensOverride.js +1 -4
- package/dist/es/hooks/useControllableValue.js +11 -11
- package/dist/es/hooks/useCountDown.js +18 -18
- package/dist/es/platform/measure.js +4 -2
- package/dist/es/utils/color.js +1 -4
- package/dist/es/utils/compare.js +3 -3
- package/dist/es/utils/date.js +2 -2
- package/dist/es/utils/deepMerge.js +5 -5
- package/dist/es/utils/hairline.js +1 -0
- package/dist/es/utils/render.js +1 -1
- package/dist/es/utils/validate.js +1 -2
- package/dist/types/components/dialog/tokens.d.ts +1 -0
- package/dist/types/components/image-preview/tokens.d.ts +1 -0
- package/dist/types/components/nav-bar/tokens.d.ts +1 -1
- package/dist/types/components/notice-bar/tokens.d.ts +1 -0
- package/dist/types/components/number-keyboard/tokens.d.ts +5 -0
- package/dist/types/components/picker/Picker.d.ts +1 -1
- package/dist/types/components/popup/tokens.d.ts +1 -0
- package/dist/types/components/share-sheet/tokens.d.ts +1 -0
- package/dist/types/components/stepper/tokens.d.ts +1 -0
- package/dist/types/components/tabs/tokens.d.ts +1 -0
- package/dist/types/components/toast/tokens.d.ts +1 -0
- package/dist/types/design-system/Text.d.ts +3 -0
- package/dist/types/design-system/index.d.ts +1 -0
- package/dist/types/hooks/useCountDown.d.ts +1 -1
- package/dist/types/utils/color.d.ts +0 -2
- package/dist/types/utils/date.d.ts +1 -1
- package/dist/types/utils/render.d.ts +1 -1
- package/dist/types/utils/validate.d.ts +0 -1
- package/package.json +17 -3
|
@@ -19,11 +19,11 @@ const TypographyTextBaseInner = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
19
19
|
const {
|
|
20
20
|
tokensOverride,
|
|
21
21
|
children,
|
|
22
|
-
type:
|
|
23
|
-
color:
|
|
24
|
-
size:
|
|
22
|
+
type: typeP,
|
|
23
|
+
color: colorP,
|
|
24
|
+
size: sizeP,
|
|
25
25
|
level,
|
|
26
|
-
disabled:
|
|
26
|
+
disabled: disP,
|
|
27
27
|
delete: deleted,
|
|
28
28
|
underline,
|
|
29
29
|
center,
|
|
@@ -34,9 +34,9 @@ const TypographyTextBaseInner = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
34
34
|
...textProps
|
|
35
35
|
} = props;
|
|
36
36
|
const tokens = useTypographyTokens(tokensOverride);
|
|
37
|
-
const type =
|
|
38
|
-
const size =
|
|
39
|
-
const disabled =
|
|
37
|
+
const type = typeP ?? tokens.defaults.type;
|
|
38
|
+
const size = sizeP ?? tokens.defaults.size;
|
|
39
|
+
const disabled = disP ?? tokens.defaults.disabled;
|
|
40
40
|
const ellipsisRows = resolveEllipsisRows(ellipsis);
|
|
41
41
|
const ellipsisConfig = isEllipsisObject(ellipsis) ? ellipsis : undefined;
|
|
42
42
|
const [isTruncated, setIsTruncated] = useState(false);
|
|
@@ -48,13 +48,14 @@ const TypographyTextBaseInner = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
48
48
|
setIsTruncated(prev => prev === exceeded ? prev : exceeded);
|
|
49
49
|
}, [ellipsisRows, expanded]);
|
|
50
50
|
let resolvedColor = tokens.colors[type] ?? tokens.colors.default;
|
|
51
|
-
if (
|
|
52
|
-
const
|
|
53
|
-
resolvedColor = hasTypographyColorKey(tokens.colors,
|
|
51
|
+
if (colorP !== undefined && colorP !== null) {
|
|
52
|
+
const ck = String(colorP);
|
|
53
|
+
resolvedColor = hasTypographyColorKey(tokens.colors, ck) ? tokens.colors[ck] : ck;
|
|
54
54
|
}
|
|
55
|
+
;
|
|
55
56
|
const fontSize = level ? tokens.sizing.titles[level].fontSize : tokens.sizing.sizes[size];
|
|
56
57
|
const lineHeight = level ? tokens.sizing.titles[level].lineHeight : fontSize * tokens.sizing.lineHeightMultiplier;
|
|
57
|
-
const
|
|
58
|
+
const textDeco = underline && deleted ? 'underline line-through' : underline ? 'underline' : deleted ? 'line-through' : undefined;
|
|
58
59
|
const baseStyle = [{
|
|
59
60
|
color: resolvedColor,
|
|
60
61
|
fontSize,
|
|
@@ -62,12 +63,12 @@ const TypographyTextBaseInner = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
62
63
|
fontFamily: tokens.typography.fontFamily,
|
|
63
64
|
fontWeight: strong ? tokens.typography.weight.strong : tokens.typography.weight.regular,
|
|
64
65
|
includeFontPadding: false,
|
|
65
|
-
textDecorationLine,
|
|
66
|
+
textDecorationLine: textDeco,
|
|
66
67
|
textAlign: center ? 'center' : undefined,
|
|
67
68
|
opacity: disabled ? tokens.opacity.disabled : 1
|
|
68
69
|
}, style];
|
|
69
|
-
const
|
|
70
|
-
const
|
|
70
|
+
const hasActTxt = !!ellipsisConfig && (ellipsisConfig.expandText || ellipsisConfig.collapseText);
|
|
71
|
+
const showAct = hasActTxt && (isTruncated || expanded || isWeb);
|
|
71
72
|
const handleToggleEllipsis = useCallback(() => {
|
|
72
73
|
if (!ellipsisConfig) return;
|
|
73
74
|
setExpanded(prev => {
|
|
@@ -76,24 +77,24 @@ const TypographyTextBaseInner = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
76
77
|
return next;
|
|
77
78
|
});
|
|
78
79
|
}, [ellipsisConfig]);
|
|
79
|
-
const
|
|
80
|
-
const
|
|
80
|
+
const actLabel = !ellipsisConfig ? undefined : expanded ? ellipsisConfig.collapseText ?? ellipsisConfig.expandText : ellipsisConfig.expandText ?? ellipsisConfig.collapseText;
|
|
81
|
+
const actTxtStyle = {
|
|
81
82
|
color: tokens.colors.primary,
|
|
82
83
|
fontSize: tokens.sizing.sizes.sm,
|
|
83
84
|
fontWeight: tokens.typography.weight.medium,
|
|
84
85
|
marginLeft: tokens.sizing.actionMarginLeft,
|
|
85
86
|
includeFontPadding: false
|
|
86
87
|
};
|
|
87
|
-
const textStyle =
|
|
88
|
+
const textStyle = showAct ? [baseStyle, FLEX_SHRINK_STYLE] : baseStyle;
|
|
88
89
|
const textNode = /*#__PURE__*/React.createElement(Text, _extends({
|
|
89
90
|
ref: ref,
|
|
90
91
|
style: textStyle,
|
|
91
92
|
onPress: onPress,
|
|
92
93
|
numberOfLines: !expanded ? ellipsisRows : undefined,
|
|
93
94
|
ellipsizeMode: "tail",
|
|
94
|
-
onTextLayout:
|
|
95
|
+
onTextLayout: hasActTxt && ellipsisRows && !expanded && !isWeb ? handleTextLayout : undefined
|
|
95
96
|
}, textProps), children);
|
|
96
|
-
if (!
|
|
97
|
+
if (!showAct) return center ? /*#__PURE__*/React.createElement(View, {
|
|
97
98
|
style: tokens.layout.centerWrapper
|
|
98
99
|
}, textNode) : textNode;
|
|
99
100
|
const actionNode = /*#__PURE__*/React.createElement(View, {
|
|
@@ -101,8 +102,8 @@ const TypographyTextBaseInner = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
101
102
|
}, textNode, /*#__PURE__*/React.createElement(Text, {
|
|
102
103
|
onPress: handleToggleEllipsis,
|
|
103
104
|
suppressHighlighting: true,
|
|
104
|
-
style:
|
|
105
|
-
},
|
|
105
|
+
style: actTxtStyle
|
|
106
|
+
}, actLabel));
|
|
106
107
|
return center ? /*#__PURE__*/React.createElement(View, {
|
|
107
108
|
style: tokens.layout.centerWrapper
|
|
108
109
|
}, actionNode) : actionNode;
|
|
@@ -137,6 +138,7 @@ const TypographyLink = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
137
138
|
onPress(event);
|
|
138
139
|
return;
|
|
139
140
|
}
|
|
141
|
+
;
|
|
140
142
|
if (href) {
|
|
141
143
|
try {
|
|
142
144
|
await Linking.openURL(href);
|
|
@@ -8,7 +8,7 @@ const resolveNonNegativeNumber = (value, fallback) => Math.max(0, resolveFiniteN
|
|
|
8
8
|
const resolvePositiveNumber = (value, fallback) => Math.max(1, resolveFiniteNumber(value, fallback));
|
|
9
9
|
const WaterMarkImpl = props => {
|
|
10
10
|
const {
|
|
11
|
-
content:
|
|
11
|
+
content: contentP,
|
|
12
12
|
width,
|
|
13
13
|
height,
|
|
14
14
|
gapX,
|
|
@@ -19,8 +19,8 @@ const WaterMarkImpl = props => {
|
|
|
19
19
|
fontSize,
|
|
20
20
|
color,
|
|
21
21
|
opacity,
|
|
22
|
-
zIndex:
|
|
23
|
-
fullPage:
|
|
22
|
+
zIndex: zIdxP,
|
|
23
|
+
fullPage: fullP,
|
|
24
24
|
tokensOverride,
|
|
25
25
|
style,
|
|
26
26
|
onLayoutCalculated,
|
|
@@ -28,9 +28,9 @@ const WaterMarkImpl = props => {
|
|
|
28
28
|
...rest
|
|
29
29
|
} = props;
|
|
30
30
|
const tokens = useWaterMarkTokens(tokensOverride);
|
|
31
|
-
const content =
|
|
32
|
-
const zIndex = resolveFiniteNumber(
|
|
33
|
-
const fullPage =
|
|
31
|
+
const content = contentP ?? tokens.defaults.content;
|
|
32
|
+
const zIndex = resolveFiniteNumber(zIdxP, tokens.defaults.zIndex);
|
|
33
|
+
const fullPage = fullP ?? tokens.defaults.fullPage;
|
|
34
34
|
const window = useWindowDimensions();
|
|
35
35
|
const [layoutSize, setLayoutSize] = useState({
|
|
36
36
|
width: 0,
|
|
@@ -41,99 +41,99 @@ const WaterMarkImpl = props => {
|
|
|
41
41
|
height: 0
|
|
42
42
|
});
|
|
43
43
|
const size = fullPage ? window : layoutSize;
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
const rows = size.height ? Math.ceil(size.height /
|
|
56
|
-
const cols = size.width ? Math.ceil(size.width /
|
|
57
|
-
const
|
|
58
|
-
|
|
44
|
+
const rGapX = resolveNonNegativeNumber(gapX, tokens.defaults.gapX);
|
|
45
|
+
const rGapY = resolveNonNegativeNumber(gapY, tokens.defaults.gapY);
|
|
46
|
+
const rRotate = resolveFiniteNumber(rotate, tokens.defaults.rotate);
|
|
47
|
+
const rOpacity = Math.max(0, Math.min(1, resolveFiniteNumber(opacity, tokens.defaults.opacity)));
|
|
48
|
+
const fontSzFromFont = isFiniteNumber(font?.size) ? font.size : isString(font?.size) ? Number.parseFloat(font.size) : undefined;
|
|
49
|
+
const normFontSz = Math.max(0, resolveFiniteNumber((Number.isFinite(fontSzFromFont ?? Number.NaN) ? fontSzFromFont : undefined) ?? fontSize, tokens.defaults.fontSize));
|
|
50
|
+
const rColor = font?.color ?? color ?? tokens.colors.mark;
|
|
51
|
+
const markW = resolvePositiveNumber(image?.width ?? width, tokens.defaults.width);
|
|
52
|
+
const markH = resolvePositiveNumber(image?.height ?? height, tokens.defaults.height);
|
|
53
|
+
const cellW = Math.max(1, markW + rGapX);
|
|
54
|
+
const cellH = Math.max(1, markH + rGapY);
|
|
55
|
+
const rows = size.height ? Math.ceil(size.height / cellH) + 1 : 1;
|
|
56
|
+
const cols = size.width ? Math.ceil(size.width / cellW) + 1 : 1;
|
|
57
|
+
const onLayoutCalcRef = useRef(onLayoutCalculated);
|
|
58
|
+
onLayoutCalcRef.current = onLayoutCalculated;
|
|
59
59
|
const handleLayout = useCallback(event => {
|
|
60
60
|
if (fullPage) return;
|
|
61
61
|
const {
|
|
62
|
-
width,
|
|
63
|
-
height
|
|
62
|
+
width: w,
|
|
63
|
+
height: h
|
|
64
64
|
} = event.nativeEvent.layout;
|
|
65
|
-
if (!isFiniteNumber(
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
if (lastLayoutRef.current.width ===
|
|
65
|
+
if (!isFiniteNumber(w) || !isFiniteNumber(h)) return;
|
|
66
|
+
const nw = Math.max(0, w),
|
|
67
|
+
nh = Math.max(0, h);
|
|
68
|
+
if (lastLayoutRef.current.width === nw && lastLayoutRef.current.height === nh) return;
|
|
69
69
|
lastLayoutRef.current = {
|
|
70
|
-
width:
|
|
71
|
-
height:
|
|
70
|
+
width: nw,
|
|
71
|
+
height: nh
|
|
72
72
|
};
|
|
73
73
|
setLayoutSize({
|
|
74
|
-
width:
|
|
75
|
-
height:
|
|
74
|
+
width: nw,
|
|
75
|
+
height: nh
|
|
76
76
|
});
|
|
77
|
-
|
|
78
|
-
width:
|
|
79
|
-
height:
|
|
77
|
+
onLayoutCalcRef.current?.({
|
|
78
|
+
width: nw,
|
|
79
|
+
height: nh
|
|
80
80
|
});
|
|
81
81
|
}, [fullPage]);
|
|
82
82
|
useEffect(() => {
|
|
83
83
|
if (!fullPage || !isFiniteNumber(window.width) || !isFiniteNumber(window.height) || window.width <= 0 || window.height <= 0) return;
|
|
84
|
-
|
|
84
|
+
onLayoutCalcRef.current?.({
|
|
85
85
|
width: window.width,
|
|
86
86
|
height: window.height
|
|
87
87
|
});
|
|
88
88
|
}, [fullPage, window.width, window.height]);
|
|
89
|
-
const
|
|
89
|
+
const zIdxStyle = useMemo(() => ({
|
|
90
90
|
zIndex
|
|
91
91
|
}), [zIndex]);
|
|
92
92
|
const cellStyle = useMemo(() => ({
|
|
93
|
-
width:
|
|
94
|
-
height:
|
|
95
|
-
}), [
|
|
93
|
+
width: cellW,
|
|
94
|
+
height: cellH
|
|
95
|
+
}), [cellW, cellH]);
|
|
96
96
|
const oddRowStyle = useMemo(() => ({
|
|
97
|
-
paddingLeft:
|
|
98
|
-
}), [
|
|
97
|
+
paddingLeft: cellW / 2
|
|
98
|
+
}), [cellW]);
|
|
99
99
|
const markStyle = useMemo(() => ({
|
|
100
|
-
width:
|
|
101
|
-
height:
|
|
100
|
+
width: markW,
|
|
101
|
+
height: markH,
|
|
102
102
|
transform: [{
|
|
103
|
-
rotate: `${
|
|
103
|
+
rotate: `${rRotate}deg`
|
|
104
104
|
}]
|
|
105
|
-
}), [
|
|
106
|
-
const
|
|
107
|
-
width:
|
|
108
|
-
height:
|
|
109
|
-
opacity:
|
|
110
|
-
}), [
|
|
111
|
-
const
|
|
112
|
-
fontSize:
|
|
113
|
-
color:
|
|
114
|
-
opacity:
|
|
105
|
+
}), [markW, markH, rRotate]);
|
|
106
|
+
const imgStyle = useMemo(() => ({
|
|
107
|
+
width: markW,
|
|
108
|
+
height: markH,
|
|
109
|
+
opacity: rOpacity
|
|
110
|
+
}), [markW, markH, rOpacity]);
|
|
111
|
+
const txtBaseStyle = useMemo(() => ({
|
|
112
|
+
fontSize: normFontSz,
|
|
113
|
+
color: rColor,
|
|
114
|
+
opacity: rOpacity,
|
|
115
115
|
fontFamily: font?.family,
|
|
116
116
|
fontWeight: font?.weight
|
|
117
|
-
}), [
|
|
118
|
-
const
|
|
117
|
+
}), [normFontSz, rColor, rOpacity, font?.family, font?.weight]);
|
|
118
|
+
const rowIdx = Array.from({
|
|
119
119
|
length: rows
|
|
120
120
|
}, (_, i) => i);
|
|
121
|
-
const
|
|
121
|
+
const colIdx = Array.from({
|
|
122
122
|
length: cols
|
|
123
123
|
}, (_, i) => i);
|
|
124
124
|
return /*#__PURE__*/React.createElement(View, _extends({
|
|
125
125
|
pointerEvents: "none",
|
|
126
126
|
importantForAccessibility: "no-hide-descendants",
|
|
127
127
|
accessibilityElementsHidden: true,
|
|
128
|
-
style: [fullPage ? tokens.layout.absoluteFill : null,
|
|
128
|
+
style: [fullPage ? tokens.layout.absoluteFill : null, zIdxStyle, style],
|
|
129
129
|
onLayout: handleLayout
|
|
130
130
|
}, rest), /*#__PURE__*/React.createElement(View, {
|
|
131
131
|
style: tokens.layout.wrapper
|
|
132
|
-
},
|
|
133
|
-
key: `row-${
|
|
134
|
-
style: [tokens.layout.row,
|
|
135
|
-
},
|
|
136
|
-
key: `col-${
|
|
132
|
+
}, rowIdx.map(ri => /*#__PURE__*/React.createElement(View, {
|
|
133
|
+
key: `row-${ri}`,
|
|
134
|
+
style: [tokens.layout.row, ri % 2 === 0 ? null : oddRowStyle]
|
|
135
|
+
}, colIdx.map(ci => /*#__PURE__*/React.createElement(View, {
|
|
136
|
+
key: `col-${ri}-${ci}`,
|
|
137
137
|
style: [tokens.layout.cell, cellStyle]
|
|
138
138
|
}, /*#__PURE__*/React.createElement(View, {
|
|
139
139
|
style: [tokens.layout.mark, markStyle]
|
|
@@ -141,11 +141,11 @@ const WaterMarkImpl = props => {
|
|
|
141
141
|
source: {
|
|
142
142
|
uri: image.src
|
|
143
143
|
},
|
|
144
|
-
style:
|
|
144
|
+
style: imgStyle,
|
|
145
145
|
resizeMode: "contain"
|
|
146
146
|
}) : /*#__PURE__*/React.createElement(Text, {
|
|
147
147
|
allowFontScaling: false,
|
|
148
|
-
style: [
|
|
148
|
+
style: [txtBaseStyle, textStyle]
|
|
149
149
|
}, content))))))));
|
|
150
150
|
};
|
|
151
151
|
const WaterMark = /*#__PURE__*/React.memo(WaterMarkImpl);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Text as RNText } from 'react-native';
|
|
4
|
+
import { useTheme } from './useTheme';
|
|
5
|
+
export const Text = /*#__PURE__*/React.forwardRef(({
|
|
6
|
+
style,
|
|
7
|
+
...rest
|
|
8
|
+
}, ref) => {
|
|
9
|
+
const {
|
|
10
|
+
foundations
|
|
11
|
+
} = useTheme();
|
|
12
|
+
return /*#__PURE__*/React.createElement(RNText, _extends({
|
|
13
|
+
ref: ref,
|
|
14
|
+
style: [{
|
|
15
|
+
fontFamily: foundations.typography.fontFamily
|
|
16
|
+
}, style]
|
|
17
|
+
}, rest));
|
|
18
|
+
});
|
|
19
|
+
Text.displayName = 'Text';
|
|
@@ -9,7 +9,7 @@ export const createComponentTokensHook = (key, createBaseTokens) => overrides =>
|
|
|
9
9
|
const co = components?.[key];
|
|
10
10
|
return useMemo(() => {
|
|
11
11
|
const base = createBaseTokens(foundations);
|
|
12
|
-
const
|
|
13
|
-
return
|
|
12
|
+
const m = co && overrides ? deepMerge(co, overrides) : co ?? overrides;
|
|
13
|
+
return m ? deepMerge(base, m) : base;
|
|
14
14
|
}, [co, foundations, overrides]);
|
|
15
15
|
};
|
|
@@ -1,5 +1,2 @@
|
|
|
1
1
|
import { deepMerge } from '../utils/deepMerge';
|
|
2
|
-
export const mergeTokensOverride = (base, override) =>
|
|
3
|
-
if (base && override) return deepMerge(base, override);
|
|
4
|
-
return base ?? override;
|
|
5
|
-
};
|
|
2
|
+
export const mergeTokensOverride = (base, override) => base && override ? deepMerge(base, override) : base ?? override;
|
|
@@ -9,21 +9,21 @@ function useControllableValue(props = {}, options = {}) {
|
|
|
9
9
|
trigger = 'onChange'
|
|
10
10
|
} = options;
|
|
11
11
|
const p = props;
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const [
|
|
15
|
-
if (
|
|
12
|
+
const ctrl = hasProp(props, valuePropName);
|
|
13
|
+
const val = p[valuePropName];
|
|
14
|
+
const [intVal, setIntVal] = useState(() => {
|
|
15
|
+
if (ctrl) return val;
|
|
16
16
|
if (hasProp(props, defaultValuePropName)) return p[defaultValuePropName];
|
|
17
17
|
return defaultValue;
|
|
18
18
|
});
|
|
19
|
-
const
|
|
19
|
+
const hRef = useRef(p[trigger]);
|
|
20
20
|
useEffect(() => {
|
|
21
|
-
|
|
21
|
+
hRef.current = p[trigger];
|
|
22
22
|
}, [props, trigger]);
|
|
23
|
-
const
|
|
24
|
-
if (!
|
|
25
|
-
if (isFunction(
|
|
26
|
-
}, [
|
|
27
|
-
return [
|
|
23
|
+
const setVal = useCallback((next, ...args) => {
|
|
24
|
+
if (!ctrl) setIntVal(next);
|
|
25
|
+
if (isFunction(hRef.current)) hRef.current(next, ...args);
|
|
26
|
+
}, [ctrl]);
|
|
27
|
+
return [ctrl ? val : intVal, setVal];
|
|
28
28
|
}
|
|
29
29
|
export default useControllableValue;
|
|
@@ -31,31 +31,31 @@ const useCountDown = options => {
|
|
|
31
31
|
const timerRef = useRef(null);
|
|
32
32
|
const countingRef = useRef(false);
|
|
33
33
|
const [current, setCurrent] = useState(() => parseTime(remainRef.current));
|
|
34
|
-
const
|
|
34
|
+
const clear = useCallback(() => {
|
|
35
35
|
if (timerRef.current) {
|
|
36
36
|
clearTimeout(timerRef.current);
|
|
37
37
|
timerRef.current = null;
|
|
38
38
|
}
|
|
39
39
|
}, []);
|
|
40
|
-
const update = useCallback(
|
|
41
|
-
remainRef.current =
|
|
42
|
-
const next = parseTime(
|
|
40
|
+
const update = useCallback(rem => {
|
|
41
|
+
remainRef.current = rem;
|
|
42
|
+
const next = parseTime(rem);
|
|
43
43
|
setCurrent(next);
|
|
44
44
|
onChangeRef.current?.(next);
|
|
45
|
-
if (
|
|
45
|
+
if (rem === 0) {
|
|
46
46
|
countingRef.current = false;
|
|
47
|
-
|
|
47
|
+
clear();
|
|
48
48
|
onFinishRef.current?.();
|
|
49
49
|
}
|
|
50
|
-
}, [
|
|
50
|
+
}, [clear]);
|
|
51
51
|
const tick = useCallback(() => {
|
|
52
52
|
if (!countingRef.current) return;
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
update(
|
|
56
|
-
if (
|
|
57
|
-
timerRef.current = setTimeout(tick, msRef.current ? Math.max(1, Math.min(30,
|
|
58
|
-
}, [
|
|
53
|
+
clear();
|
|
54
|
+
const rem = Math.max(endTimeRef.current - Date.now(), 0);
|
|
55
|
+
update(rem);
|
|
56
|
+
if (rem <= 0) return;
|
|
57
|
+
timerRef.current = setTimeout(tick, msRef.current ? Math.max(1, Math.min(30, rem)) : Math.max(1, Math.min(rem, rem % 1000 + 1)));
|
|
58
|
+
}, [clear, update]);
|
|
59
59
|
const start = useCallback(() => {
|
|
60
60
|
if (countingRef.current || remainRef.current <= 0) return;
|
|
61
61
|
countingRef.current = true;
|
|
@@ -66,16 +66,16 @@ const useCountDown = options => {
|
|
|
66
66
|
if (!countingRef.current) return;
|
|
67
67
|
countingRef.current = false;
|
|
68
68
|
remainRef.current = Math.max(endTimeRef.current - Date.now(), 0);
|
|
69
|
-
|
|
70
|
-
}, [
|
|
71
|
-
const reset = useCallback(
|
|
69
|
+
clear();
|
|
70
|
+
}, [clear]);
|
|
71
|
+
const reset = useCallback(newT => {
|
|
72
72
|
pause();
|
|
73
|
-
const n = Math.max(0, isNumber(
|
|
73
|
+
const n = Math.max(0, isNumber(newT) ? newT : timeRef.current);
|
|
74
74
|
remainRef.current = n;
|
|
75
75
|
endTimeRef.current = Date.now() + n;
|
|
76
76
|
setCurrent(parseTime(n));
|
|
77
77
|
}, [pause]);
|
|
78
|
-
useEffect(() => () =>
|
|
78
|
+
useEffect(() => () => clear(), [clear]);
|
|
79
79
|
return {
|
|
80
80
|
start,
|
|
81
81
|
pause,
|
|
@@ -10,21 +10,23 @@ export const measureInWindow = (node, cb) => {
|
|
|
10
10
|
cb(null);
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
|
+
;
|
|
13
14
|
try {
|
|
14
15
|
const mn = node;
|
|
15
16
|
if (isFunction(mn.measureInWindow)) {
|
|
16
17
|
mn.measureInWindow((x, y, w, h) => cb(toRect(x, y, w, h)));
|
|
17
18
|
return;
|
|
18
19
|
}
|
|
20
|
+
;
|
|
19
21
|
const dn = node;
|
|
20
22
|
if (isFunction(dn.getBoundingClientRect)) {
|
|
21
23
|
const r = dn.getBoundingClientRect();
|
|
22
24
|
cb(toRect(r?.left, r?.top, r?.width, r?.height));
|
|
23
25
|
return;
|
|
24
26
|
}
|
|
27
|
+
;
|
|
28
|
+
cb(null);
|
|
25
29
|
} catch {
|
|
26
30
|
cb(null);
|
|
27
|
-
return;
|
|
28
31
|
}
|
|
29
|
-
cb(null);
|
|
30
32
|
};
|
package/dist/es/utils/color.js
CHANGED
|
@@ -22,7 +22,4 @@ export const withAlpha = (color, alpha) => {
|
|
|
22
22
|
}
|
|
23
23
|
const rgb = parseRgb(t);
|
|
24
24
|
return rgb ? `rgba(${rgb[0]}, ${rgb[1]}, ${rgb[2]}, ${a})` : t;
|
|
25
|
-
};
|
|
26
|
-
export const ensureRgba = (color, alpha) => color.trim().toLowerCase().startsWith('rgba') ? color : withAlpha(color, alpha);
|
|
27
|
-
const GRADIENT_RE = /(#[0-9a-fA-F]{3,8}|rgba?\([^)]*\)|hsla?\([^)]*\))/i;
|
|
28
|
-
export const extractFirstColorToken = input => input ? input.match(GRADIENT_RE)?.[0] : undefined;
|
|
25
|
+
};
|
package/dist/es/utils/compare.js
CHANGED
|
@@ -6,8 +6,8 @@ export const shallowEqualArray = (a = [], b = []) => {
|
|
|
6
6
|
export const shallowEqualObject = (a, b) => {
|
|
7
7
|
if (a === b) return true;
|
|
8
8
|
if (!a || !b) return false;
|
|
9
|
-
const
|
|
10
|
-
if (
|
|
11
|
-
for (const k of
|
|
9
|
+
const ks = Object.keys(a);
|
|
10
|
+
if (ks.length !== Object.keys(b).length) return false;
|
|
11
|
+
for (const k of ks) if (a[k] !== b[k]) return false;
|
|
12
12
|
return true;
|
|
13
13
|
};
|
package/dist/es/utils/date.js
CHANGED
|
@@ -12,7 +12,7 @@ export const getTrueValue = value => {
|
|
|
12
12
|
};
|
|
13
13
|
export const getMonthEndDay = (year, month) => 32 - new Date(year, month - 1, 32).getDate();
|
|
14
14
|
export const isValidDate = value => value instanceof Date && !Number.isNaN(value.getTime());
|
|
15
|
-
export const formatDuration = (
|
|
15
|
+
export const formatDuration = (fmt, time) => {
|
|
16
16
|
let {
|
|
17
17
|
days,
|
|
18
18
|
hours,
|
|
@@ -20,7 +20,7 @@ export const formatDuration = (format, time) => {
|
|
|
20
20
|
seconds,
|
|
21
21
|
milliseconds
|
|
22
22
|
} = time;
|
|
23
|
-
let t =
|
|
23
|
+
let t = fmt;
|
|
24
24
|
if (t.includes('DD')) t = t.replace('DD', padZero(days));else hours += days * 24;
|
|
25
25
|
if (t.includes('HH')) t = t.replace('HH', padZero(hours));else minutes += hours * 60;
|
|
26
26
|
if (t.includes('mm')) t = t.replace('mm', padZero(minutes));else seconds += minutes * 60;
|
|
@@ -5,15 +5,15 @@ export function deepMerge(target, source) {
|
|
|
5
5
|
const out = Array.isArray(target) ? [...target] : {
|
|
6
6
|
...target
|
|
7
7
|
};
|
|
8
|
-
for (const
|
|
9
|
-
const sv = source[
|
|
8
|
+
for (const k of Object.keys(source)) {
|
|
9
|
+
const sv = source[k];
|
|
10
10
|
if (sv === undefined) continue;
|
|
11
|
-
const tv = target[
|
|
11
|
+
const tv = target[k];
|
|
12
12
|
if (isPlainObject(tv) && isPlainObject(sv)) {
|
|
13
|
-
out[
|
|
13
|
+
out[k] = deepMerge(tv, sv);
|
|
14
14
|
continue;
|
|
15
15
|
}
|
|
16
|
-
out[
|
|
16
|
+
out[k] = Array.isArray(sv) ? [...sv] : isPlainObject(sv) ? {
|
|
17
17
|
...sv
|
|
18
18
|
} : sv;
|
|
19
19
|
}
|
package/dist/es/utils/render.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { Text } from '
|
|
3
|
+
import { Text } from '../design-system';
|
|
4
4
|
import { isText } from './validate';
|
|
5
5
|
export const renderTextOrNode = (content, textStyle, textProps) => isText(content) ? /*#__PURE__*/React.createElement(Text, _extends({
|
|
6
6
|
style: textStyle
|
|
@@ -11,5 +11,4 @@ export const isUndefined = val => typeof val === 'undefined';
|
|
|
11
11
|
export const isObject = val => val !== null && typeof val === 'object';
|
|
12
12
|
export const isValidNode = node => isRenderable(node) && (typeof node !== 'string' || node.length > 0);
|
|
13
13
|
export const isPlainObject = val => !!val && typeof val === 'object' && !Array.isArray(val) && ! /*#__PURE__*/isValidElement(val);
|
|
14
|
-
export const isTwoCNChar = value => /^(?:[\u4e00-\u9fa5]){2}$/.test(value);
|
|
15
|
-
export const isImageUrlString = url => /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i.test(url);
|
|
14
|
+
export const isTwoCNChar = value => /^(?:[\u4e00-\u9fa5]){2}$/.test(value);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type Foundations } from '../../design-system/tokens';
|
|
2
2
|
import type { NavBarTokens } from './types';
|
|
3
|
-
export declare const createNavBarTokens: ({ palette, spacing, fontSize, }: Foundations) => NavBarTokens;
|
|
3
|
+
export declare const createNavBarTokens: ({ palette, spacing, fontSize, typography, }: Foundations) => NavBarTokens;
|
|
4
4
|
export declare const useNavBarTokens: (overrides?: import("../..").DeepPartial<NavBarTokens> | undefined) => NavBarTokens;
|
|
@@ -21,8 +21,13 @@ export interface NumberKeyboardTokens {
|
|
|
21
21
|
keyHeight: number;
|
|
22
22
|
closeHeight: number;
|
|
23
23
|
fontSize: number;
|
|
24
|
+
defaultIconFontSize?: number;
|
|
25
|
+
auxFontSize?: number;
|
|
24
26
|
titleFontSize: number;
|
|
25
27
|
};
|
|
28
|
+
typography: {
|
|
29
|
+
fontFamily: string;
|
|
30
|
+
};
|
|
26
31
|
radii: {
|
|
27
32
|
key: number;
|
|
28
33
|
};
|
|
@@ -15,7 +15,7 @@ export declare const toArrayValue: (value?: PickerValue[] | PickerValue | null)
|
|
|
15
15
|
export declare const findEnabledIndex: (options: PickerOption[], startIdx: number) => number;
|
|
16
16
|
export declare const prepareColumns: (input?: PickerColumns) => PreparedPickerColumns;
|
|
17
17
|
export declare const normalizePicker: (prep: PreparedPickerColumns, raw?: PickerValue[]) => NormalizedPickerResult;
|
|
18
|
-
export declare function usePickerValue({ columns, valueProp, defaultValue, emitConfirmOnAutoSelect, onChange, onConfirm
|
|
18
|
+
export declare function usePickerValue({ columns, valueProp, defaultValue, emitConfirmOnAutoSelect, onChange, onConfirm }: {
|
|
19
19
|
columns?: PickerColumns;
|
|
20
20
|
valueProp?: PickerProps['value'];
|
|
21
21
|
defaultValue?: PickerProps['defaultValue'];
|