@ithinkdt/ui 4.0.0-37 → 4.0.0-40

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 +1222 -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,501 +0,0 @@
1
- import { promiseTimeout, useElementHover, useElementSize, useEventListener, watchDebounced } from '@vueuse/core'
2
- import { NButton, NDropdown, NIcon, useThemeVars } from 'ithinkdt-ui'
3
- import { computed, defineComponent, reactive, ref, toRef, watch } from 'vue'
4
- import { useRouter } from 'vue-router'
5
-
6
- import { getOpaqueColor } from '@ithinkdt/common/color'
7
-
8
- import { useI18n } from '../use-i18n.js'
9
-
10
- import { getCtx } from './common.jsx'
11
-
12
- function useCtxMenu(tabs, current, changeFullTab) {
13
- const { t } = useI18n()
14
-
15
- const ctx = reactive({ visible: false, x: 0, y: 0 })
16
- const onCtx = async (e, tab) => {
17
- e.preventDefault()
18
- e.stopPropagation()
19
-
20
- if (ctx.visible && ctx.tab === tab) return
21
-
22
- ctx.tab = tab
23
- if (ctx.visible) {
24
- ctx.visible = false
25
- await promiseTimeout(130)
26
- }
27
- ctx.visible = true
28
- ctx.x = e.clientX
29
- ctx.y = e.clientY
30
- }
31
-
32
- const onClickoutside = async () => {
33
- requestIdleCallback(
34
- () => {
35
- ctx.visible = false
36
- },
37
- { timeout: 30 },
38
- )
39
- }
40
-
41
- const router = useRouter()
42
- const options = computed(() => [
43
- {
44
- key: 'reload',
45
- label: t('common.layout.tabs.reloadTab'),
46
- disabled: ctx.tab && ctx.tab.key !== current.value,
47
- icon: () => (
48
- <NIcon size={20}>
49
- <svg
50
- xmlns="http://www.w3.org/2000/svg"
51
- xmlns:xlink="http://www.w3.org/1999/xlink"
52
- role="img"
53
- width="1em"
54
- height="1em"
55
- viewBox="0 0 24 24"
56
- >
57
- <path
58
- fill="currentColor"
59
- d="M17.65 6.35A7.958 7.958 0 0 0 12 4a8 8 0 0 0-8 8a8 8 0 0 0 8 8c3.73 0 6.84-2.55 7.73-6h-2.08A5.99 5.99 0 0 1 12 18a6 6 0 0 1-6-6a6 6 0 0 1 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35Z"
60
- >
61
- </path>
62
- </svg>
63
- </NIcon>
64
- ),
65
- },
66
- {
67
- key: 'fullTab',
68
- label: t('common.layout.tabs.fullTab'),
69
- icon: () => (
70
- <NIcon size={16}>
71
- <svg
72
- xmlns="http://www.w3.org/2000/svg"
73
- width="1em"
74
- height="1em"
75
- viewBox="0 0 24 24"
76
- >
77
- <path
78
- fill="currentColor"
79
- fill-rule="evenodd"
80
- d="M18.29 2.89c-1.028-.138-2.383-.14-4.29-.14a.75.75 0 0 1 0-1.5h.056c1.838 0 3.294 0 4.433.153c1.172.158 2.121.49 2.87 1.238c.748.749 1.08 1.698 1.238 2.87c.153 1.14.153 2.595.153 4.433V10a.75.75 0 0 1-1.5 0c0-1.907-.002-3.261-.14-4.29c-.135-1.005-.389-1.585-.812-2.008s-1.003-.677-2.009-.812M2 13.25a.75.75 0 0 1 .75.75c0 1.907.002 3.262.14 4.29c.135 1.005.389 1.585.812 2.008s1.003.677 2.009.812c1.028.138 2.382.14 4.289.14a.75.75 0 0 1 0 1.5h-.056c-1.838 0-3.294 0-4.433-.153c-1.172-.158-2.121-.49-2.87-1.238c-.748-.749-1.08-1.698-1.238-2.87c-.153-1.14-.153-2.595-.153-4.433V14a.75.75 0 0 1 .75-.75"
81
- clip-rule="evenodd"
82
- />
83
- <path
84
- fill="currentColor"
85
- d="M9.944 1.25H10a.75.75 0 0 1 0 1.5c-1.907 0-3.261.002-4.29.14c-1.005.135-1.585.389-2.008.812S3.025 4.705 2.89 5.71c-.138 1.029-.14 2.383-.14 4.29a.75.75 0 0 1-1.5 0v-.056c0-1.838 0-3.294.153-4.433c.158-1.172.49-2.121 1.238-2.87c.749-.748 1.698-1.08 2.87-1.238c1.14-.153 2.595-.153 4.433-.153M22 13.25a.75.75 0 0 1 .75.75v.056c0 1.838 0 3.294-.153 4.433c-.158 1.172-.49 2.121-1.238 2.87c-.749.748-1.698 1.08-2.87 1.238c-1.14.153-2.595.153-4.433.153H14a.75.75 0 0 1 0-1.5c1.907 0 3.262-.002 4.29-.14c1.005-.135 1.585-.389 2.008-.812s.677-1.003.812-2.009c.138-1.027.14-2.382.14-4.289a.75.75 0 0 1 .75-.75"
86
- opacity=".5"
87
- />
88
- </svg>
89
- </NIcon>
90
- ),
91
- },
92
- {
93
- key: 'open',
94
- label: t('common.layout.tabs.openTabBlank'),
95
- disabled: ctx.tab?.key !== current.value,
96
- icon: () => (
97
- <NIcon size={20}>
98
- <svg
99
- xmlns="http://www.w3.org/2000/svg"
100
- xmlns:xlink="http://www.w3.org/1999/xlink"
101
- role="img"
102
- width="1em"
103
- height="1em"
104
- viewBox="0 0 15 15"
105
- >
106
- <path
107
- fill="currentColor"
108
- clip-rule="evenodd"
109
- fill-rule="evenodd"
110
- d="M12 13a1 1 0 0 0 1-1V3a1 1 0 0 0-1-1H3a1 1 0 0 0-1 1v3.5a.5.5 0 0 0 1 0V3h9v9H8.5a.5.5 0 0 0 0 1H12ZM9 6.5v3a.5.5 0 0 1-1 0V7.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 7H5.5a.5.5 0 0 1 0-1h3a.498.498 0 0 1 .5.497"
111
- />
112
- </svg>
113
- </NIcon>
114
- ),
115
- },
116
- {
117
- key: 'closeAll',
118
- label: t('common.layout.tabs.closeAllTabs'),
119
- icon: () => (
120
- <NIcon size={20}>
121
- <svg
122
- xmlns="http://www.w3.org/2000/svg"
123
- xmlns:xlink="http://www.w3.org/1999/xlink"
124
- role="img"
125
- width="1em"
126
- height="1em"
127
- viewBox="0 0 24 24"
128
- >
129
- <path
130
- fill="currentColor"
131
- d="M6.4 19L5 17.6l5.6-5.6L5 6.4L6.4 5l5.6 5.6L17.6 5L19 6.4L13.4 12l5.6 5.6l-1.4 1.4l-5.6-5.6L6.4 19Z"
132
- />
133
- </svg>
134
- </NIcon>
135
- ),
136
- },
137
- {
138
- key: 'closeLeft',
139
- label: t('common.layout.tabs.closeLeftTabs'),
140
- disabled: !ctx.tab,
141
- icon: () => (
142
- <NIcon size={20}>
143
- <svg
144
- xmlns="http://www.w3.org/2000/svg"
145
- xmlns:xlink="http://www.w3.org/1999/xlink"
146
- role="img"
147
- width="1em"
148
- height="1em"
149
- viewBox="0 0 24 24"
150
- >
151
- <path fill="currentColor" d="M11 16v-3h10v-2H11V8l-4 4l4 4m-8 4h2V4H3v16Z"></path>
152
- </svg>
153
- </NIcon>
154
- ),
155
- },
156
- {
157
- key: 'closeRight',
158
- label: t('common.layout.tabs.closeRightTabs'),
159
- disabled: !ctx.tab,
160
- icon: () => (
161
- <NIcon size={20}>
162
- <svg
163
- xmlns="http://www.w3.org/2000/svg"
164
- xmlns:xlink="http://www.w3.org/1999/xlink"
165
- role="img"
166
- width="1em"
167
- height="1em"
168
- viewBox="0 0 24 24"
169
- >
170
- <path fill="currentColor" d="M13 8v3H3v2h10v3l4-4l-4-4m6 12h2V4h-2v16Z"></path>
171
- </svg>
172
- </NIcon>
173
- ),
174
- },
175
- {
176
- key: 'closeOther',
177
- label: t('common.layout.tabs.closeOtherTabs'),
178
- disabled: !ctx.tab,
179
- icon: () => (
180
- <NIcon size={20}>
181
- {' '}
182
- <svg
183
- xmlns="http://www.w3.org/2000/svg"
184
- xmlns:xlink="http://www.w3.org/1999/xlink"
185
- role="img"
186
- width="1em"
187
- height="1em"
188
- viewBox="0 0 1024 1024"
189
- >
190
- <path
191
- fill="currentColor"
192
- d="M180 176h-60c-4.4 0-8 3.6-8 8v656c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V184c0-4.4-3.6-8-8-8zm724 0h-60c-4.4 0-8 3.6-8 8v656c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V184c0-4.4-3.6-8-8-8zM785.3 504.3L657.7 403.6a7.23 7.23 0 0 0-11.7 5.7V476H378v-62.8c0-6-7-9.4-11.7-5.7L238.7 508.3a7.14 7.14 0 0 0 0 11.3l127.5 100.8c4.7 3.7 11.7.4 11.7-5.7V548h268v62.8c0 6 7 9.4 11.7 5.7l127.5-100.8c3.8-2.9 3.8-8.5.2-11.4z"
193
- >
194
- </path>
195
- </svg>
196
- </NIcon>
197
- ),
198
- },
199
- ])
200
-
201
- const onSelect = async (key) => {
202
- ctx.visible = false
203
- const alltabs = [...tabs.value]
204
- if (key === 'closeAll') {
205
- await router.push('/')
206
- for (const tab of alltabs) {
207
- if (tab.key !== current.value) {
208
- tab.close(false)
209
- }
210
- }
211
- return
212
- }
213
- if (key === 'fullTab') {
214
- changeFullTab()
215
- return
216
- }
217
- if (!ctx.tab) {
218
- const tab = alltabs.find(tab => tab.key === current.value)
219
- switch (key) {
220
- case 'open': {
221
- window.open(tab.href, '_blank')
222
- break
223
- }
224
- case 'reload': {
225
- if (!tab.reloading) {
226
- tab.reloading = true
227
- await promiseTimeout(220)
228
- tab.reloading = false
229
- }
230
- break
231
- }
232
- }
233
- return
234
- }
235
-
236
- switch (key) {
237
- case 'open': {
238
- window.open(ctx.tab.href, '_blank')
239
- break
240
- }
241
- case 'reload': {
242
- if (!ctx.tab.reloading) {
243
- ctx.tab.reloading = true
244
- await promiseTimeout(220)
245
- ctx.tab.reloading = false
246
- }
247
- break
248
- }
249
- case 'close': {
250
- ctx.tab?.close()
251
- break
252
- }
253
- case 'closeOther': {
254
- if (current.value !== ctx.tab.key) {
255
- await router.push(ctx.tab.fullPath)
256
- }
257
- for (const tab of alltabs) {
258
- if (tab.key !== ctx.tab.key) {
259
- tab.close(false)
260
- }
261
- }
262
- break
263
- }
264
- case 'closeLeft': {
265
- if (current.value !== ctx.tab.key) {
266
- await router.push(ctx.tab.fullPath)
267
- }
268
- for (const tab of tabs.value.slice(0, alltabs.indexOf(ctx.tab))) {
269
- tab.close(false)
270
- }
271
- break
272
- }
273
- case 'closeRight': {
274
- if (current.value !== ctx.tab.key) {
275
- await router.push(ctx.tab.fullPath)
276
- }
277
- for (const tab of tabs.value.slice(alltabs.indexOf(ctx.tab) + 1)) {
278
- tab.close(false)
279
- }
280
- break
281
- }
282
- }
283
- }
284
-
285
- return {
286
- ctx,
287
- onCtx,
288
- onClickoutside,
289
- options,
290
- onSelect,
291
- }
292
- }
293
-
294
- function useContentScroll(el, content, current) {
295
- function scroll2Tab(index) {
296
- if (index === -1 || !content.value?.children.length) return
297
- const target = content.value.children[index]
298
- el.value.scrollTo({
299
- behavior: 'smooth',
300
- left: Math.max(
301
- 0,
302
- content.value.offsetLeft + target.offsetLeft - el.value.clientWidth / 2 + target.clientWidth / 2 + 10,
303
- ),
304
- })
305
- }
306
-
307
- watchDebounced(
308
- useElementHover(el),
309
- (hoverd) => {
310
- if (!hoverd) scroll2Tab(current.value)
311
- },
312
- { debounce: 333 },
313
- )
314
- watch(current, scroll2Tab, { flush: 'post' })
315
-
316
- useEventListener(
317
- el,
318
- 'wheel',
319
- (e) => {
320
- if (e.deltaMode !== WheelEvent.DOM_DELTA_PIXEL) {
321
- return
322
- }
323
- e.preventDefault()
324
- el.value.scrollBy({
325
- left: e.deltaY,
326
- })
327
- },
328
- { passive: false },
329
- )
330
- return { el, content }
331
- }
332
-
333
- const IBg = props => (
334
- <svg {...props}>
335
- <defs>
336
- <symbol id="geometry-left" viewBox="0 0 214 36"><path d="M17 0h197v36H0v-2c4.5 0 9-3.5 9-8V8c0-4.5 3.5-8 8-8z"></path></symbol>
337
- <symbol id="geometry-right" viewBox="0 0 214 36"><use xlink:href="#geometry-left"></use></symbol>
338
- <clipPath><rect width="100%" height="100%" x="0"></rect></clipPath>
339
- </defs>
340
- <svg width="50%" height="100%"><use xlink:href="#geometry-left" width="214" height="36" fill="currentColor"></use></svg>
341
- <g transform="scale(-1, 1)">
342
- <svg width="50%" height="100%" x="-100%" y="0"><use xlink:href="#geometry-right" width="214" height="36" fill="currentColor"></use></svg>
343
- </g>
344
- </svg>
345
- )
346
-
347
- const AppTab = /* @__PURE__ */ defineComponent({
348
- name: 'AppTab',
349
- props: {
350
- path: String,
351
- isCurrent: Boolean,
352
- isLast: Boolean,
353
- closable: Boolean,
354
- dark: Boolean,
355
- },
356
- emits: ['close'],
357
- setup(props, { emit, slots }) {
358
- const container = ref()
359
- const isHoverd = useElementHover(container)
360
-
361
- const wrapper = ref()
362
- const content = ref()
363
- const { width: contentWidth } = useElementSize(content)
364
- watch(contentWidth, async () => {
365
- await promiseTimeout(1)
366
- wrapper.value.style.width = content.value.scrollWidth + 'px'
367
- })
368
-
369
- const vars = useThemeVars()
370
-
371
- const contentStyle = computed(() => ({ fontSize: '14px', color: props.isCurrent ? vars.value.primaryColor : vars.value.textColor3, maxWidth: '355px', overflow: 'hidden' }))
372
- const bgStyle = computed(() => ({
373
- width: 'calc(100% + 27px)', height: '100%', position: 'absolute', top: '0', left: '-14px', zIndex: props.isCurrent ? -1 : -2,
374
- color: props.isCurrent
375
- ? getOpaqueColor(vars.value.primaryColor, props.dark ? 0.3 : 0.12, props.dark ? '#000' : '#fff')
376
- : isHoverd.value ? vars.value.borderColor : 'transparent',
377
- }))
378
-
379
- return () => (
380
- <div ref={container} style="position: relative; padding: 2px 10px 5px; cursor: pointer">
381
- <div ref={wrapper} style="transition: width 300ms; overflow: hidden">
382
- <div ref={content} style="display: flex; align-items: center; gap: 4px; width: fit-content">
383
- <span style={contentStyle.value}>{slots.default?.()}</span>
384
- {
385
- props.closable !== false && (props.isCurrent || isHoverd.value)
386
- ? (
387
- <span style="line-height: 0; display: inline-block; text-align: right; padding-top: 2px">
388
- <NButton
389
- text
390
- onClick={(evt) => {
391
- evt.stopPropagation()
392
- emit('close')
393
- }}
394
- >
395
- <NIcon size={18}>
396
- <svg
397
- xmlns="http://www.w3.org/2000/svg"
398
- width="1em"
399
- height="1em"
400
- viewBox="0 0 24 24"
401
- >
402
- <path
403
- fill="currentColor"
404
- d="m6.4 18.308l-.708-.708l5.6-5.6l-5.6-5.6l.708-.708l5.6 5.6l5.6-5.6l.708.708l-5.6 5.6l5.6 5.6l-.708.708l-5.6-5.6z"
405
- />
406
- </svg>
407
- </NIcon>
408
- </NButton>
409
- </span>
410
- )
411
- : undefined
412
- }
413
- </div>
414
- </div>
415
-
416
- <span style="height: 50%; width: 1px; background: #aaa; display: inline-block; position: absolute; top: 20%; right: -4px; z-index: -3" />
417
- <IBg style={bgStyle.value} />
418
- </div>
419
- )
420
- },
421
- })
422
-
423
- export const AppMultiTabs = /* @__PURE__ */ defineComponent({
424
- name: 'AppMultiTabs',
425
- props: {
426
- fullTab: Boolean,
427
- showBreadcrumb: Boolean,
428
- tabs: Array,
429
- current: Object,
430
- dark: Boolean,
431
- },
432
- emits: ['update:fullTab'],
433
- setup(props, { emit, slots }) {
434
- const appCtx = getCtx()
435
- appCtx.hasMultiTab = true
436
-
437
- const router = useRouter()
438
-
439
- const { ctx, onCtx, onClickoutside, options, onSelect } = useCtxMenu(
440
- toRef(props, 'tabs'),
441
- computed(() => props.current?.key),
442
- () => emit('update:fullTab', !props.fullTab),
443
- )
444
-
445
- const currentIndex = computed(() =>
446
- props.current ? props.tabs.findIndex(tab => tab.key === props.current?.key) : -1,
447
- )
448
-
449
- const el = ref()
450
- const content = ref()
451
- useContentScroll(el, content, currentIndex)
452
-
453
- return () => (
454
- <div style="width: 100%; height: 100%; overflow: hidden; display: flex; justify-content: space-between">
455
- <div
456
- ref={el}
457
- style="flex: 1 1 100%; height: 100%; display: flex; overflow: hidden; align-items: center; position: relative"
458
- >
459
- <div style="height: 100%; flex: 0 0 16px; z-index: 1; position: sticky; left: 0; backdrop-filter: opacity(0.9) blur(5px)" />
460
- <div ref={content} style="padding-inline: 12px; flex: 1 1 auto; display: flex; align-items: end; gap: 8px; height: 100%" onContextmenu={e => onCtx(e)}>
461
- {props.tabs.map((tab, i, arr) => {
462
- const isCurrent = props.current?.key === tab.key
463
- const name = tab.title ?? tab.path
464
- return (
465
- <AppTab
466
- key={tab.key}
467
- isCurrent={isCurrent}
468
- isLast={i === arr.length - 1}
469
- onClose={tab.close}
470
- closable={tab.closable}
471
- dark={props.dark}
472
- onClick={() => {
473
- if (!isCurrent) router.push(tab.fullPath)
474
- }}
475
- onContextmenu={e => onCtx(e, tab)}
476
- >
477
- {
478
- slots.name ? slots.name({ isCurrent, name, tab }) : name
479
- }
480
- </AppTab>
481
- )
482
- })}
483
- </div>
484
-
485
- <div style="height: 100%; flex: 0 0 16px; z-index: 1; position: sticky; right: 0; backdrop-filter: opacity(0.9) blur(5px)" />
486
- </div>
487
-
488
- <NDropdown
489
- placement="bottom-start"
490
- trigger="manual"
491
- show={ctx.visible}
492
- x={ctx.x}
493
- y={ctx.y}
494
- options={options.value}
495
- onClickoutside={onClickoutside}
496
- onSelect={onSelect}
497
- />
498
- </div>
499
- )
500
- },
501
- })