intable 0.0.6 → 0.0.8

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 (197) hide show
  1. package/.github/copilot-instructions.md +102 -0
  2. package/README.md +16 -263
  3. package/docs/index-BaMALNy6.css +1 -0
  4. package/docs/index-CDN48t9E.js +3 -0
  5. package/docs/index-Cc4RNkLY.css +1 -0
  6. package/docs/index-MRnbkYmU.js +3 -0
  7. package/docs/index.html +15 -0
  8. package/docs/vite.svg +1 -0
  9. package/index.html +13 -0
  10. package/package.json +35 -38
  11. package/packages/intable/README.md +379 -0
  12. package/packages/intable/package.json +51 -0
  13. package/packages/intable/src/assets/ClearFormat.svg +3 -0
  14. package/packages/intable/src/assets/Forms.svg +4 -0
  15. package/packages/intable/src/assets/MergeCell.svg +4 -0
  16. package/packages/intable/src/assets/SplitCell.svg +4 -0
  17. package/packages/intable/src/assets/gap.svg +3 -0
  18. package/packages/intable/src/assets/loading.svg +12 -0
  19. package/packages/intable/src/assets/paint.svg +9 -0
  20. package/packages/intable/src/assets/solid.svg +1 -0
  21. package/packages/intable/src/components/Columns.tsx +86 -0
  22. package/packages/intable/src/components/DocTree.tsx +36 -0
  23. package/packages/intable/src/components/Menu.tsx +109 -0
  24. package/packages/intable/src/components/Popover.tsx +55 -0
  25. package/packages/intable/src/components/RecycleList.tsx +99 -0
  26. package/packages/intable/src/components/Render.tsx +26 -0
  27. package/packages/intable/src/components/Split.tsx +56 -0
  28. package/packages/intable/src/components/Tree.tsx +115 -0
  29. package/packages/intable/src/components/utils.tsx +12 -0
  30. package/packages/intable/src/hooks/index.ts +200 -0
  31. package/packages/intable/src/hooks/useDir.ts +78 -0
  32. package/packages/intable/src/hooks/useSelector.ts +91 -0
  33. package/packages/intable/src/hooks/useSort.tsx +118 -0
  34. package/packages/intable/src/hooks/useVirtualizer.ts +180 -0
  35. package/packages/intable/src/index.tsx +489 -0
  36. package/packages/intable/src/plugins/CellChangeHighlightPlugin.tsx +5 -0
  37. package/packages/intable/src/plugins/CellMergePlugin.tsx +153 -0
  38. package/packages/intable/src/plugins/CellSelectionPlugin.tsx +175 -0
  39. package/packages/intable/src/plugins/CommandPlugin.tsx +74 -0
  40. package/packages/intable/src/plugins/CopyPastePlugin.tsx +99 -0
  41. package/packages/intable/src/plugins/DiffPlugin.tsx +120 -0
  42. package/packages/intable/src/plugins/DragPlugin.tsx +81 -0
  43. package/packages/intable/src/plugins/EditablePlugin.tsx +252 -0
  44. package/packages/intable/src/plugins/ExpandPlugin.tsx +80 -0
  45. package/packages/intable/src/plugins/HeaderGroup.tsx +289 -0
  46. package/packages/intable/src/plugins/HistoryPlugin.tsx +49 -0
  47. package/packages/intable/src/plugins/MenuPlugin.tsx +195 -0
  48. package/packages/intable/src/plugins/RenderPlugin/components.tsx +51 -0
  49. package/packages/intable/src/plugins/RenderPlugin/index.tsx +81 -0
  50. package/packages/intable/src/plugins/ResizePlugin.tsx +122 -0
  51. package/packages/intable/src/plugins/RowGroupPlugin.tsx +122 -0
  52. package/packages/intable/src/plugins/RowSelectionPlugin.tsx +65 -0
  53. package/packages/intable/src/plugins/TreePlugin.tsx +212 -0
  54. package/packages/intable/src/plugins/VirtualScrollPlugin.tsx +190 -0
  55. package/packages/intable/src/plugins/ZodValidatorPlugin.tsx +61 -0
  56. package/packages/intable/src/style.scss +244 -0
  57. package/{dist → packages/intable/src}/theme/antd.scss +14 -5
  58. package/packages/intable/src/theme/dark.scss +46 -0
  59. package/{dist → packages/intable/src}/theme/element-plus.scss +6 -5
  60. package/packages/intable/src/theme/github.scss +80 -0
  61. package/packages/intable/src/theme/material.scss +73 -0
  62. package/packages/intable/src/theme/shadcn.scss +66 -0
  63. package/packages/intable/src/theme/stripe.scss +57 -0
  64. package/packages/intable/src/tree.ts +13 -0
  65. package/packages/intable/src/types/auto-imports.d.ts +13 -0
  66. package/packages/intable/src/utils.ts +122 -0
  67. package/packages/intable/src/wc.tsx +35 -0
  68. package/packages/intable/src/web-component.ts +1 -0
  69. package/packages/react/package.json +36 -0
  70. package/packages/react/src/index.ts +44 -0
  71. package/packages/react/src/plugins/antd.ts +94 -0
  72. package/packages/react/src/style.scss +12 -0
  73. package/packages/react/src/types/auto-imports.d.ts +10 -0
  74. package/packages/vue/package.json +34 -0
  75. package/packages/vue/src/index.ts +63 -0
  76. package/packages/vue/src/plugins/element-plus.ts +69 -0
  77. package/packages/vue/src/style.scss +12 -0
  78. package/packages/vue/src/types/auto-imports.d.ts +10 -0
  79. package/pnpm-workspace.yaml +2 -0
  80. package/public/vite.svg +1 -0
  81. package/scripts/build.js +184 -0
  82. package/scripts/publish.js +95 -0
  83. package/src/assets/ClearFormat.svg +3 -0
  84. package/src/assets/Forms.svg +4 -0
  85. package/src/assets/MergeCell.svg +4 -0
  86. package/src/assets/SplitCell.svg +4 -0
  87. package/src/assets/gap.svg +3 -0
  88. package/src/assets/loading.svg +12 -0
  89. package/src/assets/paint.svg +9 -0
  90. package/src/assets/solid.svg +1 -0
  91. package/src/demo-vue.ts +54 -0
  92. package/src/index.scss +105 -0
  93. package/src/index.tsx +20 -0
  94. package/src/pages/demo/BasicDemo.tsx +19 -0
  95. package/src/pages/demo/CellMergeDemo.tsx +41 -0
  96. package/src/pages/demo/CellSelectionDemo.tsx +24 -0
  97. package/src/pages/demo/CompositeDemo.tsx +60 -0
  98. package/src/pages/demo/CopyPasteDemo.tsx +26 -0
  99. package/src/pages/demo/DiffDemo.tsx +33 -0
  100. package/src/pages/demo/DragDemo.tsx +25 -0
  101. package/src/pages/demo/EditableDemo.tsx +58 -0
  102. package/src/pages/demo/ExpandDemo.tsx +32 -0
  103. package/src/pages/demo/HeaderGroupDemo.tsx +36 -0
  104. package/src/pages/demo/HistoryDemo.tsx +28 -0
  105. package/src/pages/demo/ReactDemo.tsx +59 -0
  106. package/src/pages/demo/ResizeDemo.tsx +24 -0
  107. package/src/pages/demo/RowGroupDemo.tsx +43 -0
  108. package/src/pages/demo/RowSelectionDemo.tsx +27 -0
  109. package/src/pages/demo/TreeDemo.tsx +45 -0
  110. package/src/pages/demo/VirtualScrollDemo.tsx +21 -0
  111. package/src/pages/demo/helpers.tsx +39 -0
  112. package/src/pages/demo/index.tsx +180 -0
  113. package/src/pages/index.tsx +2 -0
  114. package/src/pages/website.scss +37 -0
  115. package/src/pages/website.tsx +651 -0
  116. package/src/styles/index.scss +172 -0
  117. package/src/types/auto-imports.d.ts +13 -0
  118. package/stats.html +4949 -0
  119. package/tsconfig.app.json +34 -0
  120. package/tsconfig.json +7 -0
  121. package/tsconfig.node.json +26 -0
  122. package/vite.config.ts +70 -0
  123. package/dist/__uno.css +0 -1
  124. package/dist/chevron-right.js +0 -6
  125. package/dist/components/Columns.d.ts +0 -3
  126. package/dist/components/Columns.js +0 -71
  127. package/dist/components/DocTree.d.ts +0 -4
  128. package/dist/components/DocTree.js +0 -32
  129. package/dist/components/Menu.d.ts +0 -1
  130. package/dist/components/Menu.js +0 -107
  131. package/dist/components/Popover.d.ts +0 -14
  132. package/dist/components/Popover.js +0 -41
  133. package/dist/components/Render.d.ts +0 -4
  134. package/dist/components/Render.js +0 -20
  135. package/dist/components/Split.d.ts +0 -15
  136. package/dist/components/Split.js +0 -76
  137. package/dist/components/Tree.d.ts +0 -37
  138. package/dist/components/Tree.js +0 -82
  139. package/dist/components/utils.d.ts +0 -3
  140. package/dist/components/utils.js +0 -8
  141. package/dist/hooks/index.d.ts +0 -40
  142. package/dist/hooks/index.js +0 -157
  143. package/dist/hooks/useDir.d.ts +0 -11
  144. package/dist/hooks/useDir.js +0 -42
  145. package/dist/hooks/useSelector.d.ts +0 -16
  146. package/dist/hooks/useSelector.js +0 -35
  147. package/dist/hooks/useSort.d.ts +0 -18
  148. package/dist/hooks/useSort.js +0 -83
  149. package/dist/hooks/useVirtualizer.d.ts +0 -25
  150. package/dist/hooks/useVirtualizer.js +0 -67
  151. package/dist/index.d.ts +0 -130
  152. package/dist/index.js +0 -347
  153. package/dist/loading.js +0 -6
  154. package/dist/plugins/CellChangeHighlightPlugin.d.ts +0 -2
  155. package/dist/plugins/CellChangeHighlightPlugin.js +0 -4
  156. package/dist/plugins/CellMergePlugin.d.ts +0 -12
  157. package/dist/plugins/CellMergePlugin.js +0 -2
  158. package/dist/plugins/CellSelectionPlugin.d.ts +0 -15
  159. package/dist/plugins/CellSelectionPlugin.js +0 -115
  160. package/dist/plugins/CommandPlugin.d.ts +0 -14
  161. package/dist/plugins/CommandPlugin.js +0 -12
  162. package/dist/plugins/CopyPastePlugin.d.ts +0 -14
  163. package/dist/plugins/CopyPastePlugin.js +0 -42
  164. package/dist/plugins/DiffPlugin.d.ts +0 -23
  165. package/dist/plugins/DiffPlugin.js +0 -56
  166. package/dist/plugins/DragPlugin.d.ts +0 -14
  167. package/dist/plugins/DragPlugin.js +0 -47
  168. package/dist/plugins/EditablePlugin.d.ts +0 -48
  169. package/dist/plugins/EditablePlugin.js +0 -141
  170. package/dist/plugins/ExpandPlugin.d.ts +0 -18
  171. package/dist/plugins/ExpandPlugin.js +0 -50
  172. package/dist/plugins/HistoryPlugin.d.ts +0 -10
  173. package/dist/plugins/HistoryPlugin.js +0 -30
  174. package/dist/plugins/MenuPlugin.d.ts +0 -18
  175. package/dist/plugins/MenuPlugin.js +0 -107
  176. package/dist/plugins/RenderPlugin/components.d.ts +0 -5
  177. package/dist/plugins/RenderPlugin/components.js +0 -87
  178. package/dist/plugins/RenderPlugin/index.d.ts +0 -30
  179. package/dist/plugins/RenderPlugin/index.js +0 -49
  180. package/dist/plugins/ResizePlugin.d.ts +0 -27
  181. package/dist/plugins/ResizePlugin.js +0 -81
  182. package/dist/plugins/RowGroupPlugin.d.ts +0 -17
  183. package/dist/plugins/RowGroupPlugin.js +0 -83
  184. package/dist/plugins/RowSelectionPlugin.d.ts +0 -20
  185. package/dist/plugins/RowSelectionPlugin.js +0 -42
  186. package/dist/plugins/VirtualScrollPlugin.d.ts +0 -15
  187. package/dist/plugins/VirtualScrollPlugin.js +0 -96
  188. package/dist/plus.js +0 -6
  189. package/dist/style.css +0 -3
  190. package/dist/types/auto-imports.d.js +0 -0
  191. package/dist/utils.d.ts +0 -30
  192. package/dist/utils.js +0 -70
  193. package/dist/wc.d.ts +0 -1
  194. package/dist/wc.js +0 -21
  195. package/dist/web-component.d.ts +0 -1
  196. package/dist/web-component.js +0 -2
  197. package/dist/x.js +0 -6
@@ -0,0 +1,94 @@
1
+ import type { Plugin } from 'intable'
2
+ import type { Editor } from 'intable/plugins/EditablePlugin'
3
+ import { resolveOptions } from 'intable/utils'
4
+
5
+ import { Checkbox, ColorPicker, DatePicker, Input, InputNumber, Rate, Select, Switch, TimePicker } from 'antd'
6
+ import { useEffect, useRef, useState, createElement as h, type FC } from 'react'
7
+ import { createRoot } from 'react-dom/client'
8
+
9
+ export const AntdPlugin: Plugin = {
10
+ name: 'antd',
11
+ store(store) {
12
+ store.editors.text = editor(Input)
13
+ store.editors.number = editor(InputNumber)
14
+ store.editors.rate = editor(Rate)
15
+ store.editors.switch = editor(Switch)
16
+ store.editors.checkbox = editor(Checkbox)
17
+ store.editors.color = selector(ColorPicker, { transform: v => v?.toHexString?.() || v })
18
+ store.editors.select = selector(Select)
19
+ store.editors.date = selector(DatePicker)
20
+ store.editors.time = selector(TimePicker)
21
+ store.editors.datetime = selector(DatePicker, { showTime: true })
22
+ },
23
+ rewriteProps: {
24
+ class: ({ class: clazz }) => `antd ${clazz}`
25
+ }
26
+ }
27
+
28
+ const getEl = (el: any) => {
29
+ if (!el) return el
30
+ if (el instanceof Text) el = el.nextElementSibling
31
+ return el?.querySelector('input') ?? el?.querySelector('button') ?? el?.querySelector('[class*=trigger]') ?? el
32
+ }
33
+
34
+ const createEditor = (Comp: FC<any>, opts: any, isSelector?: boolean): Editor => (editorOpts) => {
35
+ const { eventKey, value, col, ok, cancel, props } = editorOpts
36
+ const container = document.createElement('div')
37
+ const root = createRoot(container)
38
+
39
+ let currentValue = eventKey || value
40
+ let elRef: any
41
+
42
+ const EditorComp = () => {
43
+ const [val, setVal] = useState(currentValue)
44
+ const ref = useRef<any>(null)
45
+
46
+ useEffect(() => {
47
+ elRef = ref.current
48
+ if (isSelector) {
49
+ setTimeout(() => (getEl(ref.current)?.click?.(), ref.current?.focus?.()), 0)
50
+ } else {
51
+ ref.current?.focus?.()
52
+ }
53
+ }, [])
54
+
55
+ const handleChange = (newVal: any) => {
56
+ currentValue = opts.transform ? opts.transform(newVal) : newVal
57
+ setVal(currentValue)
58
+ isSelector && setTimeout(ok, 100)
59
+ }
60
+
61
+ const handleKeyDown = (e: any) => {
62
+ e.stopPropagation()
63
+ if (e.key === 'Enter') ok()
64
+ if (e.key === 'Escape') cancel()
65
+ }
66
+
67
+ return h(Comp, {
68
+ ref,
69
+ value: val,
70
+ onChange: handleChange,
71
+ onPointerDown: (e: any) => e.stopPropagation(),
72
+ onKeyDown: handleKeyDown,
73
+ ...(col?.enum && { options: resolveOptions(col.enum) }),
74
+ ...opts,
75
+ ...props,
76
+ })
77
+ }
78
+
79
+ root.render(h(EditorComp))
80
+
81
+ const fragment = document.createDocumentFragment()
82
+ fragment.appendChild(container)
83
+
84
+ return {
85
+ el: fragment,
86
+ getValue: () => currentValue,
87
+ destroy: () => root.unmount(),
88
+ focus: () => (isSelector && getEl(elRef)?.click?.(), elRef?.focus?.()),
89
+ blur: () => elRef?.blur?.(),
90
+ }
91
+ }
92
+
93
+ const editor = (Comp: FC<any>, opts = {}) => createEditor(Comp, opts, false)
94
+ const selector = (Comp: FC<any>, opts = {}) => createEditor(Comp, opts, true)
@@ -0,0 +1,12 @@
1
+ .antd {
2
+ .is-editing {
3
+ & > .area { @apply hidden; }
4
+ }
5
+ .in-cell-edit-wrapper {
6
+ @apply flex items-center p-1;
7
+
8
+ > .ant-input-affix-wrapper > .ant-input-prefix {
9
+ @apply hidden;
10
+ }
11
+ }
12
+ }
@@ -0,0 +1,10 @@
1
+ /* eslint-disable */
2
+ /* prettier-ignore */
3
+ // @ts-nocheck
4
+ // noinspection JSUnusedGlobalSymbols
5
+ // Generated by unplugin-auto-import
6
+ // biome-ignore lint: disable
7
+ export {}
8
+ declare global {
9
+
10
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@intable/vue",
3
+ "version": "0.0.8",
4
+ "license": "MIT",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": "./dist/index.js",
11
+ "./*": {
12
+ "import": "./dist/*.js",
13
+ "types": "./dist/*.d.ts"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "dependencies": {
20
+ "@vue/shared": "^3.5.27",
21
+ "intable": "workspace:^",
22
+ "solid-js": "^1.9.9"
23
+ },
24
+ "peerDependencies": {
25
+ "vue": "^3"
26
+ },
27
+ "devDependencies": {
28
+ "element-plus": "^2.13.0"
29
+ },
30
+ "publishConfig": {
31
+ "access": "public",
32
+ "registry": "https://registry.npmjs.org/"
33
+ }
34
+ }
@@ -0,0 +1,63 @@
1
+ import { onCleanup, createRenderEffect } from 'solid-js'
2
+ import { type Plugin, type TableProps } from 'intable'
3
+ import 'intable/wc'
4
+ import './style.scss'
5
+
6
+ // import '../../intable/src/wc'
7
+
8
+ export type { TableProps } from 'intable'
9
+
10
+ import { h, normalizeClass, toRaw, render, type Component, type FunctionalComponent, type App } from 'vue'
11
+ import { stringifyStyle } from '@vue/shared'
12
+ import { mapValues } from 'es-toolkit'
13
+
14
+ export const Intable: FunctionalComponent<TableProps> = ((props) => (
15
+ props = mapValues(props, v => toRaw(v)),
16
+ h('wc-table', {
17
+ style: 'display: contents',
18
+ '.options': {
19
+ ...props,
20
+ class: normalizeClass(props.class),
21
+ style: stringifyStyle(props.style),
22
+ renderer: component,
23
+ plugins: [
24
+ VModelPlugin,
25
+ ...props.plugins || []
26
+ ]
27
+ } as TableProps
28
+ })
29
+ ))
30
+
31
+ Intable.inheritAttrs = false
32
+ Intable.__name = 'intable'
33
+ Intable.install = app => app.component(Intable.__name, Intable)
34
+
35
+ const VModelPlugin: Plugin = {
36
+ name: 'v-model',
37
+ rewriteProps: {
38
+ rowSelection: ({ rowSelection }, { store }) => ({
39
+ get value() { return store.props?.selected },
40
+ ...rowSelection,
41
+ onChange(selected) {
42
+ store.props!['onUpdate:selected']?.(selected)
43
+ rowSelection?.onChange?.(...arguments)
44
+ },
45
+ }),
46
+ onDataChange: ({ onDataChange }, { store }) => (data) => {
47
+ store.props!['onUpdate:data']?.(data)
48
+ onDataChange?.(data)
49
+ }
50
+ }
51
+ }
52
+
53
+ const component = <T extends Record<string, any>>(Comp: Component<T>) => {
54
+ return (props: T) => {
55
+ const root = document.createDocumentFragment()
56
+ root.remove ??= () => {}
57
+ createRenderEffect(() => render(h(Comp, { ...props }), root))
58
+ onCleanup(() => render(null, root))
59
+ return root
60
+ }
61
+ }
62
+
63
+ export default Intable
@@ -0,0 +1,69 @@
1
+ import type { Plugin } from 'intable'
2
+ import type { Editor } from 'intable/plugins/EditablePlugin'
3
+ import { resolveOptions } from 'intable/utils'
4
+
5
+ import { ElCheckbox, ElColorPicker, ElDatePicker, ElInput, ElInputNumber, ElRate, ElSelect, ElSwitch, ElTimePicker } from 'element-plus'
6
+ import { type Component, h, mergeProps, ref, render } from 'vue'
7
+
8
+ export const ElementPlusPlugin: Plugin = {
9
+ store(store) {
10
+ store.editors.text = createEditor(ElInput)
11
+ store.editors.number = createEditor(ElInputNumber)
12
+ store.editors.rate = createEditor(ElRate)
13
+ store.editors.switch = createEditor(ElSwitch)
14
+ store.editors.checkbox = createEditor(ElCheckbox)
15
+ store.editors.color = createEditor(ElColorPicker, {}, true)
16
+ store.editors.select = createEditor(ElSelect, {}, true)
17
+ store.editors.date = createEditor(ElDatePicker, { valueFormat: 'YYYY-MM-DD' }, true)
18
+ store.editors.time = createEditor(ElTimePicker, {}, true)
19
+ store.editors.datetime = createEditor(ElDatePicker, { type: 'datetime', valueFormat: 'YYYY-MM-DD HH:mm:ss' }, true)
20
+ },
21
+ rewriteProps: {
22
+ class: ({ class: clazz }) => `element-plus ${clazz}`
23
+ }
24
+ }
25
+
26
+ const getElement = (el: any) => {
27
+ if (!el) return el
28
+ if (el instanceof Text) el = el.nextElementSibling
29
+ return el.querySelector('input') ?? el.querySelector('button') ?? el.querySelector('[class*=__trigger]') ?? el
30
+ }
31
+
32
+ const createEditor = (Comp: Component, extra?, isSelector?): Editor => {
33
+ return ({ eventKey, value, col, ok, cancel, props }) => {
34
+ const v = ref(isSelector ? value : (eventKey || value))
35
+ const elref = ref()
36
+ const root = document.createDocumentFragment()
37
+ root.remove ??= () => {}
38
+
39
+ const App = () => h(Comp, mergeProps(extra, props, {
40
+ ref: elref,
41
+ modelValue: v.value,
42
+ 'onUpdate:modelValue': (val) => v.value = val,
43
+ onPointerdown: (e: Event) => e.stopPropagation(),
44
+ onMousedown: (e: Event) => e.stopPropagation(),
45
+ onKeydown: (e: KeyboardEvent) => {
46
+ e.stopPropagation()
47
+ if (e.key === 'Enter') ok()
48
+ if (e.key === 'Escape') cancel()
49
+ },
50
+ ...isSelector ? {
51
+ onChange: () => ok(),
52
+ options: resolveOptions(col.enum ?? []),
53
+ } : {}
54
+ }))
55
+
56
+ render(h(App), root)
57
+
58
+ return {
59
+ el: root,
60
+ getValue: () => v.value,
61
+ destroy: () => render(null, root),
62
+ focus: () => {
63
+ if (isSelector) getElement(elref.value?.$el)?.click()
64
+ elref.value?.focus?.()
65
+ },
66
+ blur: () => elref.value?.blur?.(),
67
+ }
68
+ }
69
+ }
@@ -0,0 +1,12 @@
1
+ .element-plus {
2
+ .is-editing {
3
+ & > .area { @apply hidden; }
4
+ }
5
+ .in-cell-edit-wrapper {
6
+ @apply flex items-center p-1;
7
+
8
+ > .el-input > .el-input__wrapper > .el-input__prefix {
9
+ @apply hidden;
10
+ }
11
+ }
12
+ }
@@ -0,0 +1,10 @@
1
+ /* eslint-disable */
2
+ /* prettier-ignore */
3
+ // @ts-nocheck
4
+ // noinspection JSUnusedGlobalSymbols
5
+ // Generated by unplugin-auto-import
6
+ // biome-ignore lint: disable
7
+ export {}
8
+ declare global {
9
+
10
+ }
@@ -0,0 +1,2 @@
1
+ packages:
2
+ - 'packages/*'
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
@@ -0,0 +1,184 @@
1
+ import { resolve, join, dirname, relative, extname } from 'path'
2
+ import { fileURLToPath } from 'url'
3
+ import { readFileSync, readdirSync, existsSync, rmSync, cpSync, writeFileSync } from 'fs'
4
+ import { build } from 'vite'
5
+
6
+ const __dirname = dirname(fileURLToPath(import.meta.url))
7
+ const rootDir = resolve(__dirname, '..')
8
+ const packagesDir = resolve(rootDir, 'packages')
9
+
10
+ // 获取所有包目录
11
+ function getPackages() {
12
+ const packages = []
13
+ const dirs = readdirSync(packagesDir)
14
+
15
+ for (const dir of dirs) {
16
+ const packagePath = join(packagesDir, dir)
17
+ const packageJsonPath = join(packagePath, 'package.json')
18
+
19
+ if (existsSync(packageJsonPath)) {
20
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'))
21
+ packages.push({
22
+ name: packageJson.name || dir,
23
+ path: packagePath,
24
+ packageJson,
25
+ })
26
+ }
27
+ }
28
+
29
+ return packages
30
+ }
31
+
32
+ // 构建单个包
33
+ async function buildPackage(pkg) {
34
+ console.log(`\n📦 Building ${pkg.name}...`)
35
+
36
+ const distPath = join(pkg.path, 'dist')
37
+
38
+ try {
39
+ await build({
40
+ configFile: process.cwd() + '/vite.config.ts',
41
+ root: pkg.path,
42
+ build: {
43
+ outDir: 'dist',
44
+ lib: {
45
+ // preserve modules
46
+ entry: Object.fromEntries(readdirSync(join(pkg.path, 'src'), { withFileTypes: false, recursive: true }).filter(e => /\.[tj]sx?$/.test(e)).map(e => [
47
+ e.slice(0, e.length - extname(e).length),
48
+ join('src', e)
49
+ ])),
50
+ formats: ['es'],
51
+ cssFileName: 'style',
52
+ },
53
+ rollupOptions: {
54
+ external: id => {
55
+ // 排除所有外部依赖
56
+ const externals = Object.keys({
57
+ ...pkg.packageJson.dependencies,
58
+ ...pkg.packageJson.devDependencies,
59
+ ...pkg.packageJson.peerDependencies,
60
+ })
61
+
62
+ // 排除特定的外部依赖
63
+ return externals.some(ext => id === ext || id.startsWith(ext + '/'))
64
+ },
65
+ output: {
66
+ preserveModules: true,
67
+ // preserveModulesRoot: join(pkg.path, 'src'),
68
+ // entryFileNames: '[name].js',
69
+ // entryFileNames: m => m.moduleIds.some(e => e.includes('node_modules')) ? 'vendor.js' : m.name + '.js',
70
+ advancedChunks: {
71
+ groups: [
72
+ { name: (id) => id.includes('node_modules') ? 'vendor' : null },
73
+ ],
74
+ }
75
+ },
76
+ },
77
+ sourcemap: false,
78
+ minify: true,
79
+ emptyOutDir: true,
80
+ },
81
+ plugins: [
82
+ (await import('vite-plugin-lib-inject-css')).libInjectCss()
83
+ ]
84
+ })
85
+
86
+ // // 复制 style.scss 文件
87
+ // const stylePath = join(pkg.path, 'src/style.scss')
88
+ // if (existsSync(stylePath)) {
89
+ // cpSync(stylePath, join(distPath, 'style.scss'))
90
+ // console.log(' ✓ Copied style.scss')
91
+ // }
92
+
93
+ if (existsSync(join(pkg.path, 'src/theme'))) {
94
+ cpSync(join(pkg.path, 'src/theme'), join(distPath, 'theme'), { recursive: true })
95
+ }
96
+
97
+ // fix: unocss
98
+ if (existsSync(join(pkg.path, 'dist/__uno.css'))) {
99
+ const uno = readFileSync(join(pkg.path, 'dist/__uno.css'), { encoding: 'utf8' })
100
+ const rewrite = (path, fn) => writeFileSync(path, fn(readFileSync(path, { encoding: 'utf8' })))
101
+ rewrite(join(pkg.path, 'dist/style.css'), str => uno + '\n' + str)
102
+ rewrite(join(pkg.path, 'dist/index.js'), str => str.replace(`import './__uno.css'`, ''))
103
+ }
104
+
105
+
106
+ console.log(`✅ ${pkg.name} built successfully!`)
107
+
108
+ await genDts(pkg.path)
109
+ } catch (error) {
110
+ console.error(`❌ Failed to build ${pkg.name}:`, error)
111
+ throw error
112
+ }
113
+ }
114
+
115
+ // 使用 tsc 生成类型定义(跳过错误)
116
+ async function genDts(cwd) {
117
+ console.log(' 📝 Generating TypeScript declarations...')
118
+ try {
119
+ const distPath = join(cwd, 'dist')
120
+ const { execSync } = await import('child_process')
121
+ const { writeFileSync } = await import('fs')
122
+
123
+ // 创建临时 tsconfig 用于生成类型定义
124
+ const tempTsConfig = {
125
+ extends: './tsconfig.app.json',
126
+ compilerOptions: {
127
+ declaration: true,
128
+ emitDeclarationOnly: true,
129
+ noEmit: false,
130
+ outDir: distPath,
131
+ skipLibCheck: true,
132
+ noUnusedLocals: false,
133
+ noUnusedParameters: false,
134
+ jsx: 'preserve',
135
+ jsxImportSource: 'solid-js',
136
+ },
137
+ include: ['src'],
138
+ }
139
+
140
+ const tempConfigPath = join(cwd, 'tsconfig.dts.json')
141
+ writeFileSync(tempConfigPath, JSON.stringify(tempTsConfig, null, 2))
142
+
143
+ try {
144
+ execSync(`pnpm exec tsc --project tsconfig.dts.json --skipLibCheck --noCheck`, { cwd, stdio: 'pipe' })
145
+ } catch (tscExecError) {
146
+ // 即使有错误也尝试查找生成的文件
147
+ const dtsFiles = readdirSync(distPath, { recursive: true }).filter(f => f.endsWith('.d.ts'))
148
+ if (dtsFiles.length > 0) {
149
+ console.log(` ℹ Generated ${dtsFiles.length} declaration files (with some errors)`)
150
+ } else {
151
+ throw tscExecError
152
+ }
153
+ }
154
+
155
+ // 删除临时配置文件
156
+ rmSync(tempConfigPath, { force: true })
157
+
158
+ console.log(' ✓ TypeScript declarations generated')
159
+ } catch (tscError) {
160
+ console.log(' ⚠ TypeScript declarations skipped')
161
+ // 不抛出错误,允许构建继续
162
+ }
163
+ }
164
+
165
+ // 主函数
166
+ async function main() {
167
+ console.log('🚀 Starting package build process...\n')
168
+
169
+ const packages = getPackages()
170
+ console.log(`Found ${packages.length} package(s):`, packages.map(p => p.name).join(', '))
171
+
172
+ // 依次构建每个包
173
+ for (const pkg of packages) {
174
+ await buildPackage(pkg)
175
+ }
176
+
177
+ console.log('\n✨ All packages built successfully!')
178
+ }
179
+
180
+ // 执行构建
181
+ main().catch(error => {
182
+ console.error('Build failed:', error)
183
+ process.exit(1)
184
+ })
@@ -0,0 +1,95 @@
1
+ import { resolve, join, dirname } from 'path'
2
+ import { fileURLToPath } from 'url'
3
+ import { readFileSync, writeFileSync, readdirSync, existsSync } from 'fs'
4
+ import { execSync } from 'child_process'
5
+
6
+ const __dirname = dirname(fileURLToPath(import.meta.url))
7
+ const rootDir = resolve(__dirname, '..')
8
+ const packagesDir = resolve(rootDir, 'packages')
9
+
10
+ // 获取根目录的版本号
11
+ function getRootVersion() {
12
+ const rootPackageJsonPath = join(rootDir, 'package.json')
13
+ const rootPackageJson = JSON.parse(readFileSync(rootPackageJsonPath, 'utf-8'))
14
+ return rootPackageJson.version
15
+ }
16
+
17
+ // 获取所有包目录
18
+ function getPackages() {
19
+ const packages = []
20
+ const dirs = readdirSync(packagesDir)
21
+
22
+ for (const dir of dirs) {
23
+ const packagePath = join(packagesDir, dir)
24
+ const packageJsonPath = join(packagePath, 'package.json')
25
+
26
+ if (existsSync(packageJsonPath)) {
27
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'))
28
+ packages.push({
29
+ name: packageJson.name || dir,
30
+ path: packagePath,
31
+ packageJson,
32
+ packageJsonPath
33
+ })
34
+ }
35
+ }
36
+
37
+ return packages
38
+ }
39
+
40
+ // 同步版本号到子包
41
+ function syncVersion(packages, version) {
42
+ console.log(`\n🔄 Syncing version ${version} to all packages...`)
43
+
44
+ for (const pkg of packages) {
45
+ if (pkg.packageJson.version !== version) {
46
+ pkg.packageJson.version = version
47
+ writeFileSync(pkg.packageJsonPath, JSON.stringify(pkg.packageJson, null, 2))
48
+ console.log(` ✅ Updated ${pkg.name} to version ${version}`)
49
+ } else {
50
+ console.log(` ℹ ${pkg.name} already at version ${version}`)
51
+ }
52
+ }
53
+ }
54
+
55
+ // 发布子包
56
+ function publishPackage(pkg) {
57
+ console.log(`\n📤 Publishing ${pkg.name}...`)
58
+
59
+ try {
60
+ execSync(`pnpm publish --no-git-checks --filter ${pkg.name}`, { cwd: rootDir, stdio: 'inherit' })
61
+ console.log(` ✅ ${pkg.name} published successfully!`)
62
+ } catch (error) {
63
+ console.error(` ❌ Failed to publish ${pkg.name}:`, error.message)
64
+ throw error
65
+ }
66
+ }
67
+
68
+ // 主函数
69
+ async function main() {
70
+ console.log('🚀 Starting publish process...\n')
71
+
72
+ // 获取根目录版本号
73
+ const version = getRootVersion()
74
+ console.log(`Root version: ${version}`)
75
+
76
+ // 获取所有子包
77
+ const packages = getPackages()
78
+ console.log(`Found ${packages.length} package(s):`, packages.map(p => p.name).join(', '))
79
+
80
+ // 同步版本号
81
+ syncVersion(packages, version)
82
+
83
+ // 依次发布每个子包
84
+ for (const pkg of packages) {
85
+ await publishPackage(pkg)
86
+ }
87
+
88
+ console.log('\n✨ All packages published successfully!')
89
+ }
90
+
91
+ // 执行发布
92
+ main().catch(error => {
93
+ console.error('Publish failed:', error)
94
+ process.exit(1)
95
+ })
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
2
+ <path fill="currentColor" d="m14.031 1.888l9.657 9.657l-8.345 8.345l-.27.272H20v2H6.748L.253 15.667zm.322 16.164l6.507-6.507l-6.829-6.828l-6.828 6.828l6.828 6.828l.32-.323zM5.788 12.96l-2.707 2.707l4.495 4.495h4.68l.365-.37z" />
3
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
2
+ <path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
3
+ d="M12 3a3 3 0 0 0-3 3v12a3 3 0 0 0 3 3M6 3a3 3 0 0 1 3 3v12a3 3 0 0 1-3 3m7-14h7a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1h-7M5 7H4a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h1m12-5h.01M13 12h.01" />
4
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
2
+ <path fill="currentColor"
3
+ d="M5 10H3V4h8v2H5zm14 8h-6v2h8v-6h-2zM5 18v-4H3v6h8v-2zM21 4h-8v2h6v4h2zM8 13v2l3-3l-3-3v2H3v2zm8-2V9l-3 3l3 3v-2h5v-2z" />
4
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
2
+ <path fill="currentColor"
3
+ d="M19 14h2v6H3v-6h2v4h14zM3 4v6h2V6h14v4h2V4zm8 7v2H8v2l-3-3l3-3v2zm5 0V9l3 3l-3 3v-2h-3v-2z" />
4
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
2
+ <path fill="currentColor" d="M19 5h-4v14h4v-2h-2V7h2zM5 5h4v14H5v-2h2V7H5zm8 2v10h-2V7z" />
3
+ </svg>
@@ -0,0 +1,12 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
2
+ <g>
3
+ <rect width="2" height="5" x="11" y="1" fill="currentColor" opacity=".14" />
4
+ <rect width="2" height="5" x="11" y="1" fill="currentColor" opacity=".29" transform="rotate(30 12 12)" />
5
+ <rect width="2" height="5" x="11" y="1" fill="currentColor" opacity=".43" transform="rotate(60 12 12)" />
6
+ <rect width="2" height="5" x="11" y="1" fill="currentColor" opacity=".57" transform="rotate(90 12 12)" />
7
+ <rect width="2" height="5" x="11" y="1" fill="currentColor" opacity=".71" transform="rotate(120 12 12)" />
8
+ <rect width="2" height="5" x="11" y="1" fill="currentColor" opacity=".86" transform="rotate(150 12 12)" />
9
+ <rect width="2" height="5" x="11" y="1" fill="currentColor" transform="rotate(180 12 12)" />
10
+ <animateTransform attributeName="transform" calcMode="discrete" dur="0.75s" repeatCount="indefinite" type="rotate" values="0 12 12;30 12 12;60 12 12;90 12 12;120 12 12;150 12 12;180 12 12;210 12 12;240 12 12;270 12 12;300 12 12;330 12 12;360 12 12" />
11
+ </g>
12
+ </svg>
@@ -0,0 +1,9 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
2
+ <g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"
3
+ color="currentColor">
4
+ <path
5
+ d="M22 12c0-5.523-4.477-10-10-10S2 6.477 2 12s4.477 10 10 10c.842 0 2 .116 2-1c0-.609-.317-1.079-.631-1.546c-.46-.683-.917-1.359-.369-2.454c.667-1.333 1.778-1.333 3.482-1.333c.851 0 1.851 0 3.018-.167c2.101-.3 2.5-1.592 2.5-3.5M7 15.002L7.009 15" />
6
+ <circle cx="9.5" cy="8.5" r="1.5" />
7
+ <circle cx="16.5" cy="9.5" r="1.5" />
8
+ </g>
9
+ </svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 166 155.3"><path d="M163 35S110-4 69 5l-3 1c-6 2-11 5-14 9l-2 3-15 26 26 5c11 7 25 10 38 7l46 9 18-30z" fill="#76b3e1"/><linearGradient id="a" gradientUnits="userSpaceOnUse" x1="27.5" y1="3" x2="152" y2="63.5"><stop offset=".1" stop-color="#76b3e1"/><stop offset=".3" stop-color="#dcf2fd"/><stop offset="1" stop-color="#76b3e1"/></linearGradient><path d="M163 35S110-4 69 5l-3 1c-6 2-11 5-14 9l-2 3-15 26 26 5c11 7 25 10 38 7l46 9 18-30z" opacity=".3" fill="url(#a)"/><path d="M52 35l-4 1c-17 5-22 21-13 35 10 13 31 20 48 15l62-21S92 26 52 35z" fill="#518ac8"/><linearGradient id="b" gradientUnits="userSpaceOnUse" x1="95.8" y1="32.6" x2="74" y2="105.2"><stop offset="0" stop-color="#76b3e1"/><stop offset=".5" stop-color="#4377bb"/><stop offset="1" stop-color="#1f3b77"/></linearGradient><path d="M52 35l-4 1c-17 5-22 21-13 35 10 13 31 20 48 15l62-21S92 26 52 35z" opacity=".3" fill="url(#b)"/><linearGradient id="c" gradientUnits="userSpaceOnUse" x1="18.4" y1="64.2" x2="144.3" y2="149.8"><stop offset="0" stop-color="#315aa9"/><stop offset=".5" stop-color="#518ac8"/><stop offset="1" stop-color="#315aa9"/></linearGradient><path d="M134 80a45 45 0 00-48-15L24 85 4 120l112 19 20-36c4-7 3-15-2-23z" fill="url(#c)"/><linearGradient id="d" gradientUnits="userSpaceOnUse" x1="75.2" y1="74.5" x2="24.4" y2="260.8"><stop offset="0" stop-color="#4377bb"/><stop offset=".5" stop-color="#1a336b"/><stop offset="1" stop-color="#1a336b"/></linearGradient><path d="M114 115a45 45 0 00-48-15L4 120s53 40 94 30l3-1c17-5 23-21 13-34z" fill="url(#d)"/></svg>