@sakura-ui/sakura-ui 0.2.0 → 0.4.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/README.md +77 -6
- package/package.json +28 -21
- package/packages/core/package.json +30 -17
- package/packages/core/src/components/Button.tsx +33 -32
- package/packages/core/src/components/Card.tsx +37 -20
- package/packages/core/src/components/Code.tsx +6 -4
- package/packages/core/src/components/Faq.tsx +13 -7
- package/packages/core/src/components/Heading.tsx +42 -32
- package/packages/core/src/components/Icon.tsx +43 -13
- package/packages/core/src/components/IconButton.tsx +54 -43
- package/packages/core/src/components/LangSelector.tsx +135 -0
- package/packages/core/src/components/Link.tsx +37 -66
- package/packages/core/src/components/LinkCard.tsx +126 -0
- package/packages/core/src/components/List.tsx +14 -12
- package/packages/core/src/components/MenuButton.tsx +112 -0
- package/packages/core/src/components/NavigationItem.tsx +41 -0
- package/packages/core/src/components/NotificationBanner.tsx +20 -0
- package/packages/core/src/components/OverflowContainer.tsx +24 -0
- package/packages/core/src/components/PopoverMenu.tsx +82 -0
- package/packages/core/src/components/Pre.tsx +6 -4
- package/packages/core/src/components/Table.tsx +31 -25
- package/packages/core/src/components/buttonStyle.ts +43 -32
- package/packages/core/src/components/index.ts +13 -25
- package/packages/core/src/icons/Close.tsx +21 -0
- package/packages/core/src/icons/CloseMobile.tsx +43 -0
- package/packages/core/src/icons/KeyboardArrowDown.tsx +24 -0
- package/packages/core/src/icons/Language.tsx +25 -0
- package/packages/core/src/icons/LanguageMobile.tsx +40 -0
- package/packages/core/src/icons/Menu.tsx +24 -0
- package/packages/core/src/icons/MenuMobile.tsx +40 -0
- package/packages/core/src/icons/index.ts +8 -0
- package/packages/core/src/icons/props.ts +5 -0
- package/packages/core/src/index.ts +10 -28
- package/packages/core/src/type.d.ts +1 -0
- package/packages/core/tests/Button.test.tsx +20 -10
- package/packages/core/tests/Card.test.tsx +16 -11
- package/packages/core/tests/IconButton.test.tsx +57 -0
- package/packages/core/tests/Link.test.tsx +60 -0
- package/packages/core/tests/vitest.setup.ts +1 -0
- package/packages/core/tsconfig.node.json +3 -2
- package/packages/core/vite.config.ts +2 -1
- package/packages/forms/.turbo/turbo-build.log +12 -0
- package/packages/forms/dist/index.cjs.js +183 -131
- package/packages/forms/dist/index.es.js +750 -1062
- package/packages/forms/dist/types/components/Checkbox.d.ts +9 -4
- package/packages/forms/dist/types/components/Checkbox.d.ts.map +1 -1
- package/packages/forms/dist/types/components/FieldsetControl.d.ts +14 -9
- package/packages/forms/dist/types/components/FieldsetControl.d.ts.map +1 -1
- package/packages/forms/dist/types/components/FileInput.d.ts +10 -3
- package/packages/forms/dist/types/components/FileInput.d.ts.map +1 -1
- package/packages/forms/dist/types/components/Input.d.ts +9 -4
- package/packages/forms/dist/types/components/Input.d.ts.map +1 -1
- package/packages/forms/dist/types/components/LabelControl.d.ts +13 -8
- package/packages/forms/dist/types/components/LabelControl.d.ts.map +1 -1
- package/packages/forms/dist/types/components/Radio.d.ts +9 -4
- package/packages/forms/dist/types/components/Radio.d.ts.map +1 -1
- package/packages/forms/dist/types/components/Select.d.ts +9 -4
- package/packages/forms/dist/types/components/Select.d.ts.map +1 -1
- package/packages/forms/dist/types/components/Textarea.d.ts +8 -3
- package/packages/forms/dist/types/components/Textarea.d.ts.map +1 -1
- package/packages/forms/dist/types/components/controlled/CheckboxGroup.d.ts +16 -11
- package/packages/forms/dist/types/components/controlled/CheckboxGroup.d.ts.map +1 -1
- package/packages/forms/dist/types/components/controlled/RadioGroup.d.ts +17 -12
- package/packages/forms/dist/types/components/controlled/RadioGroup.d.ts.map +1 -1
- package/packages/forms/dist/types/components/index.d.ts +8 -8
- package/packages/forms/dist/types/components/index.d.ts.map +1 -1
- package/packages/forms/dist/types/components/inputStyle.d.ts +1 -1
- package/packages/forms/dist/types/components/inputStyle.d.ts.map +1 -1
- package/packages/forms/dist/types/index.d.ts +0 -1
- package/packages/forms/dist/types/index.d.ts.map +1 -1
- package/packages/forms/node_modules/.bin/autoprefixer +44 -6
- package/packages/forms/package.json +21 -16
- package/packages/forms/src/components/Checkbox.tsx +76 -80
- package/packages/forms/src/components/FieldsetControl.tsx +21 -28
- package/packages/forms/src/components/FileInput.tsx +92 -63
- package/packages/forms/src/components/Input.tsx +29 -31
- package/packages/forms/src/components/LabelControl.tsx +19 -25
- package/packages/forms/src/components/Radio.tsx +68 -69
- package/packages/forms/src/components/Select.tsx +65 -65
- package/packages/forms/src/components/Textarea.tsx +49 -54
- package/packages/forms/src/components/controlled/CheckboxGroup.tsx +15 -17
- package/packages/forms/src/components/controlled/RadioGroup.tsx +16 -18
- package/packages/forms/src/components/index.ts +8 -8
- package/packages/forms/src/components/inputStyle.ts +7 -8
- package/packages/forms/src/index.ts +0 -11
- package/packages/forms/tests/Checkbox.test.tsx +44 -0
- package/packages/forms/tests/FieldsetControl.test.tsx +68 -11
- package/packages/forms/tests/FileInput.test.tsx +25 -0
- package/packages/forms/tests/Input.test.tsx +12 -83
- package/packages/forms/tests/LabelControl.test.tsx +88 -20
- package/packages/forms/tests/Radio.test.tsx +23 -78
- package/packages/forms/tests/Select.test.tsx +30 -0
- package/packages/forms/tests/Textarea.test.tsx +25 -0
- package/packages/forms/tests/vitest.setup.ts +1 -0
- package/packages/forms/tsconfig.node.json +3 -2
- package/packages/forms/vite.config.ts +2 -1
- package/packages/helper/.turbo/turbo-build.log +12 -0
- package/packages/helper/dist/index.cjs.js +76 -0
- package/packages/helper/dist/index.es.js +119 -0
- package/packages/helper/dist/types/calc.d.ts +2 -0
- package/packages/helper/dist/types/calc.d.ts.map +1 -0
- package/packages/{forms/dist/types/utils/class.d.ts → helper/dist/types/cx.d.ts} +1 -1
- package/packages/helper/dist/types/cx.d.ts.map +1 -0
- package/packages/helper/dist/types/index.d.ts +6 -0
- package/packages/helper/dist/types/index.d.ts.map +1 -0
- package/packages/helper/dist/types/querySelector.d.ts +2 -0
- package/packages/helper/dist/types/querySelector.d.ts.map +1 -0
- package/packages/helper/dist/types/styles.d.ts +22 -0
- package/packages/helper/dist/types/styles.d.ts.map +1 -0
- package/packages/helper/dist/types/treefy.d.ts +8 -0
- package/packages/helper/dist/types/treefy.d.ts.map +1 -0
- package/packages/helper/node_modules/.bin/vitest +55 -0
- package/packages/helper/package.json +50 -0
- package/packages/helper/src/calc.ts +1 -0
- package/packages/helper/src/cx.ts +2 -0
- package/packages/helper/src/index.ts +5 -0
- package/packages/helper/src/querySelector.ts +20 -0
- package/packages/helper/src/styles.ts +114 -0
- package/packages/helper/src/treefy.ts +24 -0
- package/packages/helper/tests/calc.test.ts +22 -0
- package/packages/helper/tests/cx.test.ts +30 -0
- package/packages/helper/tests/querySelector.test.ts +24 -0
- package/packages/helper/tests/treefy.test.ts +111 -0
- package/packages/helper/tests/vitest.setup.ts +2 -0
- package/packages/helper/tsconfig.json +13 -0
- package/packages/helper/tsconfig.node.json +6 -0
- package/packages/helper/vite.config.ts +26 -0
- package/packages/markdown/.turbo/turbo-build.log +12 -0
- package/packages/markdown/README.md +129 -0
- package/packages/markdown/dist/index.cjs.js +149 -0
- package/packages/markdown/dist/index.es.js +16960 -0
- package/packages/markdown/dist/types/components/Markdown.d.ts +15 -0
- package/packages/markdown/dist/types/components/Markdown.d.ts.map +1 -0
- package/packages/markdown/dist/types/components/index.d.ts +2 -0
- package/packages/markdown/dist/types/components/index.d.ts.map +1 -0
- package/packages/markdown/dist/types/index.d.ts +2 -0
- package/packages/markdown/dist/types/index.d.ts.map +1 -0
- package/packages/markdown/dist/types/plugins/attr.d.ts +3 -0
- package/packages/markdown/dist/types/plugins/attr.d.ts.map +1 -0
- package/packages/markdown/dist/types/plugins/card.d.ts +3 -0
- package/packages/markdown/dist/types/plugins/card.d.ts.map +1 -0
- package/packages/markdown/dist/types/plugins/cell.d.ts +3 -0
- package/packages/markdown/dist/types/plugins/cell.d.ts.map +1 -0
- package/packages/markdown/dist/types/plugins/faq.d.ts +3 -0
- package/packages/markdown/dist/types/plugins/faq.d.ts.map +1 -0
- package/packages/markdown/dist/types/plugins/grid.d.ts +3 -0
- package/packages/markdown/dist/types/plugins/grid.d.ts.map +1 -0
- package/packages/markdown/dist/types/plugins/headings.d.ts +11 -0
- package/packages/markdown/dist/types/plugins/headings.d.ts.map +1 -0
- package/packages/markdown/dist/types/plugins/helper.d.ts +9 -0
- package/packages/markdown/dist/types/plugins/helper.d.ts.map +1 -0
- package/packages/markdown/dist/types/plugins/index.d.ts +9 -0
- package/packages/markdown/dist/types/plugins/index.d.ts.map +1 -0
- package/packages/markdown/dist/types/plugins/linkButton.d.ts +3 -0
- package/packages/markdown/dist/types/plugins/linkButton.d.ts.map +1 -0
- package/packages/markdown/dist/types/plugins/youtube.d.ts +3 -0
- package/packages/markdown/dist/types/plugins/youtube.d.ts.map +1 -0
- package/packages/markdown/node_modules/.bin/autoprefixer +55 -0
- package/packages/markdown/package.json +84 -0
- package/packages/markdown/src/components/Markdown.tsx +365 -0
- package/packages/markdown/src/components/index.ts +1 -0
- package/packages/markdown/src/global.d.ts +9 -0
- package/packages/markdown/src/index.ts +1 -0
- package/packages/markdown/src/plugins/attr.ts +19 -0
- package/packages/markdown/src/plugins/card.ts +57 -0
- package/packages/markdown/src/plugins/cell.ts +47 -0
- package/packages/markdown/src/plugins/faq.ts +40 -0
- package/packages/markdown/src/plugins/grid.ts +54 -0
- package/packages/markdown/src/plugins/headings.ts +38 -0
- package/packages/markdown/src/plugins/helper.ts +27 -0
- package/packages/markdown/src/plugins/index.ts +8 -0
- package/packages/markdown/src/plugins/linkButton.ts +26 -0
- package/packages/markdown/src/plugins/youtube.ts +49 -0
- package/packages/markdown/tsconfig.json +13 -0
- package/packages/markdown/tsconfig.node.json +7 -0
- package/packages/markdown/vite.config.ts +30 -0
- package/packages/tailwind-theme-plugin/#package.json# +51 -0
- package/packages/tailwind-theme-plugin/.turbo/turbo-build.log +12 -0
- package/packages/tailwind-theme-plugin/dist/index.cjs.js +1 -1
- package/packages/tailwind-theme-plugin/dist/index.es.js +4970 -6093
- package/packages/tailwind-theme-plugin/dist/types/index.d.ts +1 -4
- package/packages/tailwind-theme-plugin/dist/types/index.d.ts.map +1 -1
- package/packages/tailwind-theme-plugin/node_modules/.bin/autoprefixer +44 -6
- package/packages/tailwind-theme-plugin/package.json +11 -9
- package/packages/tailwind-theme-plugin/src/index.ts +241 -349
- package/packages/tailwind-theme-plugin/vite.config.ts +2 -0
- package/packages/core/src/libs/cx.ts +0 -2
- package/packages/core/src/libs/forward-ref.ts +0 -44
- package/packages/core/src/types/component.ts +0 -83
- package/packages/forms/dist/types/utils/class.d.ts.map +0 -1
- package/packages/forms/node_modules/.bin/acorn +0 -17
- package/packages/forms/node_modules/.bin/browserslist +0 -17
- package/packages/forms/node_modules/.bin/eslint +0 -17
- package/packages/forms/node_modules/.bin/tailwind +0 -17
- package/packages/forms/node_modules/.bin/tailwindcss +0 -17
- package/packages/forms/node_modules/.bin/ts-node +0 -17
- package/packages/forms/node_modules/.bin/ts-node-cwd +0 -17
- package/packages/forms/node_modules/.bin/ts-node-esm +0 -17
- package/packages/forms/node_modules/.bin/ts-node-script +0 -17
- package/packages/forms/node_modules/.bin/ts-node-transpile-only +0 -17
- package/packages/forms/node_modules/.bin/ts-script +0 -17
- package/packages/forms/node_modules/.bin/vitest +0 -17
- package/packages/forms/src/utils/class.ts +0 -2
- package/packages/tailwind-theme-plugin/node_modules/.bin/browserslist +0 -17
- package/packages/tailwind-theme-plugin/node_modules/.bin/tailwind +0 -17
- package/packages/tailwind-theme-plugin/node_modules/.bin/tailwindcss +0 -17
- package/packages/tailwind-theme-plugin/node_modules/.bin/ts-node +0 -17
- package/packages/tailwind-theme-plugin/node_modules/.bin/ts-node-cwd +0 -17
- package/packages/tailwind-theme-plugin/node_modules/.bin/ts-node-esm +0 -17
- package/packages/tailwind-theme-plugin/node_modules/.bin/ts-node-script +0 -17
- package/packages/tailwind-theme-plugin/node_modules/.bin/ts-node-transpile-only +0 -17
- package/packages/tailwind-theme-plugin/node_modules/.bin/ts-script +0 -17
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { cx, Style } from '@sakura-ui/helper'
|
|
3
|
+
import { Card, CardFooter, CardHeader } from './Card'
|
|
4
|
+
import { Icon } from './Icon'
|
|
5
|
+
|
|
6
|
+
export namespace LinkCard {
|
|
7
|
+
export interface Props<T extends React.ElementType>
|
|
8
|
+
extends React.ComponentProps<'article'> {
|
|
9
|
+
href: string
|
|
10
|
+
target?: string
|
|
11
|
+
linkAs?: T
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const LinkCard = <T extends React.ElementType = 'a'>(
|
|
16
|
+
props: LinkCard.Props<T>
|
|
17
|
+
) => {
|
|
18
|
+
const {
|
|
19
|
+
href,
|
|
20
|
+
target,
|
|
21
|
+
linkAs: Component = 'a',
|
|
22
|
+
className,
|
|
23
|
+
children,
|
|
24
|
+
...rest
|
|
25
|
+
} = props
|
|
26
|
+
|
|
27
|
+
const styleLink = `
|
|
28
|
+
grid
|
|
29
|
+
outline-offset-4
|
|
30
|
+
rounded-2xl
|
|
31
|
+
sm:rounded-3xl
|
|
32
|
+
w-full h-full
|
|
33
|
+
${Style.focusCard}
|
|
34
|
+
group
|
|
35
|
+
`
|
|
36
|
+
|
|
37
|
+
const styleHover = `
|
|
38
|
+
group-hover:outline
|
|
39
|
+
group-hover:outline-blue-900
|
|
40
|
+
group-hover:outline-4
|
|
41
|
+
group-hover:outline-offset-[-1px]
|
|
42
|
+
`
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<Component className={cx(styleLink)} href={href} target={target}>
|
|
46
|
+
<Card className={cx(styleHover, className)} {...rest}>
|
|
47
|
+
{children}
|
|
48
|
+
</Card>
|
|
49
|
+
</Component>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export namespace LinkCardHeader {
|
|
54
|
+
export interface Props extends React.ComponentProps<'div'> {
|
|
55
|
+
target?: string
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const LinkCardHeader = ({
|
|
60
|
+
target,
|
|
61
|
+
className,
|
|
62
|
+
children
|
|
63
|
+
}: LinkCardHeader.Props) => {
|
|
64
|
+
const styleHeading = `
|
|
65
|
+
decoration-blue-900
|
|
66
|
+
underline
|
|
67
|
+
underline-offset-[calc(3/16*1rem)]
|
|
68
|
+
`
|
|
69
|
+
const styleHover = `
|
|
70
|
+
group-hover:text-blue-900
|
|
71
|
+
group-hover:decoration-[calc(3/16*1rem)]
|
|
72
|
+
`
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<CardHeader className={cx(className, styleHeading, styleHover)}>
|
|
76
|
+
<span>
|
|
77
|
+
{children}
|
|
78
|
+
{target === '_blank' && (
|
|
79
|
+
<Icon opticalSize={16} className="ml-1">
|
|
80
|
+
open_in_new
|
|
81
|
+
</Icon>
|
|
82
|
+
)}
|
|
83
|
+
</span>
|
|
84
|
+
</CardHeader>
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export namespace LinkCardFooter {
|
|
89
|
+
export interface Props extends React.ComponentProps<'div'> {}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export const LinkCardFooter = ({
|
|
93
|
+
className,
|
|
94
|
+
children
|
|
95
|
+
}: LinkCardFooter.Props) => {
|
|
96
|
+
const style = `
|
|
97
|
+
flex
|
|
98
|
+
justify-between
|
|
99
|
+
items-center
|
|
100
|
+
`
|
|
101
|
+
|
|
102
|
+
const styleIcon = `
|
|
103
|
+
inline-flex
|
|
104
|
+
items-center
|
|
105
|
+
justify-center
|
|
106
|
+
w-6 h-6
|
|
107
|
+
text-blue-1000
|
|
108
|
+
border
|
|
109
|
+
border-blue-1000
|
|
110
|
+
rounded-full
|
|
111
|
+
`
|
|
112
|
+
|
|
113
|
+
const styleIconHover = `
|
|
114
|
+
group-hover:bg-blue-1000
|
|
115
|
+
group-hover:text-white
|
|
116
|
+
`
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<CardFooter className={cx(className, style)}>
|
|
120
|
+
<span>{children}</span>
|
|
121
|
+
<span className={cx(styleIcon, styleIconHover)}>
|
|
122
|
+
<Icon opticalSize={16}>arrow_forward</Icon>
|
|
123
|
+
</span>
|
|
124
|
+
</CardFooter>
|
|
125
|
+
)
|
|
126
|
+
}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { cx } from '
|
|
2
|
+
import { cx } from '@sakura-ui/helper'
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export namespace Ul {
|
|
5
|
+
export interface Props extends React.ComponentPropsWithoutRef<'ul'> {}
|
|
6
|
+
}
|
|
5
7
|
|
|
6
|
-
export const Ul = (props:
|
|
8
|
+
export const Ul = (props: Ul.Props) => {
|
|
7
9
|
const { className, children, ...restProps } = props
|
|
8
10
|
|
|
9
11
|
const style = `
|
|
10
12
|
list-disc
|
|
11
|
-
list-
|
|
12
|
-
-
|
|
13
|
-
pl-
|
|
14
|
-
marker:text-base-sm
|
|
13
|
+
[&_&]:list-circle
|
|
14
|
+
[&_&_&]:list-square
|
|
15
|
+
pl-8
|
|
15
16
|
`
|
|
16
17
|
return (
|
|
17
18
|
<ul className={cx(style, className)} {...restProps}>
|
|
@@ -20,16 +21,17 @@ export const Ul = (props: UlProps) => {
|
|
|
20
21
|
)
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
export
|
|
24
|
+
export namespace Ol {
|
|
25
|
+
export interface Props extends React.ComponentPropsWithoutRef<'ol'> {}
|
|
26
|
+
}
|
|
24
27
|
|
|
25
|
-
export const Ol = (props:
|
|
28
|
+
export const Ol = (props: Ol.Props) => {
|
|
26
29
|
const { className, children, ...restProps } = props
|
|
27
30
|
|
|
28
31
|
const style = `
|
|
29
32
|
list-decimal
|
|
30
|
-
list-
|
|
31
|
-
-
|
|
32
|
-
pl-4
|
|
33
|
+
[&_&]:list-lower-latin
|
|
34
|
+
pl-8
|
|
33
35
|
`
|
|
34
36
|
return (
|
|
35
37
|
<ol className={cx(style, className)} {...restProps}>
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { cx, mod, focusableSelector, Style } from '@sakura-ui/helper'
|
|
3
|
+
import { Menu, MenuMobile, Close, CloseMobile } from '@/icons'
|
|
4
|
+
|
|
5
|
+
export namespace MenuButton {
|
|
6
|
+
export interface Props extends React.ComponentPropsWithRef<'button'> {}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const MenuButton = ({
|
|
10
|
+
className,
|
|
11
|
+
children,
|
|
12
|
+
onChange,
|
|
13
|
+
...rest
|
|
14
|
+
}: MenuButton.Props) => {
|
|
15
|
+
// leading 16px * 1.375(snug) + padding top 12px + padding bottom 12px + border * 2 = 48px
|
|
16
|
+
const styleMenuItem = `
|
|
17
|
+
w-fit
|
|
18
|
+
py-[1px]
|
|
19
|
+
sm:py-3
|
|
20
|
+
text-base
|
|
21
|
+
leading-snug
|
|
22
|
+
${Style.clickable}
|
|
23
|
+
${Style.hoverUnderline}
|
|
24
|
+
${Style.focusRoundedWithBg}
|
|
25
|
+
`
|
|
26
|
+
|
|
27
|
+
const dialogRef = React.useRef<HTMLDialogElement>(null)
|
|
28
|
+
|
|
29
|
+
React.useEffect(() => {
|
|
30
|
+
document.body.style.overflow = 'auto'
|
|
31
|
+
}, [])
|
|
32
|
+
|
|
33
|
+
const open = () => {
|
|
34
|
+
dialogRef.current?.showModal()
|
|
35
|
+
document.body.style.overflow = 'hidden'
|
|
36
|
+
}
|
|
37
|
+
const close = () => {
|
|
38
|
+
dialogRef.current?.close()
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const handleKeyDown = (e: React.KeyboardEvent<HTMLElement>) => {
|
|
42
|
+
// Focus trap
|
|
43
|
+
if (e.key === 'Tab') {
|
|
44
|
+
e.preventDefault()
|
|
45
|
+
|
|
46
|
+
const focusables: HTMLElement[] = Array.from(
|
|
47
|
+
dialogRef.current?.querySelectorAll(focusableSelector) || []
|
|
48
|
+
)
|
|
49
|
+
if (focusables.length === 0) return
|
|
50
|
+
|
|
51
|
+
const tabIndex = focusables.indexOf(
|
|
52
|
+
document.activeElement as HTMLElement
|
|
53
|
+
)
|
|
54
|
+
// If there is no focused element, focus the first element
|
|
55
|
+
if (tabIndex === -1) {
|
|
56
|
+
focusables[0].focus()
|
|
57
|
+
return
|
|
58
|
+
}
|
|
59
|
+
const nextIndex = mod(tabIndex + (e.shiftKey ? -1 : 1), focusables.length)
|
|
60
|
+
focusables[nextIndex].focus()
|
|
61
|
+
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
if (e.key === 'Escape') {
|
|
65
|
+
e.preventDefault()
|
|
66
|
+
|
|
67
|
+
close()
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const handleOnClose = (_: React.KeyboardEvent<HTMLDialogElement>) => {
|
|
72
|
+
document.body.style.overflow = 'auto'
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const handleOnClick = (e: React.MouseEvent<HTMLElement>) => {
|
|
76
|
+
if ((e.target as HTMLElement).nodeName === 'DIALOG') {
|
|
77
|
+
close()
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<div className={className}>
|
|
83
|
+
<dialog
|
|
84
|
+
ref={dialogRef}
|
|
85
|
+
className="peer"
|
|
86
|
+
onKeyDown={handleKeyDown}
|
|
87
|
+
onClick={handleOnClick}
|
|
88
|
+
onClose={handleOnClose}
|
|
89
|
+
>
|
|
90
|
+
{children}
|
|
91
|
+
</dialog>
|
|
92
|
+
<button
|
|
93
|
+
className={cx(styleMenuItem, 'flex items-center peer-open:hidden')}
|
|
94
|
+
onClick={open}
|
|
95
|
+
{...rest}
|
|
96
|
+
>
|
|
97
|
+
<MenuMobile size={44} className="inline-block sm:hidden" />
|
|
98
|
+
<Menu size={22} className="hidden sm:inline-block mr-1" />
|
|
99
|
+
<span className="hidden sm:inline">Menu</span>
|
|
100
|
+
</button>
|
|
101
|
+
<button
|
|
102
|
+
className={cx(styleMenuItem, 'peer-open:flex items-center hidden')}
|
|
103
|
+
onClick={close}
|
|
104
|
+
{...rest}
|
|
105
|
+
>
|
|
106
|
+
<CloseMobile size={44} className="inline-block sm:hidden" />
|
|
107
|
+
<Close size={22} className="hidden sm:inline-block mr-1" />
|
|
108
|
+
<span className="hidden sm:inline">Close</span>
|
|
109
|
+
</button>
|
|
110
|
+
</div>
|
|
111
|
+
)
|
|
112
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { cx, Style } from '@sakura-ui/helper'
|
|
3
|
+
|
|
4
|
+
export namespace NavigationItem {
|
|
5
|
+
export interface Props<T extends React.ElementType> {
|
|
6
|
+
as?: T
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const NavigationItem = <T extends React.ElementType = 'a'>(
|
|
11
|
+
props: NavigationItem.Props<T> &
|
|
12
|
+
Omit<React.ComponentProps<T>, keyof NavigationItem.Props<T>>
|
|
13
|
+
) => {
|
|
14
|
+
const { as, className, children, ...rest } = props
|
|
15
|
+
|
|
16
|
+
const Component = as || 'a'
|
|
17
|
+
|
|
18
|
+
// leading 16px * 1.375(snug) + padding top 12px + padding bottom 12px + border * 2 = 48px
|
|
19
|
+
const style = `
|
|
20
|
+
inline-block
|
|
21
|
+
w-fit
|
|
22
|
+
py-3
|
|
23
|
+
text-base
|
|
24
|
+
leading-snug
|
|
25
|
+
${Style.clickable}
|
|
26
|
+
${Style.hoverUnderline}
|
|
27
|
+
${Style.focusRectWithBg}
|
|
28
|
+
`
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<Component
|
|
32
|
+
className={cx(style, className)}
|
|
33
|
+
rel="noopener noreferrer"
|
|
34
|
+
{...rest}
|
|
35
|
+
>
|
|
36
|
+
{children}
|
|
37
|
+
</Component>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
NavigationItem.displayName = 'NavigationItem'
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { cx } from '@sakura-ui/helper'
|
|
3
|
+
import { Card } from './Card'
|
|
4
|
+
|
|
5
|
+
export namespace NotificationBanner {
|
|
6
|
+
export interface Props extends React.ComponentPropsWithoutRef<'article'> {}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const NotificationBanner = (props: NotificationBanner.Props) => {
|
|
10
|
+
const { className, children, ...restProps } = props
|
|
11
|
+
|
|
12
|
+
const style = `
|
|
13
|
+
`
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Card className={cx(style, className)} {...restProps}>
|
|
17
|
+
{children}
|
|
18
|
+
</Card>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { cx } from '@sakura-ui/helper'
|
|
3
|
+
|
|
4
|
+
export namespace OverflowContainer {
|
|
5
|
+
export interface Props extends React.ComponentPropsWithoutRef<'div'> {}
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const OverflowContainer = (props: OverflowContainer.Props) => {
|
|
9
|
+
const { className, children, ...restProps } = props
|
|
10
|
+
|
|
11
|
+
const style = `
|
|
12
|
+
w-full
|
|
13
|
+
overflow-x-auto
|
|
14
|
+
whitespace-nowrap
|
|
15
|
+
print:overflow-visible
|
|
16
|
+
print:whitespace-normal
|
|
17
|
+
`
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<div className={cx(style, className)} {...restProps}>
|
|
21
|
+
{children}
|
|
22
|
+
</div>
|
|
23
|
+
)
|
|
24
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { cx, Style } from '@sakura-ui/helper'
|
|
3
|
+
import { Icon } from './Icon'
|
|
4
|
+
|
|
5
|
+
export const PopoverMenu = React.forwardRef<
|
|
6
|
+
HTMLUListElement,
|
|
7
|
+
React.ComponentProps<'ul'>
|
|
8
|
+
>((props, ref) => {
|
|
9
|
+
const { className, children, ...rest } = props
|
|
10
|
+
const stylePopover = `
|
|
11
|
+
min-w-fit
|
|
12
|
+
w-auto
|
|
13
|
+
py-2
|
|
14
|
+
bg-white
|
|
15
|
+
shadow-1
|
|
16
|
+
rounded-lg
|
|
17
|
+
border
|
|
18
|
+
border-solid-grey-420
|
|
19
|
+
has-[>:nth-child(7)]:rounded-r-none
|
|
20
|
+
`
|
|
21
|
+
|
|
22
|
+
const style = `
|
|
23
|
+
font-normal
|
|
24
|
+
whitespace-nowrap
|
|
25
|
+
${stylePopover}
|
|
26
|
+
`
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
// biome-ignore lint/a11y/noNoninteractiveElementToInteractiveRole: the WAI-ARIA authoring practices build menus from a ul with role="menu"
|
|
30
|
+
<ul ref={ref} role="menu" className={cx(className, style)} {...rest}>
|
|
31
|
+
{children}
|
|
32
|
+
</ul>
|
|
33
|
+
)
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
PopoverMenu.displayName = 'PopoverMenu'
|
|
37
|
+
|
|
38
|
+
export const PopoverMenuItem = React.forwardRef<
|
|
39
|
+
HTMLAnchorElement,
|
|
40
|
+
React.ComponentProps<'a'>
|
|
41
|
+
>((props, ref) => {
|
|
42
|
+
const { className, children, ...rest } = props
|
|
43
|
+
|
|
44
|
+
const style = `
|
|
45
|
+
py-1.5 pl-1.5 pr-4
|
|
46
|
+
flex
|
|
47
|
+
items-center
|
|
48
|
+
gap-x-1.5
|
|
49
|
+
hover:bg-solid-grey-50
|
|
50
|
+
${Style.focusRectCondensedWithBg}
|
|
51
|
+
`
|
|
52
|
+
|
|
53
|
+
const styleSelected = `
|
|
54
|
+
!text-blue-1000
|
|
55
|
+
!bg-blue-100
|
|
56
|
+
font-bold
|
|
57
|
+
`
|
|
58
|
+
|
|
59
|
+
const current = rest['aria-current'] ?? false
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<li role="presentation">
|
|
63
|
+
<a
|
|
64
|
+
aria-current={current}
|
|
65
|
+
ref={ref}
|
|
66
|
+
role="menuitem"
|
|
67
|
+
className={cx(style, current && styleSelected)}
|
|
68
|
+
{...rest}
|
|
69
|
+
>
|
|
70
|
+
<Icon
|
|
71
|
+
opticalSize={20}
|
|
72
|
+
className={`flex-none ${!current && 'invisible'}`}
|
|
73
|
+
>
|
|
74
|
+
check
|
|
75
|
+
</Icon>
|
|
76
|
+
<span className={Style.hoverUnderline}>{children}</span>
|
|
77
|
+
</a>
|
|
78
|
+
</li>
|
|
79
|
+
)
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
PopoverMenuItem.displayName = 'PopoverMenuItem'
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { cx } from '
|
|
2
|
+
import { cx } from '@sakura-ui/helper'
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export namespace Pre {
|
|
5
|
+
export interface Props extends React.ComponentPropsWithoutRef<'pre'> {}
|
|
6
|
+
}
|
|
5
7
|
|
|
6
|
-
export const Pre = (props:
|
|
8
|
+
export const Pre = (props: Pre.Props) => {
|
|
7
9
|
const { className, children, ...restProps } = props
|
|
8
10
|
|
|
9
11
|
const style = `
|
|
10
12
|
p-4
|
|
11
|
-
bg-
|
|
13
|
+
bg-solid-gray-50
|
|
12
14
|
rounded-lg
|
|
13
15
|
whitespace-pre-wrap
|
|
14
16
|
overflow-y-scroll
|
|
@@ -1,35 +1,31 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { cx } from '
|
|
2
|
+
import { cx } from '@sakura-ui/helper'
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export namespace Table {
|
|
5
|
+
export interface Props extends React.ComponentPropsWithoutRef<'table'> {}
|
|
6
|
+
}
|
|
5
7
|
|
|
6
8
|
const styleBorder = `
|
|
7
9
|
border
|
|
8
10
|
border-collapse
|
|
9
|
-
border-
|
|
11
|
+
border-solid-grey-420
|
|
10
12
|
`
|
|
11
13
|
|
|
12
|
-
export const Table = (props:
|
|
14
|
+
export const Table = (props: Table.Props) => {
|
|
13
15
|
const { className, children, ...restProps } = props
|
|
14
16
|
|
|
15
|
-
// If there is no break-all setting, the table will protrude when using a smartphone
|
|
16
|
-
const style = `
|
|
17
|
-
w-full
|
|
18
|
-
table-auto
|
|
19
|
-
break-all
|
|
20
|
-
`
|
|
21
|
-
|
|
22
17
|
return (
|
|
23
|
-
<table className={cx(
|
|
18
|
+
<table className={cx(styleBorder, className)} {...restProps}>
|
|
24
19
|
{children}
|
|
25
20
|
</table>
|
|
26
21
|
)
|
|
27
22
|
}
|
|
28
23
|
|
|
29
|
-
export
|
|
30
|
-
extends React.ComponentPropsWithoutRef<'caption'> {}
|
|
24
|
+
export namespace Caption {
|
|
25
|
+
export interface Props extends React.ComponentPropsWithoutRef<'caption'> {}
|
|
26
|
+
}
|
|
31
27
|
|
|
32
|
-
export const Caption = (props:
|
|
28
|
+
export const Caption = (props: Caption.Props) => {
|
|
33
29
|
const { className, children, ...restProps } = props
|
|
34
30
|
|
|
35
31
|
const style = 'text-left'
|
|
@@ -40,9 +36,11 @@ export const Caption = (props: CaptionProps) => {
|
|
|
40
36
|
)
|
|
41
37
|
}
|
|
42
38
|
|
|
43
|
-
export
|
|
39
|
+
export namespace Thead {
|
|
40
|
+
export interface Props extends React.ComponentPropsWithoutRef<'thead'> {}
|
|
41
|
+
}
|
|
44
42
|
|
|
45
|
-
export const Thead = (props:
|
|
43
|
+
export const Thead = (props: Thead.Props) => {
|
|
46
44
|
const { className, children, ...restProps } = props
|
|
47
45
|
|
|
48
46
|
return (
|
|
@@ -52,9 +50,11 @@ export const Thead = (props: TheadProps) => {
|
|
|
52
50
|
)
|
|
53
51
|
}
|
|
54
52
|
|
|
55
|
-
export
|
|
53
|
+
export namespace Tbody {
|
|
54
|
+
export interface Props extends React.ComponentPropsWithoutRef<'tbody'> {}
|
|
55
|
+
}
|
|
56
56
|
|
|
57
|
-
export const Tbody = (props:
|
|
57
|
+
export const Tbody = (props: Tbody.Props) => {
|
|
58
58
|
const { className, children, ...restProps } = props
|
|
59
59
|
|
|
60
60
|
return (
|
|
@@ -64,9 +64,11 @@ export const Tbody = (props: TbodyProps) => {
|
|
|
64
64
|
)
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
export
|
|
67
|
+
export namespace Th {
|
|
68
|
+
export interface Props extends React.ComponentPropsWithoutRef<'th'> {}
|
|
69
|
+
}
|
|
68
70
|
|
|
69
|
-
export const Th = (props:
|
|
71
|
+
export const Th = (props: Th.Props) => {
|
|
70
72
|
const { className, children, ...restProps } = props
|
|
71
73
|
|
|
72
74
|
const style = `
|
|
@@ -82,9 +84,11 @@ export const Th = (props: ThProps) => {
|
|
|
82
84
|
)
|
|
83
85
|
}
|
|
84
86
|
|
|
85
|
-
export
|
|
87
|
+
export namespace Tr {
|
|
88
|
+
export interface Props extends React.ComponentPropsWithoutRef<'tr'> {}
|
|
89
|
+
}
|
|
86
90
|
|
|
87
|
-
export const Tr = (props:
|
|
91
|
+
export const Tr = (props: Tr.Props) => {
|
|
88
92
|
const { className, children, ...restProps } = props
|
|
89
93
|
|
|
90
94
|
const style = ''
|
|
@@ -96,9 +100,11 @@ export const Tr = (props: TrProps) => {
|
|
|
96
100
|
)
|
|
97
101
|
}
|
|
98
102
|
|
|
99
|
-
export
|
|
103
|
+
export namespace Td {
|
|
104
|
+
export interface Props extends React.ComponentPropsWithoutRef<'td'> {}
|
|
105
|
+
}
|
|
100
106
|
|
|
101
|
-
export const Td = (props:
|
|
107
|
+
export const Td = (props: Td.Props) => {
|
|
102
108
|
const { className, children, ...restProps } = props
|
|
103
109
|
|
|
104
110
|
const style = `
|