@opentiny/vue-renderless 3.5.0 → 3.6.0

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.
@@ -39,9 +39,28 @@ export var computedLabelStyle = function computedLabelStyle(_ref2) {
39
39
  return result;
40
40
  };
41
41
  };
42
- export var computedContentStyle = function computedContentStyle(_ref3) {
42
+ export var computedValueStyle = function computedValueStyle(_ref3) {
43
43
  var props = _ref3.props,
44
44
  state = _ref3.state;
45
+ return function () {
46
+ var result = {};
47
+ if (state.form.labelPosition === POSITION.Top) {
48
+ return result.width = '100%';
49
+ }
50
+ var labelWidth = props.labelWidth || state.form.labelWidth;
51
+ if (labelWidth) {
52
+ if (labelWidth === 'auto') {
53
+ result.width = labelWidth;
54
+ } else {
55
+ result.width = "calc(100% - ".concat(labelWidth, ")");
56
+ }
57
+ }
58
+ return result;
59
+ };
60
+ };
61
+ export var computedContentStyle = function computedContentStyle(_ref4) {
62
+ var props = _ref4.props,
63
+ state = _ref4.state;
45
64
  return function () {
46
65
  var result = {};
47
66
  var label = props.label;
@@ -64,10 +83,10 @@ export var computedContentStyle = function computedContentStyle(_ref3) {
64
83
  return result;
65
84
  };
66
85
  };
67
- export var computedForm = function computedForm(_ref4) {
68
- var constants = _ref4.constants,
69
- instance = _ref4.instance,
70
- state = _ref4.state;
86
+ export var computedForm = function computedForm(_ref5) {
87
+ var constants = _ref5.constants,
88
+ instance = _ref5.instance,
89
+ state = _ref5.state;
71
90
  return function () {
72
91
  var FORM_NAME = constants.FORM_NAME,
73
92
  FORM_ITEM_NAME = constants.FORM_ITEM_NAME;
@@ -83,9 +102,9 @@ export var computedForm = function computedForm(_ref4) {
83
102
  return parent;
84
103
  };
85
104
  };
86
- export var computedIsRequired = function computedIsRequired(_ref5) {
87
- var api = _ref5.api,
88
- state = _ref5.state;
105
+ export var computedIsRequired = function computedIsRequired(_ref6) {
106
+ var api = _ref6.api,
107
+ state = _ref6.state;
89
108
  return function () {
90
109
  if (state.validationRequired) {
91
110
  return true;
@@ -130,9 +149,9 @@ export var getPropByPath = function getPropByPath(obj, path, strict) {
130
149
  v: findObj ? findObj[keys[index]] : null
131
150
  };
132
151
  };
133
- export var computedFieldValue = function computedFieldValue(_ref6) {
134
- var props = _ref6.props,
135
- state = _ref6.state;
152
+ export var computedFieldValue = function computedFieldValue(_ref7) {
153
+ var props = _ref7.props,
154
+ state = _ref7.state;
136
155
  return function () {
137
156
  var model = state.form.model;
138
157
  if (!model || !props.prop) {
@@ -145,12 +164,12 @@ export var computedFieldValue = function computedFieldValue(_ref6) {
145
164
  return getPropByPath(model, path, true).v;
146
165
  };
147
166
  };
148
- export var mounted = function mounted(_ref7) {
149
- var api = _ref7.api,
150
- instance = _ref7.instance,
151
- props = _ref7.props,
152
- state = _ref7.state,
153
- refs = _ref7.refs;
167
+ export var mounted = function mounted(_ref8) {
168
+ var api = _ref8.api,
169
+ instance = _ref8.instance,
170
+ props = _ref8.props,
171
+ state = _ref8.state,
172
+ refs = _ref8.refs;
154
173
  return function () {
155
174
  state.tooltip = refs.tooltip;
156
175
  if (props.prop) {
@@ -164,20 +183,20 @@ export var mounted = function mounted(_ref7) {
164
183
  }
165
184
  };
166
185
  };
167
- export var unmounted = function unmounted(_ref8) {
168
- var api = _ref8.api,
169
- instance = _ref8.instance,
170
- state = _ref8.state;
186
+ export var unmounted = function unmounted(_ref9) {
187
+ var api = _ref9.api,
188
+ instance = _ref9.instance,
189
+ state = _ref9.state;
171
190
  return function () {
172
191
  state.canShowTip = false;
173
192
  api.dispatch('Form', 'form:removeField', instance);
174
193
  };
175
194
  };
176
- export var validate = function validate(_ref9) {
177
- var api = _ref9.api,
178
- props = _ref9.props,
179
- state = _ref9.state,
180
- t = _ref9.t;
195
+ export var validate = function validate(_ref10) {
196
+ var api = _ref10.api,
197
+ props = _ref10.props,
198
+ state = _ref10.state,
199
+ t = _ref10.t;
181
200
  return function (trigger) {
182
201
  var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {
183
202
  return undefined;
@@ -226,11 +245,11 @@ export var clearValidate = function clearValidate(state) {
226
245
  state.validateDisabled = false;
227
246
  };
228
247
  };
229
- export var resetField = function resetField(_ref10) {
230
- var api = _ref10.api,
231
- nextTick = _ref10.nextTick,
232
- props = _ref10.props,
233
- state = _ref10.state;
248
+ export var resetField = function resetField(_ref11) {
249
+ var api = _ref11.api,
250
+ nextTick = _ref11.nextTick,
251
+ props = _ref11.props,
252
+ state = _ref11.state;
234
253
  return function () {
235
254
  if (state.getValidateType === 'tip') {
236
255
  state.canShowTip = false;
@@ -259,9 +278,9 @@ export var resetField = function resetField(_ref10) {
259
278
  api.broadcast('timeSelect', 'fieldReset', state.initialValue);
260
279
  };
261
280
  };
262
- export var getRules = function getRules(_ref11) {
263
- var props = _ref11.props,
264
- state = _ref11.state;
281
+ export var getRules = function getRules(_ref12) {
282
+ var props = _ref12.props,
283
+ state = _ref12.state;
265
284
  return function () {
266
285
  var formRules = state.form.rules;
267
286
  var selfRules = props.rules;
@@ -294,9 +313,9 @@ export var onFieldBlur = function onFieldBlur(api) {
294
313
  api.validate('blur');
295
314
  };
296
315
  };
297
- export var onFieldChange = function onFieldChange(_ref12) {
298
- var api = _ref12.api,
299
- state = _ref12.state;
316
+ export var onFieldChange = function onFieldChange(_ref13) {
317
+ var api = _ref13.api,
318
+ state = _ref13.state;
300
319
  return function () {
301
320
  if (state.validateDisabled) {
302
321
  state.validateDisabled = false;
@@ -310,11 +329,11 @@ export var updateComputedLabelWidth = function updateComputedLabelWidth(state) {
310
329
  state.computedLabelWidth = width ? "".concat(width, "px") : '';
311
330
  };
312
331
  };
313
- export var addValidateEvents = function addValidateEvents(_ref13) {
314
- var api = _ref13.api,
315
- instance = _ref13.instance,
316
- props = _ref13.props,
317
- state = _ref13.state;
332
+ export var addValidateEvents = function addValidateEvents(_ref14) {
333
+ var api = _ref14.api,
334
+ instance = _ref14.instance,
335
+ props = _ref14.props,
336
+ state = _ref14.state;
318
337
  return function () {
319
338
  var rules = api.getRules();
320
339
  if (rules.length || props.required !== undefined) {
@@ -331,9 +350,9 @@ export var removeValidateEvents = function removeValidateEvents(instance) {
331
350
  instance.$off();
332
351
  };
333
352
  };
334
- export var updateTip = function updateTip(_ref14) {
335
- var refs = _ref14.refs,
336
- state = _ref14.state;
353
+ export var updateTip = function updateTip(_ref15) {
354
+ var refs = _ref15.refs,
355
+ state = _ref15.state;
337
356
  return function () {
338
357
  if (state.getValidateType !== 'tip' && !state.canShowTip) {
339
358
  return;
@@ -363,9 +382,9 @@ export var getValueByPath = function getValueByPath(object, prop) {
363
382
  }
364
383
  return result;
365
384
  };
366
- export var wrapValidate = function wrapValidate(_ref15) {
367
- var validateFunc = _ref15.validateFunc,
368
- props = _ref15.props;
385
+ export var wrapValidate = function wrapValidate(_ref16) {
386
+ var validateFunc = _ref16.validateFunc,
387
+ props = _ref16.props;
369
388
  if (props.validateDebounce) {
370
389
  return debounce(50, validateFunc);
371
390
  } else {
package/form-item/vue.js CHANGED
@@ -1,4 +1,4 @@
1
- import { validate, clearValidate, resetField, getRules, getFilteredRule, onFieldBlur, onFieldChange, updateComputedLabelWidth, addValidateEvents, removeValidateEvents, mounted, unmounted, watchError, watchValidateStatus, computedLabelStyle, computedContentStyle, computedForm, computedIsRequired, computedFieldValue, computedGetValidateType, updateTip, wrapValidate } from './index';
1
+ import { validate, clearValidate, resetField, getRules, getFilteredRule, onFieldBlur, onFieldChange, updateComputedLabelWidth, addValidateEvents, removeValidateEvents, mounted, unmounted, watchError, watchValidateStatus, computedLabelStyle, computedValueStyle, computedContentStyle, computedForm, computedIsRequired, computedFieldValue, computedGetValidateType, updateTip, wrapValidate } from './index';
2
2
  export var api = ['state', 'validate', 'clearValidate', 'resetField', 'getRules', 'getFilteredRule', 'onFieldBlur', 'onFieldChange', 'updateComputedLabelWidth', 'addValidateEvents', 'removeValidateEvents', 'updateTip'];
3
3
  var initState = function initState(_ref) {
4
4
  var reactive = _ref.reactive,
@@ -27,6 +27,9 @@ var initState = function initState(_ref) {
27
27
  labelStyle: computed(function () {
28
28
  return api.computedLabelStyle();
29
29
  }),
30
+ valueStyle: computed(function () {
31
+ return api.computedValueStyle();
32
+ }),
30
33
  contentStyle: computed(function () {
31
34
  return api.computedContentStyle();
32
35
  }),
@@ -79,6 +82,10 @@ var initApi = function initApi(_ref2) {
79
82
  props: props,
80
83
  state: state
81
84
  }),
85
+ computedValueStyle: computedValueStyle({
86
+ props: props,
87
+ state: state
88
+ }),
82
89
  computedContentStyle: computedContentStyle({
83
90
  props: props,
84
91
  state: state
@@ -21,42 +21,49 @@ export var request = function request(_ref2) {
21
21
  sf = _ref2.sf,
22
22
  api = _ref2.api;
23
23
  return function () {
24
- if (state.isPageOnly) {
25
- state.isFullscreen = true;
26
- api.onChangeFullscreen();
27
- off(document, 'keyup', api.keypressCallback);
28
- on(document, 'keyup', api.keypressCallback);
29
- } else {
30
- sf.off('change', api.fullScreenCallback);
31
- sf.on('change', api.fullScreenCallback);
32
- sf.request(props.teleport ? document.body : vm.$el);
33
- }
34
- if (props.teleport) {
35
- if (vm.$el.parentNode === document.body) {
36
- return;
24
+ var change = function change() {
25
+ if (state.isPageOnly) {
26
+ state.isFullscreen = true;
27
+ api.onChangeFullscreen();
28
+ off(document, 'keyup', api.keypressCallback);
29
+ on(document, 'keyup', api.keypressCallback);
30
+ } else {
31
+ sf.off('change', api.fullScreenCallback);
32
+ sf.on('change', api.fullScreenCallback);
33
+ sf.request(props.teleport ? document.body : vm.$el);
37
34
  }
38
- state.__parentNode = vm.$el.parentNode;
39
- state.__token = document.createComment('fullscreen-token');
40
- state.__parentNode.insertBefore(state.__token, vm.$el);
41
- document.body.appendChild(vm.$el);
42
- }
35
+ if (props.teleport) {
36
+ if (vm.$el.parentNode === document.body) {
37
+ return;
38
+ }
39
+ state.__parentNode = vm.$el.parentNode;
40
+ state.__token = document.createComment('fullscreen-token');
41
+ state.__parentNode.insertBefore(state.__token, vm.$el);
42
+ document.body.appendChild(vm.$el);
43
+ }
44
+ };
45
+ props.beforeChange ? props.beforeChange(change) : change();
43
46
  };
44
47
  };
45
48
  export var exit = function exit(_ref3) {
46
49
  var state = _ref3.state,
47
50
  api = _ref3.api,
48
- sf = _ref3.sf;
51
+ sf = _ref3.sf,
52
+ props = _ref3.props;
49
53
  return function () {
50
- if (!state.isFullscreen) {
51
- return;
52
- }
53
- if (state.isPageOnly) {
54
- state.isFullscreen = false;
55
- api.onChangeFullscreen();
56
- off(document, 'keyup', api.keypressCallback);
57
- } else {
58
- sf.exit();
59
- }
54
+ var change = function change() {
55
+ if (!state.isFullscreen) {
56
+ return;
57
+ }
58
+ if (state.isPageOnly) {
59
+ state.isFullscreen = false;
60
+ api.onChangeFullscreen();
61
+ off(document, 'keyup', api.keypressCallback);
62
+ } else {
63
+ sf.exit();
64
+ }
65
+ };
66
+ props.beforeChange ? props.beforeChange(change) : change();
60
67
  };
61
68
  };
62
69
  export var shadeClick = function shadeClick(_ref4) {
package/fullscreen/vue.js CHANGED
@@ -28,7 +28,8 @@ export var renderless = function renderless(props, _ref, _ref2) {
28
28
  exit: exit({
29
29
  state: state,
30
30
  api: api,
31
- sf: sf
31
+ sf: sf,
32
+ props: props
32
33
  }),
33
34
  toggle: toggle({
34
35
  state: state,
@@ -0,0 +1,76 @@
1
+ export var switchIndex = function switchIndex(index, state, emit) {
2
+ if (index === state.index) {
3
+ return;
4
+ }
5
+ emit('select', index);
6
+ state.index = index;
7
+ if (index < state.childrenAnchor.length) {
8
+ var item = state.childrenAnchor[index];
9
+ document.documentElement.scrollTop = item.offsetTop;
10
+ }
11
+ };
12
+ export var handleTouchDown = function handleTouchDown(_ref) {
13
+ var state = _ref.state;
14
+ return function () {
15
+ state.isMouseDown = true;
16
+ };
17
+ };
18
+ export var handleTouchMove = function handleTouchMove(_ref2) {
19
+ var emit = _ref2.emit,
20
+ state = _ref2.state;
21
+ return function (e) {
22
+ console.log(e, state.isMouseDown);
23
+ if (state.isMouseDown && e.target.id) {
24
+ switchIndex(Number(e.target.id), state, emit);
25
+ }
26
+ };
27
+ };
28
+ export var handleTouchUp = function handleTouchUp(_ref3) {
29
+ var state = _ref3.state;
30
+ return function () {
31
+ state.isMouseDown = false;
32
+ };
33
+ };
34
+ export var handleIndexClick = function handleIndexClick(_ref4) {
35
+ var emit = _ref4.emit,
36
+ state = _ref4.state;
37
+ return function (value) {
38
+ switchIndex(value.index, state, emit);
39
+ };
40
+ };
41
+ export var updateAnchorChildren = function updateAnchorChildren(_ref5) {
42
+ var state = _ref5.state,
43
+ refs = _ref5.refs;
44
+ return function () {
45
+ var node = refs.indexBarContent;
46
+ if (node) {
47
+ state.childrenAnchor = [];
48
+ getAnchorChildren(node, state);
49
+ }
50
+ };
51
+ };
52
+ export var getAnchorChildren = function getAnchorChildren(node, state) {
53
+ node.childNodes.forEach(function (ele) {
54
+ if (ele.className === 'tiny-mobile-index-bar-anchor') {
55
+ state.childrenAnchor.push(ele);
56
+ } else {
57
+ getAnchorChildren(ele, state);
58
+ }
59
+ });
60
+ };
61
+ export var handleScroll = function handleScroll(_ref6) {
62
+ var state = _ref6.state;
63
+ return function () {
64
+ findTopAnchor(state);
65
+ };
66
+ };
67
+ export var findTopAnchor = function findTopAnchor(state) {
68
+ var scrollTop = document.documentElement.scrollTop;
69
+ for (var index = 0; index < state.childrenAnchor.length; index++) {
70
+ var item = state.childrenAnchor[index];
71
+ if (item.offsetTop + item.offsetHeight > scrollTop) {
72
+ state.index = index;
73
+ break;
74
+ }
75
+ }
76
+ };
@@ -0,0 +1,87 @@
1
+ import { handleScroll, updateAnchorChildren, handleTouchDown, handleTouchMove, handleTouchUp, handleIndexClick } from './index';
2
+ export var api = ['state', 'handleIndexClick', 'handleScroll', 'updateAnchorChildren', 'handleTouchDown', 'handleTouchMove', 'handleTouchUp', 'handleIndexClick'];
3
+ export var renderless = function renderless(props, _ref, _ref2) {
4
+ var computed = _ref.computed,
5
+ reactive = _ref.reactive,
6
+ onMounted = _ref.onMounted,
7
+ onUnmounted = _ref.onUnmounted,
8
+ onUpdated = _ref.onUpdated,
9
+ watch = _ref.watch;
10
+ var emit = _ref2.emit,
11
+ parent = _ref2.parent,
12
+ refs = _ref2.refs;
13
+ var state = reactive({
14
+ index: 0,
15
+ childrenAnchor: [],
16
+ isFistUpdate: true
17
+ });
18
+ var api = {
19
+ state: state,
20
+ isMouseDown: false,
21
+ handleScroll: handleScroll({
22
+ state: state
23
+ }),
24
+ updateAnchorChildren: updateAnchorChildren({
25
+ emit: emit,
26
+ parent: parent,
27
+ refs: refs,
28
+ state: state
29
+ }),
30
+ handleTouchDown: handleTouchDown({
31
+ state: state
32
+ }),
33
+ handleTouchMove: handleTouchMove({
34
+ emit: emit,
35
+ state: state
36
+ }),
37
+ handleTouchUp: handleTouchUp({
38
+ state: state
39
+ }),
40
+ handleIndexClick: handleIndexClick({
41
+ emit: emit,
42
+ parent: parent,
43
+ refs: refs,
44
+ state: state
45
+ })
46
+ };
47
+ Object.assign(api, {
48
+ state: state
49
+ });
50
+ onMounted(function (e) {
51
+ window.addEventListener('scroll', api.handleScroll);
52
+ });
53
+ onUnmounted(function () {
54
+ window.removeEventListener('scroll', api.handleScroll);
55
+ });
56
+ watch(function () {
57
+ return state.index;
58
+ }, function (value, oldValue) {
59
+ var isChange = value !== oldValue && value >= 0 && value < parent.indexList.length;
60
+ if (isChange) {
61
+ emit('change', value);
62
+ }
63
+ }, {
64
+ immediate: false
65
+ });
66
+ watch(function () {
67
+ return props.indexList;
68
+ }, function () {
69
+ api.updateAnchorChildren({
70
+ refs: refs,
71
+ state: state
72
+ });
73
+ }, {
74
+ immediate: false,
75
+ deep: true
76
+ });
77
+ onUpdated(function () {
78
+ if (state.isFistUpdate) {
79
+ state.isFistUpdate = false;
80
+ api.updateAnchorChildren({
81
+ refs: refs,
82
+ state: state
83
+ });
84
+ }
85
+ });
86
+ return api;
87
+ };
@@ -0,0 +1,20 @@
1
+ import './index';
2
+ export var api = ['state'];
3
+ export var renderless = function renderless(props, _ref, _ref2) {
4
+ var computed = _ref.computed,
5
+ reactive = _ref.reactive,
6
+ onMounted = _ref.onMounted,
7
+ onUpdated = _ref.onUpdated,
8
+ watch = _ref.watch;
9
+ var emit = _ref2.emit,
10
+ parent = _ref2.parent,
11
+ refs = _ref2.refs;
12
+ var state = reactive({});
13
+ var api = {
14
+ state: state
15
+ };
16
+ Object.assign(api, {
17
+ state: state
18
+ });
19
+ return api;
20
+ };
@@ -148,7 +148,9 @@ export var select = function select(_ref7) {
148
148
  };
149
149
  export var inputEvent = function inputEvent(_ref9) {
150
150
  var api = _ref9.api,
151
+ componentName = _ref9.componentName,
151
152
  emit = _ref9.emit,
153
+ eventName = _ref9.eventName,
152
154
  props = _ref9.props;
153
155
  return function (_ref10) {
154
156
  var item = _ref10.item,
@@ -166,6 +168,7 @@ export var inputEvent = function inputEvent(_ref9) {
166
168
  }
167
169
  value = api.getValue();
168
170
  emit('update:modelValue', value, index);
171
+ api.dispatch(componentName, eventName, [value]);
169
172
  };
170
173
  };
171
174
  export var change = function change(_ref11) {
@@ -192,7 +195,7 @@ export var blur = function blur(_ref12) {
192
195
  item.value = item.value.replace(/\D/g, '');
193
196
  }
194
197
  emit('blur', item.value, index);
195
- api.dispatch(componentName, eventName);
198
+ api.dispatch(componentName, eventName, [item.value]);
196
199
  };
197
200
  };
198
201
  export var keyup = function keyup(_ref14) {
@@ -229,13 +232,12 @@ export var keyup = function keyup(_ref14) {
229
232
  };
230
233
  };
231
234
  var checkError1 = function checkError1(_ref16) {
232
- var Tab = _ref16.Tab,
233
- Space = _ref16.Space,
235
+ var Space = _ref16.Space,
234
236
  NumpadDecimal = _ref16.NumpadDecimal,
235
237
  NumpadComma = _ref16.NumpadComma,
236
238
  keyCode = _ref16.keyCode,
237
239
  value = _ref16.value;
238
- return [Tab, Space, NumpadDecimal, NumpadComma].indexOf(keyCode) > -1 && value;
240
+ return [Space, NumpadDecimal, NumpadComma].indexOf(keyCode) > -1 && value;
239
241
  };
240
242
  var checkError2 = function checkError2(newValue) {
241
243
  return newValue && (isNaN(newValue) || newValue > IPTHRESHOLD.Max);
@@ -270,13 +272,11 @@ var isError = function isError(_ref20) {
270
272
  ctrlKey = _ref20.ctrlKey,
271
273
  keyCode = _ref20.keyCode,
272
274
  newValue = _ref20.newValue;
273
- var Tab = KEY_CODE.Tab,
274
- Space = KEY_CODE.Space,
275
+ var Space = KEY_CODE.Space,
275
276
  NumpadDecimal = KEY_CODE.NumpadDecimal,
276
277
  NumpadComma = KEY_CODE.NumpadComma,
277
278
  KeyV = KEY_CODE.KeyV;
278
279
  return checkError1({
279
- Tab: Tab,
280
280
  Space: Space,
281
281
  NumpadDecimal: NumpadDecimal,
282
282
  NumpadComma: NumpadComma,
package/ip-address/vue.js CHANGED
@@ -75,8 +75,7 @@ var initApi = function initApi(_ref2) {
75
75
  }),
76
76
  change: change({
77
77
  api: api,
78
- emit: emit,
79
- props: props
78
+ emit: emit
80
79
  }),
81
80
  keydown: keydown({
82
81
  api: api,
@@ -86,7 +85,9 @@ var initApi = function initApi(_ref2) {
86
85
  inputEvent: inputEvent({
87
86
  api: api,
88
87
  emit: emit,
89
- props: props
88
+ props: props,
89
+ componentName: componentName,
90
+ eventName: eventName.change
90
91
  })
91
92
  }));
92
93
  };
@@ -147,10 +148,10 @@ export var renderless = function renderless(props, _ref4, _ref5) {
147
148
  broadcast = _ref5.broadcast,
148
149
  dispatch = _ref5.dispatch;
149
150
  var api = {};
150
- var componentName = "".concat($prefix, "FormItem");
151
+ var componentName = "FormItem";
151
152
  var eventName = {
152
- change: "".concat($prefix, ".form.change"),
153
- blur: "".concat($prefix, ".form.blur")
153
+ change: "form.change",
154
+ blur: "form.blur"
154
155
  };
155
156
  parent.tinyForm = parent.tinyForm || inject('form', null);
156
157
  var handleValue = useHandleValue({