sprintify-ui 0.0.138 → 0.0.140

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.
@@ -1,7 +1,7 @@
1
1
  declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
2
2
  contrast: 'low' | 'high';
3
3
  color: 'gray' | 'red' | 'orange' | 'yellow' | 'green' | 'blue' | 'indigo' | 'purple' | 'pink' | string;
4
- size: 'base' | 'lg';
4
+ size: 'sm' | 'base' | 'lg';
5
5
  icon?: string | undefined;
6
6
  }>, {
7
7
  contrast: string;
@@ -11,7 +11,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
11
11
  }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
12
12
  contrast: 'low' | 'high';
13
13
  color: 'gray' | 'red' | 'orange' | 'yellow' | 'green' | 'blue' | 'indigo' | 'purple' | 'pink' | string;
14
- size: 'base' | 'lg';
14
+ size: 'sm' | 'base' | 'lg';
15
15
  icon?: string | undefined;
16
16
  }>, {
17
17
  contrast: string;
@@ -21,7 +21,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
21
21
  }>>>, {
22
22
  color: 'gray' | 'red' | 'orange' | 'yellow' | 'green' | 'blue' | 'indigo' | 'purple' | 'pink' | string;
23
23
  icon: string;
24
- size: 'base' | 'lg';
24
+ size: 'sm' | 'base' | 'lg';
25
25
  contrast: 'low' | 'high';
26
26
  }>, {
27
27
  default: (_: {}) => any;
@@ -1,9 +1,9 @@
1
1
  import { PropType } from 'vue';
2
- import { Option } from '@/types';
2
+ import { NormalizedOption, Option, OptionValue } from '@/types';
3
3
  declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
4
4
  modelValue: {
5
5
  default: undefined;
6
- type: PropType<Option | undefined>;
6
+ type: PropType<OptionValue | undefined>;
7
7
  };
8
8
  name: {
9
9
  default: undefined;
@@ -44,7 +44,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
44
44
  }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
45
45
  modelValue: {
46
46
  default: undefined;
47
- type: PropType<Option | undefined>;
47
+ type: PropType<OptionValue | undefined>;
48
48
  };
49
49
  name: {
50
50
  default: undefined;
@@ -88,13 +88,13 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
88
88
  required: boolean;
89
89
  name: string;
90
90
  disabled: boolean;
91
- modelValue: Option | undefined;
91
+ modelValue: OptionValue | undefined;
92
92
  hasError: boolean;
93
93
  inputClass: string;
94
94
  labelClass: string;
95
95
  }>, {
96
96
  option: (_: {
97
- option: import("@/types").NormalizedOption;
97
+ option: NormalizedOption;
98
98
  }) => any;
99
99
  }>;
100
100
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sprintify-ui",
3
- "version": "0.0.138",
3
+ "version": "0.0.140",
4
4
  "scripts": {
5
5
  "build": "rimraf dist && vue-tsc && vite build",
6
6
  "build-fast": "rimraf dist && vite build",
@@ -14,7 +14,7 @@ const colors = [
14
14
  '#dbeafe',
15
15
  ];
16
16
 
17
- const sizes = ['base', 'lg'];
17
+ const sizes = ['sm', 'base', 'lg'];
18
18
 
19
19
  export default {
20
20
  title: 'Components/BaseBadge',
@@ -26,7 +26,7 @@ const props = withDefaults(
26
26
  | 'purple'
27
27
  | 'pink'
28
28
  | string;
29
- size: 'base' | 'lg';
29
+ size: 'sm' | 'base' | 'lg';
30
30
  icon?: string;
31
31
  }>(),
32
32
  {
@@ -118,6 +118,9 @@ const colorStyle = computed((): Record<string, string> => {
118
118
  });
119
119
 
120
120
  const sizeClasses = computed(() => {
121
+ if (props.size == 'sm') {
122
+ return 'px-2 py-px text-[11px]';
123
+ }
121
124
  if (props.size == 'base') {
122
125
  return 'px-2.5 py-0.5 text-xs';
123
126
  }
@@ -128,6 +131,9 @@ const sizeClasses = computed(() => {
128
131
  });
129
132
 
130
133
  const iconSizeClasses = computed(() => {
134
+ if (props.size == 'sm') {
135
+ return 'h-2.5 w-2.5 mr-1 -ml-px';
136
+ }
131
137
  if (props.size == 'base') {
132
138
  return 'h-3 w-3 mr-1 -ml-0.5';
133
139
  }
@@ -1,6 +1,7 @@
1
1
  import { options } from '../../.storybook/utils';
2
2
  import BaseRadioGroup from './BaseRadioGroup.vue';
3
3
  import { createFieldStory } from '@/../.storybook/utils';
4
+ import ShowValue from '../../.storybook/components/ShowValue.vue';
4
5
 
5
6
  export default {
6
7
  title: 'Form/BaseRadioGroup',
@@ -15,9 +16,9 @@ export default {
15
16
  };
16
17
 
17
18
  const Template = (args) => ({
18
- components: { BaseRadioGroup },
19
+ components: { BaseRadioGroup, ShowValue },
19
20
  setup() {
20
- const value = ref(null);
21
+ const value = ref(options[0].value);
21
22
  function onSubmit() {
22
23
  alert('submit');
23
24
  }
@@ -27,7 +28,7 @@ const Template = (args) => ({
27
28
  <form @submit.prevent="onSubmit">
28
29
  <BaseRadioGroup v-model="value" v-bind="args"></BaseRadioGroup>
29
30
  <button type="submit" class="btn btn-primary mt-4">Submit</button>
30
- <p class="mt-5 text-sm">Value: <span class="bg-slate-200 font-mono px-1 py-px rounded">{{ value ?? 'NULL' }}</span></p>
31
+ <ShowValue :value="value">{{ value }}</ShowValue>
31
32
  </form>
32
33
  `,
33
34
  });
@@ -43,7 +44,6 @@ Required.args = {
43
44
  export const Disabled = Template.bind({});
44
45
  Disabled.args = {
45
46
  disabled: true,
46
- modelValue: { label: 'Dark Maul', value: 'darth_maul' },
47
47
  };
48
48
 
49
49
  export const SlotOption = (args) => ({
@@ -14,12 +14,12 @@
14
14
  :id="name + '-' + option.value"
15
15
  type="radio"
16
16
  :name="nameInternal"
17
- :checked="isSelected(option)"
17
+ :checked="isChecked(option)"
18
18
  :required="requiredInternal"
19
19
  :disabled="disabled"
20
20
  :value="option.value"
21
21
  :class="inputClass"
22
- @input="emitUpdate(option.option)"
22
+ @input="emitUpdate(option.value)"
23
23
  />
24
24
 
25
25
  <slot name="option" :option="option">
@@ -33,15 +33,16 @@
33
33
 
34
34
  <script lang="ts" setup>
35
35
  import { PropType } from 'vue';
36
- import { Option } from '@/types';
37
- import { useHasOptions } from '@/composables/hasOptions';
36
+ import { NormalizedOption, Option, OptionValue } from '@/types';
38
37
  import { useField } from '@/composables/field';
39
38
  import { uniqueId } from 'lodash';
40
39
 
41
40
  const props = defineProps({
42
41
  modelValue: {
43
42
  default: undefined,
44
- type: [Object, null] as PropType<Option | undefined>,
43
+ type: [String, Number, null, undefined] as PropType<
44
+ OptionValue | undefined
45
+ >,
45
46
  },
46
47
  name: {
47
48
  default: undefined,
@@ -102,11 +103,20 @@ const { nameInternal, requiredInternal, emitUpdate } = useField({
102
103
  labelClass: 'mb-3 font-medium',
103
104
  });
104
105
 
105
- const { normalizedOptions, isSelected } = useHasOptions(
106
- computed(() => props.modelValue),
107
- computed(() => props.options),
108
- computed(() => props.labelKey),
109
- computed(() => props.valueKey),
110
- computed(() => false)
111
- );
106
+ function isChecked(option: NormalizedOption): boolean {
107
+ if (props.modelValue) {
108
+ return props.modelValue == option.value;
109
+ }
110
+ return false;
111
+ }
112
+
113
+ const normalizedOptions = computed((): NormalizedOption[] => {
114
+ return props.options.map((option) => {
115
+ return {
116
+ label: option[props.labelKey] as string,
117
+ value: option[props.valueKey] as string | number,
118
+ option: option,
119
+ } as NormalizedOption;
120
+ });
121
+ });
112
122
  </script>