@varlet/ui 2.7.4-alpha.1675694992985 → 2.7.4

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.
@@ -217,7 +217,7 @@ import './time-picker/style/index.mjs'
217
217
  import './tooltip/style/index.mjs'
218
218
  import './uploader/style/index.mjs'
219
219
 
220
- const version = '2.7.4-alpha.1675694992985'
220
+ const version = '2.7.4'
221
221
 
222
222
  function install(app) {
223
223
  ActionSheet.install && app.use(ActionSheet)
package/es/index.mjs CHANGED
@@ -144,7 +144,7 @@ export * from './time-picker/index.mjs'
144
144
  export * from './tooltip/index.mjs'
145
145
  export * from './uploader/index.mjs'
146
146
 
147
- const version = '2.7.4-alpha.1675694992985'
147
+ const version = '2.7.4'
148
148
 
149
149
  function install(app) {
150
150
  ActionSheet.install && app.use(ActionSheet)
@@ -3,16 +3,31 @@ import { reactive } from 'vue';
3
3
  import { mountInstance } from '../utils/components.mjs';
4
4
  var timer;
5
5
  var isMount;
6
- var props = reactive({
6
+ var setOptions = {};
7
+ var internalProps = {
7
8
  value: 0,
8
9
  opacity: 0,
9
10
  error: false
10
- });
11
+ };
12
+ var props = reactive(internalProps);
11
13
 
12
14
  var mergeConfig = options => {
13
15
  Object.assign(props, options);
14
16
  };
15
17
 
18
+ var setDefaultOptions = options => {
19
+ Object.assign(props, options);
20
+ setOptions = options;
21
+ };
22
+
23
+ var resetDefaultOptions = () => {
24
+ Object.keys(setOptions).forEach(key => {
25
+ if (props[key] !== undefined) {
26
+ props[key] = undefined;
27
+ }
28
+ });
29
+ };
30
+
16
31
  var changeValue = () => {
17
32
  timer = window.setTimeout(() => {
18
33
  if (props.value >= 95) return;
@@ -60,7 +75,11 @@ var LoadingBar = {
60
75
  start,
61
76
  finish,
62
77
  error,
63
- mergeConfig
78
+
79
+ /** @deprecated Use setDefaultOptions to instead. */
80
+ mergeConfig,
81
+ setDefaultOptions,
82
+ resetDefaultOptions
64
83
  };
65
84
  export { props as loadingBarProps } from './props.mjs';
66
85
  export var _LoadingBarComponent = LoadingBar;
@@ -7,7 +7,7 @@ import VarSnackbar from './Snackbar.mjs';
7
7
  import context from '../context/index.mjs';
8
8
  import { reactive, TransitionGroup } from 'vue';
9
9
  import { call, mountInstance } from '../utils/components.mjs';
10
- import { isNumber, isPlainObject, isString, toNumber } from '@varlet/shared';
10
+ import { isPlainObject, isString, toNumber } from '@varlet/shared';
11
11
 
12
12
  function _isSlot(s) {
13
13
  return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !_isVNode(s);
@@ -18,8 +18,7 @@ var sid = 0;
18
18
  var isMount = false;
19
19
  var unmount;
20
20
  var isAllowMultiple = false;
21
- var uniqSnackbarOptions = reactive([]);
22
- var defaultOption = {
21
+ var defaultOptionsValue = {
23
22
  type: undefined,
24
23
  content: '',
25
24
  position: 'top',
@@ -36,6 +35,8 @@ var defaultOption = {
36
35
  onClose: () => {},
37
36
  onClosed: () => {}
38
37
  };
38
+ var uniqSnackbarOptions = reactive([]);
39
+ var defaultOptions = defaultOptionsValue;
39
40
  var transitionGroupProps = {
40
41
  name: 'var-snackbar-fade',
41
42
  tag: 'div',
@@ -76,11 +77,9 @@ var TransitionGroupHost = {
76
77
  "onUpdate:show": $event => reactiveSnackOptions.show = $event
77
78
  }), null);
78
79
  });
79
- var zindex = context.zIndex; // avoid stylelint value-keyword-case error
80
-
81
80
  return _createVNode(TransitionGroup, _mergeProps(transitionGroupProps, {
82
81
  "style": {
83
- zIndex: zindex
82
+ zIndex: context.zIndex
84
83
  },
85
84
  "onAfterEnter": opened,
86
85
  "onAfterLeave": removeUniqOption
@@ -93,10 +92,8 @@ var TransitionGroupHost = {
93
92
  };
94
93
 
95
94
  var Snackbar = function (options) {
96
- var snackOptions = isString(options) || isNumber(options) ? {
97
- content: String(options)
98
- } : options;
99
- var reactiveSnackOptions = reactive(_extends({}, defaultOption, snackOptions));
95
+ var snackOptions = normalizeOptions(options);
96
+ var reactiveSnackOptions = reactive(_extends({}, defaultOptions, snackOptions));
100
97
  reactiveSnackOptions.show = true;
101
98
 
102
99
  if (!isMount) {
@@ -170,6 +167,14 @@ Snackbar.clear = function () {
170
167
  });
171
168
  };
172
169
 
170
+ Snackbar.setDefaultOptions = function (options) {
171
+ defaultOptions = options;
172
+ };
173
+
174
+ Snackbar.resetDefaultOptions = function () {
175
+ defaultOptions = defaultOptionsValue;
176
+ };
177
+
173
178
  Snackbar.Component = VarSnackbar;
174
179
 
175
180
  function opened(element) {
@@ -204,6 +209,16 @@ function addUniqOption(uniqSnackbarOptionItem) {
204
209
  uniqSnackbarOptions.push(uniqSnackbarOptionItem);
205
210
  }
206
211
 
212
+ function normalizeOptions(options) {
213
+ if (options === void 0) {
214
+ options = {};
215
+ }
216
+
217
+ return isString(options) ? {
218
+ content: options
219
+ } : options;
220
+ }
221
+
207
222
  function updateUniqOption(reactiveSnackOptions, _update) {
208
223
  var [firstOption] = uniqSnackbarOptions;
209
224
  firstOption.reactiveSnackOptions = _extends({}, firstOption.reactiveSnackOptions, reactiveSnackOptions);