vueless 0.0.236 → 0.0.237

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.237",
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
+ }
@@ -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
@@ -3,35 +3,41 @@
3
3
  <!-- @slot Use it to add something above the text. -->
4
4
  <slot name="top" />
5
5
 
6
- <!--
7
- @slot Use it to add something instead of the title.
8
- @binding {string} title
9
- -->
10
- <slot name="title" :title="title">
11
- <div v-if="title" v-bind="titleAttrs" v-text="title" />
12
- </slot>
13
-
14
- <!--
15
- @slot Use it to add something instead of the description.
16
- @binding {string} description
17
- -->
18
- <slot name="description" :description="description">
19
- <div v-if="description" v-bind="descriptionAttrs" v-text="description" />
20
- </slot>
21
-
22
6
  <div v-bind="bodyAttrs">
23
- <!-- @slot Use it to add something before the text. -->
24
- <slot name="left" />
25
-
26
- <UText
27
- v-if="hasSlotContent($slots.default) || html"
28
- v-bind="bodyAttrs"
29
- :size="size"
30
- :html="html"
31
- >
32
- <!-- @slot Use it to add something inside. -->
33
- <slot />
34
- </UText>
7
+ <div v-bind="innerWrapperAttrs">
8
+ <!-- @slot Use it to add something before the text. -->
9
+ <slot name="left" />
10
+
11
+ <div v-bind="contentAttrs">
12
+ <!--
13
+ @slot Use it to add something instead of the title.
14
+ @binding {string} title
15
+ -->
16
+ <slot v-if="!hasSlotContent($slots['default'])" name="title" :title="title">
17
+ <div v-if="title" v-bind="titleAttrs" v-text="title" />
18
+ </slot>
19
+
20
+ <!--
21
+ @slot Use it to add something instead of the description.
22
+ @binding {string} description
23
+ -->
24
+ <slot
25
+ v-if="!hasSlotContent($slots['default'])"
26
+ name="description"
27
+ :description="description"
28
+ >
29
+ <div v-if="description" v-bind="descriptionAttrs" v-text="description" />
30
+ </slot>
31
+
32
+ <!-- @slot Use it to add something inside. -->
33
+ <UText v-bind="textAttrs" :size="size">
34
+ <slot />
35
+ </UText>
36
+ </div>
37
+
38
+ <!-- @slot Use it to add something after the text. -->
39
+ <slot name="right" />
40
+ </div>
35
41
 
36
42
  <UButton
37
43
  v-if="closable"
@@ -52,9 +58,6 @@
52
58
  v-bind="iconAttrs"
53
59
  />
54
60
  </UButton>
55
-
56
- <!-- @slot Use it to add something after the text. -->
57
- <slot name="right" />
58
61
  </div>
59
62
 
60
63
  <!-- @slot Use it to add something under the text. -->
@@ -79,20 +82,28 @@ defineOptions({ name: "UAlert" });
79
82
 
80
83
  const props = defineProps({
81
84
  /**
82
- * Alert variant.
83
- * @values primary, secondary, thirdary
85
+ * Alert title.
84
86
  */
85
- variant: {
87
+ title: {
86
88
  type: String,
87
- default: UIService.get(defaultConfig, UAlert).default.variant,
89
+ default: "",
88
90
  },
89
91
 
90
92
  /**
91
- * HTML or plain text.
93
+ * Alert description.
94
+ */
95
+ description: {
96
+ type: String,
97
+ default: "",
98
+ },
99
+
100
+ /**
101
+ * Alert variant.
102
+ * @values primary, secondary, thirdary
92
103
  */
93
- html: {
104
+ variant: {
94
105
  type: String,
95
- default: UIService.get(defaultConfig, UAlert).default.html,
106
+ default: UIService.get(defaultConfig, UAlert).default.variant,
96
107
  },
97
108
 
98
109
  /**
@@ -151,22 +162,6 @@ const props = defineProps({
151
162
  type: String,
152
163
  default: "",
153
164
  },
154
-
155
- /**
156
- * Alert title.
157
- */
158
- title: {
159
- type: String,
160
- default: "",
161
- },
162
-
163
- /**
164
- * Alert description.
165
- */
166
- description: {
167
- type: String,
168
- default: "",
169
- },
170
165
  });
171
166
 
172
167
  const emit = defineEmits([
@@ -182,10 +177,13 @@ const {
182
177
  config,
183
178
  wrapperAttrs,
184
179
  bodyAttrs,
180
+ contentAttrs,
181
+ textAttrs,
185
182
  titleAttrs,
186
183
  descriptionAttrs,
187
184
  iconAttrs,
188
185
  buttonAttrs,
186
+ innerWrapperAttrs,
189
187
  hasSlotContent,
190
188
  } = useAttrs(props);
191
189