vueless 0.0.481 → 0.0.483

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/constants.js CHANGED
@@ -189,6 +189,8 @@ export const DEFAULT_SVGO_CONFIG = {
189
189
  export const PX_IN_REM = 16;
190
190
  export const NESTED_COMPONENT_REG_EXP = /\{U[^}]*}/g;
191
191
  export const DYNAMIC_COLOR_PATTERN = "{color}";
192
- export const TAILWIND_CLASS_DELIMITER = ":";
192
+ export const TAILWIND_COLOR_OPACITY_DELIMITER = "/";
193
+ export const TAILWIND_VARIANT_DELIMITER = ":";
194
+ export const TAILWIND_VARIANT_DELIMITER_REG_EXP = /:(?![^[]*])/;
193
195
  export const CACHE_PATH = "node_modules/.cache/vueless";
194
196
  export const VUELESS_CONFIG_FILE_NAME = "vueless.config";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.481",
3
+ "version": "0.0.483",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless UI Component Library, powered by Tailwind CSS.",
6
6
  "keywords": [
@@ -5,6 +5,8 @@ import {
5
5
  getDocsDescription,
6
6
  } from "../../utils/storybook.ts";
7
7
 
8
+ import { ref } from "vue";
9
+
8
10
  import UButton from "../../ui.button/UButton.vue";
9
11
  import UIcon from "../../ui.image-icon/UIcon.vue";
10
12
  import URow from "../../ui.container-row/URow.vue";
@@ -46,7 +48,7 @@ const EnumVariantTemplate = (args, { argTypes }) => ({
46
48
  },
47
49
  template: `
48
50
  <UCol>
49
- <URow>
51
+ <URow no-mobile>
50
52
  <UButton
51
53
  v-for="(option, index) in options"
52
54
  :key="index"
@@ -62,22 +64,28 @@ const EnumVariantTemplate = (args, { argTypes }) => ({
62
64
  const ColorTemplate = (args, { argTypes }) => ({
63
65
  components: { UButton, URow, UCol },
64
66
  setup() {
67
+ const variants = [...argTypes.variant.options, "thirdary"];
68
+
65
69
  return {
66
70
  args,
67
- variants: argTypes.variant.options,
71
+ variants,
68
72
  colors: argTypes.color.options,
73
+ shouldBeFilled: (variant, index) => {
74
+ return variant === "thirdary" && index === variants.length - 2;
75
+ },
69
76
  };
70
77
  },
71
78
  template: `
72
79
  <UCol>
73
- <URow v-for="(variant, index) in variants" :key="index">
80
+ <URow v-for="(variant, variantIndex) in variants" :key="variantIndex" no-mobile>
74
81
  <UButton
75
- v-for="(color, index) in colors"
82
+ v-for="(color, colorIndex) in colors"
76
83
  v-bind="args"
77
84
  :variant="variant"
78
85
  :color="color"
79
86
  :label="color"
80
- :key="index"
87
+ :key="colorIndex"
88
+ :filled="shouldBeFilled(variant, variantIndex)"
81
89
  />
82
90
  </URow>
83
91
  </UCol>
@@ -96,6 +104,37 @@ Sizes.args = { enum: "size" };
96
104
  export const Round = EnumVariantTemplate.bind({});
97
105
  Round.args = { enum: "variant", round: true };
98
106
 
107
+ export const Loading = (args) => ({
108
+ components: { UButton, URow },
109
+ setup() {
110
+ const loading = ref(false);
111
+
112
+ function toggleLoading() {
113
+ loading.value = !loading.value;
114
+ }
115
+
116
+ return { args, toggleLoading, loading };
117
+ },
118
+ template: `
119
+ <URow no-mobile>
120
+ <UButton
121
+ label="Loader demo"
122
+ :loading="loading"
123
+ />
124
+ <UButton
125
+ label="Toggle loading"
126
+ variant="secondary"
127
+ color="green"
128
+ leftIcon="play_arrow"
129
+ @click="toggleLoading"
130
+ />
131
+ </URow>
132
+ `,
133
+ });
134
+
135
+ export const Block = DefaultTemplate.bind({});
136
+ Block.args = { block: true };
137
+
99
138
  export const Disabled = EnumVariantTemplate.bind({});
100
139
  Disabled.args = { enum: "variant", disabled: true };
101
140
 
@@ -105,43 +144,64 @@ NoRing.args = { noRing: true };
105
144
  export const Colors = ColorTemplate.bind({});
106
145
  Colors.args = {};
107
146
 
108
- export const LeftIcon = DefaultTemplate.bind({});
109
- LeftIcon.args = { leftIcon: "star" };
110
-
111
- export const RightIcon = DefaultTemplate.bind({});
112
- RightIcon.args = { rightIcon: "star" };
147
+ export const Square = DefaultTemplate.bind({});
148
+ Square.args = { square: true, icon: "filter_list" };
113
149
 
114
- export const SlotDefault = DefaultTemplate.bind({});
115
- SlotDefault.args = {
116
- slotTemplate: `
117
- <template #default>
118
- 🤘🤘🤘
119
- </template>
120
- `,
121
- };
122
-
123
- export const LeftSlot = DefaultTemplate.bind({});
124
- LeftSlot.args = {
125
- slotTemplate: `
126
- <template #left>
127
- <UIcon
128
- name="archive"
129
- color="red"
130
- size="sm"
150
+ export const IconProps = (args) => ({
151
+ components: { UButton, URow },
152
+ setup() {
153
+ return { args };
154
+ },
155
+ template: `
156
+ <URow no-mobile>
157
+ <UButton
158
+ leftIcon="download"
159
+ label="Download"
131
160
  />
132
- </template>
161
+ <UButton
162
+ rightIcon="menu"
163
+ label="Menu"
164
+ />
165
+ </URow>
133
166
  `,
134
- };
167
+ });
135
168
 
136
- export const RightSlot = DefaultTemplate.bind({});
137
- RightSlot.args = {
138
- slotTemplate: `
139
- <template #right>
140
- <UIcon
141
- name="archive"
142
- color="red"
143
- size="sm"
144
- />
145
- </template>
169
+ export const Slots = (args) => ({
170
+ components: { UButton, UIcon, URow },
171
+ setup() {
172
+ return { args };
173
+ },
174
+ template: `
175
+ <URow no-mobile>
176
+ <UButton v-bind="args" label="Add to favorite">
177
+ <template #left>
178
+ <UIcon
179
+ name="heart_plus"
180
+ color="green"
181
+ size="sm"
182
+ />
183
+ </template>
184
+ </UButton>
185
+
186
+ <UButton v-bind="args" square>
187
+ <template #default>
188
+ <UIcon
189
+ name="settings"
190
+ color="green"
191
+ size="sm"
192
+ />
193
+ </template>
194
+ </UButton>
195
+
196
+ <UButton v-bind="args" label="Delete">
197
+ <template #right>
198
+ <UIcon
199
+ name="delete"
200
+ color="green"
201
+ size="sm"
202
+ />
203
+ </template>
204
+ </UButton>
205
+ </URow>
146
206
  `,
147
- };
207
+ });
@@ -50,7 +50,7 @@ const EnumVariantTemplate = (args, { argTypes }) => ({
50
50
  return { args, options: argTypes[args.enum].options, prefixedOptions };
51
51
  },
52
52
  template: `
53
- <URow>
53
+ <URow no-mobile>
54
54
  <ULink
55
55
  v-for="(option, index) in options"
56
56
  :key="index"
@@ -71,26 +71,93 @@ Sizes.args = { enum: "size" };
71
71
  export const Colors = EnumVariantTemplate.bind({});
72
72
  Colors.args = { enum: "color" };
73
73
 
74
- export const Types = EnumVariantTemplate.bind({});
75
- Types.args = { enum: "type" };
76
-
77
- export const Underlined = EnumVariantTemplate.bind({});
78
- Underlined.args = { enum: "color", underlined: true, dashed: false };
74
+ export const Types = (args) => ({
75
+ components: { ULink, URow },
76
+ setup() {
77
+ function getTypeLabel(type) {
78
+ switch (type) {
79
+ case "phone":
80
+ return "+1 (000) 123-4567";
81
+ case "email":
82
+ return "hello@vueless.com";
83
+ case "link":
84
+ return "Vueless.com";
85
+ }
86
+ }
79
87
 
80
- export const Dashed = EnumVariantTemplate.bind({});
81
- Dashed.args = { enum: "color", dashed: true };
88
+ function getTypeHref(type, label) {
89
+ switch (type) {
90
+ case "phone": {
91
+ const phoneNumber = label.replace(/\D/g, "");
92
+
93
+ return `+${phoneNumber}`;
94
+ }
95
+
96
+ case "email":
97
+ return `${label}`;
98
+ case "link":
99
+ return "https://vueless.com/";
100
+ default:
101
+ return "#";
102
+ }
103
+ }
82
104
 
83
- export const Href = DefaultTemplate.bind({});
84
- Href.args = { href: "https://storybook.js.org/docs/react/get-started/introduction" };
105
+ const options = ["phone", "email", "link"];
106
+ const links = options.map((type) => ({
107
+ type,
108
+ label: getTypeLabel(type),
109
+ href: getTypeHref(type, getTypeLabel(type)),
110
+ }));
85
111
 
86
- export const Route = DefaultTemplate.bind({});
87
- Route.args = { name: "routerName" };
112
+ return { args, links };
113
+ },
114
+ template: `
115
+ <URow>
116
+ <ULink
117
+ v-for="(link, index) in links"
118
+ :key="index"
119
+ v-bind="args"
120
+ :type="link.type"
121
+ :label="link.label"
122
+ :href="link.href"
123
+ target-blank
124
+ />
125
+ </URow>
126
+ `,
127
+ });
88
128
 
89
- export const TargetBlank = DefaultTemplate.bind({});
90
- TargetBlank.args = {
91
- href: "https://storybook.js.org/docs/react/get-started/introduction",
92
- targetBlank: true,
93
- };
129
+ export const UnderlineVariants = (args, { argTypes } = {}) => ({
130
+ components: { ULink, URow },
131
+ setup() {
132
+ const variants = [
133
+ { name: "Default", props: {} },
134
+ { name: "Underlined", props: { underlined: true } },
135
+ { name: "Dashed", props: { dashed: true } },
136
+ ];
137
+
138
+ const colors = argTypes.color.options;
139
+
140
+ return {
141
+ args,
142
+ variants,
143
+ colors,
144
+ };
145
+ },
146
+ template: `
147
+ <div v-for="variant in variants" :key="variant.name" class="mb-8">
148
+ <div class="text-sm font-medium mb-2">{{ variant.name }}</div>
149
+ <URow no-mobile>
150
+ <ULink
151
+ v-for="color in colors"
152
+ :key="color"
153
+ v-bind="variant.props"
154
+ :color="color"
155
+ :label="color"
156
+ />
157
+ </URow>
158
+ </div>
159
+ `,
160
+ });
94
161
 
95
162
  export const Disabled = DefaultTemplate.bind({});
96
163
  Disabled.args = { disabled: true };
@@ -98,8 +165,11 @@ Disabled.args = { disabled: true };
98
165
  export const NoRing = DefaultTemplate.bind({});
99
166
  NoRing.args = { noRing: true };
100
167
 
101
- export const SlotDefault = DefaultTemplate.bind({});
102
- SlotDefault.args = {
168
+ export const Block = DefaultTemplate.bind({});
169
+ Block.args = { block: true, config: { wrapper: "border-2 border-dashed border-green-500 p-2" } };
170
+
171
+ export const DefaultSlot = DefaultTemplate.bind({});
172
+ DefaultSlot.args = {
103
173
  slotTemplate: `
104
174
  <template #default>
105
175
  <UButton label="Text" />
@@ -107,20 +177,24 @@ SlotDefault.args = {
107
177
  `,
108
178
  };
109
179
 
110
- export const SlotLeft = DefaultTemplate.bind({});
111
- SlotLeft.args = {
112
- slotTemplate: `
113
- <template #left>
114
- <UIcon name="star" size="xs" />
115
- </template>
116
- `,
117
- };
118
-
119
- export const SlotRight = DefaultTemplate.bind({});
120
- SlotRight.args = {
121
- slotTemplate: `
122
- <template #right>
123
- <UIcon name="star" size="xs" />
124
- </template>
180
+ export const LeftAndRightSlots = (args) => ({
181
+ components: { ULink, UIcon, URow },
182
+ setup() {
183
+ return { args };
184
+ },
185
+ template: `
186
+ <URow no-mobile>
187
+ <ULink label="Download">
188
+ <template #left>
189
+ <UIcon name="download" size="xs" color="green" />
190
+ </template>
191
+ </ULink>
192
+
193
+ <ULink label="Open">
194
+ <template #right>
195
+ <UIcon name="open_in_new" size="xs" color="green" />
196
+ </template>
197
+ </ULink>
198
+ </URow>
125
199
  `,
126
- };
200
+ });
@@ -15,9 +15,11 @@ import {
15
15
  BRAND_COLOR,
16
16
  GRAY_COLOR,
17
17
  DYNAMIC_COLOR_PATTERN,
18
- TAILWIND_CLASS_DELIMITER,
18
+ TAILWIND_VARIANT_DELIMITER,
19
19
  TAILWIND_MERGE_EXTENSION,
20
20
  NESTED_COMPONENT_REG_EXP,
21
+ TAILWIND_COLOR_OPACITY_DELIMITER,
22
+ TAILWIND_VARIANT_DELIMITER_REG_EXP,
21
23
  } from "../../constants.js";
22
24
 
23
25
  const twMerge = extendTailwindMerge(merge(TAILWIND_MERGE_EXTENSION, vuelessConfig.tailwindMerge));
@@ -140,16 +142,22 @@ function getSafelistClasses(config) {
140
142
  }
141
143
 
142
144
  function getSafelistItem(safelistClass, colorString) {
143
- const classes = safelistClass.split(TAILWIND_CLASS_DELIMITER);
145
+ const classes = safelistClass.split(TAILWIND_VARIANT_DELIMITER_REG_EXP);
144
146
  const mainClass = classes.at(-1);
145
- const variantClasses = classes.slice(0, classes.length - 1);
146
-
147
147
  const pattern = mainClass.replace(DYNAMIC_COLOR_PATTERN, colorString);
148
- const variants = variantClasses
149
- .map((variantItem) => (variantItem ? variantItem : TAILWIND_CLASS_DELIMITER))
150
- .join("");
151
148
 
152
- return classes.length === 1 ? { pattern } : { pattern, variants: [variants].flat() };
149
+ if (classes.length > 1) {
150
+ const variantClasses = classes.slice(0, classes.length - 1);
151
+
152
+ const variants =
153
+ variantClasses.length > 1
154
+ ? [variantClasses.join(TAILWIND_VARIANT_DELIMITER)].flat()
155
+ : [variantClasses.join()].flat();
156
+
157
+ return { pattern, variants };
158
+ } else {
159
+ return { pattern };
160
+ }
153
161
  }
154
162
 
155
163
  async function getComponentSafelist(componentName, { colors, vuelessConfigFiles }) {
@@ -288,11 +296,13 @@ function getSafelistData(safelist) {
288
296
  .match(safelistItemRegExp)
289
297
  .slice(matchGroupStart, matchGroupEnd);
290
298
 
299
+ const [shade] = colorShade.split(TAILWIND_COLOR_OPACITY_DELIMITER);
300
+
291
301
  return {
292
302
  property,
293
303
  colorPattern,
294
304
  variants: safelistItem.variants,
295
- shades: new Set([colorShade]),
305
+ shades: new Set([shade]),
296
306
  };
297
307
  });
298
308
  }
@@ -317,7 +327,7 @@ function mergeSafelistColors(safelistData) {
317
327
  return !isSameItem && isSameProperty && isSameVariants && isIncludesColors;
318
328
  });
319
329
 
320
- if (duplicateIndex === -1) {
330
+ if (!~duplicateIndex) {
321
331
  mergedSafelist.push(currentSafelistItem);
322
332
  } else {
323
333
  const mergedColors = [
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "vueless",
4
- "version": "0.0.481",
4
+ "version": "0.0.483",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",