ui-thing 0.1.44 → 0.1.46

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": "ui-thing",
3
- "version": "0.1.44",
3
+ "version": "0.1.46",
4
4
  "description": "CLI used to add Nuxt 3 components to a project",
5
5
  "keywords": [
6
6
  "cli",
@@ -11,6 +11,7 @@ import { compareUIConfig } from "../utils/compareUIConfig";
11
11
  import { addModuleToConfig, getNuxtConfig, getUIConfig, updateConfig } from "../utils/config";
12
12
  import { fileExists } from "../utils/fileExists";
13
13
  import { installPackages } from "../utils/installPackages";
14
+ import { installValidator } from "../utils/installValidator";
14
15
  import { printFancyBoxMessage } from "../utils/printFancyBoxMessage";
15
16
  import { promptUserForComponents } from "../utils/promptForComponents";
16
17
  import { writeFile } from "../utils/writeFile";
@@ -281,6 +282,21 @@ export const add = new Command()
281
282
  }
282
283
  }
283
284
 
285
+ // check if any of the components has the `askValidator` property set to true
286
+ let shouldAskValidator = false;
287
+ // Check if any component has askValidator set to true
288
+ for (const component of found) {
289
+ if (component.askValidator) {
290
+ shouldAskValidator = true;
291
+ break;
292
+ }
293
+ }
294
+
295
+ if (shouldAskValidator) {
296
+ // Ask the user for their choice of validator
297
+ await installValidator(uiConfig.packageManager);
298
+ }
299
+
284
300
  printFancyBoxMessage(
285
301
  "All Done!",
286
302
  { title: "Components Added" },
package/src/comps.ts CHANGED
@@ -338,7 +338,7 @@ export default [
338
338
  fileName: "Button.vue",
339
339
  dirPath: "app/components/Ui",
340
340
  fileContent:
341
- '<template>\n <component\n :is="elementType"\n :class="\n buttonStyles({\n hasIcon: !!icon,\n disabled: disabled || loading,\n variant: variant,\n size: size,\n class: props.class,\n })\n "\n :disabled="disabled || loading"\n v-bind="forwarded"\n >\n <slot name="iconLeft">\n <div\n v-if="icon && iconPlacement == \'left\'"\n class="group-hover:translate-x-100 flex w-0 shrink-0 translate-x-[0%] items-center justify-center pr-0 opacity-0 transition-all duration-200 group-hover:w-6 group-hover:pr-2 group-hover:opacity-100"\n >\n <Icon :name="icon" class="size-5" />\n </div>\n </slot>\n <slot>\n <span v-if="text">{{ text }}</span>\n </slot>\n <slot name="iconRight">\n <div\n v-if="icon && iconPlacement == \'right\'"\n class="flex w-0 shrink-0 translate-x-[100%] items-center justify-center pl-0 opacity-0 transition-all duration-200 group-hover:w-6 group-hover:translate-x-0 group-hover:pl-2 group-hover:opacity-100"\n >\n <Icon :name="icon" class="size-5" />\n </div>\n </slot>\n </component>\n</template>\n\n<script setup lang="ts">\n import { reactiveOmit } from "@vueuse/core";\n import { useForwardProps } from "radix-vue";\n import type { NuxtLinkProps } from "#app/components";\n\n type ButtonProps = VariantProps<typeof buttonStyles>;\n const props = withDefaults(\n defineProps<\n NuxtLinkProps & {\n /** The type fro the button */\n type?: "button" | "submit" | "reset";\n /** Whether the button is disabled */\n disabled?: boolean;\n /** Whether the button is loading */\n loading?: boolean;\n /** The action to perform when the button is clicked */\n onClick?: any;\n /** The element to render the button as */\n as?: string;\n /** Custom class(es) to add to parent element */\n class?: any;\n /** The variant of the button */\n variant?: ButtonProps["variant"];\n /** The size of the button */\n size?: ButtonProps["size"];\n /** The text to display in the button */\n text?: string;\n /** Should the icon be displayed on the `left` or the `right`? */\n iconPlacement?: "left" | "right";\n /** The icon to display in the button */\n icon?: string;\n }\n >(),\n {\n type: "button",\n }\n );\n\n const elementType = computed(() => {\n if (props.as) return props.as;\n if (props.href || props.to || props.target) return resolveComponent("NuxtLink");\n return "button";\n });\n\n const forwarded = useForwardProps(\n reactiveOmit(\n props,\n "class",\n "text",\n "icon",\n "iconPlacement",\n "size",\n "variant",\n "as",\n "loading",\n "disabled"\n )\n );\n</script>\n',
341
+ '<template>\n <component\n :is="elementType"\n :class="\n buttonStyles({\n hasIcon: !!icon,\n disabled: disabled || loading,\n variant: variant,\n size: size,\n class: props.class,\n })\n "\n :disabled="disabled || loading"\n v-bind="forwarded"\n >\n <slot name="iconLeft">\n <div\n v-if="icon && iconPlacement == \'left\'"\n class="group-hover:translate-x-100 flex w-0 shrink-0 translate-x-[0%] items-center justify-center pr-0 opacity-0 transition-all duration-200 group-hover:w-6 group-hover:pr-2 group-hover:opacity-100"\n >\n <Icon :name="icon" class="size-5" />\n </div>\n </slot>\n <slot name="loading">\n <Icon v-if="loading" class="size-4 shrink-0" :name="loadingIcon" />\n </slot>\n <slot>\n <span v-if="text">{{ text }}</span>\n </slot>\n <slot name="iconRight">\n <div\n v-if="icon && iconPlacement == \'right\'"\n class="flex w-0 shrink-0 translate-x-[100%] items-center justify-center pl-0 opacity-0 transition-all duration-200 group-hover:w-6 group-hover:translate-x-0 group-hover:pl-2 group-hover:opacity-100"\n >\n <Icon :name="icon" class="size-5" />\n </div>\n </slot>\n </component>\n</template>\n\n<script setup lang="ts">\n import { reactiveOmit } from "@vueuse/core";\n import { useForwardProps } from "radix-vue";\n import type { NuxtLinkProps } from "#app/components";\n\n type ButtonProps = VariantProps<typeof buttonStyles>;\n const props = withDefaults(\n defineProps<\n NuxtLinkProps & {\n /** The type for the button */\n type?: "button" | "submit" | "reset";\n /** Whether the button is disabled */\n disabled?: boolean;\n /** Whether the button is loading */\n loading?: boolean;\n /** The action to perform when the button is clicked */\n onClick?: any;\n /** The element to render the button as */\n as?: string;\n /** Custom class(es) to add to parent element */\n class?: any;\n /** The variant of the button */\n variant?: ButtonProps["variant"];\n /** The size of the button */\n size?: ButtonProps["size"];\n /** The text to display in the button */\n text?: string;\n /** Should the icon be displayed on the `left` or the `right`? */\n iconPlacement?: "left" | "right";\n /** The icon to display in the button */\n icon?: string;\n /** The icon to display when the button is loading */\n loadingIcon?: string;\n }\n >(),\n {\n type: "button",\n loadingIcon: "line-md:loading-loop",\n iconPlacement: "left",\n loading: false,\n }\n );\n\n const elementType = computed(() => {\n if (props.as) return props.as;\n if (props.href || props.to || props.target) return resolveComponent("NuxtLink");\n return "button";\n });\n\n const forwarded = useForwardProps(\n reactiveOmit(\n props,\n "class",\n "text",\n "icon",\n "iconPlacement",\n "size",\n "variant",\n "as",\n "loading",\n "disabled",\n "loadingIcon"\n )\n );\n</script>\n',
342
342
  },
343
343
  ],
344
344
  composables: [],
@@ -0,0 +1,35 @@
1
+ import prompts from "prompts";
2
+
3
+ import { installPackages } from "./installPackages";
4
+
5
+ export const installValidator = async (packageManager: string) => {
6
+ // Depending on the selected validator, install the corresponding packages
7
+ const validatorPackages = {
8
+ yup: ["yup", "@vee-validate/yup"],
9
+ zod: ["zod", "@vee-validate/zod"],
10
+ joi: ["joi", "@vee-validate/joi"],
11
+ valibot: ["valibot", "@vee-validate/valibot"],
12
+ };
13
+
14
+ const { validator }: { validator: keyof typeof validatorPackages } = await prompts({
15
+ type: "select",
16
+ name: "validator",
17
+ message: "Choose the validator package to use with Vee Validate: ",
18
+ choices: [
19
+ { title: "Yup", value: "yup" },
20
+ { title: "Zod", value: "zod" },
21
+ { title: "Joi", value: "joi" },
22
+ { title: "Valibot", value: "valibot" },
23
+ ],
24
+ });
25
+ if (!validator) {
26
+ console.log("No validator package selected");
27
+ return;
28
+ }
29
+ console.log(`Selected ${validator} as the validator package`);
30
+
31
+ if (validatorPackages[validator]) {
32
+ await installPackages(packageManager, validatorPackages[validator]);
33
+ }
34
+ return validator;
35
+ };