@winchsa/ui 0.1.12 → 0.1.13

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,14 +1,20 @@
1
1
  <script setup>
2
2
  import { VBtn } from "vuetify/components";
3
3
  const props = defineProps({
4
- color: { type: null, required: false, default: "default" },
5
- variant: { type: null, required: false, default: "text" },
6
- density: { type: null, required: false, default: "comfortable" }
4
+ color: { type: String, required: false, default: "default" },
5
+ variant: { type: String, required: false, default: "text" },
6
+ density: { type: String, required: false, default: "comfortable" }
7
7
  });
8
8
  </script>
9
9
 
10
10
  <template>
11
- <VBtn :icon="true" v-bind="{ ...props, ...$attrs }">
11
+ <VBtn
12
+ :icon="true"
13
+ :color="props.color"
14
+ :variant="props.variant"
15
+ :density="props.density"
16
+ v-bind="$attrs"
17
+ >
12
18
  <slot />
13
19
  </VBtn>
14
20
  </template>
@@ -1,8 +1,8 @@
1
1
  import { VBtn } from 'vuetify/components';
2
2
  type __VLS_Props = {
3
- color?: any;
4
- variant?: any;
5
- density?: any;
3
+ color?: string;
4
+ variant?: 'text' | 'flat' | 'outlined' | 'elevated' | 'tonal' | 'plain';
5
+ density?: 'default' | 'comfortable' | 'compact';
6
6
  };
7
7
  declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
8
8
  declare var __VLS_6: {};
@@ -12,14 +12,14 @@ type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$
12
12
  declare const __VLS_self: import("vue").DefineComponent<__VLS_Props, {
13
13
  VBtn: typeof VBtn;
14
14
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
15
- color: any;
16
- density: any;
17
- variant: any;
15
+ color: string;
16
+ density: "default" | "comfortable" | "compact";
17
+ variant: "text" | "flat" | "outlined" | "elevated" | "tonal" | "plain";
18
18
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
19
19
  declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
20
- color: any;
21
- density: any;
22
- variant: any;
20
+ color: string;
21
+ density: "default" | "comfortable" | "compact";
22
+ variant: "text" | "flat" | "outlined" | "elevated" | "tonal" | "plain";
23
23
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
24
24
  declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
25
25
  export default _default;
@@ -1,6 +1,6 @@
1
1
  <script setup>
2
2
  import { ref } from "vue";
3
- import { VCard, VCardItem, VIcon, VOverlay, VExpandTransition, VProgressCircular, VCardTitle, VBtn } from "vuetify/components";
3
+ import { VCard, VCardItem, VIcon, VOverlay, VExpandTransition, VProgressCircular, VCardTitle } from "vuetify/components";
4
4
  import IconBtn from "../IconBtn.vue";
5
5
  const props = defineProps({
6
6
  collapsed: { type: Boolean, required: false, default: false },
@@ -1,8 +1,8 @@
1
1
  <script setup>
2
2
  import { computed } from "vue";
3
3
  import { VLabel } from "vuetify/components";
4
- import AppCard from "./AppCard.vue";
5
4
  import AppLink from "../forms/AppLink.vue";
5
+ import AppCard from "./AppCard.vue";
6
6
  const props = defineProps({
7
7
  title: { type: String, required: false, default: "" },
8
8
  text: { type: [String, Number], required: false, default: "" },
@@ -1,6 +1,6 @@
1
1
  import { VLabel } from 'vuetify/components';
2
- import AppCard from './AppCard.vue';
3
2
  import AppLink from '../forms/AppLink.vue';
3
+ import AppCard from './AppCard.vue';
4
4
  type __VLS_Props = {
5
5
  title?: string;
6
6
  text?: string | number;
@@ -17,8 +17,8 @@ type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$
17
17
  }>;
18
18
  declare const __VLS_self: import("vue").DefineComponent<__VLS_Props, {
19
19
  VLabel: typeof VLabel;
20
- AppCard: typeof AppCard;
21
20
  AppLink: typeof AppLink;
21
+ AppCard: typeof AppCard;
22
22
  colorStyle: typeof colorStyle;
23
23
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
24
24
  color: string;
@@ -2,7 +2,7 @@
2
2
  import { PerfectScrollbar } from "vue3-perfect-scrollbar";
3
3
  import { useMagicKeys } from "@vueuse/core";
4
4
  import { ref, toRaw, watch, watchEffect } from "vue";
5
- import { VList, VListItem, VListSubheader, VListItemTitle, VCardText, VDialog, VIcon, VDivider, VCol, VRow, VTextField, VBtn } from "vuetify/components";
5
+ import { VList, VListItem, VListSubheader, VListItemTitle, VCardText, VDialog, VIcon, VDivider, VCol, VRow, VTextField } from "vuetify/components";
6
6
  import IconBtn from "../IconBtn.vue";
7
7
  import AppCard from "../cards/AppCard.vue";
8
8
  const props = defineProps({
@@ -1,8 +1,8 @@
1
1
  <script setup>
2
2
  import { VCardText, VIcon } from "vuetify/components";
3
3
  import AppSearchHeaderBg from "../../images/avatar.png";
4
- import AppTextField from "./AppTextField.vue";
5
4
  import AppCard from "../cards/AppCard.vue";
5
+ import AppTextField from "./AppTextField.vue";
6
6
  defineProps({
7
7
  title: { type: String, required: false },
8
8
  subtitle: { type: String, required: false },
@@ -436,7 +436,7 @@ defineExpose({
436
436
 
437
437
  <template #clear>
438
438
  <div
439
- v-if="!disabled && Array.isArray(value) && value.length > 0"
439
+ v-if="(Array.isArray(value) && value?.length > 0 || value) && value && !disabled"
440
440
  class="multiselect-clear cursor-pointer"
441
441
  @mousedown.prevent.stop="value = null"
442
442
  >
@@ -7,11 +7,12 @@ const props = defineProps({
7
7
  hideDetails: { type: Boolean, required: false },
8
8
  label: { type: String, required: false },
9
9
  customId: { type: String, required: false },
10
- errorMessages: { type: [Array, String], required: false },
11
- error: { type: Boolean, required: false }
10
+ errorMessages: { type: [Array, String], required: false }
12
11
  });
13
12
  const model = defineModel({ type: [Array, null], ...{ default: ["", "", "", ""] } });
14
13
  const LangLabel = computed(() => props.label ? t(props.label) : "");
14
+ const allowedLetters = ["A", "B", "J", "D", "R", "S", "X", "T", "E", "G", "K", "L", "Z", "N", "H", "U", "V"];
15
+ const allowedArabicLetters = ["\u0623", "\u0628", "\u062D", "\u062F", "\u0631", "\u0633", "\u0635", "\u0637", "\u0639", "\u0642", "\u0643", "\u0644", "\u0645", "\u0646", "\u0647", "\u0648", "\u064A"];
15
16
  const handleInput = (e, index) => {
16
17
  const input = e.target;
17
18
  const value = input.value;
@@ -26,7 +27,7 @@ const handleInput = (e, index) => {
26
27
  return;
27
28
  }
28
29
  if (index < 3) {
29
- if (/\d/.test(value)) {
30
+ if (!allowedLetters.includes(value) && !allowedArabicLetters.includes(value)) {
30
31
  model.value[index] = "";
31
32
  input.value = "";
32
33
  return;
@@ -47,12 +48,14 @@ const handleInput = (e, index) => {
47
48
  const clear = () => {
48
49
  model.value = null;
49
50
  };
50
- const requiredRule = computed(() => {
51
- return (value) => {
52
- return value?.some(Boolean) || t("validation.required");
53
- };
54
- });
51
+ const requiredRule = (value) => {
52
+ if (value.length !== 4 || !value.every((item) => item !== "")) {
53
+ return t("validation.required");
54
+ }
55
+ return true;
56
+ };
55
57
  watch(() => model.value, (newVal) => {
58
+ console.log(newVal);
56
59
  if (Array.isArray(newVal)) {
57
60
  model.value = newVal;
58
61
  } else {
@@ -79,7 +82,7 @@ watch(() => model.value, (newVal) => {
79
82
  class="app-license-plate-input position-relative"
80
83
  style="min-height: 45px;"
81
84
  :class="{
82
- 'app-license-plate-input--error': isValid.value === false || error
85
+ 'app-license-plate-input--error': !isValid.value && validationErrors.value?.length > 0
83
86
  }"
84
87
  >
85
88
  <input
@@ -132,7 +135,7 @@ watch(() => model.value, (newVal) => {
132
135
  box-sizing: border-box;
133
136
  }
134
137
  .app-license-plate-input.app-license-plate-input--error {
135
- border-color: rgba(var(--v-theme-error), 1);
138
+ border-color: rgba(var(--v-theme-error), 1) !important;
136
139
  }
137
140
  .app-license-plate-input:hover {
138
141
  transition: all 0.3s;
@@ -3,7 +3,6 @@ type __VLS_Props = {
3
3
  label?: string;
4
4
  customId?: string;
5
5
  errorMessages?: string[] | string;
6
- error?: boolean;
7
6
  };
8
7
  type __VLS_PublicProps = {
9
8
  modelValue?: string[] | null;
@@ -1,9 +1,8 @@
1
1
  <script setup>
2
- import { HijriJS } from "../../utils/hijriDate";
3
2
  import { computed, ref, watch } from "vue";
4
3
  import { useI18n } from "vue-i18n";
5
4
  import { VLabel, VIcon, VValidation, VMessages } from "vuetify/components";
6
- import { ruleValidator } from "../../utils/ruleValidator";
5
+ import { HijriJS } from "../../utils/hijriDate";
7
6
  const { t } = useI18n();
8
7
  const props = defineProps({
9
8
  hideDetails: { type: Boolean, required: false },
@@ -12,10 +11,10 @@ const props = defineProps({
12
11
  modelValue: { type: String, required: false },
13
12
  errorMessages: { type: [Array, String], required: false },
14
13
  type: { type: null, required: false },
15
- disabled: { type: Boolean, required: false }
14
+ disabled: { type: Boolean, required: false },
15
+ rules: { type: Array, required: false }
16
16
  });
17
17
  const emit = defineEmits(["update:model-value"]);
18
- const { requiredValidator } = ruleValidator();
19
18
  const date = ref({
20
19
  year: "",
21
20
  month: "",
@@ -143,7 +142,8 @@ watch(() => props.modelValue, (val) => {
143
142
  <VValidation
144
143
  v-slot="{ errorMessages: validationErrors, isValid }"
145
144
  v-model="date"
146
- :rules="[requiredValidator]"
145
+ :rules="rules"
146
+ validate-on="input lazy"
147
147
  >
148
148
  <div class="d-flex flex-column">
149
149
  <VLabel
@@ -152,7 +152,7 @@ watch(() => props.modelValue, (val) => {
152
152
  :text="LangLabel"
153
153
  />
154
154
  <div class="app-date-input position-relative" style="min-height: 45px;" :class="{
155
- 'app-date-input--error': !isValid || yearIsInvalid,
155
+ 'app-date-input--error': !isValid.value || yearIsInvalid,
156
156
  'app-date-input--disabled': disabled
157
157
  }">
158
158
  <input
@@ -224,13 +224,13 @@ watch(() => props.modelValue, (val) => {
224
224
  min-height: 40px;
225
225
  height: 100%;
226
226
  align-items: center;
227
- border: 1px solid rgba(var(--v-border-color), 0.29);
227
+ border: 1px solid rgba(var(--v-border-color), 0.29) !important;
228
228
  border-radius: 6px;
229
229
  transition: all 0.5s;
230
230
  box-sizing: border-box;
231
231
  }
232
232
  .app-date-input.app-date-input--error {
233
- border-color: rgba(var(--v-theme-error), 1);
233
+ border-color: rgba(var(--v-theme-error), 1) !important;
234
234
  }
235
235
  .app-date-input.app-date-input--disabled {
236
236
  border-color: rgba(var(--v-border-color), var(--v-border-opacity)) !important;
@@ -6,6 +6,7 @@ type __VLS_Props = {
6
6
  errorMessages?: string[] | string;
7
7
  type?: 'gregorian' | 'hijri' | string | undefined;
8
8
  disabled?: boolean;
9
+ rules?: ((value: unknown) => string)[];
9
10
  };
10
11
  declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
11
12
  "update:model-value": (value: string) => any;
@@ -20,7 +20,7 @@ declare const headers: import("vue").ComputedRef<{
20
20
  placeholder?: string;
21
21
  type?: import("../../types").EditableDataTableItemType;
22
22
  required?: boolean;
23
- rules?: ((value: unknown) => typeof value | string)[];
23
+ rules?: ((value: unknown) => string)[];
24
24
  renderDataOnMounted?: boolean;
25
25
  renderDataOnBeforeMount?: boolean;
26
26
  showDescription?: boolean;
@@ -161,6 +161,7 @@ const placeholder = (header) => {
161
161
  :disable-if-empty="header.disableIfEmpty"
162
162
  teleported
163
163
  hide-details
164
+ :clearable="header.clearable"
164
165
  />
165
166
 
166
167
  <AutocompleteInput
@@ -187,6 +188,7 @@ const placeholder = (header) => {
187
188
  grouped
188
189
  teleported
189
190
  hide-details
191
+ :clearable="header.clearable"
190
192
  />
191
193
 
192
194
  <DatePicker
@@ -226,7 +228,6 @@ const placeholder = (header) => {
226
228
  class="pa-0 h-100 app-flex-1 app-max-w-150px app-input-outline"
227
229
  :custom-id="`field.${index}.${header.key}`"
228
230
  :error-messages="errorMessages"
229
- :error="error"
230
231
  hide-details
231
232
  />
232
233
 
@@ -235,6 +236,7 @@ const placeholder = (header) => {
235
236
  v-model="item[header.key]"
236
237
  class="pa-0 h-100 app-flex-1 app-input-outline"
237
238
  :custom-id="`field.${index}.${header.key}`"
239
+ :rules="header.rules"
238
240
  :type="item[header.dependsOn]"
239
241
  :disabled="isDisabled"
240
242
  :error-messages="errorMessages"
package/dist/types.d.ts CHANGED
@@ -116,7 +116,7 @@ export type EditableDataTableItem = {
116
116
  placeholder?: string
117
117
  type?: EditableDataTableItemType
118
118
  required?: boolean
119
- rules?: ((value: unknown) => typeof value | string)[]
119
+ rules?: ((value: unknown) => string)[];
120
120
  renderDataOnMounted?: boolean
121
121
  renderDataOnBeforeMount?: boolean
122
122
  showDescription?: boolean
@@ -60,7 +60,7 @@ class HDateClass {
60
60
  }
61
61
  }
62
62
  exports.HDateClass = HDateClass;
63
- let currentLanguage = "en";
63
+ const currentLanguage = "en";
64
64
  function vlidateHijri(year, month, day) {
65
65
  if (month < 1 || month > 12) return false;
66
66
  if (day < 1 || day > 30) return false;
@@ -121,7 +121,7 @@ function gregorianToHijri(pYear, pMonth, pDay) {
121
121
  const c = Math.floor((b - 122.1) / 365.25);
122
122
  const d = Math.floor(365.25 * c);
123
123
  let monthResult = Math.floor((b - d) / 30.6001);
124
- let dayResult = b - d - Math.floor(30.6001 * monthResult);
124
+ const dayResult = b - d - Math.floor(30.6001 * monthResult);
125
125
  if (monthResult > 13) {
126
126
  monthResult -= 12;
127
127
  }
@@ -1824,7 +1824,7 @@ class HDateClass {
1824
1824
  return "";
1825
1825
  }
1826
1826
  }
1827
- let currentLanguage = "en";
1827
+ const currentLanguage = "en";
1828
1828
  function vlidateHijri(year, month, day) {
1829
1829
  if (month < 1 || month > 12)
1830
1830
  return false;
@@ -1890,7 +1890,7 @@ function gregorianToHijri(pYear, pMonth, pDay) {
1890
1890
  const c = Math.floor((b - 122.1) / 365.25);
1891
1891
  const d = Math.floor(365.25 * c);
1892
1892
  let monthResult = Math.floor((b - d) / 30.6001);
1893
- let dayResult = b - d - Math.floor(30.6001 * monthResult);
1893
+ const dayResult = b - d - Math.floor(30.6001 * monthResult);
1894
1894
  if (monthResult > 13) {
1895
1895
  monthResult -= 12;
1896
1896
  }
@@ -26,6 +26,12 @@ export declare const ruleValidator: () => {
26
26
  ibanValidator: (value: unknown) => string | true;
27
27
  dateValidator: (value: unknown) => string | true;
28
28
  regexValidator: (value: string, regex: RegExp, message?: string) => string | true;
29
+ idNumberValidator: (value: string | number | null) => string | undefined;
30
+ requiredManualDateValidator: (value: {
31
+ year?: string;
32
+ month?: string;
33
+ day?: string;
34
+ }) => string | true;
29
35
  };
30
36
  export declare const useFormValidation: () => {
31
37
  validateAndScroll: (refVForm: VForm | undefined) => Promise<boolean>;
@@ -36,6 +36,19 @@ const ruleValidator = () => {
36
36
  }
37
37
  return !!String(value).trim().length || t("validation.iban");
38
38
  };
39
+ const idNumberValidator = value => {
40
+ const str = value?.toString() || "";
41
+ const validStarts = ["1", "2", "3", "4"];
42
+ if (str.length !== 10 || !validStarts.includes(str[0])) {
43
+ return t("validation.invalid");
44
+ }
45
+ };
46
+ const requiredManualDateValidator = value => {
47
+ if ((0, _utils.isEmpty)(value?.day) || (0, _utils.isEmpty)(value?.month) || (0, _utils.isEmpty)(value?.year)) {
48
+ return t("validation.required");
49
+ }
50
+ return true;
51
+ };
39
52
  const emailValidator = value => {
40
53
  if ((0, _utils.isEmpty)(value)) {
41
54
  return true;
@@ -153,7 +166,9 @@ const ruleValidator = () => {
153
166
  lengthValidator,
154
167
  ibanValidator,
155
168
  dateValidator,
156
- regexValidator
169
+ regexValidator,
170
+ idNumberValidator,
171
+ requiredManualDateValidator
157
172
  };
158
173
  };
159
174
  exports.ruleValidator = ruleValidator;
@@ -28,6 +28,19 @@ export const ruleValidator = () => {
28
28
  }
29
29
  return !!String(value).trim().length || t("validation.iban");
30
30
  };
31
+ const idNumberValidator = (value) => {
32
+ const str = value?.toString() || "";
33
+ const validStarts = ["1", "2", "3", "4"];
34
+ if (str.length !== 10 || !validStarts.includes(str[0])) {
35
+ return t("validation.invalid");
36
+ }
37
+ };
38
+ const requiredManualDateValidator = (value) => {
39
+ if (isEmpty(value?.day) || isEmpty(value?.month) || isEmpty(value?.year)) {
40
+ return t("validation.required");
41
+ }
42
+ return true;
43
+ };
31
44
  const emailValidator = (value) => {
32
45
  if (isEmpty(value)) {
33
46
  return true;
@@ -140,7 +153,9 @@ export const ruleValidator = () => {
140
153
  lengthValidator,
141
154
  ibanValidator,
142
155
  dateValidator,
143
- regexValidator
156
+ regexValidator,
157
+ idNumberValidator,
158
+ requiredManualDateValidator
144
159
  };
145
160
  };
146
161
  export const useFormValidation = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@winchsa/ui",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -45,6 +45,7 @@
45
45
  },
46
46
  "devDependencies": {
47
47
  "@tanstack/eslint-plugin-query": "^5.73.3",
48
+ "@typescript-eslint/eslint-plugin": "^7.18.0",
48
49
  "@types/node": "20.17.27",
49
50
  "@vitejs/plugin-vue": "^4.6.2",
50
51
  "eslint": "^8.57.1",
@@ -62,8 +63,8 @@
62
63
  "scripts": {
63
64
  "dev": "vite",
64
65
  "build": "unbuild",
65
- "lint": "eslint \"**/*.{ts,vue,mjs,json}\"",
66
- "lint:fix": "eslint \"**/*.{ts,vue,mjs,json}\" --fix",
66
+ "lint": "eslint \"**/*.{ts,vue,mjs}\"",
67
+ "lint:fix": "eslint \"**/*.{ts,vue,mjs}\" --fix",
67
68
  "bump": "pnpm version patch && pnpm run build && git add . && git commit -m \"chore: release v$(node -p \"require('./package.json').version\")\""
68
69
  }
69
70
  }