@flipova/foundation 1.13.0 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +181 -0
- package/README.md +53 -178
- package/components/ui/accordion/ANIMATION_CUSTOMIZATION.md +162 -0
- package/components/ui/accordion/AccordionAnimatedHeight.tsx +56 -0
- package/components/ui/accordion/AccordionAnimatedIcon.tsx +41 -0
- package/components/ui/accordion/AnimatedHeight.tsx +56 -0
- package/components/ui/accordion/AnimatedIcon.tsx +41 -0
- package/components/ui/accordion/MIGRATION_SUMMARY.md +250 -0
- package/components/ui/accordion/USAGE_EXAMPLE.tsx +179 -0
- package/components/ui/accordion/animation-config.ts +32 -0
- package/components/ui/accordion/index.tsx +253 -0
- package/components/ui/actionsheet/index.tsx +511 -0
- package/components/ui/alert/index.tsx +158 -0
- package/components/ui/alert-dialog/index.tsx +254 -0
- package/components/ui/avatar/index.tsx +139 -0
- package/components/ui/badge/index.tsx +163 -0
- package/components/ui/bottomsheet/index.tsx +477 -0
- package/components/ui/box/index.tsx +19 -0
- package/components/ui/box/index.web.tsx +19 -0
- package/components/ui/box/styles.tsx +10 -0
- package/components/ui/button/index.tsx +264 -0
- package/components/ui/calendar/creator.tsx +366 -0
- package/components/ui/calendar/index.tsx +462 -0
- package/components/ui/calendar/styles.tsx +140 -0
- package/components/ui/card/index.tsx +23 -0
- package/components/ui/card/index.web.tsx +26 -0
- package/components/ui/card/styles.tsx +16 -0
- package/components/ui/center/index.tsx +22 -0
- package/components/ui/center/index.web.tsx +20 -0
- package/components/ui/center/styles.tsx +8 -0
- package/components/ui/checkbox/index.tsx +184 -0
- package/components/ui/date-time-picker/creator.tsx +109 -0
- package/components/ui/date-time-picker/index.tsx +585 -0
- package/components/ui/date-time-picker/index.web.tsx +217 -0
- package/components/ui/date-time-picker/styles.tsx +56 -0
- package/components/ui/divider/index.tsx +40 -0
- package/components/ui/drawer/index.tsx +362 -0
- package/components/ui/fab/index.tsx +215 -0
- package/components/ui/flat-list/index.tsx +21 -0
- package/components/ui/form-control/index.tsx +352 -0
- package/components/ui/gluestack-ui-provider/config.ts +72 -0
- package/components/ui/gluestack-ui-provider/index.tsx +47 -0
- package/components/ui/gluestack-ui-provider/index.web.tsx +96 -0
- package/components/ui/gluestack-ui-provider/script.ts +19 -0
- package/components/ui/gluestack-ui-provider/tokens.d.ts +17 -0
- package/components/ui/gluestack-ui-provider/tokens.js +188 -0
- package/components/ui/gluestack-ui-provider/useGluestackColors.ts +82 -0
- package/components/ui/grid/index.tsx +283 -0
- package/components/ui/grid/index.web.tsx +66 -0
- package/components/ui/grid/styles.tsx +15 -0
- package/components/ui/heading/index.tsx +220 -0
- package/components/ui/heading/index.web.tsx +202 -0
- package/components/ui/heading/styles.tsx +43 -0
- package/components/ui/hstack/index.tsx +27 -0
- package/components/ui/hstack/index.web.tsx +26 -0
- package/components/ui/hstack/styles.tsx +25 -0
- package/components/ui/icon/index.tsx +1588 -0
- package/components/ui/icon/index.web.tsx +1573 -0
- package/components/ui/image/index.tsx +48 -0
- package/components/ui/image-background/index.tsx +25 -0
- package/components/ui/image-viewer/index.tsx +743 -0
- package/components/ui/image-viewer/index.web.tsx +302 -0
- package/components/ui/index.ts +58 -0
- package/components/ui/input/index.tsx +125 -0
- package/components/ui/input-accessory-view/index.tsx +2 -0
- package/components/ui/keyboard-avoiding-view/index.tsx +2 -0
- package/components/ui/link/index.tsx +102 -0
- package/components/ui/liquid-glass/index.tsx +74 -0
- package/components/ui/menu/index.tsx +186 -0
- package/components/ui/modal/index.tsx +237 -0
- package/components/ui/popover/index.tsx +272 -0
- package/components/ui/portal/index.tsx +17 -0
- package/components/ui/pressable/index.tsx +39 -0
- package/components/ui/progress/index.tsx +83 -0
- package/components/ui/radio/index.tsx +217 -0
- package/components/ui/refresh-control/index.tsx +2 -0
- package/components/ui/safe-area-view/index.tsx +2 -0
- package/components/ui/scroll-view/index.tsx +2 -0
- package/components/ui/section-list/index.tsx +2 -0
- package/components/ui/select/index.tsx +277 -0
- package/components/ui/select/select-actionsheet.tsx +562 -0
- package/components/ui/skeleton/index.tsx +105 -0
- package/components/ui/skeleton/index.web.tsx +103 -0
- package/components/ui/skeleton/styles.tsx +35 -0
- package/components/ui/slider/index.tsx +181 -0
- package/components/ui/spinner/index.tsx +40 -0
- package/components/ui/status-bar/index.tsx +2 -0
- package/components/ui/switch/index.tsx +41 -0
- package/components/ui/table/index.tsx +210 -0
- package/components/ui/table/index.web.tsx +157 -0
- package/components/ui/table/styles.tsx +44 -0
- package/components/ui/tabs/TabsAnimatedIndicator.tsx +160 -0
- package/components/ui/tabs/animation-config.ts +3 -0
- package/components/ui/tabs/creator.tsx +206 -0
- package/components/ui/tabs/index.tsx +484 -0
- package/components/ui/text/index.tsx +48 -0
- package/components/ui/text/index.web.tsx +45 -0
- package/components/ui/text/styles.tsx +47 -0
- package/components/ui/textarea/index.tsx +94 -0
- package/components/ui/toast/index.tsx +252 -0
- package/components/ui/tooltip/index.tsx +131 -0
- package/components/ui/view/index.tsx +2 -0
- package/components/ui/virtualized-list/index.tsx +2 -0
- package/components/ui/vstack/index.tsx +28 -0
- package/components/ui/vstack/index.web.tsx +27 -0
- package/components/ui/vstack/styles.tsx +25 -0
- package/design/canonical.index.txt +53 -0
- package/design/documentation.xml +519 -0
- package/design/manifest.xml +90 -0
- package/design/schema.xsd +639 -0
- package/design/themes.xml +204 -0
- package/design/tokens.xml +510 -0
- package/design/tools/design.js +165 -0
- package/design/tools/npm.js +65 -0
- package/design/tools/requirements.txt +35 -0
- package/design/tools/sources/.checker/__init__.py +81 -0
- package/design/tools/sources/.checker/checks.py +198 -0
- package/design/tools/sources/.checker/cli.py +154 -0
- package/design/tools/sources/.checker/io.py +242 -0
- package/design/tools/sources/.checker/model.py +144 -0
- package/design/tools/sources/.checker/registry.py +115 -0
- package/design/tools/sources/.checker/report.py +21 -0
- package/design/tools/sources/.docgen/__init__.py +45 -0
- package/design/tools/sources/.docgen/cli.py +101 -0
- package/design/tools/sources/.docgen/model.py +147 -0
- package/design/tools/sources/.docgen/reference.py +97 -0
- package/design/tools/sources/.docgen/site.py +145 -0
- package/design/tools/sources/.docgen/xsddoc.py +329 -0
- package/design/tools/sources/.generate/__init__.py +35 -0
- package/design/tools/sources/.generate/cli.py +76 -0
- package/design/tools/sources/.generate/common.py +33 -0
- package/design/tools/sources/.generate/config.py +119 -0
- package/design/tools/sources/.generate/model.py +51 -0
- package/design/tools/sources/.generate/tokens.py +141 -0
- package/design/tools/sources/.linter/__init__.py +9 -0
- package/design/tools/sources/.linter/cli.py +44 -0
- package/design/tools/sources/.linter/discovery.py +30 -0
- package/design/tools/sources/.linter/errors.py +45 -0
- package/design/tools/sources/.linter/linter.py +68 -0
- package/design/tools/sources/.xmleditor/__init__.py +74 -0
- package/design/tools/sources/.xmleditor/blocks.py +185 -0
- package/design/tools/sources/.xmleditor/cli.py +141 -0
- package/design/tools/sources/.xmleditor/editor.py +906 -0
- package/design/tools/sources/.xmleditor/model.py +708 -0
- package/design/tools/sources/.xmleditor/widgets.py +1832 -0
- package/design/tools/sources/.xmleditor/xsdmodel.py +753 -0
- package/design/tools/sources/checker.py +55 -0
- package/design/tools/sources/docgen.py +66 -0
- package/design/tools/sources/generate.py +48 -0
- package/design/tools/sources/linter.py +54 -0
- package/design/tools/sources/ruff.toml +12 -0
- package/design/tools/sources/xmleditor.py +62 -0
- package/design/tools/unix/_venv_python.sh +16 -0
- package/design/tools/unix/check.sh +13 -0
- package/design/tools/unix/doc.sh +14 -0
- package/design/tools/unix/gen.sh +14 -0
- package/design/tools/unix/lint.sh +10 -0
- package/design/tools/unix/run.sh +20 -0
- package/design/tools/unix/verify.sh +12 -0
- package/design/tools/unix/xmledit.sh +12 -0
- package/design/tools/windows/check.cmd +12 -0
- package/design/tools/windows/doc.cmd +12 -0
- package/design/tools/windows/gen.cmd +11 -0
- package/design/tools/windows/lint.cmd +9 -0
- package/design/tools/windows/run.cmd +26 -0
- package/design/tools/windows/verify.cmd +10 -0
- package/design/tools/windows/xmledit.cmd +10 -0
- package/dist/chunk-LV4UIEQN.js +9730 -0
- package/dist/chunk-LV4UIEQN.js.map +1 -0
- package/dist/chunk-WNVU3BM2.mjs +9401 -0
- package/dist/chunk-WNVU3BM2.mjs.map +1 -0
- package/dist/index.d.mts +40 -9
- package/dist/index.d.ts +40 -9
- package/dist/index.js +726 -414
- package/dist/index.mjs +1 -5
- package/dist/ui/index.d.mts +6931 -3070
- package/dist/ui/index.d.ts +6931 -3070
- package/dist/ui/index.js +779 -352
- package/dist/ui/index.mjs +1 -2
- package/package.json +66 -142
- package/dist/chunk-2XORADW6.js +0 -24552
- package/dist/chunk-2XORADW6.js.map +0 -1
- package/dist/chunk-52BHHF5M.js +0 -46
- package/dist/chunk-52BHHF5M.js.map +0 -1
- package/dist/chunk-5647JY7Z.mjs +0 -100
- package/dist/chunk-5647JY7Z.mjs.map +0 -1
- package/dist/chunk-5N5HC4ZA.mjs +0 -3
- package/dist/chunk-5N5HC4ZA.mjs.map +0 -1
- package/dist/chunk-7QFZMGL6.js +0 -8583
- package/dist/chunk-7QFZMGL6.js.map +0 -1
- package/dist/chunk-ASZEP37D.js +0 -423
- package/dist/chunk-ASZEP37D.js.map +0 -1
- package/dist/chunk-BH5SU2JQ.mjs +0 -8282
- package/dist/chunk-BH5SU2JQ.mjs.map +0 -1
- package/dist/chunk-BO65GO53.mjs +0 -422
- package/dist/chunk-BO65GO53.mjs.map +0 -1
- package/dist/chunk-BSVXX52E.mjs +0 -413
- package/dist/chunk-BSVXX52E.mjs.map +0 -1
- package/dist/chunk-DNV5UBNF.mjs +0 -3
- package/dist/chunk-DNV5UBNF.mjs.map +0 -1
- package/dist/chunk-EDTAMUO2.js +0 -8310
- package/dist/chunk-EDTAMUO2.js.map +0 -1
- package/dist/chunk-IJTI6EX4.js +0 -4
- package/dist/chunk-IJTI6EX4.js.map +0 -1
- package/dist/chunk-M3YLASM2.js +0 -428
- package/dist/chunk-M3YLASM2.js.map +0 -1
- package/dist/chunk-OXKOGLXE.js +0 -4
- package/dist/chunk-OXKOGLXE.js.map +0 -1
- package/dist/chunk-RQXQK3ZO.mjs +0 -8486
- package/dist/chunk-RQXQK3ZO.mjs.map +0 -1
- package/dist/chunk-SR25V4EA.mjs +0 -40
- package/dist/chunk-SR25V4EA.mjs.map +0 -1
- package/dist/chunk-UB34WFEQ.js +0 -106
- package/dist/chunk-UB34WFEQ.js.map +0 -1
- package/dist/chunk-ZBRWXKDF.mjs +0 -24431
- package/dist/chunk-ZBRWXKDF.mjs.map +0 -1
- package/dist/cli/ds.d.mts +0 -1
- package/dist/cli/ds.d.ts +0 -1
- package/dist/cli/ds.js +0 -602
- package/dist/cli/ds.js.map +0 -1
- package/dist/cli/ds.mjs +0 -579
- package/dist/cli/ds.mjs.map +0 -1
- package/dist/cli/flipova.d.mts +0 -1
- package/dist/cli/flipova.d.ts +0 -1
- package/dist/cli/flipova.js +0 -161
- package/dist/cli/flipova.js.map +0 -1
- package/dist/cli/flipova.mjs +0 -154
- package/dist/cli/flipova.mjs.map +0 -1
- package/dist/config/index.d.mts +0 -123
- package/dist/config/index.d.ts +0 -123
- package/dist/config/index.js +0 -28
- package/dist/config/index.js.map +0 -1
- package/dist/config/index.mjs +0 -3
- package/dist/config/index.mjs.map +0 -1
- package/dist/index-CuaJA3gM.d.mts +0 -78
- package/dist/index-CuaJA3gM.d.ts +0 -78
- package/dist/registry/index.d.mts +0 -10160
- package/dist/registry/index.d.ts +0 -10160
- package/dist/registry/index.js +0 -392
- package/dist/registry/index.js.map +0 -1
- package/dist/registry/index.mjs +0 -3
- package/dist/registry/index.mjs.map +0 -1
- package/dist/theme/index.d.mts +0 -109
- package/dist/theme/index.d.ts +0 -109
- package/dist/theme/index.js +0 -28
- package/dist/theme/index.js.map +0 -1
- package/dist/theme/index.mjs +0 -3
- package/dist/theme/index.mjs.map +0 -1
- package/dist/tokens/index.d.mts +0 -423
- package/dist/tokens/index.d.ts +0 -423
- package/dist/tokens/index.js +0 -44
- package/dist/tokens/index.js.map +0 -1
- package/dist/tokens/index.mjs +0 -3
- package/dist/tokens/index.mjs.map +0 -1
- package/dist/types/index.d.mts +0 -202
- package/dist/types/index.d.ts +0 -202
- package/dist/types/index.js +0 -4
- package/dist/types/index.js.map +0 -1
- package/dist/types/index.mjs +0 -3
- package/dist/types/index.mjs.map +0 -1
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { createButton } from '@gluestack-ui/core/button/creator';
|
|
4
|
+
import {
|
|
5
|
+
tva,
|
|
6
|
+
withStyleContext,
|
|
7
|
+
useStyleContext,
|
|
8
|
+
type VariantProps,
|
|
9
|
+
} from '@gluestack-ui/utils/nativewind-utils';
|
|
10
|
+
import { cssInterop } from 'nativewind';
|
|
11
|
+
import { ActivityIndicator, Pressable, Text, View } from 'react-native';
|
|
12
|
+
import { UIIcon } from '@gluestack-ui/core/icon/creator';
|
|
13
|
+
const SCOPE = 'BUTTON';
|
|
14
|
+
const Root = withStyleContext(Pressable, SCOPE);
|
|
15
|
+
const UIButton = createButton({
|
|
16
|
+
Root: Root,
|
|
17
|
+
Text,
|
|
18
|
+
Group: View,
|
|
19
|
+
Spinner: ActivityIndicator,
|
|
20
|
+
Icon: UIIcon,
|
|
21
|
+
});
|
|
22
|
+
cssInterop(UIIcon, {
|
|
23
|
+
className: {
|
|
24
|
+
target: 'style',
|
|
25
|
+
nativeStyleToProp: {
|
|
26
|
+
height: true,
|
|
27
|
+
width: true,
|
|
28
|
+
fill: true,
|
|
29
|
+
color: 'classNameColor',
|
|
30
|
+
stroke: true,
|
|
31
|
+
} as any,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
const buttonStyle = tva({
|
|
35
|
+
base: 'rounded-md flex-row items-center justify-center data-[focus-visible=true]:web:outline-none data-[focus-visible=true]:web:ring-2 data-[disabled=true]:opacity-40 gap-2 h-fit',
|
|
36
|
+
variants: {
|
|
37
|
+
variant: {
|
|
38
|
+
default:
|
|
39
|
+
'bg-primary data-[hover=true]:bg-primary/90 data-[active=true]:bg-primary/90',
|
|
40
|
+
destructive:
|
|
41
|
+
'bg-destructive data-[hover=true]:bg-destructive/90 data-[active=true]:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60',
|
|
42
|
+
outline:
|
|
43
|
+
'border border-border bg-background shadow-xs data-[hover=true]:bg-accent data-[active=true]:bg-accent dark:bg-input/[0.045] dark:border-border/90 dark:data-[hover=true]:bg-input/[0.075] dark:data-[active=true]:bg-input/[0.075]',
|
|
44
|
+
secondary:
|
|
45
|
+
'bg-secondary text-secondary-foreground data-[hover=true]:bg-secondary/80 data-[active=true]:bg-secondary/80',
|
|
46
|
+
ghost: 'data-[hover=true]:bg-accent data-[active=true]:bg-accent dark:data-[hover=true]:bg-accent/50 dark:data-[active=true]:bg-accent/50',
|
|
47
|
+
link: 'text-primary underline-offset-4 data-[hover=true]:underline data-[active=true]:underline',
|
|
48
|
+
},
|
|
49
|
+
size: {
|
|
50
|
+
default: 'px-4 py-2',
|
|
51
|
+
sm: 'min-h-8 rounded-md px-3 text-xs',
|
|
52
|
+
lg: 'min-h-10 rounded-md px-8',
|
|
53
|
+
icon: 'min-h-9 min-w-9',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
const buttonTextStyle = tva({
|
|
58
|
+
base: 'web:select-none font-sans',
|
|
59
|
+
parentVariants: {
|
|
60
|
+
variant: {
|
|
61
|
+
default: 'text-primary-foreground',
|
|
62
|
+
destructive: 'text-white',
|
|
63
|
+
outline: 'text-foreground data-[hover=true]:text-accent-foreground data-[active=true]:text-accent-foreground',
|
|
64
|
+
secondary: 'text-secondary-foreground',
|
|
65
|
+
ghost: 'text-foreground ',
|
|
66
|
+
link: 'text-primary data-[hover=true]:underline data-[active=true]:underline',
|
|
67
|
+
},
|
|
68
|
+
size: {
|
|
69
|
+
default: 'text-sm',
|
|
70
|
+
sm: 'text-xs',
|
|
71
|
+
lg: 'text-sm',
|
|
72
|
+
icon: 'text-sm',
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const buttonSpinnerStyle = tva({
|
|
78
|
+
base: '',
|
|
79
|
+
parentVariants: {
|
|
80
|
+
size: {
|
|
81
|
+
default: 'h-4 w-4',
|
|
82
|
+
sm: 'h-4 w-4',
|
|
83
|
+
lg: 'h-4 w-4',
|
|
84
|
+
icon: 'h-4 w-4',
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const buttonIconStyle = tva({
|
|
90
|
+
base: 'fill-none pointer-events-none shrink-0',
|
|
91
|
+
parentVariants: {
|
|
92
|
+
variant: {
|
|
93
|
+
default: 'text-primary-foreground',
|
|
94
|
+
destructive: 'text-white',
|
|
95
|
+
outline:
|
|
96
|
+
'text-foreground data-[hover=true]:text-accent-foreground data-[active=true]:text-accent-foreground',
|
|
97
|
+
secondary: 'text-secondary-foreground',
|
|
98
|
+
ghost:
|
|
99
|
+
'text-foreground data-[hover=true]:text-accent-foreground data-[active=true]:text-accent-foreground',
|
|
100
|
+
link: 'text-primary',
|
|
101
|
+
},
|
|
102
|
+
size: {
|
|
103
|
+
default: 'h-4 w-4',
|
|
104
|
+
sm: 'h-4 w-4',
|
|
105
|
+
lg: 'h-4 w-4',
|
|
106
|
+
icon: 'h-4 w-4',
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
const buttonGroupStyle = tva({
|
|
111
|
+
base: '',
|
|
112
|
+
variants: {
|
|
113
|
+
space: {
|
|
114
|
+
'xs': 'gap-1',
|
|
115
|
+
'sm': 'gap-2',
|
|
116
|
+
'md': 'gap-3',
|
|
117
|
+
'lg': 'gap-4',
|
|
118
|
+
'xl': 'gap-5',
|
|
119
|
+
'2xl': 'gap-6',
|
|
120
|
+
'3xl': 'gap-7',
|
|
121
|
+
'4xl': 'gap-8',
|
|
122
|
+
},
|
|
123
|
+
isAttached: {
|
|
124
|
+
true: 'gap-0',
|
|
125
|
+
},
|
|
126
|
+
flexDirection: {
|
|
127
|
+
'row': 'flex-row',
|
|
128
|
+
'column': 'flex-col',
|
|
129
|
+
'row-reverse': 'flex-row-reverse',
|
|
130
|
+
'column-reverse': 'flex-col-reverse',
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
type IButtonProps = Omit<
|
|
135
|
+
React.ComponentPropsWithoutRef<typeof UIButton>,
|
|
136
|
+
'context'
|
|
137
|
+
> &
|
|
138
|
+
VariantProps<typeof buttonStyle> & { className?: string };
|
|
139
|
+
const Button = React.forwardRef<
|
|
140
|
+
React.ElementRef<typeof UIButton>,
|
|
141
|
+
IButtonProps
|
|
142
|
+
>(({ className, variant = 'default', size = 'default', ...props }, ref) => {
|
|
143
|
+
return (
|
|
144
|
+
<UIButton
|
|
145
|
+
ref={ref}
|
|
146
|
+
{...props}
|
|
147
|
+
className={buttonStyle({ variant, size, class: className })}
|
|
148
|
+
context={{ variant, size }}
|
|
149
|
+
/>
|
|
150
|
+
);
|
|
151
|
+
});
|
|
152
|
+
type IButtonTextProps = React.ComponentPropsWithoutRef<typeof UIButton.Text> &
|
|
153
|
+
VariantProps<typeof buttonTextStyle> & { className?: string };
|
|
154
|
+
const ButtonText = React.forwardRef<
|
|
155
|
+
React.ElementRef<typeof UIButton.Text>,
|
|
156
|
+
IButtonTextProps
|
|
157
|
+
>(({ className, size, ...props }, ref) => {
|
|
158
|
+
const { size: parentSize, variant: parentVariant } = useStyleContext(SCOPE);
|
|
159
|
+
return (
|
|
160
|
+
<UIButton.Text
|
|
161
|
+
ref={ref}
|
|
162
|
+
{...props}
|
|
163
|
+
className={buttonTextStyle({
|
|
164
|
+
parentVariants: {
|
|
165
|
+
size: parentSize,
|
|
166
|
+
variant: parentVariant,
|
|
167
|
+
},
|
|
168
|
+
size,
|
|
169
|
+
class: className,
|
|
170
|
+
})}
|
|
171
|
+
/>
|
|
172
|
+
);
|
|
173
|
+
});
|
|
174
|
+
const ButtonSpinner = React.forwardRef<
|
|
175
|
+
React.ElementRef<typeof UIButton.Spinner>,
|
|
176
|
+
React.ComponentPropsWithoutRef<typeof UIButton.Spinner>
|
|
177
|
+
>(({ className, size, ...props }, ref) => {
|
|
178
|
+
const { size: parentSize } = useStyleContext(SCOPE);
|
|
179
|
+
return <UIButton.Spinner ref={ref} {...props} className={buttonSpinnerStyle({ parentVariants: { size: parentSize }, class: className, size: size as any })} />;
|
|
180
|
+
});
|
|
181
|
+
type IButtonIcon = React.ComponentPropsWithoutRef<typeof UIButton.Icon> &
|
|
182
|
+
VariantProps<typeof buttonIconStyle> & {
|
|
183
|
+
className?: string | undefined;
|
|
184
|
+
as?: React.ElementType;
|
|
185
|
+
height?: number;
|
|
186
|
+
width?: number;
|
|
187
|
+
};
|
|
188
|
+
const ButtonIcon = React.forwardRef<
|
|
189
|
+
React.ElementRef<typeof UIButton.Icon>,
|
|
190
|
+
IButtonIcon
|
|
191
|
+
>(({ className, size, ...props }, ref) => {
|
|
192
|
+
const { size: parentSize, variant: parentVariant } = useStyleContext(SCOPE);
|
|
193
|
+
if (typeof size === 'number') {
|
|
194
|
+
return (
|
|
195
|
+
<UIButton.Icon
|
|
196
|
+
ref={ref}
|
|
197
|
+
{...props}
|
|
198
|
+
className={buttonIconStyle({ class: className })}
|
|
199
|
+
size={size}
|
|
200
|
+
/>
|
|
201
|
+
);
|
|
202
|
+
} else if (
|
|
203
|
+
(props.height !== undefined || props.width !== undefined) &&
|
|
204
|
+
size === undefined
|
|
205
|
+
) {
|
|
206
|
+
return (
|
|
207
|
+
<UIButton.Icon
|
|
208
|
+
ref={ref}
|
|
209
|
+
{...props}
|
|
210
|
+
className={buttonIconStyle({ class: className })}
|
|
211
|
+
/>
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
return (
|
|
215
|
+
<UIButton.Icon
|
|
216
|
+
{...props}
|
|
217
|
+
className={buttonIconStyle({
|
|
218
|
+
parentVariants: {
|
|
219
|
+
size: parentSize,
|
|
220
|
+
variant: parentVariant,
|
|
221
|
+
},
|
|
222
|
+
size,
|
|
223
|
+
class: className,
|
|
224
|
+
})}
|
|
225
|
+
ref={ref}
|
|
226
|
+
/>
|
|
227
|
+
);
|
|
228
|
+
});
|
|
229
|
+
type IButtonGroupProps = React.ComponentPropsWithoutRef<typeof UIButton.Group> &
|
|
230
|
+
VariantProps<typeof buttonGroupStyle>;
|
|
231
|
+
const ButtonGroup = React.forwardRef<
|
|
232
|
+
React.ElementRef<typeof UIButton.Group>,
|
|
233
|
+
IButtonGroupProps
|
|
234
|
+
>(
|
|
235
|
+
(
|
|
236
|
+
{
|
|
237
|
+
className,
|
|
238
|
+
space = 'md',
|
|
239
|
+
isAttached = false,
|
|
240
|
+
flexDirection = 'column',
|
|
241
|
+
...props
|
|
242
|
+
},
|
|
243
|
+
ref
|
|
244
|
+
) => {
|
|
245
|
+
return (
|
|
246
|
+
<UIButton.Group
|
|
247
|
+
className={buttonGroupStyle({
|
|
248
|
+
class: className,
|
|
249
|
+
space,
|
|
250
|
+
isAttached,
|
|
251
|
+
flexDirection,
|
|
252
|
+
})}
|
|
253
|
+
{...props}
|
|
254
|
+
ref={ref}
|
|
255
|
+
/>
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
);
|
|
259
|
+
Button.displayName = 'Button';
|
|
260
|
+
ButtonText.displayName = 'ButtonText';
|
|
261
|
+
ButtonSpinner.displayName = 'ButtonSpinner';
|
|
262
|
+
ButtonIcon.displayName = 'ButtonIcon';
|
|
263
|
+
ButtonGroup.displayName = 'ButtonGroup';
|
|
264
|
+
export { Button, ButtonText, ButtonSpinner, ButtonIcon, ButtonGroup };
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local replacement for the (unpublished) `@gluestack-ui/core/calendar/creator`
|
|
3
|
+
* module. Implements an actual date-selection engine (single/multiple/range
|
|
4
|
+
* modes, month/year navigation, day-grid generation, min/max bounds, markers)
|
|
5
|
+
* driving the styled slot components defined in `./index.tsx`.
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { Pressable, Text, View } from 'react-native';
|
|
9
|
+
|
|
10
|
+
export type CalendarMode = 'single' | 'multiple' | 'range';
|
|
11
|
+
|
|
12
|
+
export interface DayState {
|
|
13
|
+
isSelected?: boolean;
|
|
14
|
+
isToday?: boolean;
|
|
15
|
+
isDisabled?: boolean;
|
|
16
|
+
isOutsideMonth?: boolean;
|
|
17
|
+
isInRange?: boolean;
|
|
18
|
+
isRangeStart?: boolean;
|
|
19
|
+
isRangeEnd?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface CalendarMarker {
|
|
23
|
+
date: Date;
|
|
24
|
+
color?: string;
|
|
25
|
+
}
|
|
26
|
+
export type CalendarMarkers = CalendarMarker[];
|
|
27
|
+
|
|
28
|
+
export interface ICalendarProps {
|
|
29
|
+
mode?: CalendarMode;
|
|
30
|
+
value?: Date | Date[] | { from: Date; to?: Date };
|
|
31
|
+
defaultValue?: Date | Date[] | { from: Date; to?: Date };
|
|
32
|
+
onValueChange?: (value: any) => void;
|
|
33
|
+
month?: Date;
|
|
34
|
+
defaultMonth?: Date;
|
|
35
|
+
onMonthChange?: (month: Date) => void;
|
|
36
|
+
minimumDate?: Date;
|
|
37
|
+
maximumDate?: Date;
|
|
38
|
+
disabledDates?: Date[] | ((date: Date) => boolean);
|
|
39
|
+
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
40
|
+
markers?: CalendarMarkers;
|
|
41
|
+
showWeekNumbers?: boolean;
|
|
42
|
+
showFooter?: boolean;
|
|
43
|
+
disabled?: boolean;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* ---- date helpers (no external date library) ---- */
|
|
47
|
+
|
|
48
|
+
const DAY_MS = 86400000;
|
|
49
|
+
const WEEKDAY_LABELS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
50
|
+
const MONTH_LABELS = [
|
|
51
|
+
'January', 'February', 'March', 'April', 'May', 'June',
|
|
52
|
+
'July', 'August', 'September', 'October', 'November', 'December',
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
function stripTime(d: Date) {
|
|
56
|
+
return new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
|
57
|
+
}
|
|
58
|
+
function isSameDay(a?: Date, b?: Date) {
|
|
59
|
+
return !!a && !!b && a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
60
|
+
}
|
|
61
|
+
function startOfMonthDate(d: Date) {
|
|
62
|
+
return new Date(d.getFullYear(), d.getMonth(), 1);
|
|
63
|
+
}
|
|
64
|
+
function monthIndex(d: Date) {
|
|
65
|
+
return d.getFullYear() * 12 + d.getMonth();
|
|
66
|
+
}
|
|
67
|
+
function addMonths(d: Date, n: number) {
|
|
68
|
+
return new Date(d.getFullYear(), d.getMonth() + n, 1);
|
|
69
|
+
}
|
|
70
|
+
function daysInMonth(year: number, month: number) {
|
|
71
|
+
return new Date(year, month + 1, 0).getDate();
|
|
72
|
+
}
|
|
73
|
+
function buildMonthGrid(monthDate: Date, weekStartsOn: number): Date[][] {
|
|
74
|
+
const year = monthDate.getFullYear();
|
|
75
|
+
const month = monthDate.getMonth();
|
|
76
|
+
const firstWeekday = new Date(year, month, 1).getDay();
|
|
77
|
+
const offset = (firstWeekday - weekStartsOn + 7) % 7;
|
|
78
|
+
const total = daysInMonth(year, month);
|
|
79
|
+
const lastWeekday = new Date(year, month, total).getDay();
|
|
80
|
+
const endOffset = (weekStartsOn + 6 - lastWeekday + 7) % 7;
|
|
81
|
+
const cells = offset + total + endOffset;
|
|
82
|
+
const weeks: Date[][] = [];
|
|
83
|
+
for (let w = 0; w < cells / 7; w++) {
|
|
84
|
+
const week: Date[] = [];
|
|
85
|
+
for (let d = 0; d < 7; d++) {
|
|
86
|
+
week.push(new Date(year, month, 1 - offset + w * 7 + d));
|
|
87
|
+
}
|
|
88
|
+
weeks.push(week);
|
|
89
|
+
}
|
|
90
|
+
return weeks;
|
|
91
|
+
}
|
|
92
|
+
function getWeekNumber(date: Date) {
|
|
93
|
+
const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
|
|
94
|
+
const dayNum = d.getUTCDay() || 7;
|
|
95
|
+
d.setUTCDate(d.getUTCDate() + 4 - dayNum);
|
|
96
|
+
const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
|
|
97
|
+
return Math.ceil(((d.getTime() - yearStart.getTime()) / DAY_MS + 1) / 7);
|
|
98
|
+
}
|
|
99
|
+
function isDateDisabled(date: Date, props: Pick<ICalendarProps, 'minimumDate' | 'maximumDate' | 'disabledDates' | 'disabled'>) {
|
|
100
|
+
if (props.disabled) return true;
|
|
101
|
+
if (props.minimumDate && stripTime(date) < stripTime(props.minimumDate)) return true;
|
|
102
|
+
if (props.maximumDate && stripTime(date) > stripTime(props.maximumDate)) return true;
|
|
103
|
+
if (props.disabledDates) {
|
|
104
|
+
if (typeof props.disabledDates === 'function') return props.disabledDates(date);
|
|
105
|
+
return props.disabledDates.some((d) => isSameDay(d, date));
|
|
106
|
+
}
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface CreateCalendarConfig {
|
|
111
|
+
Root: React.ComponentType<any>;
|
|
112
|
+
Header: React.ComponentType<any>;
|
|
113
|
+
HeaderPrevButton: React.ComponentType<any>;
|
|
114
|
+
HeaderNextButton: React.ComponentType<any>;
|
|
115
|
+
HeaderTitle: React.ComponentType<any>;
|
|
116
|
+
HeaderMonthSelect: React.ComponentType<any>;
|
|
117
|
+
HeaderYearSelect: React.ComponentType<any>;
|
|
118
|
+
WeekDaysHeader: React.ComponentType<any>;
|
|
119
|
+
WeekDay: React.ComponentType<any>;
|
|
120
|
+
Body: React.ComponentType<any>;
|
|
121
|
+
Grid: React.ComponentType<any>;
|
|
122
|
+
Week: React.ComponentType<any>;
|
|
123
|
+
Day: React.ComponentType<any>;
|
|
124
|
+
DayText: React.ComponentType<any>;
|
|
125
|
+
DayIndicator: React.ComponentType<any>;
|
|
126
|
+
WeekNumber: React.ComponentType<any>;
|
|
127
|
+
Footer: React.ComponentType<any>;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function createCalendar(slots: CreateCalendarConfig) {
|
|
131
|
+
const {
|
|
132
|
+
Root, Header, HeaderPrevButton, HeaderNextButton, HeaderMonthSelect, HeaderYearSelect,
|
|
133
|
+
WeekDaysHeader, WeekDay, Body, Grid, Week, Day, DayText, DayIndicator, WeekNumber, Footer,
|
|
134
|
+
} = slots;
|
|
135
|
+
|
|
136
|
+
const Calendar = React.forwardRef<any, ICalendarProps & { className?: string }>(function Calendar(props, ref) {
|
|
137
|
+
const {
|
|
138
|
+
mode = 'single',
|
|
139
|
+
value,
|
|
140
|
+
defaultValue,
|
|
141
|
+
onValueChange,
|
|
142
|
+
month: controlledMonth,
|
|
143
|
+
defaultMonth,
|
|
144
|
+
onMonthChange,
|
|
145
|
+
minimumDate,
|
|
146
|
+
maximumDate,
|
|
147
|
+
disabledDates,
|
|
148
|
+
weekStartsOn = 0,
|
|
149
|
+
markers,
|
|
150
|
+
showWeekNumbers = false,
|
|
151
|
+
showFooter = true,
|
|
152
|
+
disabled,
|
|
153
|
+
className,
|
|
154
|
+
...rest
|
|
155
|
+
} = props as any;
|
|
156
|
+
|
|
157
|
+
const [uncontrolledValue, setUncontrolledValue] = React.useState(defaultValue);
|
|
158
|
+
const currentValue = value !== undefined ? value : uncontrolledValue;
|
|
159
|
+
|
|
160
|
+
const [uncontrolledMonth, setUncontrolledMonth] = React.useState<Date>(() => {
|
|
161
|
+
if (controlledMonth) return startOfMonthDate(controlledMonth);
|
|
162
|
+
if (defaultMonth) return startOfMonthDate(defaultMonth);
|
|
163
|
+
if (mode === 'single' && currentValue instanceof Date) return startOfMonthDate(currentValue);
|
|
164
|
+
if (mode === 'range' && currentValue?.from) return startOfMonthDate(currentValue.from);
|
|
165
|
+
if (mode === 'multiple' && Array.isArray(currentValue) && currentValue[0]) return startOfMonthDate(currentValue[0]);
|
|
166
|
+
return startOfMonthDate(new Date());
|
|
167
|
+
});
|
|
168
|
+
const displayedMonth = controlledMonth ? startOfMonthDate(controlledMonth) : uncontrolledMonth;
|
|
169
|
+
|
|
170
|
+
const setDisplayedMonth = React.useCallback(
|
|
171
|
+
(next: Date) => {
|
|
172
|
+
if (!controlledMonth) setUncontrolledMonth(next);
|
|
173
|
+
onMonthChange?.(next);
|
|
174
|
+
},
|
|
175
|
+
[controlledMonth, onMonthChange]
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
const setValue = React.useCallback(
|
|
179
|
+
(next: any) => {
|
|
180
|
+
if (value === undefined) setUncontrolledValue(next);
|
|
181
|
+
onValueChange?.(next);
|
|
182
|
+
},
|
|
183
|
+
[value, onValueChange]
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
const handleDayPress = React.useCallback(
|
|
187
|
+
(date: Date) => {
|
|
188
|
+
if (isDateDisabled(date, { minimumDate, maximumDate, disabledDates, disabled })) return;
|
|
189
|
+
|
|
190
|
+
if (mode === 'multiple') {
|
|
191
|
+
const arr: Date[] = Array.isArray(currentValue) ? currentValue : [];
|
|
192
|
+
const exists = arr.some((d) => isSameDay(d, date));
|
|
193
|
+
setValue(exists ? arr.filter((d) => !isSameDay(d, date)) : [...arr, date]);
|
|
194
|
+
} else if (mode === 'range') {
|
|
195
|
+
const range = currentValue as { from: Date; to?: Date } | undefined;
|
|
196
|
+
if (!range?.from || (range.from && range.to)) {
|
|
197
|
+
setValue({ from: date, to: undefined });
|
|
198
|
+
} else if (date < range.from) {
|
|
199
|
+
setValue({ from: date, to: range.from });
|
|
200
|
+
} else {
|
|
201
|
+
setValue({ from: range.from, to: date });
|
|
202
|
+
}
|
|
203
|
+
} else {
|
|
204
|
+
setValue(date);
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
[mode, currentValue, setValue, minimumDate, maximumDate, disabledDates, disabled]
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
const weeks = React.useMemo(() => buildMonthGrid(displayedMonth, weekStartsOn), [displayedMonth, weekStartsOn]);
|
|
211
|
+
const weekDayLabels = React.useMemo(
|
|
212
|
+
() => Array.from({ length: 7 }, (_, i) => WEEKDAY_LABELS[(weekStartsOn + i) % 7]),
|
|
213
|
+
[weekStartsOn]
|
|
214
|
+
);
|
|
215
|
+
const today = React.useMemo(() => new Date(), []);
|
|
216
|
+
|
|
217
|
+
const prevDisabled = !!minimumDate && monthIndex(displayedMonth) <= monthIndex(minimumDate);
|
|
218
|
+
const nextDisabled = !!maximumDate && monthIndex(displayedMonth) >= monthIndex(maximumDate);
|
|
219
|
+
|
|
220
|
+
const monthItems = React.useMemo(() => MONTH_LABELS.map((label, idx) => ({ label, value: idx })), []);
|
|
221
|
+
const yearItems = React.useMemo(() => {
|
|
222
|
+
const minYear = minimumDate ? minimumDate.getFullYear() : displayedMonth.getFullYear() - 100;
|
|
223
|
+
const maxYear = maximumDate ? maximumDate.getFullYear() : displayedMonth.getFullYear() + 10;
|
|
224
|
+
const items: { label: string; value: number }[] = [];
|
|
225
|
+
for (let y = maxYear; y >= minYear; y--) items.push({ label: String(y), value: y });
|
|
226
|
+
return items;
|
|
227
|
+
}, [minimumDate, maximumDate, displayedMonth]);
|
|
228
|
+
|
|
229
|
+
const resolveDayState = React.useCallback(
|
|
230
|
+
(date: Date): DayState => {
|
|
231
|
+
const isOutsideMonth = date.getMonth() !== displayedMonth.getMonth();
|
|
232
|
+
const isToday = isSameDay(date, today);
|
|
233
|
+
const isDisabled = isDateDisabled(date, { minimumDate, maximumDate, disabledDates, disabled });
|
|
234
|
+
|
|
235
|
+
if (mode === 'multiple') {
|
|
236
|
+
const arr = Array.isArray(currentValue) ? currentValue : [];
|
|
237
|
+
return { isSelected: arr.some((d: Date) => isSameDay(d, date)), isToday, isDisabled, isOutsideMonth };
|
|
238
|
+
}
|
|
239
|
+
if (mode === 'range') {
|
|
240
|
+
const range = currentValue as { from: Date; to?: Date } | undefined;
|
|
241
|
+
const isRangeStart = !!range?.from && isSameDay(date, range.from);
|
|
242
|
+
const isRangeEnd = !!range?.to && isSameDay(date, range.to);
|
|
243
|
+
const isInRange = !!range?.from && !!range?.to && date > stripTime(range.from) && date < stripTime(range.to);
|
|
244
|
+
return { isSelected: isRangeStart || isRangeEnd, isToday, isDisabled, isOutsideMonth, isInRange, isRangeStart, isRangeEnd };
|
|
245
|
+
}
|
|
246
|
+
return { isSelected: isSameDay(currentValue as Date | undefined, date), isToday, isDisabled, isOutsideMonth };
|
|
247
|
+
},
|
|
248
|
+
[mode, currentValue, displayedMonth, today, minimumDate, maximumDate, disabledDates, disabled]
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
return (
|
|
252
|
+
<Root ref={ref} className={className} {...rest}>
|
|
253
|
+
<Header>
|
|
254
|
+
<HeaderPrevButton
|
|
255
|
+
disabled={prevDisabled}
|
|
256
|
+
onPress={() => !prevDisabled && setDisplayedMonth(addMonths(displayedMonth, -1))}
|
|
257
|
+
>
|
|
258
|
+
{'<'}
|
|
259
|
+
</HeaderPrevButton>
|
|
260
|
+
<HeaderMonthSelect
|
|
261
|
+
items={monthItems}
|
|
262
|
+
selectedValue={displayedMonth.getMonth()}
|
|
263
|
+
onValueChange={(m: number) => setDisplayedMonth(new Date(displayedMonth.getFullYear(), m, 1))}
|
|
264
|
+
/>
|
|
265
|
+
<HeaderYearSelect
|
|
266
|
+
items={yearItems}
|
|
267
|
+
selectedValue={displayedMonth.getFullYear()}
|
|
268
|
+
onValueChange={(y: number) => setDisplayedMonth(new Date(y, displayedMonth.getMonth(), 1))}
|
|
269
|
+
/>
|
|
270
|
+
<HeaderNextButton
|
|
271
|
+
disabled={nextDisabled}
|
|
272
|
+
onPress={() => !nextDisabled && setDisplayedMonth(addMonths(displayedMonth, 1))}
|
|
273
|
+
>
|
|
274
|
+
{'>'}
|
|
275
|
+
</HeaderNextButton>
|
|
276
|
+
</Header>
|
|
277
|
+
|
|
278
|
+
<WeekDaysHeader>
|
|
279
|
+
{weekDayLabels.map((label, i) => (
|
|
280
|
+
<WeekDay key={`${label}-${i}`}>{label}</WeekDay>
|
|
281
|
+
))}
|
|
282
|
+
</WeekDaysHeader>
|
|
283
|
+
|
|
284
|
+
<Body>
|
|
285
|
+
<Grid>
|
|
286
|
+
{weeks.map((week, wi) => (
|
|
287
|
+
<Week key={wi}>
|
|
288
|
+
{showWeekNumbers && <WeekNumber>{getWeekNumber(week[0])}</WeekNumber>}
|
|
289
|
+
{week.map((date) => {
|
|
290
|
+
const state = resolveDayState(date);
|
|
291
|
+
const dayMarkers = markers?.filter((m: CalendarMarker) => isSameDay(m.date, date)) ?? [];
|
|
292
|
+
const dataState = state.isRangeStart && state.isRangeEnd
|
|
293
|
+
? 'selected'
|
|
294
|
+
: state.isRangeStart
|
|
295
|
+
? 'range-start'
|
|
296
|
+
: state.isRangeEnd
|
|
297
|
+
? 'range-end'
|
|
298
|
+
: state.isInRange
|
|
299
|
+
? 'range-middle'
|
|
300
|
+
: state.isSelected
|
|
301
|
+
? 'selected'
|
|
302
|
+
: state.isToday
|
|
303
|
+
? 'today'
|
|
304
|
+
: state.isDisabled
|
|
305
|
+
? 'disabled'
|
|
306
|
+
: state.isOutsideMonth
|
|
307
|
+
? 'outside-month'
|
|
308
|
+
: 'default';
|
|
309
|
+
|
|
310
|
+
return (
|
|
311
|
+
<Day
|
|
312
|
+
key={date.toISOString()}
|
|
313
|
+
data-state={dataState}
|
|
314
|
+
disabled={state.isDisabled}
|
|
315
|
+
onPress={() => handleDayPress(date)}
|
|
316
|
+
>
|
|
317
|
+
<DayText state={state}>{date.getDate()}</DayText>
|
|
318
|
+
{dayMarkers.length > 0 && (
|
|
319
|
+
<DayIndicator data-type={dayMarkers.length > 1 ? 'multi-dot' : 'dot'}>
|
|
320
|
+
{dayMarkers.map((m: CalendarMarker, mi: number) => (
|
|
321
|
+
<View
|
|
322
|
+
key={mi}
|
|
323
|
+
style={{ width: 4, height: 4, borderRadius: 2, backgroundColor: m.color ?? '#999' }}
|
|
324
|
+
/>
|
|
325
|
+
))}
|
|
326
|
+
</DayIndicator>
|
|
327
|
+
)}
|
|
328
|
+
</Day>
|
|
329
|
+
);
|
|
330
|
+
})}
|
|
331
|
+
</Week>
|
|
332
|
+
))}
|
|
333
|
+
</Grid>
|
|
334
|
+
</Body>
|
|
335
|
+
|
|
336
|
+
{showFooter && (
|
|
337
|
+
<Footer>
|
|
338
|
+
<Pressable onPress={() => setDisplayedMonth(startOfMonthDate(new Date()))}>
|
|
339
|
+
<Text>Today</Text>
|
|
340
|
+
</Pressable>
|
|
341
|
+
</Footer>
|
|
342
|
+
)}
|
|
343
|
+
</Root>
|
|
344
|
+
);
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
const Compound = Calendar as typeof Calendar & CreateCalendarConfig;
|
|
348
|
+
Compound.Header = Header;
|
|
349
|
+
Compound.HeaderPrevButton = HeaderPrevButton;
|
|
350
|
+
Compound.HeaderNextButton = HeaderNextButton;
|
|
351
|
+
Compound.HeaderTitle = slots.HeaderTitle;
|
|
352
|
+
Compound.HeaderMonthSelect = HeaderMonthSelect;
|
|
353
|
+
Compound.HeaderYearSelect = HeaderYearSelect;
|
|
354
|
+
Compound.WeekDaysHeader = WeekDaysHeader;
|
|
355
|
+
Compound.WeekDay = WeekDay;
|
|
356
|
+
Compound.Body = Body;
|
|
357
|
+
Compound.Grid = Grid;
|
|
358
|
+
Compound.Week = Week;
|
|
359
|
+
Compound.Day = Day;
|
|
360
|
+
Compound.DayText = DayText;
|
|
361
|
+
Compound.DayIndicator = DayIndicator;
|
|
362
|
+
Compound.WeekNumber = WeekNumber;
|
|
363
|
+
Compound.Footer = Footer;
|
|
364
|
+
|
|
365
|
+
return Compound;
|
|
366
|
+
}
|