@ithinkdt/ui 4.0.0-38 → 4.0.0-41

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 (55) hide show
  1. package/dist/components-BC8oa62b.js +1612 -0
  2. package/dist/components.js +5 -0
  3. package/dist/directives-DUuJW647.js +183 -0
  4. package/dist/directives.js +3 -0
  5. package/dist/index.js +1224 -0
  6. package/dist/page.js +511 -0
  7. package/dist/use-i18n-Dx7V4KrY.js +6 -0
  8. package/dist/use-style-DcT-1dj4.js +29 -0
  9. package/dist/use-style.js +2 -0
  10. package/esm/components.js +1 -0
  11. package/esm/directives.js +1 -0
  12. package/esm/index.js +1 -0
  13. package/esm/page.js +1 -0
  14. package/esm/use-style.js +1 -0
  15. package/package.json +21 -18
  16. package/src/components/Checkboxes.jsx +0 -130
  17. package/src/components/DataActions.jsx +0 -105
  18. package/src/components/DataCustom.jsx +0 -187
  19. package/src/components/DataFilter.jsx +0 -119
  20. package/src/components/DataForm.jsx +0 -264
  21. package/src/components/DataLocaleInput.jsx +0 -121
  22. package/src/components/DataPagination.jsx +0 -62
  23. package/src/components/DataSelection.jsx +0 -57
  24. package/src/components/DataTable.jsx +0 -302
  25. package/src/components/Radios.jsx +0 -134
  26. package/src/components/UserDept.jsx +0 -643
  27. package/src/components/assets.jsx +0 -274
  28. package/src/components/index.js +0 -11
  29. package/src/design/Account.jsx +0 -154
  30. package/src/design/Appearance.jsx +0 -89
  31. package/src/design/Breadcrumb.jsx +0 -67
  32. package/src/design/Fullscreen.jsx +0 -65
  33. package/src/design/Language.jsx +0 -45
  34. package/src/design/Layout.jsx +0 -241
  35. package/src/design/Logo.jsx +0 -92
  36. package/src/design/Menu.jsx +0 -133
  37. package/src/design/MultiTabs.jsx +0 -501
  38. package/src/design/Notification.jsx +0 -311
  39. package/src/design/Tenant.jsx +0 -88
  40. package/src/design/common.jsx +0 -21
  41. package/src/design/index.js +0 -11
  42. package/src/directives/index.js +0 -2
  43. package/src/directives/spin.js +0 -181
  44. package/src/directives/tooltip.jsx +0 -121
  45. package/src/index.js +0 -18
  46. package/src/page.jsx +0 -740
  47. package/src/use-i18n.js +0 -8
  48. package/src/use-style.js +0 -58
  49. package/src/utils.js +0 -20
  50. /package/{src → esm}/components.d.ts +0 -0
  51. /package/{src → esm}/design.d.ts +0 -0
  52. /package/{src → esm}/directives.d.ts +0 -0
  53. /package/{src → esm}/index.d.ts +0 -0
  54. /package/{src → esm}/page.d.ts +0 -0
  55. /package/{src → esm}/use-style.d.ts +0 -0
@@ -1,130 +0,0 @@
1
- import { NCheckbox, NCheckboxGroup, NFlex } from 'ithinkdt-ui'
2
- import { computed, defineComponent, ref, watch } from 'vue'
3
-
4
- import { useI18n } from '../use-i18n.js'
5
-
6
- export const NCheckboxes = /* @__PURE__ */ defineComponent({
7
- name: 'Checkboxes',
8
- inheritAttrs: false,
9
- props: {
10
- options: {
11
- type: Array,
12
- default: () => [],
13
- },
14
- vertical: {
15
- type: Boolean,
16
- default: false,
17
- },
18
- default: {
19
- type: [Boolean, String, Object],
20
- default: false,
21
- },
22
- gap: {
23
- type: [Number, String, Array],
24
- default: undefined,
25
- },
26
- modelValue: {
27
- type: Array,
28
- default: undefined,
29
- },
30
- labelPadding: {
31
- type: String,
32
- default: undefined,
33
- },
34
- labelField: {
35
- type: String,
36
- default: 'label',
37
- },
38
- valueField: {
39
- type: String,
40
- default: 'value',
41
- },
42
- disabledField: {
43
- type: String,
44
- default: 'disabled',
45
- },
46
- },
47
- emits: {
48
- 'update:modelValue': () => true,
49
- 'updateModelValue': () => true,
50
- },
51
-
52
- setup(props, { emit, attrs }) {
53
- const { t } = useI18n()
54
- const defaultLabel = computed(() => {
55
- if (!props.default) return ''
56
- if (props.default === true) return t('common.all')
57
- if (typeof props.default === 'string') return props.default
58
- return props.default?.[props.labelField] ?? t('common.all')
59
- })
60
- const checked = ref([])
61
-
62
- watch(
63
- () => props.modelValue,
64
- v => (checked.value = v),
65
- { immediate: true },
66
- )
67
-
68
- const emitValue = (v) => {
69
- emit('update:modelValue', v)
70
- emit('updateModelValue', v)
71
- }
72
- const onAll = () => {
73
- emitValue(
74
- checked.value?.length === props.options.length ? [] : props.options.map(it => it[props.valueField]),
75
- )
76
- }
77
- const indeterminate = computed(() => props.options.length > checked.value?.length && checked.value?.length > 0)
78
-
79
- const style = computed(() => {
80
- return {
81
- '--n-label-padding': props.labelPadding,
82
- }
83
- })
84
- return () => {
85
- const group = (
86
- <NCheckboxGroup {...attrs} value={checked.value} onUpdateValue={emitValue}>
87
- <NFlex
88
- size={props.gap ?? (props.vertical ? undefined : 'small')}
89
- vertical={props.vertical}
90
- style={!props.default && props.vertical ? { padding: '6px 0 0' } : {}}
91
- >
92
- {props.options?.map(op => (
93
- <NCheckbox
94
- value={op[props.valueField]}
95
- disabled={op[props.disabledField]}
96
- style={style.value}
97
- >
98
- {op[props.labelField]}
99
- </NCheckbox>
100
- ))}
101
- </NFlex>
102
- </NCheckboxGroup>
103
- )
104
-
105
- return props.default
106
- ? (
107
- <NFlex
108
- size={props.gap ?? (props.vertical ? undefined : 'small')}
109
- vertical={props.vertical}
110
- style={props.vertical ? { padding: '6px 0 0' } : {}}
111
- >
112
- <span>
113
- <NCheckbox
114
- indeterminate={indeterminate.value}
115
- checked={checked.value?.length > 0}
116
- onUpdateChecked={onAll}
117
- style={style.value}
118
- >
119
- {defaultLabel.value}
120
- </NCheckbox>
121
- </span>
122
- {group}
123
- </NFlex>
124
- )
125
- : (
126
- group
127
- )
128
- }
129
- },
130
- })
@@ -1,105 +0,0 @@
1
- import { NButton, NDropdown } from 'ithinkdt-ui'
2
- import { computed, defineComponent, ref } from 'vue'
3
- import { VOverflow, VResizeObserver } from 'vueuc'
4
-
5
- import { IMore } from './assets.jsx'
6
-
7
- export const DataActions = /* @__PURE__ */ defineComponent({
8
- name: 'DataActions',
9
- props: {
10
- options: {
11
- type: Array,
12
- default: () => [],
13
- },
14
- },
15
- setup(props) {
16
- const ofRef = ref()
17
- let isFirstResize = true
18
- const onResize = () => {
19
- if (isFirstResize) {
20
- isFirstResize = false
21
- } else {
22
- ofRef.value?.sync({
23
- showAllItemsBeforeCalculate: true,
24
- })
25
- }
26
- }
27
- const counter = ref()
28
- const getCounter = () => {
29
- return counter.value
30
- }
31
- const ellipsisFromIndexRef = ref(-1)
32
- const onUpdateCount = (count) => {
33
- ellipsisFromIndexRef.value = props.options.length - count
34
- }
35
- const onUpdateOverflow = (overflow) => {
36
- if (!overflow) {
37
- ellipsisFromIndexRef.value = -1
38
- }
39
- }
40
- const updateCounter = () => {}
41
- const moreOptions = computed(() => {
42
- if (ellipsisFromIndexRef.value === -1) return []
43
- return props.options.slice(ellipsisFromIndexRef.value).map((act) => {
44
- return {
45
- ...act,
46
- key: act.text,
47
- }
48
- })
49
- })
50
-
51
- const renderLabel = (act) => {
52
- const color = act.color === 'danger'
53
- ? 'error'
54
- : ['default', 'tertiary', 'primary', 'info', 'success', 'warning', 'error'].includes(act.color)
55
- ? act.color
56
- : 'primary'
57
- return (
58
- <NButton type={color} text>
59
- {act.text}
60
- </NButton>
61
- )
62
- }
63
-
64
- const onSelect = (key, act) => {
65
- act.onClick?.()
66
- }
67
-
68
- return () => {
69
- return (
70
- <VResizeObserver onResize={onResize}>
71
- <VOverflow
72
- ref={ofRef}
73
- getCounter={getCounter}
74
- onUpdateCount={onUpdateCount}
75
- onUpdateOverflow={onUpdateOverflow}
76
- updateCounter={updateCounter}
77
- style="margin-top: 2px"
78
- >
79
- { {
80
- default: () => props.options.map((act) => {
81
- const color = act.color === 'danger'
82
- ? 'error'
83
- : ['default', 'tertiary', 'primary', 'info', 'success', 'warning', 'error'].includes(act.color)
84
- ? act.color
85
- : 'primary'
86
- return (
87
- <NButton quaternary type={color} size="small" onClick={act.onClick}>
88
- {act.text}
89
- </NButton>
90
- )
91
- }),
92
- counter: () => (
93
- <span ref={counter} style="position: absolute">
94
- <NDropdown options={moreOptions.value} renderLabel={renderLabel} onSelect={onSelect}>
95
- <NButton quaternary size="small"><IMore style="font-size: 14px; color: #888" /></NButton>
96
- </NDropdown>
97
- </span>
98
- ),
99
- }}
100
- </VOverflow>
101
- </VResizeObserver>
102
- )
103
- }
104
- },
105
- })
@@ -1,187 +0,0 @@
1
- import { NButton, NCheckbox, NEllipsis, NFlex, NIcon, NPopover } from 'ithinkdt-ui'
2
- import { Sortable } from 'sortablejs/modular/sortable.core.esm.js'
3
- import { defineComponent, ref, toValue, watch, withDirectives } from 'vue'
4
-
5
- import { vTooltip } from '../directives/tooltip.jsx'
6
- import { useI18n } from '../use-i18n.js'
7
-
8
- import { ICustom, IDrag, ILeft, IRight } from './assets.jsx'
9
-
10
- const DataCustomItem = /* @__PURE__ */ defineComponent({
11
- name: 'DataCustomRow',
12
- props: {
13
- label: [String, Function],
14
- disabled: Boolean,
15
- hidden: Boolean,
16
- showFixed: Boolean,
17
- fixed: [Boolean, String],
18
- },
19
- emits: ['update-hidden', 'update-fixed'],
20
- setup(props, { emit }) {
21
- return () => {
22
- return (
23
- <NFlex align="center" wrap={false} size="small">
24
- <NButton type="primary" text class="icon-drag">
25
- <NIcon size="18">
26
- <IDrag />
27
- </NIcon>
28
- </NButton>
29
- <NCheckbox
30
- checked={!props.hidden}
31
- disabled={props.disabled}
32
- onUpdateChecked={v => emit('update-hidden', !v)}
33
- />
34
- <NEllipsis style="flex: 1 1 auto">{toValue(props.label)}</NEllipsis>
35
- {
36
- props.showFixed
37
- ? [
38
- <NButton
39
- text
40
- type={props.fixed === 'left' ? 'primary' : undefined}
41
- onClick={() => emit('update-fixed', props.fixed === 'left' ? false : 'left')}
42
- >
43
- <NIcon>
44
- <ILeft />
45
- </NIcon>
46
- </NButton>,
47
- <NButton
48
- text
49
- type={props.fixed === 'right' ? 'primary' : undefined}
50
- onClick={() => emit('update-fixed', props.fixed === 'right' ? false : 'right')}
51
- >
52
- <NIcon>
53
- <IRight />
54
- </NIcon>
55
- </NButton>,
56
- ]
57
- : undefined
58
- }
59
- </NFlex>
60
- )
61
- }
62
- },
63
- })
64
-
65
- export const DataCustom = /* @__PURE__ */ defineComponent({
66
- name: 'DataCustom',
67
- props: {
68
- data: {
69
- type: Array,
70
- required: true,
71
- },
72
- keyField: {
73
- type: String,
74
- default: 'key',
75
- },
76
- labelField: {
77
- type: String,
78
- default: 'label',
79
- },
80
- fixedField: {
81
- type: String,
82
- default: 'fixed',
83
- },
84
- hiddenField: {
85
- type: String,
86
- default: 'hidden',
87
- },
88
- showFixed: {
89
- type: Boolean,
90
- default: true,
91
- },
92
- disabledField: {
93
- type: String,
94
- default: 'disabled',
95
- },
96
- visiblityField: {
97
- type: String,
98
- default: 'visiblity',
99
- },
100
- tooltip: [String, Object],
101
- size: {
102
- type: Number,
103
- default: 20,
104
- },
105
- type: {
106
- type: String,
107
- },
108
- },
109
- emits: {
110
- custom: () => true,
111
- },
112
- setup(props, { emit }) {
113
- const { t } = useI18n()
114
-
115
- function emitCols(col, field, value) {
116
- emit('custom', {
117
- key: col[props.keyField],
118
- [field]: value,
119
- })
120
- }
121
-
122
- const ulRef = ref()
123
-
124
- watch(ulRef, (inst) => {
125
- if (!inst.$el) return
126
- Sortable.create(inst.$el, {
127
- animation: 150,
128
- ghostClass: 'ghost',
129
- handle: '.icon-drag',
130
- filter: '.disabled',
131
- onEnd(e) {
132
- const orders = props.data.map(item => item[props.keyField])
133
- const [curr] = orders.splice(e.oldIndex, 1)
134
- orders.splice(e.newIndex, 0, curr)
135
- emit('custom', orders)
136
- },
137
- })
138
- })
139
-
140
- return () => (
141
- <NPopover
142
- trigger="click"
143
- scrollable
144
- placement="left-start"
145
- displayDirective="show"
146
- style="max-height: 400px; width: 240px"
147
- >
148
- {{
149
- trigger: () =>
150
- withDirectives(
151
- <NButton text type={props.type}>
152
- <NIcon size={props.size}>
153
- <ICustom />
154
- </NIcon>
155
- </NButton>,
156
- [[vTooltip, props.tooltip ?? t('common.page.custom.tooltip')]],
157
- ),
158
- default: () => (
159
- <NFlex vertical>
160
- <NFlex justify="space-between">
161
- <div style="font-weight: bold">{props.tooltip ?? t('common.page.custom.tooltip') }</div>
162
- <NButton text type="primary" size="small" onClick={() => emit('custom', true)}>
163
- { t('common.page.custom.reset') }
164
- </NButton>
165
- </NFlex>
166
- <NFlex ref={ulRef} vertical>
167
- {props.data
168
- .filter(item => item[props.visiblityField] !== false)
169
- .map(item => (
170
- <DataCustomItem
171
- key={item[props.keyField]}
172
- label={item[props.labelField]}
173
- hidden={item[props.hiddenField]}
174
- fixed={item[props.fixedField]}
175
- showFixed={props.showFixed}
176
- onUpdateHidden={v => emitCols(item, 'hidden', v)}
177
- onUpdateFixed={v => emitCols(item, 'fixed', v)}
178
- />
179
- ))}
180
- </NFlex>
181
- </NFlex>
182
- ),
183
- }}
184
- </NPopover>
185
- )
186
- },
187
- })
@@ -1,119 +0,0 @@
1
- import { NButton, NFlex, formProps } from 'ithinkdt-ui'
2
- import { defineComponent, reactive, ref } from 'vue'
3
-
4
- import { pickProps } from '@ithinkdt/common/object'
5
-
6
- import { useI18n } from '../use-i18n.js'
7
-
8
- import { DataCustom } from './DataCustom.jsx'
9
- import { DataForm } from './DataForm.jsx'
10
- import { IDown, IUp } from './assets.jsx'
11
-
12
- export const DataFilter = /* @__PURE__ */ defineComponent({
13
- name: 'DataFilter',
14
- props: {
15
- grid: {
16
- type: Object,
17
- default: () => ({}),
18
- },
19
- ...pickProps(formProps, 'disabled', 'model'),
20
- labelWidth: { type: [String, Number], default: '5em' },
21
- labelPlacement: { type: String, default: 'left' },
22
- items: { type: Array, required: true },
23
- loading: { type: Boolean, required: false, default: false },
24
- filterOnReset: { type: Boolean, required: false, default: true },
25
- filterText: { type: String, default: undefined },
26
- resetText: { type: String, default: undefined },
27
- customizable: { type: Boolean, required: false, default: true },
28
- collapsible: { type: Boolean, required: false, default: true },
29
- defaultCollapsed: { type: Boolean, required: false, default: true },
30
- },
31
- emits: ['filter', 'reset', 'custom', 'collapse'],
32
- setup(props, { expose, emit }) {
33
- const { t } = useI18n()
34
-
35
- const onSubmit = (e) => {
36
- emit('filter', props.model, e)
37
- }
38
- const onReset = (e) => {
39
- emit('reset', e)
40
- if (props.filterOnReset) {
41
- emit('filter', props.model, e)
42
- }
43
- }
44
- const collapsed = ref(props.defaultCollapsed)
45
- const collapse = (collapsedValue) => {
46
- collapsed.value = collapsedValue
47
- }
48
-
49
- expose({
50
- collapse,
51
- })
52
-
53
- const action = reactive({
54
- span: 6,
55
- suffix: true,
56
- })
57
-
58
- return () => {
59
- const { filterOnReset, filterText, resetText, customizable, defaultCollapsed, collapsible, grid, ...formProps } = props
60
-
61
- return (
62
- <DataForm
63
- grid={
64
- {
65
- cols: '12 768:18 1280:24 1536:30',
66
- yGap: 20,
67
- xGap: 8,
68
- ...grid,
69
- collapsed: collapsed.value,
70
- }
71
- }
72
- {...formProps}
73
- showFeedback={false}
74
- showAction={action}
75
- onSubmit={onSubmit}
76
- onReset={onReset}
77
- >
78
- {{
79
- action: ({ cols, spans }) => {
80
- action.suffix = cols < (spans + action.span)
81
-
82
- return (
83
- <NFlex justify={action.suffix ? 'end' : 'start'} align="center">
84
- {action.suffix ? undefined : <span>&nbsp;&nbsp;&nbsp;&nbsp;</span>}
85
- <NButton attrType="submit" type="primary" disabled={props.disabled} loading={props.loading}>
86
- {filterText || t('common.page.filter.submitText') }
87
- </NButton>
88
- <NButton attrType="reset" disabled={props.disabled || props.loading}>
89
- {resetText || t('common.page.form.resetText') }
90
- </NButton>
91
- {
92
- customizable
93
- ? <DataCustom keyField="name" showFixed={false} data={formProps.items} onCustom={e => emit('custom', e)} size={18} type="primary" />
94
- : undefined
95
- }
96
- {
97
- collapsible && action.suffix
98
- ? (
99
- <NButton
100
- text
101
- type="primary"
102
- iconPlacement="right"
103
- renderIcon={collapsed.value ? IDown : IUp}
104
- onClick={() => collapse(!collapsed.value)}
105
- >
106
- {collapsed.value ? t('common.page.filter.expand') : t('common.page.filter.collapse') }
107
- </NButton>
108
- )
109
- : undefined
110
- }
111
- </NFlex>
112
- )
113
- },
114
- }}
115
- </DataForm>
116
- )
117
- }
118
- },
119
- })