y-design-ssr 0.2.1 → 0.2.2

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 (90) hide show
  1. package/libs/button/index.css +579 -1
  2. package/libs/button/index.mjs +111 -66
  3. package/libs/button/index.umd.js +203 -2
  4. package/libs/cell/index.css +1077 -1
  5. package/libs/cell/index.mjs +167 -104
  6. package/libs/cell/index.umd.js +300 -2
  7. package/libs/checkbox/index.css +1053 -1
  8. package/libs/checkbox/index.mjs +242 -127
  9. package/libs/checkbox/index.umd.js +369 -2
  10. package/libs/checkboxGroup/index.css +422 -1
  11. package/libs/checkboxGroup/index.mjs +173 -87
  12. package/libs/checkboxGroup/index.umd.js +265 -2
  13. package/libs/col/index.css +615 -1
  14. package/libs/col/index.mjs +246 -81
  15. package/libs/col/index.umd.js +305 -2
  16. package/libs/countdown/index.css +417 -1
  17. package/libs/countdown/index.mjs +179 -71
  18. package/libs/countdown/index.umd.js +231 -2
  19. package/libs/dialog/index.css +1405 -1
  20. package/libs/dialog/index.mjs +646 -476
  21. package/libs/dialog/index.umd.js +1128 -2
  22. package/libs/empty/index.css +457 -1
  23. package/libs/empty/index.mjs +91 -44
  24. package/libs/empty/index.umd.js +139 -2
  25. package/libs/form/index.css +477 -1
  26. package/libs/form/index.mjs +226 -126
  27. package/libs/form/index.umd.js +319 -2
  28. package/libs/formItem/index.css +477 -1
  29. package/libs/formItem/index.mjs +276 -126
  30. package/libs/formItem/index.umd.js +372 -2
  31. package/libs/icon/index.css +982 -1
  32. package/libs/icon/index.mjs +107 -58
  33. package/libs/icon/index.umd.js +186 -2
  34. package/libs/index.css +2902 -1
  35. package/libs/index.mjs +3785 -2344
  36. package/libs/index.umd.js +5509 -2
  37. package/libs/input/index.css +483 -1
  38. package/libs/input/index.mjs +183 -92
  39. package/libs/input/index.umd.js +274 -2
  40. package/libs/layout/index.css +684 -1
  41. package/libs/layout/index.mjs +230 -130
  42. package/libs/layout/index.umd.js +318 -2
  43. package/libs/list/index.css +440 -1
  44. package/libs/list/index.mjs +388 -207
  45. package/libs/list/index.umd.js +571 -2
  46. package/libs/loading/index.css +548 -1
  47. package/libs/loading/index.mjs +196 -118
  48. package/libs/loading/index.umd.js +321 -2
  49. package/libs/mask/index.css +426 -1
  50. package/libs/mask/index.mjs +131 -70
  51. package/libs/mask/index.umd.js +201 -2
  52. package/libs/popup/index.css +465 -1
  53. package/libs/popup/index.mjs +210 -134
  54. package/libs/popup/index.umd.js +358 -2
  55. package/libs/progress/index.css +488 -1
  56. package/libs/progress/index.mjs +200 -128
  57. package/libs/progress/index.umd.js +322 -2
  58. package/libs/pullrefresh/index.css +441 -1
  59. package/libs/pullrefresh/index.mjs +241 -111
  60. package/libs/pullrefresh/index.umd.js +302 -2
  61. package/libs/row/index.css +485 -1
  62. package/libs/row/index.mjs +181 -89
  63. package/libs/row/index.umd.js +237 -2
  64. package/libs/slider/index.css +558 -1
  65. package/libs/slider/index.mjs +356 -160
  66. package/libs/slider/index.umd.js +453 -2
  67. package/libs/stepper/index.css +489 -1
  68. package/libs/stepper/index.mjs +181 -101
  69. package/libs/stepper/index.umd.js +269 -2
  70. package/libs/swipe/index.css +506 -1
  71. package/libs/swipe/index.mjs +542 -259
  72. package/libs/swipe/index.umd.js +703 -2
  73. package/libs/swipeItem/index.css +424 -1
  74. package/libs/swipeItem/index.mjs +111 -52
  75. package/libs/swipeItem/index.umd.js +154 -2
  76. package/libs/switch/index.css +472 -1
  77. package/libs/switch/index.mjs +121 -62
  78. package/libs/switch/index.umd.js +200 -2
  79. package/libs/tab/index.mjs +131 -68
  80. package/libs/tab/index.umd.js +190 -1
  81. package/libs/tabs/index.css +514 -1
  82. package/libs/tabs/index.mjs +751 -410
  83. package/libs/tabs/index.umd.js +1020 -2
  84. package/libs/toast/index.css +1050 -1
  85. package/libs/toast/index.mjs +183 -114
  86. package/libs/toast/index.umd.js +306 -2
  87. package/libs/tooltip/index.css +514 -1
  88. package/libs/tooltip/index.mjs +293 -155
  89. package/libs/tooltip/index.umd.js +416 -2
  90. package/package.json +2 -2
@@ -1,11 +1,40 @@
1
- import { ref as V, reactive as z, inject as E, getCurrentInstance as F, watch as x, onUnmounted as A, defineComponent as T, computed as f, createVNode as d, withDirectives as k, vModelText as w } from "vue";
2
- const b = (e, t) => t ? typeof t == "string" ? ` ${e}--${t}` : Array.isArray(t) ? t.reduce((l, n) => l + b(e, n), "") : Object.keys(t).reduce(
3
- (l, n) => l + (t[n] ? b(e, n) : ""),
4
- ""
5
- ) : "", D = (e) => (t, l) => {
6
- let n = t, i = l;
7
- return n && typeof n != "string" && (i = n, n = ""), n = n ? `${e}__${n}` : e, `${n}${b(n, i)}`;
8
- }, R = () => (e, t) => t ? `${b(`y-${e}`, t)}` : `y-${e}`, W = {
1
+ import { ref, reactive, inject, getCurrentInstance, watch, onUnmounted, defineComponent, computed, createVNode, withDirectives, vModelText } from "vue";
2
+ const getMods = (el, mods) => {
3
+ if (!mods) {
4
+ return "";
5
+ }
6
+ if (typeof mods === "string") {
7
+ return ` ${el}--${mods}`;
8
+ }
9
+ if (Array.isArray(mods)) {
10
+ return mods.reduce((acc, cur) => acc + getMods(el, cur), "");
11
+ }
12
+ return Object.keys(mods).reduce(
13
+ (acc, cur) => acc + (mods[cur] ? getMods(el, cur) : ""),
14
+ ""
15
+ );
16
+ };
17
+ const createBEM = (block) => {
18
+ return (el, mods) => {
19
+ let _el = el;
20
+ let _mods = mods;
21
+ if (_el && typeof _el !== "string") {
22
+ _mods = _el;
23
+ _el = "";
24
+ }
25
+ _el = _el ? `${block}__${_el}` : block;
26
+ return `${_el}${getMods(_el, _mods)}`;
27
+ };
28
+ };
29
+ const createGlobalBem = () => {
30
+ return (el, mods) => {
31
+ if (!mods) {
32
+ return `y-${el}`;
33
+ }
34
+ return `${getMods(`y-${el}`, mods)}`;
35
+ };
36
+ };
37
+ const defaultLang = {
9
38
  "pull-refresh": {
10
39
  pulling: "下拉刷新...",
11
40
  loosing: "释放刷新...",
@@ -17,31 +46,50 @@ const b = (e, t) => t ? typeof t == "string" ? ` ${e}--${t}` : Array.isArray(t)
17
46
  validateMessage: "请输入正确内容"
18
47
  }
19
48
  };
20
- V("zh-CN");
21
- z({
22
- "zh-CN": W
49
+ ref("zh-CN");
50
+ reactive({
51
+ "zh-CN": defaultLang
23
52
  });
24
- const O = (e) => {
25
- const t = `y-${e}`;
26
- return [t, D(t), R()];
27
- }, U = (e) => isNaN(Number(e)) && typeof e == "string" ? e : `${e}px`, j = "y-form-item", G = () => {
28
- const e = E(j, null), t = F();
29
- if (e && (t != null && t.proxy)) {
30
- const { setField: l } = e, { resetValidation: n, change: i, validateWithTrigger: s } = e;
31
- return x(
32
- () => t.proxy.modelValue,
53
+ const createNamespace = (name2) => {
54
+ const prefixedName = `y-${name2}`;
55
+ return [prefixedName, createBEM(prefixedName), createGlobalBem()];
56
+ };
57
+ const parseUnit = (val) => {
58
+ if (isNaN(Number(val)) && typeof val === "string") {
59
+ return val;
60
+ }
61
+ return `${val}px`;
62
+ };
63
+ const FORM_ITEM_PROVIDE = "y-form-item";
64
+ const useFormItem = () => {
65
+ const parent = inject(FORM_ITEM_PROVIDE, null);
66
+ const instance = getCurrentInstance();
67
+ if (parent && (instance == null ? void 0 : instance.proxy)) {
68
+ const { setField } = parent;
69
+ const { resetValidation, change, validateWithTrigger } = parent;
70
+ watch(
71
+ () => instance.proxy.modelValue,
33
72
  () => {
34
- e.instance && e.instance.exposed && (n(), i(), s("onChange"));
73
+ if (parent.instance && parent.instance.exposed) {
74
+ resetValidation();
75
+ change();
76
+ validateWithTrigger("onChange");
77
+ }
35
78
  }
36
- ), l(t), A(() => l(null)), {
37
- parent: e
79
+ );
80
+ setField(instance);
81
+ onUnmounted(() => setField(null));
82
+ return {
83
+ parent
38
84
  };
39
85
  }
40
86
  return {
41
87
  parent: null
42
88
  };
43
- }, [P, m, v] = O("stepper"), g = /* @__PURE__ */ T({
44
- name: P,
89
+ };
90
+ const [name, bem, gbem] = createNamespace("stepper");
91
+ const Stepper = /* @__PURE__ */ defineComponent({
92
+ name,
45
93
  props: {
46
94
  modelValue: {
47
95
  type: [Number, String],
@@ -61,7 +109,7 @@ const O = (e) => {
61
109
  },
62
110
  integer: {
63
111
  type: Boolean,
64
- default: !1
112
+ default: false
65
113
  },
66
114
  max: {
67
115
  type: Number,
@@ -69,11 +117,11 @@ const O = (e) => {
69
117
  },
70
118
  disabled: {
71
119
  type: Boolean,
72
- default: !1
120
+ default: false
73
121
  },
74
122
  disableInput: {
75
123
  type: Boolean,
76
- default: !1
124
+ default: false
77
125
  },
78
126
  inputWidth: {
79
127
  type: [Number, String],
@@ -85,99 +133,131 @@ const O = (e) => {
85
133
  }
86
134
  },
87
135
  emits: ["change", "blur", "subtract", "addit", "foucs", "update:modelValue"],
88
- setup(e, {
89
- slots: t,
90
- emit: l
136
+ setup(props, {
137
+ slots,
138
+ emit
91
139
  }) {
92
140
  const {
93
- parent: n
94
- } = G(), i = V(e.modelValue), s = f(() => e.size || (n == null ? void 0 : n.getProp("size"))), y = f(() => e.modelValue <= e.min || e.disabled), p = f(() => e.modelValue >= e.max || e.disabled), h = (a) => {
95
- let u = e.integer;
96
- return a.toString().replace(/([^0-9\.\-])/g, "").replace(/\./g, (r) => u ? "" : (u = !0, r)).replace(/\-/g, (r, c) => c === 0 ? "-" : "");
97
- }, o = (a) => {
98
- const u = h(a);
99
- i.value = u, l("update:modelValue", u), l("change", u);
141
+ parent
142
+ } = useFormItem();
143
+ const currentValue = ref(props.modelValue);
144
+ const size = computed(() => props.size || (parent == null ? void 0 : parent.getProp("size")));
145
+ const subDisabled = computed(() => props.modelValue <= props.min || props.disabled);
146
+ const addDisabled = computed(() => props.modelValue >= props.max || props.disabled);
147
+ const format = (value) => {
148
+ let bool = props.integer;
149
+ return value.toString().replace(/([^0-9\.\-])/g, "").replace(/\./g, ($1) => {
150
+ if (bool)
151
+ return "";
152
+ bool = true;
153
+ return $1;
154
+ }).replace(/\-/g, (_, i) => i === 0 ? "-" : "");
100
155
  };
101
- x(() => e.modelValue, (a) => {
102
- i.value = a;
156
+ const changeValue = (number) => {
157
+ const fNumber = format(number);
158
+ currentValue.value = fNumber;
159
+ emit("update:modelValue", fNumber);
160
+ emit("change", fNumber);
161
+ };
162
+ watch(() => props.modelValue, (value) => {
163
+ currentValue.value = value;
103
164
  });
104
- const $ = (a) => l("focus", a), _ = (a) => {
165
+ const onFocus = (e) => emit("focus", e);
166
+ const onChange = (e) => {
105
167
  const {
106
- value: u
107
- } = a.target;
108
- o(u);
109
- }, B = (a) => {
168
+ value
169
+ } = e.target;
170
+ changeValue(value);
171
+ };
172
+ const onBlurReset = (e) => {
110
173
  const {
111
- value: u
112
- } = a.target, r = Number(h(u));
113
- if (r && r < e.min ? o(e.min) : r && r > e.max ? o(e.max) : r && o(r), n) {
174
+ value
175
+ } = e.target;
176
+ const number = Number(format(value));
177
+ if (number && number < props.min)
178
+ changeValue(props.min);
179
+ else if (number && number > props.max)
180
+ changeValue(props.max);
181
+ else if (number)
182
+ changeValue(number);
183
+ if (parent) {
114
184
  const {
115
- validateWithTrigger: c
116
- } = n;
117
- c("onBlur");
185
+ validateWithTrigger
186
+ } = parent;
187
+ validateWithTrigger("onBlur");
118
188
  }
119
- l("blur", a);
120
- }, C = () => {
121
- const a = Number(e.modelValue) - e.step;
122
- o(a), l("subtract", a);
123
- }, I = () => {
124
- const a = Number(e.modelValue) + e.step;
125
- o(a), l("addit", a);
189
+ emit("blur", e);
190
+ };
191
+ const onSubtract = () => {
192
+ const number = Number(props.modelValue) - props.step;
193
+ changeValue(number);
194
+ emit("subtract", number);
195
+ };
196
+ const onAddit = () => {
197
+ const number = Number(props.modelValue) + props.step;
198
+ changeValue(number);
199
+ emit("addit", number);
126
200
  };
127
201
  return () => {
128
202
  const {
129
- min: a,
130
- max: u,
131
- inputWidth: r,
132
- placeholder: c,
133
- disabled: S,
134
- disableInput: N
135
- } = e;
136
- return d("div", {
137
- class: m({
138
- [s.value]: s.value
203
+ min,
204
+ max,
205
+ inputWidth,
206
+ placeholder,
207
+ disabled,
208
+ disableInput
209
+ } = props;
210
+ return createVNode("div", {
211
+ "class": bem({
212
+ [size.value]: size.value
139
213
  })
140
- }, [t.subtraction ? t.subtraction() : d("button", {
141
- type: "button",
142
- disabled: y.value,
143
- class: [m("subtraction"), v("el", {
144
- clickable: !y.value
214
+ }, [slots.subtraction ? slots.subtraction() : createVNode("button", {
215
+ "type": "button",
216
+ "disabled": subDisabled.value,
217
+ "class": [bem("subtraction"), gbem("el", {
218
+ clickable: !subDisabled.value
145
219
  })],
146
- onClick: C
147
- }, null), k(d("input", {
148
- type: "text",
149
- class: m("input", {
150
- "only-disable": N
220
+ "onClick": onSubtract
221
+ }, null), withDirectives(createVNode("input", {
222
+ "type": "text",
223
+ "class": bem("input", {
224
+ "only-disable": disableInput
151
225
  }),
152
- style: {
153
- width: U(r)
226
+ "style": {
227
+ width: parseUnit(inputWidth)
154
228
  },
155
- "onUpdate:modelValue": (M) => i.value = M,
156
- role: "spinbutton",
157
- inputmode: "decimal",
158
- "aria-min": a,
159
- "aria-max": u,
160
- "aria-valuenow": i.value,
161
- onInput: _,
162
- onBlur: B,
163
- onFocus: $,
164
- placeholder: c,
165
- disabled: S || N
166
- }, null), [[w, i.value]]), t.addition ? t.addition() : d("button", {
167
- type: "button",
168
- disabled: p.value,
169
- class: [m("addition"), v("el", {
170
- clickable: !p.value
229
+ "onUpdate:modelValue": ($event) => currentValue.value = $event,
230
+ "role": "spinbutton",
231
+ "inputmode": "decimal",
232
+ "aria-min": min,
233
+ "aria-max": max,
234
+ "aria-valuenow": currentValue.value,
235
+ "onInput": onChange,
236
+ "onBlur": onBlurReset,
237
+ "onFocus": onFocus,
238
+ "placeholder": placeholder,
239
+ "disabled": disabled || disableInput
240
+ }, null), [[vModelText, currentValue.value]]), slots.addition ? slots.addition() : createVNode("button", {
241
+ "type": "button",
242
+ "disabled": addDisabled.value,
243
+ "class": [bem("addition"), gbem("el", {
244
+ clickable: !addDisabled.value
171
245
  })],
172
- onClick: I
246
+ "onClick": onAddit
173
247
  }, null)]);
174
248
  };
175
249
  }
176
250
  });
177
- g.install = (e) => {
178
- const { name: t } = g;
179
- e.component(t, g);
251
+ const reset = "";
252
+ const libs = "";
253
+ const font = "";
254
+ const animation = "";
255
+ const theme = "";
256
+ const style = "";
257
+ Stepper.install = (Vue) => {
258
+ const { name: name2 } = Stepper;
259
+ Vue.component(name2, Stepper);
180
260
  };
181
261
  export {
182
- g as default
262
+ Stepper as default
183
263
  };