@pixelium/web-vue 0.0.2 → 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 -5852
  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 -672
  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
@@ -6,12 +6,8 @@ type __VLS_Slots = {} & {
6
6
  default?: (props: typeof __VLS_8) => any;
7
7
  };
8
8
  declare const __VLS_component: import("vue").DefineComponent<ButtonProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ButtonProps> & Readonly<{}>, {
9
- shape: "default" | "round" | "circle" | "square";
10
- size: "medium" | "large" | "small";
11
9
  disabled: boolean;
12
10
  loading: boolean;
13
- variant: "primary" | "plain" | "text" | "outline";
14
- theme: "primary" | "sakura" | "success" | "warning" | "danger" | "info";
15
11
  block: boolean;
16
12
  nativeType: "button" | "submit" | "reset";
17
13
  autofocus: boolean;
@@ -1,258 +1,232 @@
1
1
  import './css.js'
2
- import { defineComponent, getCurrentInstance, ref, inject, computed, useSlots, shallowRef, onMounted, nextTick, watch, createElementBlock, openBlock, normalizeStyle, normalizeClass, createElementVNode, createCommentVNode, renderSlot, unref, createBlock } from "vue";
3
- import { S as SpinnerThirdSolid } from "../auto-complete/index.js";
4
- import { a as canvasPreprocess, c as calcPixelSize, g as getBorderRadius, b as calcBorderCornerCenter, f as floodFill } from "../share/util/plot.js";
5
- import { p as parseColor, a as generatePalette } from "../share/util/color.js";
6
- import { _ as _sfc_main$1 } from "../button-group/index.js";
7
- import { _ as _sfc_main$2 } from "../input-group/index.js";
8
- import { g as getTextColorWithPalette, a as getBorderColor, d as drawGradient, b as drawBorder, c as getBackgroundColor } from "./draw.js";
9
- import { u as useDarkMode } from "../share/hook/use-dark-mode.js";
10
- import { u as useResizeObserver } from "../share/hook/use-resize-observer.js";
11
- import { u as useWatchGlobalCssVal } from "../share/hook/use-watch-global-css-var.js";
12
- import { u as useIndexOfChildren } from "../share/hook/use-index-of-children.js";
13
- import { B as BUTTON_GROUP_UPDATE, I as INPUT_GROUP_UPDATE } from "../share/const/event-bus-key.js";
14
- import { B as BUTTON_GROUP_PROVIDE, I as INPUT_GROUP_PROVIDE } from "../share/const/provide-key.js";
15
- import { B as BORDER_CORNER_RAD_RANGE } from "../share/const/index.js";
16
- const _hoisted_1 = ["disabled", "type", "autofocus"];
17
- const _sfc_main = /* @__PURE__ */ defineComponent({
18
- ...{
19
- name: "Button"
20
- },
21
- __name: "index",
22
- props: {
23
- borderRadius: null,
24
- shape: { default: "default" },
25
- size: { default: "medium" },
26
- disabled: { type: Boolean, default: false },
27
- loading: { type: Boolean, default: false },
28
- variant: { default: "primary" },
29
- theme: { default: "primary" },
30
- color: null,
31
- block: { type: Boolean, default: false },
32
- nativeType: { default: "button" },
33
- autofocus: { type: Boolean, default: false }
34
- },
35
- setup(__props) {
36
- var _a, _b;
37
- const props = __props;
38
- const instance = getCurrentInstance();
39
- const innerButtonGroup = ref(((_a = instance == null ? void 0 : instance.parent) == null ? void 0 : _a.type) === _sfc_main$1);
40
- const innerInputGroup = ref(((_b = instance == null ? void 0 : instance.parent) == null ? void 0 : _b.type) === _sfc_main$2);
41
- const [_, first, last] = innerButtonGroup.value ? useIndexOfChildren(BUTTON_GROUP_UPDATE) : innerInputGroup.value ? useIndexOfChildren(INPUT_GROUP_UPDATE) : [ref(0), ref(false), ref(false)];
42
- const buttonGroupProps = inject(BUTTON_GROUP_PROVIDE);
43
- const inputGroupProps = inject(INPUT_GROUP_PROVIDE);
44
- const borderRadiusComputed = computed(() => {
45
- return innerButtonGroup.value && buttonGroupProps ? buttonGroupProps.borderRadius : innerInputGroup.value && inputGroupProps ? inputGroupProps.borderRadius : props.borderRadius;
46
- });
47
- const typeComputed = computed(() => {
48
- return innerButtonGroup.value && buttonGroupProps ? buttonGroupProps.variant || props.variant : props.variant;
49
- });
50
- const sizeComputed = computed(() => {
51
- return innerButtonGroup.value && buttonGroupProps ? buttonGroupProps.size : innerInputGroup.value && inputGroupProps ? inputGroupProps.size : props.size;
52
- });
53
- const shapeComputed = computed(() => {
54
- return innerButtonGroup.value && buttonGroupProps ? buttonGroupProps.shape : innerInputGroup.value && inputGroupProps ? inputGroupProps.shape : props.shape;
55
- });
56
- const disabledComputed = computed(() => {
57
- return innerButtonGroup.value && buttonGroupProps ? buttonGroupProps.disabled || props.disabled : innerInputGroup.value && inputGroupProps ? inputGroupProps.disabled || props.disabled : props.disabled;
58
- });
59
- const loadingComputed = computed(() => {
60
- return innerButtonGroup.value && buttonGroupProps ? buttonGroupProps.loading || props.loading : props.loading;
61
- });
62
- const slots = useSlots();
63
- const hoverFlag = ref(false);
64
- const activeFlag = ref(false);
65
- const toggleHover = (value) => {
66
- hoverFlag.value = value;
67
- };
68
- const toggleActive = (value) => {
69
- activeFlag.value = value;
70
- };
71
- const darkMode = useDarkMode();
72
- const canvasRef = shallowRef(null);
73
- const buttonRef = shallowRef(null);
74
- onMounted(() => {
75
- nextTick(() => {
76
- drawPixel();
77
- });
78
- });
79
- const palette = computed(() => {
80
- if (!props.color) return null;
81
- const color = parseColor(props.color);
82
- const palette2 = generatePalette(color.r, color.g, color.b, color.a, darkMode.value);
83
- return palette2;
84
- });
85
- const textColor = computed(() => {
86
- return getTextColorWithPalette(
87
- palette.value,
88
- typeComputed.value,
89
- disabledComputed.value,
90
- loadingComputed.value,
91
- hoverFlag.value,
92
- activeFlag.value
93
- );
94
- });
95
- watch(
96
- [
97
- borderRadiusComputed,
98
- shapeComputed,
99
- disabledComputed,
100
- loadingComputed,
101
- typeComputed,
102
- () => props.theme,
103
- palette,
104
- hoverFlag,
105
- activeFlag,
106
- darkMode
107
- ],
108
- () => {
109
- drawPixel();
110
- }
111
- );
112
- watch([first, last], () => {
113
- drawPixel();
114
- });
115
- const drawPixel = () => {
116
- const preprocessData = canvasPreprocess(buttonRef, canvasRef);
117
- if (!preprocessData) {
118
- return;
119
- }
120
- const pixelSize = calcPixelSize();
121
- const { ctx, width, height, canvas } = preprocessData;
122
- const borderRadius = getBorderRadius(
123
- canvas,
124
- pixelSize,
125
- borderRadiusComputed.value,
126
- shapeComputed.value,
127
- sizeComputed.value || "medium",
128
- innerButtonGroup.value || innerInputGroup.value,
129
- first.value,
130
- last.value
131
- );
132
- const borderColor = getBorderColor(
133
- disabledComputed.value,
134
- loadingComputed.value,
135
- typeComputed.value,
136
- props.theme,
137
- palette.value,
138
- hoverFlag.value,
139
- activeFlag.value
140
- );
141
- const center = calcBorderCornerCenter(borderRadius, width, height, pixelSize);
142
- const rad = BORDER_CORNER_RAD_RANGE;
143
- if (typeComputed.value === "primary") {
144
- drawGradient(
145
- ctx,
146
- width,
147
- height,
148
- center,
149
- borderRadius,
150
- rad,
151
- pixelSize,
152
- disabledComputed.value,
153
- loadingComputed.value,
154
- props.theme,
155
- palette.value,
156
- innerButtonGroup.value || innerInputGroup.value,
157
- first.value,
158
- last.value,
159
- hoverFlag.value,
160
- activeFlag.value
161
- );
162
- }
163
- drawBorder(
164
- ctx,
165
- width,
166
- height,
167
- center,
168
- borderRadius,
169
- rad,
170
- borderColor,
171
- pixelSize,
172
- typeComputed.value,
173
- innerButtonGroup.value || innerInputGroup.value,
174
- first.value,
175
- last.value
176
- );
177
- const backgroundColor = getBackgroundColor(
178
- disabledComputed.value,
179
- loadingComputed.value,
180
- typeComputed.value,
181
- props.theme,
182
- palette.value,
183
- hoverFlag.value,
184
- activeFlag.value
185
- );
186
- floodFill(ctx, Math.round(width / 2), Math.round(height / 2), backgroundColor);
187
- };
188
- useResizeObserver(buttonRef, drawPixel);
189
- useWatchGlobalCssVal(drawPixel);
190
- return (_ctx, _cache) => {
191
- return openBlock(), createElementBlock("button", {
192
- disabled: disabledComputed.value || loadingComputed.value,
193
- class: normalizeClass(["pixelium px-button", {
194
- "px-button__block": !(innerButtonGroup.value || innerInputGroup.value) && !!props.block,
195
- "px-button__circle": shapeComputed.value === "circle",
196
- "px-button__square": shapeComputed.value === "square",
197
- "px-button__loading": loadingComputed.value,
198
- "px-button__large": sizeComputed.value === "large",
199
- "px-button__small": sizeComputed.value === "small",
200
- "px-button__outline": typeComputed.value === "outline",
201
- "px-button__plain": typeComputed.value === "plain",
202
- "px-button__text": typeComputed.value === "text",
203
- "px-button__disabled": disabledComputed.value,
204
- "px-button__custom": palette.value,
205
- "px-button__inner": innerButtonGroup.value || innerInputGroup.value,
206
- [`px-button__${props.theme || "primary"}`]: true
207
- }]),
208
- style: normalizeStyle({
209
- color: textColor.value
210
- }),
211
- ref_key: "buttonRef",
212
- ref: buttonRef,
213
- onMouseenter: _cache[0] || (_cache[0] = ($event) => toggleHover(true)),
214
- onMouseleave: _cache[1] || (_cache[1] = ($event) => toggleHover(false)),
215
- onMousedown: _cache[2] || (_cache[2] = ($event) => toggleActive(true)),
216
- onMouseup: _cache[3] || (_cache[3] = ($event) => toggleActive(false)),
217
- type: props.nativeType,
218
- autofocus: props.autofocus
219
- }, [
220
- createElementVNode(
221
- "canvas",
222
- {
223
- ref_key: "canvasRef",
224
- ref: canvasRef,
225
- class: "px-button-canvas"
226
- },
227
- null,
228
- 512
229
- /* NEED_PATCH */
230
- ),
231
- unref(slots).icon || loadingComputed.value ? (openBlock(), createElementBlock(
232
- "div",
233
- {
234
- key: 0,
235
- class: normalizeClass(["px-button-icon-wrapper", {
236
- "px-button-icon-wrapper__last": !unref(slots).default
237
- }])
238
- },
239
- [
240
- loadingComputed.value ? (openBlock(), createBlock(unref(SpinnerThirdSolid), {
241
- key: 0,
242
- class: "px-button-icon px-animation__loading",
243
- style: normalizeStyle({
244
- fill: textColor.value
245
- })
246
- }, null, 8, ["style"])) : renderSlot(_ctx.$slots, "icon", { key: 1 })
247
- ],
248
- 2
249
- /* CLASS */
250
- )) : createCommentVNode("v-if", true),
251
- renderSlot(_ctx.$slots, "default")
252
- ], 46, _hoisted_1);
253
- };
254
- }
2
+ import { V as spinner_third_solid_default } from "../vendor.js";
3
+ import { t as BORDER_CORNER_RAD_RANGE } from "../share/const/index.js";
4
+ import { i as canvasPreprocess, l as getBorderRadius, n as calcPixelSize, s as floodFill, t as calcBorderCornerCenter } from "../share/util/plot.js";
5
+ import { i as parseColor, t as generatePalette } from "../share/util/color.js";
6
+ import { a as getTextColorWithPalette, i as getBorderColor, n as drawGradient, r as getBackgroundColor, t as drawBorder } from "./draw.js";
7
+ import { t as useDarkMode } from "../share/hook/use-dark-mode.js";
8
+ import { t as useResizeObserver } from "../share/hook/use-resize-observer.js";
9
+ import { i as INPUT_GROUP_UPDATE, t as BUTTON_GROUP_UPDATE } from "../share/const/event-bus-key.js";
10
+ import { t as useWatchGlobalCssVal } from "../share/hook/use-watch-global-css-var.js";
11
+ import { n as useIndexOfChildren } from "../share/hook/use-index-of-children.js";
12
+ import { a as FORM_PROVIDE, i as FORM_ITEM_PROVIDE, s as INPUT_GROUP_PROVIDE, t as BUTTON_GROUP_PROVIDE } from "../share/const/provide-key.js";
13
+ import { t as createProvideComputed } from "../share/util/reactivity.js";
14
+ import { t as useTransitionEnd } from "../share/hook/use-transition-end.js";
15
+ import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, defineComponent, getCurrentInstance, inject, nextTick, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, openBlock, ref, renderSlot, shallowRef, unref, useId, useSlots, watch } from "vue";
16
+ var _hoisted_1 = [
17
+ "disabled",
18
+ "type",
19
+ "autofocus"
20
+ ];
21
+ var button_default = /* @__PURE__ */ defineComponent({
22
+ name: "Button",
23
+ __name: "index",
24
+ props: {
25
+ borderRadius: null,
26
+ shape: null,
27
+ size: null,
28
+ disabled: {
29
+ type: Boolean,
30
+ default: false
31
+ },
32
+ loading: {
33
+ type: Boolean,
34
+ default: false
35
+ },
36
+ variant: null,
37
+ theme: null,
38
+ color: null,
39
+ block: {
40
+ type: Boolean,
41
+ default: false
42
+ },
43
+ nativeType: { default: "button" },
44
+ autofocus: {
45
+ type: Boolean,
46
+ default: false
47
+ }
48
+ },
49
+ setup(__props) {
50
+ var _instance$parent, _instance$parent2;
51
+ const props = __props;
52
+ const instance = getCurrentInstance();
53
+ const innerButtonGroup = ref((instance === null || instance === void 0 || (_instance$parent = instance.parent) === null || _instance$parent === void 0 ? void 0 : _instance$parent.type.name) === "ButtonGroup");
54
+ const innerInputGroup = ref((instance === null || instance === void 0 || (_instance$parent2 = instance.parent) === null || _instance$parent2 === void 0 ? void 0 : _instance$parent2.type.name) === "InputGroup");
55
+ const [index, first, last] = innerButtonGroup.value ? useIndexOfChildren(BUTTON_GROUP_UPDATE) : innerInputGroup.value ? useIndexOfChildren(INPUT_GROUP_UPDATE) : [
56
+ ref(0),
57
+ ref(false),
58
+ ref(false)
59
+ ];
60
+ const buttonGroupProvide = inject(BUTTON_GROUP_PROVIDE, void 0);
61
+ const inputGroupProvide = inject(INPUT_GROUP_PROVIDE, void 0);
62
+ const formProps = inject(FORM_PROVIDE, void 0);
63
+ const formItemProvide = inject(FORM_ITEM_PROVIDE, void 0);
64
+ const borderRadiusComputed = createProvideComputed("borderRadius", [
65
+ innerButtonGroup.value && buttonGroupProvide,
66
+ innerInputGroup.value && inputGroupProvide,
67
+ props
68
+ ]);
69
+ const typeComputed = createProvideComputed("variant", [innerButtonGroup.value && buttonGroupProvide, props], "nullish", (val) => val || "primary");
70
+ const sizeComputed = createProvideComputed("size", () => [
71
+ innerButtonGroup.value && buttonGroupProvide,
72
+ innerInputGroup.value && inputGroupProvide,
73
+ props.size && props,
74
+ formItemProvide,
75
+ formProps,
76
+ props
77
+ ], "nullish", (val) => val || "medium");
78
+ const shapeComputed = createProvideComputed("shape", [
79
+ innerButtonGroup.value && buttonGroupProvide,
80
+ innerInputGroup.value && inputGroupProvide,
81
+ props
82
+ ], "nullish", (val) => val || "rect");
83
+ const themeComputed = createProvideComputed("theme", [innerButtonGroup.value && buttonGroupProvide, props], "nullish", (val) => val || "primary");
84
+ const disabledComputed = createProvideComputed("disabled", [
85
+ innerButtonGroup.value && buttonGroupProvide,
86
+ innerInputGroup.value && inputGroupProvide,
87
+ formItemProvide,
88
+ formProps,
89
+ props
90
+ ], (pre, value, cur) => {
91
+ return pre || value || "readonly" in cur && cur["readonly"].value;
92
+ });
93
+ const loadingComputed = createProvideComputed("loading", [innerButtonGroup.value && buttonGroupProvide, props], "or");
94
+ const slots = useSlots();
95
+ const hoverFlag = ref(false);
96
+ const activeFlag = ref(false);
97
+ const toggleHover = (value) => {
98
+ hoverFlag.value = value;
99
+ };
100
+ const toggleActive = (value) => {
101
+ activeFlag.value = value;
102
+ };
103
+ const darkMode = useDarkMode();
104
+ const canvasRef = shallowRef(null);
105
+ const buttonRef = shallowRef(null);
106
+ const id = useId();
107
+ onMounted(() => {
108
+ nextTick(() => {
109
+ drawPixel();
110
+ if (innerButtonGroup.value) buttonGroupProvide === null || buttonGroupProvide === void 0 || buttonGroupProvide.collectChildrenInfo({
111
+ id,
112
+ variant: typeComputed.value,
113
+ index: index.value
114
+ });
115
+ if (innerInputGroup.value) inputGroupProvide === null || inputGroupProvide === void 0 || inputGroupProvide.collectChildrenInfo({
116
+ id,
117
+ variant: typeComputed.value,
118
+ index: index.value
119
+ });
120
+ });
121
+ });
122
+ onBeforeUnmount(() => {
123
+ if (innerButtonGroup.value) buttonGroupProvide === null || buttonGroupProvide === void 0 || buttonGroupProvide.removeChildrenInfo(id);
124
+ if (innerInputGroup.value) inputGroupProvide === null || inputGroupProvide === void 0 || inputGroupProvide.removeChildrenInfo(id);
125
+ });
126
+ watch([typeComputed, index], () => {
127
+ if (innerButtonGroup.value) buttonGroupProvide === null || buttonGroupProvide === void 0 || buttonGroupProvide.collectChildrenInfo({
128
+ id,
129
+ variant: typeComputed.value,
130
+ index: index.value
131
+ });
132
+ if (innerInputGroup.value) inputGroupProvide === null || inputGroupProvide === void 0 || inputGroupProvide.collectChildrenInfo({
133
+ id,
134
+ variant: typeComputed.value,
135
+ index: index.value
136
+ });
137
+ });
138
+ const nextIsTextButton = computed(() => {
139
+ if (index.value >= 0) {
140
+ var _buttonGroupProvide$c, _inputGroupProvide$ch;
141
+ return innerButtonGroup.value ? !!((buttonGroupProvide === null || buttonGroupProvide === void 0 || (_buttonGroupProvide$c = buttonGroupProvide.childrenInfo.value.find((e) => e.index === index.value + 1)) === null || _buttonGroupProvide$c === void 0 ? void 0 : _buttonGroupProvide$c.variant) === "text") : innerInputGroup.value ? !!((inputGroupProvide === null || inputGroupProvide === void 0 || (_inputGroupProvide$ch = inputGroupProvide.childrenInfo.value.find((e) => e.index === index.value + 1)) === null || _inputGroupProvide$ch === void 0 ? void 0 : _inputGroupProvide$ch.variant) === "text") : false;
142
+ } else return false;
143
+ });
144
+ const palette = computed(() => {
145
+ if (!props.color) return null;
146
+ const color = parseColor(props.color);
147
+ if (!color) return null;
148
+ return generatePalette(color.r, color.g, color.b, color.a, darkMode.value);
149
+ });
150
+ const textColor = computed(() => {
151
+ return getTextColorWithPalette(palette.value, typeComputed.value, !!disabledComputed.value, !!loadingComputed.value, hoverFlag.value, activeFlag.value);
152
+ });
153
+ watch([
154
+ borderRadiusComputed,
155
+ shapeComputed,
156
+ disabledComputed,
157
+ loadingComputed,
158
+ typeComputed,
159
+ themeComputed,
160
+ palette,
161
+ hoverFlag,
162
+ activeFlag,
163
+ darkMode,
164
+ nextIsTextButton
165
+ ], () => {
166
+ drawPixel();
167
+ });
168
+ watch([first, last], () => {
169
+ drawPixel();
170
+ });
171
+ const drawPixel = () => {
172
+ const preprocessData = canvasPreprocess(buttonRef, canvasRef);
173
+ if (!preprocessData) return;
174
+ const pixelSize = calcPixelSize();
175
+ const { ctx, width, height, canvas } = preprocessData;
176
+ const borderRadius = getBorderRadius(canvas, pixelSize, borderRadiusComputed.value, shapeComputed.value || "rect", sizeComputed.value || "medium", innerButtonGroup.value || innerInputGroup.value, first.value, last.value);
177
+ const borderColor = getBorderColor(!!disabledComputed.value, !!loadingComputed.value, typeComputed.value || "primary", themeComputed.value || "primary", palette.value, hoverFlag.value, activeFlag.value);
178
+ const center = calcBorderCornerCenter(borderRadius, width, height, pixelSize);
179
+ const rad = BORDER_CORNER_RAD_RANGE;
180
+ if (!typeComputed.value || typeComputed.value === "primary") drawGradient(ctx, width, height, center, borderRadius, rad, pixelSize, !!disabledComputed.value, !!loadingComputed.value, themeComputed.value, palette.value, innerButtonGroup.value || innerInputGroup.value, first.value, last.value, hoverFlag.value, activeFlag.value);
181
+ if (borderColor) drawBorder(ctx, width, height, center, borderRadius, rad, borderColor, pixelSize, typeComputed.value || "primary", innerButtonGroup.value || innerInputGroup.value, first.value, last.value, nextIsTextButton.value);
182
+ const backgroundColor = getBackgroundColor(!!disabledComputed.value, !!loadingComputed.value, typeComputed.value || "primary", themeComputed.value || "primary", palette.value, hoverFlag.value, activeFlag.value);
183
+ if (backgroundColor) floodFill(ctx, Math.round(width / 2), Math.round(height / 2), backgroundColor);
184
+ };
185
+ useResizeObserver(buttonRef, drawPixel);
186
+ useWatchGlobalCssVal(drawPixel);
187
+ useTransitionEnd(buttonRef, drawPixel);
188
+ return (_ctx, _cache) => {
189
+ return openBlock(), createElementBlock("button", {
190
+ disabled: unref(disabledComputed) || unref(loadingComputed),
191
+ class: normalizeClass(["pixelium px-button", {
192
+ "px-button__block": !(innerButtonGroup.value || innerInputGroup.value) && !!props.block,
193
+ [`px-button__${unref(shapeComputed)}`]: unref(shapeComputed),
194
+ "px-button__loading": unref(loadingComputed),
195
+ [`px-button__${unref(sizeComputed)}`]: unref(sizeComputed),
196
+ "px-button__outline": unref(typeComputed) === "outline",
197
+ "px-button__plain": unref(typeComputed) === "plain",
198
+ "px-button__text": unref(typeComputed) === "text",
199
+ "px-button__disabled": unref(disabledComputed),
200
+ "px-button__custom": palette.value,
201
+ "px-button__inner": innerButtonGroup.value || innerInputGroup.value,
202
+ [`px-button__${unref(themeComputed) || "primary"}`]: true
203
+ }]),
204
+ style: normalizeStyle({ color: textColor.value }),
205
+ ref_key: "buttonRef",
206
+ ref: buttonRef,
207
+ onMouseenter: _cache[0] || (_cache[0] = ($event) => toggleHover(true)),
208
+ onMouseleave: _cache[1] || (_cache[1] = ($event) => toggleHover(false)),
209
+ onMousedown: _cache[2] || (_cache[2] = ($event) => toggleActive(true)),
210
+ onMouseup: _cache[3] || (_cache[3] = ($event) => toggleActive(false)),
211
+ type: props.nativeType,
212
+ autofocus: props.autofocus
213
+ }, [
214
+ createElementVNode("canvas", {
215
+ ref_key: "canvasRef",
216
+ ref: canvasRef,
217
+ class: "px-button-canvas"
218
+ }, null, 512),
219
+ unref(slots).icon || unref(loadingComputed) ? (openBlock(), createElementBlock("div", {
220
+ key: 0,
221
+ class: normalizeClass(["px-button-icon-wrapper", { "px-button-icon-wrapper__last": !unref(slots).default }])
222
+ }, [unref(loadingComputed) ? (openBlock(), createBlock(unref(spinner_third_solid_default), {
223
+ key: 0,
224
+ class: "px-button-icon px-animation__loading",
225
+ style: normalizeStyle({ fill: textColor.value })
226
+ }, null, 8, ["style"])) : renderSlot(_ctx.$slots, "icon", { key: 1 })], 2)) : createCommentVNode("v-if", true),
227
+ renderSlot(_ctx.$slots, "default")
228
+ ], 46, _hoisted_1);
229
+ };
230
+ }
255
231
  });
256
- export {
257
- _sfc_main as _
258
- };
232
+ export { button_default as t };
@@ -6,10 +6,10 @@ export type ButtonProps = {
6
6
  */
7
7
  borderRadius?: NumberOrPercentage | NumberOrPercentage[];
8
8
  /**
9
- * @property {'default' | 'round' | 'circle' | 'square'} [shape='default']
10
- * @version 0.0.0-beta
9
+ * @property {'rect' | 'round' | 'circle' | 'square'} [shape='rect']
10
+ * @version 0.0.3
11
11
  */
12
- shape?: 'default' | 'round' | 'circle' | 'square';
12
+ shape?: 'rect' | 'round' | 'circle' | 'square' | 'default';
13
13
  /**
14
14
  * @property {'medium' | 'large' | 'small'} [size='medium']
15
15
  * @version 0.0.0-beta
@@ -1,7 +1,4 @@
1
1
  .px-button-group {
2
- --padding-y-size: 6px;
3
- --padding-x-size: 12px;
4
- height: var(--button-size);
5
2
  display: inline-flex;
6
3
  align-items: center;
7
4
  position: relative;
@@ -4,9 +4,8 @@ type __VLS_Slots = {} & {
4
4
  default?: (props: typeof __VLS_1) => any;
5
5
  };
6
6
  declare const __VLS_component: import("vue").DefineComponent<ButtonGroupProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ButtonGroupProps> & Readonly<{}>, {
7
- shape: "default" | "round";
8
- size: "medium" | "large" | "small";
9
7
  disabled: boolean;
8
+ shape: "rect" | "round" | "default";
10
9
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
11
10
  declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
12
11
  export default _default;