vueless 0.0.646 → 0.0.648

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
@@ -212,6 +212,7 @@ export const DEFAULT_SVGO_CONFIG = {
212
212
  /* Vueless general */
213
213
  export const ICONS_DIR = "assets/icons";
214
214
  export const VUELESS_LIBRARY = "vueless";
215
+ export const STORYBOOK_DIR = "storybook";
215
216
  export const VUELESS_CONFIG_FILE_NAME = "vueless.config";
216
217
  export const VUELESS_CACHE_DIR = "node_modules/.cache/vueless";
217
218
  export const VUELESS_DIR = `node_modules/${VUELESS_LIBRARY}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.646",
3
+ "version": "0.0.648",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless UI Component Library, powered by Tailwind CSS.",
6
6
  "keywords": [
package/plugin-vite.js CHANGED
@@ -12,6 +12,7 @@ import { getNuxtFiles, getVueFiles } from "./utils/node/helper.js";
12
12
  import { componentResolver, directiveResolver } from "./utils/node/vuelessResolver.js";
13
13
  import { setCustomPropTypes, removeCustomPropTypes } from "./utils/node/dynamicProps.js";
14
14
  import { buildWebTypes } from "./utils/node/webTypes.js";
15
+ import { hideHiddenStories, showHiddenStories } from "./utils/node/dynamicStories.js";
15
16
 
16
17
  /* Automatically importing Vueless components on demand */
17
18
  export const VuelessUnpluginComponents = (options) =>
@@ -36,6 +37,8 @@ export const Vueless = function (options = {}) {
36
37
 
37
38
  /* if server stopped by developer (Ctrl+C) */
38
39
  process.on("SIGINT", async () => {
40
+ await showHiddenStories(isVuelessEnv);
41
+
39
42
  await removeCustomPropTypes(isVuelessEnv);
40
43
 
41
44
  /* remove cached icons */
@@ -68,7 +71,9 @@ export const Vueless = function (options = {}) {
68
71
  }
69
72
 
70
73
  if ((config.command.includes("sb:") && mode === "storybook") || isVuelessEnv) {
74
+ await showHiddenStories(isVuelessEnv);
71
75
  await buildWebTypes();
76
+ await hideHiddenStories(isVuelessEnv);
72
77
  }
73
78
 
74
79
  if (config.command === "build") {
@@ -86,6 +86,14 @@ const { toggleLabelAttrs, itemsAttrs, itemAttrs } = useUI<Config>(defaultConfig)
86
86
  v-bind="toggleLabelAttrs"
87
87
  :data-test="dataTest"
88
88
  >
89
+ <template #label>
90
+ <!--
91
+ @slot Use this to add custom content instead of the label.
92
+ @binding {string} label
93
+ -->
94
+ <slot name="label" :label="label" />
95
+ </template>
96
+
89
97
  <div v-bind="itemsAttrs">
90
98
  <!-- @slot Use it to add UToggleItem directly. -->
91
99
  <slot>
@@ -136,6 +136,14 @@ const { config, checkboxAttrs, iconWrapperAttrs, checkboxLabelAttrs, checkedIcon
136
136
  v-bind="checkboxLabelAttrs"
137
137
  :data-test="`${dataTest}-label`"
138
138
  >
139
+ <template #label>
140
+ <!--
141
+ @slot Use this to add custom content instead of the label.
142
+ @binding {string} label
143
+ -->
144
+ <slot name="label" :label="label" />
145
+ </template>
146
+
139
147
  <input
140
148
  :id="elementId"
141
149
  type="checkbox"
@@ -77,6 +77,14 @@ const { groupLabelAttrs, groupCheckboxAttrs, listAttrs } = useUI<Config>(default
77
77
  v-bind="groupLabelAttrs"
78
78
  :data-test="dataTest"
79
79
  >
80
+ <template #label>
81
+ <!--
82
+ @slot Use this to add custom content instead of the label.
83
+ @binding {string} label
84
+ -->
85
+ <slot name="label" :label="label" />
86
+ </template>
87
+
80
88
  <div v-bind="listAttrs">
81
89
  <!-- @slot Use it to add URadio directly. -->
82
90
  <slot>
@@ -69,6 +69,14 @@ const {
69
69
  v-bind="colorPickerLabelAttrs"
70
70
  :data-test="dataTest"
71
71
  >
72
+ <template #label>
73
+ <!--
74
+ @slot Use this to add custom content instead of the label.
75
+ @binding {string} label
76
+ -->
77
+ <slot name="label" :label="label" />
78
+ </template>
79
+
72
80
  <div v-bind="listAttrs">
73
81
  <div v-bind="unselectedAttrs">
74
82
  <URadio
@@ -266,6 +266,14 @@ const {
266
266
  interactive
267
267
  v-bind="inputLabelAttrs"
268
268
  >
269
+ <template #label>
270
+ <!--
271
+ @slot Use this to add custom content instead of the label.
272
+ @binding {string} label
273
+ -->
274
+ <slot name="label" :label="label" />
275
+ </template>
276
+
269
277
  <label :for="elementId" v-bind="wrapperAttrs">
270
278
  <span
271
279
  v-if="hasSlotContent($slots['left']) || leftIcon"
@@ -274,6 +274,14 @@ const {
274
274
  interactive
275
275
  v-bind="inputLabelAttrs"
276
276
  >
277
+ <template #label>
278
+ <!--
279
+ @slot Use this to add custom content instead of the label.
280
+ @binding {string} label
281
+ -->
282
+ <slot name="label" :label="label" />
283
+ </template>
284
+
277
285
  <div ref="dropZoneRef" :ondrop="onDrop" v-bind="dropzoneAttrs">
278
286
  <UText v-if="hasSlotContent($slots['top'])" :size="size" v-bind="descriptionTopAttrs">
279
287
  <!-- @slot Use it to add something above the component content. -->
@@ -76,6 +76,14 @@ const {
76
76
  v-bind="labelAttrs"
77
77
  :data-test="dataTest"
78
78
  >
79
+ <template #label>
80
+ <!--
81
+ @slot Use this to add custom content instead of the label.
82
+ @binding {string} label
83
+ -->
84
+ <slot name="label" :label="label" />
85
+ </template>
86
+
79
87
  <UButton
80
88
  variant="thirdary"
81
89
  size="sm"
@@ -74,6 +74,14 @@ const { config, inputLabelAttrs, containerAttrs, counterAttrs, totalAttrs, stars
74
74
  v-bind="inputLabelAttrs"
75
75
  :data-test="dataTest"
76
76
  >
77
+ <template #label>
78
+ <!--
79
+ @slot Use this to add custom content instead of the label.
80
+ @binding {string} label
81
+ -->
82
+ <slot name="label" :label="label" />
83
+ </template>
84
+
77
85
  <div v-bind="containerAttrs">
78
86
  <div v-if="counter || hasSlotContent($slots['counter'])" v-bind="counterAttrs">
79
87
  <!--
@@ -88,13 +88,15 @@ const { wrapperAttrs, contentAttrs, labelAttrs, descriptionAttrs } = useUI<Confi
88
88
 
89
89
  <!-- `v-bind` isn't assigned, because the div is system -->
90
90
  <div v-if="label || error || description">
91
- <label
92
- v-if="label"
93
- :for="props.for"
94
- v-bind="labelAttrs"
95
- :data-test="`${dataTest}-label`"
96
- v-text="label"
97
- />
91
+ <label v-if="label" :for="props.for" v-bind="labelAttrs" :data-test="`${dataTest}-label`">
92
+ <!--
93
+ @slot Use this to add custom content instead of the label.
94
+ @binding {string} label
95
+ -->
96
+ <slot name="label" :label="label">
97
+ {{ label }}
98
+ </slot>
99
+ </label>
98
100
 
99
101
  <div v-if="error" v-bind="descriptionAttrs" :data-test="`${dataTest}-error`" v-text="error" />
100
102
 
@@ -111,14 +113,15 @@ const { wrapperAttrs, contentAttrs, labelAttrs, descriptionAttrs } = useUI<Confi
111
113
  </div>
112
114
 
113
115
  <div v-else v-bind="wrapperAttrs">
114
- <label
115
- v-if="label"
116
- ref="labelRef"
117
- :for="props.for"
118
- v-bind="labelAttrs"
119
- :data-test="`${dataTest}-label`"
120
- v-text="label"
121
- />
116
+ <label v-if="label" :for="props.for" v-bind="labelAttrs" :data-test="`${dataTest}-label`">
117
+ <!--
118
+ @slot Use this to add custom content instead of the label.
119
+ @binding {string} label
120
+ -->
121
+ <slot name="label" :label="label">
122
+ {{ label }}
123
+ </slot>
124
+ </label>
122
125
 
123
126
  <div v-bind="contentAttrs">
124
127
  <!-- @slot Use it to add label content. -->
@@ -9,6 +9,7 @@ import ULabel from "../../ui.form-label/ULabel.vue";
9
9
  import UCol from "../../ui.container-col/UCol.vue";
10
10
  import UText from "../../ui.text-block/UText.vue";
11
11
  import UIcon from "../../ui.image-icon/UIcon.vue";
12
+ import UBadge from "../../ui.text-badge/UBadge.vue";
12
13
 
13
14
  import type { Meta, StoryFn } from "@storybook/vue3";
14
15
  import type { Props } from "../types.ts";
@@ -39,7 +40,7 @@ export default {
39
40
  const defaultTemplate = "This is plain text";
40
41
 
41
42
  const DefaultTemplate: StoryFn<ULabelArgs> = (args: ULabelArgs) => ({
42
- components: { ULabel, UText, UIcon },
43
+ components: { ULabel, UText, UIcon, UBadge },
43
44
  setup() {
44
45
  const slots = getSlotNames(ULabel.__name);
45
46
 
@@ -108,10 +109,20 @@ Error.args = { error: "Error description" };
108
109
  export const Disabled = DefaultTemplate.bind({});
109
110
  Disabled.args = { disabled: true };
110
111
 
112
+ export const SlotLabel = DefaultTemplate.bind({});
113
+ SlotLabel.args = {
114
+ label: "Custom badge label",
115
+ slotTemplate: `
116
+ <template #label="{ label }">
117
+ <UBadge :label="label" color="green" />
118
+ </template>
119
+ `,
120
+ };
121
+
111
122
  export const SlotFooter = DefaultTemplate.bind({});
112
123
  SlotFooter.args = {
113
124
  slotTemplate: `
114
- <template #footer>
125
+ <template #bottom>
115
126
  <UIcon name="star" color="green" />
116
127
  </template>
117
128
  `,
@@ -107,6 +107,14 @@ const { radioAttrs, radioLabelAttrs } = useUI<Config>(defaultConfig, mutatedProp
107
107
  v-bind="radioLabelAttrs"
108
108
  :data-test="`${dataTest}-label`"
109
109
  >
110
+ <template #label>
111
+ <!--
112
+ @slot Use this to add custom content instead of the label.
113
+ @binding {string} label
114
+ -->
115
+ <slot name="label" :label="label" />
116
+ </template>
117
+
110
118
  <input
111
119
  :id="elementId"
112
120
  type="radio"
@@ -60,6 +60,14 @@ const { groupLabelAttrs, listAttrs, groupRadioAttrs } = useUI<Config>(defaultCon
60
60
  v-bind="groupLabelAttrs"
61
61
  :data-test="dataTest"
62
62
  >
63
+ <template #label>
64
+ <!--
65
+ @slot Use this to add custom content instead of the label.
66
+ @binding {string} label
67
+ -->
68
+ <slot name="label" :label="label" />
69
+ </template>
70
+
63
71
  <div v-bind="listAttrs">
64
72
  <!-- @slot Use it to add URadio directly. -->
65
73
  <slot>
@@ -456,6 +456,14 @@ const {
456
456
  :data-test="dataTest"
457
457
  :tabindex="-1"
458
458
  >
459
+ <template #label>
460
+ <!--
461
+ @slot Use this to add custom content instead of the label.
462
+ @binding {string} label
463
+ -->
464
+ <slot name="label" :label="label" />
465
+ </template>
466
+
459
467
  <div
460
468
  ref="wrapperRef"
461
469
  :tabindex="searchable || disabled ? -1 : 0"
@@ -100,6 +100,14 @@ const {
100
100
  :data-test="dataTest"
101
101
  @click="onClickToggle"
102
102
  >
103
+ <template #label>
104
+ <!--
105
+ @slot Use this to add custom content instead of the label.
106
+ @binding {string} label
107
+ -->
108
+ <slot name="label" :label="label" />
109
+ </template>
110
+
103
111
  <label :for="elementId" v-bind="wrapperAttrs">
104
112
  <input
105
113
  :id="elementId"
@@ -207,6 +207,14 @@ const { textareaAttrs, textareaLabelAttrs, wrapperAttrs, leftSlotAttrs, rightSlo
207
207
  v-bind="textareaLabelAttrs"
208
208
  :data-test="dataTest"
209
209
  >
210
+ <template #label>
211
+ <!--
212
+ @slot Use this to add custom content instead of the label.
213
+ @binding {string} label
214
+ -->
215
+ <slot name="label" :label="label" />
216
+ </template>
217
+
210
218
  <label ref="wrapperRef" :for="elementId" v-bind="wrapperAttrs">
211
219
  <div
212
220
  v-if="hasSlotContent($slots['left'])"
@@ -62,6 +62,14 @@ const { filesLabelAttrs, itemsAttrs, itemAttrs } = useUI<Config>(defaultConfig);
62
62
  :align="labelAlign"
63
63
  v-bind="filesLabelAttrs"
64
64
  >
65
+ <template #label>
66
+ <!--
67
+ @slot Use this to add custom content instead of the label.
68
+ @binding {string} label
69
+ -->
70
+ <slot name="label" :label="label" />
71
+ </template>
72
+
65
73
  <div v-bind="itemsAttrs">
66
74
  <!-- @slot Use it to add UFile. -->
67
75
  <slot>
@@ -11,20 +11,19 @@ const CLOSING_BRACKET = "}";
11
11
  const IGNORE_PROP = "@ignore";
12
12
  const CUSTOM_PROP = "@custom";
13
13
 
14
- const VUELESS_SRC = path.join(VUELESS_DIR, VUELESS_LOCAL_DIR);
15
-
16
14
  const PROPS_INTERFACE_REG_EXP = /export\s+interface\s+Props\s*{([^}]*)}/s;
17
15
  const UNION_SYMBOLS_REG_EXP = /[?|:"|;]/g;
18
16
  const WORD_IN_QUOTE_REG_EXP = /"([^"]+)"/g;
19
17
 
20
18
  export async function setCustomPropTypes(isVuelessEnv) {
21
- const srcDir = isVuelessEnv ? VUELESS_LOCAL_DIR : VUELESS_SRC;
19
+ const srcDir = isVuelessEnv ? VUELESS_LOCAL_DIR : VUELESS_DIR;
22
20
 
23
21
  for await (const [componentName, componentDir] of Object.entries(COMPONENTS)) {
24
- const customProps =
25
- componentName in vuelessConfig.component && vuelessConfig.component[componentName].props;
22
+ const componentGlobalConfig = vuelessConfig.component[componentName];
23
+ const customProps = componentGlobalConfig && componentGlobalConfig.props;
24
+ const isHiddenStories = componentGlobalConfig && componentGlobalConfig.storybook === false;
26
25
 
27
- if (customProps) {
26
+ if (customProps && !isHiddenStories) {
28
27
  await cacheComponentTypes(path.join(srcDir, componentDir));
29
28
  await modifyComponentTypes(
30
29
  path.join(srcDir, componentDir),
@@ -35,7 +34,7 @@ export async function setCustomPropTypes(isVuelessEnv) {
35
34
  }
36
35
 
37
36
  export async function removeCustomPropTypes(isVuelessEnv) {
38
- const srcDir = isVuelessEnv ? VUELESS_LOCAL_DIR : VUELESS_SRC;
37
+ const srcDir = isVuelessEnv ? VUELESS_LOCAL_DIR : VUELESS_DIR;
39
38
 
40
39
  for await (const componentDir of Object.values(COMPONENTS)) {
41
40
  await restoreComponentTypes(path.join(srcDir, componentDir));
@@ -0,0 +1,65 @@
1
+ import path from "node:path";
2
+ import { existsSync } from "node:fs";
3
+ import { cwd } from "node:process";
4
+ import { rename, readdir } from "node:fs/promises";
5
+
6
+ import { vuelessConfig } from "./vuelessConfig.js";
7
+ import { COMPONENTS, VUELESS_DIR, VUELESS_LOCAL_DIR, STORYBOOK_DIR } from "../../constants.js";
8
+
9
+ async function hideComponentStories(storybookPath) {
10
+ if (existsSync(storybookPath)) {
11
+ const storyFiles = await readdir(storybookPath);
12
+ const visibleFiles = storyFiles.filter((storybookFile) => !storybookFile.includes("hidden"));
13
+
14
+ await Promise.all(
15
+ visibleFiles.map((storybookFile) => {
16
+ const [fileName, extension] = storybookFile.split(".");
17
+
18
+ return rename(
19
+ path.join(storybookPath, storybookFile),
20
+ path.join(storybookPath, `${fileName}_hidden.${extension}`),
21
+ );
22
+ }),
23
+ );
24
+ }
25
+ }
26
+
27
+ async function showComponentStories(storybookPath) {
28
+ if (existsSync(storybookPath)) {
29
+ const storyFiles = await readdir(storybookPath);
30
+ const hiddenFiles = storyFiles.filter((storybookFile) => storybookFile.includes("hidden"));
31
+
32
+ await Promise.all(
33
+ hiddenFiles.map((storybookFile) => {
34
+ const [fileName, extension] = storybookFile.split(".");
35
+ const [originalFileName] = fileName.split("_");
36
+
37
+ return rename(
38
+ path.join(storybookPath, storybookFile),
39
+ path.join(storybookPath, `${originalFileName}.${extension}`),
40
+ );
41
+ }),
42
+ );
43
+ }
44
+ }
45
+
46
+ export async function hideHiddenStories(isVuelessEnv) {
47
+ const srcDir = isVuelessEnv ? VUELESS_LOCAL_DIR : VUELESS_DIR;
48
+
49
+ for await (const [componentName, componentDir] of Object.entries(COMPONENTS)) {
50
+ const componentGlobalConfig = vuelessConfig.component[componentName];
51
+ const isHiddenStories = componentGlobalConfig && componentGlobalConfig.storybook === false;
52
+
53
+ if (isHiddenStories) {
54
+ await hideComponentStories(path.join(cwd(), srcDir, componentDir, STORYBOOK_DIR));
55
+ }
56
+ }
57
+ }
58
+
59
+ export async function showHiddenStories(isVuelessEnv) {
60
+ const srcDir = isVuelessEnv ? VUELESS_LOCAL_DIR : VUELESS_DIR;
61
+
62
+ for await (const componentDir of Object.values(COMPONENTS)) {
63
+ await showComponentStories(path.join(cwd(), srcDir, componentDir, STORYBOOK_DIR));
64
+ }
65
+ }