@oiij/naive-ui 0.0.59 → 0.0.60

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.
@@ -0,0 +1,29 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ let colord = require("colord");
3
+ colord = require_rolldown_runtime.__toESM(colord);
4
+
5
+ //#region src/composables/_helper.ts
6
+ function getStatusColor(color) {
7
+ if (!color) return void 0;
8
+ const baseColor = (0, colord.colord)(color);
9
+ if (!baseColor.isValid()) return void 0;
10
+ return {
11
+ color,
12
+ hover: baseColor.lighten(.1).toHex(),
13
+ pressed: baseColor.darken(.1).toHex(),
14
+ suppl: baseColor.lighten(.1).toHex()
15
+ };
16
+ }
17
+ function getColors(colors) {
18
+ const { primary, info, success, warning, error } = colors ?? {};
19
+ return {
20
+ primary: getStatusColor(primary),
21
+ info: getStatusColor(info),
22
+ success: getStatusColor(success),
23
+ warning: getStatusColor(warning),
24
+ error: getStatusColor(error)
25
+ };
26
+ }
27
+
28
+ //#endregion
29
+ exports.getColors = getColors;
@@ -0,0 +1,10 @@
1
+ //#region src/composables/_helper.d.ts
2
+ type Colors = {
3
+ primary?: string;
4
+ info?: string;
5
+ success?: string;
6
+ warning?: string;
7
+ error?: string;
8
+ };
9
+ //#endregion
10
+ export { Colors };
@@ -0,0 +1,10 @@
1
+ //#region src/composables/_helper.d.ts
2
+ type Colors = {
3
+ primary?: string;
4
+ info?: string;
5
+ success?: string;
6
+ warning?: string;
7
+ error?: string;
8
+ };
9
+ //#endregion
10
+ export { Colors };
@@ -0,0 +1,27 @@
1
+ import { colord } from "colord";
2
+
3
+ //#region src/composables/_helper.ts
4
+ function getStatusColor(color) {
5
+ if (!color) return void 0;
6
+ const baseColor = colord(color);
7
+ if (!baseColor.isValid()) return void 0;
8
+ return {
9
+ color,
10
+ hover: baseColor.lighten(.1).toHex(),
11
+ pressed: baseColor.darken(.1).toHex(),
12
+ suppl: baseColor.lighten(.1).toHex()
13
+ };
14
+ }
15
+ function getColors(colors) {
16
+ const { primary, info, success, warning, error } = colors ?? {};
17
+ return {
18
+ primary: getStatusColor(primary),
19
+ info: getStatusColor(info),
20
+ success: getStatusColor(success),
21
+ warning: getStatusColor(warning),
22
+ error: getStatusColor(error)
23
+ };
24
+ }
25
+
26
+ //#endregion
27
+ export { getColors };
@@ -1,20 +1,11 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require__helper = require('./_helper.cjs');
2
3
  let vue = require("vue");
3
4
  vue = require_rolldown_runtime.__toESM(vue);
4
- let colord = require("colord");
5
- colord = require_rolldown_runtime.__toESM(colord);
6
5
  let naive_ui = require("naive-ui");
7
6
  naive_ui = require_rolldown_runtime.__toESM(naive_ui);
8
7
 
9
8
  //#region src/composables/useNaiveTheme.ts
10
- function getStatusColor(color = "#ff461f") {
11
- return {
12
- color,
13
- hover: (0, colord.colord)(color).lighten(.1).toHex(),
14
- pressed: (0, colord.colord)(color).darken(.1).toHex(),
15
- suppl: (0, colord.colord)(color).lighten(.1).toHex()
16
- };
17
- }
18
9
  const naiveLocaleMap = {
19
10
  "zh-CN": {
20
11
  name: "简体中文",
@@ -27,18 +18,8 @@ const naiveLocaleMap = {
27
18
  locale: naive_ui.enUS
28
19
  }
29
20
  };
30
- function getColors(color) {
31
- const { primary, info, success, warning, error } = color;
32
- return {
33
- primary: getStatusColor(primary),
34
- info: getStatusColor(info),
35
- success: getStatusColor(success),
36
- warning: getStatusColor(warning),
37
- error: getStatusColor(error)
38
- };
39
- }
40
21
  function useNaiveTheme(options) {
41
- const { language, darkMode, color, globalThemeOverrides } = options ?? {};
22
+ const { language, darkMode, colors, globalThemeOverrides } = options ?? {};
42
23
  const languageRef = (0, vue.ref)((0, vue.toValue)(language));
43
24
  (0, vue.watchEffect)(() => {
44
25
  languageRef.value = (0, vue.toValue)(language);
@@ -47,55 +28,44 @@ function useNaiveTheme(options) {
47
28
  (0, vue.watchEffect)(() => {
48
29
  darkModeRef.value = (0, vue.toValue)(darkMode);
49
30
  });
50
- const { common, Dialog,...extra } = globalThemeOverrides ?? {};
51
- const colorRef = (0, vue.ref)({
52
- primary: "#64748B",
53
- info: "#06b6d4",
54
- success: "#10b981",
55
- warning: "#fbbf24",
56
- error: "#f43f5e",
57
- ...color
58
- });
31
+ const { common,...extra } = globalThemeOverrides ?? {};
32
+ const colorRef = (0, vue.ref)({ ...colors });
59
33
  function setColor(v) {
60
- colorRef.value = v;
34
+ colorRef.value = {
35
+ ...colorRef.value,
36
+ ...v
37
+ };
61
38
  }
62
39
  const theme = (0, vue.computed)(() => {
63
40
  return darkModeRef?.value ? naive_ui.darkTheme : void 0;
64
41
  });
65
42
  const themeOverrides = (0, vue.computed)(() => {
66
- const { primary, info, success, warning, error } = getColors(colorRef.value);
43
+ const { primary, info, success, warning, error } = require__helper.getColors(colorRef.value);
67
44
  return {
68
45
  common: {
69
46
  bodyColor: darkModeRef?.value ? "#1f1f1f" : "#f5f5f5",
70
- primaryColor: primary.color,
71
- primaryColorHover: primary.hover,
72
- primaryColorPressed: primary.pressed,
73
- primaryColorSuppl: primary.suppl,
74
- infoColor: info.color,
75
- infoColorHover: info.hover,
76
- infoColorPressed: info.pressed,
77
- infoColorSuppl: info.suppl,
78
- successColor: success.color,
79
- successColorHover: success.hover,
80
- successColorPressed: success.pressed,
81
- successColorSuppl: success.suppl,
82
- warningColor: warning.color,
83
- warningColorHover: warning.hover,
84
- warningColorPressed: warning.pressed,
85
- warningColorSuppl: warning.suppl,
86
- errorColor: error.color,
87
- errorColorHover: error.hover,
88
- errorColorPressed: error.pressed,
89
- errorColorSuppl: error.suppl,
90
- borderRadius: "6px",
47
+ primaryColor: primary?.color,
48
+ primaryColorHover: primary?.hover,
49
+ primaryColorPressed: primary?.pressed,
50
+ primaryColorSuppl: primary?.suppl,
51
+ infoColor: info?.color,
52
+ infoColorHover: info?.hover,
53
+ infoColorPressed: info?.pressed,
54
+ infoColorSuppl: info?.suppl,
55
+ successColor: success?.color,
56
+ successColorHover: success?.hover,
57
+ successColorPressed: success?.pressed,
58
+ successColorSuppl: success?.suppl,
59
+ warningColor: warning?.color,
60
+ warningColorHover: warning?.hover,
61
+ warningColorPressed: warning?.pressed,
62
+ warningColorSuppl: warning?.suppl,
63
+ errorColor: error?.color,
64
+ errorColorHover: error?.hover,
65
+ errorColorPressed: error?.pressed,
66
+ errorColorSuppl: error?.suppl,
91
67
  ...common
92
68
  },
93
- Dialog: {
94
- borderRadius: "12px",
95
- padding: "20px",
96
- closeMargin: "20px 20px 0 0",
97
- ...Dialog
98
- },
99
69
  ...extra
100
70
  };
101
71
  });
@@ -1,19 +1,13 @@
1
+ import { Colors } from "./_helper.cjs";
1
2
  import { ComputedRef, Ref } from "vue";
2
3
  import { GlobalThemeOverrides, NDateLocale } from "naive-ui";
3
4
  import * as naive_ui_es_themes_interface0 from "naive-ui/es/themes/interface";
4
5
 
5
6
  //#region src/composables/useNaiveTheme.d.ts
6
- interface Color {
7
- primary: string;
8
- info: string;
9
- success: string;
10
- warning: string;
11
- error: string;
12
- }
13
7
  interface NaiveThemeOptions {
14
8
  language?: string | Ref<string>;
15
9
  darkMode?: boolean | Ref<boolean>;
16
- color?: Color;
10
+ colors?: Colors;
17
11
  globalThemeOverrides?: GlobalThemeOverrides;
18
12
  }
19
13
  declare function useNaiveTheme(options?: NaiveThemeOptions): {
@@ -152,19 +146,25 @@ declare function useNaiveTheme(options?: NaiveThemeOptions): {
152
146
  }>;
153
147
  dateLocale: ComputedRef<NDateLocale>;
154
148
  color: Ref<{
155
- primary: string;
156
- info: string;
157
- success: string;
158
- warning: string;
159
- error: string;
160
- }, Color | {
161
- primary: string;
162
- info: string;
163
- success: string;
164
- warning: string;
165
- error: string;
149
+ primary?: string | undefined;
150
+ info?: string | undefined;
151
+ success?: string | undefined;
152
+ warning?: string | undefined;
153
+ error?: string | undefined;
154
+ }, {
155
+ primary?: string;
156
+ info?: string;
157
+ success?: string;
158
+ warning?: string;
159
+ error?: string;
160
+ } | {
161
+ primary?: string | undefined;
162
+ info?: string | undefined;
163
+ success?: string | undefined;
164
+ warning?: string | undefined;
165
+ error?: string | undefined;
166
166
  }>;
167
- setColor: (v: Color) => void;
167
+ setColor: (v: Partial<Colors>) => void;
168
168
  };
169
169
  type NaiveThemeReturns = ReturnType<typeof useNaiveTheme>;
170
170
  //#endregion
@@ -1,19 +1,13 @@
1
+ import { Colors } from "./_helper.js";
1
2
  import { ComputedRef, Ref } from "vue";
2
3
  import { GlobalThemeOverrides, NDateLocale } from "naive-ui";
3
4
  import * as naive_ui_es_themes_interface0 from "naive-ui/es/themes/interface";
4
5
 
5
6
  //#region src/composables/useNaiveTheme.d.ts
6
- interface Color {
7
- primary: string;
8
- info: string;
9
- success: string;
10
- warning: string;
11
- error: string;
12
- }
13
7
  interface NaiveThemeOptions {
14
8
  language?: string | Ref<string>;
15
9
  darkMode?: boolean | Ref<boolean>;
16
- color?: Color;
10
+ colors?: Colors;
17
11
  globalThemeOverrides?: GlobalThemeOverrides;
18
12
  }
19
13
  declare function useNaiveTheme(options?: NaiveThemeOptions): {
@@ -152,19 +146,25 @@ declare function useNaiveTheme(options?: NaiveThemeOptions): {
152
146
  }>;
153
147
  dateLocale: ComputedRef<NDateLocale>;
154
148
  color: Ref<{
155
- primary: string;
156
- info: string;
157
- success: string;
158
- warning: string;
159
- error: string;
160
- }, Color | {
161
- primary: string;
162
- info: string;
163
- success: string;
164
- warning: string;
165
- error: string;
149
+ primary?: string | undefined;
150
+ info?: string | undefined;
151
+ success?: string | undefined;
152
+ warning?: string | undefined;
153
+ error?: string | undefined;
154
+ }, {
155
+ primary?: string;
156
+ info?: string;
157
+ success?: string;
158
+ warning?: string;
159
+ error?: string;
160
+ } | {
161
+ primary?: string | undefined;
162
+ info?: string | undefined;
163
+ success?: string | undefined;
164
+ warning?: string | undefined;
165
+ error?: string | undefined;
166
166
  }>;
167
- setColor: (v: Color) => void;
167
+ setColor: (v: Partial<Colors>) => void;
168
168
  };
169
169
  type NaiveThemeReturns = ReturnType<typeof useNaiveTheme>;
170
170
  //#endregion
@@ -1,16 +1,8 @@
1
+ import { getColors } from "./_helper.js";
1
2
  import { computed, ref, toValue, watchEffect } from "vue";
2
- import { colord } from "colord";
3
3
  import { darkTheme, dateEnUS, dateZhCN, enUS, zhCN } from "naive-ui";
4
4
 
5
5
  //#region src/composables/useNaiveTheme.ts
6
- function getStatusColor(color = "#ff461f") {
7
- return {
8
- color,
9
- hover: colord(color).lighten(.1).toHex(),
10
- pressed: colord(color).darken(.1).toHex(),
11
- suppl: colord(color).lighten(.1).toHex()
12
- };
13
- }
14
6
  const naiveLocaleMap = {
15
7
  "zh-CN": {
16
8
  name: "简体中文",
@@ -23,18 +15,8 @@ const naiveLocaleMap = {
23
15
  locale: enUS
24
16
  }
25
17
  };
26
- function getColors(color) {
27
- const { primary, info, success, warning, error } = color;
28
- return {
29
- primary: getStatusColor(primary),
30
- info: getStatusColor(info),
31
- success: getStatusColor(success),
32
- warning: getStatusColor(warning),
33
- error: getStatusColor(error)
34
- };
35
- }
36
18
  function useNaiveTheme(options) {
37
- const { language, darkMode, color, globalThemeOverrides } = options ?? {};
19
+ const { language, darkMode, colors, globalThemeOverrides } = options ?? {};
38
20
  const languageRef = ref(toValue(language));
39
21
  watchEffect(() => {
40
22
  languageRef.value = toValue(language);
@@ -43,17 +25,13 @@ function useNaiveTheme(options) {
43
25
  watchEffect(() => {
44
26
  darkModeRef.value = toValue(darkMode);
45
27
  });
46
- const { common, Dialog,...extra } = globalThemeOverrides ?? {};
47
- const colorRef = ref({
48
- primary: "#64748B",
49
- info: "#06b6d4",
50
- success: "#10b981",
51
- warning: "#fbbf24",
52
- error: "#f43f5e",
53
- ...color
54
- });
28
+ const { common,...extra } = globalThemeOverrides ?? {};
29
+ const colorRef = ref({ ...colors });
55
30
  function setColor(v) {
56
- colorRef.value = v;
31
+ colorRef.value = {
32
+ ...colorRef.value,
33
+ ...v
34
+ };
57
35
  }
58
36
  const theme = computed(() => {
59
37
  return darkModeRef?.value ? darkTheme : void 0;
@@ -63,35 +41,28 @@ function useNaiveTheme(options) {
63
41
  return {
64
42
  common: {
65
43
  bodyColor: darkModeRef?.value ? "#1f1f1f" : "#f5f5f5",
66
- primaryColor: primary.color,
67
- primaryColorHover: primary.hover,
68
- primaryColorPressed: primary.pressed,
69
- primaryColorSuppl: primary.suppl,
70
- infoColor: info.color,
71
- infoColorHover: info.hover,
72
- infoColorPressed: info.pressed,
73
- infoColorSuppl: info.suppl,
74
- successColor: success.color,
75
- successColorHover: success.hover,
76
- successColorPressed: success.pressed,
77
- successColorSuppl: success.suppl,
78
- warningColor: warning.color,
79
- warningColorHover: warning.hover,
80
- warningColorPressed: warning.pressed,
81
- warningColorSuppl: warning.suppl,
82
- errorColor: error.color,
83
- errorColorHover: error.hover,
84
- errorColorPressed: error.pressed,
85
- errorColorSuppl: error.suppl,
86
- borderRadius: "6px",
44
+ primaryColor: primary?.color,
45
+ primaryColorHover: primary?.hover,
46
+ primaryColorPressed: primary?.pressed,
47
+ primaryColorSuppl: primary?.suppl,
48
+ infoColor: info?.color,
49
+ infoColorHover: info?.hover,
50
+ infoColorPressed: info?.pressed,
51
+ infoColorSuppl: info?.suppl,
52
+ successColor: success?.color,
53
+ successColorHover: success?.hover,
54
+ successColorPressed: success?.pressed,
55
+ successColorSuppl: success?.suppl,
56
+ warningColor: warning?.color,
57
+ warningColorHover: warning?.hover,
58
+ warningColorPressed: warning?.pressed,
59
+ warningColorSuppl: warning?.suppl,
60
+ errorColor: error?.color,
61
+ errorColorHover: error?.hover,
62
+ errorColorPressed: error?.pressed,
63
+ errorColorSuppl: error?.suppl,
87
64
  ...common
88
65
  },
89
- Dialog: {
90
- borderRadius: "12px",
91
- padding: "20px",
92
- closeMargin: "20px 20px 0 0",
93
- ...Dialog
94
- },
95
66
  ...extra
96
67
  };
97
68
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oiij/naive-ui",
3
3
  "type": "module",
4
- "version": "0.0.59",
4
+ "version": "0.0.60",
5
5
  "description": "Some Composable Functions And Components for Vue 3",
6
6
  "author": "oiij",
7
7
  "license": "MIT",
@@ -47,7 +47,7 @@
47
47
  "vue-hooks-plus": "^2.4.1",
48
48
  "@oiij/css-render": "0.0.4",
49
49
  "@oiij/markdown-it": "0.0.6",
50
- "@oiij/use": "0.0.23"
50
+ "@oiij/use": "0.0.24"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/prismjs": "^1.26.5",
@@ -59,9 +59,9 @@
59
59
  "vue": "^3.5.21",
60
60
  "vue-component-type-helpers": "^3.0.7",
61
61
  "vue-hooks-plus": "^2.4.1",
62
- "@oiij/markdown-it": "0.0.6",
63
- "@oiij/use": "0.0.23",
64
- "@oiij/css-render": "0.0.4"
62
+ "@oiij/css-render": "0.0.4",
63
+ "@oiij/use": "0.0.24",
64
+ "@oiij/markdown-it": "0.0.6"
65
65
  },
66
66
  "publishConfig": {
67
67
  "access": "public"