@balikjs/mobile 0.0.2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +3537 -0
- package/dist/styles.css +1 -1
- package/package.json +209 -10
- package/dist/mobile.js +0 -3235
- package/src/Alert/Alert.jsx +0 -67
- package/src/Alert/Alert.module.css +0 -87
- package/src/Alert/index.js +0 -1
- package/src/Avatar/Avatar.jsx +0 -77
- package/src/Avatar/Avatar.module.css +0 -74
- package/src/Avatar/index.js +0 -1
- package/src/Badge/Badge.jsx +0 -83
- package/src/Badge/Badge.module.css +0 -141
- package/src/Badge/index.js +0 -1
- package/src/BottomNavigation/BottomNavigation.jsx +0 -61
- package/src/BottomNavigation/BottomNavigation.module.css +0 -53
- package/src/BottomNavigation/index.js +0 -1
- package/src/BottomSheet/BottomSheet.jsx +0 -51
- package/src/BottomSheet/BottomSheet.module.css +0 -56
- package/src/BottomSheet/index.js +0 -1
- package/src/Button/Button.jsx +0 -77
- package/src/Button/Button.module.css +0 -124
- package/src/Button/index.js +0 -1
- package/src/Card/Card.jsx +0 -31
- package/src/Card/Card.module.css +0 -4
- package/src/Card/index.js +0 -1
- package/src/Checkbox/Checkbox.jsx +0 -64
- package/src/Checkbox/Checkbox.module.css +0 -146
- package/src/Checkbox/index.js +0 -1
- package/src/Clipboard/Clipboard.jsx +0 -82
- package/src/Clipboard/Clipboard.module.css +0 -126
- package/src/Clipboard/index.js +0 -1
- package/src/CloseButton/CloseButton.jsx +0 -51
- package/src/CloseButton/CloseButton.module.css +0 -94
- package/src/Confirm/Confirm.jsx +0 -52
- package/src/Confirm/Confirm.module.css +0 -5
- package/src/Confirm/index.js +0 -1
- package/src/DatePicker/DatePicker.jsx +0 -276
- package/src/DatePicker/DatePicker.module.css +0 -197
- package/src/DatePicker/index.js +0 -1
- package/src/Dialog/Dialog.jsx +0 -63
- package/src/Dialog/Dialog.module.css +0 -111
- package/src/Dialog/index.js +0 -1
- package/src/Divider/Divider.jsx +0 -38
- package/src/Divider/Divider.module.css +0 -16
- package/src/Divider/index.js +0 -1
- package/src/Drawer/Drawer.jsx +0 -55
- package/src/Drawer/Drawer.module.css +0 -68
- package/src/Drawer/index.js +0 -1
- package/src/Empty/Empty.jsx +0 -35
- package/src/Empty/Empty.module.css +0 -17
- package/src/Empty/index.js +0 -1
- package/src/Fab/Fab.jsx +0 -91
- package/src/Fab/Fab.module.css +0 -94
- package/src/Fab/index.js +0 -1
- package/src/Input/Input.jsx +0 -53
- package/src/Input/Input.module.css +0 -97
- package/src/Input/index.js +0 -1
- package/src/Link/Link.jsx +0 -31
- package/src/Link/Link.module.css +0 -18
- package/src/Link/index.js +0 -1
- package/src/Popover/Popover.jsx +0 -162
- package/src/Popover/Popover.module.css +0 -63
- package/src/Popover/index.js +0 -1
- package/src/RadioGroup/Radio.jsx +0 -52
- package/src/RadioGroup/Radio.module.css +0 -133
- package/src/RadioGroup/RadioGroup.jsx +0 -36
- package/src/RadioGroup/RadioGroup.module.css +0 -23
- package/src/RadioGroup/index.js +0 -2
- package/src/SearchInput/SearchInput.jsx +0 -89
- package/src/SearchInput/SearchInput.module.css +0 -169
- package/src/SearchInput/index.js +0 -1
- package/src/Select/Select.jsx +0 -102
- package/src/Select/Select.module.css +0 -174
- package/src/Select/index.js +0 -1
- package/src/SelectPc/Select.jsx +0 -88
- package/src/SelectPc/SelectPc.module.css +0 -132
- package/src/SelectPc/index.js +0 -1
- package/src/Skeleton/Skeleton.jsx +0 -55
- package/src/Skeleton/Skeleton.module.css +0 -33
- package/src/Skeleton/index.js +0 -1
- package/src/Slider/Slider.jsx +0 -50
- package/src/Slider/Slider.module.css +0 -77
- package/src/Slider/index.js +0 -1
- package/src/Spinner/Spinner.jsx +0 -45
- package/src/Spinner/Spinner.module.css +0 -35
- package/src/Spinner/index.js +0 -1
- package/src/Switch/Switch.jsx +0 -51
- package/src/Switch/Switch.module.css +0 -156
- package/src/Switch/index.js +0 -1
- package/src/Tabs/Tabs.jsx +0 -75
- package/src/Tabs/Tabs.module.css +0 -45
- package/src/Tabs/index.js +0 -1
- package/src/Tag/Tag.jsx +0 -74
- package/src/Tag/Tag.module.css +0 -128
- package/src/Tag/index.js +0 -1
- package/src/Textarea/Textarea.jsx +0 -52
- package/src/Textarea/Textarea.module.css +0 -89
- package/src/Textarea/index.js +0 -1
- package/src/Toast/Toast.jsx +0 -169
- package/src/Toast/Toast.module.css +0 -152
- package/src/Toast/index.js +0 -1
- package/src/Tooltip/Tooltip.jsx +0 -42
- package/src/Tooltip/Tooltip.module.css +0 -41
- package/src/Tooltip/index.js +0 -1
- package/src/index.js +0 -35
- package/src/styles/index.css +0 -90
- package/src/styles/tokens.css +0 -227
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
.base {
|
|
2
|
-
display: inline-flex;
|
|
3
|
-
align-items: center;
|
|
4
|
-
justify-content: center;
|
|
5
|
-
gap: 6px;
|
|
6
|
-
border: none;
|
|
7
|
-
border-radius: var(--_border-radius);
|
|
8
|
-
font-family: inherit;
|
|
9
|
-
cursor: pointer;
|
|
10
|
-
outline: none;
|
|
11
|
-
color: var(--color-disabled-fg);
|
|
12
|
-
background-color: transparent;
|
|
13
|
-
user-select: none;
|
|
14
|
-
touch-action: manipulation;
|
|
15
|
-
-webkit-tap-highlight-color: transparent;
|
|
16
|
-
transition: background-color var(--b-transition-fast),
|
|
17
|
-
color var(--b-transition-fast);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
@media (hover: hover) {
|
|
21
|
-
.base:hover {
|
|
22
|
-
color: var(--base-fg);
|
|
23
|
-
background-color: color-mix(in oklch, var(--base-fg) 6%, var(--base-bg));
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.base:focus {
|
|
28
|
-
outline: none;
|
|
29
|
-
background-color: transparent;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.base:focus-visible {
|
|
33
|
-
color: var(--base-fg);
|
|
34
|
-
outline: 2px solid var(--color-focus-border);
|
|
35
|
-
outline-offset: 2px;
|
|
36
|
-
background-color: transparent;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.base:active {
|
|
40
|
-
background-color: transparent;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.icon {
|
|
44
|
-
flex-shrink: 0;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.copied {
|
|
48
|
-
color: var(--color-success);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
@media (hover: hover) {
|
|
52
|
-
.copied:hover {
|
|
53
|
-
color: var(--color-success);
|
|
54
|
-
background-color: color-mix(in oklch, var(--color-success) 10%, var(--base-bg));
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.sizeXs {
|
|
59
|
-
height: 28px;
|
|
60
|
-
width: 28px;
|
|
61
|
-
min-width: 28px;
|
|
62
|
-
padding: 0;
|
|
63
|
-
--_border-radius: var(--b-radius-l1-xs);
|
|
64
|
-
--_icon-size: 14px;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
.sizeXs .icon {
|
|
68
|
-
width: 14px;
|
|
69
|
-
height: 14px;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
.sizeSm {
|
|
73
|
-
height: 32px;
|
|
74
|
-
width: 32px;
|
|
75
|
-
min-width: 32px;
|
|
76
|
-
padding: 0;
|
|
77
|
-
--_border-radius: var(--b-radius-l1-sm);
|
|
78
|
-
--_icon-size: 16px;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
.sizeSm .icon {
|
|
82
|
-
width: 16px;
|
|
83
|
-
height: 16px;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
.sizeMd {
|
|
87
|
-
height: 36px;
|
|
88
|
-
width: 36px;
|
|
89
|
-
min-width: 36px;
|
|
90
|
-
padding: 0;
|
|
91
|
-
--_border-radius: var(--b-radius-l1-md);
|
|
92
|
-
--_icon-size: 18px;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
.sizeMd .icon {
|
|
96
|
-
width: 18px;
|
|
97
|
-
height: 18px;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
.sizeLg {
|
|
101
|
-
height: 40px;
|
|
102
|
-
width: 40px;
|
|
103
|
-
min-width: 40px;
|
|
104
|
-
padding: 0;
|
|
105
|
-
--_border-radius: var(--b-radius-l1-lg);
|
|
106
|
-
--_icon-size: 20px;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
.sizeLg .icon {
|
|
110
|
-
width: 20px;
|
|
111
|
-
height: 20px;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
.sizeXl {
|
|
115
|
-
height: 44px;
|
|
116
|
-
width: 44px;
|
|
117
|
-
min-width: 44px;
|
|
118
|
-
padding: 0;
|
|
119
|
-
--_border-radius: var(--b-radius-l1-xl);
|
|
120
|
-
--_icon-size: 22px;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
.sizeXl .icon {
|
|
124
|
-
width: 22px;
|
|
125
|
-
height: 22px;
|
|
126
|
-
}
|
package/src/Clipboard/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Clipboard } from './Clipboard.jsx'
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { splitProps, mergeProps } from 'solid-js'
|
|
2
|
-
import { X } from 'lucide-solid'
|
|
3
|
-
import styles from './CloseButton.module.css'
|
|
4
|
-
|
|
5
|
-
const sizeMap = {
|
|
6
|
-
xs: styles.sizeXs,
|
|
7
|
-
sm: styles.sizeSm,
|
|
8
|
-
md: styles.sizeMd,
|
|
9
|
-
lg: styles.sizeLg,
|
|
10
|
-
xl: styles.sizeXl,
|
|
11
|
-
'2xl': styles.size2xl,
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const DEFAULT_PROPS = {
|
|
15
|
-
size: 'md',
|
|
16
|
-
rounded: false,
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @param {import('solid-js').JSX.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
21
|
-
* size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'
|
|
22
|
-
* rounded?: boolean
|
|
23
|
-
* class?: string
|
|
24
|
-
* }} props
|
|
25
|
-
*/
|
|
26
|
-
export function CloseButton(props) {
|
|
27
|
-
const [local, rest] = splitProps(
|
|
28
|
-
mergeProps(DEFAULT_PROPS, props),
|
|
29
|
-
['size', 'rounded', 'class'],
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<button
|
|
34
|
-
{...rest}
|
|
35
|
-
type="button"
|
|
36
|
-
aria-label="Close"
|
|
37
|
-
class={[
|
|
38
|
-
'balik-close-button',
|
|
39
|
-
`balik-close-button--${local.size}`,
|
|
40
|
-
styles.base,
|
|
41
|
-
sizeMap[local.size],
|
|
42
|
-
local.rounded && styles.rounded,
|
|
43
|
-
local.class,
|
|
44
|
-
]
|
|
45
|
-
.filter(Boolean)
|
|
46
|
-
.join(' ')}
|
|
47
|
-
>
|
|
48
|
-
<X aria-hidden="true" />
|
|
49
|
-
</button>
|
|
50
|
-
)
|
|
51
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
.base {
|
|
2
|
-
display: inline-flex;
|
|
3
|
-
align-items: center;
|
|
4
|
-
justify-content: center;
|
|
5
|
-
padding: 0;
|
|
6
|
-
border: none;
|
|
7
|
-
border-radius: var(--b-radius-l1-md);
|
|
8
|
-
background: transparent;
|
|
9
|
-
color: color-mix(in oklch, var(--base-fg) 40%, transparent);
|
|
10
|
-
cursor: pointer;
|
|
11
|
-
transition:
|
|
12
|
-
color var(--b-transition-fast),
|
|
13
|
-
background-color var(--b-transition-fast);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.base:hover {
|
|
17
|
-
color: var(--base-fg);
|
|
18
|
-
background-color: color-mix(in oklch, var(--base-fg) 8%, transparent);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.base:focus-visible {
|
|
22
|
-
outline: 2px solid var(--base-edge);
|
|
23
|
-
outline-offset: 2px;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.base svg {
|
|
27
|
-
display: block;
|
|
28
|
-
pointer-events: none;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.sizeXs {
|
|
32
|
-
width: var(--b-comp-height-xs);
|
|
33
|
-
height: var(--b-comp-height-xs);
|
|
34
|
-
border-radius: var(--b-radius-l1-xs);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.sizeXs svg {
|
|
38
|
-
width: 16px;
|
|
39
|
-
height: 16px;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.sizeSm {
|
|
43
|
-
width: var(--b-comp-height-sm);
|
|
44
|
-
height: var(--b-comp-height-sm);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.sizeSm svg {
|
|
48
|
-
width: 18px;
|
|
49
|
-
height: 18px;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.sizeMd {
|
|
53
|
-
width: var(--b-comp-height-md);
|
|
54
|
-
height: var(--b-comp-height-md);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.sizeMd svg {
|
|
58
|
-
width: 20px;
|
|
59
|
-
height: 20px;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.sizeLg {
|
|
63
|
-
width: var(--b-comp-height-lg);
|
|
64
|
-
height: var(--b-comp-height-lg);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
.sizeLg svg {
|
|
68
|
-
width: 22px;
|
|
69
|
-
height: 22px;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
.sizeXl {
|
|
73
|
-
width: var(--b-comp-height-xl);
|
|
74
|
-
height: var(--b-comp-height-xl);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
.sizeXl svg {
|
|
78
|
-
width: 24px;
|
|
79
|
-
height: 24px;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.size2xl {
|
|
83
|
-
width: var(--b-comp-height-2xl);
|
|
84
|
-
height: var(--b-comp-height-2xl);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
.size2xl svg {
|
|
88
|
-
width: 32px;
|
|
89
|
-
height: 32px;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
.rounded {
|
|
93
|
-
border-radius: 50%;
|
|
94
|
-
}
|
package/src/Confirm/Confirm.jsx
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { splitProps, mergeProps } from 'solid-js'
|
|
2
|
-
import { Dialog } from '../Dialog/Dialog.jsx'
|
|
3
|
-
import { Button } from '../Button/Button.jsx'
|
|
4
|
-
import styles from './Confirm.module.css'
|
|
5
|
-
|
|
6
|
-
const DEFAULT_PROPS = {
|
|
7
|
-
closeable: false,
|
|
8
|
-
confirmLabel: 'Confirm',
|
|
9
|
-
cancelLabel: 'Cancel',
|
|
10
|
-
danger: false,
|
|
11
|
-
loading: false,
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @param {import('../Dialog/Dialog.jsx').DialogProps & {
|
|
16
|
-
* confirmLabel?: string
|
|
17
|
-
* cancelLabel?: string
|
|
18
|
-
* danger?: boolean
|
|
19
|
-
* loading?: boolean
|
|
20
|
-
* onConfirm?: () => void
|
|
21
|
-
* onCancel?: () => void
|
|
22
|
-
* }} props
|
|
23
|
-
*/
|
|
24
|
-
export function Confirm(props) {
|
|
25
|
-
const [local, rest] = splitProps(
|
|
26
|
-
mergeProps(DEFAULT_PROPS, props),
|
|
27
|
-
['confirmLabel', 'cancelLabel', 'danger', 'loading', 'closeable', 'onConfirm', 'onCancel', 'onOpenChange', 'class', 'children'],
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
const handleConfirm = () => {
|
|
31
|
-
local.onConfirm?.()
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const handleCancel = () => {
|
|
35
|
-
local.onCancel?.()
|
|
36
|
-
local.onOpenChange?.({ open: false })
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<Dialog {...rest} closeable={local.closeable} onOpenChange={local.onOpenChange} class={local.class}>
|
|
41
|
-
{local.children}
|
|
42
|
-
<div class={styles.actions}>
|
|
43
|
-
<Button size="sm" onClick={handleCancel}>
|
|
44
|
-
{local.cancelLabel}
|
|
45
|
-
</Button>
|
|
46
|
-
<Button size="sm" solid danger={local.danger} loading={local.loading} onClick={handleConfirm}>
|
|
47
|
-
{local.confirmLabel}
|
|
48
|
-
</Button>
|
|
49
|
-
</div>
|
|
50
|
-
</Dialog>
|
|
51
|
-
)
|
|
52
|
-
}
|
package/src/Confirm/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Confirm } from './Confirm.jsx'
|
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
splitProps,
|
|
3
|
-
mergeProps,
|
|
4
|
-
createSignal,
|
|
5
|
-
createMemo,
|
|
6
|
-
For,
|
|
7
|
-
onMount,
|
|
8
|
-
createEffect,
|
|
9
|
-
} from 'solid-js'
|
|
10
|
-
import { Portal } from 'solid-js/web'
|
|
11
|
-
import styles from './DatePicker.module.css'
|
|
12
|
-
|
|
13
|
-
const MONTHS = [
|
|
14
|
-
'January', 'February', 'March', 'April', 'May', 'June',
|
|
15
|
-
'July', 'August', 'September', 'October', 'November', 'December',
|
|
16
|
-
]
|
|
17
|
-
|
|
18
|
-
const ITEM_HEIGHT = 40
|
|
19
|
-
const VISIBLE_ITEMS = 5
|
|
20
|
-
|
|
21
|
-
function daysInMonth(year, month) {
|
|
22
|
-
return new Date(year, month + 1, 0).getDate()
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function clamp(v, min, max) {
|
|
26
|
-
return Math.max(min, Math.min(max, v))
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function scrollColumnTo(ref, index) {
|
|
30
|
-
if (!ref) return
|
|
31
|
-
ref.scrollTo({ top: index * ITEM_HEIGHT, behavior: 'instant' })
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const DEFAULT_PROPS = {
|
|
35
|
-
open: false,
|
|
36
|
-
title: 'Select Date',
|
|
37
|
-
value: null,
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* iOS-style date picker with three scrollable columns.
|
|
42
|
-
*
|
|
43
|
-
* @param {{
|
|
44
|
-
* open: boolean
|
|
45
|
-
* onOpenChange?: (open: boolean) => void
|
|
46
|
-
* value?: Date | null
|
|
47
|
-
* onConfirm?: (date: Date) => void
|
|
48
|
-
* onCancel?: () => void
|
|
49
|
-
* min?: Date
|
|
50
|
-
* max?: Date
|
|
51
|
-
* title?: string
|
|
52
|
-
* class?: string
|
|
53
|
-
* }} props
|
|
54
|
-
*/
|
|
55
|
-
export function DatePicker(props) {
|
|
56
|
-
const [local] = splitProps(
|
|
57
|
-
mergeProps(DEFAULT_PROPS, props),
|
|
58
|
-
['open', 'onOpenChange', 'value', 'onConfirm', 'onCancel', 'min', 'max', 'title', 'class'],
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
const now = new Date()
|
|
62
|
-
const startDate = local.value || now
|
|
63
|
-
const minDate = local.min || new Date(now.getFullYear() - 100, 0, 1)
|
|
64
|
-
const maxDate = local.max || new Date(now.getFullYear() + 10, 11, 31)
|
|
65
|
-
|
|
66
|
-
const minYear = minDate.getFullYear()
|
|
67
|
-
const maxYear = maxDate.getFullYear()
|
|
68
|
-
const yearCount = maxYear - minYear + 1
|
|
69
|
-
|
|
70
|
-
const [selectedYear, setSelectedYear] = createSignal(startDate.getFullYear())
|
|
71
|
-
const [selectedMonth, setSelectedMonth] = createSignal(startDate.getMonth())
|
|
72
|
-
const [selectedDay, setSelectedDay] = createSignal(startDate.getDate())
|
|
73
|
-
|
|
74
|
-
let yearRef
|
|
75
|
-
let monthRef
|
|
76
|
-
let dayRef
|
|
77
|
-
|
|
78
|
-
const yearIndex = () => selectedYear() - minYear
|
|
79
|
-
const monthIndex = () => selectedMonth()
|
|
80
|
-
const dayIndex = () => selectedDay() - 1
|
|
81
|
-
const maxDay = createMemo(() => daysInMonth(selectedYear(), selectedMonth()))
|
|
82
|
-
|
|
83
|
-
function initScroll() {
|
|
84
|
-
scrollColumnTo(yearRef, yearIndex())
|
|
85
|
-
scrollColumnTo(monthRef, monthIndex())
|
|
86
|
-
requestAnimationFrame(() => {
|
|
87
|
-
scrollColumnTo(dayRef, clamp(dayIndex(), 0, maxDay() - 1))
|
|
88
|
-
})
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
onMount(() => {
|
|
92
|
-
createEffect(() => {
|
|
93
|
-
if (local.open) {
|
|
94
|
-
const d = local.value || now
|
|
95
|
-
setSelectedYear(d.getFullYear())
|
|
96
|
-
setSelectedMonth(d.getMonth())
|
|
97
|
-
setSelectedDay(d.getDate())
|
|
98
|
-
initScroll()
|
|
99
|
-
}
|
|
100
|
-
})
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
function handleYearScroll() {
|
|
104
|
-
const idx = Math.round(yearRef.scrollTop / ITEM_HEIGHT)
|
|
105
|
-
setSelectedYear(minYear + idx)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function handleMonthScroll() {
|
|
109
|
-
const idx = Math.round(monthRef.scrollTop / ITEM_HEIGHT)
|
|
110
|
-
setSelectedMonth(idx)
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function handleDayScroll() {
|
|
114
|
-
const idx = Math.round(dayRef.scrollTop / ITEM_HEIGHT)
|
|
115
|
-
setSelectedDay(idx + 1)
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
createEffect(() => {
|
|
119
|
-
requestAnimationFrame(() => {
|
|
120
|
-
const maxD = maxDay()
|
|
121
|
-
const d = selectedDay()
|
|
122
|
-
if (d > maxD) {
|
|
123
|
-
setSelectedDay(maxD)
|
|
124
|
-
scrollColumnTo(dayRef, maxD - 1)
|
|
125
|
-
}
|
|
126
|
-
})
|
|
127
|
-
})
|
|
128
|
-
|
|
129
|
-
const weekday = createMemo(() => {
|
|
130
|
-
const d = new Date(selectedYear(), selectedMonth(), selectedDay())
|
|
131
|
-
return d.toLocaleDateString('en-US', { weekday: 'long' })
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
function confirm() {
|
|
135
|
-
const date = new Date(selectedYear(), selectedMonth(), selectedDay())
|
|
136
|
-
local.onConfirm?.(date)
|
|
137
|
-
local.onOpenChange?.(false)
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
function cancel() {
|
|
141
|
-
local.onCancel?.()
|
|
142
|
-
local.onOpenChange?.(false)
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return (
|
|
146
|
-
<Portal mount={document.body}>
|
|
147
|
-
<div
|
|
148
|
-
class={styles.backdrop}
|
|
149
|
-
data-open={local.open ? '' : undefined}
|
|
150
|
-
onClick={cancel}
|
|
151
|
-
/>
|
|
152
|
-
<div
|
|
153
|
-
class={[
|
|
154
|
-
'balik-date-picker',
|
|
155
|
-
styles.root,
|
|
156
|
-
local.class,
|
|
157
|
-
]
|
|
158
|
-
.filter(Boolean)
|
|
159
|
-
.join(' ')}
|
|
160
|
-
data-open={local.open ? '' : undefined}
|
|
161
|
-
role="dialog"
|
|
162
|
-
aria-modal="true"
|
|
163
|
-
aria-label={local.title}
|
|
164
|
-
>
|
|
165
|
-
<div class={styles.header}>
|
|
166
|
-
<button
|
|
167
|
-
type="button"
|
|
168
|
-
class={styles.headerBtn}
|
|
169
|
-
onClick={cancel}
|
|
170
|
-
>
|
|
171
|
-
Cancel
|
|
172
|
-
</button>
|
|
173
|
-
<span class={styles.headerTitle}>{local.title}</span>
|
|
174
|
-
<button
|
|
175
|
-
type="button"
|
|
176
|
-
class={[styles.headerBtn, styles.headerBtnConfirm].join(' ')}
|
|
177
|
-
onClick={confirm}
|
|
178
|
-
>
|
|
179
|
-
Confirm
|
|
180
|
-
</button>
|
|
181
|
-
</div>
|
|
182
|
-
|
|
183
|
-
<div class={styles.pickerBody}>
|
|
184
|
-
<div class={styles.selectedBar} />
|
|
185
|
-
|
|
186
|
-
<div class={styles.columns}>
|
|
187
|
-
<div class={styles.column}>
|
|
188
|
-
<div
|
|
189
|
-
ref={yearRef}
|
|
190
|
-
class={[styles.scroller, styles.yearColumn].join(' ')}
|
|
191
|
-
onScroll={handleYearScroll}
|
|
192
|
-
>
|
|
193
|
-
<div style={{ height: `${(VISIBLE_ITEMS - 1) / 2 * ITEM_HEIGHT}px` }} />
|
|
194
|
-
<For each={Array.from({ length: yearCount }, (_, i) => minYear + i)}>
|
|
195
|
-
{(year) => (
|
|
196
|
-
<span
|
|
197
|
-
class={[
|
|
198
|
-
styles.item,
|
|
199
|
-
styles.yearItem,
|
|
200
|
-
year === selectedYear() && styles.itemSelected,
|
|
201
|
-
].filter(Boolean).join(' ')}
|
|
202
|
-
style={{ height: `${ITEM_HEIGHT}px` }}
|
|
203
|
-
>
|
|
204
|
-
{year}
|
|
205
|
-
</span>
|
|
206
|
-
)}
|
|
207
|
-
</For>
|
|
208
|
-
<div style={{ height: `${(VISIBLE_ITEMS - 1) / 2 * ITEM_HEIGHT}px` }} />
|
|
209
|
-
</div>
|
|
210
|
-
</div>
|
|
211
|
-
|
|
212
|
-
<div class={styles.column}>
|
|
213
|
-
<div
|
|
214
|
-
ref={monthRef}
|
|
215
|
-
class={styles.scroller}
|
|
216
|
-
onScroll={handleMonthScroll}
|
|
217
|
-
>
|
|
218
|
-
<div style={{ height: `${(VISIBLE_ITEMS - 1) / 2 * ITEM_HEIGHT}px` }} />
|
|
219
|
-
<For each={MONTHS}>
|
|
220
|
-
{(month, i) => {
|
|
221
|
-
const disabled = (
|
|
222
|
-
selectedYear() === minYear && i() < minDate.getMonth()
|
|
223
|
-
) || (
|
|
224
|
-
selectedYear() === maxYear && i() > maxDate.getMonth()
|
|
225
|
-
)
|
|
226
|
-
return (
|
|
227
|
-
<span
|
|
228
|
-
class={[
|
|
229
|
-
styles.item,
|
|
230
|
-
styles.monthItem,
|
|
231
|
-
i() === selectedMonth() && styles.itemSelected,
|
|
232
|
-
disabled && styles.itemDisabled,
|
|
233
|
-
].filter(Boolean).join(' ')}
|
|
234
|
-
style={{ height: `${ITEM_HEIGHT}px` }}
|
|
235
|
-
>
|
|
236
|
-
{month.slice(0, 3)}
|
|
237
|
-
</span>
|
|
238
|
-
)
|
|
239
|
-
}}
|
|
240
|
-
</For>
|
|
241
|
-
<div style={{ height: `${(VISIBLE_ITEMS - 1) / 2 * ITEM_HEIGHT}px` }} />
|
|
242
|
-
</div>
|
|
243
|
-
</div>
|
|
244
|
-
|
|
245
|
-
<div class={styles.column}>
|
|
246
|
-
<div
|
|
247
|
-
ref={dayRef}
|
|
248
|
-
class={styles.scroller}
|
|
249
|
-
onScroll={handleDayScroll}
|
|
250
|
-
>
|
|
251
|
-
<div style={{ height: `${(VISIBLE_ITEMS - 1) / 2 * ITEM_HEIGHT}px` }} />
|
|
252
|
-
<For each={Array.from({ length: maxDay() }, (_, i) => i + 1)}>
|
|
253
|
-
{(day) => (
|
|
254
|
-
<span
|
|
255
|
-
class={[
|
|
256
|
-
styles.item,
|
|
257
|
-
styles.dayItem,
|
|
258
|
-
day === selectedDay() && styles.itemSelected,
|
|
259
|
-
].filter(Boolean).join(' ')}
|
|
260
|
-
style={{ height: `${ITEM_HEIGHT}px` }}
|
|
261
|
-
>
|
|
262
|
-
{String(day).padStart(2, '0')}
|
|
263
|
-
</span>
|
|
264
|
-
)}
|
|
265
|
-
</For>
|
|
266
|
-
<div style={{ height: `${(VISIBLE_ITEMS - 1) / 2 * ITEM_HEIGHT}px` }} />
|
|
267
|
-
</div>
|
|
268
|
-
</div>
|
|
269
|
-
</div>
|
|
270
|
-
|
|
271
|
-
<p class={styles.weekday}>{weekday()}</p>
|
|
272
|
-
</div>
|
|
273
|
-
</div>
|
|
274
|
-
</Portal>
|
|
275
|
-
)
|
|
276
|
-
}
|