@firerian/fireui 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +74 -0
  3. package/dist/fireui.cjs +2 -0
  4. package/dist/fireui.cjs.map +1 -0
  5. package/dist/fireui.css +1 -0
  6. package/dist/fireui.es.mjs +3867 -0
  7. package/dist/fireui.es.mjs.map +1 -0
  8. package/dist/fireui.umd.js +2 -0
  9. package/dist/fireui.umd.js.map +1 -0
  10. package/dist/types/index.d.ts +1590 -0
  11. package/package.json +132 -0
  12. package/src/components/button/button.test.ts +357 -0
  13. package/src/components/button/button.vue +366 -0
  14. package/src/components/button/index.ts +17 -0
  15. package/src/components/button/types.ts +76 -0
  16. package/src/components/form/form-item.vue +136 -0
  17. package/src/components/form/form.vue +76 -0
  18. package/src/components/form/index.ts +16 -0
  19. package/src/components/grid/col.vue +99 -0
  20. package/src/components/grid/index.ts +16 -0
  21. package/src/components/grid/row.vue +85 -0
  22. package/src/components/grid/types.ts +66 -0
  23. package/src/components/index.ts +36 -0
  24. package/src/components/input/index.ts +8 -0
  25. package/src/components/input/input.test.ts +129 -0
  26. package/src/components/input/input.vue +256 -0
  27. package/src/components/input/types.ts +100 -0
  28. package/src/components/layout/aside.vue +89 -0
  29. package/src/components/layout/container.vue +53 -0
  30. package/src/components/layout/footer.vue +57 -0
  31. package/src/components/layout/header.vue +56 -0
  32. package/src/components/layout/index.ts +28 -0
  33. package/src/components/layout/main.vue +36 -0
  34. package/src/components/layout/types.ts +74 -0
  35. package/src/components/table/index.ts +16 -0
  36. package/src/components/table/table-column.vue +69 -0
  37. package/src/components/table/table.vue +354 -0
  38. package/src/components/tips/index.ts +12 -0
  39. package/src/components/tips/tips.test.ts +96 -0
  40. package/src/components/tips/tips.vue +206 -0
  41. package/src/components/tips/types.ts +56 -0
  42. package/src/components/tooltip/index.ts +8 -0
  43. package/src/components/tooltip/tooltip.test.ts +187 -0
  44. package/src/components/tooltip/tooltip.vue +261 -0
  45. package/src/components/tooltip/types.ts +60 -0
  46. package/src/hooks/useForm.ts +233 -0
  47. package/src/hooks/useTable.ts +153 -0
  48. package/src/index.ts +48 -0
  49. package/src/styles/main.scss +6 -0
  50. package/src/styles/mixins.scss +48 -0
  51. package/src/styles/reset.scss +49 -0
  52. package/src/styles/variables.scss +137 -0
  53. package/src/types/component.ts +9 -0
  54. package/src/types/form.ts +149 -0
  55. package/src/types/global.d.ts +49 -0
  56. package/src/types/grid.ts +76 -0
  57. package/src/types/index.ts +23 -0
  58. package/src/types/table.ts +181 -0
  59. package/src/types/tooltip.ts +44 -0
  60. package/src/utils/auto-import.ts +41 -0
  61. package/src/utils/index.ts +2 -0
  62. package/src/utils/install.ts +20 -0
  63. package/src/utils/useNamespace.ts +29 -0
@@ -0,0 +1,100 @@
1
+ export interface InputProps {
2
+ /**
3
+ * 输入框类型
4
+ */
5
+ type?: string
6
+ /**
7
+ * 绑定值
8
+ */
9
+ modelValue?: string | number
10
+ /**
11
+ * 占位符
12
+ */
13
+ placeholder?: string
14
+ /**
15
+ * 是否禁用
16
+ */
17
+ disabled?: boolean
18
+ /**
19
+ * 是否只读
20
+ */
21
+ readonly?: boolean
22
+ /**
23
+ * 是否为密码输入框
24
+ */
25
+ password?: boolean
26
+ /**
27
+ * 最大长度
28
+ */
29
+ maxlength?: number
30
+ /**
31
+ * 最小长度
32
+ */
33
+ minlength?: number
34
+ /**
35
+ * 是否显示字数统计
36
+ */
37
+ showWordLimit?: boolean
38
+ /**
39
+ * 输入框大小
40
+ */
41
+ size?: 'large' | 'medium' | 'small'
42
+ /**
43
+ * 前缀图标
44
+ */
45
+ prefixIcon?: string | object
46
+ /**
47
+ * 后缀图标
48
+ */
49
+ suffixIcon?: string | object
50
+ /**
51
+ * 自定义类名
52
+ */
53
+ class?: string
54
+ /**
55
+ * 自定义样式
56
+ */
57
+ style?: string | object
58
+ }
59
+
60
+ export interface InputEmits {
61
+ /**
62
+ * 输入事件
63
+ */
64
+ (e: 'update:modelValue', value: string | number): void
65
+ /**
66
+ * 输入事件
67
+ */
68
+ (e: 'input', value: string | number): void
69
+ /**
70
+ * 焦点事件
71
+ */
72
+ (e: 'focus', event: FocusEvent): void
73
+ /**
74
+ * 失焦事件
75
+ */
76
+ (e: 'blur', event: FocusEvent): void
77
+ /**
78
+ * 回车事件
79
+ */
80
+ (e: 'enter', event: KeyboardEvent): void
81
+ /**
82
+ * 清除事件
83
+ */
84
+ (e: 'clear'): void
85
+ }
86
+
87
+ export interface InputSlots {
88
+ /**
89
+ * 前缀
90
+ */
91
+ prefix?: () => any
92
+ /**
93
+ * 后缀
94
+ */
95
+ suffix?: () => any
96
+ /**
97
+ * 输入框内容
98
+ */
99
+ default?: () => any
100
+ }
@@ -0,0 +1,89 @@
1
+ <template>
2
+ <aside
3
+ :class="[
4
+ ns.b,
5
+ {
6
+ [ns.m('collapsed')]: collapsed
7
+ }
8
+ ]"
9
+ :style="asideStyle"
10
+ >
11
+ <slot></slot>
12
+ </aside>
13
+ </template>
14
+
15
+ <script setup lang="ts">
16
+ import { computed } from 'vue'
17
+ import { useNamespace } from '../../utils'
18
+
19
+ const ns = useNamespace('aside')
20
+
21
+ const props = withDefaults(defineProps<{
22
+ /**
23
+ * 侧边栏宽度
24
+ */
25
+ width?: string | number
26
+ /**
27
+ * 是否折叠
28
+ */
29
+ collapsed?: boolean
30
+ /**
31
+ * 自定义类名
32
+ */
33
+ class?: string
34
+ /**
35
+ * 自定义样式
36
+ */
37
+ style?: string | object
38
+ }>(), {
39
+ width: 240,
40
+ collapsed: false
41
+ })
42
+
43
+ defineEmits<{
44
+ /**
45
+ * 折叠状态变化事件
46
+ */
47
+ (e: 'update:collapsed', value: boolean): void
48
+ }>()
49
+
50
+ const asideStyle = computed(() => {
51
+ const style: Record<string, string> = {}
52
+ if (props.width) {
53
+ style.width = typeof props.width === 'number' ? `${props.width}px` : props.width
54
+ }
55
+ return style
56
+ })
57
+ </script>
58
+
59
+ <style scoped lang="scss">
60
+ @import '../../styles/variables.scss';
61
+
62
+ .#{$namespace}-aside {
63
+ width: 240px;
64
+ flex-shrink: 0;
65
+ background-color: #ffffff;
66
+ box-shadow: $shadow-sm;
67
+ transition: all 0.3s ease;
68
+ overflow: hidden;
69
+ height: 100%;
70
+ z-index: 99;
71
+
72
+ &--collapsed {
73
+ width: 64px;
74
+ flex-basis: 64px;
75
+ }
76
+
77
+ @media (max-width: 768px) {
78
+ position: fixed;
79
+ left: 0;
80
+ top: 64px;
81
+ height: calc(100vh - 64px);
82
+ transform: translateX(-100%);
83
+
84
+ &:not(.#{$namespace}-aside--collapsed) {
85
+ transform: translateX(0);
86
+ }
87
+ }
88
+ }
89
+ </style>
@@ -0,0 +1,53 @@
1
+ <template>
2
+ <div
3
+ :class="[
4
+ ns.b,
5
+ ns.m(`direction-${direction}`)
6
+ ]"
7
+ >
8
+ <slot></slot>
9
+ </div>
10
+ </template>
11
+
12
+ <script setup lang="ts">
13
+ import { useNamespace } from '../../utils'
14
+
15
+ const ns = useNamespace('container')
16
+
17
+ withDefaults(defineProps<{
18
+ /**
19
+ * 布局方向
20
+ */
21
+ direction?: 'horizontal' | 'vertical'
22
+ /**
23
+ * 自定义类名
24
+ */
25
+ class?: string
26
+ /**
27
+ * 自定义样式
28
+ */
29
+ style?: string | object
30
+ }>(), {
31
+ direction: 'horizontal'
32
+ })
33
+ </script>
34
+
35
+ <style scoped lang="scss">
36
+ @import '../../styles/variables.scss';
37
+
38
+ .#{$namespace}-container {
39
+ display: flex;
40
+ flex-direction: row;
41
+ height: 100%;
42
+ width: 100%;
43
+ background-color: $bg-color;
44
+
45
+ &--direction-vertical {
46
+ flex-direction: column;
47
+ }
48
+
49
+ @media (max-width: 768px) {
50
+ flex-direction: column;
51
+ }
52
+ }
53
+ </style>
@@ -0,0 +1,57 @@
1
+ <template>
2
+ <footer
3
+ :class="ns.b"
4
+ :style="footerStyle"
5
+ >
6
+ <slot></slot>
7
+ </footer>
8
+ </template>
9
+
10
+ <script setup lang="ts">
11
+ import { computed } from 'vue'
12
+ import { useNamespace } from '../../utils'
13
+
14
+ const ns = useNamespace('footer')
15
+
16
+ const props = withDefaults(defineProps<{
17
+ /**
18
+ * 底部高度
19
+ */
20
+ height?: string | number
21
+ /**
22
+ * 自定义类名
23
+ */
24
+ class?: string
25
+ /**
26
+ * 自定义样式
27
+ */
28
+ style?: string | object
29
+ }>(), {
30
+ height: 64
31
+ })
32
+
33
+ const footerStyle = computed(() => {
34
+ const style: Record<string, string> = {}
35
+ if (props.height) {
36
+ style.height = typeof props.height === 'number' ? `${props.height}px` : props.height
37
+ }
38
+ return style
39
+ })
40
+ </script>
41
+
42
+ <style scoped lang="scss">
43
+ @import '../../styles/variables.scss';
44
+
45
+ .#{$namespace}-footer {
46
+ display: flex;
47
+ align-items: center;
48
+ justify-content: center;
49
+ padding: 0 24px;
50
+ background-color: #ffffff;
51
+ box-shadow: $shadow-sm inset;
52
+ flex-shrink: 0;
53
+ height: 64px;
54
+ color: #666666;
55
+ font-size: 14px;
56
+ }
57
+ </style>
@@ -0,0 +1,56 @@
1
+ <template>
2
+ <header
3
+ :class="ns.b"
4
+ :style="headerStyle"
5
+ >
6
+ <slot></slot>
7
+ </header>
8
+ </template>
9
+
10
+ <script setup lang="ts">
11
+ import { computed } from 'vue'
12
+ import { useNamespace } from '../../utils'
13
+
14
+ const ns = useNamespace('header')
15
+
16
+ const props = withDefaults(defineProps<{
17
+ /**
18
+ * 头部高度
19
+ */
20
+ height?: string | number
21
+ /**
22
+ * 自定义类名
23
+ */
24
+ class?: string
25
+ /**
26
+ * 自定义样式
27
+ */
28
+ style?: string | object
29
+ }>(), {
30
+ height: 64
31
+ })
32
+
33
+ const headerStyle = computed(() => {
34
+ const style: Record<string, string> = {}
35
+ if (props.height) {
36
+ style.height = typeof props.height === 'number' ? `${props.height}px` : props.height
37
+ }
38
+ return style
39
+ })
40
+ </script>
41
+
42
+ <style scoped lang="scss">
43
+ @import '../../styles/variables.scss';
44
+
45
+ .#{$namespace}-header {
46
+ display: flex;
47
+ align-items: center;
48
+ justify-content: space-between;
49
+ padding: 0 24px;
50
+ background-color: #ffffff;
51
+ box-shadow: $shadow-sm;
52
+ z-index: 100;
53
+ height: 64px;
54
+ flex-shrink: 0;
55
+ }
56
+ </style>
@@ -0,0 +1,28 @@
1
+ import Container from './container.vue'
2
+ import Header from './header.vue'
3
+ import Aside from './aside.vue'
4
+ import Main from './main.vue'
5
+ import Footer from './footer.vue'
6
+ import { withInstall } from '../../utils'
7
+
8
+ const FireContainer = withInstall(Container)
9
+ const FireHeader = withInstall(Header)
10
+ const FireAside = withInstall(Aside)
11
+ const FireMain = withInstall(Main)
12
+ const FireFooter = withInstall(Footer)
13
+
14
+ export {
15
+ FireContainer,
16
+ FireHeader,
17
+ FireAside,
18
+ FireMain,
19
+ FireFooter
20
+ }
21
+
22
+ export default {
23
+ FireContainer,
24
+ FireHeader,
25
+ FireAside,
26
+ FireMain,
27
+ FireFooter
28
+ }
@@ -0,0 +1,36 @@
1
+ <template>
2
+ <main
3
+ :class="ns.b"
4
+ >
5
+ <slot></slot>
6
+ </main>
7
+ </template>
8
+
9
+ <script setup lang="ts">
10
+ import { useNamespace } from '../../utils'
11
+
12
+ const ns = useNamespace('main')
13
+
14
+ withDefaults(defineProps<{
15
+ /**
16
+ * 自定义类名
17
+ */
18
+ class?: string
19
+ /**
20
+ * 自定义样式
21
+ */
22
+ style?: string | object
23
+ }>(), {})
24
+ </script>
25
+
26
+ <style scoped lang="scss">
27
+ @import '../../styles/variables.scss';
28
+
29
+ .#{$namespace}-main {
30
+ flex: 1;
31
+ padding: 24px;
32
+ background-color: #f5f5f5;
33
+ overflow-y: auto;
34
+ min-height: 0;
35
+ }
36
+ </style>
@@ -0,0 +1,74 @@
1
+ export interface ContainerProps {
2
+ /**
3
+ * 布局方向
4
+ */
5
+ direction?: 'horizontal' | 'vertical'
6
+ /**
7
+ * 自定义类名
8
+ */
9
+ class?: string
10
+ /**
11
+ * 自定义样式
12
+ */
13
+ style?: string | object
14
+ }
15
+
16
+ export interface HeaderProps {
17
+ /**
18
+ * 头部高度
19
+ */
20
+ height?: string | number
21
+ /**
22
+ * 自定义类名
23
+ */
24
+ class?: string
25
+ /**
26
+ * 自定义样式
27
+ */
28
+ style?: string | object
29
+ }
30
+
31
+ export interface AsideProps {
32
+ /**
33
+ * 侧边栏宽度
34
+ */
35
+ width?: string | number
36
+ /**
37
+ * 折叠状态
38
+ */
39
+ collapsed?: boolean
40
+ /**
41
+ * 自定义类名
42
+ */
43
+ class?: string
44
+ /**
45
+ * 自定义样式
46
+ */
47
+ style?: string | object
48
+ }
49
+
50
+ export interface MainProps {
51
+ /**
52
+ * 自定义类名
53
+ */
54
+ class?: string
55
+ /**
56
+ * 自定义样式
57
+ */
58
+ style?: string | object
59
+ }
60
+
61
+ export interface FooterProps {
62
+ /**
63
+ * 底部高度
64
+ */
65
+ height?: string | number
66
+ /**
67
+ * 自定义类名
68
+ */
69
+ class?: string
70
+ /**
71
+ * 自定义样式
72
+ */
73
+ style?: string | object
74
+ }
@@ -0,0 +1,16 @@
1
+ import Table from './table.vue'
2
+ import TableColumn from './table-column.vue'
3
+ import { withInstall } from '../../utils'
4
+
5
+ const FireTable = withInstall(Table)
6
+ const FireTableColumn = withInstall(TableColumn)
7
+
8
+ export {
9
+ FireTable,
10
+ FireTableColumn
11
+ }
12
+
13
+ export default {
14
+ FireTable,
15
+ FireTableColumn
16
+ }
@@ -0,0 +1,69 @@
1
+ <template>
2
+ <div style="display: none;">
3
+ <!-- TableColumn 只是一个配置组件,不直接渲染内容 -->
4
+ </div>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ import { onMounted, onUnmounted, useSlots, computed } from 'vue'
9
+ import { useTableContext, useTableColumn } from '../../hooks/useTable'
10
+ import type { TableColumnProps } from '../../types/table'
11
+
12
+ const props = withDefaults(defineProps<TableColumnProps>(), {
13
+ prop: '',
14
+ label: '',
15
+ width: '',
16
+ fixed: undefined,
17
+ sortable: false,
18
+ sortOrder: null,
19
+ filters: undefined,
20
+ filteredValue: undefined
21
+ })
22
+
23
+ const slots = useSlots()
24
+
25
+ const tableContext = useTableContext()
26
+ const { columnInstance } = useTableColumn(props)
27
+
28
+ // 扩展 columnInstance,添加 slots 信息
29
+ const columnWithSlots = computed(() => {
30
+ return {
31
+ ...columnInstance.column,
32
+ $slots: slots
33
+ }
34
+ })
35
+
36
+ onMounted(() => {
37
+ // 注册列到表格
38
+ const table = (tableContext as any).table
39
+ if (table && table.registerColumn) {
40
+ table.registerColumn(columnWithSlots.value)
41
+ }
42
+
43
+ // 也可以直接通过表格实例注册
44
+ const tableElement = document.querySelector('.fire-table')
45
+ if (tableElement && (tableElement as any).__vueParentComponent) {
46
+ const parent = (tableElement as any).__vueParentComponent
47
+ if (parent.proxy && parent.proxy.registerColumn) {
48
+ parent.proxy.registerColumn(columnWithSlots.value)
49
+ }
50
+ }
51
+ })
52
+
53
+ onUnmounted(() => {
54
+ // 从表格中移除列
55
+ const table = (tableContext as any).table
56
+ if (table && table.unregisterColumn) {
57
+ table.unregisterColumn(columnWithSlots.value)
58
+ }
59
+
60
+ // 也可以直接通过表格实例移除
61
+ const tableElement = document.querySelector('.fire-table')
62
+ if (tableElement && (tableElement as any).__vueParentComponent) {
63
+ const parent = (tableElement as any).__vueParentComponent
64
+ if (parent.proxy && parent.proxy.unregisterColumn) {
65
+ parent.proxy.unregisterColumn(columnWithSlots.value)
66
+ }
67
+ }
68
+ })
69
+ </script>