vueless 1.5.1-beta.6 → 1.5.1-beta.7

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.
@@ -284,6 +284,17 @@ describe("useUI", () => {
284
284
  expect(result).toHaveProperty("iconAttrs");
285
285
  expect(result).toHaveProperty("buttonAttrs");
286
286
  });
287
+
288
+ it("should strip every nested component marker from classes", () => {
289
+ const defaultConfig = {
290
+ label: "{ULabel} {ULabel} label-class",
291
+ };
292
+
293
+ const result = useUI(defaultConfig);
294
+
295
+ expect(result.labelAttrs.value.class).not.toContain("{ULabel}");
296
+ expect(result.labelAttrs.value.class).toContain("label-class");
297
+ });
287
298
  });
288
299
 
289
300
  describe("Reactivity", () => {
@@ -170,7 +170,7 @@ export function useUI<T>(defaultConfig: T, mutatedProps?: MutatedProps, topLevel
170
170
 
171
171
  classes = classes
172
172
  .replaceAll(EXTENDS_PATTERN_REG_EXP, "")
173
- .replace(NESTED_COMPONENT_PATTERN_REG_EXP, "");
173
+ .replaceAll(NESTED_COMPONENT_PATTERN_REG_EXP, "");
174
174
 
175
175
  return color && !isNestedComponent ? setColor(classes, color) : classes;
176
176
  }
@@ -335,7 +335,7 @@ function getExtendsKeys(configItemValue?: string | CVA | NestedComponent): strin
335
335
  */
336
336
  function getNestedComponent(value?: string | CVA | NestedComponent) {
337
337
  const classes = getBaseClasses(value);
338
- const match = classes.match(NESTED_COMPONENT_PATTERN_REG_EXP);
338
+ const [match] = classes.matchAll(NESTED_COMPONENT_PATTERN_REG_EXP);
339
339
 
340
340
  return match ? match[1] : "";
341
341
  }
package/constants.js CHANGED
@@ -445,7 +445,7 @@ export const FAILURE_CODE = 1;
445
445
 
446
446
  /* Other */
447
447
  export const PX_IN_REM = 16;
448
- export const NESTED_COMPONENT_PATTERN_REG_EXP = /\{(U[^}]*)}/;
448
+ export const NESTED_COMPONENT_PATTERN_REG_EXP = /\{(U[^}]*)}/g;
449
449
  export const EXTENDS_PATTERN_REG_EXP = /\{>[^}]*}/g;
450
450
  export const DYNAMIC_COLOR_PATTERN = "{color}";
451
451
  export const JAVASCRIPT_EXT = ".js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "1.5.1-beta.6",
3
+ "version": "1.5.1-beta.7",
4
4
  "description": "Vue Styleless UI Component Library, powered by Tailwind CSS.",
5
5
  "author": "Johnny Grid <hello@vueless.com> (https://vueless.com)",
6
6
  "homepage": "https://vueless.com",
@@ -1,6 +1,6 @@
1
1
  export default /*tw*/ {
2
2
  wrapper: {
3
- base: "flex w-full group/label",
3
+ base: "flex w-full max-w-full group/label",
4
4
  variants: {
5
5
  align: {
6
6
  topInside: "flex-col gap-0 relative",
@@ -25,7 +25,7 @@ export default /*tw*/ {
25
25
  },
26
26
  content: "flex",
27
27
  label: {
28
- base: "z-10 block leading-none! w-max transition",
28
+ base: "z-10 block leading-none! transition",
29
29
  variants: {
30
30
  size: {
31
31
  sm: "text-small",
@@ -151,6 +151,18 @@ describe("ULabel.vue", () => {
151
151
  });
152
152
  });
153
153
 
154
+ it("Align – side-aligned label can wrap within its container", () => {
155
+ const component = mount(ULabel, {
156
+ props: {
157
+ label: "Label",
158
+ align: "right",
159
+ },
160
+ });
161
+
162
+ expect(component.attributes("class")).toContain("max-w-full");
163
+ expect(component.find("[vl-key='label']").attributes("class")).not.toContain("w-max");
164
+ });
165
+
154
166
  it("Size – applies correct class for size prop", () => {
155
167
  const sizeCases = {
156
168
  sm: "text-small",
@@ -60,7 +60,8 @@ const twMerge = extendTailwindMerge(
60
60
  export const { cx } = defineConfig({
61
61
  cx: cvaCx,
62
62
  hooks: {
63
- onComplete: (classNames) => twMerge(classNames).replace(NESTED_COMPONENT_PATTERN_REG_EXP, ""),
63
+ onComplete: (classNames) =>
64
+ twMerge(classNames).replaceAll(NESTED_COMPONENT_PATTERN_REG_EXP, ""),
64
65
  },
65
66
  });
66
67