@uzum-tech/ui 2.1.4 → 2.2.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 (85) hide show
  1. package/dist/index.js +1221 -527
  2. package/dist/index.mjs +1218 -528
  3. package/dist/index.prod.js +2 -2
  4. package/dist/index.prod.mjs +2 -2
  5. package/es/_internal/icon/src/UIcon.mjs +17 -9
  6. package/es/_internal/icons/SearchOutline.d.ts +2 -0
  7. package/es/_internal/icons/SearchOutline.mjs +18 -0
  8. package/es/_internal/icons/index.d.ts +1 -0
  9. package/es/_internal/icons/index.mjs +1 -0
  10. package/es/_utils/dom/copy-to-clipboard.d.ts +1 -0
  11. package/es/_utils/dom/copy-to-clipboard.mjs +8 -0
  12. package/es/_utils/dom/index.d.ts +1 -0
  13. package/es/_utils/dom/index.mjs +1 -0
  14. package/es/components.d.ts +1083 -4
  15. package/es/components.mjs +3 -0
  16. package/es/config-provider/src/internal-interface.d.ts +4 -0
  17. package/es/data-table/src/use-table-data.d.ts +1 -1
  18. package/es/icon-pack/index.d.ts +5 -0
  19. package/es/icon-pack/index.mjs +3 -0
  20. package/es/icon-pack/src/IconPack.d.ts +1047 -0
  21. package/es/icon-pack/src/IconPack.mjs +300 -0
  22. package/es/icon-pack/src/interface.d.ts +465 -0
  23. package/es/icon-pack/src/interface.mjs +75 -0
  24. package/es/icon-pack/src/styles/index.cssr.d.ts +2 -0
  25. package/es/icon-pack/src/styles/index.cssr.mjs +131 -0
  26. package/es/icon-pack/styles/dark.d.ts +123 -0
  27. package/es/icon-pack/styles/dark.mjs +20 -0
  28. package/es/icon-pack/styles/index.d.ts +3 -0
  29. package/es/icon-pack/styles/index.mjs +2 -0
  30. package/es/icon-pack/styles/light.d.ts +143 -0
  31. package/es/icon-pack/styles/light.mjs +64 -0
  32. package/es/icon-wrapper/src/IconWrapper.d.ts +1 -1
  33. package/es/input/src/Input.mjs +3 -1
  34. package/es/pagination/index.d.ts +3 -3
  35. package/es/pagination/index.mjs +2 -1
  36. package/es/pagination/src/Pagination.d.ts +78 -1379
  37. package/es/pagination/src/Pagination.mjs +36 -63
  38. package/es/pagination/src/interface.d.ts +1347 -1
  39. package/es/pagination/src/interface.mjs +70 -1
  40. package/es/themes/dark.mjs +2 -0
  41. package/es/themes/light.mjs +2 -0
  42. package/es/version.d.ts +1 -1
  43. package/es/version.mjs +1 -1
  44. package/lib/_internal/icon/src/UIcon.js +15 -8
  45. package/lib/_internal/icons/SearchOutline.d.ts +2 -0
  46. package/lib/_internal/icons/SearchOutline.js +10 -0
  47. package/lib/_internal/icons/index.d.ts +1 -0
  48. package/lib/_internal/icons/index.js +3 -1
  49. package/lib/_utils/dom/copy-to-clipboard.d.ts +1 -0
  50. package/lib/_utils/dom/copy-to-clipboard.js +11 -0
  51. package/lib/_utils/dom/index.d.ts +1 -0
  52. package/lib/_utils/dom/index.js +3 -1
  53. package/lib/components.d.ts +1083 -4
  54. package/lib/components.js +11 -5
  55. package/lib/config-provider/src/internal-interface.d.ts +4 -0
  56. package/lib/data-table/src/use-table-data.d.ts +1 -1
  57. package/lib/icon-pack/index.d.ts +5 -0
  58. package/lib/icon-pack/index.js +13 -0
  59. package/lib/icon-pack/src/IconPack.d.ts +1047 -0
  60. package/lib/icon-pack/src/IconPack.js +240 -0
  61. package/lib/icon-pack/src/interface.d.ts +465 -0
  62. package/lib/icon-pack/src/interface.js +49 -0
  63. package/lib/icon-pack/src/styles/index.cssr.d.ts +2 -0
  64. package/lib/icon-pack/src/styles/index.cssr.js +136 -0
  65. package/lib/icon-pack/styles/dark.d.ts +123 -0
  66. package/lib/icon-pack/styles/dark.js +22 -0
  67. package/lib/icon-pack/styles/index.d.ts +3 -0
  68. package/lib/icon-pack/styles/index.js +10 -0
  69. package/lib/icon-pack/styles/light.d.ts +143 -0
  70. package/lib/icon-pack/styles/light.js +46 -0
  71. package/lib/icon-wrapper/src/IconWrapper.d.ts +1 -1
  72. package/lib/input/src/Input.js +3 -1
  73. package/lib/pagination/index.d.ts +3 -3
  74. package/lib/pagination/index.js +2 -1
  75. package/lib/pagination/src/Pagination.d.ts +78 -1379
  76. package/lib/pagination/src/Pagination.js +33 -40
  77. package/lib/pagination/src/interface.d.ts +1347 -1
  78. package/lib/pagination/src/interface.js +37 -0
  79. package/lib/themes/dark.js +110 -108
  80. package/lib/themes/light.js +110 -108
  81. package/lib/version.d.ts +1 -1
  82. package/lib/version.js +1 -1
  83. package/package.json +3 -3
  84. package/volar.d.ts +1 -0
  85. package/web-types.json +272 -1
@@ -0,0 +1,300 @@
1
+ import { computed, defineComponent, h, provide, ref, watch } from 'vue';
2
+ import { SearchOutlineIcon } from "../../_internal/icons/index.mjs";
3
+ import { useConfig, useFormItem, useTheme, useThemeClass } from "../../_mixins/index.mjs";
4
+ import { copyToClipboard, formatLength, resolveSlot } from "../../_utils/index.mjs";
5
+ import { debounce } from "../../_utils/debounce/index.mjs";
6
+ import { UPerformantEllipsis } from "../../ellipsis/index.mjs";
7
+ import { UEmpty } from "../../empty/index.mjs";
8
+ import { UInput } from "../../input/index.mjs";
9
+ import { UScrollbar } from "../../scrollbar/index.mjs";
10
+ import { iconPackLight } from "../styles/index.mjs";
11
+ import { iconPackInjectionKey, iconPackProps } from "./interface.mjs";
12
+ import style from "./styles/index.cssr.mjs";
13
+ export default defineComponent({
14
+ name: 'IconPack',
15
+ props: iconPackProps,
16
+ emits: ['update:value', 'update:searchValue', 'select', 'copy', 'search'],
17
+ setup(props, {
18
+ emit
19
+ }) {
20
+ const {
21
+ mergedClsPrefixRef,
22
+ mergedIconPacksRef
23
+ } = useConfig(props);
24
+ const themeRef = useTheme('IconPack', '-icon-pack', style, iconPackLight, props, mergedClsPrefixRef);
25
+ const formItem = useFormItem(props);
26
+ const {
27
+ mergedDisabledRef
28
+ } = formItem;
29
+ provide(iconPackInjectionKey, {
30
+ mergedClsPrefixRef
31
+ });
32
+ const uncontrolledValueRef = ref(props.defaultValue);
33
+ const mergedValueRef = computed(() => props.value !== undefined ? props.value : uncontrolledValueRef.value);
34
+ const uncontrolledSearchRef = ref(props.defaultSearchValue);
35
+ const mergedSearchRef = computed(() => props.searchValue !== undefined ? props.searchValue : uncontrolledSearchRef.value);
36
+ const mergedPackRef = computed(() => {
37
+ const {
38
+ pack
39
+ } = props;
40
+ if (pack && typeof pack === 'object') return pack;
41
+ const config = mergedIconPacksRef === null || mergedIconPacksRef === void 0 ? void 0 : mergedIconPacksRef.value;
42
+ if (!config) return undefined;
43
+ const name = typeof pack === 'string' ? pack : config.defaultPackName;
44
+ return config.packs.find(p => p.name === name);
45
+ });
46
+ function renderIconVNode(name) {
47
+ const pack = mergedPackRef.value;
48
+ if (!pack) return null;
49
+ if (props.async === true && typeof pack.renderAsyncIcon === 'function') return pack.renderAsyncIcon(name);
50
+ if (typeof pack.renderIcon === 'function') return pack.renderIcon(name);
51
+ if (typeof pack.renderAsyncIcon === 'function') return pack.renderAsyncIcon(name);
52
+ return null;
53
+ }
54
+ const allIconsRef = computed(() => {
55
+ const pack = mergedPackRef.value;
56
+ if (!pack) return [];
57
+ const format = props.formatIconLabel;
58
+ return pack.iconNames.map(name => {
59
+ const slashIndex = name.indexOf('/');
60
+ const group = slashIndex === -1 ? '' : name.slice(0, slashIndex);
61
+ const defaultLabel = slashIndex === -1 ? name : name.slice(slashIndex + 1);
62
+ return {
63
+ name,
64
+ group,
65
+ label: format ? format(name, group) : defaultLabel,
66
+ render: () => renderIconVNode(name)
67
+ };
68
+ });
69
+ });
70
+ const searchIndexRef = computed(() => allIconsRef.value.map(icon => `${icon.name}\n${icon.label}`.toLowerCase()));
71
+ const debouncedQueryRef = ref(mergedSearchRef.value.trim().toLowerCase());
72
+ const applyQuery = value => {
73
+ debouncedQueryRef.value = value.trim().toLowerCase();
74
+ };
75
+ const applyQueryDebounced = debounce(applyQuery, props.searchDebounce);
76
+ watch(mergedSearchRef, value => {
77
+ if (props.searchDebounce <= 0) applyQuery(value);else applyQueryDebounced(value);
78
+ });
79
+ const filteredIconsRef = computed(() => {
80
+ const query = debouncedQueryRef.value;
81
+ const icons = allIconsRef.value;
82
+ if (!query) return icons;
83
+ const searchIndex = searchIndexRef.value;
84
+ const result = [];
85
+ for (let index = 0; index < icons.length; index++) {
86
+ if (searchIndex[index].includes(query)) result.push(icons[index]);
87
+ }
88
+ return result;
89
+ });
90
+ const groupsRef = computed(() => {
91
+ const icons = filteredIconsRef.value;
92
+ if (!props.grouped) return [{
93
+ key: '',
94
+ label: '',
95
+ icons
96
+ }];
97
+ const map = new Map();
98
+ for (const icon of icons) {
99
+ const existing = map.get(icon.group);
100
+ if (existing) existing.push(icon);else map.set(icon.group, [icon]);
101
+ }
102
+ const format = props.formatGroupLabel;
103
+ return Array.from(map, ([key, groupIcons]) => ({
104
+ key,
105
+ label: format ? format(key) : key,
106
+ icons: groupIcons
107
+ }));
108
+ });
109
+ const isEmptyRef = computed(() => filteredIconsRef.value.length === 0);
110
+ function handleSearch(value) {
111
+ if (props.searchValue === undefined) uncontrolledSearchRef.value = value;
112
+ emit('update:searchValue', value);
113
+ emit('search', value);
114
+ }
115
+ function handleSelect(icon) {
116
+ if (mergedDisabledRef.value) return;
117
+ if (props.value === undefined) uncontrolledValueRef.value = icon.name;
118
+ emit('update:value', icon.name);
119
+ emit('select', icon.name, icon);
120
+ formItem.triggerFormInput();
121
+ formItem.triggerFormChange();
122
+ if (props.copyable) {
123
+ const text = props.formatCopy ? props.formatCopy(icon.name, icon) : icon.name;
124
+ void copyToClipboard(text).catch(() => {});
125
+ emit('copy', text, icon);
126
+ }
127
+ }
128
+ const cssVarsRef = computed(() => {
129
+ const {
130
+ common: {
131
+ cubicBezierEaseInOut
132
+ },
133
+ self: {
134
+ containerColor,
135
+ borderRadius,
136
+ titleTextColor,
137
+ descriptionTextColor,
138
+ groupTitleTextColor,
139
+ groupCounterTextColor,
140
+ cardColor,
141
+ cardColorHover,
142
+ cardColorPressed,
143
+ cardColorSelected,
144
+ cardBorderRadius,
145
+ cardIconColor,
146
+ cardIconColorSelected,
147
+ cardLabelTextColor,
148
+ cardLabelTextColorSelected,
149
+ dividerColor
150
+ }
151
+ } = themeRef.value;
152
+ const {
153
+ columns
154
+ } = props;
155
+ const gridTemplateColumns = columns === undefined || columns === null || columns === 'auto' ? `repeat(auto-fill, minmax(${formatLength(props.minColumnWidth)}, 1fr))` : `repeat(${columns}, minmax(0, 1fr))`;
156
+ return {
157
+ '--u-bezier': cubicBezierEaseInOut,
158
+ '--u-icon-pack-container-color': containerColor,
159
+ '--u-icon-pack-border-radius': borderRadius,
160
+ '--u-icon-pack-title-text-color': titleTextColor,
161
+ '--u-icon-pack-description-text-color': descriptionTextColor,
162
+ '--u-icon-pack-group-title-text-color': groupTitleTextColor,
163
+ '--u-icon-pack-group-counter-text-color': groupCounterTextColor,
164
+ '--u-icon-pack-card-color': cardColor,
165
+ '--u-icon-pack-card-color-hover': cardColorHover,
166
+ '--u-icon-pack-card-color-pressed': cardColorPressed,
167
+ '--u-icon-pack-card-color-selected': cardColorSelected,
168
+ '--u-icon-pack-card-border-radius': cardBorderRadius,
169
+ '--u-icon-pack-card-icon-color': cardIconColor,
170
+ '--u-icon-pack-card-icon-color-selected': cardIconColorSelected,
171
+ '--u-icon-pack-card-label-text-color': cardLabelTextColor,
172
+ '--u-icon-pack-card-label-text-color-selected': cardLabelTextColorSelected,
173
+ '--u-icon-pack-divider-color': dividerColor,
174
+ '--u-icon-pack-grid-template-columns': gridTemplateColumns,
175
+ '--u-icon-pack-icon-size': formatLength(props.iconSize),
176
+ '--u-icon-pack-content-padding': formatLength(props.contentPadding)
177
+ };
178
+ });
179
+ const themeClassHandle = useThemeClass('icon-pack', computed(() => ''), cssVarsRef, props);
180
+ return {
181
+ mergedClsPrefix: mergedClsPrefixRef,
182
+ mergedTheme: themeRef,
183
+ cssVars: cssVarsRef,
184
+ themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass,
185
+ onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender,
186
+ mergedValue: mergedValueRef,
187
+ mergedSearch: mergedSearchRef,
188
+ mergedDisabled: mergedDisabledRef,
189
+ groups: groupsRef,
190
+ isEmpty: isEmptyRef,
191
+ handleSearch,
192
+ handleSelect
193
+ };
194
+ },
195
+ render() {
196
+ var _a;
197
+ const {
198
+ mergedClsPrefix: cls,
199
+ $slots,
200
+ title,
201
+ description,
202
+ searchable,
203
+ grouped,
204
+ showGroupCounter,
205
+ searchPlaceholder,
206
+ searchInputProps,
207
+ scrollbarProps,
208
+ emptyText,
209
+ emptyProps,
210
+ height,
211
+ maxBodyHeight,
212
+ mergedDisabled
213
+ } = this;
214
+ (_a = this.onRender) === null || _a === void 0 ? void 0 : _a.call(this);
215
+ const showHeader = !!(title || description) || !!$slots.header || !!$slots.title || !!$slots.description;
216
+ const hasFixedHeight = height !== undefined && height !== null;
217
+ const bodyStyle = hasFixedHeight ? {
218
+ flex: '1 1 auto',
219
+ minHeight: 0
220
+ } : {
221
+ maxHeight: formatLength(maxBodyHeight)
222
+ };
223
+ const renderCard = icon => {
224
+ const selected = this.mergedValue === icon.name;
225
+ return h("div", {
226
+ key: icon.name,
227
+ class: [`${cls}-icon-pack-card`, selected && `${cls}-icon-pack-card--selected`],
228
+ role: "button",
229
+ tabindex: mergedDisabled ? -1 : 0,
230
+ "aria-pressed": selected,
231
+ "aria-disabled": mergedDisabled,
232
+ onClick: () => this.handleSelect(icon),
233
+ onKeydown: e => {
234
+ if (e.key === 'Enter' || e.key === ' ') {
235
+ e.preventDefault();
236
+ this.handleSelect(icon);
237
+ }
238
+ }
239
+ }, h("div", {
240
+ class: `${cls}-icon-pack-card__icon`
241
+ }, icon.render()), h(UPerformantEllipsis, {
242
+ class: `${cls}-icon-pack-card__label`,
243
+ lineClamp: 1
244
+ }, {
245
+ default: () => icon.label
246
+ }));
247
+ };
248
+ return h("div", {
249
+ class: [`${cls}-icon-pack`, this.themeClass, mergedDisabled && `${cls}-icon-pack--disabled`],
250
+ style: Object.assign(Object.assign({}, this.cssVars), hasFixedHeight ? {
251
+ height: formatLength(height)
252
+ } : {})
253
+ }, showHeader && h("div", {
254
+ class: `${cls}-icon-pack__header`
255
+ }, h("div", {
256
+ class: `${cls}-icon-pack__header-main`
257
+ }, resolveSlot($slots.header, () => [(title || $slots.title) && h("div", {
258
+ class: `${cls}-icon-pack__title`
259
+ }, $slots.title ? $slots.title() : title), (description || $slots.description) && h("div", {
260
+ class: `${cls}-icon-pack__description`
261
+ }, $slots.description ? $slots.description() : description)]))), searchable && h("div", {
262
+ class: `${cls}-icon-pack__search`
263
+ }, h(UInput, Object.assign({
264
+ value: this.mergedSearch,
265
+ clearable: true,
266
+ disabled: mergedDisabled,
267
+ placeholder: searchPlaceholder,
268
+ onUpdateValue: this.handleSearch
269
+ }, searchInputProps), {
270
+ prefix: () => h(SearchOutlineIcon)
271
+ })), h(UScrollbar, Object.assign({
272
+ class: `${cls}-icon-pack__body`,
273
+ style: bodyStyle
274
+ }, scrollbarProps), {
275
+ default: () => this.isEmpty ? h("div", {
276
+ class: `${cls}-icon-pack__empty`
277
+ }, resolveSlot($slots.empty, () => [h(UEmpty, Object.assign({}, emptyProps, {
278
+ size: "large",
279
+ description: emptyText,
280
+ theme: this.mergedTheme.peers.Empty,
281
+ themeOverrides: this.mergedTheme.peerOverrides.Empty
282
+ }))])) : h("div", {
283
+ class: `${cls}-icon-pack__groups`
284
+ }, this.groups.map(group => h("div", {
285
+ key: group.key,
286
+ class: `${cls}-icon-pack__group`
287
+ }, grouped && group.key !== '' && h("div", {
288
+ class: `${cls}-icon-pack__group-header`
289
+ }, h("div", {
290
+ class: `${cls}-icon-pack__group-title`
291
+ }, group.label), showGroupCounter && h("span", {
292
+ class: `${cls}-icon-pack__group-counter`
293
+ }, "(", group.icons.length, ")")), h("div", {
294
+ class: `${cls}-icon-pack__grid`
295
+ }, group.icons.map(renderCard)))))
296
+ }), $slots.footer && h("div", {
297
+ class: `${cls}-icon-pack__footer`
298
+ }, $slots.footer()));
299
+ }
300
+ });