y-design-ssr 0.2.0 → 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 (119) 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 +5 -4
  91. package/libs/button/package.json +0 -5
  92. package/libs/cell/package.json +0 -5
  93. package/libs/checkbox/package.json +0 -5
  94. package/libs/checkboxGroup/package.json +0 -5
  95. package/libs/col/package.json +0 -5
  96. package/libs/countdown/package.json +0 -5
  97. package/libs/dialog/package.json +0 -5
  98. package/libs/empty/package.json +0 -5
  99. package/libs/form/package.json +0 -5
  100. package/libs/formItem/package.json +0 -5
  101. package/libs/icon/package.json +0 -5
  102. package/libs/input/package.json +0 -5
  103. package/libs/layout/package.json +0 -5
  104. package/libs/list/package.json +0 -5
  105. package/libs/loading/package.json +0 -5
  106. package/libs/mask/package.json +0 -5
  107. package/libs/popup/package.json +0 -5
  108. package/libs/progress/package.json +0 -5
  109. package/libs/pullrefresh/package.json +0 -5
  110. package/libs/row/package.json +0 -5
  111. package/libs/slider/package.json +0 -5
  112. package/libs/stepper/package.json +0 -5
  113. package/libs/swipe/package.json +0 -5
  114. package/libs/swipeItem/package.json +0 -5
  115. package/libs/switch/package.json +0 -5
  116. package/libs/tab/package.json +0 -5
  117. package/libs/tabs/package.json +0 -5
  118. package/libs/toast/package.json +0 -5
  119. package/libs/tooltip/package.json +0 -5
@@ -1,27 +1,67 @@
1
- import { inject as k, getCurrentInstance as b, watch as s, onUnmounted as I, ref as T, reactive as D, defineComponent as W, onMounted as F, onBeforeUnmount as O, computed as P, withDirectives as h, createVNode as v, mergeProps as x, vModelText as U, vModelDynamic as j } from "vue";
2
- const A = "y-form-item", R = () => {
3
- const e = k(A, null), t = b();
4
- if (e && (t != null && t.proxy)) {
5
- const { setField: a } = e, { resetValidation: n, change: o, validateWithTrigger: u } = e;
6
- return s(
7
- () => t.proxy.modelValue,
1
+ import { inject, getCurrentInstance, watch, onUnmounted, ref, reactive, defineComponent, onMounted, onBeforeUnmount, computed, withDirectives, createVNode, mergeProps, vModelText, vModelDynamic } from "vue";
2
+ const FORM_ITEM_PROVIDE = "y-form-item";
3
+ const useFormItem = () => {
4
+ const parent = inject(FORM_ITEM_PROVIDE, null);
5
+ const instance = getCurrentInstance();
6
+ if (parent && (instance == null ? void 0 : instance.proxy)) {
7
+ const { setField } = parent;
8
+ const { resetValidation, change, validateWithTrigger } = parent;
9
+ watch(
10
+ () => instance.proxy.modelValue,
8
11
  () => {
9
- e.instance && e.instance.exposed && (n(), o(), u("onChange"));
12
+ if (parent.instance && parent.instance.exposed) {
13
+ resetValidation();
14
+ change();
15
+ validateWithTrigger("onChange");
16
+ }
10
17
  }
11
- ), a(t), I(() => a(null)), {
12
- parent: e
18
+ );
19
+ setField(instance);
20
+ onUnmounted(() => setField(null));
21
+ return {
22
+ parent
13
23
  };
14
24
  }
15
25
  return {
16
26
  parent: null
17
27
  };
18
- }, c = (e, t) => t ? typeof t == "string" ? ` ${e}--${t}` : Array.isArray(t) ? t.reduce((a, n) => a + c(e, n), "") : Object.keys(t).reduce(
19
- (a, n) => a + (t[n] ? c(e, n) : ""),
20
- ""
21
- ) : "", G = (e) => (t, a) => {
22
- let n = t, o = a;
23
- return n && typeof n != "string" && (o = n, n = ""), n = n ? `${e}__${n}` : e, `${n}${c(n, o)}`;
24
- }, H = () => (e, t) => t ? `${c(`y-${e}`, t)}` : `y-${e}`, K = {
28
+ };
29
+ const getMods = (el, mods) => {
30
+ if (!mods) {
31
+ return "";
32
+ }
33
+ if (typeof mods === "string") {
34
+ return ` ${el}--${mods}`;
35
+ }
36
+ if (Array.isArray(mods)) {
37
+ return mods.reduce((acc, cur) => acc + getMods(el, cur), "");
38
+ }
39
+ return Object.keys(mods).reduce(
40
+ (acc, cur) => acc + (mods[cur] ? getMods(el, cur) : ""),
41
+ ""
42
+ );
43
+ };
44
+ const createBEM = (block) => {
45
+ return (el, mods) => {
46
+ let _el = el;
47
+ let _mods = mods;
48
+ if (_el && typeof _el !== "string") {
49
+ _mods = _el;
50
+ _el = "";
51
+ }
52
+ _el = _el ? `${block}__${_el}` : block;
53
+ return `${_el}${getMods(_el, _mods)}`;
54
+ };
55
+ };
56
+ const createGlobalBem = () => {
57
+ return (el, mods) => {
58
+ if (!mods) {
59
+ return `y-${el}`;
60
+ }
61
+ return `${getMods(`y-${el}`, mods)}`;
62
+ };
63
+ };
64
+ const defaultLang = {
25
65
  "pull-refresh": {
26
66
  pulling: "下拉刷新...",
27
67
  loosing: "释放刷新...",
@@ -33,15 +73,18 @@ const A = "y-form-item", R = () => {
33
73
  validateMessage: "请输入正确内容"
34
74
  }
35
75
  };
36
- T("zh-CN");
37
- D({
38
- "zh-CN": K
76
+ ref("zh-CN");
77
+ reactive({
78
+ "zh-CN": defaultLang
39
79
  });
40
- const q = (e) => {
41
- const t = `y-${e}`;
42
- return [t, G(t), H()];
43
- }, [J, Q] = q("input"), X = 13, f = /* @__PURE__ */ W({
44
- name: J,
80
+ const createNamespace = (name2) => {
81
+ const prefixedName = `y-${name2}`;
82
+ return [prefixedName, createBEM(prefixedName), createGlobalBem()];
83
+ };
84
+ const [name, bem] = createNamespace("input");
85
+ const ENTER_CODE = 13;
86
+ const Input = /* @__PURE__ */ defineComponent({
87
+ name,
45
88
  props: {
46
89
  modelValue: {
47
90
  type: [String, Number],
@@ -53,7 +96,7 @@ const q = (e) => {
53
96
  },
54
97
  border: {
55
98
  type: Boolean,
56
- default: !1
99
+ default: false
57
100
  },
58
101
  placeholder: {
59
102
  type: String,
@@ -81,97 +124,145 @@ const q = (e) => {
81
124
  },
82
125
  showWordLimit: {
83
126
  type: Boolean,
84
- default: !1
127
+ default: false
85
128
  },
86
129
  readonly: {
87
130
  type: Boolean,
88
- default: !1
131
+ default: false
89
132
  },
90
133
  disabled: {
91
134
  type: Boolean,
92
- default: !1
135
+ default: false
93
136
  }
94
137
  },
95
138
  emits: ["click", "input", "keypress", "focus", "blur", "update:modelValue"],
96
- setup(e, {
97
- emit: t
139
+ setup(props, {
140
+ emit
98
141
  }) {
99
- const a = b(), {
100
- parent: n
101
- } = R();
102
- let o = null;
103
- const u = (l, r) => {
104
- l !== r && o && (o.innerHTML = `${e.modelValue.toString().length}/${e.maxLength}`);
105
- }, m = (l, r) => {
106
- l !== r && (l ? (o = document.createElement("div"), o.className = "y-input__limit-num", (a == null ? void 0 : a.vnode.el).insertAdjacentElement("afterend", o), e.maxLength && u(e.maxLength)) : (o && o.remove(), o = null));
142
+ const instance = getCurrentInstance();
143
+ const {
144
+ parent
145
+ } = useFormItem();
146
+ let limitEl = null;
147
+ const setLimit = (value, oldValue) => {
148
+ if (value === oldValue)
149
+ return;
150
+ if (limitEl) {
151
+ limitEl.innerHTML = `${props.modelValue.toString().length}/${props.maxLength}`;
152
+ }
153
+ };
154
+ const setLimitContainer = (value, oldValue) => {
155
+ if (value === oldValue)
156
+ return;
157
+ if (value) {
158
+ limitEl = document.createElement("div");
159
+ limitEl.className = "y-input__limit-num";
160
+ const el = instance == null ? void 0 : instance.vnode.el;
161
+ el.insertAdjacentElement("afterend", limitEl);
162
+ if (props.maxLength)
163
+ setLimit(props.maxLength);
164
+ } else {
165
+ limitEl && limitEl.remove();
166
+ limitEl = null;
167
+ }
107
168
  };
108
- s(() => e.showWordLimit, m), s(() => e.modelValue, u), s(() => e.maxLength, u);
109
- const L = (l) => t("focus", l), V = (l) => t("click", l), $ = (l) => {
110
- if (n) {
169
+ watch(() => props.showWordLimit, setLimitContainer);
170
+ watch(() => props.modelValue, setLimit);
171
+ watch(() => props.maxLength, setLimit);
172
+ const onFocus = (e) => emit("focus", e);
173
+ const onClick = (e) => emit("click", e);
174
+ const onBlur = (e) => {
175
+ if (parent) {
111
176
  const {
112
- validateWithTrigger: r
113
- } = n;
114
- r("onBlur");
177
+ validateWithTrigger
178
+ } = parent;
179
+ validateWithTrigger("onBlur");
115
180
  }
116
- t("blur", l);
117
- }, N = (l) => {
118
- t("update:modelValue", l.target.value), t("input", l);
119
- }, B = (l) => {
120
- l.keyCode === X && (n != null && n.getProp("enterable") || l.preventDefault(), e.type === "search" && (a == null ? void 0 : a.vnode.el).blur()), t("keypress", l);
181
+ emit("blur", e);
121
182
  };
122
- F(() => {
123
- m(e.showWordLimit), u(e.maxLength);
124
- }), O(() => {
125
- o && o.remove(), o = null;
183
+ const onInput = (e) => {
184
+ emit("update:modelValue", e.target.value);
185
+ emit("input", e);
186
+ };
187
+ const onKeypress = (e) => {
188
+ if (e.keyCode === ENTER_CODE) {
189
+ if (!(parent == null ? void 0 : parent.getProp("enterable"))) {
190
+ e.preventDefault();
191
+ }
192
+ if (props.type === "search") {
193
+ const el = instance == null ? void 0 : instance.vnode.el;
194
+ el.blur();
195
+ }
196
+ }
197
+ emit("keypress", e);
198
+ };
199
+ onMounted(() => {
200
+ setLimitContainer(props.showWordLimit);
201
+ setLimit(props.maxLength);
126
202
  });
127
- const i = P({
128
- get: () => e.modelValue,
129
- set: (l) => t("update:modelValue", l)
203
+ onBeforeUnmount(() => {
204
+ limitEl && limitEl.remove();
205
+ limitEl = null;
206
+ });
207
+ const visible = computed({
208
+ get: () => props.modelValue,
209
+ set: (value) => emit("update:modelValue", value)
130
210
  });
131
211
  return () => {
132
212
  const {
133
- type: l,
134
- rows: r,
135
- align: g,
136
- disabled: C,
137
- maxLength: E,
138
- size: M,
139
- border: _,
140
- readonly: w,
141
- autocomplete: S,
142
- placeholder: z
143
- } = e, y = M || (n == null ? void 0 : n.getProp("size")), p = {
144
- class: Q({
145
- [y]: y,
146
- border: _
213
+ type,
214
+ rows,
215
+ align,
216
+ disabled,
217
+ maxLength,
218
+ size: inputSize,
219
+ border,
220
+ readonly,
221
+ autocomplete,
222
+ placeholder
223
+ } = props;
224
+ const size = inputSize || (parent == null ? void 0 : parent.getProp("size"));
225
+ const attrs = {
226
+ class: bem({
227
+ [size]: size,
228
+ border
147
229
  }),
148
230
  style: {
149
- "text-align": g
231
+ "text-align": align
150
232
  },
151
- disabled: C,
152
- readonly: w,
153
- placeholder: z,
154
- maxlength: E,
155
- onInput: N,
156
- autocomplete: S,
157
- onFocus: L,
158
- onClick: V,
159
- onKeypress: B,
160
- onBlur: $
233
+ disabled,
234
+ readonly,
235
+ placeholder,
236
+ maxlength: maxLength,
237
+ onInput,
238
+ autocomplete,
239
+ onFocus,
240
+ onClick,
241
+ onKeypress,
242
+ onBlur
161
243
  };
162
- return l === "textarea" ? h(v("textarea", x(p, {
163
- rows: r,
164
- "onUpdate:modelValue": (d) => i.value = d
165
- }), null), [[U, i.value]]) : h(v("input", x(p, {
166
- "onUpdate:modelValue": (d) => i.value = d,
167
- type: l
168
- }), null), [[j, i.value]]);
244
+ if (type === "textarea") {
245
+ return withDirectives(createVNode("textarea", mergeProps(attrs, {
246
+ "rows": rows,
247
+ "onUpdate:modelValue": ($event) => visible.value = $event
248
+ }), null), [[vModelText, visible.value]]);
249
+ }
250
+ return withDirectives(createVNode("input", mergeProps(attrs, {
251
+ "onUpdate:modelValue": ($event) => visible.value = $event,
252
+ "type": type
253
+ }), null), [[vModelDynamic, visible.value]]);
169
254
  };
170
255
  }
171
256
  });
172
- f.install = (e) => {
173
- e.component(f.name, f);
257
+ const reset = "";
258
+ const libs = "";
259
+ const font = "";
260
+ const animation = "";
261
+ const theme = "";
262
+ const style = "";
263
+ Input.install = (Vue) => {
264
+ Vue.component(Input.name, Input);
174
265
  };
175
266
  export {
176
- f as default
267
+ Input as default
177
268
  };