@pixelium/web-vue 0.0.2-fix → 0.0.3-alpha

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.
Files changed (284) hide show
  1. package/README.md +42 -0
  2. package/README.zh.md +6 -3
  3. package/dist/font.css +1 -1
  4. package/dist/index.d.ts +1602 -248
  5. package/dist/normalize.css +2 -0
  6. package/dist/pixelium-vue-icon-hn.cjs +1 -1
  7. package/dist/pixelium-vue-icon-hn.css +2 -1
  8. package/dist/pixelium-vue-icon-hn.js +8533 -8154
  9. package/dist/pixelium-vue-icon-hn.umd.cjs +1 -1
  10. package/dist/pixelium-vue-icon-pa.cjs +1 -1
  11. package/dist/pixelium-vue-icon-pa.css +2 -1
  12. package/dist/pixelium-vue-icon-pa.js +10625 -10143
  13. package/dist/pixelium-vue-icon-pa.umd.cjs +1 -1
  14. package/dist/pixelium-vue.cjs +2 -2
  15. package/dist/pixelium-vue.css +2 -1
  16. package/dist/pixelium-vue.js +7407 -5854
  17. package/dist/pixelium-vue.umd.cjs +2 -2
  18. package/es/aside/index.css +1 -0
  19. package/es/aside/index.js +46 -151
  20. package/es/auto-complete/draw.d.ts +1 -1
  21. package/es/auto-complete/draw.js +26 -51
  22. package/es/auto-complete/index.css +92 -32
  23. package/es/auto-complete/index.d.ts +12 -15
  24. package/es/auto-complete/index.js +338 -400
  25. package/es/auto-complete/type.d.ts +25 -13
  26. package/es/avatar/css.js +2 -0
  27. package/es/avatar/draw.d.ts +2 -0
  28. package/es/avatar/draw.js +11 -0
  29. package/es/avatar/index.css +49 -0
  30. package/es/avatar/index.d.ts +15 -0
  31. package/es/avatar/index.js +110 -0
  32. package/es/avatar/type.d.ts +34 -0
  33. package/es/button/draw.d.ts +4 -4
  34. package/es/button/draw.js +213 -297
  35. package/es/button/index.css +40 -30
  36. package/es/button/index.d.ts +0 -4
  37. package/es/button/index.js +230 -256
  38. package/es/button/type.d.ts +3 -3
  39. package/es/button-group/index.css +0 -3
  40. package/es/button-group/index.d.ts +1 -2
  41. package/es/button-group/index.js +59 -31
  42. package/es/button-group/type.d.ts +21 -4
  43. package/es/checkbox/css.js +2 -0
  44. package/es/checkbox/draw.d.ts +4 -0
  45. package/es/checkbox/draw.js +46 -0
  46. package/es/checkbox/index.css +85 -0
  47. package/es/checkbox/index.d.ts +31 -0
  48. package/es/checkbox/index.js +206 -0
  49. package/es/checkbox/type.d.ts +88 -0
  50. package/es/checkbox-group/css.js +2 -0
  51. package/es/checkbox-group/index.css +20 -0
  52. package/es/checkbox-group/index.d.ts +23 -0
  53. package/es/checkbox-group/index.js +84 -0
  54. package/es/checkbox-group/type.d.ts +78 -0
  55. package/es/col/index.d.ts +2 -2
  56. package/es/col/index.js +43 -58
  57. package/es/container/index.css +1 -0
  58. package/es/container/index.js +18 -31
  59. package/es/divider/index.js +39 -53
  60. package/es/empty/index.css +4 -4
  61. package/es/empty/index.js +16 -71
  62. package/es/entry.js +102 -0
  63. package/es/footer/index.css +1 -0
  64. package/es/footer/index.js +31 -40
  65. package/es/form/css.js +1 -0
  66. package/es/form/index.d.ts +27 -0
  67. package/es/form/index.js +125 -0
  68. package/es/form/type.d.ts +238 -0
  69. package/es/form/use-form.d.ts +4 -0
  70. package/es/form/use-form.js +48 -0
  71. package/es/form-item/css.js +2 -0
  72. package/es/form-item/index.css +77 -0
  73. package/es/form-item/index.d.ts +37 -0
  74. package/es/form-item/index.js +318 -0
  75. package/es/form-item/type.d.ts +96 -0
  76. package/es/grid/index.js +56 -75
  77. package/es/grid-item/css.js +0 -1
  78. package/es/grid-item/index.d.ts +1 -1
  79. package/es/grid-item/index.js +85 -121
  80. package/es/header/index.css +1 -0
  81. package/es/header/index.js +31 -40
  82. package/es/icon/index.js +44 -55
  83. package/es/icons/css-hn.js +0 -1
  84. package/es/icons/css-pa.js +0 -1
  85. package/es/icons/icon-hn.js +10337 -15986
  86. package/es/icons/icon-pa.js +12573 -17447
  87. package/es/image/css.js +2 -0
  88. package/es/image/index.css +69 -0
  89. package/es/image/index.d.ts +35 -0
  90. package/es/image/index.js +199 -0
  91. package/es/image/type.d.ts +126 -0
  92. package/es/index.css +1 -515
  93. package/es/index.d.ts +22 -2
  94. package/es/index.js +144 -123
  95. package/es/input/draw.d.ts +1 -1
  96. package/es/input/draw.js +26 -51
  97. package/es/input/index.css +85 -33
  98. package/es/input/index.d.ts +9 -16
  99. package/es/input/index.js +319 -423
  100. package/es/input/type.d.ts +3 -3
  101. package/es/input-group/index.css +0 -1
  102. package/es/input-group/index.d.ts +2 -2
  103. package/es/input-group/index.js +66 -37
  104. package/es/input-group/type.d.ts +16 -4
  105. package/es/input-group-label/draw.d.ts +1 -1
  106. package/es/input-group-label/draw.js +26 -51
  107. package/es/input-group-label/index.css +33 -22
  108. package/es/input-group-label/index.d.ts +1 -4
  109. package/es/input-group-label/index.js +104 -127
  110. package/es/input-group-label/type.d.ts +3 -3
  111. package/es/input-number/draw.d.ts +1 -1
  112. package/es/input-number/draw.js +26 -51
  113. package/es/input-number/index.css +90 -35
  114. package/es/input-number/index.d.ts +9 -16
  115. package/es/input-number/index.js +428 -536
  116. package/es/input-number/type.d.ts +3 -3
  117. package/es/input-tag/draw.d.ts +1 -1
  118. package/es/input-tag/draw.js +26 -48
  119. package/es/input-tag/index.css +100 -33
  120. package/es/input-tag/index.d.ts +7 -13
  121. package/es/input-tag/index.js +442 -467
  122. package/es/input-tag/type.d.ts +24 -13
  123. package/es/link/index.js +75 -106
  124. package/es/main/index.css +4 -0
  125. package/es/main/index.d.ts +4 -1
  126. package/es/main/index.js +15 -15
  127. package/es/main/type.d.ts +7 -0
  128. package/es/mask/index.js +94 -115
  129. package/es/message/index.css +1 -1
  130. package/es/message/index.js +168 -346
  131. package/es/message-box/css.js +1 -1
  132. package/es/message-box/index.js +98 -114
  133. package/es/message-box/message-box-wrapped.js +33 -46
  134. package/es/message-box/message-box.js +79 -111
  135. package/es/option-list/index.css +13 -13
  136. package/es/option-list/index.d.ts +4 -31
  137. package/es/option-list/index.js +99 -167
  138. package/es/option-list/type.d.ts +5 -1
  139. package/es/pixelate/pixel.d.ts +5 -0
  140. package/es/pixelate/pixel.js +70 -0
  141. package/es/pixelate/pixelate.worker.d.ts +1 -0
  142. package/es/popover/index.d.ts +13 -99
  143. package/es/popover/index.js +75 -238
  144. package/es/popover/type.d.ts +7 -2
  145. package/es/popup/css.js +1 -0
  146. package/es/popup/index.d.ts +210 -0
  147. package/es/popup/index.js +203 -0
  148. package/es/popup/type.d.ts +105 -0
  149. package/es/popup-content/draw.d.ts +2 -2
  150. package/es/popup-content/draw.js +98 -143
  151. package/es/popup-content/index.css +11 -11
  152. package/es/popup-content/index.d.ts +1 -0
  153. package/es/popup-content/index.js +253 -1576
  154. package/es/popup-content/type.d.ts +1 -0
  155. package/es/popup-trigger/index.d.ts +8 -2
  156. package/es/popup-trigger/index.js +122 -95
  157. package/es/popup-trigger/type.d.ts +4 -1
  158. package/es/popup-wrapper/css.js +2 -0
  159. package/es/popup-wrapper/index.css +14 -0
  160. package/es/popup-wrapper/index.d.ts +18 -0
  161. package/es/popup-wrapper/index.js +67 -0
  162. package/es/popup-wrapper/type.d.ts +9 -0
  163. package/es/radio/css.js +1 -0
  164. package/es/radio/draw.d.ts +4 -0
  165. package/es/radio/draw.js +47 -0
  166. package/es/radio/index.d.ts +30 -0
  167. package/es/radio/index.js +190 -0
  168. package/es/radio/style.css +73 -0
  169. package/es/radio/type.d.ts +76 -0
  170. package/es/radio-group/css.js +2 -0
  171. package/es/radio-group/index.css +20 -0
  172. package/es/radio-group/index.d.ts +23 -0
  173. package/es/radio-group/index.js +77 -0
  174. package/es/radio-group/type.d.ts +77 -0
  175. package/es/row/index.js +56 -70
  176. package/es/select/draw.d.ts +1 -1
  177. package/es/select/draw.js +26 -51
  178. package/es/select/index.css +118 -36
  179. package/es/select/index.d.ts +14 -16
  180. package/es/select/index.js +625 -675
  181. package/es/select/type.d.ts +60 -25
  182. package/es/share/const/event-bus-key.js +1 -6
  183. package/es/share/const/index.d.ts +4 -0
  184. package/es/share/const/index.js +22 -24
  185. package/es/share/const/provide-key.d.ts +5 -0
  186. package/es/share/const/provide-key.js +6 -5
  187. package/es/share/const/style.d.ts +6 -0
  188. package/es/share/const/style.js +7 -0
  189. package/es/share/hook/use-cancelable-delay.d.ts +1 -0
  190. package/es/share/hook/use-cancelable-delay.js +42 -0
  191. package/es/share/hook/use-click-outside-listener.d.ts +1 -1
  192. package/es/share/hook/use-click-outside-listener.js +28 -41
  193. package/es/share/hook/use-composition.js +17 -15
  194. package/es/share/hook/use-controlled-mode.d.ts +3 -3
  195. package/es/share/hook/use-controlled-mode.js +20 -23
  196. package/es/share/hook/use-dark-mode.js +51 -65
  197. package/es/share/hook/use-index-of-children.d.ts +2 -1
  198. package/es/share/hook/use-index-of-children.js +47 -45
  199. package/es/share/hook/use-lazy-load.d.ts +10 -0
  200. package/es/share/hook/use-lazy-load.js +133 -0
  201. package/es/share/hook/use-props-detect.d.ts +2 -0
  202. package/es/share/hook/use-resize-observer.d.ts +1 -2
  203. package/es/share/hook/use-resize-observer.js +28 -20
  204. package/es/share/hook/use-screen-width.js +27 -36
  205. package/es/share/hook/use-smooth-transition.d.ts +2 -0
  206. package/es/share/hook/use-smooth-transition.js +65 -0
  207. package/es/share/hook/use-textarea-height.js +86 -92
  208. package/es/share/hook/use-theme-mode.js +41 -42
  209. package/es/share/hook/use-transition-end.d.ts +2 -0
  210. package/es/share/hook/use-transition-end.js +12 -0
  211. package/es/share/hook/use-watch-global-css-var.js +12 -16
  212. package/es/share/hook/use-window-resize-listener.d.ts +1 -0
  213. package/es/share/hook/use-window-resize-listener.js +15 -0
  214. package/es/share/hook/use-z-index.js +30 -27
  215. package/es/share/style/index.css +5 -0
  216. package/es/share/type/index.d.ts +18 -3
  217. package/es/share/util/color.d.ts +5 -3
  218. package/es/share/util/color.js +156 -149
  219. package/es/share/util/common.d.ts +7 -2
  220. package/es/share/util/common.js +127 -65
  221. package/es/share/util/console.d.ts +3 -3
  222. package/es/share/util/console.js +10 -7
  223. package/es/share/util/dom.d.ts +19 -0
  224. package/es/share/util/dom.js +88 -0
  225. package/es/share/util/env.d.ts +1 -0
  226. package/es/share/util/env.js +5 -4
  227. package/es/share/util/event-bus.js +3 -20
  228. package/es/share/util/lru-cache.js +29 -33
  229. package/es/share/util/pixel.d.ts +4 -0
  230. package/es/share/util/plot.d.ts +8 -3
  231. package/es/share/util/plot.js +457 -229
  232. package/es/share/util/reactivity.d.ts +8 -0
  233. package/es/share/util/reactivity.js +23 -0
  234. package/es/share/util/render.js +31 -41
  235. package/es/share/util/theme.d.ts +3 -0
  236. package/es/share/util/theme.js +77 -57
  237. package/es/slider/css.js +2 -0
  238. package/es/slider/draw.d.ts +25 -0
  239. package/es/slider/draw.js +113 -0
  240. package/es/slider/index.css +119 -0
  241. package/es/slider/index.d.ts +66 -0
  242. package/es/slider/index.js +503 -0
  243. package/es/slider/type.d.ts +162 -0
  244. package/es/slider/util.d.ts +37 -0
  245. package/es/slider/util.js +130 -0
  246. package/es/space/index.css +24 -29
  247. package/es/space/index.js +73 -97
  248. package/es/spin/index.css +18 -17
  249. package/es/spin/index.js +72 -102
  250. package/es/spin/type.d.ts +11 -5
  251. package/es/switch/css.js +2 -0
  252. package/es/switch/draw.d.ts +2 -0
  253. package/es/switch/draw.js +18 -0
  254. package/es/switch/index.css +121 -0
  255. package/es/switch/index.d.ts +42 -0
  256. package/es/switch/index.js +259 -0
  257. package/es/switch/type.d.ts +133 -0
  258. package/es/tag/draw.d.ts +2 -2
  259. package/es/tag/draw.js +80 -127
  260. package/es/tag/index.css +38 -22
  261. package/es/tag/index.d.ts +2 -2
  262. package/es/tag/index.js +121 -190
  263. package/es/tag/type.d.ts +3 -3
  264. package/es/text-outline/css.js +2 -0
  265. package/es/text-outline/index.css +4 -0
  266. package/es/text-outline/index.d.ts +17 -0
  267. package/es/text-outline/index.js +33 -0
  268. package/es/text-outline/type.d.ts +23 -0
  269. package/es/textarea/draw.js +9 -11
  270. package/es/textarea/index.css +37 -23
  271. package/es/textarea/index.d.ts +8 -14
  272. package/es/textarea/index.js +274 -262
  273. package/es/tooltip/index.d.ts +100 -4
  274. package/es/tooltip/index.js +70 -226
  275. package/es/tooltip/type.d.ts +7 -2
  276. package/es/vendor.js +504 -0
  277. package/es/virtual-list/css.js +2 -0
  278. package/es/virtual-list/index.css +25 -0
  279. package/es/virtual-list/index.d.ts +11 -0
  280. package/es/virtual-list/index.js +313 -0
  281. package/es/virtual-list/type.d.ts +26 -0
  282. package/package.json +10 -16
  283. package/es/grid-item/index.css +0 -0
  284. /package/es/message-box/{message-box.css → index.css} +0 -0
@@ -1,45 +1,44 @@
1
- import { ref, onBeforeUnmount, watch, onScopeDispose } from "vue";
2
- import { i as inBrowser } from "../util/env.js";
3
- const apply = (t) => {
4
- if (!inBrowser()) {
5
- return;
6
- }
7
- const html = document.documentElement;
8
- html.classList.remove("light", "dark");
9
- if (t !== "unset") html.classList.add(t);
1
+ import { t as inBrowser } from "../util/env.js";
2
+ import { onBeforeUnmount, onScopeDispose, ref, watch } from "vue";
3
+ var apply = (t) => {
4
+ if (!inBrowser()) return;
5
+ const html = document.documentElement;
6
+ html.classList.remove("light", "dark");
7
+ if (t !== "unset") html.classList.add(t);
10
8
  };
11
9
  function useThemeMode(defaultTheme) {
12
- const queryDarkMode = ref(false);
13
- if (inBrowser()) {
14
- let handleDarkModeChange = function(e) {
15
- queryDarkMode.value = e.matches;
16
- };
17
- const darkModeQuery = window.matchMedia("(prefers-color-scheme: dark)");
18
- handleDarkModeChange(darkModeQuery);
19
- darkModeQuery.addEventListener("change", handleDarkModeChange);
20
- onBeforeUnmount(() => {
21
- darkModeQuery.removeEventListener("change", handleDarkModeChange);
22
- });
23
- }
24
- const theme = ref(defaultTheme || queryDarkMode.value ? "dark" : "light");
25
- if (defaultTheme) {
26
- apply(theme.value);
27
- }
28
- const toggle = () => {
29
- theme.value = theme.value === "unset" ? queryDarkMode.value ? "light" : "dark" : theme.value === "light" ? "dark" : "light";
30
- };
31
- const clear = () => {
32
- theme.value = "unset";
33
- };
34
- const followMedia = () => {
35
- theme.value = queryDarkMode.value ? "dark" : "light";
36
- };
37
- const stopWatch = watch(theme, apply, { flush: "post" });
38
- onScopeDispose(() => {
39
- stopWatch();
40
- });
41
- return [theme, toggle, clear, followMedia];
10
+ const queryDarkMode = ref(false);
11
+ if (inBrowser()) {
12
+ const darkModeQuery = window.matchMedia("(prefers-color-scheme: dark)");
13
+ function handleDarkModeChange(e) {
14
+ queryDarkMode.value = e.matches;
15
+ }
16
+ handleDarkModeChange(darkModeQuery);
17
+ darkModeQuery.addEventListener("change", handleDarkModeChange);
18
+ onBeforeUnmount(() => {
19
+ darkModeQuery.removeEventListener("change", handleDarkModeChange);
20
+ });
21
+ }
22
+ const theme = ref(defaultTheme || queryDarkMode.value ? "dark" : "light");
23
+ if (defaultTheme) apply(theme.value);
24
+ const toggle = () => {
25
+ theme.value = theme.value === "unset" ? queryDarkMode.value ? "light" : "dark" : theme.value === "light" ? "dark" : "light";
26
+ };
27
+ const clear = () => {
28
+ theme.value = "unset";
29
+ };
30
+ const followMedia = () => {
31
+ theme.value = queryDarkMode.value ? "dark" : "light";
32
+ };
33
+ const stopWatch = watch(theme, apply, { flush: "post" });
34
+ onScopeDispose(() => {
35
+ stopWatch();
36
+ });
37
+ return [
38
+ theme,
39
+ toggle,
40
+ clear,
41
+ followMedia
42
+ ];
42
43
  }
43
- export {
44
- useThemeMode as u
45
- };
44
+ export { useThemeMode as t };
@@ -0,0 +1,2 @@
1
+ import { type Ref } from 'vue';
2
+ export declare function useTransitionEnd(elementRef: Ref<HTMLElement | SVGElement | null>, callback: (event: TransitionEvent) => void): void;
@@ -0,0 +1,12 @@
1
+ import { onMounted, onUnmounted } from "vue";
2
+ function useTransitionEnd(elementRef, callback) {
3
+ onMounted(() => {
4
+ if (!elementRef.value) return;
5
+ elementRef.value.addEventListener("transitionend", callback);
6
+ });
7
+ onUnmounted(() => {
8
+ if (!elementRef.value) return;
9
+ elementRef.value.removeEventListener("transitionend", callback);
10
+ });
11
+ }
12
+ export { useTransitionEnd as t };
@@ -1,19 +1,15 @@
1
+ import { n as inVitest, t as inBrowser } from "../util/env.js";
2
+ import { t as EventBus } from "../util/event-bus.js";
3
+ import { n as GLOBAL_CSS_VAR_CHANGE } from "../const/event-bus-key.js";
1
4
  import { onBeforeUnmount } from "vue";
2
- import { i as inBrowser } from "../util/env.js";
3
- import { E as EventBus } from "../util/event-bus.js";
4
- import { a as GLOBAL_CSS_VAR_CHANGE } from "../const/event-bus-key.js";
5
5
  const useWatchGlobalCssVal = (callback) => {
6
- if (!inBrowser()) {
7
- return;
8
- }
9
- const cb = () => {
10
- callback();
11
- };
12
- EventBus.on(GLOBAL_CSS_VAR_CHANGE, cb);
13
- onBeforeUnmount(() => {
14
- EventBus.off(GLOBAL_CSS_VAR_CHANGE, cb);
15
- });
16
- };
17
- export {
18
- useWatchGlobalCssVal as u
6
+ if (!inBrowser() || inVitest()) return;
7
+ const cb = () => {
8
+ callback();
9
+ };
10
+ EventBus.on(GLOBAL_CSS_VAR_CHANGE, cb);
11
+ onBeforeUnmount(() => {
12
+ EventBus.off(GLOBAL_CSS_VAR_CHANGE, cb);
13
+ });
19
14
  };
15
+ export { useWatchGlobalCssVal as t };
@@ -0,0 +1 @@
1
+ export declare const useWindowResizeListener: (callback: (event?: UIEvent) => any, leading?: boolean) => void;
@@ -0,0 +1,15 @@
1
+ import { t as inBrowser } from "../util/env.js";
2
+ import { nextTick, onBeforeUnmount, onMounted } from "vue";
3
+ const useWindowResizeListener = (callback, leading) => {
4
+ if (!inBrowser()) return;
5
+ onMounted(() => {
6
+ nextTick(() => {
7
+ leading && callback();
8
+ window.addEventListener("resize", callback);
9
+ });
10
+ });
11
+ onBeforeUnmount(() => {
12
+ window.removeEventListener("resize", callback);
13
+ });
14
+ };
15
+ export { useWindowResizeListener as t };
@@ -1,32 +1,35 @@
1
- import { ref, onUnmounted } from "vue";
2
- const DEFAULT_CONFIG = {
3
- message: { start: 3e3 },
4
- popup: { start: 1e3 }
1
+ import { onUnmounted, ref } from "vue";
2
+ var DEFAULT_CONFIG = {
3
+ message: { start: 3e3 },
4
+ popup: { start: 1e3 }
5
5
  };
6
- const stateMap = {};
6
+ var stateMap = {};
7
7
  function ensureNamespace(ns, cfg) {
8
- if (!stateMap[ns]) {
9
- stateMap[ns] = { max: cfg.start, count: 0, initial: cfg.start };
10
- }
11
- return stateMap[ns];
8
+ if (!stateMap[ns]) stateMap[ns] = { initial: cfg.start };
9
+ return stateMap[ns];
12
10
  }
11
+ var usedZIndex = /* @__PURE__ */ new Set();
12
+ var allocate = (ns) => {
13
+ const nextZIndex = (usedZIndex.size > 0 ? Math.max(...usedZIndex) : ns.initial) + 1;
14
+ usedZIndex.add(nextZIndex);
15
+ return nextZIndex;
16
+ };
13
17
  function useZIndex(namespace = "popup") {
14
- const cfg = DEFAULT_CONFIG[namespace];
15
- const ns = ensureNamespace(namespace, cfg);
16
- const localZIndex = ref(++ns.max);
17
- ns.count++;
18
- const next = () => {
19
- localZIndex.value = ++ns.max;
20
- return localZIndex.value;
21
- };
22
- const release = () => {
23
- if (--ns.count === 0) {
24
- ns.max = ns.initial;
25
- }
26
- };
27
- onUnmounted(release);
28
- return [localZIndex, next, release];
18
+ const cfg = DEFAULT_CONFIG[namespace];
19
+ const ns = ensureNamespace(namespace, cfg);
20
+ const localZIndex = ref(allocate(ns));
21
+ const next = () => {
22
+ localZIndex.value = allocate(ns);
23
+ return localZIndex.value;
24
+ };
25
+ const release = () => {
26
+ usedZIndex.delete(localZIndex.value);
27
+ };
28
+ onUnmounted(release);
29
+ return [
30
+ localZIndex,
31
+ next,
32
+ release
33
+ ];
29
34
  }
30
- export {
31
- useZIndex as u
32
- };
35
+ export { useZIndex as t };
@@ -0,0 +1,5 @@
1
+
2
+ .pixelium {
3
+ font-family: var(--px-font);
4
+ line-height: var(--px-line-height);
5
+ }
@@ -1,4 +1,4 @@
1
- import type { VNode } from 'vue';
1
+ import type { DefineComponent, VNode } from 'vue';
2
2
  import type { JSX } from 'vue/jsx-runtime';
3
3
  import type { GROUP_OPTION_TYPE, SCREEN_SIZE_TYPE } from '../const';
4
4
  export type NumberOrPercentage = number | `${number}%`;
@@ -8,8 +8,13 @@ export type RgbaColor = {
8
8
  b: number;
9
9
  a: number;
10
10
  };
11
- export type ValidContent = string | (() => VNode | string | JSX.Element);
12
- export type ValidVNodeContent = () => VNode | JSX.Element;
11
+ export type RgbColor = {
12
+ r: number;
13
+ g: number;
14
+ b: number;
15
+ };
16
+ export type ValidContent = string | ((...args: any[]) => VNode | string | JSX.Element);
17
+ export type ValidVNodeContent = (...args: any[]) => VNode | JSX.Element;
13
18
  export type ValueWithDeviceWidth<T> = Record<SCREEN_SIZE_TYPE, T>;
14
19
  export interface Option<T = any> {
15
20
  value: T;
@@ -19,3 +24,13 @@ export interface GroupOption<T = any> {
19
24
  children: (Option<T> | string)[];
20
25
  type: typeof GROUP_OPTION_TYPE;
21
26
  }
27
+ export type LooseRequired<T> = {
28
+ [P in keyof (T & Required<T>)]: T[P];
29
+ };
30
+ export type RemoveUndefinedFromFields<T, K extends keyof T> = {
31
+ [P in keyof T]: P extends K ? Exclude<T[P], undefined> : T[P];
32
+ };
33
+ export type VueComponent = DefineComponent<Record<string, never>, Record<string, never>, any>;
34
+ export type EmitEvent<T extends Record<string, any>> = {
35
+ [K in keyof T as `on${Capitalize<K & string>}`]?: (...args: T[K]) => void;
36
+ };
@@ -1,5 +1,7 @@
1
- import type { RgbaColor } from '../type';
2
- export declare function parseColor(color: string): RgbaColor;
3
- export declare const getGlobalThemeColor: (theme: string, level: number) => RgbaColor;
1
+ import type { RgbaColor, RgbColor } from '../type';
2
+ export declare function parseColor(color: string): RgbaColor | null;
3
+ export declare const getGlobalThemeColor: (theme: string, level: number) => RgbaColor | null;
4
+ export declare const getGlobalThemeColorString: (theme: string, level: number) => string;
4
5
  export declare function generatePalette(r: number, g: number, b: number, a?: number, darkMode?: boolean): RgbaColor[];
5
6
  export declare const rgbaColor2string: (color: RgbaColor) => string;
7
+ export declare function rgbaEuclideanDistance(color1: RgbaColor, color2: RgbaColor, background?: RgbColor): number;
@@ -1,169 +1,176 @@
1
- import { T as TRANSPARENT_RGBA_COLOR_OBJECT } from "../const/index.js";
2
- import { i as inBrowser } from "./env.js";
3
- import { c as createLRU } from "./lru-cache.js";
4
- const colorCache = createLRU(120);
1
+ import { l as TRANSPARENT_RGBA_COLOR_OBJECT } from "../const/index.js";
2
+ import { t as inBrowser } from "./env.js";
3
+ import { t as createLRU } from "./lru-cache.js";
4
+ var colorCache = createLRU(120);
5
5
  function parseColor(color) {
6
- const cached = colorCache.get(color);
7
- if (cached) return { ...cached };
8
- let result = { r: 0, g: 0, b: 0, a: 255 };
9
- if (color.startsWith("rgb(") || color.startsWith("rgba(")) {
10
- const matches = color.match(/rgba?\(\s*(\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)/i);
11
- if (matches) {
12
- result.r = parseInt(matches[1], 10);
13
- result.g = parseInt(matches[2], 10);
14
- result.b = parseInt(matches[3], 10);
15
- if (matches[4]) {
16
- result.a = Math.round(parseFloat(matches[4]) * 255);
17
- }
18
- }
19
- } else if (color.startsWith("#")) {
20
- color = color.slice(1);
21
- if (color.length === 3) {
22
- result.r = parseInt(color[0] + color[0], 16);
23
- result.g = parseInt(color[1] + color[1], 16);
24
- result.b = parseInt(color[2] + color[2], 16);
25
- } else if (color.length === 4) {
26
- result.r = parseInt(color[0] + color[0], 16);
27
- result.g = parseInt(color[1] + color[1], 16);
28
- result.b = parseInt(color[2] + color[2], 16);
29
- result.a = parseInt(color[3] + color[3], 16);
30
- } else if (color.length === 6) {
31
- result.r = parseInt(color.slice(0, 2), 16);
32
- result.g = parseInt(color.slice(2, 4), 16);
33
- result.b = parseInt(color.slice(4, 6), 16);
34
- } else if (color.length === 8) {
35
- result.r = parseInt(color.slice(0, 2), 16);
36
- result.g = parseInt(color.slice(2, 4), 16);
37
- result.b = parseInt(color.slice(4, 6), 16);
38
- result.a = parseInt(color.slice(6, 8), 16);
39
- }
40
- }
41
- colorCache.set(color, result);
42
- return { ...result };
6
+ const cached = colorCache.get(color);
7
+ if (cached) return { ...cached };
8
+ if (color.startsWith("rgb(") || color.startsWith("rgba(")) {
9
+ let result = {
10
+ r: 0,
11
+ g: 0,
12
+ b: 0,
13
+ a: 255
14
+ };
15
+ const matches = color.match(/rgba?\(\s*(\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)/i);
16
+ if (matches) {
17
+ result.r = parseInt(matches[1], 10);
18
+ result.g = parseInt(matches[2], 10);
19
+ result.b = parseInt(matches[3], 10);
20
+ if (matches[4]) result.a = Math.round(parseFloat(matches[4]) * 255);
21
+ }
22
+ colorCache.set(color, result);
23
+ return { ...result };
24
+ } else if (color.startsWith("#")) {
25
+ let result = {
26
+ r: 0,
27
+ g: 0,
28
+ b: 0,
29
+ a: 255
30
+ };
31
+ color = color.slice(1);
32
+ if (color.length === 3) {
33
+ result.r = parseInt(color[0] + color[0], 16);
34
+ result.g = parseInt(color[1] + color[1], 16);
35
+ result.b = parseInt(color[2] + color[2], 16);
36
+ } else if (color.length === 4) {
37
+ result.r = parseInt(color[0] + color[0], 16);
38
+ result.g = parseInt(color[1] + color[1], 16);
39
+ result.b = parseInt(color[2] + color[2], 16);
40
+ result.a = parseInt(color[3] + color[3], 16);
41
+ } else if (color.length === 6) {
42
+ result.r = parseInt(color.slice(0, 2), 16);
43
+ result.g = parseInt(color.slice(2, 4), 16);
44
+ result.b = parseInt(color.slice(4, 6), 16);
45
+ } else if (color.length === 8) {
46
+ result.r = parseInt(color.slice(0, 2), 16);
47
+ result.g = parseInt(color.slice(2, 4), 16);
48
+ result.b = parseInt(color.slice(4, 6), 16);
49
+ result.a = parseInt(color.slice(6, 8), 16);
50
+ }
51
+ colorCache.set(color, result);
52
+ return { ...result };
53
+ }
54
+ return null;
43
55
  }
44
56
  const getGlobalThemeColor = (theme, level) => {
45
- if (!inBrowser()) {
46
- return TRANSPARENT_RGBA_COLOR_OBJECT;
47
- }
48
- return parseColor(
49
- getComputedStyle(document.documentElement).getPropertyValue(`--px-${theme}-${level}`)
50
- );
57
+ if (!inBrowser()) return TRANSPARENT_RGBA_COLOR_OBJECT;
58
+ return parseColor(getComputedStyle(document.documentElement).getPropertyValue(`--px-${theme}-${level}`));
59
+ };
60
+ const getGlobalThemeColorString = (theme, level) => {
61
+ if (!inBrowser()) return "rgba(0,0,0,0)";
62
+ return getComputedStyle(document.documentElement).getPropertyValue(`--px-${theme}-${level}`);
51
63
  };
52
64
  function toLinear(c) {
53
- return c <= 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
65
+ return c <= .04045 ? c / 12.92 : Math.pow((c + .055) / 1.055, 2.4);
54
66
  }
55
67
  function rgbaToOklch(r, g, b, a = 255) {
56
- const rn = r / 255;
57
- const gn = g / 255;
58
- const bn = b / 255;
59
- const lr = toLinear(rn);
60
- const lg = toLinear(gn);
61
- const lb = toLinear(bn);
62
- let x = lr * 0.41239079926595934 + lg * 0.357584339383878 + lb * 0.1804807884018343;
63
- let y = lr * 0.21263900587151027 + lg * 0.715168678767756 + lb * 0.07219231536073371;
64
- let z = lr * 0.01933081871559182 + lg * 0.11919477979462598 + lb * 0.9505321522496607;
65
- let l_ = 0.819022437996703 * x + 0.3619062600528904 * y - 0.1288737815209879 * z;
66
- let m = 0.0329836539323885 * x + 0.9292868615863434 * y + 0.0361446663506424 * z;
67
- let s = 0.0481771893596242 * x + 0.2642395317527308 * y + 0.6335478284694309 * z;
68
- l_ = Math.cbrt(l_);
69
- m = Math.cbrt(m);
70
- s = Math.cbrt(s);
71
- const l = 0.210454268309314 * l_ + 0.7936177747023054 * m - 0.0040720430116193 * s;
72
- const aLab = 1.9779985324311684 * l_ - 2.42859224204858 * m + 0.450593709617411 * s;
73
- const bLab = 0.0259040424655478 * l_ + 0.7827717124575296 * m - 0.8086757549230774 * s;
74
- const c = Math.sqrt(aLab * aLab + bLab * bLab);
75
- let h = Math.atan2(bLab, aLab) * 180 / Math.PI;
76
- if (h < 0) h += 360;
77
- return {
78
- l,
79
- c,
80
- h,
81
- a
82
- };
68
+ const rn = r / 255;
69
+ const gn = g / 255;
70
+ const bn = b / 255;
71
+ const lr = toLinear(rn);
72
+ const lg = toLinear(gn);
73
+ const lb = toLinear(bn);
74
+ let x = lr * .41239079926595934 + lg * .357584339383878 + lb * .1804807884018343;
75
+ let y = lr * .21263900587151027 + lg * .715168678767756 + lb * .07219231536073371;
76
+ let z = lr * .01933081871559182 + lg * .11919477979462598 + lb * .9505321522496607;
77
+ let l_ = .819022437996703 * x + .3619062600528904 * y - .1288737815209879 * z;
78
+ let m = .0329836539323885 * x + .9292868615863434 * y + .0361446663506424 * z;
79
+ let s = .0481771893596242 * x + .2642395317527308 * y + .6335478284694309 * z;
80
+ l_ = Math.cbrt(l_);
81
+ m = Math.cbrt(m);
82
+ s = Math.cbrt(s);
83
+ const l = .210454268309314 * l_ + .7936177747023054 * m - .0040720430116193 * s;
84
+ const aLab = 1.9779985324311684 * l_ - 2.42859224204858 * m + .450593709617411 * s;
85
+ const bLab = .0259040424655478 * l_ + .7827717124575296 * m - .8086757549230774 * s;
86
+ const c = Math.sqrt(aLab * aLab + bLab * bLab);
87
+ let h = Math.atan2(bLab, aLab) * 180 / Math.PI;
88
+ if (h < 0) h += 360;
89
+ return {
90
+ l,
91
+ c,
92
+ h,
93
+ a
94
+ };
83
95
  }
84
96
  function toGamma(cLin) {
85
- return cLin <= 31308e-7 ? 12.92 * cLin : 1.055 * Math.pow(cLin, 1 / 2.4) - 0.055;
97
+ return cLin <= .0031308 ? 12.92 * cLin : 1.055 * Math.pow(cLin, 1 / 2.4) - .055;
86
98
  }
87
99
  function oklchToRgba(l, c, h, a = 255) {
88
- const hRad = h * Math.PI / 180;
89
- const aLab = c * Math.cos(hRad);
90
- const bLab = c * Math.sin(hRad);
91
- let l_ = l + 0.3963377773761749 * aLab + 0.2158037573099136 * bLab;
92
- let m = l - 0.1055613458156586 * aLab - 0.0638541728258133 * bLab;
93
- let s = l - 0.0894841775298119 * aLab - 1.2914855480194092 * bLab;
94
- l_ = l_ * l_ * l_;
95
- m = m * m * m;
96
- s = s * s * s;
97
- const x = 1.2268798758459243 * l_ - 0.5578149944602171 * m + 0.2813910456659647 * s;
98
- const y = -0.0405757452148008 * l_ + 1.112286803280317 * m - 0.0717110580655164 * s;
99
- const z = -0.0763729366746601 * l_ - 0.4214933324022432 * m + 1.5869240198367816 * s;
100
- const lr = 3.2409699419045226 * x - 1.537383177570094 * y - 0.4986107602930034 * z;
101
- const lg = -0.9692436362808796 * x + 1.8759675015077202 * y + 0.04155505740717559 * z;
102
- const lb = 0.05563007969699366 * x - 0.20397695888897652 * y + 1.0569715142428786 * z;
103
- const r = toGamma(lr);
104
- const g = toGamma(lg);
105
- const b = toGamma(lb);
106
- return {
107
- r: Math.round(r * 255),
108
- g: Math.round(g * 255),
109
- b: Math.round(b * 255),
110
- a
111
- };
100
+ const hRad = h * Math.PI / 180;
101
+ const aLab = c * Math.cos(hRad);
102
+ const bLab = c * Math.sin(hRad);
103
+ let l_ = l + .3963377773761749 * aLab + .2158037573099136 * bLab;
104
+ let m = l - .1055613458156586 * aLab - .0638541728258133 * bLab;
105
+ let s = l - .0894841775298119 * aLab - 1.2914855480194092 * bLab;
106
+ l_ = l_ * l_ * l_;
107
+ m = m * m * m;
108
+ s = s * s * s;
109
+ const x = 1.2268798758459243 * l_ - .5578149944602171 * m + .2813910456659647 * s;
110
+ const y = -.0405757452148008 * l_ + 1.112286803280317 * m - .0717110580655164 * s;
111
+ const z = -.0763729366746601 * l_ - .4214933324022432 * m + 1.5869240198367816 * s;
112
+ const lr = 3.2409699419045226 * x - 1.537383177570094 * y - .4986107602930034 * z;
113
+ const lg = -.9692436362808796 * x + 1.8759675015077202 * y + .04155505740717559 * z;
114
+ const lb = .05563007969699366 * x - .20397695888897652 * y + 1.0569715142428786 * z;
115
+ const r = toGamma(lr);
116
+ const g = toGamma(lg);
117
+ const b = toGamma(lb);
118
+ return {
119
+ r: Math.round(r * 255),
120
+ g: Math.round(g * 255),
121
+ b: Math.round(b * 255),
122
+ a
123
+ };
112
124
  }
113
125
  function inGamut(c, l, h) {
114
- const { r, g, b } = oklchToRgba(l, c, h);
115
- return r >= 0 && r <= 255 && g >= 0 && g <= 255 && b >= 0 && b <= 255;
126
+ const { r, g, b } = oklchToRgba(l, c, h);
127
+ return r >= 0 && r <= 255 && g >= 0 && g <= 255 && b >= 0 && b <= 255;
116
128
  }
117
129
  function maxChromaForOklch(l, h) {
118
- const tol = 1e-6;
119
- let lo = 0, hi = 2;
120
- while (hi - lo > tol) {
121
- const mid = (lo + hi) / 2;
122
- if (inGamut(mid, l, h)) lo = mid;
123
- else hi = mid;
124
- }
125
- return lo;
130
+ const tol = 1e-6;
131
+ let lo = 0, hi = 2;
132
+ while (hi - lo > tol) {
133
+ const mid = (lo + hi) / 2;
134
+ if (inGamut(mid, l, h)) lo = mid;
135
+ else hi = mid;
136
+ }
137
+ return lo;
126
138
  }
127
- const paletteCache = createLRU(60);
139
+ var paletteCache = createLRU(60);
128
140
  function generatePalette(r, g, b, a = 255, darkMode = false) {
129
- const key = `${r},${g},${b},${a},${darkMode}`;
130
- const cached = paletteCache.get(key);
131
- if (cached) return cached;
132
- const oklch = rgbaToOklch(r, g, b, a);
133
- let palette = [];
134
- const minC = oklch.c < 0.049 ? 0 : 0.049;
135
- const startL = darkMode ? Math.min(Math.max(oklch.l, 0.05), 0.85) : Math.min(Math.max(oklch.l, 0.15), 0.95);
136
- const startC = Math.min(Math.max(oklch.c, minC), maxChromaForOklch(startL, oklch.h));
137
- const maxL = Math.min(startL + 0.35, darkMode ? 0.85 : 0.9);
138
- const minL = Math.max(startL - 0.35, darkMode ? 0.1 : 0.15);
139
- const stepSizeDown4L = darkMode ? (startL - minL) / 4 : (maxL - startL) / 4;
140
- const stepSizeDown4C = (startC - minC) / 4;
141
- const stepSizeUp4L = darkMode ? (maxL - startL) / 3 : (startL - minL) / 3;
142
- const stepSizeUp4C = (startC - minC) / 3;
143
- for (let i = 0; i < 5; i++) {
144
- const L = startL + (darkMode ? -1 : 1) * stepSizeDown4L * (5 - i);
145
- const C = Math.min(startC - stepSizeDown4C * (5 - i), maxChromaForOklch(L, oklch.h));
146
- const h = oklch.h;
147
- const color = oklchToRgba(L, C, h, a);
148
- palette.push(color);
149
- }
150
- palette.push(oklchToRgba(startL, startC, oklch.h, a));
151
- for (let i = 0; i < 4; i++) {
152
- const L = startL - (darkMode ? -1 : 1) * stepSizeUp4L * (i + 1);
153
- const C = Math.min(startC - stepSizeUp4C * (i + 1), maxChromaForOklch(L, oklch.h));
154
- const h = oklch.h;
155
- const color = oklchToRgba(L, C, h, a);
156
- palette.push(color);
157
- }
158
- paletteCache.set(key, palette);
159
- return palette;
141
+ const key = `${r},${g},${b},${a},${darkMode}`;
142
+ const cached = paletteCache.get(key);
143
+ if (cached) return cached;
144
+ const oklch = rgbaToOklch(r, g, b, a);
145
+ let palette = [];
146
+ const minC = oklch.c < .049 ? 0 : .049;
147
+ const startL = darkMode ? Math.min(Math.max(oklch.l, .05), .85) : Math.min(Math.max(oklch.l, .15), .95);
148
+ const startC = Math.min(Math.max(oklch.c, minC), maxChromaForOklch(startL, oklch.h));
149
+ const maxL = Math.min(startL + .35, darkMode ? .85 : .9);
150
+ const minL = Math.max(startL - .35, darkMode ? .1 : .15);
151
+ const stepSizeDown4L = darkMode ? (startL - minL) / 4 : (maxL - startL) / 4;
152
+ const stepSizeDown4C = (startC - minC) / 4;
153
+ const stepSizeUp4L = darkMode ? (maxL - startL) / 3 : (startL - minL) / 3;
154
+ const stepSizeUp4C = (startC - minC) / 3;
155
+ for (let i = 0; i < 5; i++) {
156
+ const L = startL + (darkMode ? -1 : 1) * stepSizeDown4L * (5 - i);
157
+ const C = Math.min(startC - stepSizeDown4C * (5 - i), maxChromaForOklch(L, oklch.h));
158
+ const h = oklch.h;
159
+ const color = oklchToRgba(L, C, h, a);
160
+ palette.push(color);
161
+ }
162
+ palette.push(oklchToRgba(startL, startC, oklch.h, a));
163
+ for (let i = 0; i < 4; i++) {
164
+ const L = startL - (darkMode ? -1 : 1) * stepSizeUp4L * (i + 1);
165
+ const C = Math.min(startC - stepSizeUp4C * (i + 1), maxChromaForOklch(L, oklch.h));
166
+ const h = oklch.h;
167
+ const color = oklchToRgba(L, C, h, a);
168
+ palette.push(color);
169
+ }
170
+ paletteCache.set(key, palette);
171
+ return palette;
160
172
  }
161
173
  const rgbaColor2string = (color) => {
162
- return `rgba(${color.r}, ${color.g}, ${color.b}, ${color.a / 255})`;
163
- };
164
- export {
165
- generatePalette as a,
166
- getGlobalThemeColor as g,
167
- parseColor as p,
168
- rgbaColor2string as r
174
+ return `rgba(${color.r}, ${color.g}, ${color.b}, ${color.a / 255})`;
169
175
  };
176
+ export { rgbaColor2string as a, parseColor as i, getGlobalThemeColor as n, getGlobalThemeColorString as r, generatePalette as t };
@@ -1,5 +1,10 @@
1
1
  import type { GroupOption, Option } from '../type';
2
- export declare const clamp: (x: number, min: number, max: number) => number;
3
- export declare const fillArr: (val: number, size: number) => any[];
2
+ export declare const fillArr: (val: number, size: number) => number[];
4
3
  export declare const defaultFilter: <T extends string | Option | GroupOption>(keyword: string, list?: T[]) => T[];
5
4
  export declare const findSameOption: <T extends string | Option | GroupOption>(keyword: string, list: T[], checkLabel?: boolean) => T[];
5
+ export declare function offsetOutward(center: [number, number], points: [number, number][], offset: number): [number, number][];
6
+ export declare function isUrl(url: any, options?: {
7
+ allowWithoutProtocol?: boolean;
8
+ allowIpv6?: boolean;
9
+ }): boolean;
10
+ export declare const fixedNumber: (value: number, precision: number) => number;