vueless 0.0.236 → 0.0.238

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.236",
3
+ "version": "0.0.238",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless Component Framework.",
6
6
  "homepage": "https://vueless.com",
@@ -16,7 +16,12 @@ export function getArgTypes(componentName) {
16
16
 
17
17
  if (!component) return;
18
18
 
19
- const types = {};
19
+ const types = {
20
+ // Hide default template arg in docs.
21
+ defaultTemplate: { table: { disable: true } },
22
+ // Hide slot template arg in docs.
23
+ slotTemplate: { table: { disable: true } },
24
+ };
20
25
 
21
26
  component.attributes?.forEach((attribute) => {
22
27
  const type = attribute.value.type;
@@ -135,12 +140,23 @@ export function getArgTypes(componentName) {
135
140
  return types;
136
141
  }
137
142
 
138
- export function getSource(defaultCnfig) {
139
- return defaultCnfig.replace("export default /*tw*/ ", "").replace(";", "");
143
+ export function getSource(defaultConfig) {
144
+ return defaultConfig.replace("export default /*tw*/ ", "").replace(";", "");
140
145
  }
141
146
 
147
+ // TODO: remove it when allSlotsFragment will be replaced to getSlotsFragment
142
148
  export const allSlotsFragment = `
143
149
  <template v-for="(slot, index) of slots" :key="index" v-slot:[slot]>
144
150
  <template v-if="args[slot + 'Slot']">{{ args[slot + 'Slot'] }}</template>
145
151
  </template>
146
152
  `;
153
+
154
+ export function getSlotsFragment(defaultTemplate) {
155
+ return `
156
+ <template v-for="(slot, index) of slots" :key="index" v-slot:[slot]>
157
+ <template v-if="slot === 'default' && !args['defaultSlot']">${defaultTemplate || ""}</template>
158
+ <template v-else-if="slot === 'default' && args['defaultSlot']">{{ args['defaultSlot'] }}</template>
159
+ <template v-else-if="args[slot + 'Slot']">{{ args[slot + 'Slot'] }}</template>
160
+ </template>
161
+ `;
162
+ }
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <ULabel
3
- ref="labelComponent"
3
+ ref="labelComponentRef"
4
4
  :for="id"
5
5
  :label="label"
6
6
  :description="description"
@@ -12,14 +12,14 @@
12
12
  v-bind="labelAttrs"
13
13
  >
14
14
  <label :for="id" v-bind="blockAttrs">
15
- <span v-if="hasSlotContent($slots['left'])" ref="leftSlotWrapper">
15
+ <span v-if="hasSlotContent($slots['left'])" ref="leftSlotWrapperRef">
16
16
  <!-- @slot Use it to add something before the text. -->
17
17
  <slot name="left" />
18
18
  </span>
19
19
 
20
20
  <span
21
21
  v-if="hasSlotContent($slots['icon-left']) || iconLeft"
22
- ref="leftSlotWrapper"
22
+ ref="leftSlotWrapperRef"
23
23
  v-bind="leftIconSlotAttrs"
24
24
  >
25
25
  <!--
@@ -35,7 +35,7 @@
35
35
  <span v-bind="inputWrapperAttrs">
36
36
  <input
37
37
  :id="id"
38
- ref="input"
38
+ ref="inputRef"
39
39
  v-model="inputValue"
40
40
  :placeholder="placeholder"
41
41
  :type="inputType"
@@ -315,11 +315,11 @@ const props = defineProps({
315
315
  const slots = useSlots();
316
316
 
317
317
  const isShownPassword = ref(false);
318
- const input = ref(null);
319
- const labelComponent = ref(null);
320
- const leftSlotWrapper = ref(null);
318
+ const inputRef = ref(null);
319
+ const labelComponentRef = ref(null);
320
+ const leftSlotWrapperRef = ref(null);
321
321
 
322
- defineExpose({ input });
322
+ defineExpose({ inputRef });
323
323
 
324
324
  const isTypePassword = computed(() => props.type === "password");
325
325
 
@@ -440,12 +440,12 @@ function setLabelPosition() {
440
440
  return;
441
441
  }
442
442
 
443
- let leftSlotOrIconWidth = leftSlotWrapper.value.getBoundingClientRect().width;
443
+ let leftSlotOrIconWidth = leftSlotWrapperRef.value.getBoundingClientRect().width;
444
444
 
445
- const leftPaddingValue = parseFloat(getComputedStyle(input.value).paddingLeft);
445
+ const leftPaddingValue = parseFloat(getComputedStyle(inputRef.value).paddingLeft);
446
446
 
447
- if (labelComponent.value.labelElement) {
448
- labelComponent.value.labelElement.style.left = `${leftSlotOrIconWidth + leftPaddingValue}px`;
447
+ if (labelComponentRef.value.labelElement) {
448
+ labelComponentRef.value.labelElement.style.left = `${leftSlotOrIconWidth + leftPaddingValue}px`;
449
449
  }
450
450
  }
451
451
  </script>
@@ -13,7 +13,7 @@ export default /*tw*/ {
13
13
  variants: {
14
14
  error: {
15
15
  true: `
16
- border-red-300 hover:border-red-300
16
+ bg-red-50 border-red-300 hover:border-red-300
17
17
  focus-within:border-red-500 focus-within:ring-red-100
18
18
  `,
19
19
  },
@@ -2,8 +2,7 @@ export default /*tw*/ {
2
2
  label: "{ULabel}",
3
3
  wrapper: {
4
4
  base: `
5
- transition duration-300
6
- flex items-center p-0.5 relative rounded-3xl cursor-pointer
5
+ flex items-center p-0.5 relative rounded-3xl cursor-pointer transition
7
6
  ring-opacity-10 focus-within:ring-dynamic focus-within:ring-offset-dynamic
8
7
  `,
9
8
  variants: {
@@ -28,7 +27,7 @@ export default /*tw*/ {
28
27
  },
29
28
  input: "absolute size-0 opacity-0",
30
29
  circle: {
31
- base: "transition duration-300 rounded-full bg-white flex items-center justify-center",
30
+ base: "transition-all duration-300 rounded-full bg-white flex items-center justify-center",
32
31
  variants: {
33
32
  size: {
34
33
  sm: "size-3",
@@ -46,7 +45,7 @@ export default /*tw*/ {
46
45
  selectedIconName: "check",
47
46
  unselectedIconName: "close",
48
47
  toggleLabel: {
49
- base: "absolute text-center text-2xs font-medium uppercase text-white transition duration-300",
48
+ base: "absolute text-center text-2xs font-medium uppercase text-white",
50
49
  compoundVariants: [
51
50
  { toggleLabel: true, checked: true, class: "w-1/2 left-1" },
52
51
  { toggleLabel: true, checked: false, class: "w-1/2 right-1" },
@@ -12,7 +12,7 @@ export default /*tw*/ {
12
12
  variants: {
13
13
  error: {
14
14
  true: `
15
- border-red-300
15
+ bg-red-50 border-red-300
16
16
  hover:border-red-400 hover:focus-within:border-red-500
17
17
  focus-within:border-red-500 focus-within:ring-red-100
18
18
  `,
@@ -51,7 +51,6 @@ export default /*tw*/ {
51
51
  type: "text",
52
52
  inputmode: "text",
53
53
  labelAlign: "topInside",
54
- error: false,
55
54
  disabled: false,
56
55
  readonly: false,
57
56
  noAutocomplete: false,
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <ULabel
3
- ref="labelComponent"
3
+ ref="labelComponentRef"
4
4
  :for="id"
5
5
  :label="label"
6
6
  :error="error"
@@ -13,17 +13,17 @@
13
13
  >
14
14
  <label
15
15
  v-if="hasSlotContent($slots['left'])"
16
- ref="leftSlotWrapper"
16
+ ref="leftSlotWrapperRef"
17
17
  :for="id"
18
18
  v-bind="leftSlotAttrs"
19
19
  >
20
20
  <!-- @slot Use it to add something before the text. -->
21
21
  <slot name="left" />
22
22
  </label>
23
- <label ref="textareaWrapper" :for="id" v-bind="textareaWrapperAttrs">
23
+ <label ref="textareaWrapperRef" :for="id" v-bind="textareaWrapperAttrs">
24
24
  <textarea
25
25
  :id="id"
26
- ref="textarea"
26
+ ref="textareaRef"
27
27
  v-model="localValue"
28
28
  :value="modelValue"
29
29
  :placeholder="placeholder"
@@ -231,10 +231,10 @@ const {
231
231
  hasSlotContent,
232
232
  } = useAttrs(props);
233
233
 
234
- const textarea = ref(null);
235
- const labelComponent = ref(null);
236
- const leftSlotWrapper = ref(null);
237
- const textareaWrapper = ref(null);
234
+ const textareaRef = ref(null);
235
+ const labelComponentRef = ref(null);
236
+ const leftSlotWrapperRef = ref(null);
237
+ const textareaWrapperRef = ref(null);
238
238
 
239
239
  const localValue = computed({
240
240
  get() {
@@ -245,7 +245,7 @@ const localValue = computed({
245
245
  },
246
246
  });
247
247
 
248
- defineExpose({ textarea });
248
+ defineExpose({ textareaRef });
249
249
 
250
250
  onMounted(() => toggleReadonly(true));
251
251
 
@@ -292,13 +292,13 @@ function toggleReadonly(hasReadonly) {
292
292
  function setLabelPosition() {
293
293
  if (props.labelAlign === "top" || !hasSlotContent(slots["left"])) return;
294
294
 
295
- const leftSlotWidth = leftSlotWrapper.value.getBoundingClientRect().width;
295
+ const leftSlotWidth = leftSlotWrapperRef.value.getBoundingClientRect().width;
296
296
 
297
- if (labelComponent.value.labelElement) {
298
- labelComponent.value.labelElement.style.left = `${leftSlotWidth}px`;
297
+ if (labelComponentRef.value.labelElement) {
298
+ labelComponentRef.value.labelElement.style.left = `${leftSlotWidth}px`;
299
299
  }
300
300
 
301
- textareaWrapper.value.style.paddingLeft = `${leftSlotWidth}px`;
301
+ textareaWrapperRef.value.style.paddingLeft = `${leftSlotWidth}px`;
302
302
  }
303
303
 
304
304
  onMounted(() => setLabelPosition());
@@ -3,23 +3,35 @@ export default /*tw*/ {
3
3
  base: "p-4 flex flex-col rounded-dynamic",
4
4
  variants: {
5
5
  variant: {
6
- primary: `bg-{color}-500 text-white`,
7
- secondary: `bg-transparent border border-{color}-500 text-{color}-500`,
8
- thirdary: `bg-{color}-50 text-{color}-700`,
6
+ primary: "bg-{color}-500 text-white",
7
+ secondary: "bg-transparent border border-{color}-500 text-{color}-500",
8
+ thirdary: "bg-{color}-50 text-{color}-700",
9
+ },
10
+ size: {
11
+ xs: "text-2xs",
12
+ sm: "text-xs",
13
+ md: "text-sm",
14
+ lg: "text-base",
9
15
  },
10
16
  },
11
17
  compoundVariants: [
12
18
  { variant: "thirdary", bordered: true, class: "border border-{color}-100" },
13
19
  { color: "white", variant: "primary", class: "text-gray-900 bg-white" },
14
- { color: "white", variant: "secondary", class: "text-gray-900 bg-white border-gray-500" },
15
- { color: "white", variant: "thirdary", bordered: true, class: "text-gray-900 bg-white border border-gray-500" },
16
- { color: "grayscale", variant: "primary", class: `bg-gray-900` },
17
- { color: "grayscale", variant: "secondary", class: `text-gray-900 border-gray-900` },
18
- { color: "grayscale", variant: "thirdary", bordered: true, class: `text-gray-900 border border-gray-500` },
20
+ { color: "white", variant: "secondary", class: "text-gray-900 border-gray-200" },
21
+ { color: "white", variant: "thirdary", class: "text-gray-900 bg-white" },
22
+ { color: "white", variant: "thirdary", bordered: true, class: "border-gray-200" },
23
+ { color: "grayscale", variant: "primary", class: "bg-gray-900" },
24
+ { color: "grayscale", variant: "secondary", class: "text-gray-900 border-gray-900" },
25
+ { color: "grayscale", variant: "thirdary", class: "text-gray-900 bg-gray-50" },
26
+ { color: "grayscale", variant: "thirdary", bordered: true, class: "border-gray-200" },
19
27
  ],
20
28
  },
21
- body: {
22
- base: "{UText} flex gap-2 items-baseline",
29
+ text: "{UText}",
30
+ body: "flex items-start justify-between",
31
+ content: "",
32
+ innerWrapper: "flex gap-2",
33
+ title: {
34
+ base: "font-bold leading-tight",
23
35
  variants: {
24
36
  size: {
25
37
  xs: "text-xs",
@@ -29,36 +41,18 @@ export default /*tw*/ {
29
41
  },
30
42
  },
31
43
  },
32
- title: {
33
- base: "font-bold leading-tight",
34
- variants: {
35
- size: {
36
- xs: "text-sm",
37
- sm: "text-base",
38
- md: "text-lg",
39
- lg: "text-xl",
40
- },
41
- },
42
- },
43
- description: {
44
- variants: {
45
- size: {
46
- xs: "text-xs",
47
- sm: "text-xs",
48
- md: "text-sm",
49
- lg: "text-base",
50
- },
51
- },
44
+ description: "",
45
+ button: {
46
+ component: "{UButton}",
47
+ compoundVariants: [{ color: "grayscale", variant: "primary", closable: true, class: "hover:bg-gray-200" }],
52
48
  },
53
- button: "{UButton}",
54
49
  icon: "{UIcon}",
55
50
  iconName: "close",
56
51
  defaultVariants: {
57
- variant: "thirdary",
52
+ variant: "primary",
58
53
  color: "brand",
59
54
  size: "md",
60
55
  timeout: 0,
61
- html: undefined,
62
56
  bordered: false,
63
57
  closable: false,
64
58
  },
@@ -1,4 +1,4 @@
1
- import { getArgTypes, getSlotNames } from "../service.storybook";
1
+ import { getArgTypes, getSlotNames, getSlotsFragment } from "../service.storybook";
2
2
 
3
3
  import UAlert from "../ui.text-alert";
4
4
  import URow from "../ui.container-row";
@@ -12,154 +12,87 @@ export default {
12
12
  id: "4030",
13
13
  title: "Text & Content / Alert",
14
14
  component: UAlert,
15
- args: {},
15
+ args: {
16
+ title: "Default Title",
17
+ description: "Default Description",
18
+ },
16
19
  argTypes: {
17
20
  ...getArgTypes(UAlert.name),
18
21
  },
19
22
  };
20
23
 
21
- const defaultTemplate = `
22
- <p>
23
- <b>Please note that your session is about to expire </b>
24
- <u>in 5 minutes,</u>
25
- <em> so make sure to save your work to avoid any data loss. </em>
26
- <a href="https://uk.wikipedia.org/wiki/Lorem_ipsum" target="_blank">Wikipedia</a>
27
- </p>
28
- `;
29
-
30
24
  const DefaultTemplate = (args) => ({
31
- components: { UAlert, UIcon },
25
+ components: { UAlert, UIcon, URow },
32
26
  setup() {
33
27
  const slots = getSlotNames(UAlert.name);
34
28
 
35
29
  return { args, slots };
36
30
  },
37
31
  template: `
38
- <UAlert v-bind="args" v-model="args.value">
39
- ${args.template || defaultTemplate}
32
+ <UAlert v-bind="args">
33
+ ${args.slotTemplate || getSlotsFragment(args.defaultTemplate)}
40
34
  </UAlert>
41
35
  `,
42
36
  });
43
37
 
44
- const SlotTemplate = (args) => ({
45
- components: { UAlert, UIcon },
46
- setup() {
47
- return { args };
48
- },
49
- template: `
50
- <UAlert v-bind="args" v-model="args.value">
51
- ${args.slotTemplate}
52
- ${defaultTemplate}
53
- </UAlert>
54
- `,
55
- });
56
-
57
- const VariantsTemplate = (args, { argTypes } = {}) => ({
38
+ const EnumVariantTemplate = (args, { argTypes } = {}) => ({
58
39
  components: { UAlert, UGroup },
59
40
  setup() {
60
- return {
61
- args,
62
- variants: argTypes.variant.options,
63
- };
64
- },
65
- template: `
66
- <UGroup>
67
- <UAlert
68
- v-for="(variant, index) in variants"
69
- v-bind="args"
70
- :variant="variant"
71
- :key="index"
72
- :title="variant"
73
- color="gray"
74
- />
75
- </UGroup>
76
- `,
77
- });
41
+ const options = argTypes[args.enum].options;
42
+ let prefixedOptions = options;
78
43
 
79
- const ColorsTemplate = (args, { argTypes } = {}) => ({
80
- components: { UAlert, URow },
81
- setup() {
82
- return {
83
- args,
84
- colors: argTypes.color.options,
85
- };
86
- },
87
- template: `
88
- <URow>
89
- <UAlert
90
- v-for="(color, index) in colors"
91
- v-bind="args"
92
- :color="color"
93
- :title="color"
94
- :key="index"
95
- />
96
- </URow>
97
- `,
98
- });
44
+ if (argTypes[args.enum].name === "size") {
45
+ prefixedOptions = options.map((option) => getText(option));
46
+ }
99
47
 
100
- const SizeTemplate = (args, { argTypes } = {}) => ({
101
- components: { UAlert, URow },
102
- setup() {
103
- return {
104
- args,
105
- sizes: argTypes.size.options,
106
- };
48
+ function getText(value) {
49
+ return `This is Alert's ${value} size`;
50
+ }
51
+
52
+ return { args, options: argTypes[args.enum].options, prefixedOptions };
107
53
  },
108
54
  template: `
109
- <URow>
55
+ <UGroup align="stretch">
110
56
  <UAlert
111
- v-for="(size, index) in sizes"
112
- v-bind="args"
113
- :size="size"
57
+ v-for="(option, index) in options"
114
58
  :key="index"
115
- >
116
- text
117
- </UAlert>
118
- </URow>
119
- `,
120
- });
121
-
122
- const HTMLTemplate = (args) => ({
123
- components: { UAlert },
124
- setup() {
125
- return { args };
126
- },
127
- template: `
128
- <UAlert :html="args.html" />
59
+ v-bind="args"
60
+ :[args.enum]="option"
61
+ :title="prefixedOptions[index]"
62
+ />
63
+ </UGroup>
129
64
  `,
130
65
  });
131
66
 
132
67
  export const Default = DefaultTemplate.bind({});
133
- Default.args = {
134
- title: "Default Title",
135
- description: "Default Description",
136
- };
68
+ Default.args = {};
137
69
 
138
- export const variants = VariantsTemplate.bind({});
139
- variants.args = {};
70
+ export const variants = EnumVariantTemplate.bind({});
71
+ variants.args = { enum: "variant" };
140
72
 
141
- export const colors = ColorsTemplate.bind({});
142
- colors.args = {};
73
+ export const colors = EnumVariantTemplate.bind({});
74
+ colors.args = { enum: "color" };
143
75
 
144
- export const sizes = SizeTemplate.bind({});
145
- sizes.args = {};
76
+ export const sizes = EnumVariantTemplate.bind({});
77
+ sizes.args = { enum: "size" };
146
78
 
147
- export const HTML = HTMLTemplate.bind({});
79
+ export const HTML = DefaultTemplate.bind({});
148
80
  HTML.args = {
149
- html: `
150
- <p>
151
- <b>Important Security Update: </b>
152
- <u>Your account password will expire in 10 days,</u>
153
- <em> please update it to maintain account security. </em>
154
- <a href="https://security.example.com/password-update" target="_blank">Update Password</a>
81
+ title: "",
82
+ description: "",
83
+ defaultTemplate: `
84
+ <h3 class="text-lg font-medium mb-2">Important Security Update</h3>
85
+ <p class="mb-0.5">
86
+ <b>Your account password will expire in 10 days,</b> please update it to maintain account security.
155
87
  </p>
88
+ <a href="https://security.example.com/password-update" target="_blank">Update Password</a>
156
89
  `,
157
90
  };
158
91
 
159
92
  export const closable = DefaultTemplate.bind({});
160
93
  closable.args = {
161
94
  closable: true,
162
- template: `
95
+ slotTemplate: `
163
96
  <template #default>
164
97
  some text
165
98
  </template>
@@ -168,12 +101,15 @@ closable.args = {
168
101
 
169
102
  export const paragraphs = DefaultTemplate.bind({});
170
103
  paragraphs.args = {
171
- template: `
104
+ slotTemplate: `
172
105
  <template #default>
173
106
  <p>
174
107
  Please be aware that the scheduled maintenance will occur this Saturday,
175
108
  from 12 AM to 4 AM. During this time, some services may be temporarily
176
- unavailable. We apologize for any inconvenience this may cause and
109
+ unavailable.
110
+ </p>
111
+ <p>
112
+ We apologize for any inconvenience this may cause and
177
113
  appreciate your understanding. Our team is committed to improving
178
114
  the system's performance and reliability.
179
115
  </p>
@@ -183,24 +119,23 @@ paragraphs.args = {
183
119
 
184
120
  export const list = DefaultTemplate.bind({});
185
121
  list.args = {
186
- template: `
187
- <URow>
188
- <ul>
189
- <li>Check your email for verification link.</li>
190
- <li>Update your password regularly to enhance security.</li>
191
- <li>Enable two-factor authentication for added protection.</li>
192
- </ul>
193
-
194
- <ol>
195
- <li>Sign in to your account using your credentials.</li>
196
- <li>Navigate to the settings menu to update your profile.</li>
197
- <li>Review your privacy settings and adjust them as needed.</li>
198
- </ol>
199
- </URow>
200
- `,
122
+ slotTemplate: `
123
+ <URow>
124
+ <ul>
125
+ <li>Check your email for verification link.</li>
126
+ <li>Update your password regularly to enhance security.</li>
127
+ <li>Enable two-factor authentication for added protection.</li>
128
+ </ul>
129
+ <ol>
130
+ <li>Sign in to your account using your credentials.</li>
131
+ <li>Navigate to the settings menu to update your profile.</li>
132
+ <li>Review your privacy settings and adjust them as needed.</li>
133
+ </ol>
134
+ </URow>
135
+ `,
201
136
  };
202
137
 
203
- export const slotTitleAndDescription = SlotTemplate.bind({});
138
+ export const slotTitleAndDescription = DefaultTemplate.bind({});
204
139
  slotTitleAndDescription.args = {
205
140
  slotTemplate: `
206
141
  <template #title>
@@ -212,8 +147,8 @@ slotTitleAndDescription.args = {
212
147
  `,
213
148
  };
214
149
 
215
- export const slotAlertLeft = SlotTemplate.bind({});
216
- slotAlertLeft.args = {
150
+ export const slotLeft = DefaultTemplate.bind({});
151
+ slotLeft.args = {
217
152
  slotTemplate: `
218
153
  <template #left>
219
154
  <UIcon
@@ -224,8 +159,8 @@ slotAlertLeft.args = {
224
159
  `,
225
160
  };
226
161
 
227
- export const slotAlertRight = SlotTemplate.bind({});
228
- slotAlertRight.args = {
162
+ export const slotRight = DefaultTemplate.bind({});
163
+ slotRight.args = {
229
164
  slotTemplate: `
230
165
  <template #right>
231
166
  <UIcon
@@ -236,8 +171,8 @@ slotAlertRight.args = {
236
171
  `,
237
172
  };
238
173
 
239
- export const slotAlertTop = SlotTemplate.bind({});
240
- slotAlertTop.args = {
174
+ export const slotTop = DefaultTemplate.bind({});
175
+ slotTop.args = {
241
176
  slotTemplate: `
242
177
  <template #top>
243
178
  <UIcon
@@ -248,8 +183,8 @@ slotAlertTop.args = {
248
183
  `,
249
184
  };
250
185
 
251
- export const slotAlertBottom = SlotTemplate.bind({});
252
- slotAlertBottom.args = {
186
+ export const slotBottom = DefaultTemplate.bind({});
187
+ slotBottom.args = {
253
188
  slotTemplate: `
254
189
  <template #bottom>
255
190
  <UIcon