vueless 1.2.8-beta.5 → 1.2.8-beta.6
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/package.json +1 -1
- package/ui.form-checkbox/tests/UCheckbox.test.ts +2 -2
- package/ui.form-checkbox-group/tests/UCheckboxGroup.test.ts +2 -2
- package/ui.form-input/tests/UInput.test.ts +2 -2
- package/ui.form-input-file/tests/UInputFile.test.ts +2 -2
- package/ui.form-label/ULabel.vue +10 -4
- package/ui.form-label/tests/ULabel.test.ts +29 -12
- package/ui.form-radio/tests/URadio.test.ts +2 -2
- package/ui.form-radio-group/tests/URadioGroup.test.ts +2 -2
- package/ui.form-select/USelect.vue +0 -1
- package/ui.form-textarea/tests/UTextarea.test.ts +2 -2
- package/utils/theme.ts +1 -1
package/package.json
CHANGED
|
@@ -261,7 +261,7 @@ describe("UCheckbox.vue", () => {
|
|
|
261
261
|
});
|
|
262
262
|
|
|
263
263
|
const labelComponent = component.getComponent(ULabel);
|
|
264
|
-
const labelElement = labelComponent.find("label");
|
|
264
|
+
const labelElement = labelComponent.find("[vl-child-key='label']");
|
|
265
265
|
|
|
266
266
|
expect(labelElement.text()).toBe(customLabelContent);
|
|
267
267
|
});
|
|
@@ -279,7 +279,7 @@ describe("UCheckbox.vue", () => {
|
|
|
279
279
|
});
|
|
280
280
|
|
|
281
281
|
const labelComponent = component.getComponent(ULabel);
|
|
282
|
-
const labelElement = labelComponent.find("label");
|
|
282
|
+
const labelElement = labelComponent.find("[vl-child-key='label']");
|
|
283
283
|
|
|
284
284
|
expect(labelElement.text()).toBe(`Modified ${defaultLabel}`);
|
|
285
285
|
});
|
|
@@ -201,7 +201,7 @@ describe("UCheckboxGroup.vue", () => {
|
|
|
201
201
|
});
|
|
202
202
|
|
|
203
203
|
const labelComponent = component.getComponent(ULabel);
|
|
204
|
-
const labelElement = labelComponent.find("label");
|
|
204
|
+
const labelElement = labelComponent.find("[vl-child-key='label']");
|
|
205
205
|
|
|
206
206
|
expect(labelElement.text()).toBe(customLabelContent);
|
|
207
207
|
});
|
|
@@ -219,7 +219,7 @@ describe("UCheckboxGroup.vue", () => {
|
|
|
219
219
|
});
|
|
220
220
|
|
|
221
221
|
const labelComponent = component.getComponent(ULabel);
|
|
222
|
-
const labelElement = labelComponent.find("label");
|
|
222
|
+
const labelElement = labelComponent.find("[vl-child-key='label']");
|
|
223
223
|
|
|
224
224
|
expect(labelElement.text()).toBe(`Modified ${defaultLabel}`);
|
|
225
225
|
});
|
|
@@ -318,7 +318,7 @@ describe("UInput.vue", () => {
|
|
|
318
318
|
});
|
|
319
319
|
|
|
320
320
|
const labelComponent = component.getComponent(ULabel);
|
|
321
|
-
const labelElement = labelComponent.find("label");
|
|
321
|
+
const labelElement = labelComponent.find("[vl-child-key='label']");
|
|
322
322
|
|
|
323
323
|
expect(labelElement.text()).toBe(customLabelContent);
|
|
324
324
|
});
|
|
@@ -336,7 +336,7 @@ describe("UInput.vue", () => {
|
|
|
336
336
|
});
|
|
337
337
|
|
|
338
338
|
const labelComponent = component.getComponent(ULabel);
|
|
339
|
-
const labelElement = labelComponent.find("label");
|
|
339
|
+
const labelElement = labelComponent.find("[vl-child-key='label']");
|
|
340
340
|
|
|
341
341
|
expect(labelElement.text()).toBe(`Modified ${defaultLabel}`);
|
|
342
342
|
});
|
|
@@ -269,7 +269,7 @@ describe("UInputFile.vue", () => {
|
|
|
269
269
|
});
|
|
270
270
|
|
|
271
271
|
const labelComponent = component.getComponent(ULabel);
|
|
272
|
-
const labelElement = labelComponent.find("label");
|
|
272
|
+
const labelElement = labelComponent.find("[vl-child-key='label']");
|
|
273
273
|
|
|
274
274
|
expect(labelElement.text()).toBe(customLabelContent);
|
|
275
275
|
});
|
|
@@ -287,7 +287,7 @@ describe("UInputFile.vue", () => {
|
|
|
287
287
|
});
|
|
288
288
|
|
|
289
289
|
const labelComponent = component.getComponent(ULabel);
|
|
290
|
-
const labelElement = labelComponent.find("label");
|
|
290
|
+
const labelElement = labelComponent.find("[vl-child-key='label']");
|
|
291
291
|
|
|
292
292
|
expect(labelElement.text()).toBe(`Custom ${defaultLabel}`);
|
|
293
293
|
});
|
package/ui.form-label/ULabel.vue
CHANGED
|
@@ -33,6 +33,10 @@ const isHorizontalPlacement = computed(() => {
|
|
|
33
33
|
return props.align === PLACEMENT.left || props.align === PLACEMENT.right;
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
+
const tag = computed(() => {
|
|
37
|
+
return props.for ? "label" : "div";
|
|
38
|
+
});
|
|
39
|
+
|
|
36
40
|
const isTopWithDescPlacement = computed(() => {
|
|
37
41
|
return props.align === PLACEMENT.topWithDesc;
|
|
38
42
|
});
|
|
@@ -95,7 +99,8 @@ const { getDataTest, wrapperAttrs, contentAttrs, labelAttrs, descriptionAttrs, e
|
|
|
95
99
|
|
|
96
100
|
<!-- `v-bind` isn't assigned, because the div is system -->
|
|
97
101
|
<div v-if="label || hasSlotContent(slots['label'], { label }) || error || description">
|
|
98
|
-
<
|
|
102
|
+
<component
|
|
103
|
+
:is="tag"
|
|
99
104
|
v-if="label || hasSlotContent(slots['label'], { label })"
|
|
100
105
|
ref="label"
|
|
101
106
|
:for="props.for"
|
|
@@ -110,7 +115,7 @@ const { getDataTest, wrapperAttrs, contentAttrs, labelAttrs, descriptionAttrs, e
|
|
|
110
115
|
<slot name="label" :label="label">
|
|
111
116
|
{{ label }}
|
|
112
117
|
</slot>
|
|
113
|
-
</
|
|
118
|
+
</component>
|
|
114
119
|
|
|
115
120
|
<div
|
|
116
121
|
v-if="isShownError"
|
|
@@ -132,7 +137,8 @@ const { getDataTest, wrapperAttrs, contentAttrs, labelAttrs, descriptionAttrs, e
|
|
|
132
137
|
</div>
|
|
133
138
|
|
|
134
139
|
<div v-else ref="wrapper" v-bind="wrapperAttrs">
|
|
135
|
-
<
|
|
140
|
+
<component
|
|
141
|
+
:is="tag"
|
|
136
142
|
v-if="label || hasSlotContent(slots['label'], { label })"
|
|
137
143
|
v-bind="labelAttrs"
|
|
138
144
|
ref="label"
|
|
@@ -147,7 +153,7 @@ const { getDataTest, wrapperAttrs, contentAttrs, labelAttrs, descriptionAttrs, e
|
|
|
147
153
|
<slot name="label" :label="label">
|
|
148
154
|
{{ label }}
|
|
149
155
|
</slot>
|
|
150
|
-
</
|
|
156
|
+
</component>
|
|
151
157
|
|
|
152
158
|
<div v-bind="contentAttrs" :data-test="getDataTest('content')">
|
|
153
159
|
<!-- @slot Use it to add label content. -->
|
|
@@ -16,7 +16,7 @@ describe("ULabel.vue", () => {
|
|
|
16
16
|
},
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
expect(component.
|
|
19
|
+
expect(component.find("[vl-key='label']").text()).toContain(label);
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
it("For – applied to label element", () => {
|
|
@@ -29,7 +29,7 @@ describe("ULabel.vue", () => {
|
|
|
29
29
|
},
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
expect(component.
|
|
32
|
+
expect(component.find("[vl-key='label']").attributes("for")).toBe(forId);
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
it("For – applies interactive classes when true", () => {
|
|
@@ -42,7 +42,7 @@ describe("ULabel.vue", () => {
|
|
|
42
42
|
},
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
-
expect(component.
|
|
45
|
+
expect(component.find("[vl-key='label']").attributes("class")).toContain(interactiveClasses);
|
|
46
46
|
});
|
|
47
47
|
|
|
48
48
|
it("Description – description is rendered with provided text", () => {
|
|
@@ -133,7 +133,7 @@ describe("ULabel.vue", () => {
|
|
|
133
133
|
},
|
|
134
134
|
});
|
|
135
135
|
|
|
136
|
-
expect(component.
|
|
136
|
+
expect(component.find("[vl-key='label']").attributes("class")).toContain(expectedClass);
|
|
137
137
|
});
|
|
138
138
|
});
|
|
139
139
|
|
|
@@ -148,7 +148,7 @@ describe("ULabel.vue", () => {
|
|
|
148
148
|
});
|
|
149
149
|
|
|
150
150
|
expect(component.attributes("class")).toContain(disabledClasses);
|
|
151
|
-
expect(component.
|
|
151
|
+
expect(component.find("[vl-key='label']").attributes("class")).toContain(disabledClasses);
|
|
152
152
|
});
|
|
153
153
|
|
|
154
154
|
it("Disabled – does not apply disabled class when false", () => {
|
|
@@ -162,7 +162,7 @@ describe("ULabel.vue", () => {
|
|
|
162
162
|
});
|
|
163
163
|
|
|
164
164
|
expect(component.attributes("class")).not.toContain(disabledClasses);
|
|
165
|
-
expect(component.
|
|
165
|
+
expect(component.find("[vl-key='label']").attributes("class")).not.toContain(disabledClasses);
|
|
166
166
|
});
|
|
167
167
|
|
|
168
168
|
it("Disabled – interactive class is not applied when disabled true", () => {
|
|
@@ -176,7 +176,9 @@ describe("ULabel.vue", () => {
|
|
|
176
176
|
},
|
|
177
177
|
});
|
|
178
178
|
|
|
179
|
-
expect(component.
|
|
179
|
+
expect(component.find("[vl-key='label']").attributes("class")).not.toContain(
|
|
180
|
+
interactiveClasses,
|
|
181
|
+
);
|
|
180
182
|
});
|
|
181
183
|
|
|
182
184
|
it("Disabled – topInside label doesn't have focus styles disabled", () => {
|
|
@@ -190,7 +192,7 @@ describe("ULabel.vue", () => {
|
|
|
190
192
|
},
|
|
191
193
|
});
|
|
192
194
|
|
|
193
|
-
expect(component.
|
|
195
|
+
expect(component.find("[vl-key='label']").attributes("class")).not.toContain(focusClasses);
|
|
194
196
|
});
|
|
195
197
|
|
|
196
198
|
it("Disabled – error is not rendered when disabled is true", () => {
|
|
@@ -294,7 +296,7 @@ describe("ULabel.vue", () => {
|
|
|
294
296
|
},
|
|
295
297
|
});
|
|
296
298
|
|
|
297
|
-
const labelElement = component.
|
|
299
|
+
const labelElement = component.find("[vl-key='label']");
|
|
298
300
|
|
|
299
301
|
expect(labelElement.text()).toBe(slotContent);
|
|
300
302
|
expect(labelElement.text()).not.toContain(defaultLabel);
|
|
@@ -313,7 +315,7 @@ describe("ULabel.vue", () => {
|
|
|
313
315
|
},
|
|
314
316
|
});
|
|
315
317
|
|
|
316
|
-
expect(component.
|
|
318
|
+
expect(component.find("[vl-key='label']").text()).toBe(slotContent);
|
|
317
319
|
});
|
|
318
320
|
|
|
319
321
|
it("Bottom – renders content from bottom slot", () => {
|
|
@@ -337,7 +339,7 @@ describe("ULabel.vue", () => {
|
|
|
337
339
|
},
|
|
338
340
|
});
|
|
339
341
|
|
|
340
|
-
const labelElement = component.
|
|
342
|
+
const labelElement = component.find("[vl-key='label']");
|
|
341
343
|
|
|
342
344
|
await labelElement.trigger("click");
|
|
343
345
|
|
|
@@ -346,7 +348,7 @@ describe("ULabel.vue", () => {
|
|
|
346
348
|
});
|
|
347
349
|
|
|
348
350
|
describe("Exposed properties", () => {
|
|
349
|
-
it("Exposes label element ref", () => {
|
|
351
|
+
it("Exposes label element ref as a div", () => {
|
|
350
352
|
const defaultLabel = "Label";
|
|
351
353
|
|
|
352
354
|
const component = mount(ULabel, {
|
|
@@ -355,6 +357,21 @@ describe("ULabel.vue", () => {
|
|
|
355
357
|
},
|
|
356
358
|
});
|
|
357
359
|
|
|
360
|
+
expect(component.vm.labelElement).toBeDefined();
|
|
361
|
+
expect(component.vm.labelElement!.tagName).toBe("DIV");
|
|
362
|
+
expect(component.vm.labelElement!.textContent).toBe(defaultLabel);
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
it("Exposes label element ref as a label", () => {
|
|
366
|
+
const defaultLabel = "Label";
|
|
367
|
+
|
|
368
|
+
const component = mount(ULabel, {
|
|
369
|
+
props: {
|
|
370
|
+
label: defaultLabel,
|
|
371
|
+
for: "test-id",
|
|
372
|
+
},
|
|
373
|
+
});
|
|
374
|
+
|
|
358
375
|
expect(component.vm.labelElement).toBeDefined();
|
|
359
376
|
expect(component.vm.labelElement!.tagName).toBe("LABEL");
|
|
360
377
|
expect(component.vm.labelElement!.textContent).toBe(defaultLabel);
|
|
@@ -183,7 +183,7 @@ describe("URadio.vue", () => {
|
|
|
183
183
|
});
|
|
184
184
|
|
|
185
185
|
const labelComponent = component.getComponent(ULabel);
|
|
186
|
-
const labelElement = labelComponent.find("label");
|
|
186
|
+
const labelElement = labelComponent.find("[vl-child-key='label']");
|
|
187
187
|
|
|
188
188
|
expect(labelElement.text()).toBe(customLabelContent);
|
|
189
189
|
});
|
|
@@ -201,7 +201,7 @@ describe("URadio.vue", () => {
|
|
|
201
201
|
});
|
|
202
202
|
|
|
203
203
|
const labelComponent = component.getComponent(ULabel);
|
|
204
|
-
const labelElement = labelComponent.find("label");
|
|
204
|
+
const labelElement = labelComponent.find("[vl-child-key='label']");
|
|
205
205
|
|
|
206
206
|
expect(labelElement.text()).toBe(`Modified ${defaultLabel}`);
|
|
207
207
|
});
|
|
@@ -211,7 +211,7 @@ describe("URadioGroup.vue", () => {
|
|
|
211
211
|
});
|
|
212
212
|
|
|
213
213
|
const labelComponent = component.getComponent(ULabel);
|
|
214
|
-
const labelElement = labelComponent.find("label");
|
|
214
|
+
const labelElement = labelComponent.find("[vl-child-key='label']");
|
|
215
215
|
|
|
216
216
|
expect(labelElement.text()).toBe(customLabelContent);
|
|
217
217
|
});
|
|
@@ -230,7 +230,7 @@ describe("URadioGroup.vue", () => {
|
|
|
230
230
|
});
|
|
231
231
|
|
|
232
232
|
const labelComponent = component.getComponent(ULabel);
|
|
233
|
-
const labelElement = labelComponent.find("label");
|
|
233
|
+
const labelElement = labelComponent.find("[vl-child-key='label']");
|
|
234
234
|
|
|
235
235
|
expect(labelElement.text()).toBe(`Modified ${defaultLabel}`);
|
|
236
236
|
});
|
|
@@ -408,7 +408,7 @@ describe("UTextarea.vue", () => {
|
|
|
408
408
|
},
|
|
409
409
|
});
|
|
410
410
|
|
|
411
|
-
const labelElement = component.getComponent(ULabel).find("label");
|
|
411
|
+
const labelElement = component.getComponent(ULabel).find("[vl-child-key='label']");
|
|
412
412
|
|
|
413
413
|
expect(labelElement.text()).toBe(customLabelContent);
|
|
414
414
|
});
|
|
@@ -425,7 +425,7 @@ describe("UTextarea.vue", () => {
|
|
|
425
425
|
},
|
|
426
426
|
});
|
|
427
427
|
|
|
428
|
-
const labelElement = component.getComponent(ULabel).find("label");
|
|
428
|
+
const labelElement = component.getComponent(ULabel).find("[vl-child-key='label']");
|
|
429
429
|
|
|
430
430
|
expect(labelElement.text()).toBe(`Modified ${defaultLabel}`);
|
|
431
431
|
});
|
package/utils/theme.ts
CHANGED
|
@@ -608,7 +608,7 @@ function getLetterSpacing(letterSpacing?: ThemeConfig["letterSpacing"]) {
|
|
|
608
608
|
const storageKey = `vl-${LETTER_SPACING}`;
|
|
609
609
|
|
|
610
610
|
const spacing = letterSpacing ?? getStored(storageKey) ?? vuelessConfig.letterSpacing;
|
|
611
|
-
const mergedSpacing =
|
|
611
|
+
const mergedSpacing = Number(spacing ?? DEFAULT_LETTER_SPACING);
|
|
612
612
|
|
|
613
613
|
if (isCSR && letterSpacing !== undefined) {
|
|
614
614
|
setCookie(storageKey, String(mergedSpacing));
|