@saasmakers/ui 1.3.3 → 1.3.5

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.
@@ -99,7 +99,7 @@ function onOpenFilePicker() {
99
99
  <div class="pointer-events-none min-w-0 flex flex-1 items-center gap-2">
100
100
  <div
101
101
  v-if="loading"
102
- class="shrink-0 flex items-center justify-center"
102
+ class="flex shrink-0 items-center justify-center"
103
103
  :class="{
104
104
  'h-7 w-7': size === 'xs',
105
105
  'h-8 w-8': size === 'sm',
@@ -49,6 +49,7 @@ export default {
49
49
  'lg',
50
50
  ] satisfies FieldSize[],
51
51
  },
52
+ slugOnly: { control: 'boolean' },
52
53
  type: {
53
54
  control: 'select',
54
55
  options: [
@@ -78,3 +79,12 @@ export const Default: StoryObj<typeof FieldInput> = {
78
79
  placeholder: 'Enter text...',
79
80
  } satisfies Partial<FieldInput>,
80
81
  }
82
+
83
+ export const SlugOnly: StoryObj<typeof FieldInput> = {
84
+ args: {
85
+ label: 'Username',
86
+ modelValue: '',
87
+ placeholder: 'Enter your username',
88
+ slugOnly: true,
89
+ } satisfies Partial<FieldInput>,
90
+ }
@@ -21,6 +21,7 @@ const props = withDefaults(defineProps<Omit<FieldInput, 'modelValue'>>(), {
21
21
  placeholder: '',
22
22
  required: false,
23
23
  size: 'base',
24
+ slugOnly: false,
24
25
  type: 'text',
25
26
  uppercase: false,
26
27
  validation: undefined,
@@ -80,7 +81,10 @@ function onFieldInput(event: Event) {
80
81
  value = props.max.toString()
81
82
  }
82
83
 
83
- if (props.lowercaseOnly) {
84
+ if (props.slugOnly) {
85
+ value = value.toString().toLowerCase().replace(/[^a-z0-9_-]/g, '')
86
+ }
87
+ else if (props.lowercaseOnly) {
84
88
  value = value.toString().toLowerCase()
85
89
  }
86
90
 
@@ -22,7 +22,7 @@ const validationMessage = computed(() => {
22
22
  return unref(firstError.$message)
23
23
  }
24
24
 
25
- switch (false) {
25
+ switch (true) {
26
26
  case ruleIsInvalid(props.validation.alpha): {
27
27
  return t('alpha')
28
28
  }
@@ -114,7 +114,7 @@ function ruleIsInvalid(rule: unknown) {
114
114
  if (rule && typeof rule === 'object' && '$invalid' in rule) {
115
115
  return (rule as {
116
116
  $invalid: boolean
117
- }).$invalid
117
+ }).$invalid === true
118
118
  }
119
119
 
120
120
  return false
@@ -69,6 +69,7 @@ export interface FieldInput {
69
69
  placeholder?: string
70
70
  required?: boolean
71
71
  size?: FieldSize
72
+ slugOnly?: boolean
72
73
  type?: FieldInputType
73
74
  uppercase?: boolean
74
75
  validation?: VuelidateValidation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saasmakers/ui",
3
- "version": "1.3.3",
3
+ "version": "1.3.5",
4
4
  "private": false,
5
5
  "description": "Reusable Nuxt UI components for SaaS Makers projects",
6
6
  "license": "MIT",