@uzum-tech/ui 2.4.7 → 2.4.9

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 (52) hide show
  1. package/dist/index.js +225 -75
  2. package/dist/index.mjs +225 -75
  3. package/dist/index.prod.js +2 -2
  4. package/dist/index.prod.mjs +3 -3
  5. package/es/components.d.ts +82 -10
  6. package/es/dynamic-tags/index.d.ts +3 -3
  7. package/es/dynamic-tags/index.mjs +2 -1
  8. package/es/dynamic-tags/src/DynamicTags.d.ts +74 -1177
  9. package/es/dynamic-tags/src/DynamicTags.mjs +150 -107
  10. package/es/dynamic-tags/src/interface.d.ts +1146 -6
  11. package/es/dynamic-tags/src/interface.mjs +34 -1
  12. package/es/dynamic-tags/src/styles/index.cssr.mjs +35 -3
  13. package/es/dynamic-tags/styles/dark.mjs +4 -2
  14. package/es/dynamic-tags/styles/light.d.ts +2 -0
  15. package/es/dynamic-tags/styles/light.mjs +4 -2
  16. package/es/form/src/Form.d.ts +4 -0
  17. package/es/form/src/Form.mjs +1 -0
  18. package/es/form/src/FormItem.d.ts +15 -1
  19. package/es/form/src/FormItem.mjs +8 -1
  20. package/es/form/src/FormItemCol.d.ts +14 -1
  21. package/es/form/src/FormItemGridItem.d.ts +14 -1
  22. package/es/form/src/FormItemRow.d.ts +13 -0
  23. package/es/form/src/styles/form-item.cssr.mjs +2 -1
  24. package/es/form/src/utils.d.ts +1 -0
  25. package/es/form/src/utils.mjs +6 -0
  26. package/es/version.d.ts +1 -1
  27. package/es/version.mjs +1 -1
  28. package/lib/components.d.ts +82 -10
  29. package/lib/dynamic-tags/index.d.ts +3 -3
  30. package/lib/dynamic-tags/index.js +3 -2
  31. package/lib/dynamic-tags/src/DynamicTags.d.ts +74 -1177
  32. package/lib/dynamic-tags/src/DynamicTags.js +142 -77
  33. package/lib/dynamic-tags/src/interface.d.ts +1146 -6
  34. package/lib/dynamic-tags/src/interface.js +24 -0
  35. package/lib/dynamic-tags/src/styles/index.cssr.js +34 -2
  36. package/lib/dynamic-tags/styles/dark.js +4 -2
  37. package/lib/dynamic-tags/styles/light.d.ts +2 -0
  38. package/lib/dynamic-tags/styles/light.js +4 -2
  39. package/lib/form/src/Form.d.ts +4 -0
  40. package/lib/form/src/Form.js +1 -1
  41. package/lib/form/src/FormItem.d.ts +15 -1
  42. package/lib/form/src/FormItem.js +6 -2
  43. package/lib/form/src/FormItemCol.d.ts +14 -1
  44. package/lib/form/src/FormItemGridItem.d.ts +14 -1
  45. package/lib/form/src/FormItemRow.d.ts +13 -0
  46. package/lib/form/src/styles/form-item.cssr.js +2 -1
  47. package/lib/form/src/utils.d.ts +1 -0
  48. package/lib/form/src/utils.js +7 -0
  49. package/lib/version.d.ts +1 -1
  50. package/lib/version.js +1 -1
  51. package/package.json +1 -1
  52. package/web-types.json +31 -1
@@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.dynamicTagsProps = void 0;
7
6
  const vooks_1 = require("vooks");
8
7
  const vue_1 = require("vue");
9
8
  const _internal_1 = require("../../_internal");
@@ -14,27 +13,12 @@ const button_1 = require("../../button");
14
13
  const input_1 = require("../../input");
15
14
  const space_1 = require("../../space");
16
15
  const tag_1 = require("../../tag");
17
- const common_props_1 = __importDefault(require("../../tag/src/common-props"));
18
16
  const styles_1 = require("../styles");
17
+ const interface_1 = require("./interface");
19
18
  const index_cssr_1 = __importDefault(require("./styles/index.cssr"));
20
- exports.dynamicTagsProps = Object.assign(Object.assign(Object.assign({}, _mixins_1.useTheme.props), common_props_1.default), { size: {
21
- type: String,
22
- default: 'medium'
23
- }, closable: {
24
- type: Boolean,
25
- default: true
26
- }, defaultValue: {
27
- type: Array,
28
- default: () => []
29
- }, value: Array, inputStyle: [String, Object], inputProps: Object, max: Number, tagStyle: [String, Object], renderTag: Function, onCreate: {
30
- type: Function,
31
- default: (label) => label
32
- }, 'onUpdate:value': [Function, Array], onUpdateValue: [Function, Array],
33
- // deprecated
34
- onChange: [Function, Array] });
35
19
  exports.default = (0, vue_1.defineComponent)({
36
20
  name: 'DynamicTags',
37
- props: exports.dynamicTagsProps,
21
+ props: interface_1.dynamicTagsProps,
38
22
  slots: Object,
39
23
  setup(props) {
40
24
  if (process.env.NODE_ENV !== 'production') {
@@ -44,17 +28,18 @@ exports.default = (0, vue_1.defineComponent)({
44
28
  }
45
29
  });
46
30
  }
47
- const { mergedClsPrefixRef, inlineThemeDisabled } = (0, _mixins_1.useConfig)(props);
48
31
  const { localeRef } = (0, _mixins_1.useLocale)('DynamicTags');
32
+ const { mergedClsPrefixRef, inlineThemeDisabled } = (0, _mixins_1.useConfig)(props);
49
33
  const formItem = (0, _mixins_1.useFormItem)(props);
50
- const { mergedDisabledRef } = formItem;
34
+ const themeRef = (0, _mixins_1.useTheme)('DynamicTags', '-dynamic-tags', index_cssr_1.default, styles_1.dynamicTagsLight, props, mergedClsPrefixRef);
35
+ const inputInstRef = (0, vue_1.ref)(null);
51
36
  const inputValueRef = (0, vue_1.ref)('');
52
37
  const showInputRef = (0, vue_1.ref)(false);
53
38
  const inputForceFocusedRef = (0, vue_1.ref)(true);
54
- const inputInstRef = (0, vue_1.ref)(null);
55
- const themeRef = (0, _mixins_1.useTheme)('DynamicTags', '-dynamic-tags', index_cssr_1.default, styles_1.dynamicTagsLight, props, mergedClsPrefixRef);
56
39
  const uncontrolledValueRef = (0, vue_1.ref)(props.defaultValue);
57
40
  const controlledValueRef = (0, vue_1.toRef)(props, 'value');
41
+ const dragIndexRef = (0, vue_1.ref)(null);
42
+ const dragOverIndexRef = (0, vue_1.ref)(null);
58
43
  const mergedValueRef = (0, vooks_1.useMergedState)(controlledValueRef, uncontrolledValueRef);
59
44
  const localizedAddRef = (0, vue_1.computed)(() => {
60
45
  return localeRef.value.add;
@@ -62,35 +47,45 @@ exports.default = (0, vue_1.defineComponent)({
62
47
  const inputSizeRef = (0, vue_1.computed)(() => {
63
48
  return (0, _utils_1.smallerSize)(props.size);
64
49
  });
50
+ const buttonSizeRef = (0, vue_1.computed)(() => {
51
+ return (0, _utils_1.smallerSize)(props.size);
52
+ });
65
53
  const triggerDisabledRef = (0, vue_1.computed)(() => {
66
- return (mergedDisabledRef.value
54
+ return (formItem.mergedDisabledRef.value
67
55
  || (!!props.max && mergedValueRef.value.length >= props.max));
68
56
  });
69
- function doChange(value) {
70
- const { onChange, 'onUpdate:value': _onUpdateValue, onUpdateValue } = props;
71
- const { triggerFormInput, triggerFormChange } = formItem;
72
- if (onChange)
73
- (0, _utils_1.call)(onChange, value);
74
- if (onUpdateValue)
75
- (0, _utils_1.call)(onUpdateValue, value);
76
- if (_onUpdateValue)
77
- (0, _utils_1.call)(_onUpdateValue, value);
57
+ const cssVarsRef = (0, vue_1.computed)(() => {
58
+ const { self: { inputWidth, draggingOpacity, dropIndicatorColor } } = themeRef.value;
59
+ return {
60
+ '--u-input-width': inputWidth,
61
+ '--u-dragging-opacity': draggingOpacity,
62
+ '--u-drop-indicator-color': dropIndicatorColor
63
+ };
64
+ });
65
+ const tagSizeRef = (0, vue_1.computed)(() => {
66
+ const { size } = props;
67
+ return size === 'huge' ? 'medium' : 'small';
68
+ });
69
+ const themeClassHandle = inlineThemeDisabled
70
+ ? (0, _mixins_1.useThemeClass)('dynamic-tags', undefined, cssVarsRef, props)
71
+ : undefined;
72
+ const doChange = (value) => {
73
+ if (props.onChange)
74
+ (0, _utils_1.call)(props.onChange, value);
75
+ if (props.onUpdateValue)
76
+ (0, _utils_1.call)(props.onUpdateValue, value);
77
+ if (props['onUpdate:value'])
78
+ (0, _utils_1.call)(props['onUpdate:value'], value);
78
79
  uncontrolledValueRef.value = value;
79
- triggerFormInput();
80
- triggerFormChange();
81
- }
82
- function handleCloseClick(index) {
80
+ formItem.triggerFormInput();
81
+ formItem.triggerFormChange();
82
+ };
83
+ const handleCloseClick = (index) => {
83
84
  const tags = mergedValueRef.value.slice(0);
84
85
  tags.splice(index, 1);
85
86
  doChange(tags);
86
- }
87
- function handleInputKeyUp(e) {
88
- switch (e.key) {
89
- case 'Enter':
90
- handleInputConfirm();
91
- }
92
- }
93
- function handleInputConfirm(externalValue) {
87
+ };
88
+ const handleInputConfirm = (externalValue) => {
94
89
  const nextValue = externalValue !== null && externalValue !== void 0 ? externalValue : inputValueRef.value;
95
90
  if (nextValue) {
96
91
  const tags = mergedValueRef.value.slice(0);
@@ -100,75 +95,145 @@ exports.default = (0, vue_1.defineComponent)({
100
95
  showInputRef.value = false;
101
96
  inputForceFocusedRef.value = true;
102
97
  inputValueRef.value = '';
103
- }
104
- function handleInputBlur() {
98
+ };
99
+ const handleInputKeyUp = (event) => {
100
+ if (event.key === 'Enter')
101
+ handleInputConfirm();
102
+ };
103
+ const handleInputBlur = () => {
105
104
  handleInputConfirm();
106
- }
107
- function handleAddClick() {
105
+ };
106
+ const handleAddClick = () => {
108
107
  showInputRef.value = true;
109
108
  void (0, vue_1.nextTick)(() => {
110
109
  var _a;
111
110
  (_a = inputInstRef.value) === null || _a === void 0 ? void 0 : _a.focus();
112
111
  inputForceFocusedRef.value = false;
113
112
  });
114
- }
115
- const cssVarsRef = (0, vue_1.computed)(() => {
116
- const { self: { inputWidth } } = themeRef.value;
113
+ };
114
+ const moveItem = (from, to) => {
115
+ if (from === to)
116
+ return;
117
+ const values = [...mergedValueRef.value];
118
+ const [item] = values.splice(from, 1);
119
+ values.splice(to, 0, item);
120
+ doChange(values);
121
+ };
122
+ const resetDrag = () => {
123
+ dragIndexRef.value = null;
124
+ dragOverIndexRef.value = null;
125
+ };
126
+ const handleDragStart = (event, index) => {
127
+ dragIndexRef.value = index;
128
+ if (event.dataTransfer) {
129
+ event.dataTransfer.effectAllowed = 'move';
130
+ event.dataTransfer.setData('text/plain', String(index));
131
+ }
132
+ };
133
+ const handleDragOver = (event, index) => {
134
+ if (dragIndexRef.value === null)
135
+ return;
136
+ event.preventDefault();
137
+ dragOverIndexRef.value = index;
138
+ };
139
+ const handleDragLeave = (event, index) => {
140
+ if (dragOverIndexRef.value !== index)
141
+ return;
142
+ const current = event.currentTarget;
143
+ const related = event.relatedTarget;
144
+ if (current && related && current.contains(related))
145
+ return;
146
+ dragOverIndexRef.value = null;
147
+ };
148
+ const handleDrop = (event, index) => {
149
+ if (dragIndexRef.value === null)
150
+ return;
151
+ event.preventDefault();
152
+ moveItem(dragIndexRef.value, index);
153
+ resetDrag();
154
+ };
155
+ const getDragProps = (index) => {
156
+ if (!props.draggable || formItem.mergedDisabledRef.value)
157
+ return {};
158
+ const prefix = `${mergedClsPrefixRef.value}-dynamic-tags__tag`;
159
+ const from = dragIndexRef.value;
160
+ const isOver = from !== null && dragOverIndexRef.value === index;
117
161
  return {
118
- '--u-input-width': inputWidth
162
+ class: [
163
+ prefix,
164
+ `${prefix}--draggable`,
165
+ {
166
+ [`${prefix}--dragging`]: from === index,
167
+ [`${prefix}--drop-before`]: isOver && from > index,
168
+ [`${prefix}--drop-after`]: isOver && from < index
169
+ }
170
+ ],
171
+ draggable: true,
172
+ onDragstart: event => handleDragStart(event, index),
173
+ onDragover: event => handleDragOver(event, index),
174
+ onDragleave: event => handleDragLeave(event, index),
175
+ onDrop: event => handleDrop(event, index),
176
+ onDragend: resetDrag
119
177
  };
120
- });
121
- const tagSizeRef = (0, vue_1.computed)(() => {
122
- const { size } = props;
123
- return size === 'huge' ? 'medium' : 'small';
124
- });
125
- const themeClassHandle = inlineThemeDisabled
126
- ? (0, _mixins_1.useThemeClass)('dynamic-tags', undefined, cssVarsRef, props)
127
- : undefined;
178
+ };
128
179
  return {
129
180
  mergedClsPrefix: mergedClsPrefixRef,
130
181
  inputInstRef,
131
182
  localizedAdd: localizedAddRef,
132
183
  inputSize: inputSizeRef,
133
184
  inputValue: inputValueRef,
185
+ buttonSize: buttonSizeRef,
134
186
  showInput: showInputRef,
135
187
  inputForceFocused: inputForceFocusedRef,
136
188
  mergedValue: mergedValueRef,
137
- mergedDisabled: mergedDisabledRef,
189
+ mergedDisabled: formItem.mergedDisabledRef,
138
190
  triggerDisabled: triggerDisabledRef,
191
+ mergedTheme: themeRef,
192
+ cssVars: inlineThemeDisabled ? undefined : cssVarsRef,
193
+ themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass,
194
+ tagSize: tagSizeRef,
139
195
  handleInputKeyUp,
140
196
  handleAddClick,
141
197
  handleInputBlur,
142
198
  handleCloseClick,
143
199
  handleInputConfirm,
144
- mergedTheme: themeRef,
145
- cssVars: inlineThemeDisabled ? undefined : cssVarsRef,
146
- themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass,
147
- onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender,
148
- tagSize: tagSizeRef
200
+ getDragProps,
201
+ onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender
149
202
  };
150
203
  },
151
204
  render() {
152
- const { mergedTheme, cssVars, mergedClsPrefix, onRender, renderTag } = this;
205
+ const { mergedTheme, cssVars, mergedClsPrefix, themeClass, onRender, renderTag } = this;
153
206
  onRender === null || onRender === void 0 ? void 0 : onRender();
154
- return ((0, vue_1.h)(space_1.USpace, { class: [`${mergedClsPrefix}-dynamic-tags`, this.themeClass], size: "small", style: cssVars, theme: mergedTheme.peers.Space, themeOverrides: mergedTheme.peerOverrides.Space, itemStyle: "display: flex;" }, {
207
+ return ((0, vue_1.h)(space_1.USpace, { class: [`${mergedClsPrefix}-dynamic-tags`, themeClass], size: "small", style: cssVars, theme: mergedTheme.peers.Space, themeOverrides: mergedTheme.peerOverrides.Space, itemStyle: "display: flex;" }, {
155
208
  default: () => {
156
- const { mergedTheme, tagStyle, type, round, color, closable, mergedDisabled, showInput, inputValue, inputStyle, inputSize, inputForceFocused, triggerDisabled, handleInputKeyUp, handleInputBlur, handleAddClick, handleCloseClick, handleInputConfirm, $slots } = this;
157
- return this.mergedValue
158
- .map((tag, index) => renderTag ? (renderTag(tag, index)) : ((0, vue_1.h)(tag_1.UTag, { key: index, theme: mergedTheme.peers.Tag, themeOverrides: mergedTheme.peerOverrides.Tag, style: tagStyle, type: type, round: round, size: this.tagSize, color: color, closable: closable, disabled: mergedDisabled, onClose: () => {
159
- handleCloseClick(index);
160
- } }, {
161
- default: () => (typeof tag === 'string' ? tag : tag.label)
162
- })))
209
+ const { mergedTheme, mergedValue, tagStyle, tagSize, type, round, color, closable, mergedDisabled, draggable, showInput, inputValue, inputStyle, inputProps, inputSize, buttonSize, inputForceFocused, triggerDisabled, $slots, handleInputKeyUp, handleInputBlur, handleAddClick, handleCloseClick, handleInputConfirm, getDragProps } = this;
210
+ return mergedValue
211
+ .map((tag, index) => {
212
+ if (renderTag) {
213
+ const customTag = renderTag(tag, index);
214
+ if (!draggable)
215
+ return customTag;
216
+ const dragProps = getDragProps(index);
217
+ return ((0, vue_1.h)("div", Object.assign({ key: index }, dragProps, { class: [
218
+ `${mergedClsPrefix}-dynamic-tags__tag-wrapper`,
219
+ dragProps.class
220
+ ] }), customTag));
221
+ }
222
+ return ((0, vue_1.h)(tag_1.UTag, Object.assign({ key: index }, getDragProps(index), { theme: mergedTheme.peers.Tag, themeOverrides: mergedTheme.peerOverrides.Tag, style: tagStyle, type: type, round: round, size: tagSize, color: color, closable: closable, disabled: mergedDisabled, onClose: () => {
223
+ handleCloseClick(index);
224
+ } }), {
225
+ default: () => (typeof tag === 'string' ? tag : tag.label)
226
+ }));
227
+ })
163
228
  .concat(showInput ? ($slots.input ? ($slots.input({
164
229
  submit: handleInputConfirm,
165
230
  deactivate: handleInputBlur
166
- })) : ((0, vue_1.h)(input_1.UInput, Object.assign({ placeholder: "", size: inputSize, style: inputStyle, autosize: true }, this.inputProps, { ref: "inputInstRef", value: inputValue, onUpdateValue: (v) => {
231
+ })) : ((0, vue_1.h)(input_1.UInput, Object.assign({ placeholder: "", size: inputSize, style: inputStyle, autosize: true }, inputProps, { ref: "inputInstRef", value: inputValue, onUpdateValue: (v) => {
167
232
  this.inputValue = v;
168
233
  }, theme: mergedTheme.peers.Input, themeOverrides: mergedTheme.peerOverrides.Input, onKeyup: handleInputKeyUp, onBlur: handleInputBlur, internalForceFocus: inputForceFocused })))) : $slots.trigger ? ($slots.trigger({
169
234
  activate: handleAddClick,
170
235
  disabled: triggerDisabled
171
- })) : ((0, vue_1.h)(button_1.UButton, { dashed: true, disabled: triggerDisabled, theme: mergedTheme.peers.Button, themeOverrides: mergedTheme.peerOverrides.Button, size: inputSize, onClick: handleAddClick }, {
236
+ })) : ((0, vue_1.h)(button_1.UButton, { dashed: true, disabled: triggerDisabled, theme: mergedTheme.peers.Button, themeOverrides: mergedTheme.peerOverrides.Button, size: buttonSize, onClick: handleAddClick }, {
172
237
  icon: () => ((0, vue_1.h)(_internal_1.UBaseIcon, { clsPrefix: mergedClsPrefix }, { default: () => (0, vue_1.h)(icons_1.AddIcon, null) }))
173
238
  })));
174
239
  }