@unsource/ui 1.9.0 → 1.9.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.
package/README.md CHANGED
File without changes
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "unsource-ui",
3
3
  "configKey": "unsourceUi",
4
- "version": "1.9.0",
4
+ "version": "1.9.5",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -41,17 +41,13 @@ const module = defineNuxtModule({
41
41
  prefix: "iconsax-linear",
42
42
  dir: resolver.resolve("./runtime/assets/icons/linear")
43
43
  },
44
- // {
45
- // prefix: 'iconsax-outline',
46
- // dir: resolver.resolve('./runtime/assets/icons/outline'),
47
- // },
48
44
  {
49
45
  prefix: "iconsax-twotone",
50
46
  dir: resolver.resolve("./runtime/assets/icons/twotone")
51
47
  },
52
48
  {
53
49
  prefix: "my-icon",
54
- dir: "./assets/icons"
50
+ dir: resolver.resolve("./runtime/assets/icons")
55
51
  }
56
52
  ]
57
53
  });
@@ -1,18 +1,17 @@
1
1
  import type { CardItem } from './UnCard.vue.js';
2
+ import type { CardCustomClass } from "./UnCard.vue.js";
3
+ export type CheckboxCustomInput = Partial<Record<'box' | 'innerBox' | 'card', string>> & {
4
+ item?: CardCustomClass;
5
+ };
6
+ export type CheckboxCustomClass = CheckboxCustomInput & {
7
+ selected?: CheckboxCustomInput;
8
+ notSelected?: CheckboxCustomInput;
9
+ };
2
10
  type __VLS_Props = {
3
11
  item: CardItem;
4
12
  selected?: boolean;
13
+ customClass?: CheckboxCustomClass;
5
14
  };
6
- declare var __VLS_6: {};
7
- type __VLS_Slots = {} & {
8
- default?: (props: typeof __VLS_6) => any;
9
- };
10
- declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, any, string, import("vue").PublicProps, any, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
11
- declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
15
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, any, string, import("vue").PublicProps, any, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
12
16
  declare const _default: typeof __VLS_export;
13
17
  export default _default;
14
- type __VLS_WithSlots<T, S> = T & {
15
- new (): {
16
- $slots: S;
17
- };
18
- };
@@ -1,28 +1,30 @@
1
1
  <template>
2
2
  <div
3
- class="px-4 py-3 flex gap-3 transition duration-300 hover:bg-primary-100"
3
+ class="px-4 py-3 flex items-center gap-2 transition duration-300 hover:bg-primary-100"
4
4
  @click="toggle"
5
5
  >
6
- <div class="flex items-center grow-1 gap-2">
6
+ <div
7
+ name="box"
8
+ :class="[customClass.box, customClass[selected ? 'selected' : 'notSelected']?.box]"
9
+ class="border-(1 solid primary) rounded w-4 h-4 flex justify-center items-center"
10
+ >
7
11
  <div
8
- class="border-(1 solid primary) rounded w-4 h-4 flex justify-center items-center"
9
- >
10
- <div
11
- class="bg-primary rounded h-8px w-10px transition-height duration-200"
12
- :class="[selected ? '!h-10px' : '!h-1px']"
13
- />
14
- </div>
15
- <UnCard :item />
12
+ name="innerBox"
13
+ class="bg-primary rounded h-8px w-10px transition-height duration-200"
14
+ :class="[customClass.innerBox, customClass[selected ? 'selected' : 'notSelected']?.innerBox, selected ? '!h-10px' : '!h-1px']"
15
+ />
16
16
  </div>
17
- <slot />
17
+ <UnCard :class="[customClass.card, customClass[selected ? 'selected' : 'notSelected']?.card]" :custom-class="_mergeWith(customClass.item, customClass[selected ? 'selected' : 'notSelected']?.item, merge)" :item/>
18
18
  </div>
19
19
  </template>
20
20
 
21
21
  <script setup>
22
+ import { _mergeWith, merge } from "#imports";
22
23
  const emit = defineEmits(["input"]);
23
- defineProps({
24
+ const { customClass = {} } = defineProps({
24
25
  item: { type: Object, required: true },
25
- selected: { type: Boolean, required: false }
26
+ selected: { type: Boolean, required: false },
27
+ customClass: { type: Object, required: false }
26
28
  });
27
29
  const toggle = () => {
28
30
  emit("input");
@@ -1,18 +1,17 @@
1
1
  import type { CardItem } from './UnCard.vue.js';
2
+ import type { CardCustomClass } from "./UnCard.vue.js";
3
+ export type CheckboxCustomInput = Partial<Record<'box' | 'innerBox' | 'card', string>> & {
4
+ item?: CardCustomClass;
5
+ };
6
+ export type CheckboxCustomClass = CheckboxCustomInput & {
7
+ selected?: CheckboxCustomInput;
8
+ notSelected?: CheckboxCustomInput;
9
+ };
2
10
  type __VLS_Props = {
3
11
  item: CardItem;
4
12
  selected?: boolean;
13
+ customClass?: CheckboxCustomClass;
5
14
  };
6
- declare var __VLS_6: {};
7
- type __VLS_Slots = {} & {
8
- default?: (props: typeof __VLS_6) => any;
9
- };
10
- declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, any, string, import("vue").PublicProps, any, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
11
- declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
15
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, any, string, import("vue").PublicProps, any, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
12
16
  declare const _default: typeof __VLS_export;
13
17
  export default _default;
14
- type __VLS_WithSlots<T, S> = T & {
15
- new (): {
16
- $slots: S;
17
- };
18
- };
@@ -1,5 +1,5 @@
1
1
  import type { CardCustomClass, CardItem } from './UnCard.vue.js';
2
- export type RadioCustomInput = Partial<Record<'radio' | 'radioInside', string>> & {
2
+ export type RadioCustomInput = Partial<Record<'radio' | 'radioInside' | 'card', string>> & {
3
3
  item?: CardCustomClass;
4
4
  };
5
5
  export type RadioCustomClass = RadioCustomInput & {
@@ -17,13 +17,14 @@
17
17
  <UnCard
18
18
  :item="item"
19
19
  class="!bg-transparent"
20
+ :class="[customClass.card, customClass[selected ? 'selected' : 'notSelected']?.card]"
20
21
  :custom-class="_mergeWith(customClass.item, customClass[selected ? 'selected' : 'notSelected']?.item, merge)"
21
22
  />
22
23
  </div>
23
24
  </template>
24
25
 
25
26
  <script setup>
26
- import { _mergeWith, isPlainObject } from "#imports";
27
+ import { _mergeWith, merge } from "#imports";
27
28
  const emit = defineEmits(["input"]);
28
29
  const { customClass = {} } = defineProps({
29
30
  value: { type: null, required: true },
@@ -34,12 +35,4 @@ const { customClass = {} } = defineProps({
34
35
  const toggle = () => {
35
36
  emit("input");
36
37
  };
37
- const merge = (v, s) => {
38
- if (typeof v === "string") {
39
- return s + " " + v;
40
- }
41
- if (isPlainObject(v)) {
42
- return _mergeWith(s, v, merge);
43
- }
44
- };
45
38
  </script>
@@ -1,5 +1,5 @@
1
1
  import type { CardCustomClass, CardItem } from './UnCard.vue.js';
2
- export type RadioCustomInput = Partial<Record<'radio' | 'radioInside', string>> & {
2
+ export type RadioCustomInput = Partial<Record<'radio' | 'radioInside' | 'card', string>> & {
3
3
  item?: CardCustomClass;
4
4
  };
5
5
  export type RadioCustomClass = RadioCustomInput & {
@@ -1,3 +1,5 @@
1
+ import type { RadioCustomClass } from "./UnRadioItem.vue.js";
2
+ import type { CheckboxCustomClass } from "./UnCheckboxItem.vue.js";
1
3
  type __VLS_Props = {
2
4
  placeholder?: string;
3
5
  icon?: string;
@@ -6,29 +8,21 @@ type __VLS_Props = {
6
8
  multi?: boolean;
7
9
  searchable?: boolean;
8
10
  valueKey?: string;
9
- descriptionKey?: string;
10
- wrapperClass?: string;
11
11
  readonly?: boolean;
12
12
  inline?: boolean;
13
+ customClass?: Partial<Record<'header' | 'icon' | 'label' | 'arrowIcon' | 'wrapper' | 'innerWrapper' | 'search' | 'list' | 'radio' | 'checkbox' | 'checkboxButton', unknown>> & {
14
+ radioItem?: RadioCustomClass;
15
+ checkboxItem?: CheckboxCustomClass;
16
+ };
13
17
  };
14
18
  type __VLS_ModelProps = {
15
19
  modelValue?: any;
16
20
  };
17
21
  type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
18
- declare var __VLS_1: {};
19
- type __VLS_Slots = {} & {
20
- icon?: (props: typeof __VLS_1) => any;
21
- };
22
- declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
22
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
23
23
  "update:modelValue": (value: any) => any;
24
24
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
25
25
  "onUpdate:modelValue"?: ((value: any) => any) | undefined;
26
26
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
27
- declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
28
27
  declare const _default: typeof __VLS_export;
29
28
  export default _default;
30
- type __VLS_WithSlots<T, S> = T & {
31
- new (): {
32
- $slots: S;
33
- };
34
- };
@@ -4,40 +4,28 @@
4
4
  class="cursor-pointer relative"
5
5
  >
6
6
  <div
7
+ name="header"
7
8
  v-if="!inline"
8
- :class="wrapperClass"
9
+ :class="customClass.header"
9
10
  class="bg-white h-12 rounded-2xl flex flex-row gap-1 items-center px-2 py-1 cursor-pointer text-black-1 relative"
10
11
  @click="!readonly && !inline ? show = !show : ''"
11
12
  >
12
- <div
13
+ <UnNuxtIcon
13
14
  v-if="icon"
14
- class="flex items-center justify-center"
15
- @click.self="!readonly && !inline ? show = !show : ''"
16
- >
17
- <slot name="icon">
18
- <UnNuxtIcon
19
- :name="icon"
20
- class="text-xl"
21
- @click.self="!readonly && !inline ? show = !show : ''"
22
- />
23
- </slot>
24
- </div>
25
- <p class="flex-grow text-sm select-none whitespace-nowrap">
15
+ :name="icon"
16
+ :class="customClass.icon"
17
+ class="text-xl"
18
+ />
19
+ <p name="label" :class="customClass.label" class="flex-grow text-sm select-none whitespace-nowrap">
26
20
  {{
27
21
  (multi && Array.isArray(value) && !value?.length || value === void 0 ? placeholder : multi ? value.map((v) => Label(IsSelected(v)).title).join(", ") : Label(Selected).title) || "\u0627\u0646\u062A\u062E\u0627\u0628"
28
22
  }}
29
23
  </p>
30
- <div
31
- class="flex items-center justify-center"
32
- @click.self="!readonly ? show = !show : ''"
33
- >
34
- <UnNuxtIcon
35
- name="iconsax-bold:arrow-down"
36
- class="transform transition-transform duration-300 text-xl"
37
- :class="{ 'rotate-180': show }"
38
- @click.self="show = !show"
39
- />
40
- </div>
24
+ <UnNuxtIcon
25
+ name="iconsax-bold:arrow-down"
26
+ class="transform transition-transform duration-300 text-xl"
27
+ :class="[customClass.arrowIcon, { 'rotate-180': show }]"
28
+ />
41
29
  </div>
42
30
  <Teleport
43
31
  v-if="show && !readonly || inline"
@@ -45,29 +33,32 @@
45
33
  to="body"
46
34
  >
47
35
  <div
36
+ name="wrapper"
48
37
  v-on-click-outside="close"
49
38
  :style="dropdownStyles"
50
39
  class="z-1000 md:mt-3 rounded-2xl w-full min-w-fit text-base flex flex-col items-stretch overflow-y-auto scrollbar-thin"
51
40
  :class="[
52
- inline ? 'relative' : 'absolute',
41
+ customClass.wrapper.inline ? 'relative' : 'absolute',
53
42
  light ? 'bg-white' : 'bg-border',
54
43
  inline ? '' : Searchable ? 'md:max-h-230px' : 'md:max-h-160px'
55
44
  ]"
56
45
  >
57
46
  <div
47
+ name="innerWrapper"
48
+ :class="customClass.innerWrapper"
58
49
  class="flex flex-col items-stretch min-w-fit <md:(max-h-80dvh bg-white border-(1 solid primary) rounded-t-2xl pb-24)"
59
50
  >
60
- <div
61
- v-if="Searchable"
62
- class="p-1"
63
- >
64
51
  <UnSearch
52
+ name="search"
53
+ :class="customClass.search"
54
+ v-if="Searchable"
65
55
  v-model="search"
66
56
  class="h-10"
67
57
  placeholder="جستجو..."
68
58
  />
69
- </div>
70
59
  <div
60
+ name="list"
61
+ :class="customClass.list"
71
62
  class="divide-y divide-border min-w-fit divide-dashed divide-solid flex flex-col items-stretch overflow-y-auto scrollbar-width-thin !children:b-x-0"
72
63
  >
73
64
  <template v-if="multi">
@@ -76,6 +67,8 @@
76
67
  :key="Value(option)"
77
68
  :value="Value(option)"
78
69
  :item="Label(option)"
70
+ :class="customClass.checkbox"
71
+ :custom-class="customClass.checkboxItem"
79
72
  :selected="value?.includes(Value(option))"
80
73
  @click="handleSelect(option)"
81
74
  />
@@ -84,6 +77,7 @@
84
77
  variant="primary-fill"
85
78
  label="تایید"
86
79
  class="m-2"
80
+ :class="customClass.checkboxButton"
87
81
  @click="close"
88
82
  />
89
83
  </template>
@@ -93,6 +87,8 @@
93
87
  :key="Value(option)"
94
88
  :value="Value(option)"
95
89
  :item="Label(option)"
90
+ :class="customClass.radio"
91
+ :custom-class="customClass.radioItem"
96
92
  :selected="isEqual(Value(option), value)"
97
93
  class="!min-w-60"
98
94
  @click="handleSelect(option)"
@@ -108,7 +104,7 @@
108
104
  <script setup>
109
105
  import { vOnClickOutside } from "@vueuse/components";
110
106
  import { _get, computed, isEqual, nextTick, ref, watch } from "#imports";
111
- const props = defineProps({
107
+ const { valueKey, items, multi, searchable, customClass = {} } = defineProps({
112
108
  placeholder: { type: String, required: false },
113
109
  icon: { type: String, required: false },
114
110
  light: { type: Boolean, required: false },
@@ -116,41 +112,40 @@ const props = defineProps({
116
112
  multi: { type: Boolean, required: false },
117
113
  searchable: { type: Boolean, required: false },
118
114
  valueKey: { type: String, required: false },
119
- descriptionKey: { type: String, required: false },
120
- wrapperClass: { type: String, required: false },
121
115
  readonly: { type: Boolean, required: false },
122
- inline: { type: Boolean, required: false }
116
+ inline: { type: Boolean, required: false },
117
+ customClass: { type: Object, required: false }
123
118
  });
124
119
  const value = defineModel({ type: null });
125
120
  const show = ref(false);
126
121
  const search = ref("");
127
- const Searchable = computed(() => props.searchable && props.items?.length > 8);
122
+ const Searchable = computed(() => searchable && items?.length > 8);
128
123
  const searchedOptions = computed(() => {
129
- if (!search.value) return props.items;
130
- return props.items.filter((option) => Label(option).title?.toLowerCase().includes(search.value?.toLowerCase()?.trim()));
124
+ if (!search.value) return items;
125
+ return items.filter((option) => Label(option).title?.toLowerCase().includes(search.value?.toLowerCase()?.trim()));
131
126
  });
132
127
  const close = () => {
133
128
  show.value = false;
134
129
  };
135
130
  const dropdownStyles = ref({});
136
- const Value = (option) => _get(option, props.valueKey || "value", option) || option;
131
+ const Value = (option) => _get(option, valueKey || "value", option) || option;
137
132
  const Label = (option) => typeof option === "string" ? { title: option } : option;
138
- const Selected = computed(() => props.items.find((o) => isEqual(Value(o), value.value)));
139
- const IsSelected = (v) => props.items.find((o) => isEqual(Value(o), v));
133
+ const Selected = computed(() => items.find((o) => isEqual(Value(o), value.value)));
134
+ const IsSelected = (v) => items.find((o) => isEqual(Value(o), v));
140
135
  const handleSelect = (data) => {
141
- if (!props.multi) {
136
+ if (!multi) {
142
137
  value.value = Value(data);
143
138
  close();
144
139
  return;
145
140
  }
146
141
  const existingItem = value.value?.includes(Value(data));
147
- let items = [];
142
+ let items2 = [];
148
143
  if (existingItem) {
149
- items = value.value.filter((item) => item !== Value(data));
144
+ items2 = value.value.filter((item) => item !== Value(data));
150
145
  } else {
151
- items = [...value.value || [], Value(data)];
146
+ items2 = [...value.value || [], Value(data)];
152
147
  }
153
- value.value = items;
148
+ value.value = items2;
154
149
  };
155
150
  const wrapper = ref(null);
156
151
  const updateDropdownPosition = () => {
@@ -1,3 +1,5 @@
1
+ import type { RadioCustomClass } from "./UnRadioItem.vue.js";
2
+ import type { CheckboxCustomClass } from "./UnCheckboxItem.vue.js";
1
3
  type __VLS_Props = {
2
4
  placeholder?: string;
3
5
  icon?: string;
@@ -6,29 +8,21 @@ type __VLS_Props = {
6
8
  multi?: boolean;
7
9
  searchable?: boolean;
8
10
  valueKey?: string;
9
- descriptionKey?: string;
10
- wrapperClass?: string;
11
11
  readonly?: boolean;
12
12
  inline?: boolean;
13
+ customClass?: Partial<Record<'header' | 'icon' | 'label' | 'arrowIcon' | 'wrapper' | 'innerWrapper' | 'search' | 'list' | 'radio' | 'checkbox' | 'checkboxButton', unknown>> & {
14
+ radioItem?: RadioCustomClass;
15
+ checkboxItem?: CheckboxCustomClass;
16
+ };
13
17
  };
14
18
  type __VLS_ModelProps = {
15
19
  modelValue?: any;
16
20
  };
17
21
  type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
18
- declare var __VLS_1: {};
19
- type __VLS_Slots = {} & {
20
- icon?: (props: typeof __VLS_1) => any;
21
- };
22
- declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
22
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
23
23
  "update:modelValue": (value: any) => any;
24
24
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
25
25
  "onUpdate:modelValue"?: ((value: any) => any) | undefined;
26
26
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
27
- declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
28
27
  declare const _default: typeof __VLS_export;
29
28
  export default _default;
30
- type __VLS_WithSlots<T, S> = T & {
31
- new (): {
32
- $slots: S;
33
- };
34
- };
@@ -0,0 +1 @@
1
+ export declare const merge: (v: string | Record<string, unknown>, s: string | Record<string, unknown>) => string | Record<string, unknown> | undefined;
@@ -0,0 +1,9 @@
1
+ import { _mergeWith, isPlainObject } from "#imports";
2
+ export const merge = (v, s) => {
3
+ if (typeof v === "string") {
4
+ return s + " " + v;
5
+ }
6
+ if (isPlainObject(v)) {
7
+ return _mergeWith(s, v, merge);
8
+ }
9
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unsource/ui",
3
- "version": "1.9.0",
3
+ "version": "1.9.5",
4
4
  "private": false,
5
5
  "description": "nuxt ui kit for unsource env",
6
6
  "repository": "https://github.com/alisa2142/unsource-ui",
@@ -24,7 +24,7 @@
24
24
  "dist"
25
25
  ],
26
26
  "scripts": {
27
- "prepack": "nuxt-module-build build",
27
+
28
28
  "dev": "npm run dev:prepare && nuxi dev playground",
29
29
  "dev:build": "nuxi build playground",
30
30
  "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
@@ -1,3 +0,0 @@
1
- {
2
- "eslint.experimental.useFlatConfig": true
3
- }