@pixelium/web-vue 0.0.2 → 0.0.3-beta

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 (285) hide show
  1. package/README.md +42 -0
  2. package/README.zh.md +6 -3
  3. package/coverage/base.css +224 -0
  4. package/coverage/block-navigation.js +87 -0
  5. package/coverage/coverage-final.json +106 -0
  6. package/coverage/favicon.png +0 -0
  7. package/coverage/index.html +926 -0
  8. package/coverage/prettify.css +1 -0
  9. package/coverage/prettify.js +2 -0
  10. package/coverage/sort-arrow-sprite.png +0 -0
  11. package/coverage/sorter.js +210 -0
  12. package/dist/font.css +1 -1
  13. package/dist/index.d.ts +1593 -248
  14. package/dist/normalize.css +2 -0
  15. package/dist/pixelium-vue-icon-hn.cjs +1 -1
  16. package/dist/pixelium-vue-icon-hn.css +2 -1
  17. package/dist/pixelium-vue-icon-hn.js +8533 -8154
  18. package/dist/pixelium-vue-icon-hn.umd.cjs +1 -1
  19. package/dist/pixelium-vue-icon-pa.cjs +1 -1
  20. package/dist/pixelium-vue-icon-pa.css +2 -1
  21. package/dist/pixelium-vue-icon-pa.js +10625 -10143
  22. package/dist/pixelium-vue-icon-pa.umd.cjs +1 -1
  23. package/dist/pixelium-vue.cjs +2 -2
  24. package/dist/pixelium-vue.css +2 -1
  25. package/dist/pixelium-vue.js +7402 -5852
  26. package/dist/pixelium-vue.umd.cjs +2 -2
  27. package/es/aside/index.js +46 -151
  28. package/es/auto-complete/draw.d.ts +1 -1
  29. package/es/auto-complete/draw.js +26 -51
  30. package/es/auto-complete/index.css +92 -32
  31. package/es/auto-complete/index.d.ts +12 -15
  32. package/es/auto-complete/index.js +338 -400
  33. package/es/auto-complete/type.d.ts +25 -13
  34. package/es/avatar/css.js +2 -0
  35. package/es/avatar/draw.d.ts +2 -0
  36. package/es/avatar/draw.js +11 -0
  37. package/es/avatar/index.css +49 -0
  38. package/es/avatar/index.d.ts +15 -0
  39. package/es/avatar/index.js +110 -0
  40. package/es/avatar/type.d.ts +34 -0
  41. package/es/button/draw.d.ts +4 -4
  42. package/es/button/draw.js +213 -297
  43. package/es/button/index.css +40 -30
  44. package/es/button/index.d.ts +0 -4
  45. package/es/button/index.js +230 -256
  46. package/es/button/type.d.ts +3 -3
  47. package/es/button-group/index.css +0 -3
  48. package/es/button-group/index.d.ts +1 -2
  49. package/es/button-group/index.js +59 -31
  50. package/es/button-group/type.d.ts +21 -4
  51. package/es/checkbox/css.js +2 -0
  52. package/es/checkbox/draw.d.ts +4 -0
  53. package/es/checkbox/draw.js +46 -0
  54. package/es/checkbox/index.css +85 -0
  55. package/es/checkbox/index.d.ts +31 -0
  56. package/es/checkbox/index.js +206 -0
  57. package/es/checkbox/type.d.ts +88 -0
  58. package/es/checkbox-group/css.js +2 -0
  59. package/es/checkbox-group/index.css +20 -0
  60. package/es/checkbox-group/index.d.ts +23 -0
  61. package/es/checkbox-group/index.js +84 -0
  62. package/es/checkbox-group/type.d.ts +78 -0
  63. package/es/col/index.d.ts +2 -2
  64. package/es/col/index.js +43 -58
  65. package/es/container/index.js +18 -31
  66. package/es/divider/index.js +39 -53
  67. package/es/empty/index.css +4 -4
  68. package/es/empty/index.js +16 -71
  69. package/es/entry.js +102 -0
  70. package/es/footer/index.js +31 -40
  71. package/es/form/css.js +1 -0
  72. package/es/form/index.d.ts +27 -0
  73. package/es/form/index.js +125 -0
  74. package/es/form/type.d.ts +238 -0
  75. package/es/form/use-form.d.ts +4 -0
  76. package/es/form/use-form.js +48 -0
  77. package/es/form-item/css.js +2 -0
  78. package/es/form-item/index.css +77 -0
  79. package/es/form-item/index.d.ts +37 -0
  80. package/es/form-item/index.js +318 -0
  81. package/es/form-item/type.d.ts +96 -0
  82. package/es/grid/index.js +56 -75
  83. package/es/grid-item/css.js +0 -1
  84. package/es/grid-item/index.d.ts +1 -1
  85. package/es/grid-item/index.js +85 -121
  86. package/es/header/index.js +31 -40
  87. package/es/icon/index.js +44 -55
  88. package/es/icons/css-hn.js +0 -1
  89. package/es/icons/css-pa.js +0 -1
  90. package/es/icons/icon-hn.js +10337 -15986
  91. package/es/icons/icon-pa.js +12573 -17447
  92. package/es/image/css.js +2 -0
  93. package/es/image/index.css +69 -0
  94. package/es/image/index.d.ts +35 -0
  95. package/es/image/index.js +199 -0
  96. package/es/image/type.d.ts +126 -0
  97. package/es/index.css +1 -515
  98. package/es/index.d.ts +22 -2
  99. package/es/index.js +143 -123
  100. package/es/input/draw.d.ts +1 -1
  101. package/es/input/draw.js +26 -51
  102. package/es/input/index.css +85 -33
  103. package/es/input/index.d.ts +9 -16
  104. package/es/input/index.js +319 -423
  105. package/es/input/type.d.ts +3 -3
  106. package/es/input-group/index.css +0 -1
  107. package/es/input-group/index.d.ts +2 -2
  108. package/es/input-group/index.js +66 -37
  109. package/es/input-group/type.d.ts +16 -4
  110. package/es/input-group-label/draw.d.ts +1 -1
  111. package/es/input-group-label/draw.js +26 -51
  112. package/es/input-group-label/index.css +33 -22
  113. package/es/input-group-label/index.d.ts +1 -4
  114. package/es/input-group-label/index.js +104 -127
  115. package/es/input-group-label/type.d.ts +3 -3
  116. package/es/input-number/draw.d.ts +1 -1
  117. package/es/input-number/draw.js +26 -51
  118. package/es/input-number/index.css +90 -35
  119. package/es/input-number/index.d.ts +9 -16
  120. package/es/input-number/index.js +428 -536
  121. package/es/input-number/type.d.ts +3 -3
  122. package/es/input-tag/draw.d.ts +1 -1
  123. package/es/input-tag/draw.js +26 -48
  124. package/es/input-tag/index.css +100 -33
  125. package/es/input-tag/index.d.ts +7 -13
  126. package/es/input-tag/index.js +442 -467
  127. package/es/input-tag/type.d.ts +24 -13
  128. package/es/link/index.js +75 -106
  129. package/es/main/index.js +11 -15
  130. package/es/mask/index.js +94 -115
  131. package/es/message/index.css +1 -1
  132. package/es/message/index.js +168 -346
  133. package/es/message-box/css.js +1 -1
  134. package/es/message-box/index.js +98 -114
  135. package/es/message-box/message-box-wrapped.js +33 -46
  136. package/es/message-box/message-box.js +79 -111
  137. package/es/option-list/index.css +13 -13
  138. package/es/option-list/index.d.ts +4 -31
  139. package/es/option-list/index.js +99 -167
  140. package/es/option-list/type.d.ts +5 -1
  141. package/es/pixelate/pixel.d.ts +5 -0
  142. package/es/pixelate/pixel.js +70 -0
  143. package/es/pixelate/pixelate.worker.d.ts +1 -0
  144. package/es/popover/index.d.ts +13 -99
  145. package/es/popover/index.js +75 -238
  146. package/es/popover/type.d.ts +7 -2
  147. package/es/popup/css.js +1 -0
  148. package/es/popup/index.d.ts +210 -0
  149. package/es/popup/index.js +203 -0
  150. package/es/popup/type.d.ts +105 -0
  151. package/es/popup-content/draw.d.ts +2 -2
  152. package/es/popup-content/draw.js +98 -143
  153. package/es/popup-content/index.css +11 -11
  154. package/es/popup-content/index.d.ts +1 -0
  155. package/es/popup-content/index.js +253 -1576
  156. package/es/popup-content/type.d.ts +1 -0
  157. package/es/popup-trigger/index.d.ts +8 -2
  158. package/es/popup-trigger/index.js +122 -95
  159. package/es/popup-trigger/type.d.ts +4 -1
  160. package/es/popup-wrapper/css.js +2 -0
  161. package/es/popup-wrapper/index.css +14 -0
  162. package/es/popup-wrapper/index.d.ts +18 -0
  163. package/es/popup-wrapper/index.js +67 -0
  164. package/es/popup-wrapper/type.d.ts +9 -0
  165. package/es/radio/css.js +1 -0
  166. package/es/radio/draw.d.ts +4 -0
  167. package/es/radio/draw.js +47 -0
  168. package/es/radio/index.d.ts +30 -0
  169. package/es/radio/index.js +190 -0
  170. package/es/radio/style.css +73 -0
  171. package/es/radio/type.d.ts +76 -0
  172. package/es/radio-group/css.js +2 -0
  173. package/es/radio-group/index.css +20 -0
  174. package/es/radio-group/index.d.ts +23 -0
  175. package/es/radio-group/index.js +77 -0
  176. package/es/radio-group/type.d.ts +77 -0
  177. package/es/row/index.js +56 -70
  178. package/es/select/draw.d.ts +1 -1
  179. package/es/select/draw.js +26 -51
  180. package/es/select/index.css +118 -36
  181. package/es/select/index.d.ts +14 -16
  182. package/es/select/index.js +625 -672
  183. package/es/select/type.d.ts +60 -25
  184. package/es/share/const/event-bus-key.js +1 -6
  185. package/es/share/const/index.d.ts +4 -0
  186. package/es/share/const/index.js +22 -24
  187. package/es/share/const/provide-key.d.ts +5 -0
  188. package/es/share/const/provide-key.js +6 -5
  189. package/es/share/const/style.d.ts +6 -0
  190. package/es/share/const/style.js +7 -0
  191. package/es/share/hook/use-cancelable-delay.d.ts +1 -0
  192. package/es/share/hook/use-cancelable-delay.js +42 -0
  193. package/es/share/hook/use-click-outside-listener.d.ts +1 -1
  194. package/es/share/hook/use-click-outside-listener.js +28 -41
  195. package/es/share/hook/use-composition.js +17 -15
  196. package/es/share/hook/use-controlled-mode.d.ts +3 -3
  197. package/es/share/hook/use-controlled-mode.js +20 -23
  198. package/es/share/hook/use-dark-mode.js +51 -65
  199. package/es/share/hook/use-index-of-children.d.ts +2 -1
  200. package/es/share/hook/use-index-of-children.js +47 -45
  201. package/es/share/hook/use-lazy-load.d.ts +10 -0
  202. package/es/share/hook/use-lazy-load.js +133 -0
  203. package/es/share/hook/use-props-detect.d.ts +2 -0
  204. package/es/share/hook/use-resize-observer.d.ts +1 -2
  205. package/es/share/hook/use-resize-observer.js +28 -20
  206. package/es/share/hook/use-screen-width.js +27 -36
  207. package/es/share/hook/use-smooth-transition.d.ts +2 -0
  208. package/es/share/hook/use-smooth-transition.js +65 -0
  209. package/es/share/hook/use-textarea-height.js +86 -92
  210. package/es/share/hook/use-theme-mode.js +41 -42
  211. package/es/share/hook/use-transition-end.d.ts +2 -0
  212. package/es/share/hook/use-transition-end.js +12 -0
  213. package/es/share/hook/use-watch-global-css-var.js +12 -16
  214. package/es/share/hook/use-window-resize-listener.d.ts +1 -0
  215. package/es/share/hook/use-window-resize-listener.js +15 -0
  216. package/es/share/hook/use-z-index.js +30 -27
  217. package/es/share/type/index.d.ts +18 -3
  218. package/es/share/util/color.d.ts +5 -3
  219. package/es/share/util/color.js +156 -149
  220. package/es/share/util/common.d.ts +7 -2
  221. package/es/share/util/common.js +127 -65
  222. package/es/share/util/console.d.ts +3 -3
  223. package/es/share/util/console.js +10 -7
  224. package/es/share/util/dom.d.ts +19 -0
  225. package/es/share/util/dom.js +88 -0
  226. package/es/share/util/env.d.ts +1 -0
  227. package/es/share/util/env.js +5 -4
  228. package/es/share/util/event-bus.js +3 -20
  229. package/es/share/util/lru-cache.js +29 -33
  230. package/es/share/util/pixel.d.ts +4 -0
  231. package/es/share/util/plot.d.ts +8 -3
  232. package/es/share/util/plot.js +457 -229
  233. package/es/share/util/reactivity.d.ts +8 -0
  234. package/es/share/util/reactivity.js +23 -0
  235. package/es/share/util/render.js +31 -41
  236. package/es/share/util/theme.d.ts +3 -0
  237. package/es/share/util/theme.js +77 -57
  238. package/es/slider/css.js +2 -0
  239. package/es/slider/draw.d.ts +25 -0
  240. package/es/slider/draw.js +113 -0
  241. package/es/slider/index.css +119 -0
  242. package/es/slider/index.d.ts +66 -0
  243. package/es/slider/index.js +503 -0
  244. package/es/slider/type.d.ts +162 -0
  245. package/es/slider/util.d.ts +37 -0
  246. package/es/slider/util.js +130 -0
  247. package/es/space/index.css +24 -29
  248. package/es/space/index.js +73 -97
  249. package/es/spin/index.css +18 -17
  250. package/es/spin/index.js +72 -102
  251. package/es/spin/type.d.ts +11 -5
  252. package/es/switch/css.js +2 -0
  253. package/es/switch/draw.d.ts +2 -0
  254. package/es/switch/draw.js +18 -0
  255. package/es/switch/index.css +121 -0
  256. package/es/switch/index.d.ts +42 -0
  257. package/es/switch/index.js +259 -0
  258. package/es/switch/type.d.ts +133 -0
  259. package/es/tag/draw.d.ts +2 -2
  260. package/es/tag/draw.js +80 -127
  261. package/es/tag/index.css +38 -22
  262. package/es/tag/index.d.ts +2 -2
  263. package/es/tag/index.js +121 -190
  264. package/es/tag/type.d.ts +3 -3
  265. package/es/text-outline/css.js +2 -0
  266. package/es/text-outline/index.css +4 -0
  267. package/es/text-outline/index.d.ts +17 -0
  268. package/es/text-outline/index.js +33 -0
  269. package/es/text-outline/type.d.ts +23 -0
  270. package/es/textarea/draw.js +9 -11
  271. package/es/textarea/index.css +37 -23
  272. package/es/textarea/index.d.ts +8 -14
  273. package/es/textarea/index.js +274 -262
  274. package/es/tooltip/index.d.ts +100 -4
  275. package/es/tooltip/index.js +70 -226
  276. package/es/tooltip/type.d.ts +7 -2
  277. package/es/vendor.js +504 -0
  278. package/es/virtual-list/css.js +2 -0
  279. package/es/virtual-list/index.css +25 -0
  280. package/es/virtual-list/index.d.ts +11 -0
  281. package/es/virtual-list/index.js +313 -0
  282. package/es/virtual-list/type.d.ts +26 -0
  283. package/package.json +10 -16
  284. package/es/grid-item/index.css +0 -0
  285. /package/es/message-box/{message-box.css → index.css} +0 -0
@@ -1,33 +1,61 @@
1
1
  import './css.js'
2
- import { defineComponent, provide, createElementBlock, openBlock, renderSlot } from "vue";
3
- import { e as emitParentUpdate } from "../share/hook/use-index-of-children.js";
4
- import { B as BUTTON_GROUP_UPDATE } from "../share/const/event-bus-key.js";
5
- import { B as BUTTON_GROUP_PROVIDE } from "../share/const/provide-key.js";
6
- const _hoisted_1 = { class: "pixelium px-button-group" };
7
- const _sfc_main = /* @__PURE__ */ defineComponent({
8
- ...{
9
- name: "ButtonGroup"
10
- },
11
- __name: "index",
12
- props: {
13
- borderRadius: null,
14
- shape: { default: "default" },
15
- size: { default: "medium" },
16
- disabled: { type: Boolean, default: false },
17
- loading: { type: Boolean },
18
- variant: null
19
- },
20
- setup(__props) {
21
- const props = __props;
22
- provide(BUTTON_GROUP_PROVIDE, props);
23
- emitParentUpdate(BUTTON_GROUP_UPDATE);
24
- return (_ctx, _cache) => {
25
- return openBlock(), createElementBlock("div", _hoisted_1, [
26
- renderSlot(_ctx.$slots, "default")
27
- ]);
28
- };
29
- }
2
+ import { t as BUTTON_GROUP_UPDATE } from "../share/const/event-bus-key.js";
3
+ import { t as emitParentUpdate } from "../share/hook/use-index-of-children.js";
4
+ import { a as FORM_PROVIDE, i as FORM_ITEM_PROVIDE, t as BUTTON_GROUP_PROVIDE } from "../share/const/provide-key.js";
5
+ import { t as createProvideComputed } from "../share/util/reactivity.js";
6
+ import { createElementBlock, defineComponent, inject, openBlock, provide, ref, renderSlot, toRefs } from "vue";
7
+ var _hoisted_1 = { class: "pixelium px-button-group" };
8
+ var button_group_default = /* @__PURE__ */ defineComponent({
9
+ name: "ButtonGroup",
10
+ __name: "index",
11
+ props: {
12
+ borderRadius: null,
13
+ shape: { default: "rect" },
14
+ size: null,
15
+ disabled: {
16
+ type: Boolean,
17
+ default: false
18
+ },
19
+ loading: { type: Boolean },
20
+ variant: null,
21
+ theme: null
22
+ },
23
+ setup(__props) {
24
+ const props = __props;
25
+ const formProvide = inject(FORM_PROVIDE);
26
+ const formItemProvide = inject(FORM_ITEM_PROVIDE);
27
+ const sizeComputed = createProvideComputed("size", () => [
28
+ props.size && props,
29
+ formItemProvide,
30
+ formProvide,
31
+ props
32
+ ], "nullish", (val) => val || "medium");
33
+ const disabledComputed = createProvideComputed("disabled", [
34
+ formItemProvide,
35
+ formProvide,
36
+ props
37
+ ], (pre, value, cur) => {
38
+ return pre || value || "readonly" in cur && cur["readonly"].value;
39
+ });
40
+ const childrenInfo = ref([]);
41
+ provide(BUTTON_GROUP_PROVIDE, {
42
+ ...toRefs(props),
43
+ size: sizeComputed,
44
+ disabled: disabledComputed,
45
+ childrenInfo,
46
+ collectChildrenInfo: (info) => {
47
+ const idx = childrenInfo.value.findIndex((e) => e.id === info.id);
48
+ if (idx >= 0) childrenInfo.value[idx] = info;
49
+ else childrenInfo.value.push(info);
50
+ },
51
+ removeChildrenInfo: (id) => {
52
+ childrenInfo.value = childrenInfo.value.filter((e) => e.id != id);
53
+ }
54
+ });
55
+ emitParentUpdate(BUTTON_GROUP_UPDATE);
56
+ return (_ctx, _cache) => {
57
+ return openBlock(), createElementBlock("div", _hoisted_1, [renderSlot(_ctx.$slots, "default")]);
58
+ };
59
+ }
30
60
  });
31
- export {
32
- _sfc_main as _
33
- };
61
+ export { button_group_default as t };
@@ -1,4 +1,6 @@
1
- import type { NumberOrPercentage } from '../share/type';
1
+ import type { Ref, ToRefs } from 'vue';
2
+ import type { LooseRequired, NumberOrPercentage } from '../share/type';
3
+ import type { ButtonProps } from '../button/type';
2
4
  export type ButtonGroupProps = {
3
5
  /**
4
6
  * @property {NumberOrPercentage | NumberOrPercentage[]} [borderRadius]
@@ -6,13 +8,13 @@ export type ButtonGroupProps = {
6
8
  */
7
9
  borderRadius?: NumberOrPercentage | NumberOrPercentage[];
8
10
  /**
9
- * @property {'default' | 'round'} [shape='default']
11
+ * @property {'rect' | 'round'} [shape='rect']
10
12
  * @version 0.0.0-beta
11
13
  */
12
- shape?: 'default' | 'round';
14
+ shape?: 'rect' | 'round' | 'default';
13
15
  /**
14
16
  * @property {'medium' | 'large' | 'small'} [size='medium']
15
- * @version 0.0.0-beta
17
+ * @version 0.0.3
16
18
  */
17
19
  size?: 'medium' | 'large' | 'small';
18
20
  /**
@@ -30,6 +32,11 @@ export type ButtonGroupProps = {
30
32
  * @version 0.0.0-beta
31
33
  */
32
34
  variant?: 'primary' | 'plain' | 'text' | 'outline';
35
+ /**
36
+ * @property {'primary' | 'sakura' | 'success' | 'warning' | 'danger' | 'info'} [theme]
37
+ * @version 0.0.0-beta
38
+ */
39
+ theme?: 'primary' | 'sakura' | 'success' | 'warning' | 'danger' | 'info';
33
40
  };
34
41
  export type ButtonGroupSlots = {
35
42
  /**
@@ -38,3 +45,13 @@ export type ButtonGroupSlots = {
38
45
  */
39
46
  default: {};
40
47
  };
48
+ export type ChildrenInfo = {
49
+ id: string;
50
+ variant?: ButtonProps['variant'];
51
+ index: number;
52
+ };
53
+ export type ButtonGroupProvide = ToRefs<LooseRequired<ButtonGroupProps>> & {
54
+ childrenInfo: Ref<ChildrenInfo[]>;
55
+ collectChildrenInfo: (info: ChildrenInfo) => void;
56
+ removeChildrenInfo: (id: string) => void;
57
+ };
@@ -0,0 +1,2 @@
1
+ import '../index.css'
2
+ import './index.css'
@@ -0,0 +1,4 @@
1
+ export declare const drawBorder: (ctx: CanvasRenderingContext2D, width: number, height: number, borderColor: string, pixelSize: number) => void;
2
+ export declare const drawBracketBorder: (ctx: CanvasRenderingContext2D, width: number, height: number, borderColor: string, pixelSize: number) => void;
3
+ export declare const drawAsteriskMark: (ctx: CanvasRenderingContext2D, size: number, interval: number, color: string, pixelSize: number) => void;
4
+ export declare const drawLineMark: (ctx: CanvasRenderingContext2D, size: number, interval: number, color: string, pixelSize: number) => void;
@@ -0,0 +1,46 @@
1
+ import { a as INV_SQRT3 } from "../share/const/index.js";
2
+ import { d as roundToPixel } from "../share/util/plot.js";
3
+ const drawBorder = (ctx, width, height, borderColor, pixelSize) => {
4
+ ctx.fillStyle = borderColor;
5
+ ctx.fillRect(pixelSize, 0, width - pixelSize * 2, pixelSize);
6
+ ctx.fillRect(width - pixelSize, pixelSize, pixelSize, height - pixelSize * 2);
7
+ ctx.fillRect(pixelSize, height - pixelSize, width - pixelSize * 2, pixelSize);
8
+ ctx.fillRect(0, pixelSize, pixelSize, height - pixelSize * 2);
9
+ };
10
+ const drawBracketBorder = (ctx, width, height, borderColor, pixelSize) => {
11
+ ctx.fillStyle = borderColor;
12
+ const bracketWidth = Math.floor(width / 3);
13
+ ctx.fillRect(0, 0, bracketWidth, pixelSize);
14
+ ctx.fillRect(width - bracketWidth, 0, bracketWidth, pixelSize);
15
+ ctx.fillRect(width - pixelSize, pixelSize, pixelSize, height - pixelSize * 2);
16
+ ctx.fillRect(0, height - pixelSize, bracketWidth, pixelSize);
17
+ ctx.fillRect(width - bracketWidth, height - pixelSize, bracketWidth, pixelSize);
18
+ ctx.fillRect(0, pixelSize, pixelSize, height - pixelSize * 2);
19
+ };
20
+ const drawAsteriskMark = (ctx, size, interval, color, pixelSize) => {
21
+ ctx.fillStyle = color;
22
+ let areaSize = roundToPixel(size - pixelSize * 2 - interval * 2, pixelSize);
23
+ while (Math.round(areaSize / pixelSize) <= 3) areaSize += pixelSize;
24
+ const offset = Math.round((size - areaSize) / 2);
25
+ const steps = Math.round(areaSize / pixelSize);
26
+ let mid = steps >> 1;
27
+ if (steps % 2 === 0) mid -= .5;
28
+ ctx.fillRect(offset + mid * pixelSize, offset, pixelSize, areaSize);
29
+ const offset4Slash = mid * pixelSize - mid * pixelSize * INV_SQRT3;
30
+ for (let i = 0; i < steps; i++) {
31
+ const y = Math.round(offset + offset4Slash + i * pixelSize * INV_SQRT3);
32
+ ctx.fillRect(offset + i * pixelSize, y, pixelSize, pixelSize);
33
+ ctx.fillRect(offset + (steps - i) * pixelSize - pixelSize, y, pixelSize, pixelSize);
34
+ }
35
+ };
36
+ const drawLineMark = (ctx, size, interval, color, pixelSize) => {
37
+ ctx.fillStyle = color;
38
+ let areaSize = roundToPixel(size - pixelSize * 2 - interval * 2, pixelSize);
39
+ while (Math.round(areaSize / pixelSize) <= 3) areaSize += pixelSize;
40
+ const offset = Math.round((size - areaSize) / 2);
41
+ const steps = Math.round(areaSize / pixelSize);
42
+ let mid = steps >> 1;
43
+ if (steps % 2 === 0) mid -= .5;
44
+ ctx.fillRect(offset, offset + mid * pixelSize, areaSize, pixelSize);
45
+ };
46
+ export { drawLineMark as i, drawBorder as n, drawBracketBorder as r, drawAsteriskMark as t };
@@ -0,0 +1,85 @@
1
+ .px-checkbox {
2
+ --checkbox-size: var(--px-medium-compat-size);
3
+ --text-color: var(--px-neutral-10);
4
+ color: var(--text-color);
5
+ display: inline-flex;
6
+ align-items: center;
7
+ cursor: pointer;
8
+ transition: 0.25s all;
9
+ }
10
+ .px-checkbox.px-checkbox {
11
+ font-size: 14px;
12
+ }
13
+ .px-checkbox__large {
14
+ --checkbox-size: var(--px-large-compat-size);
15
+ font-size: 15px;
16
+ }
17
+ .px-checkbox__large .px-checkbox-box {
18
+ margin-right: 12px;
19
+ }
20
+ .px-checkbox__small {
21
+ --checkbox-size: var(--px-small-compat-size);
22
+ font-size: 12px;
23
+ }
24
+ .px-checkbox__small .px-checkbox-box {
25
+ margin-right: 4px;
26
+ }
27
+ .px-checkbox-box {
28
+ width: var(--checkbox-size);
29
+ height: var(--checkbox-size);
30
+ border: var(--px-bit) solid transparent;
31
+ background-color: transparent;
32
+ position: relative;
33
+ box-sizing: border-box;
34
+ flex-shrink: 0;
35
+ flex-grow: 0;
36
+ margin-right: 8px;
37
+ transition: 0.25s;
38
+ z-index: 0;
39
+ }
40
+ .px-checkbox-box > .px-checkbox-checked-mark {
41
+ position: absolute;
42
+ top: 50%;
43
+ left: 50%;
44
+ transform: translate(-50%, -50%);
45
+ fill: var(--px-primary-6);
46
+ width: 100%;
47
+ height: 100%;
48
+ }
49
+ .px-checkbox-canvas {
50
+ position: absolute;
51
+ top: 50%;
52
+ left: 50%;
53
+ transform: translate(-50%, -50%);
54
+ pointer-events: none;
55
+ z-index: -1;
56
+ }
57
+ .px-checkbox-input {
58
+ width: 0;
59
+ height: 0;
60
+ margin: 0;
61
+ padding: 0;
62
+ position: absolute;
63
+ }
64
+ .px-checkbox:hover .px-checkbox-checked-mark {
65
+ fill: var(--px-primary-5);
66
+ }
67
+ .px-checkbox__checked {
68
+ --text-color: var(--px-primary-6);
69
+ }
70
+ .px-checkbox__readonly {
71
+ cursor: default;
72
+ }
73
+ .px-checkbox__disabled {
74
+ cursor: not-allowed;
75
+ --text-color: var(--px-neutral-8);
76
+ }
77
+ .px-checkbox__disabled .px-checkbox-checked-mark {
78
+ fill: var(--px-neutral-8);
79
+ }
80
+ .px-checkbox__disabled.px-checkbox__checked {
81
+ --text-color: var(--px-primary-2);
82
+ }
83
+ .px-checkbox__disabled.px-checkbox__checked .px-checkbox-checked-mark {
84
+ fill: var(--px-primary-2);
85
+ }
@@ -0,0 +1,31 @@
1
+ import type { CheckboxProps } from './type';
2
+ declare var __VLS_6: {};
3
+ type __VLS_Slots = {} & {
4
+ default?: (props: typeof __VLS_6) => any;
5
+ };
6
+ declare const __VLS_component: import("vue").DefineComponent<CheckboxProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
7
+ change: (value: boolean, event: Event) => any;
8
+ blur: (event: FocusEvent) => any;
9
+ input: (value: boolean, event: InputEvent) => any;
10
+ focus: (event: FocusEvent) => any;
11
+ "update:modelValue": (value: boolean) => any;
12
+ }, string, import("vue").PublicProps, Readonly<CheckboxProps> & Readonly<{
13
+ onChange?: ((value: boolean, event: Event) => any) | undefined;
14
+ onBlur?: ((event: FocusEvent) => any) | undefined;
15
+ onInput?: ((value: boolean, event: InputEvent) => any) | undefined;
16
+ onFocus?: ((event: FocusEvent) => any) | undefined;
17
+ "onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
18
+ }>, {
19
+ disabled: boolean;
20
+ readonly: boolean;
21
+ modelValue: boolean | null;
22
+ defaultValue: boolean | null;
23
+ indeterminate: boolean;
24
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
25
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
26
+ export default _default;
27
+ type __VLS_WithSlots<T, S> = T & {
28
+ new (): {
29
+ $slots: S;
30
+ };
31
+ };
@@ -0,0 +1,206 @@
1
+ import './css.js'
2
+ import { t as check_solid_default } from "../vendor.js";
3
+ import { n as INTERVAL } from "../share/const/style.js";
4
+ import { i as canvasPreprocess, n as calcPixelSize } from "../share/util/plot.js";
5
+ import { r as getGlobalThemeColorString } from "../share/util/color.js";
6
+ import { t as useDarkMode } from "../share/hook/use-dark-mode.js";
7
+ import { t as useResizeObserver } from "../share/hook/use-resize-observer.js";
8
+ import { t as useWatchGlobalCssVal } from "../share/hook/use-watch-global-css-var.js";
9
+ import { i as FORM_ITEM_PROVIDE, n as CHECKBOX_GROUP_PROVIDE } from "../share/const/provide-key.js";
10
+ import { t as createProvideComputed } from "../share/util/reactivity.js";
11
+ import { t as useTransitionEnd } from "../share/hook/use-transition-end.js";
12
+ import { t as useControlledMode } from "../share/hook/use-controlled-mode.js";
13
+ import { i as drawLineMark, n as drawBorder, r as drawBracketBorder, t as drawAsteriskMark } from "./draw.js";
14
+ import { createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, inject, nextTick, normalizeClass, onMounted, openBlock, ref, renderSlot, shallowRef, toDisplayString, unref, watch, withModifiers } from "vue";
15
+ var _hoisted_1 = [
16
+ "disabled",
17
+ "value",
18
+ "checked"
19
+ ];
20
+ var checkbox_default = /* @__PURE__ */ defineComponent({
21
+ name: "Checkbox",
22
+ __name: "index",
23
+ props: {
24
+ modelValue: {
25
+ type: Boolean,
26
+ default: void 0
27
+ },
28
+ defaultValue: {
29
+ type: Boolean,
30
+ default: void 0
31
+ },
32
+ indeterminate: {
33
+ type: Boolean,
34
+ default: false
35
+ },
36
+ disabled: {
37
+ type: Boolean,
38
+ default: false
39
+ },
40
+ readonly: {
41
+ type: Boolean,
42
+ default: false
43
+ },
44
+ variant: null,
45
+ label: null,
46
+ value: null,
47
+ size: null
48
+ },
49
+ emits: [
50
+ "update:modelValue",
51
+ "input",
52
+ "change",
53
+ "focus",
54
+ "blur"
55
+ ],
56
+ setup(__props, { emit: __emit }) {
57
+ const props = __props;
58
+ const emits = __emit;
59
+ const [modelValue, updateModelValue] = useControlledMode("modelValue", props, emits, {
60
+ defaultField: "defaultValue",
61
+ transform: (val) => !!val
62
+ });
63
+ const formItemProvide = inject(FORM_ITEM_PROVIDE);
64
+ const checkboxGroupProvide = inject(CHECKBOX_GROUP_PROVIDE);
65
+ const sizeComputed = createProvideComputed("size", () => [
66
+ checkboxGroupProvide,
67
+ props.size && props,
68
+ formItemProvide,
69
+ props
70
+ ], "nullish", (val) => val || "medium");
71
+ const variantComputed = createProvideComputed("variant", [checkboxGroupProvide, props], "nullish", (val) => val || "normal");
72
+ const disabledComputed = createProvideComputed("disabled", [
73
+ checkboxGroupProvide,
74
+ formItemProvide,
75
+ props
76
+ ], "or");
77
+ const readonlyComputed = createProvideComputed("readonly", [
78
+ checkboxGroupProvide,
79
+ formItemProvide,
80
+ props
81
+ ], "or");
82
+ const canvasRef = shallowRef(null);
83
+ const boxRef = shallowRef(null);
84
+ const focusFlag = ref(false);
85
+ const hoverFlag = ref(false);
86
+ const mouseenterHandler = () => {
87
+ hoverFlag.value = true;
88
+ };
89
+ const mouseleaveHandler = () => {
90
+ hoverFlag.value = false;
91
+ };
92
+ const blurHandler = (e) => {
93
+ emits("blur", e);
94
+ focusFlag.value = false;
95
+ formItemProvide === null || formItemProvide === void 0 || formItemProvide.blurHandler();
96
+ };
97
+ const focusHandler = (e) => {
98
+ focusFlag.value = true;
99
+ emits("focus", e);
100
+ };
101
+ const inputHandler = async (e) => {
102
+ const newValue = e.target.checked;
103
+ modelValue.value = newValue;
104
+ emits("input", newValue, e);
105
+ await updateModelValue(newValue);
106
+ formItemProvide === null || formItemProvide === void 0 || formItemProvide.inputHandler();
107
+ };
108
+ const changeHandler = (e) => {
109
+ const target = e.target;
110
+ emits("change", target.checked, e);
111
+ formItemProvide === null || formItemProvide === void 0 || formItemProvide.changeHandler();
112
+ };
113
+ if (checkboxGroupProvide) {
114
+ watch(() => checkboxGroupProvide.modelValue.value, (newValue) => {
115
+ modelValue.value = !newValue ? false : newValue.includes(props.value);
116
+ }, { immediate: true });
117
+ watch(modelValue, (newValue) => {
118
+ if (!checkboxGroupProvide) return;
119
+ checkboxGroupProvide.updateValue(props.value, !!newValue);
120
+ });
121
+ }
122
+ const drawPixel = () => {
123
+ const preprocessData = canvasPreprocess(boxRef, canvasRef);
124
+ if (!preprocessData) return;
125
+ const { ctx, width, height } = preprocessData;
126
+ const pixelSize = calcPixelSize();
127
+ const mainColor = disabledComputed.value ? modelValue.value || props.indeterminate ? getGlobalThemeColorString("primary", 2) : getGlobalThemeColorString("neutral", 8) : hoverFlag.value && !readonlyComputed.value ? getGlobalThemeColorString("primary", 5) : modelValue.value || props.indeterminate ? getGlobalThemeColorString("primary", 6) : getGlobalThemeColorString("neutral", 10);
128
+ const backgroundColor = getGlobalThemeColorString("neutral", 1);
129
+ const intervalSize = 4;
130
+ if (variantComputed.value === "normal") {
131
+ drawBorder(ctx, width, height, mainColor, pixelSize);
132
+ ctx.fillStyle = backgroundColor;
133
+ ctx.fillRect(pixelSize, pixelSize, width - pixelSize * 2, height - pixelSize * 2);
134
+ if (props.indeterminate) {
135
+ ctx.fillStyle = mainColor;
136
+ ctx.fillRect(pixelSize + intervalSize, pixelSize + intervalSize, width - pixelSize * 2 - intervalSize * 2, height - pixelSize * 2 - intervalSize * 2);
137
+ }
138
+ } else {
139
+ drawBracketBorder(ctx, width, height, mainColor, pixelSize);
140
+ const size = Math.min(width, height);
141
+ if (props.indeterminate) drawLineMark(ctx, size, intervalSize, mainColor, pixelSize);
142
+ else if (modelValue.value) drawAsteriskMark(ctx, size, intervalSize, mainColor, pixelSize);
143
+ }
144
+ };
145
+ onMounted(() => {
146
+ nextTick(() => {
147
+ drawPixel();
148
+ });
149
+ });
150
+ watch([
151
+ useDarkMode(),
152
+ hoverFlag,
153
+ focusFlag,
154
+ modelValue,
155
+ () => props.indeterminate,
156
+ disabledComputed,
157
+ readonlyComputed,
158
+ sizeComputed,
159
+ variantComputed
160
+ ], () => {
161
+ drawPixel();
162
+ });
163
+ useResizeObserver(boxRef, drawPixel);
164
+ useWatchGlobalCssVal(drawPixel);
165
+ useTransitionEnd(boxRef, drawPixel);
166
+ return (_ctx, _cache) => {
167
+ return openBlock(), createElementBlock("label", {
168
+ class: normalizeClass(["pixelium px-checkbox", {
169
+ "px-checkbox__checked": unref(modelValue) || props.indeterminate,
170
+ "px-checkbox__disabled": unref(disabledComputed),
171
+ "px-checkbox__readonly": unref(readonlyComputed),
172
+ [`px-checkbox__${unref(sizeComputed)}`]: unref(sizeComputed),
173
+ [`px-checkbox__${unref(variantComputed)}`]: unref(variantComputed)
174
+ }]),
175
+ onMouseenter: mouseenterHandler,
176
+ onMouseleave: mouseleaveHandler
177
+ }, [createElementVNode("div", {
178
+ class: "px-checkbox-box",
179
+ ref_key: "boxRef",
180
+ ref: boxRef
181
+ }, [
182
+ createElementVNode("canvas", {
183
+ class: "px-checkbox-canvas",
184
+ ref_key: "canvasRef",
185
+ ref: canvasRef
186
+ }, null, 512),
187
+ unref(modelValue) && !props.indeterminate && unref(variantComputed) === "normal" ? (openBlock(), createBlock(unref(check_solid_default), {
188
+ key: 0,
189
+ class: "px-checkbox-checked-mark"
190
+ })) : createCommentVNode("v-if", true),
191
+ createElementVNode("input", {
192
+ type: "checkbox",
193
+ class: "px-checkbox-input",
194
+ disabled: unref(disabledComputed) || unref(readonlyComputed),
195
+ value: props.value,
196
+ checked: !!unref(modelValue),
197
+ onFocus: focusHandler,
198
+ onBlur: blurHandler,
199
+ onInput: withModifiers(inputHandler, ["stop"]),
200
+ onChange: withModifiers(changeHandler, ["stop"])
201
+ }, null, 40, _hoisted_1)
202
+ ], 512), renderSlot(_ctx.$slots, "default", {}, () => [createTextVNode(toDisplayString(props.label), 1)])], 34);
203
+ };
204
+ }
205
+ });
206
+ export { checkbox_default as t };
@@ -0,0 +1,88 @@
1
+ export type CheckboxProps = {
2
+ /**
3
+ * @property {boolean | null} [modelValue]
4
+ * @version 0.0.3
5
+ */
6
+ modelValue?: boolean | null;
7
+ /**
8
+ * @property {boolean | null} [defaultValue]
9
+ * @version 0.0.3
10
+ */
11
+ defaultValue?: boolean | null;
12
+ /**
13
+ * @property {boolean} [indeterminate=false]
14
+ * @version 0.0.3
15
+ */
16
+ indeterminate?: boolean;
17
+ /**
18
+ * @property {boolean} [disabled=false]
19
+ * @version 0.0.3
20
+ */
21
+ disabled?: boolean;
22
+ /**
23
+ * @property {boolean} [readonly=false]
24
+ * @version 0.0.3
25
+ */
26
+ readonly?: boolean;
27
+ /**
28
+ * @property {'normal' | 'retro'} [variant='normal']
29
+ * @version 0.0.3
30
+ */
31
+ variant?: 'normal' | 'retro';
32
+ /**
33
+ * @property {string} [label]
34
+ * @version 0.0.3
35
+ */
36
+ label?: string;
37
+ /**
38
+ * @property {any} [value]
39
+ * @version 0.0.3
40
+ */
41
+ value?: any;
42
+ /**
43
+ * @property {'medium' | 'large' | 'small'} [size='medium']
44
+ * @version 0.0.3
45
+ */
46
+ size?: 'medium' | 'large' | 'small';
47
+ };
48
+ export type CheckboxEvents = {
49
+ /**
50
+ * @event update:modelValue
51
+ * @param {boolean} value
52
+ * @version 0.0.3
53
+ */
54
+ 'update:modelValue': [value: boolean];
55
+ /**
56
+ * @event input
57
+ * @param {boolean} value
58
+ * @param {InputEvent} event
59
+ * @version 0.0.3
60
+ */
61
+ input: [value: boolean, event: InputEvent];
62
+ /**
63
+ * @event change
64
+ * @param {boolean} value
65
+ * @param {Event} event
66
+ * @version 0.0.3
67
+ */
68
+ change: [value: boolean, event: Event];
69
+ /**
70
+ * @event focus
71
+ * @param {FocusEvent} event
72
+ * @version 0.0.3
73
+ */
74
+ focus: [event: FocusEvent];
75
+ /**
76
+ * @event blur
77
+ * @param {FocusEvent} event
78
+ * @version 0.0.3
79
+ */
80
+ blur: [event: FocusEvent];
81
+ };
82
+ export type CheckboxSlots = {
83
+ /**
84
+ * @slot default
85
+ * @version 0.0.3
86
+ */
87
+ default: {};
88
+ };
@@ -0,0 +1,2 @@
1
+ import '../index.css'
2
+ import './index.css'
@@ -0,0 +1,20 @@
1
+ div.px-checkbox-group {
2
+ font-size: 0;
3
+ }
4
+ .px-checkbox-group {
5
+ display: inline-block;
6
+ }
7
+ .px-checkbox-group-inner {
8
+ display: inline-flex;
9
+ flex-wrap: wrap;
10
+ margin: -8px;
11
+ }
12
+ .px-checkbox-group-inner > * {
13
+ margin: 8px;
14
+ }
15
+ .px-checkbox-group__vertical {
16
+ display: inline-block;
17
+ }
18
+ .px-checkbox-group__vertical > .px-checkbox-group-inner {
19
+ flex-direction: column;
20
+ }
@@ -0,0 +1,23 @@
1
+ import type { CheckboxGroupProps } from './type';
2
+ declare var __VLS_1: {};
3
+ type __VLS_Slots = {} & {
4
+ default?: (props: typeof __VLS_1) => any;
5
+ };
6
+ declare const __VLS_component: import("vue").DefineComponent<CheckboxGroupProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
7
+ change: (value: any[]) => any;
8
+ "update:modelValue": (value: any[]) => any;
9
+ }, string, import("vue").PublicProps, Readonly<CheckboxGroupProps> & Readonly<{
10
+ onChange?: ((value: any[]) => any) | undefined;
11
+ "onUpdate:modelValue"?: ((value: any[]) => any) | undefined;
12
+ }>, {
13
+ disabled: boolean;
14
+ readonly: boolean;
15
+ direction: "horizontal" | "vertical";
16
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
18
+ export default _default;
19
+ type __VLS_WithSlots<T, S> = T & {
20
+ new (): {
21
+ $slots: S;
22
+ };
23
+ };