@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.
Files changed (212) hide show
  1. package/README.md +77 -6
  2. package/package.json +28 -21
  3. package/packages/core/package.json +30 -17
  4. package/packages/core/src/components/Button.tsx +33 -32
  5. package/packages/core/src/components/Card.tsx +37 -20
  6. package/packages/core/src/components/Code.tsx +6 -4
  7. package/packages/core/src/components/Faq.tsx +13 -7
  8. package/packages/core/src/components/Heading.tsx +42 -32
  9. package/packages/core/src/components/Icon.tsx +43 -13
  10. package/packages/core/src/components/IconButton.tsx +54 -43
  11. package/packages/core/src/components/LangSelector.tsx +135 -0
  12. package/packages/core/src/components/Link.tsx +37 -66
  13. package/packages/core/src/components/LinkCard.tsx +126 -0
  14. package/packages/core/src/components/List.tsx +14 -12
  15. package/packages/core/src/components/MenuButton.tsx +112 -0
  16. package/packages/core/src/components/NavigationItem.tsx +41 -0
  17. package/packages/core/src/components/NotificationBanner.tsx +20 -0
  18. package/packages/core/src/components/OverflowContainer.tsx +24 -0
  19. package/packages/core/src/components/PopoverMenu.tsx +82 -0
  20. package/packages/core/src/components/Pre.tsx +6 -4
  21. package/packages/core/src/components/Table.tsx +31 -25
  22. package/packages/core/src/components/buttonStyle.ts +43 -32
  23. package/packages/core/src/components/index.ts +13 -25
  24. package/packages/core/src/icons/Close.tsx +21 -0
  25. package/packages/core/src/icons/CloseMobile.tsx +43 -0
  26. package/packages/core/src/icons/KeyboardArrowDown.tsx +24 -0
  27. package/packages/core/src/icons/Language.tsx +25 -0
  28. package/packages/core/src/icons/LanguageMobile.tsx +40 -0
  29. package/packages/core/src/icons/Menu.tsx +24 -0
  30. package/packages/core/src/icons/MenuMobile.tsx +40 -0
  31. package/packages/core/src/icons/index.ts +8 -0
  32. package/packages/core/src/icons/props.ts +5 -0
  33. package/packages/core/src/index.ts +10 -28
  34. package/packages/core/src/type.d.ts +1 -0
  35. package/packages/core/tests/Button.test.tsx +20 -10
  36. package/packages/core/tests/Card.test.tsx +16 -11
  37. package/packages/core/tests/IconButton.test.tsx +57 -0
  38. package/packages/core/tests/Link.test.tsx +60 -0
  39. package/packages/core/tests/vitest.setup.ts +1 -0
  40. package/packages/core/tsconfig.node.json +3 -2
  41. package/packages/core/vite.config.ts +2 -1
  42. package/packages/forms/.turbo/turbo-build.log +12 -0
  43. package/packages/forms/dist/index.cjs.js +183 -131
  44. package/packages/forms/dist/index.es.js +750 -1062
  45. package/packages/forms/dist/types/components/Checkbox.d.ts +9 -4
  46. package/packages/forms/dist/types/components/Checkbox.d.ts.map +1 -1
  47. package/packages/forms/dist/types/components/FieldsetControl.d.ts +14 -9
  48. package/packages/forms/dist/types/components/FieldsetControl.d.ts.map +1 -1
  49. package/packages/forms/dist/types/components/FileInput.d.ts +10 -3
  50. package/packages/forms/dist/types/components/FileInput.d.ts.map +1 -1
  51. package/packages/forms/dist/types/components/Input.d.ts +9 -4
  52. package/packages/forms/dist/types/components/Input.d.ts.map +1 -1
  53. package/packages/forms/dist/types/components/LabelControl.d.ts +13 -8
  54. package/packages/forms/dist/types/components/LabelControl.d.ts.map +1 -1
  55. package/packages/forms/dist/types/components/Radio.d.ts +9 -4
  56. package/packages/forms/dist/types/components/Radio.d.ts.map +1 -1
  57. package/packages/forms/dist/types/components/Select.d.ts +9 -4
  58. package/packages/forms/dist/types/components/Select.d.ts.map +1 -1
  59. package/packages/forms/dist/types/components/Textarea.d.ts +8 -3
  60. package/packages/forms/dist/types/components/Textarea.d.ts.map +1 -1
  61. package/packages/forms/dist/types/components/controlled/CheckboxGroup.d.ts +16 -11
  62. package/packages/forms/dist/types/components/controlled/CheckboxGroup.d.ts.map +1 -1
  63. package/packages/forms/dist/types/components/controlled/RadioGroup.d.ts +17 -12
  64. package/packages/forms/dist/types/components/controlled/RadioGroup.d.ts.map +1 -1
  65. package/packages/forms/dist/types/components/index.d.ts +8 -8
  66. package/packages/forms/dist/types/components/index.d.ts.map +1 -1
  67. package/packages/forms/dist/types/components/inputStyle.d.ts +1 -1
  68. package/packages/forms/dist/types/components/inputStyle.d.ts.map +1 -1
  69. package/packages/forms/dist/types/index.d.ts +0 -1
  70. package/packages/forms/dist/types/index.d.ts.map +1 -1
  71. package/packages/forms/node_modules/.bin/autoprefixer +44 -6
  72. package/packages/forms/package.json +21 -16
  73. package/packages/forms/src/components/Checkbox.tsx +76 -80
  74. package/packages/forms/src/components/FieldsetControl.tsx +21 -28
  75. package/packages/forms/src/components/FileInput.tsx +92 -63
  76. package/packages/forms/src/components/Input.tsx +29 -31
  77. package/packages/forms/src/components/LabelControl.tsx +19 -25
  78. package/packages/forms/src/components/Radio.tsx +68 -69
  79. package/packages/forms/src/components/Select.tsx +65 -65
  80. package/packages/forms/src/components/Textarea.tsx +49 -54
  81. package/packages/forms/src/components/controlled/CheckboxGroup.tsx +15 -17
  82. package/packages/forms/src/components/controlled/RadioGroup.tsx +16 -18
  83. package/packages/forms/src/components/index.ts +8 -8
  84. package/packages/forms/src/components/inputStyle.ts +7 -8
  85. package/packages/forms/src/index.ts +0 -11
  86. package/packages/forms/tests/Checkbox.test.tsx +44 -0
  87. package/packages/forms/tests/FieldsetControl.test.tsx +68 -11
  88. package/packages/forms/tests/FileInput.test.tsx +25 -0
  89. package/packages/forms/tests/Input.test.tsx +12 -83
  90. package/packages/forms/tests/LabelControl.test.tsx +88 -20
  91. package/packages/forms/tests/Radio.test.tsx +23 -78
  92. package/packages/forms/tests/Select.test.tsx +30 -0
  93. package/packages/forms/tests/Textarea.test.tsx +25 -0
  94. package/packages/forms/tests/vitest.setup.ts +1 -0
  95. package/packages/forms/tsconfig.node.json +3 -2
  96. package/packages/forms/vite.config.ts +2 -1
  97. package/packages/helper/.turbo/turbo-build.log +12 -0
  98. package/packages/helper/dist/index.cjs.js +76 -0
  99. package/packages/helper/dist/index.es.js +119 -0
  100. package/packages/helper/dist/types/calc.d.ts +2 -0
  101. package/packages/helper/dist/types/calc.d.ts.map +1 -0
  102. package/packages/{forms/dist/types/utils/class.d.ts → helper/dist/types/cx.d.ts} +1 -1
  103. package/packages/helper/dist/types/cx.d.ts.map +1 -0
  104. package/packages/helper/dist/types/index.d.ts +6 -0
  105. package/packages/helper/dist/types/index.d.ts.map +1 -0
  106. package/packages/helper/dist/types/querySelector.d.ts +2 -0
  107. package/packages/helper/dist/types/querySelector.d.ts.map +1 -0
  108. package/packages/helper/dist/types/styles.d.ts +22 -0
  109. package/packages/helper/dist/types/styles.d.ts.map +1 -0
  110. package/packages/helper/dist/types/treefy.d.ts +8 -0
  111. package/packages/helper/dist/types/treefy.d.ts.map +1 -0
  112. package/packages/helper/node_modules/.bin/vitest +55 -0
  113. package/packages/helper/package.json +50 -0
  114. package/packages/helper/src/calc.ts +1 -0
  115. package/packages/helper/src/cx.ts +2 -0
  116. package/packages/helper/src/index.ts +5 -0
  117. package/packages/helper/src/querySelector.ts +20 -0
  118. package/packages/helper/src/styles.ts +114 -0
  119. package/packages/helper/src/treefy.ts +24 -0
  120. package/packages/helper/tests/calc.test.ts +22 -0
  121. package/packages/helper/tests/cx.test.ts +30 -0
  122. package/packages/helper/tests/querySelector.test.ts +24 -0
  123. package/packages/helper/tests/treefy.test.ts +111 -0
  124. package/packages/helper/tests/vitest.setup.ts +2 -0
  125. package/packages/helper/tsconfig.json +13 -0
  126. package/packages/helper/tsconfig.node.json +6 -0
  127. package/packages/helper/vite.config.ts +26 -0
  128. package/packages/markdown/.turbo/turbo-build.log +12 -0
  129. package/packages/markdown/README.md +129 -0
  130. package/packages/markdown/dist/index.cjs.js +149 -0
  131. package/packages/markdown/dist/index.es.js +16960 -0
  132. package/packages/markdown/dist/types/components/Markdown.d.ts +15 -0
  133. package/packages/markdown/dist/types/components/Markdown.d.ts.map +1 -0
  134. package/packages/markdown/dist/types/components/index.d.ts +2 -0
  135. package/packages/markdown/dist/types/components/index.d.ts.map +1 -0
  136. package/packages/markdown/dist/types/index.d.ts +2 -0
  137. package/packages/markdown/dist/types/index.d.ts.map +1 -0
  138. package/packages/markdown/dist/types/plugins/attr.d.ts +3 -0
  139. package/packages/markdown/dist/types/plugins/attr.d.ts.map +1 -0
  140. package/packages/markdown/dist/types/plugins/card.d.ts +3 -0
  141. package/packages/markdown/dist/types/plugins/card.d.ts.map +1 -0
  142. package/packages/markdown/dist/types/plugins/cell.d.ts +3 -0
  143. package/packages/markdown/dist/types/plugins/cell.d.ts.map +1 -0
  144. package/packages/markdown/dist/types/plugins/faq.d.ts +3 -0
  145. package/packages/markdown/dist/types/plugins/faq.d.ts.map +1 -0
  146. package/packages/markdown/dist/types/plugins/grid.d.ts +3 -0
  147. package/packages/markdown/dist/types/plugins/grid.d.ts.map +1 -0
  148. package/packages/markdown/dist/types/plugins/headings.d.ts +11 -0
  149. package/packages/markdown/dist/types/plugins/headings.d.ts.map +1 -0
  150. package/packages/markdown/dist/types/plugins/helper.d.ts +9 -0
  151. package/packages/markdown/dist/types/plugins/helper.d.ts.map +1 -0
  152. package/packages/markdown/dist/types/plugins/index.d.ts +9 -0
  153. package/packages/markdown/dist/types/plugins/index.d.ts.map +1 -0
  154. package/packages/markdown/dist/types/plugins/linkButton.d.ts +3 -0
  155. package/packages/markdown/dist/types/plugins/linkButton.d.ts.map +1 -0
  156. package/packages/markdown/dist/types/plugins/youtube.d.ts +3 -0
  157. package/packages/markdown/dist/types/plugins/youtube.d.ts.map +1 -0
  158. package/packages/markdown/node_modules/.bin/autoprefixer +55 -0
  159. package/packages/markdown/package.json +84 -0
  160. package/packages/markdown/src/components/Markdown.tsx +365 -0
  161. package/packages/markdown/src/components/index.ts +1 -0
  162. package/packages/markdown/src/global.d.ts +9 -0
  163. package/packages/markdown/src/index.ts +1 -0
  164. package/packages/markdown/src/plugins/attr.ts +19 -0
  165. package/packages/markdown/src/plugins/card.ts +57 -0
  166. package/packages/markdown/src/plugins/cell.ts +47 -0
  167. package/packages/markdown/src/plugins/faq.ts +40 -0
  168. package/packages/markdown/src/plugins/grid.ts +54 -0
  169. package/packages/markdown/src/plugins/headings.ts +38 -0
  170. package/packages/markdown/src/plugins/helper.ts +27 -0
  171. package/packages/markdown/src/plugins/index.ts +8 -0
  172. package/packages/markdown/src/plugins/linkButton.ts +26 -0
  173. package/packages/markdown/src/plugins/youtube.ts +49 -0
  174. package/packages/markdown/tsconfig.json +13 -0
  175. package/packages/markdown/tsconfig.node.json +7 -0
  176. package/packages/markdown/vite.config.ts +30 -0
  177. package/packages/tailwind-theme-plugin/#package.json# +51 -0
  178. package/packages/tailwind-theme-plugin/.turbo/turbo-build.log +12 -0
  179. package/packages/tailwind-theme-plugin/dist/index.cjs.js +1 -1
  180. package/packages/tailwind-theme-plugin/dist/index.es.js +4970 -6093
  181. package/packages/tailwind-theme-plugin/dist/types/index.d.ts +1 -4
  182. package/packages/tailwind-theme-plugin/dist/types/index.d.ts.map +1 -1
  183. package/packages/tailwind-theme-plugin/node_modules/.bin/autoprefixer +44 -6
  184. package/packages/tailwind-theme-plugin/package.json +11 -9
  185. package/packages/tailwind-theme-plugin/src/index.ts +241 -349
  186. package/packages/tailwind-theme-plugin/vite.config.ts +2 -0
  187. package/packages/core/src/libs/cx.ts +0 -2
  188. package/packages/core/src/libs/forward-ref.ts +0 -44
  189. package/packages/core/src/types/component.ts +0 -83
  190. package/packages/forms/dist/types/utils/class.d.ts.map +0 -1
  191. package/packages/forms/node_modules/.bin/acorn +0 -17
  192. package/packages/forms/node_modules/.bin/browserslist +0 -17
  193. package/packages/forms/node_modules/.bin/eslint +0 -17
  194. package/packages/forms/node_modules/.bin/tailwind +0 -17
  195. package/packages/forms/node_modules/.bin/tailwindcss +0 -17
  196. package/packages/forms/node_modules/.bin/ts-node +0 -17
  197. package/packages/forms/node_modules/.bin/ts-node-cwd +0 -17
  198. package/packages/forms/node_modules/.bin/ts-node-esm +0 -17
  199. package/packages/forms/node_modules/.bin/ts-node-script +0 -17
  200. package/packages/forms/node_modules/.bin/ts-node-transpile-only +0 -17
  201. package/packages/forms/node_modules/.bin/ts-script +0 -17
  202. package/packages/forms/node_modules/.bin/vitest +0 -17
  203. package/packages/forms/src/utils/class.ts +0 -2
  204. package/packages/tailwind-theme-plugin/node_modules/.bin/browserslist +0 -17
  205. package/packages/tailwind-theme-plugin/node_modules/.bin/tailwind +0 -17
  206. package/packages/tailwind-theme-plugin/node_modules/.bin/tailwindcss +0 -17
  207. package/packages/tailwind-theme-plugin/node_modules/.bin/ts-node +0 -17
  208. package/packages/tailwind-theme-plugin/node_modules/.bin/ts-node-cwd +0 -17
  209. package/packages/tailwind-theme-plugin/node_modules/.bin/ts-node-esm +0 -17
  210. package/packages/tailwind-theme-plugin/node_modules/.bin/ts-node-script +0 -17
  211. package/packages/tailwind-theme-plugin/node_modules/.bin/ts-node-transpile-only +0 -17
  212. package/packages/tailwind-theme-plugin/node_modules/.bin/ts-script +0 -17
@@ -0,0 +1,15 @@
1
+ import * as production from 'react/jsx-runtime';
2
+ import { type HeadingItem } from '../plugins';
3
+ interface TocProps {
4
+ items: HeadingItem[];
5
+ }
6
+ export declare const TableOfContents: ({ items }: TocProps) => production.JSX.Element;
7
+ type Props = {
8
+ tocTitle?: string;
9
+ showToc?: boolean;
10
+ shiftHeding?: number;
11
+ children: string;
12
+ };
13
+ export declare const Markdown: ({ children, showToc, tocTitle, shiftHeding }: Props) => production.JSX.Element;
14
+ export {};
15
+ //# sourceMappingURL=Markdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Markdown.d.ts","sourceRoot":"","sources":["../../../src/components/Markdown.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAA;AA6C/C,OAAO,EASL,KAAK,WAAW,EACjB,MAAM,YAAY,CAAA;AAEnB,UAAU,QAAQ;IAChB,KAAK,EAAE,WAAW,EAAE,CAAA;CACrB;AAED,eAAO,MAAM,eAAe,GAAI,WAAW,QAAQ,2BAelD,CAAA;AAgKD,KAAK,KAAK,GAAG;IACX,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,QAAQ,GAAI,8CAKtB,KAAK,2BAmHP,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { Markdown } from './Markdown';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { Markdown } from './components';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { Root } from 'mdast';
2
+ export declare const attrPlugin: () => (tree: Root) => void;
3
+ //# sourceMappingURL=attr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attr.d.ts","sourceRoot":"","sources":["../../../src/plugins/attr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAQjC,eAAO,MAAM,UAAU,SACb,MAAM,IAAI,SASnB,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { Root } from 'mdast';
2
+ export declare const cardPlugin: () => (tree: Root) => void;
3
+ //# sourceMappingURL=card.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"card.d.ts","sourceRoot":"","sources":["../../../src/plugins/card.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAQjC,eAAO,MAAM,UAAU,SACb,MAAM,IAAI,SA+CnB,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { Root } from 'mdast';
2
+ export declare const cellPlugin: () => (tree: Root) => void;
3
+ //# sourceMappingURL=cell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cell.d.ts","sourceRoot":"","sources":["../../../src/plugins/cell.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAQjC,eAAO,MAAM,UAAU,SACb,MAAM,IAAI,SAqCnB,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { Root } from 'mdast';
2
+ export declare const faqPlugin: () => (tree: Root) => void;
3
+ //# sourceMappingURL=faq.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"faq.d.ts","sourceRoot":"","sources":["../../../src/plugins/faq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAQjC,eAAO,MAAM,SAAS,SACZ,MAAM,IAAI,SA8BnB,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { Root } from 'mdast';
2
+ export declare const gridPlugin: () => (tree: Root) => void;
3
+ //# sourceMappingURL=grid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../../src/plugins/grid.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAQjC,eAAO,MAAM,UAAU,SACb,MAAM,IAAI,SA4CnB,CAAA"}
@@ -0,0 +1,11 @@
1
+ import type { Root } from 'mdast';
2
+ export type HeadingItem = {
3
+ id?: string;
4
+ depth: number;
5
+ value?: string;
6
+ children?: Array<HeadingItem>;
7
+ };
8
+ export declare const headingsPlugin: () => (tree: Root, vFile: {
9
+ data: Record<string, unknown>;
10
+ }) => void;
11
+ //# sourceMappingURL=headings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"headings.d.ts","sourceRoot":"","sources":["../../../src/plugins/headings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAW,IAAI,EAAE,MAAM,OAAO,CAAA;AAO1C,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,CAAA;CAC9B,CAAA;AAED,eAAO,MAAM,cAAc,SACjB,MAAM,IAAI,EAAE,OAAO;IAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,SAsB7D,CAAA"}
@@ -0,0 +1,9 @@
1
+ import type { Directives } from 'mdast-util-directive';
2
+ import type { Node } from 'unist';
3
+ import type { Heading } from 'mdast';
4
+ export declare const isDirective: (node: Node) => node is Directives;
5
+ export declare const isContainerDirective: (node: Node) => node is Directives;
6
+ export declare const isLeafDirective: (node: Node) => node is Directives;
7
+ export declare const isTextDirective: (node: Node) => node is Directives;
8
+ export declare const isHeading: (node: Node) => node is Heading;
9
+ //# sourceMappingURL=helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../../src/plugins/helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAEpC,eAAO,MAAM,WAAW,GAAI,MAAM,IAAI,KAAG,IAAI,IAAI,UAMhD,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAI,MAAM,IAAI,KAAG,IAAI,IAAI,UAEzD,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,MAAM,IAAI,KAAG,IAAI,IAAI,UAEpD,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,MAAM,IAAI,KAAG,IAAI,IAAI,UAEpD,CAAA;AAED,eAAO,MAAM,SAAS,GAAI,MAAM,IAAI,KAAG,IAAI,IAAI,OAE9C,CAAA"}
@@ -0,0 +1,9 @@
1
+ export { youtubePlugin } from './youtube';
2
+ export { attrPlugin } from './attr';
3
+ export { linkButtonPlugin } from './linkButton';
4
+ export { gridPlugin } from './grid';
5
+ export { cellPlugin } from './cell';
6
+ export { cardPlugin } from './card';
7
+ export { faqPlugin } from './faq';
8
+ export { headingsPlugin, type HeadingItem } from './headings';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { Root } from 'mdast';
2
+ export declare const linkButtonPlugin: () => (tree: Root) => void;
3
+ //# sourceMappingURL=linkButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linkButton.d.ts","sourceRoot":"","sources":["../../../src/plugins/linkButton.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAQjC,eAAO,MAAM,gBAAgB,SACnB,MAAM,IAAI,SAgBnB,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { Root } from 'mdast';
2
+ export declare const youtubePlugin: () => (tree: Root) => void;
3
+ //# sourceMappingURL=youtube.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"youtube.d.ts","sourceRoot":"","sources":["../../../src/plugins/youtube.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAOjC,eAAO,MAAM,aAAa,SAChB,MAAM,IAAI,SAwCnB,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/autoprefixer@10.5.4_postcss@8.5.26/node_modules/autoprefixer/node_modules:/home/runner/work/sakura-ui/sakura-ui/node_modules/.pnpm/autoprefixer@10.5.4_postcss@8.5.26/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/autoprefixer@10.5.4_postcss@8.5.26/node_modules/autoprefixer/node_modules:/home/runner/work/sakura-ui/sakura-ui/node_modules/.pnpm/autoprefixer@10.5.4_postcss@8.5.26/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/../autoprefixer/bin/autoprefixer" "$@"
46
+ elif [ -x "$basedir/node" ]; then
47
+ exec "$basedir/node" "$basedir/../autoprefixer/bin/autoprefixer" "$@"
48
+ elif command -v node >/dev/null 2>&1; then
49
+ exec node "$basedir/../autoprefixer/bin/autoprefixer" "$@"
50
+ elif [ -n "$exe" ] && command -v node.exe >/dev/null 2>&1; then
51
+ exec node.exe "$basedir_win/../autoprefixer/bin/autoprefixer" "$@"
52
+ else
53
+ exec node "$basedir/../autoprefixer/bin/autoprefixer" "$@"
54
+ fi
55
+ # cmd-shim-target=/home/runner/work/sakura-ui/sakura-ui/packages/markdown/node_modules/autoprefixer/bin/autoprefixer
@@ -0,0 +1,84 @@
1
+ {
2
+ "name": "@sakura-ui/markdown",
3
+ "version": "0.2.2",
4
+ "description": "",
5
+ "keywords": [
6
+ "markdown"
7
+ ],
8
+ "author": "glassonion1",
9
+ "homepage": "https://github.com/glassonion1/sakura-ui",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/glassonion1/sakura-ui.git",
13
+ "directory": "packages/markdown"
14
+ },
15
+ "license": "MIT",
16
+ "type": "module",
17
+ "main": "dist/index.cjs.js",
18
+ "types": "dist/types/index.d.ts",
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/types/index.d.ts",
22
+ "require": "./dist/index.cjs.js",
23
+ "import": "./dist/index.es.js"
24
+ }
25
+ },
26
+ "sideEffects": false,
27
+ "files": [
28
+ "dist"
29
+ ],
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "scripts": {
34
+ "lint": "run-s lint:*",
35
+ "lint:lint": "biome lint ./",
36
+ "lint:prettier": "prettier --write --ignore-path .gitignore './src/*.ts'",
37
+ "prebuild": "rimraf dist",
38
+ "build": "run-p build:*",
39
+ "build:scripts": "vite build",
40
+ "build:types": "tsc && tsc-alias",
41
+ "test": "vitest run --passWithNoTests",
42
+ "test:watch": "vitest"
43
+ },
44
+ "peerDependencies": {
45
+ "@sakura-ui/core": "^0.4.0-beta.0",
46
+ "react": "^19.2.1",
47
+ "react-dom": "^19.2.1",
48
+ "tailwindcss": "^4.1.17"
49
+ },
50
+ "dependencies": {
51
+ "@sakura-ui/helper": "workspace:*",
52
+ "github-slugger": "^2.0.0",
53
+ "hastscript": "^9.0.1",
54
+ "mdast-util-directive": "^3.1.0",
55
+ "mdast-util-to-string": "^4.0.0",
56
+ "rehype-external-links": "^3.0.0",
57
+ "rehype-raw": "^7.0.0",
58
+ "rehype-react": "^8.0.0",
59
+ "rehype-shift-heading": "^2.0.0",
60
+ "rehype-slug": "^6.0.0",
61
+ "remark": "^15.0.1",
62
+ "remark-breaks": "^4.0.0",
63
+ "remark-directive": "^3.0.1",
64
+ "remark-gfm": "^4.0.1",
65
+ "remark-parse": "^11.0.0",
66
+ "remark-rehype": "^11.1.2",
67
+ "unified": "^11.0.5",
68
+ "unist-util-visit": "^5.1.0"
69
+ },
70
+ "devDependencies": {
71
+ "@testing-library/jest-dom": "catalog:",
72
+ "@testing-library/react": "catalog:",
73
+ "@types/mdast": "^4.0.4",
74
+ "@types/react": "catalog:",
75
+ "@types/react-dom": "catalog:",
76
+ "@types/unist": "^3.0.3",
77
+ "autoprefixer": "catalog:",
78
+ "happy-dom": "catalog:",
79
+ "postcss": "catalog:",
80
+ "react": "catalog:",
81
+ "react-dom": "catalog:",
82
+ "tailwindcss": "catalog:"
83
+ }
84
+ }
@@ -0,0 +1,365 @@
1
+ import React, { Children } from 'react'
2
+ import * as production from 'react/jsx-runtime'
3
+ import { remark } from 'remark'
4
+ import { unified } from 'unified'
5
+ import remarkParse from 'remark-parse'
6
+ import remarkGfm from 'remark-gfm'
7
+ import remarkDirective from 'remark-directive'
8
+ import remarkRehype from 'remark-rehype'
9
+ import remarkBreaks from 'remark-breaks'
10
+ import rehypeRaw from 'rehype-raw'
11
+ import rehypeExternalLinks from 'rehype-external-links'
12
+ import rebypeShiftHeding from 'rehype-shift-heading'
13
+ import rehypeReact from 'rehype-react'
14
+ import rehypeSlug from 'rehype-slug'
15
+ import { cx } from '@sakura-ui/helper'
16
+ import {
17
+ Link,
18
+ H1,
19
+ H2,
20
+ H3,
21
+ H4,
22
+ H5,
23
+ H6,
24
+ Table,
25
+ Caption,
26
+ Thead,
27
+ Tbody,
28
+ Th,
29
+ Tr,
30
+ Td,
31
+ Ul,
32
+ Ol,
33
+ Pre,
34
+ Code,
35
+ Faq,
36
+ Question,
37
+ Answer,
38
+ Button,
39
+ Card,
40
+ CardImg,
41
+ CardBody,
42
+ CardFooter,
43
+ LinkCard,
44
+ LinkCardHeader,
45
+ OverflowContainer
46
+ } from '@sakura-ui/core'
47
+ import {
48
+ attrPlugin,
49
+ youtubePlugin,
50
+ linkButtonPlugin,
51
+ gridPlugin,
52
+ cellPlugin,
53
+ cardPlugin,
54
+ faqPlugin,
55
+ headingsPlugin,
56
+ type HeadingItem
57
+ } from '../plugins'
58
+
59
+ interface TocProps {
60
+ items: HeadingItem[]
61
+ }
62
+
63
+ export const TableOfContents = ({ items }: TocProps) => {
64
+ return (
65
+ <>
66
+ {items.map((item) => {
67
+ return (
68
+ <li key={item.id}>
69
+ <Link href={`#${item.id}`}>{item.value}</Link>
70
+ {item.children ? (
71
+ <Ul>{<TableOfContents items={item.children} />}</Ul>
72
+ ) : null}
73
+ </li>
74
+ )
75
+ })}
76
+ </>
77
+ )
78
+ }
79
+
80
+ interface TableContainerProps extends React.ComponentPropsWithoutRef<'table'> {}
81
+
82
+ const TableContainer = (props: TableContainerProps) => {
83
+ const { className, children, ...restProps } = props
84
+
85
+ return (
86
+ <OverflowContainer>
87
+ <Table className={cx(className)} {...restProps}>
88
+ {children}
89
+ </Table>
90
+ </OverflowContainer>
91
+ )
92
+ }
93
+
94
+ interface DataProps {
95
+ [key: `data-${string}`]: unknown
96
+ }
97
+
98
+ interface AnchorProps extends React.ComponentPropsWithoutRef<'a'>, DataProps {}
99
+
100
+ const Anchor = (props: AnchorProps) => {
101
+ const { children, href, ...restProps } = props
102
+
103
+ if (restProps['data-node'] === 'link-button') {
104
+ return (
105
+ <Button as="a" variant="secondary" href={href}>
106
+ {children}
107
+ </Button>
108
+ )
109
+ }
110
+
111
+ return (
112
+ <Link href={href} {...restProps}>
113
+ {children}
114
+ </Link>
115
+ )
116
+ }
117
+
118
+ interface ArticleProps
119
+ extends React.ComponentPropsWithoutRef<'article'>,
120
+ DataProps {}
121
+
122
+ const Article = (props: ArticleProps) => {
123
+ const { children, className, ...restProps } = props
124
+
125
+ const node = restProps['data-node']
126
+
127
+ if (node === 'card') {
128
+ if (restProps['data-behavior'] === 'link') {
129
+ const href = restProps['data-href'] as string
130
+
131
+ return (
132
+ <LinkCard href={href} className={cx(className)}>
133
+ {children}
134
+ </LinkCard>
135
+ )
136
+ }
137
+ return <Card className={cx(className)}>{children}</Card>
138
+ }
139
+
140
+ return (
141
+ <article className={className} {...restProps}>
142
+ {children}
143
+ </article>
144
+ )
145
+ }
146
+
147
+ interface DivProps extends React.ComponentPropsWithoutRef<'div'>, DataProps {}
148
+
149
+ const Div = (props: DivProps) => {
150
+ const { children, ...restProps } = props
151
+
152
+ const node = restProps['data-node']
153
+
154
+ if (node === 'card-title') {
155
+ return <LinkCardHeader>{children}</LinkCardHeader>
156
+ }
157
+ if (node === 'card-description') {
158
+ return <CardBody>{children}</CardBody>
159
+ }
160
+ if (node === 'card-footer') {
161
+ return <CardFooter>{children}</CardFooter>
162
+ }
163
+
164
+ if (restProps['data-behavior'] === 'list') {
165
+ // Set the css class configured for cells to the ul tag
166
+ return (
167
+ <ul className={restProps.className}>
168
+ {Children.map(children, (child) => (
169
+ <li className="sm:grid" key={Math.random()}>
170
+ {child}
171
+ </li>
172
+ ))}
173
+ </ul>
174
+ )
175
+ }
176
+
177
+ return <div {...restProps}>{children}</div>
178
+ }
179
+
180
+ interface ImgProps extends React.ComponentPropsWithoutRef<'img'>, DataProps {}
181
+
182
+ const Img = (props: ImgProps) => {
183
+ const { children, className, ...restProps } = props
184
+
185
+ if (restProps['data-node'] === 'card-img') {
186
+ return (
187
+ <CardImg
188
+ className={cx('w-full aspect-[352/226]', className)}
189
+ {...restProps}
190
+ />
191
+ )
192
+ }
193
+
194
+ if (restProps['data-node'] === 'cell-img') {
195
+ // biome-ignore lint/a11y/useAltText: alt is carried by restProps from the markdown image syntax
196
+ return <img className={cx('mb-4', className)} {...restProps} />
197
+ }
198
+
199
+ // biome-ignore lint/a11y/useAltText: alt is carried by restProps from the markdown image syntax
200
+ return <img className={className} {...restProps} />
201
+ }
202
+
203
+ interface IframeProps extends React.ComponentPropsWithoutRef<'iframe'> {}
204
+
205
+ const Iframe = (props: IframeProps) => {
206
+ const { className, children, ...restProps } = props
207
+
208
+ const styleMargin = `
209
+ my-8
210
+ `
211
+
212
+ let style = `
213
+ aspect-video
214
+ w-full
215
+ max-w-[470px]
216
+ `
217
+
218
+ if (props.width || props.height) {
219
+ style = `
220
+ aspect-video
221
+ w-full
222
+ lg:aspect-auto
223
+ lg:w-[${props.width}px]
224
+ lg:h-[${props.height}px]
225
+ `
226
+ }
227
+
228
+ return (
229
+ <iframe className={cx(styleMargin, style, className)} {...restProps}>
230
+ {children}
231
+ </iframe>
232
+ )
233
+ }
234
+
235
+ const sleep = (time: number) =>
236
+ new Promise((resolve) => setTimeout(resolve, time))
237
+
238
+ type Props = {
239
+ tocTitle?: string
240
+ showToc?: boolean
241
+ shiftHeding?: number
242
+ children: string
243
+ }
244
+
245
+ export const Markdown = ({
246
+ children,
247
+ showToc,
248
+ tocTitle = '目次',
249
+ shiftHeding = 0
250
+ }: Props) => {
251
+ const [toc, setToc] = React.useState<HeadingItem[]>([])
252
+ const [element, setElement] = React.useState(<React.Fragment />)
253
+
254
+ const markdown2Headings = React.useCallback((md: string) => {
255
+ // biome-ignore lint/suspicious/noExplicitAny: remark does not type the data that plugins attach to the VFile
256
+ const result: any = remark().use(headingsPlugin).processSync(md)
257
+
258
+ const headings: HeadingItem[] = result.data.fm.headings.filter(
259
+ (obj: HeadingItem) => obj.depth < 3
260
+ )
261
+
262
+ return headings
263
+ }, [])
264
+
265
+ const markdown2ReactElements = React.useCallback(
266
+ (md: string) => {
267
+ const rhypeReactOptions = {
268
+ ...production,
269
+ components: {
270
+ a: Anchor,
271
+ article: Article,
272
+ button: Button,
273
+ code: Code,
274
+ dl: Faq,
275
+ dt: Question,
276
+ dd: Answer,
277
+ h1: H1,
278
+ h2: H2,
279
+ h3: H3,
280
+ h4: H4,
281
+ h5: H5,
282
+ h6: H6,
283
+ iframe: Iframe,
284
+ img: Img,
285
+ ul: Ul,
286
+ ol: Ol,
287
+ pre: Pre,
288
+ table: TableContainer,
289
+ caption: Caption,
290
+ thead: Thead,
291
+ tbody: Tbody,
292
+ th: Th,
293
+ tr: Tr,
294
+ td: Td,
295
+ div: Div
296
+ }
297
+ }
298
+
299
+ const elem = unified()
300
+ .use(remarkParse) // md -> mdast (Markdown Abstract Syntax Tree)
301
+ .use(remarkGfm) // mdast -> GFM mdast (GitHub Flavored Markdown Abstract Syntax Tree)
302
+ .use(remarkDirective) // support for directive syntax
303
+ .use(remarkBreaks)
304
+ .use(attrPlugin)
305
+ .use(youtubePlugin)
306
+ .use(linkButtonPlugin)
307
+ .use(cellPlugin)
308
+ .use(cardPlugin)
309
+ .use(faqPlugin)
310
+ .use(gridPlugin)
311
+ .use(remarkRehype, {
312
+ allowDangerousHtml: true
313
+ }) // mdast -> hast (HTML Abstract Syntax Tree)
314
+ .use(rehypeRaw) // hast -> hast
315
+ .use(rehypeExternalLinks, { target: '_blank' }) // hast -> hast
316
+ .use(rebypeShiftHeding, { shift: shiftHeding }) // hast -> hast
317
+ .use(rehypeSlug)
318
+ // biome-ignore lint/suspicious/noExplicitAny: rehype-react's declared option type rejects the component map it accepts at runtime
319
+ .use(rehypeReact, rhypeReactOptions as any) // hast -> React Elements
320
+ .processSync(md).result
321
+ return elem
322
+ },
323
+ [shiftHeding]
324
+ )
325
+
326
+ React.useEffect(() => {
327
+ setToc(markdown2Headings(children))
328
+ setElement(markdown2ReactElements(children))
329
+ }, [children, markdown2Headings, markdown2ReactElements])
330
+
331
+ React.useEffect(() => {
332
+ // Necessary to make in-page links work.
333
+ const scrollToHash = async () => {
334
+ await sleep(500)
335
+ if (location.hash) {
336
+ document
337
+ .getElementById(decodeURI(location.hash.substring(1)))
338
+ ?.scrollIntoView()
339
+ }
340
+ }
341
+ scrollToHash()
342
+ }, [])
343
+
344
+ const style = `
345
+ rounded-3xl
346
+ p-10
347
+ bg-yellow-50
348
+ `
349
+
350
+ return (
351
+ <div className="py-8 flex flex-col gap-8">
352
+ {showToc && (
353
+ <nav className={style}>
354
+ <h2 className="mb-4 font-bold text-h-xs-m sm:text-h-xs">
355
+ {tocTitle}
356
+ </h2>
357
+ <Ul>
358
+ <TableOfContents items={toc} />
359
+ </Ul>
360
+ </nav>
361
+ )}
362
+ {element}
363
+ </div>
364
+ )
365
+ }
@@ -0,0 +1 @@
1
+ export { Markdown } from './Markdown'
@@ -0,0 +1,9 @@
1
+ import type { JSX as Jsx } from 'react/jsx-runtime'
2
+
3
+ declare global {
4
+ namespace JSX {
5
+ type ElementClass = Jsx.ElementClass
6
+ type Element = Jsx.Element
7
+ type IntrinsicElements = Jsx.IntrinsicElements
8
+ }
9
+ }
@@ -0,0 +1 @@
1
+ export { Markdown } from './components'