rx-compo 1.0.52 → 1.0.54
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.
- package/entry/types/index.d.ts +0 -1
- package/es/components/RxButton/index.js +16 -25
- package/es/components/RxCheckbox/index.js +3712 -0
- package/es/components/RxCheckboxGroup/index.js +6430 -0
- package/es/components/RxDatePicker/index.js +13042 -0
- package/es/components/RxInput/index.js +1560 -0
- package/es/components/RxOption/index.js +8859 -0
- package/es/components/RxRadio/index.js +646 -0
- package/es/components/RxRadioButton/index.js +646 -0
- package/es/components/RxRadioGroup/index.js +1117 -0
- package/es/components/RxScrollbar/index.js +867 -0
- package/es/components/RxSelect/index.js +9022 -0
- package/es/components/RxSelectPlus/index.js +17471 -0
- package/es/components/RxSuperCondition/index.js +8690 -0
- package/es/components/RxTooltip/index.js +2470 -0
- package/es/components/index.js +13 -0
- package/es/index.d.ts +0 -1
- package/es/index.js +0 -1
- package/es/utils/useContext.d.ts +10 -0
- package/es/utils/useContext.js +13 -0
- package/es/utils/useTextOverflow.d.ts +4 -0
- package/es/utils/useTextOverflow.js +13 -0
- package/es/utils/with-install.d.ts +3 -0
- package/es/utils/with-install.js +7 -0
- package/index.esm.js +43171 -1577
- package/index.js +43192 -1585
- package/lib/components/RxButton/index.js +15 -24
- package/lib/components/RxCheckbox/index.js +3717 -0
- package/lib/components/RxCheckboxGroup/index.js +6435 -0
- package/lib/components/RxDatePicker/index.js +13047 -0
- package/lib/components/RxInput/index.js +1565 -0
- package/lib/components/RxOption/index.js +8864 -0
- package/lib/components/RxRadio/index.js +651 -0
- package/lib/components/RxRadioButton/index.js +651 -0
- package/lib/components/RxRadioGroup/index.js +1122 -0
- package/lib/components/RxScrollbar/index.js +872 -0
- package/lib/components/RxSelect/index.js +9027 -0
- package/lib/components/RxSelectPlus/index.js +17476 -0
- package/lib/components/RxSuperCondition/index.js +8695 -0
- package/lib/components/RxTooltip/index.js +2475 -0
- package/lib/components/index.js +91 -0
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/utils/useContext.d.ts +10 -0
- package/lib/utils/useContext.js +18 -0
- package/lib/utils/useTextOverflow.d.ts +4 -0
- package/lib/utils/useTextOverflow.js +17 -0
- package/lib/utils/with-install.d.ts +3 -0
- package/lib/utils/with-install.js +11 -0
- package/package.json +4 -2
- package/theme-chalk/css/index.css +1 -1
- package/theme-chalk/css/rx-button.css +1 -0
- package/theme-chalk/css/rx-checkbox-group.css +1 -0
- package/theme-chalk/css/rx-checkbox.css +1 -0
- package/theme-chalk/css/rx-date-picker.css +0 -0
- package/theme-chalk/css/rx-input.css +1 -0
- package/theme-chalk/css/rx-option.css +1 -0
- package/theme-chalk/css/rx-radio-button.css +0 -0
- package/theme-chalk/css/rx-radio-group.css +1 -0
- package/theme-chalk/css/rx-radio.css +1 -0
- package/theme-chalk/css/rx-scrollbar.css +0 -0
- package/theme-chalk/css/rx-select.css +1 -0
- package/theme-chalk/css/rx-super-condition.css +0 -0
- package/theme-chalk/css/rx-tooltip.css +0 -0
- package/es/components/RxButton/index.d.ts +0 -3
- package/es/components/RxButton/src/index.d.ts +0 -3
- package/es/components/RxButton/src/index.vue.d.ts +0 -10
- package/es/components/index.d.ts +0 -2
- package/lib/components/RxButton/index.d.ts +0 -3
- package/lib/components/RxButton/src/index.d.ts +0 -3
- package/lib/components/RxButton/src/index.vue.d.ts +0 -10
- package/lib/components/index.d.ts +0 -2
- package/types/components/RxButton/index.d.ts +0 -3
- package/types/components/RxButton/src/index.d.ts +0 -3
- package/types/components/RxButton/src/index.vue.d.ts +0 -10
- package/types/components/index.d.ts +0 -2
- package/types/utils/with-install.d.ts +0 -3
|
@@ -0,0 +1,651 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var withInstall$1 = require('rx-compo/lib/utils/with-install');
|
|
6
|
+
var vue = require('vue');
|
|
7
|
+
require('vue-demi');
|
|
8
|
+
|
|
9
|
+
const RxRadioButtonProps = {};
|
|
10
|
+
|
|
11
|
+
var _a;
|
|
12
|
+
const isClient = typeof window !== "undefined";
|
|
13
|
+
isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
|
|
14
|
+
|
|
15
|
+
!!(process.env.NODE_ENV !== "production") ? Object.freeze({}) : {};
|
|
16
|
+
!!(process.env.NODE_ENV !== "production") ? Object.freeze([]) : [];
|
|
17
|
+
const NOOP = () => {
|
|
18
|
+
};
|
|
19
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
20
|
+
const hasOwn = (val, key) => hasOwnProperty.call(val, key);
|
|
21
|
+
const isString = (val) => typeof val === "string";
|
|
22
|
+
const isObject = (val) => val !== null && typeof val === "object";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The inverse of `_.toPairs`; this method returns an object composed
|
|
26
|
+
* from key-value `pairs`.
|
|
27
|
+
*
|
|
28
|
+
* @static
|
|
29
|
+
* @memberOf _
|
|
30
|
+
* @since 4.0.0
|
|
31
|
+
* @category Array
|
|
32
|
+
* @param {Array} pairs The key-value pairs.
|
|
33
|
+
* @returns {Object} Returns the new object.
|
|
34
|
+
* @example
|
|
35
|
+
*
|
|
36
|
+
* _.fromPairs([['a', 1], ['b', 2]]);
|
|
37
|
+
* // => { 'a': 1, 'b': 2 }
|
|
38
|
+
*/
|
|
39
|
+
function fromPairs(pairs) {
|
|
40
|
+
var index = -1,
|
|
41
|
+
length = pairs == null ? 0 : pairs.length,
|
|
42
|
+
result = {};
|
|
43
|
+
|
|
44
|
+
while (++index < length) {
|
|
45
|
+
var pair = pairs[index];
|
|
46
|
+
result[pair[0]] = pair[1];
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const isBoolean = (val) => typeof val === "boolean";
|
|
52
|
+
const isNumber = (val) => typeof val === "number";
|
|
53
|
+
|
|
54
|
+
class ElementPlusError extends Error {
|
|
55
|
+
constructor(m) {
|
|
56
|
+
super(m);
|
|
57
|
+
this.name = "ElementPlusError";
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function debugWarn(scope, message) {
|
|
61
|
+
if (process.env.NODE_ENV !== "production") {
|
|
62
|
+
const error = isString(scope) ? new ElementPlusError(`[${scope}] ${message}`) : scope;
|
|
63
|
+
console.warn(error);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const epPropKey = "__epPropKey";
|
|
68
|
+
const isEpProp = (val) => isObject(val) && !!val[epPropKey];
|
|
69
|
+
const buildProp = (prop, key) => {
|
|
70
|
+
if (!isObject(prop) || isEpProp(prop))
|
|
71
|
+
return prop;
|
|
72
|
+
const { values, required, default: defaultValue, type, validator } = prop;
|
|
73
|
+
const _validator = values || validator ? (val) => {
|
|
74
|
+
let valid = false;
|
|
75
|
+
let allowedValues = [];
|
|
76
|
+
if (values) {
|
|
77
|
+
allowedValues = Array.from(values);
|
|
78
|
+
if (hasOwn(prop, "default")) {
|
|
79
|
+
allowedValues.push(defaultValue);
|
|
80
|
+
}
|
|
81
|
+
valid || (valid = allowedValues.includes(val));
|
|
82
|
+
}
|
|
83
|
+
if (validator)
|
|
84
|
+
valid || (valid = validator(val));
|
|
85
|
+
if (!valid && allowedValues.length > 0) {
|
|
86
|
+
const allowValuesText = [...new Set(allowedValues)].map((value) => JSON.stringify(value)).join(", ");
|
|
87
|
+
vue.warn(`Invalid prop: validation failed${key ? ` for prop "${key}"` : ""}. Expected one of [${allowValuesText}], got value ${JSON.stringify(val)}.`);
|
|
88
|
+
}
|
|
89
|
+
return valid;
|
|
90
|
+
} : void 0;
|
|
91
|
+
const epProp = {
|
|
92
|
+
type,
|
|
93
|
+
required: !!required,
|
|
94
|
+
validator: _validator,
|
|
95
|
+
[epPropKey]: true
|
|
96
|
+
};
|
|
97
|
+
if (hasOwn(prop, "default"))
|
|
98
|
+
epProp.default = defaultValue;
|
|
99
|
+
return epProp;
|
|
100
|
+
};
|
|
101
|
+
const buildProps = (props) => fromPairs(Object.entries(props).map(([key, option]) => [
|
|
102
|
+
key,
|
|
103
|
+
buildProp(option, key)
|
|
104
|
+
]));
|
|
105
|
+
|
|
106
|
+
const withInstall = (main, extra) => {
|
|
107
|
+
main.install = (app) => {
|
|
108
|
+
for (const comp of [main, ...Object.values(extra != null ? extra : {})]) {
|
|
109
|
+
app.component(comp.name, comp);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
if (extra) {
|
|
113
|
+
for (const [key, comp] of Object.entries(extra)) {
|
|
114
|
+
main[key] = comp;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return main;
|
|
118
|
+
};
|
|
119
|
+
const withNoopInstall = (component) => {
|
|
120
|
+
component.install = NOOP;
|
|
121
|
+
return component;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const UPDATE_MODEL_EVENT = "update:modelValue";
|
|
125
|
+
const CHANGE_EVENT = "change";
|
|
126
|
+
|
|
127
|
+
const componentSizes = ["", "default", "small", "large"];
|
|
128
|
+
|
|
129
|
+
const defaultNamespace = "el";
|
|
130
|
+
const statePrefix = "is-";
|
|
131
|
+
const _bem = (namespace, block, blockSuffix, element, modifier) => {
|
|
132
|
+
let cls = `${namespace}-${block}`;
|
|
133
|
+
if (blockSuffix) {
|
|
134
|
+
cls += `-${blockSuffix}`;
|
|
135
|
+
}
|
|
136
|
+
if (element) {
|
|
137
|
+
cls += `__${element}`;
|
|
138
|
+
}
|
|
139
|
+
if (modifier) {
|
|
140
|
+
cls += `--${modifier}`;
|
|
141
|
+
}
|
|
142
|
+
return cls;
|
|
143
|
+
};
|
|
144
|
+
const namespaceContextKey = Symbol("namespaceContextKey");
|
|
145
|
+
const useGetDerivedNamespace = (namespaceOverrides) => {
|
|
146
|
+
const derivedNamespace = namespaceOverrides || vue.inject(namespaceContextKey, vue.ref(defaultNamespace));
|
|
147
|
+
const namespace = vue.computed(() => {
|
|
148
|
+
return vue.unref(derivedNamespace) || defaultNamespace;
|
|
149
|
+
});
|
|
150
|
+
return namespace;
|
|
151
|
+
};
|
|
152
|
+
const useNamespace = (block, namespaceOverrides) => {
|
|
153
|
+
const namespace = useGetDerivedNamespace(namespaceOverrides);
|
|
154
|
+
const b = (blockSuffix = "") => _bem(namespace.value, block, blockSuffix, "", "");
|
|
155
|
+
const e = (element) => element ? _bem(namespace.value, block, "", element, "") : "";
|
|
156
|
+
const m = (modifier) => modifier ? _bem(namespace.value, block, "", "", modifier) : "";
|
|
157
|
+
const be = (blockSuffix, element) => blockSuffix && element ? _bem(namespace.value, block, blockSuffix, element, "") : "";
|
|
158
|
+
const em = (element, modifier) => element && modifier ? _bem(namespace.value, block, "", element, modifier) : "";
|
|
159
|
+
const bm = (blockSuffix, modifier) => blockSuffix && modifier ? _bem(namespace.value, block, blockSuffix, "", modifier) : "";
|
|
160
|
+
const bem = (blockSuffix, element, modifier) => blockSuffix && element && modifier ? _bem(namespace.value, block, blockSuffix, element, modifier) : "";
|
|
161
|
+
const is = (name, ...args) => {
|
|
162
|
+
const state = args.length >= 1 ? args[0] : true;
|
|
163
|
+
return name && state ? `${statePrefix}${name}` : "";
|
|
164
|
+
};
|
|
165
|
+
const cssVar = (object) => {
|
|
166
|
+
const styles = {};
|
|
167
|
+
for (const key in object) {
|
|
168
|
+
if (object[key]) {
|
|
169
|
+
styles[`--${namespace.value}-${key}`] = object[key];
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return styles;
|
|
173
|
+
};
|
|
174
|
+
const cssVarBlock = (object) => {
|
|
175
|
+
const styles = {};
|
|
176
|
+
for (const key in object) {
|
|
177
|
+
if (object[key]) {
|
|
178
|
+
styles[`--${namespace.value}-${block}-${key}`] = object[key];
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return styles;
|
|
182
|
+
};
|
|
183
|
+
const cssVarName = (name) => `--${namespace.value}-${name}`;
|
|
184
|
+
const cssVarBlockName = (name) => `--${namespace.value}-${block}-${name}`;
|
|
185
|
+
return {
|
|
186
|
+
namespace,
|
|
187
|
+
b,
|
|
188
|
+
e,
|
|
189
|
+
m,
|
|
190
|
+
be,
|
|
191
|
+
em,
|
|
192
|
+
bm,
|
|
193
|
+
bem,
|
|
194
|
+
is,
|
|
195
|
+
cssVar,
|
|
196
|
+
cssVarName,
|
|
197
|
+
cssVarBlock,
|
|
198
|
+
cssVarBlockName
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
const useProp = (name) => {
|
|
203
|
+
const vm = vue.getCurrentInstance();
|
|
204
|
+
return vue.computed(() => {
|
|
205
|
+
var _a, _b;
|
|
206
|
+
return (_b = (_a = vm == null ? void 0 : vm.proxy) == null ? void 0 : _a.$props) == null ? void 0 : _b[name];
|
|
207
|
+
});
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
const defaultIdInjection = {
|
|
211
|
+
prefix: Math.floor(Math.random() * 1e4),
|
|
212
|
+
current: 0
|
|
213
|
+
};
|
|
214
|
+
const ID_INJECTION_KEY = Symbol("elIdInjection");
|
|
215
|
+
const useIdInjection = () => {
|
|
216
|
+
return vue.getCurrentInstance() ? vue.inject(ID_INJECTION_KEY, defaultIdInjection) : defaultIdInjection;
|
|
217
|
+
};
|
|
218
|
+
const useId = (deterministicId) => {
|
|
219
|
+
const idInjection = useIdInjection();
|
|
220
|
+
if (!isClient && idInjection === defaultIdInjection) {
|
|
221
|
+
debugWarn("IdInjection", `Looks like you are using server rendering, you must provide a id provider to ensure the hydration process to be succeed
|
|
222
|
+
usage: app.provide(ID_INJECTION_KEY, {
|
|
223
|
+
prefix: number,
|
|
224
|
+
current: number,
|
|
225
|
+
})`);
|
|
226
|
+
}
|
|
227
|
+
const namespace = useGetDerivedNamespace();
|
|
228
|
+
const idRef = vue.computed(() => vue.unref(deterministicId) || `${namespace.value}-id-${idInjection.prefix}-${idInjection.current++}`);
|
|
229
|
+
return idRef;
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
const useSizeProp = buildProp({
|
|
233
|
+
type: String,
|
|
234
|
+
values: componentSizes,
|
|
235
|
+
required: false
|
|
236
|
+
});
|
|
237
|
+
const SIZE_INJECTION_KEY = Symbol("size");
|
|
238
|
+
const useGlobalSize = () => {
|
|
239
|
+
const injectedSize = vue.inject(SIZE_INJECTION_KEY, {});
|
|
240
|
+
return vue.computed(() => {
|
|
241
|
+
return vue.unref(injectedSize.size) || "";
|
|
242
|
+
});
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
var _export_sfc = (sfc, props) => {
|
|
246
|
+
const target = sfc.__vccOpts || sfc;
|
|
247
|
+
for (const [key, val] of props) {
|
|
248
|
+
target[key] = val;
|
|
249
|
+
}
|
|
250
|
+
return target;
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
const formContextKey = Symbol("formContextKey");
|
|
254
|
+
const formItemContextKey = Symbol("formItemContextKey");
|
|
255
|
+
|
|
256
|
+
const useFormSize = (fallback, ignore = {}) => {
|
|
257
|
+
const emptyRef = vue.ref(void 0);
|
|
258
|
+
const size = ignore.prop ? emptyRef : useProp("size");
|
|
259
|
+
const globalConfig = ignore.global ? emptyRef : useGlobalSize();
|
|
260
|
+
const form = ignore.form ? { size: void 0 } : vue.inject(formContextKey, void 0);
|
|
261
|
+
const formItem = ignore.formItem ? { size: void 0 } : vue.inject(formItemContextKey, void 0);
|
|
262
|
+
return vue.computed(() => size.value || vue.unref(fallback) || (formItem == null ? void 0 : formItem.size) || (form == null ? void 0 : form.size) || globalConfig.value || "");
|
|
263
|
+
};
|
|
264
|
+
const useFormDisabled = (fallback) => {
|
|
265
|
+
const disabled = useProp("disabled");
|
|
266
|
+
const form = vue.inject(formContextKey, void 0);
|
|
267
|
+
return vue.computed(() => disabled.value || vue.unref(fallback) || (form == null ? void 0 : form.disabled) || false);
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
const useFormItem = () => {
|
|
271
|
+
const form = vue.inject(formContextKey, void 0);
|
|
272
|
+
const formItem = vue.inject(formItemContextKey, void 0);
|
|
273
|
+
return {
|
|
274
|
+
form,
|
|
275
|
+
formItem
|
|
276
|
+
};
|
|
277
|
+
};
|
|
278
|
+
const useFormItemInputId = (props, {
|
|
279
|
+
formItemContext,
|
|
280
|
+
disableIdGeneration,
|
|
281
|
+
disableIdManagement
|
|
282
|
+
}) => {
|
|
283
|
+
if (!disableIdGeneration) {
|
|
284
|
+
disableIdGeneration = vue.ref(false);
|
|
285
|
+
}
|
|
286
|
+
if (!disableIdManagement) {
|
|
287
|
+
disableIdManagement = vue.ref(false);
|
|
288
|
+
}
|
|
289
|
+
const inputId = vue.ref();
|
|
290
|
+
let idUnwatch = void 0;
|
|
291
|
+
const isLabeledByFormItem = vue.computed(() => {
|
|
292
|
+
var _a;
|
|
293
|
+
return !!(!props.label && formItemContext && formItemContext.inputIds && ((_a = formItemContext.inputIds) == null ? void 0 : _a.length) <= 1);
|
|
294
|
+
});
|
|
295
|
+
vue.onMounted(() => {
|
|
296
|
+
idUnwatch = vue.watch([vue.toRef(props, "id"), disableIdGeneration], ([id, disableIdGeneration2]) => {
|
|
297
|
+
const newId = id != null ? id : !disableIdGeneration2 ? useId().value : void 0;
|
|
298
|
+
if (newId !== inputId.value) {
|
|
299
|
+
if (formItemContext == null ? void 0 : formItemContext.removeInputId) {
|
|
300
|
+
inputId.value && formItemContext.removeInputId(inputId.value);
|
|
301
|
+
if (!(disableIdManagement == null ? void 0 : disableIdManagement.value) && !disableIdGeneration2 && newId) {
|
|
302
|
+
formItemContext.addInputId(newId);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
inputId.value = newId;
|
|
306
|
+
}
|
|
307
|
+
}, { immediate: true });
|
|
308
|
+
});
|
|
309
|
+
vue.onUnmounted(() => {
|
|
310
|
+
idUnwatch && idUnwatch();
|
|
311
|
+
if (formItemContext == null ? void 0 : formItemContext.removeInputId) {
|
|
312
|
+
inputId.value && formItemContext.removeInputId(inputId.value);
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
return {
|
|
316
|
+
isLabeledByFormItem,
|
|
317
|
+
inputId
|
|
318
|
+
};
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
const radioPropsBase = buildProps({
|
|
322
|
+
size: useSizeProp,
|
|
323
|
+
disabled: Boolean,
|
|
324
|
+
label: {
|
|
325
|
+
type: [String, Number, Boolean],
|
|
326
|
+
default: ""
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
const radioProps = buildProps({
|
|
330
|
+
...radioPropsBase,
|
|
331
|
+
modelValue: {
|
|
332
|
+
type: [String, Number, Boolean],
|
|
333
|
+
default: ""
|
|
334
|
+
},
|
|
335
|
+
name: {
|
|
336
|
+
type: String,
|
|
337
|
+
default: ""
|
|
338
|
+
},
|
|
339
|
+
border: Boolean
|
|
340
|
+
});
|
|
341
|
+
const radioEmits = {
|
|
342
|
+
[UPDATE_MODEL_EVENT]: (val) => isString(val) || isNumber(val) || isBoolean(val),
|
|
343
|
+
[CHANGE_EVENT]: (val) => isString(val) || isNumber(val) || isBoolean(val)
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
const radioGroupKey = Symbol("radioGroupKey");
|
|
347
|
+
|
|
348
|
+
const useRadio = (props, emit) => {
|
|
349
|
+
const radioRef = vue.ref();
|
|
350
|
+
const radioGroup = vue.inject(radioGroupKey, void 0);
|
|
351
|
+
const isGroup = vue.computed(() => !!radioGroup);
|
|
352
|
+
const modelValue = vue.computed({
|
|
353
|
+
get() {
|
|
354
|
+
return isGroup.value ? radioGroup.modelValue : props.modelValue;
|
|
355
|
+
},
|
|
356
|
+
set(val) {
|
|
357
|
+
if (isGroup.value) {
|
|
358
|
+
radioGroup.changeEvent(val);
|
|
359
|
+
} else {
|
|
360
|
+
emit && emit(UPDATE_MODEL_EVENT, val);
|
|
361
|
+
}
|
|
362
|
+
radioRef.value.checked = props.modelValue === props.label;
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
const size = useFormSize(vue.computed(() => radioGroup == null ? void 0 : radioGroup.size));
|
|
366
|
+
const disabled = useFormDisabled(vue.computed(() => radioGroup == null ? void 0 : radioGroup.disabled));
|
|
367
|
+
const focus = vue.ref(false);
|
|
368
|
+
const tabIndex = vue.computed(() => {
|
|
369
|
+
return disabled.value || isGroup.value && modelValue.value !== props.label ? -1 : 0;
|
|
370
|
+
});
|
|
371
|
+
return {
|
|
372
|
+
radioRef,
|
|
373
|
+
isGroup,
|
|
374
|
+
radioGroup,
|
|
375
|
+
focus,
|
|
376
|
+
size,
|
|
377
|
+
disabled,
|
|
378
|
+
tabIndex,
|
|
379
|
+
modelValue
|
|
380
|
+
};
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
const _hoisted_1$2 = ["value", "name", "disabled"];
|
|
384
|
+
const __default__$2 = vue.defineComponent({
|
|
385
|
+
name: "ElRadio"
|
|
386
|
+
});
|
|
387
|
+
const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
388
|
+
...__default__$2,
|
|
389
|
+
props: radioProps,
|
|
390
|
+
emits: radioEmits,
|
|
391
|
+
setup(__props, { emit }) {
|
|
392
|
+
const props = __props;
|
|
393
|
+
const ns = useNamespace("radio");
|
|
394
|
+
const { radioRef, radioGroup, focus, size, disabled, modelValue } = useRadio(props, emit);
|
|
395
|
+
function handleChange() {
|
|
396
|
+
vue.nextTick(() => emit("change", modelValue.value));
|
|
397
|
+
}
|
|
398
|
+
return (_ctx, _cache) => {
|
|
399
|
+
var _a;
|
|
400
|
+
return vue.openBlock(), vue.createElementBlock("label", {
|
|
401
|
+
class: vue.normalizeClass([
|
|
402
|
+
vue.unref(ns).b(),
|
|
403
|
+
vue.unref(ns).is("disabled", vue.unref(disabled)),
|
|
404
|
+
vue.unref(ns).is("focus", vue.unref(focus)),
|
|
405
|
+
vue.unref(ns).is("bordered", _ctx.border),
|
|
406
|
+
vue.unref(ns).is("checked", vue.unref(modelValue) === _ctx.label),
|
|
407
|
+
vue.unref(ns).m(vue.unref(size))
|
|
408
|
+
])
|
|
409
|
+
}, [
|
|
410
|
+
vue.createElementVNode("span", {
|
|
411
|
+
class: vue.normalizeClass([
|
|
412
|
+
vue.unref(ns).e("input"),
|
|
413
|
+
vue.unref(ns).is("disabled", vue.unref(disabled)),
|
|
414
|
+
vue.unref(ns).is("checked", vue.unref(modelValue) === _ctx.label)
|
|
415
|
+
])
|
|
416
|
+
}, [
|
|
417
|
+
vue.withDirectives(vue.createElementVNode("input", {
|
|
418
|
+
ref_key: "radioRef",
|
|
419
|
+
ref: radioRef,
|
|
420
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => vue.isRef(modelValue) ? modelValue.value = $event : null),
|
|
421
|
+
class: vue.normalizeClass(vue.unref(ns).e("original")),
|
|
422
|
+
value: _ctx.label,
|
|
423
|
+
name: _ctx.name || ((_a = vue.unref(radioGroup)) == null ? void 0 : _a.name),
|
|
424
|
+
disabled: vue.unref(disabled),
|
|
425
|
+
type: "radio",
|
|
426
|
+
onFocus: _cache[1] || (_cache[1] = ($event) => focus.value = true),
|
|
427
|
+
onBlur: _cache[2] || (_cache[2] = ($event) => focus.value = false),
|
|
428
|
+
onChange: handleChange
|
|
429
|
+
}, null, 42, _hoisted_1$2), [
|
|
430
|
+
[vue.vModelRadio, vue.unref(modelValue)]
|
|
431
|
+
]),
|
|
432
|
+
vue.createElementVNode("span", {
|
|
433
|
+
class: vue.normalizeClass(vue.unref(ns).e("inner"))
|
|
434
|
+
}, null, 2)
|
|
435
|
+
], 2),
|
|
436
|
+
vue.createElementVNode("span", {
|
|
437
|
+
class: vue.normalizeClass(vue.unref(ns).e("label")),
|
|
438
|
+
onKeydown: _cache[3] || (_cache[3] = vue.withModifiers(() => {
|
|
439
|
+
}, ["stop"]))
|
|
440
|
+
}, [
|
|
441
|
+
vue.renderSlot(_ctx.$slots, "default", {}, () => [
|
|
442
|
+
vue.createTextVNode(vue.toDisplayString(_ctx.label), 1)
|
|
443
|
+
])
|
|
444
|
+
], 34)
|
|
445
|
+
], 2);
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
});
|
|
449
|
+
var Radio = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/radio/src/radio.vue"]]);
|
|
450
|
+
|
|
451
|
+
const radioButtonProps = buildProps({
|
|
452
|
+
...radioPropsBase,
|
|
453
|
+
name: {
|
|
454
|
+
type: String,
|
|
455
|
+
default: ""
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
const _hoisted_1$1 = ["value", "name", "disabled"];
|
|
460
|
+
const __default__$1 = vue.defineComponent({
|
|
461
|
+
name: "ElRadioButton"
|
|
462
|
+
});
|
|
463
|
+
const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
464
|
+
...__default__$1,
|
|
465
|
+
props: radioButtonProps,
|
|
466
|
+
setup(__props) {
|
|
467
|
+
const props = __props;
|
|
468
|
+
const ns = useNamespace("radio");
|
|
469
|
+
const { radioRef, focus, size, disabled, modelValue, radioGroup } = useRadio(props);
|
|
470
|
+
const activeStyle = vue.computed(() => {
|
|
471
|
+
return {
|
|
472
|
+
backgroundColor: (radioGroup == null ? void 0 : radioGroup.fill) || "",
|
|
473
|
+
borderColor: (radioGroup == null ? void 0 : radioGroup.fill) || "",
|
|
474
|
+
boxShadow: (radioGroup == null ? void 0 : radioGroup.fill) ? `-1px 0 0 0 ${radioGroup.fill}` : "",
|
|
475
|
+
color: (radioGroup == null ? void 0 : radioGroup.textColor) || ""
|
|
476
|
+
};
|
|
477
|
+
});
|
|
478
|
+
return (_ctx, _cache) => {
|
|
479
|
+
var _a;
|
|
480
|
+
return vue.openBlock(), vue.createElementBlock("label", {
|
|
481
|
+
class: vue.normalizeClass([
|
|
482
|
+
vue.unref(ns).b("button"),
|
|
483
|
+
vue.unref(ns).is("active", vue.unref(modelValue) === _ctx.label),
|
|
484
|
+
vue.unref(ns).is("disabled", vue.unref(disabled)),
|
|
485
|
+
vue.unref(ns).is("focus", vue.unref(focus)),
|
|
486
|
+
vue.unref(ns).bm("button", vue.unref(size))
|
|
487
|
+
])
|
|
488
|
+
}, [
|
|
489
|
+
vue.withDirectives(vue.createElementVNode("input", {
|
|
490
|
+
ref_key: "radioRef",
|
|
491
|
+
ref: radioRef,
|
|
492
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => vue.isRef(modelValue) ? modelValue.value = $event : null),
|
|
493
|
+
class: vue.normalizeClass(vue.unref(ns).be("button", "original-radio")),
|
|
494
|
+
value: _ctx.label,
|
|
495
|
+
type: "radio",
|
|
496
|
+
name: _ctx.name || ((_a = vue.unref(radioGroup)) == null ? void 0 : _a.name),
|
|
497
|
+
disabled: vue.unref(disabled),
|
|
498
|
+
onFocus: _cache[1] || (_cache[1] = ($event) => focus.value = true),
|
|
499
|
+
onBlur: _cache[2] || (_cache[2] = ($event) => focus.value = false)
|
|
500
|
+
}, null, 42, _hoisted_1$1), [
|
|
501
|
+
[vue.vModelRadio, vue.unref(modelValue)]
|
|
502
|
+
]),
|
|
503
|
+
vue.createElementVNode("span", {
|
|
504
|
+
class: vue.normalizeClass(vue.unref(ns).be("button", "inner")),
|
|
505
|
+
style: vue.normalizeStyle(vue.unref(modelValue) === _ctx.label ? vue.unref(activeStyle) : {}),
|
|
506
|
+
onKeydown: _cache[3] || (_cache[3] = vue.withModifiers(() => {
|
|
507
|
+
}, ["stop"]))
|
|
508
|
+
}, [
|
|
509
|
+
vue.renderSlot(_ctx.$slots, "default", {}, () => [
|
|
510
|
+
vue.createTextVNode(vue.toDisplayString(_ctx.label), 1)
|
|
511
|
+
])
|
|
512
|
+
], 38)
|
|
513
|
+
], 2);
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
});
|
|
517
|
+
var RadioButton = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/radio/src/radio-button.vue"]]);
|
|
518
|
+
|
|
519
|
+
const radioGroupProps = buildProps({
|
|
520
|
+
id: {
|
|
521
|
+
type: String,
|
|
522
|
+
default: void 0
|
|
523
|
+
},
|
|
524
|
+
size: useSizeProp,
|
|
525
|
+
disabled: Boolean,
|
|
526
|
+
modelValue: {
|
|
527
|
+
type: [String, Number, Boolean],
|
|
528
|
+
default: ""
|
|
529
|
+
},
|
|
530
|
+
fill: {
|
|
531
|
+
type: String,
|
|
532
|
+
default: ""
|
|
533
|
+
},
|
|
534
|
+
label: {
|
|
535
|
+
type: String,
|
|
536
|
+
default: void 0
|
|
537
|
+
},
|
|
538
|
+
textColor: {
|
|
539
|
+
type: String,
|
|
540
|
+
default: ""
|
|
541
|
+
},
|
|
542
|
+
name: {
|
|
543
|
+
type: String,
|
|
544
|
+
default: void 0
|
|
545
|
+
},
|
|
546
|
+
validateEvent: {
|
|
547
|
+
type: Boolean,
|
|
548
|
+
default: true
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
const radioGroupEmits = radioEmits;
|
|
552
|
+
|
|
553
|
+
const _hoisted_1 = ["id", "aria-label", "aria-labelledby"];
|
|
554
|
+
const __default__ = vue.defineComponent({
|
|
555
|
+
name: "ElRadioGroup"
|
|
556
|
+
});
|
|
557
|
+
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
558
|
+
...__default__,
|
|
559
|
+
props: radioGroupProps,
|
|
560
|
+
emits: radioGroupEmits,
|
|
561
|
+
setup(__props, { emit }) {
|
|
562
|
+
const props = __props;
|
|
563
|
+
const ns = useNamespace("radio");
|
|
564
|
+
const radioId = useId();
|
|
565
|
+
const radioGroupRef = vue.ref();
|
|
566
|
+
const { formItem } = useFormItem();
|
|
567
|
+
const { inputId: groupId, isLabeledByFormItem } = useFormItemInputId(props, {
|
|
568
|
+
formItemContext: formItem
|
|
569
|
+
});
|
|
570
|
+
const changeEvent = (value) => {
|
|
571
|
+
emit(UPDATE_MODEL_EVENT, value);
|
|
572
|
+
vue.nextTick(() => emit("change", value));
|
|
573
|
+
};
|
|
574
|
+
vue.onMounted(() => {
|
|
575
|
+
const radios = radioGroupRef.value.querySelectorAll("[type=radio]");
|
|
576
|
+
const firstLabel = radios[0];
|
|
577
|
+
if (!Array.from(radios).some((radio) => radio.checked) && firstLabel) {
|
|
578
|
+
firstLabel.tabIndex = 0;
|
|
579
|
+
}
|
|
580
|
+
});
|
|
581
|
+
const name = vue.computed(() => {
|
|
582
|
+
return props.name || radioId.value;
|
|
583
|
+
});
|
|
584
|
+
vue.provide(radioGroupKey, vue.reactive({
|
|
585
|
+
...vue.toRefs(props),
|
|
586
|
+
changeEvent,
|
|
587
|
+
name
|
|
588
|
+
}));
|
|
589
|
+
vue.watch(() => props.modelValue, () => {
|
|
590
|
+
if (props.validateEvent) {
|
|
591
|
+
formItem == null ? void 0 : formItem.validate("change").catch((err) => debugWarn(err));
|
|
592
|
+
}
|
|
593
|
+
});
|
|
594
|
+
return (_ctx, _cache) => {
|
|
595
|
+
return vue.openBlock(), vue.createElementBlock("div", {
|
|
596
|
+
id: vue.unref(groupId),
|
|
597
|
+
ref_key: "radioGroupRef",
|
|
598
|
+
ref: radioGroupRef,
|
|
599
|
+
class: vue.normalizeClass(vue.unref(ns).b("group")),
|
|
600
|
+
role: "radiogroup",
|
|
601
|
+
"aria-label": !vue.unref(isLabeledByFormItem) ? _ctx.label || "radio-group" : void 0,
|
|
602
|
+
"aria-labelledby": vue.unref(isLabeledByFormItem) ? vue.unref(formItem).labelId : void 0
|
|
603
|
+
}, [
|
|
604
|
+
vue.renderSlot(_ctx.$slots, "default")
|
|
605
|
+
], 10, _hoisted_1);
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
});
|
|
609
|
+
var RadioGroup = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/radio/src/radio-group.vue"]]);
|
|
610
|
+
|
|
611
|
+
withInstall(Radio, {
|
|
612
|
+
RadioButton,
|
|
613
|
+
RadioGroup
|
|
614
|
+
});
|
|
615
|
+
withNoopInstall(RadioGroup);
|
|
616
|
+
const ElRadioButton = withNoopInstall(RadioButton);
|
|
617
|
+
|
|
618
|
+
var script = vue.defineComponent({
|
|
619
|
+
name: 'RxRadioButton',
|
|
620
|
+
components: {
|
|
621
|
+
ElRadioButton
|
|
622
|
+
},
|
|
623
|
+
props: RxRadioButtonProps,
|
|
624
|
+
setup() {
|
|
625
|
+
return {};
|
|
626
|
+
}
|
|
627
|
+
});
|
|
628
|
+
|
|
629
|
+
function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
630
|
+
const _component_el_radio_button = vue.resolveComponent("el-radio-button");
|
|
631
|
+
|
|
632
|
+
return (vue.openBlock(), vue.createBlock(_component_el_radio_button, vue.mergeProps(_ctx.$props, { class: "rx-radio-button" }), vue.createSlots({ _: 2 /* DYNAMIC */ }, [
|
|
633
|
+
(_ctx.$slots.default)
|
|
634
|
+
? {
|
|
635
|
+
name: "default",
|
|
636
|
+
fn: vue.withCtx(() => [
|
|
637
|
+
vue.renderSlot(_ctx.$slots, "default")
|
|
638
|
+
]),
|
|
639
|
+
key: "0"
|
|
640
|
+
}
|
|
641
|
+
: undefined
|
|
642
|
+
]), 1040 /* FULL_PROPS, DYNAMIC_SLOTS */))
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
script.render = render;
|
|
646
|
+
script.__file = "packages/components/RxRadioButton/src/index.vue";
|
|
647
|
+
|
|
648
|
+
const RxRadioButton = withInstall$1.withInstall(script);
|
|
649
|
+
|
|
650
|
+
exports.RxRadioButton = RxRadioButton;
|
|
651
|
+
exports["default"] = RxRadioButton;
|