@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,76 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=':not([tabindex^="-"])',n=":not(:disabled)",d=[`a[href]${o}`,`area[href]${o}`,`input:not([type="hidden"])${o}${n}`,`select${o}${n}`,`textarea${o}${n}`,`button${o}${n}`,`details > summary:first-of-type${o}`,`details:not(:has(> summary))${o}`,`iframe${o}`,`audio[controls]${o}`,`video[controls]${o}`,`[contenteditable]${o}`,`[tabindex]${o}`],f=d.join(","),a=(e,s)=>(e%s+s)%s,b=(...e)=>e.filter(Boolean).join(" "),h=e=>{const s=[],c=[];let t=-1,r=-1;for(const{children:v,...i}of e){if(t<i.depth&&i.depth<=r+1){const l=i.depth-t;r=i.depth;const u=c[l-1];u.children??=[],u.children.push(i),c[l]=i;continue}s.push(i),c[0]=i,t=r=i.depth}return s};exports.Style=void 0;(e=>{e.clickable=`
|
|
2
|
+
px-2
|
|
3
|
+
min-h-[calc(44/16*1rem)]
|
|
4
|
+
border
|
|
5
|
+
border-transparent
|
|
6
|
+
rounded-lg
|
|
7
|
+
hover:bg-solid-grey-50
|
|
8
|
+
`,e.selected=`
|
|
9
|
+
rounded-full
|
|
10
|
+
bg-yellow-50
|
|
11
|
+
`;const s=`
|
|
12
|
+
focus-visible:outline-4
|
|
13
|
+
focus-visible:outline-black
|
|
14
|
+
focus-visible:ring-yellow-300
|
|
15
|
+
`;e.focusRectCondensed=`
|
|
16
|
+
${s}
|
|
17
|
+
focus-visible:-outline-offset-4
|
|
18
|
+
focus-visible:ring-[calc(6/16*1rem)]
|
|
19
|
+
focus-visible:ring-inset
|
|
20
|
+
`,e.focusRectCondensedWithBg=`
|
|
21
|
+
${e.focusRectCondensed}
|
|
22
|
+
focus-visible:bg-yellow-300
|
|
23
|
+
`,e.focusRect=`
|
|
24
|
+
${s}
|
|
25
|
+
focus-visible:outline-offset-[calc(2/16*1rem)]
|
|
26
|
+
focus-visible:ring-[calc(2/16*1rem)]
|
|
27
|
+
`,e.focusRounded=`
|
|
28
|
+
${e.focusRect}
|
|
29
|
+
focus-visible:rounded-sm
|
|
30
|
+
`,e.focusCard=`
|
|
31
|
+
${e.focusRect}
|
|
32
|
+
focus-visible:rounded-2xl
|
|
33
|
+
sm:focus-visible:rounded-3xl
|
|
34
|
+
`,e.focusRectWithBg=`
|
|
35
|
+
${e.focusRect}
|
|
36
|
+
focus-visible:bg-yellow-300
|
|
37
|
+
`,e.focusRoundedWithBg=`
|
|
38
|
+
${e.focusRectWithBg}
|
|
39
|
+
focus-visible:rounded-sm
|
|
40
|
+
`,e.hoverUnderline=`
|
|
41
|
+
hover:underline
|
|
42
|
+
hover:underline-offset-[calc(3/16*1rem)]
|
|
43
|
+
`,e.underline=`
|
|
44
|
+
underline
|
|
45
|
+
underline-offset-[calc(3/16*1rem)]
|
|
46
|
+
hover:decoration-[calc(3/16*1rem)]
|
|
47
|
+
`,e.underlineNoDeco=`
|
|
48
|
+
underline
|
|
49
|
+
underline-offset-[calc(3/16*1rem)]
|
|
50
|
+
`,e.popover=`
|
|
51
|
+
min-w-fit
|
|
52
|
+
w-auto
|
|
53
|
+
py-2
|
|
54
|
+
bg-white
|
|
55
|
+
shadow-1
|
|
56
|
+
rounded-lg
|
|
57
|
+
border
|
|
58
|
+
border-solid-grey-420
|
|
59
|
+
has-[>:nth-child(7)]:rounded-r-none
|
|
60
|
+
`,e.popoverPositionBottomRight=`
|
|
61
|
+
absolute
|
|
62
|
+
top-11
|
|
63
|
+
right-0
|
|
64
|
+
`,e.popoverPositionBottomLeft=`
|
|
65
|
+
absolute
|
|
66
|
+
top-11
|
|
67
|
+
left-0
|
|
68
|
+
`,(c=>{c.focus=`
|
|
69
|
+
peer-focus-visible:outline-4
|
|
70
|
+
peer-focus-visible:outline-black
|
|
71
|
+
peer-focus-visible:ring-yellow-300
|
|
72
|
+
`,c.focusRect=`
|
|
73
|
+
${c.focus}
|
|
74
|
+
peer-focus-visible:outline-offset-[calc(2/16*1rem)]
|
|
75
|
+
peer-focus-visible:ring-[calc(2/16*1rem)]
|
|
76
|
+
`})(e.Peer||(e.Peer={}))})(exports.Style||(exports.Style={}));exports.cx=b;exports.focusableSelector=f;exports.mod=a;exports.treefy=h;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
const o = ':not([tabindex^="-"])', n = ":not(:disabled)", f = [
|
|
2
|
+
`a[href]${o}`,
|
|
3
|
+
`area[href]${o}`,
|
|
4
|
+
`input:not([type="hidden"])${o}${n}`,
|
|
5
|
+
`select${o}${n}`,
|
|
6
|
+
`textarea${o}${n}`,
|
|
7
|
+
`button${o}${n}`,
|
|
8
|
+
`details > summary:first-of-type${o}`,
|
|
9
|
+
`details:not(:has(> summary))${o}`,
|
|
10
|
+
`iframe${o}`,
|
|
11
|
+
`audio[controls]${o}`,
|
|
12
|
+
`video[controls]${o}`,
|
|
13
|
+
`[contenteditable]${o}`,
|
|
14
|
+
`[tabindex]${o}`
|
|
15
|
+
], b = f.join(","), h = (e, s) => (e % s + s) % s, p = (...e) => e.filter(Boolean).join(" "), v = (e) => {
|
|
16
|
+
const s = [], c = [];
|
|
17
|
+
let t = -1, r = -1;
|
|
18
|
+
for (const { children: a, ...i } of e) {
|
|
19
|
+
if (t < i.depth && i.depth <= r + 1) {
|
|
20
|
+
const u = i.depth - t;
|
|
21
|
+
r = i.depth;
|
|
22
|
+
const l = c[u - 1];
|
|
23
|
+
l.children ??= [], l.children.push(i), c[u] = i;
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
s.push(i), c[0] = i, t = r = i.depth;
|
|
27
|
+
}
|
|
28
|
+
return s;
|
|
29
|
+
};
|
|
30
|
+
var d;
|
|
31
|
+
((e) => {
|
|
32
|
+
e.clickable = `
|
|
33
|
+
px-2
|
|
34
|
+
min-h-[calc(44/16*1rem)]
|
|
35
|
+
border
|
|
36
|
+
border-transparent
|
|
37
|
+
rounded-lg
|
|
38
|
+
hover:bg-solid-grey-50
|
|
39
|
+
`, e.selected = `
|
|
40
|
+
rounded-full
|
|
41
|
+
bg-yellow-50
|
|
42
|
+
`;
|
|
43
|
+
const s = `
|
|
44
|
+
focus-visible:outline-4
|
|
45
|
+
focus-visible:outline-black
|
|
46
|
+
focus-visible:ring-yellow-300
|
|
47
|
+
`;
|
|
48
|
+
e.focusRectCondensed = `
|
|
49
|
+
${s}
|
|
50
|
+
focus-visible:-outline-offset-4
|
|
51
|
+
focus-visible:ring-[calc(6/16*1rem)]
|
|
52
|
+
focus-visible:ring-inset
|
|
53
|
+
`, e.focusRectCondensedWithBg = `
|
|
54
|
+
${e.focusRectCondensed}
|
|
55
|
+
focus-visible:bg-yellow-300
|
|
56
|
+
`, e.focusRect = `
|
|
57
|
+
${s}
|
|
58
|
+
focus-visible:outline-offset-[calc(2/16*1rem)]
|
|
59
|
+
focus-visible:ring-[calc(2/16*1rem)]
|
|
60
|
+
`, e.focusRounded = `
|
|
61
|
+
${e.focusRect}
|
|
62
|
+
focus-visible:rounded-sm
|
|
63
|
+
`, e.focusCard = `
|
|
64
|
+
${e.focusRect}
|
|
65
|
+
focus-visible:rounded-2xl
|
|
66
|
+
sm:focus-visible:rounded-3xl
|
|
67
|
+
`, e.focusRectWithBg = `
|
|
68
|
+
${e.focusRect}
|
|
69
|
+
focus-visible:bg-yellow-300
|
|
70
|
+
`, e.focusRoundedWithBg = `
|
|
71
|
+
${e.focusRectWithBg}
|
|
72
|
+
focus-visible:rounded-sm
|
|
73
|
+
`, e.hoverUnderline = `
|
|
74
|
+
hover:underline
|
|
75
|
+
hover:underline-offset-[calc(3/16*1rem)]
|
|
76
|
+
`, e.underline = `
|
|
77
|
+
underline
|
|
78
|
+
underline-offset-[calc(3/16*1rem)]
|
|
79
|
+
hover:decoration-[calc(3/16*1rem)]
|
|
80
|
+
`, e.underlineNoDeco = `
|
|
81
|
+
underline
|
|
82
|
+
underline-offset-[calc(3/16*1rem)]
|
|
83
|
+
`, e.popover = `
|
|
84
|
+
min-w-fit
|
|
85
|
+
w-auto
|
|
86
|
+
py-2
|
|
87
|
+
bg-white
|
|
88
|
+
shadow-1
|
|
89
|
+
rounded-lg
|
|
90
|
+
border
|
|
91
|
+
border-solid-grey-420
|
|
92
|
+
has-[>:nth-child(7)]:rounded-r-none
|
|
93
|
+
`, e.popoverPositionBottomRight = `
|
|
94
|
+
absolute
|
|
95
|
+
top-11
|
|
96
|
+
right-0
|
|
97
|
+
`, e.popoverPositionBottomLeft = `
|
|
98
|
+
absolute
|
|
99
|
+
top-11
|
|
100
|
+
left-0
|
|
101
|
+
`, ((c) => {
|
|
102
|
+
c.focus = `
|
|
103
|
+
peer-focus-visible:outline-4
|
|
104
|
+
peer-focus-visible:outline-black
|
|
105
|
+
peer-focus-visible:ring-yellow-300
|
|
106
|
+
`, c.focusRect = `
|
|
107
|
+
${c.focus}
|
|
108
|
+
peer-focus-visible:outline-offset-[calc(2/16*1rem)]
|
|
109
|
+
peer-focus-visible:ring-[calc(2/16*1rem)]
|
|
110
|
+
`;
|
|
111
|
+
})(e.Peer || (e.Peer = {}));
|
|
112
|
+
})(d || (d = {}));
|
|
113
|
+
export {
|
|
114
|
+
d as Style,
|
|
115
|
+
p as cx,
|
|
116
|
+
b as focusableSelector,
|
|
117
|
+
h as mod,
|
|
118
|
+
v as treefy
|
|
119
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calc.d.ts","sourceRoot":"","sources":["../../src/calc.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,GAAG,GAAI,GAAG,MAAM,EAAE,GAAG,MAAM,KAAG,MAA2B,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const cx: (...classNames: any[]) => string;
|
|
2
|
-
//# sourceMappingURL=
|
|
2
|
+
//# sourceMappingURL=cx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cx.d.ts","sourceRoot":"","sources":["../../src/cx.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,EAAE,GAAI,GAAG,YAAY,GAAG,EAAE,WAAyC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAC5B,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAA;AACzB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"querySelector.d.ts","sourceRoot":"","sources":["../../src/querySelector.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,iBAAiB,QAAsB,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare namespace Style {
|
|
2
|
+
const clickable = "\n px-2\n min-h-[calc(44/16*1rem)]\n border\n border-transparent\n rounded-lg\n hover:bg-solid-grey-50\n ";
|
|
3
|
+
const selected = "\n rounded-full\n bg-yellow-50\n ";
|
|
4
|
+
const focusRectCondensed = "\n \n focus-visible:outline-4\n focus-visible:outline-black\n focus-visible:ring-yellow-300\n \n focus-visible:-outline-offset-4\n focus-visible:ring-[calc(6/16*1rem)]\n focus-visible:ring-inset\n ";
|
|
5
|
+
const focusRectCondensedWithBg = "\n \n \n focus-visible:outline-4\n focus-visible:outline-black\n focus-visible:ring-yellow-300\n \n focus-visible:-outline-offset-4\n focus-visible:ring-[calc(6/16*1rem)]\n focus-visible:ring-inset\n \n focus-visible:bg-yellow-300\n ";
|
|
6
|
+
const focusRect = "\n \n focus-visible:outline-4\n focus-visible:outline-black\n focus-visible:ring-yellow-300\n \n focus-visible:outline-offset-[calc(2/16*1rem)]\n focus-visible:ring-[calc(2/16*1rem)]\n ";
|
|
7
|
+
const focusRounded = "\n \n \n focus-visible:outline-4\n focus-visible:outline-black\n focus-visible:ring-yellow-300\n \n focus-visible:outline-offset-[calc(2/16*1rem)]\n focus-visible:ring-[calc(2/16*1rem)]\n \n focus-visible:rounded-sm\n ";
|
|
8
|
+
const focusCard = "\n \n \n focus-visible:outline-4\n focus-visible:outline-black\n focus-visible:ring-yellow-300\n \n focus-visible:outline-offset-[calc(2/16*1rem)]\n focus-visible:ring-[calc(2/16*1rem)]\n \n focus-visible:rounded-2xl\n sm:focus-visible:rounded-3xl\n ";
|
|
9
|
+
const focusRectWithBg = "\n \n \n focus-visible:outline-4\n focus-visible:outline-black\n focus-visible:ring-yellow-300\n \n focus-visible:outline-offset-[calc(2/16*1rem)]\n focus-visible:ring-[calc(2/16*1rem)]\n \n focus-visible:bg-yellow-300\n ";
|
|
10
|
+
const focusRoundedWithBg = "\n \n \n \n focus-visible:outline-4\n focus-visible:outline-black\n focus-visible:ring-yellow-300\n \n focus-visible:outline-offset-[calc(2/16*1rem)]\n focus-visible:ring-[calc(2/16*1rem)]\n \n focus-visible:bg-yellow-300\n \n focus-visible:rounded-sm\n ";
|
|
11
|
+
const hoverUnderline = "\n hover:underline\n hover:underline-offset-[calc(3/16*1rem)]\n ";
|
|
12
|
+
const underline = "\n underline\n underline-offset-[calc(3/16*1rem)]\n hover:decoration-[calc(3/16*1rem)]\n ";
|
|
13
|
+
const underlineNoDeco = "\n underline\n underline-offset-[calc(3/16*1rem)]\n ";
|
|
14
|
+
const popover = "\n min-w-fit\n w-auto\n py-2\n bg-white\n shadow-1\n rounded-lg\n border\n border-solid-grey-420\n has-[>:nth-child(7)]:rounded-r-none\n ";
|
|
15
|
+
const popoverPositionBottomRight = "\n absolute\n top-11\n right-0\n ";
|
|
16
|
+
const popoverPositionBottomLeft = "\n absolute\n top-11\n left-0\n ";
|
|
17
|
+
namespace Peer {
|
|
18
|
+
const focus = "\n peer-focus-visible:outline-4\n peer-focus-visible:outline-black\n peer-focus-visible:ring-yellow-300\n ";
|
|
19
|
+
const focusRect = "\n \n peer-focus-visible:outline-4\n peer-focus-visible:outline-black\n peer-focus-visible:ring-yellow-300\n \n peer-focus-visible:outline-offset-[calc(2/16*1rem)]\n peer-focus-visible:ring-[calc(2/16*1rem)]\n ";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/styles.ts"],"names":[],"mappings":"AAAA,yBAAiB,KAAK,CAAC;IACd,MAAM,SAAS,iIAOrB,CAAA;IAEM,MAAM,QAAQ,6CAGpB,CAAA;IAQM,MAAM,kBAAkB,iOAK9B,CAAA;IAEM,MAAM,wBAAwB,4QAGpC,CAAA;IAEM,MAAM,SAAS,kNAIrB,CAAA;IAEM,MAAM,YAAY,0PAGxB,CAAA;IAEM,MAAM,SAAS,6RAIrB,CAAA;IAEM,MAAM,eAAe,6PAG3B,CAAA;IAEM,MAAM,kBAAkB,qSAG9B,CAAA;IAEM,MAAM,cAAc,4EAG1B,CAAA;IAEM,MAAM,SAAS,wGAIrB,CAAA;IAEM,MAAM,eAAe,gEAG3B,CAAA;IAEM,MAAM,OAAO,0KAUnB,CAAA;IAEM,MAAM,0BAA0B,gDAItC,CAAA;IAEM,MAAM,yBAAyB,+CAIrC,CAAA;IAED,UAAiB,IAAI,CAAC;QACb,MAAM,KAAK,iIAIjB,CAAA;QAEM,MAAM,SAAS,2PAIrB,CAAA;KACF;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"treefy.d.ts","sourceRoot":"","sources":["../../src/treefy.ts"],"names":[],"mappings":"AAAA,KAAK,QAAQ,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,UAAU,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAA;CAAE,CAAA;AAGrE,eAAO,MAAM,MAAM,GAAI,CAAC,SAAS;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,OAAO,CAAC,EAAE,kBAoB7D,CAAA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Resolve $0 through symlinks so basedir is the shim's real directory.
|
|
3
|
+
# Cap hops at the kernel's ELOOP limit so a cycle cannot hang the shim.
|
|
4
|
+
link="$0"
|
|
5
|
+
hops=0
|
|
6
|
+
while [ -L "$link" ] && [ "$hops" -lt 40 ]; do
|
|
7
|
+
hops=$((hops+1))
|
|
8
|
+
target=$(readlink "$link")
|
|
9
|
+
case "$target" in
|
|
10
|
+
/*) link="$target" ;;
|
|
11
|
+
*) link="$(dirname "$link")/$target" ;;
|
|
12
|
+
esac
|
|
13
|
+
done
|
|
14
|
+
basedir=$(dirname "$(echo "$link" | sed -e 's,\\,/,g')")
|
|
15
|
+
basedir_win="$basedir"
|
|
16
|
+
exe=""
|
|
17
|
+
msys=""
|
|
18
|
+
|
|
19
|
+
case `uname -a` in
|
|
20
|
+
*CYGWIN*|*MINGW*|*MSYS*)
|
|
21
|
+
if command -v cygpath > /dev/null 2>&1; then
|
|
22
|
+
basedir_win=`cygpath -w "$basedir"`
|
|
23
|
+
fi
|
|
24
|
+
exe=".exe"
|
|
25
|
+
msys="true"
|
|
26
|
+
;;
|
|
27
|
+
*WSL2*)
|
|
28
|
+
if command -v wslpath > /dev/null 2>&1; then
|
|
29
|
+
basedir_win="$(wslpath -w "$basedir" 2> /dev/null)"
|
|
30
|
+
if [ $? -ne 0 ] || [ -z "$basedir_win" ]; then
|
|
31
|
+
basedir_win="$basedir"
|
|
32
|
+
else
|
|
33
|
+
exe=".exe"
|
|
34
|
+
fi
|
|
35
|
+
fi
|
|
36
|
+
;;
|
|
37
|
+
esac
|
|
38
|
+
|
|
39
|
+
if [ -z "$NODE_PATH" ]; then
|
|
40
|
+
export NODE_PATH="/home/runner/work/sakura-ui/sakura-ui/node_modules/.pnpm/vitest@4.1.11_@types+node@24.13.3_happy-dom@20.11.6_vite@7.3.6_@types+node@24.13.3_jiti@2.7.0_lightningcss@1.32.0_/node_modules/vitest/node_modules:/home/runner/work/sakura-ui/sakura-ui/node_modules/.pnpm/vitest@4.1.11_@types+node@24.13.3_happy-dom@20.11.6_vite@7.3.6_@types+node@24.13.3_jiti@2.7.0_lightningcss@1.32.0_/node_modules:/home/runner/work/sakura-ui/sakura-ui/node_modules/.pnpm/node_modules"
|
|
41
|
+
else
|
|
42
|
+
export NODE_PATH="/home/runner/work/sakura-ui/sakura-ui/node_modules/.pnpm/vitest@4.1.11_@types+node@24.13.3_happy-dom@20.11.6_vite@7.3.6_@types+node@24.13.3_jiti@2.7.0_lightningcss@1.32.0_/node_modules/vitest/node_modules:/home/runner/work/sakura-ui/sakura-ui/node_modules/.pnpm/vitest@4.1.11_@types+node@24.13.3_happy-dom@20.11.6_vite@7.3.6_@types+node@24.13.3_jiti@2.7.0_lightningcss@1.32.0_/node_modules:/home/runner/work/sakura-ui/sakura-ui/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
43
|
+
fi
|
|
44
|
+
if [ -n "$exe" ] && [ -x "$basedir/node.exe" ]; then
|
|
45
|
+
exec "$basedir/node.exe" "$basedir_win/../vitest/vitest.mjs" "$@"
|
|
46
|
+
elif [ -x "$basedir/node" ]; then
|
|
47
|
+
exec "$basedir/node" "$basedir/../vitest/vitest.mjs" "$@"
|
|
48
|
+
elif command -v node >/dev/null 2>&1; then
|
|
49
|
+
exec node "$basedir/../vitest/vitest.mjs" "$@"
|
|
50
|
+
elif [ -n "$exe" ] && command -v node.exe >/dev/null 2>&1; then
|
|
51
|
+
exec node.exe "$basedir_win/../vitest/vitest.mjs" "$@"
|
|
52
|
+
else
|
|
53
|
+
exec node "$basedir/../vitest/vitest.mjs" "$@"
|
|
54
|
+
fi
|
|
55
|
+
# cmd-shim-target=/home/runner/work/sakura-ui/sakura-ui/packages/helper/node_modules/vitest/vitest.mjs
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sakura-ui/helper",
|
|
3
|
+
"version": "0.0.9",
|
|
4
|
+
"author": "glassonion1",
|
|
5
|
+
"homepage": "https://github.com/glassonion1/sakura-ui",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/glassonion1/sakura-ui.git",
|
|
9
|
+
"directory": "packages/helper"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"main": "dist/index.cjs.js",
|
|
14
|
+
"types": "dist/types/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/types/index.d.ts",
|
|
18
|
+
"require": "./dist/index.cjs.js",
|
|
19
|
+
"import": "./dist/index.es.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"sideEffects": false,
|
|
23
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"lint": "run-s lint:*",
|
|
31
|
+
"lint:lint": "biome lint ./",
|
|
32
|
+
"lint:prettier": "prettier --write --ignore-path .gitignore './src/*.ts'",
|
|
33
|
+
"prebuild": "rimraf dist",
|
|
34
|
+
"build": "run-p build:*",
|
|
35
|
+
"build:scripts": "vite build",
|
|
36
|
+
"build:types": "tsc && tsc-alias",
|
|
37
|
+
"test": "vitest run",
|
|
38
|
+
"test:watch": "vitest"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@testing-library/jest-dom": "catalog:",
|
|
42
|
+
"@testing-library/react": "catalog:",
|
|
43
|
+
"@types/react": "catalog:",
|
|
44
|
+
"@types/react-dom": "catalog:",
|
|
45
|
+
"happy-dom": "catalog:",
|
|
46
|
+
"react": "catalog:",
|
|
47
|
+
"react-dom": "catalog:",
|
|
48
|
+
"vitest": "catalog:"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const mod = (n: number, m: number): number => ((n % m) + m) % m
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const notNegTabIndex = ':not([tabindex^="-"])'
|
|
2
|
+
const notDisabled = ':not(:disabled)'
|
|
3
|
+
|
|
4
|
+
const selectors = [
|
|
5
|
+
`a[href]${notNegTabIndex}`,
|
|
6
|
+
`area[href]${notNegTabIndex}`,
|
|
7
|
+
`input:not([type="hidden"])${notNegTabIndex}${notDisabled}`,
|
|
8
|
+
`select${notNegTabIndex}${notDisabled}`,
|
|
9
|
+
`textarea${notNegTabIndex}${notDisabled}`,
|
|
10
|
+
`button${notNegTabIndex}${notDisabled}`,
|
|
11
|
+
`details > summary:first-of-type${notNegTabIndex}`,
|
|
12
|
+
`details:not(:has(> summary))${notNegTabIndex}`,
|
|
13
|
+
`iframe${notNegTabIndex}`,
|
|
14
|
+
`audio[controls]${notNegTabIndex}`,
|
|
15
|
+
`video[controls]${notNegTabIndex}`,
|
|
16
|
+
`[contenteditable]${notNegTabIndex}`,
|
|
17
|
+
`[tabindex]${notNegTabIndex}`
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
export const focusableSelector = selectors.join(',')
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
export namespace Style {
|
|
2
|
+
export const clickable = `
|
|
3
|
+
px-2
|
|
4
|
+
min-h-[calc(44/16*1rem)]
|
|
5
|
+
border
|
|
6
|
+
border-transparent
|
|
7
|
+
rounded-lg
|
|
8
|
+
hover:bg-solid-grey-50
|
|
9
|
+
`
|
|
10
|
+
|
|
11
|
+
export const selected = `
|
|
12
|
+
rounded-full
|
|
13
|
+
bg-yellow-50
|
|
14
|
+
`
|
|
15
|
+
|
|
16
|
+
const focus = `
|
|
17
|
+
focus-visible:outline-4
|
|
18
|
+
focus-visible:outline-black
|
|
19
|
+
focus-visible:ring-yellow-300
|
|
20
|
+
`
|
|
21
|
+
|
|
22
|
+
export const focusRectCondensed = `
|
|
23
|
+
${focus}
|
|
24
|
+
focus-visible:-outline-offset-4
|
|
25
|
+
focus-visible:ring-[calc(6/16*1rem)]
|
|
26
|
+
focus-visible:ring-inset
|
|
27
|
+
`
|
|
28
|
+
|
|
29
|
+
export const focusRectCondensedWithBg = `
|
|
30
|
+
${focusRectCondensed}
|
|
31
|
+
focus-visible:bg-yellow-300
|
|
32
|
+
`
|
|
33
|
+
|
|
34
|
+
export const focusRect = `
|
|
35
|
+
${focus}
|
|
36
|
+
focus-visible:outline-offset-[calc(2/16*1rem)]
|
|
37
|
+
focus-visible:ring-[calc(2/16*1rem)]
|
|
38
|
+
`
|
|
39
|
+
|
|
40
|
+
export const focusRounded = `
|
|
41
|
+
${focusRect}
|
|
42
|
+
focus-visible:rounded-sm
|
|
43
|
+
`
|
|
44
|
+
|
|
45
|
+
export const focusCard = `
|
|
46
|
+
${focusRect}
|
|
47
|
+
focus-visible:rounded-2xl
|
|
48
|
+
sm:focus-visible:rounded-3xl
|
|
49
|
+
`
|
|
50
|
+
|
|
51
|
+
export const focusRectWithBg = `
|
|
52
|
+
${focusRect}
|
|
53
|
+
focus-visible:bg-yellow-300
|
|
54
|
+
`
|
|
55
|
+
|
|
56
|
+
export const focusRoundedWithBg = `
|
|
57
|
+
${focusRectWithBg}
|
|
58
|
+
focus-visible:rounded-sm
|
|
59
|
+
`
|
|
60
|
+
|
|
61
|
+
export const hoverUnderline = `
|
|
62
|
+
hover:underline
|
|
63
|
+
hover:underline-offset-[calc(3/16*1rem)]
|
|
64
|
+
`
|
|
65
|
+
|
|
66
|
+
export const underline = `
|
|
67
|
+
underline
|
|
68
|
+
underline-offset-[calc(3/16*1rem)]
|
|
69
|
+
hover:decoration-[calc(3/16*1rem)]
|
|
70
|
+
`
|
|
71
|
+
|
|
72
|
+
export const underlineNoDeco = `
|
|
73
|
+
underline
|
|
74
|
+
underline-offset-[calc(3/16*1rem)]
|
|
75
|
+
`
|
|
76
|
+
|
|
77
|
+
export const popover = `
|
|
78
|
+
min-w-fit
|
|
79
|
+
w-auto
|
|
80
|
+
py-2
|
|
81
|
+
bg-white
|
|
82
|
+
shadow-1
|
|
83
|
+
rounded-lg
|
|
84
|
+
border
|
|
85
|
+
border-solid-grey-420
|
|
86
|
+
has-[>:nth-child(7)]:rounded-r-none
|
|
87
|
+
`
|
|
88
|
+
|
|
89
|
+
export const popoverPositionBottomRight = `
|
|
90
|
+
absolute
|
|
91
|
+
top-11
|
|
92
|
+
right-0
|
|
93
|
+
`
|
|
94
|
+
|
|
95
|
+
export const popoverPositionBottomLeft = `
|
|
96
|
+
absolute
|
|
97
|
+
top-11
|
|
98
|
+
left-0
|
|
99
|
+
`
|
|
100
|
+
|
|
101
|
+
export namespace Peer {
|
|
102
|
+
export const focus = `
|
|
103
|
+
peer-focus-visible:outline-4
|
|
104
|
+
peer-focus-visible:outline-black
|
|
105
|
+
peer-focus-visible:ring-yellow-300
|
|
106
|
+
`
|
|
107
|
+
|
|
108
|
+
export const focusRect = `
|
|
109
|
+
${focus}
|
|
110
|
+
peer-focus-visible:outline-offset-[calc(2/16*1rem)]
|
|
111
|
+
peer-focus-visible:ring-[calc(2/16*1rem)]
|
|
112
|
+
`
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
type TreeNode<I> = Omit<I, 'children'> & { children?: TreeNode<I>[] }
|
|
2
|
+
type Input<I> = (I & { children: unknown })[]
|
|
3
|
+
|
|
4
|
+
export const treefy = <I extends { depth: number }>(input: I[]) => {
|
|
5
|
+
const tree: TreeNode<I>[] = []
|
|
6
|
+
const last: TreeNode<I>[] = []
|
|
7
|
+
let top = -1
|
|
8
|
+
let bottom = -1
|
|
9
|
+
for (const { children: _, ...item } of input as Input<I>) {
|
|
10
|
+
if (top < item.depth && item.depth <= bottom + 1) {
|
|
11
|
+
const idx = item.depth - top
|
|
12
|
+
bottom = item.depth
|
|
13
|
+
const parent = last[idx - 1]
|
|
14
|
+
parent.children ??= []
|
|
15
|
+
parent.children.push(item)
|
|
16
|
+
last[idx] = item
|
|
17
|
+
continue
|
|
18
|
+
}
|
|
19
|
+
tree.push(item)
|
|
20
|
+
last[0] = item
|
|
21
|
+
top = bottom = item.depth
|
|
22
|
+
}
|
|
23
|
+
return tree
|
|
24
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { mod } from '../src/calc'
|
|
3
|
+
|
|
4
|
+
describe('mod', () => {
|
|
5
|
+
it('should return the remainder for positive numbers', () => {
|
|
6
|
+
expect(mod(5, 3)).toBe(2)
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
it('should return a positive result for negative dividend', () => {
|
|
10
|
+
expect(mod(-1, 3)).toBe(2)
|
|
11
|
+
expect(mod(-5, 3)).toBe(1)
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('should return 0 when evenly divisible', () => {
|
|
15
|
+
expect(mod(6, 3)).toBe(0)
|
|
16
|
+
expect(mod(7, 7)).toBe(0)
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('should return 0 when dividend is 0', () => {
|
|
20
|
+
expect(mod(0, 5)).toBe(0)
|
|
21
|
+
})
|
|
22
|
+
})
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { cx } from '../src/cx'
|
|
3
|
+
|
|
4
|
+
describe('cx', () => {
|
|
5
|
+
it('should join multiple class names with a space', () => {
|
|
6
|
+
expect(cx('foo', 'bar', 'baz')).toBe('foo bar baz')
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
it('should filter out falsy values', () => {
|
|
10
|
+
expect(cx('foo', false, 'bar', null, undefined, 0, '', 'baz')).toBe(
|
|
11
|
+
'foo bar baz'
|
|
12
|
+
)
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it('should handle conditional class names', () => {
|
|
16
|
+
const isActive = true
|
|
17
|
+
const isDisabled = false
|
|
18
|
+
expect(cx('base', isActive && 'active', isDisabled && 'disabled')).toBe(
|
|
19
|
+
'base active'
|
|
20
|
+
)
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('should return an empty string when no arguments', () => {
|
|
24
|
+
expect(cx()).toBe('')
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it('should handle a single class name', () => {
|
|
28
|
+
expect(cx('only')).toBe('only')
|
|
29
|
+
})
|
|
30
|
+
})
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { focusableSelector } from '../src/querySelector'
|
|
3
|
+
|
|
4
|
+
describe('focusableSelector', () => {
|
|
5
|
+
it('should be a string', () => {
|
|
6
|
+
expect(typeof focusableSelector).toBe('string')
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
it('should include common focusable element selectors', () => {
|
|
10
|
+
expect(focusableSelector).toContain('a[href]')
|
|
11
|
+
expect(focusableSelector).toContain('button')
|
|
12
|
+
expect(focusableSelector).toContain('input')
|
|
13
|
+
expect(focusableSelector).toContain('select')
|
|
14
|
+
expect(focusableSelector).toContain('textarea')
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it('should exclude elements with negative tabindex', () => {
|
|
18
|
+
expect(focusableSelector).toContain(':not([tabindex^="-"])')
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('should exclude disabled elements for interactive elements', () => {
|
|
22
|
+
expect(focusableSelector).toContain(':not(:disabled)')
|
|
23
|
+
})
|
|
24
|
+
})
|