sard-uniapp 1.5.0 → 1.6.0-rc1

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 (142) hide show
  1. package/changelog.md +9 -0
  2. package/components/accordion/accordion.vue +1 -1
  3. package/components/accordion-item/accordion-item.vue +2 -7
  4. package/components/accordion-item/index.scss +17 -11
  5. package/components/action-sheet/action-sheet.d.ts +1 -1
  6. package/components/back-top/back-top.d.ts +38 -0
  7. package/components/back-top/back-top.vue +62 -0
  8. package/components/back-top/common.d.ts +19 -0
  9. package/components/back-top/common.js +5 -0
  10. package/components/back-top/index.d.ts +3 -0
  11. package/components/back-top/index.js +2 -0
  12. package/components/back-top/index.scss +34 -0
  13. package/components/back-top/usePageBackTop.d.ts +4 -0
  14. package/components/back-top/usePageBackTop.js +18 -0
  15. package/components/back-top/useScrollViewBackTop.d.ts +5 -0
  16. package/components/back-top/useScrollViewBackTop.js +15 -0
  17. package/components/back-top/variables.scss +17 -0
  18. package/components/cascader/index.scss +1 -1
  19. package/components/check-icon/check-icon.d.ts +29 -0
  20. package/components/check-icon/check-icon.vue +50 -0
  21. package/components/check-icon/common.d.ts +8 -0
  22. package/components/check-icon/common.js +1 -0
  23. package/components/check-icon/index.scss +30 -0
  24. package/components/check-icon/variables.scss +11 -0
  25. package/components/checkbox/checkbox.d.ts +2 -0
  26. package/components/checkbox/checkbox.vue +17 -9
  27. package/components/checkbox/common.d.ts +3 -4
  28. package/components/checkbox/common.js +0 -4
  29. package/components/checkbox/index.scss +3 -3
  30. package/components/checkbox/variables.scss +1 -0
  31. package/components/checkbox-group/checkbox-group.d.ts +2 -0
  32. package/components/checkbox-group/checkbox-group.vue +18 -12
  33. package/components/checkbox-input/checkbox-input.vue +13 -7
  34. package/components/collapse/collapse.vue +2 -1
  35. package/components/config/index.d.ts +16 -0
  36. package/components/config/index.js +9 -1
  37. package/components/dialog/common.d.ts +2 -0
  38. package/components/dialog/dialog.d.ts +4 -1
  39. package/components/dialog/dialog.vue +7 -3
  40. package/components/dropdown/dropdown.vue +5 -5
  41. package/components/fab/index.scss +1 -1
  42. package/components/fab/variables.scss +1 -1
  43. package/components/floating-bubble/floating-bubble.d.ts +1 -1
  44. package/components/floating-bubble/floating-bubble.vue +2 -19
  45. package/components/floating-bubble/index.scss +1 -1
  46. package/components/floating-bubble/variables.scss +1 -1
  47. package/components/form/common.d.ts +2 -0
  48. package/components/form/form.d.ts +1 -0
  49. package/components/form/form.vue +15 -13
  50. package/components/form-item/form-item.vue +2 -3
  51. package/components/grid/grid.vue +2 -2
  52. package/components/grid-item/index.scss +1 -0
  53. package/components/icon/sari.scss +37 -5
  54. package/components/indexes-nav/indexes-nav.vue +3 -20
  55. package/components/locale/lang/en-US.d.ts +8 -0
  56. package/components/locale/lang/en-US.js +8 -0
  57. package/components/locale/lang/zh-CN.d.ts +8 -0
  58. package/components/locale/lang/zh-CN.js +8 -0
  59. package/components/menu/common.d.ts +1 -0
  60. package/components/menu/variables.scss +2 -2
  61. package/components/menu-item/index.scss +13 -6
  62. package/components/menu-item/menu-item.vue +1 -1
  63. package/components/notify/notify.d.ts +1 -1
  64. package/components/notify-agent/notify-agent.d.ts +1 -1
  65. package/components/overlay/overlay.vue +2 -2
  66. package/components/pagination/index.scss +1 -1
  67. package/components/popout/popout.d.ts +1 -1
  68. package/components/popout/popout.vue +3 -3
  69. package/components/popout-input/index.scss +1 -1
  70. package/components/popover/index.scss +6 -1
  71. package/components/popover/popover.vue +2 -1
  72. package/components/popover/variables.scss +2 -2
  73. package/components/popup/popup.vue +2 -2
  74. package/components/pull-down-refresh/pull-down-refresh.vue +3 -23
  75. package/components/radio/common.d.ts +2 -5
  76. package/components/radio/common.js +0 -4
  77. package/components/radio/index.scss +2 -2
  78. package/components/radio/radio.vue +36 -13
  79. package/components/radio/variables.scss +1 -0
  80. package/components/radio-group/radio-group.d.ts +2 -2
  81. package/components/radio-group/radio-group.vue +22 -13
  82. package/components/radio-input/radio-input.vue +17 -7
  83. package/components/rate/index.scss +8 -2
  84. package/components/rate/rate.vue +5 -20
  85. package/components/result/result.d.ts +1 -1
  86. package/components/row/row.vue +1 -1
  87. package/components/share-sheet/share-sheet.d.ts +1 -1
  88. package/components/slider/index.scss +6 -2
  89. package/components/slider/slider.vue +13 -23
  90. package/components/stepper/index.scss +1 -1
  91. package/components/style/configuration.scss +10 -10
  92. package/components/style/variables-dark.scss +1 -0
  93. package/components/style/variables.scss +1 -0
  94. package/components/switch/index.scss +4 -3
  95. package/components/switch/switch.vue +1 -0
  96. package/components/tab/index.scss +1 -2
  97. package/components/tabbar/tabbar.vue +2 -2
  98. package/components/timeline/common.d.ts +23 -0
  99. package/components/timeline/common.js +1 -0
  100. package/components/timeline/index.d.ts +1 -0
  101. package/components/timeline/index.js +1 -0
  102. package/components/timeline/index.scss +7 -0
  103. package/components/timeline/timeline.d.ts +25 -0
  104. package/components/timeline/timeline.vue +41 -0
  105. package/components/timeline/variables.scss +29 -0
  106. package/components/timeline-item/index.scss +94 -0
  107. package/components/timeline-item/timeline-item.d.ts +25 -0
  108. package/components/timeline-item/timeline-item.vue +71 -0
  109. package/components/tree/common.d.ts +93 -0
  110. package/components/tree/common.js +11 -0
  111. package/components/tree/index.d.ts +1 -0
  112. package/components/tree/index.js +1 -0
  113. package/components/tree/index.scss +13 -0
  114. package/components/tree/tree.d.ts +47 -0
  115. package/components/tree/tree.vue +556 -0
  116. package/components/tree/utils.d.ts +5 -0
  117. package/components/tree/utils.js +29 -0
  118. package/components/tree/variables.scss +42 -0
  119. package/components/tree-branch/tree-branch.d.ts +20 -0
  120. package/components/tree-branch/tree-branch.vue +27 -0
  121. package/components/tree-node/index.scss +110 -0
  122. package/components/tree-node/tree-node.d.ts +20 -0
  123. package/components/tree-node/tree-node.vue +358 -0
  124. package/components/upload/index.scss +2 -3
  125. package/global.d.ts +4 -0
  126. package/index.d.ts +3 -0
  127. package/index.js +3 -0
  128. package/index.scss +4 -0
  129. package/package.json +1 -1
  130. package/use/index.d.ts +3 -0
  131. package/use/index.js +3 -0
  132. package/use/useMouseDown.d.ts +1 -0
  133. package/use/useMouseDown.js +23 -0
  134. package/use/useSetTimeout.d.ts +1 -1
  135. package/use/useSetTimeout.js +2 -2
  136. package/use/useSimulatedClick.d.ts +1 -0
  137. package/use/useSimulatedClick.js +31 -0
  138. package/use/useSimulatedPress.d.ts +12 -0
  139. package/use/useSimulatedPress.js +46 -0
  140. package/utils/dom.js +1 -1
  141. package/utils/utils.d.ts +8 -0
  142. package/utils/utils.js +7 -1
package/changelog.md CHANGED
@@ -1,3 +1,12 @@
1
+ # [1.6.0-rc1](https://github.com/sutras/sard-uniapp/compare/v1.5.0...v1.6.0-rc1) (2024-08-19)
2
+
3
+
4
+ ### Features
5
+
6
+ * 新增Tree, Timeline, BackTop 组件 close [#36](https://github.com/sutras/sard-uniapp/issues/36), close [#41](https://github.com/sutras/sard-uniapp/issues/41), close 43 ([4b7a222](https://github.com/sutras/sard-uniapp/commit/4b7a222a55ca25e85026a9028717c61ea8b2bbea))
7
+
8
+
9
+
1
10
  # [1.5.0](https://github.com/sutras/sard-uniapp/compare/v1.4.1...v1.5.0) (2024-08-08)
2
11
 
3
12
 
@@ -61,7 +61,7 @@ export default _defineComponent({
61
61
  accoridonContextSymbol,
62
62
  reactive({
63
63
  value: innerValue,
64
- multiple: toRef(props, "multiple"),
64
+ multiple: toRef(() => props.multiple),
65
65
  toggle
66
66
  })
67
67
  );
@@ -1,11 +1,6 @@
1
1
  <template>
2
2
  <view :class="accordionItemClass" :style="accordionItemStyle">
3
- <view
4
- :class="
5
- classNames(bem.e('header'), bem.em('header', 'disabled', disabled))
6
- "
7
- @click="onClick"
8
- >
3
+ <view :class="classNames(bem.e('header'))" @click="onClick">
9
4
  <view :class="bem.e('title')">{{ title }}</view>
10
5
  <view v-if="value" :class="bem.e('value')">{{ value }}</view>
11
6
  <view :class="bem.e('arrow')">
@@ -70,7 +65,7 @@ export default _defineComponent({
70
65
  return visible.value ? "up" : "down";
71
66
  });
72
67
  const accordionItemClass = computed(() => {
73
- return classNames(bem.b(), props.rootClass);
68
+ return classNames(bem.b(), bem.m("disabled", props.disabled), props.rootClass);
74
69
  });
75
70
  const accordionItemStyle = computed(() => {
76
71
  return stringifyStyle(props.rootStyle);
@@ -24,17 +24,6 @@
24
24
  padding: var(--sar-accordion-item-header-padding-y)
25
25
  var(--sar-accordion-item-header-padding-x);
26
26
  cursor: pointer;
27
-
28
- @include m-not(disabled) {
29
- &:active {
30
- background-color: var(--sar-accordion-active-bg);
31
- }
32
- }
33
-
34
- @include m(disabled) {
35
- cursor: not-allowed;
36
- @include disabled;
37
- }
38
27
  }
39
28
 
40
29
  @include e(title) {
@@ -62,4 +51,21 @@
62
51
  right: var(--sar-accordion-item-body-padding-x);
63
52
  }
64
53
  }
54
+
55
+ @include m(disabled) {
56
+ @include e(header) {
57
+ cursor: not-allowed;
58
+ }
59
+ @include e(title, arrow) {
60
+ color: var(--sar-disabled-color);
61
+ }
62
+ }
63
+
64
+ @include m-not(disabled) {
65
+ @include e(header) {
66
+ &:active {
67
+ background-color: var(--sar-accordion-active-bg);
68
+ }
69
+ }
70
+ }
65
71
  }
@@ -12,8 +12,8 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
12
12
  duration: number;
13
13
  }>>> & {
14
14
  onSelect?: ((item: ActionSheetItem, index: number) => any) | undefined;
15
- onClose?: (() => any) | undefined;
16
15
  onCancel?: (() => any) | undefined;
16
+ onClose?: (() => any) | undefined;
17
17
  "onUpdate:visible"?: ((visible: boolean) => any) | undefined;
18
18
  }, {
19
19
  overlayClosable: boolean;
@@ -0,0 +1,38 @@
1
+ import { type BackTopProps, type BackTopSlots } from './common';
2
+ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<BackTopProps>, {
3
+ scrollTop: number;
4
+ visibleHeight: number;
5
+ }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
6
+ click: (event: any) => void;
7
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<BackTopProps>, {
8
+ scrollTop: number;
9
+ visibleHeight: number;
10
+ }>>> & {
11
+ onClick?: ((event: any) => any) | undefined;
12
+ }, {
13
+ visibleHeight: number;
14
+ scrollTop: number;
15
+ }, {}>, Readonly<BackTopSlots> & BackTopSlots>;
16
+ export default _default;
17
+ type __VLS_WithDefaults<P, D> = {
18
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
19
+ default: D[K];
20
+ }> : P[K];
21
+ };
22
+ type __VLS_Prettify<T> = {
23
+ [K in keyof T]: T[K];
24
+ } & {};
25
+ type __VLS_WithTemplateSlots<T, S> = T & {
26
+ new (): {
27
+ $slots: S;
28
+ };
29
+ };
30
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
31
+ type __VLS_TypePropsToOption<T> = {
32
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
33
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
34
+ } : {
35
+ type: import('vue').PropType<T[K]>;
36
+ required: true;
37
+ };
38
+ };
@@ -0,0 +1,62 @@
1
+ <template>
2
+ <view :class="backTopClass" :style="backTopStyle" @click="onClick">
3
+ <slot>
4
+ <sar-icon name="backtop" />
5
+ </slot>
6
+ </view>
7
+ </template>
8
+
9
+ <script>
10
+ import { mergeDefaults as _mergeDefaults, defineComponent as _defineComponent } from "vue";
11
+ import { computed } from "vue";
12
+ import { classNames, stringifyStyle, createBem } from "../../utils";
13
+ import {
14
+ backTopPropsDefaults
15
+ } from "./common";
16
+ import SarIcon from "../icon/icon.vue";
17
+ export default _defineComponent({
18
+ ...{
19
+ options: {
20
+ virtualHost: true,
21
+ styleIsolation: "shared"
22
+ }
23
+ },
24
+ __name: "back-top",
25
+ props: _mergeDefaults({
26
+ rootStyle: { type: [Boolean, null, String, Object, Array], required: false, skipCheck: true },
27
+ rootClass: { type: String, required: false },
28
+ scrollTop: { type: Number, required: false },
29
+ visibleHeight: { type: Number, required: false },
30
+ right: { type: String, required: false },
31
+ bottom: { type: String, required: false }
32
+ }, backTopPropsDefaults),
33
+ emits: ["click"],
34
+ setup(__props, { expose: __expose, emit: __emit }) {
35
+ __expose();
36
+ const props = __props;
37
+ const emit = __emit;
38
+ const bem = createBem("back-top");
39
+ const visible = computed(() => {
40
+ return props.scrollTop >= props.visibleHeight;
41
+ });
42
+ const onClick = (event) => {
43
+ emit("click", event);
44
+ };
45
+ const backTopClass = computed(() => {
46
+ return classNames(bem.b(), bem.m("visible", visible.value), props.rootClass);
47
+ });
48
+ const backTopStyle = computed(() => {
49
+ return stringifyStyle(props.rootStyle, {
50
+ right: props.right,
51
+ bottom: props.bottom
52
+ });
53
+ });
54
+ const __returned__ = { props, emit, bem, visible, onClick, backTopClass, backTopStyle, SarIcon };
55
+ return __returned__;
56
+ }
57
+ });
58
+ </script>
59
+
60
+ <style lang="scss">
61
+ @import './index.scss';
62
+ </style>
@@ -0,0 +1,19 @@
1
+ import { type StyleValue } from 'vue';
2
+ export interface BackTopProps {
3
+ rootStyle?: StyleValue;
4
+ rootClass?: string;
5
+ scrollTop?: number;
6
+ visibleHeight?: number;
7
+ right?: string;
8
+ bottom?: string;
9
+ }
10
+ export declare const backTopPropsDefaults: {
11
+ scrollTop: number;
12
+ visibleHeight: number;
13
+ };
14
+ export interface BackTopSlots {
15
+ default?(props: Record<string, never>): any;
16
+ }
17
+ export interface BackTopEmits {
18
+ (e: 'click', event: any): void;
19
+ }
@@ -0,0 +1,5 @@
1
+ import { defaultConfig } from '../config';
2
+ export const backTopPropsDefaults = {
3
+ ...defaultConfig.backTop,
4
+ scrollTop: 0,
5
+ };
@@ -0,0 +1,3 @@
1
+ export type { BackTopProps, BackTopSlots, BackTopEmits } from './common';
2
+ export { usePageBackTop } from './usePageBackTop';
3
+ export { useScrollViewBackTop } from './useScrollViewBackTop';
@@ -0,0 +1,2 @@
1
+ export { usePageBackTop } from './usePageBackTop';
2
+ export { useScrollViewBackTop } from './useScrollViewBackTop';
@@ -0,0 +1,34 @@
1
+ @use '../style/base' as *;
2
+
3
+ @include bem(back-top) {
4
+ @include b() {
5
+ @include universal;
6
+ position: fixed;
7
+ right: var(--sar-back-top-right);
8
+ bottom: var(--sar-back-top-bottom);
9
+ z-index: var(--sar-back-top-z-index);
10
+ justify-content: center;
11
+ align-items: center;
12
+ min-width: var(--sar-back-top-min-width);
13
+ height: var(--sar-back-top-height);
14
+ padding: 0 var(--sar-back-top-padding-x);
15
+ border-radius: var(--sar-back-top-border-radius);
16
+ font-size: var(--sar-back-top-font-size);
17
+ color: var(--sar-back-top-color);
18
+ background-color: var(--sar-back-top-bg);
19
+ box-shadow: var(--sar-back-top-box-shadow);
20
+ cursor: pointer;
21
+ pointer-events: none;
22
+ opacity: 0;
23
+ transition: opacity var(--sar-back-top-duration);
24
+
25
+ &:active {
26
+ opacity: var(--sar-back-top-active-opacity);
27
+ }
28
+
29
+ @include m(visible) {
30
+ pointer-events: auto;
31
+ opacity: 1;
32
+ }
33
+ }
34
+ }
@@ -0,0 +1,4 @@
1
+ export declare function usePageBackTop(duration?: number): {
2
+ scrollTop: import("vue").Ref<number>;
3
+ onClick: () => void;
4
+ };
@@ -0,0 +1,18 @@
1
+ import { onPageScroll } from '@dcloudio/uni-app';
2
+ import { ref } from 'vue';
3
+ export function usePageBackTop(duration = 300) {
4
+ const scrollTop = ref(0);
5
+ onPageScroll((event) => {
6
+ scrollTop.value = event.scrollTop;
7
+ });
8
+ const onClick = () => {
9
+ uni.pageScrollTo({
10
+ scrollTop: 0,
11
+ duration,
12
+ });
13
+ };
14
+ return {
15
+ scrollTop,
16
+ onClick,
17
+ };
18
+ }
@@ -0,0 +1,5 @@
1
+ export declare function useScrollViewBackTop(): {
2
+ scrollTop: import("vue").Ref<number>;
3
+ onScroll: (event: any) => void;
4
+ onClick: () => void;
5
+ };
@@ -0,0 +1,15 @@
1
+ import { ref } from 'vue';
2
+ export function useScrollViewBackTop() {
3
+ const scrollTop = ref(0);
4
+ const onScroll = (event) => {
5
+ scrollTop.value = event.detail.scrollTop;
6
+ };
7
+ const onClick = () => {
8
+ scrollTop.value = 0;
9
+ };
10
+ return {
11
+ scrollTop,
12
+ onScroll,
13
+ onClick,
14
+ };
15
+ }
@@ -0,0 +1,17 @@
1
+ // #variables
2
+ page {
3
+ --sar-back-top-right: 48rpx;
4
+ --sar-back-top-bottom: 96rpx;
5
+ --sar-back-top-z-index: 1000;
6
+ --sar-back-top-height: 96rpx;
7
+ --sar-back-top-min-width: 96rpx;
8
+ --sar-back-top-padding-x: 24rpx;
9
+ --sar-back-top-border-radius: var(--sar-rounded-full);
10
+ --sar-back-top-font-size: 48rpx;
11
+ --sar-back-top-color: var(--sar-white);
12
+ --sar-back-top-bg: var(--sar-primary);
13
+ --sar-back-top-box-shadow: var(--sar-shadow-lg);
14
+ --sar-back-top-active-opacity: var(--sar-active-opacity);
15
+ --sar-back-top-duration: var(--sar-duration);
16
+ }
17
+ // #endvariables
@@ -51,7 +51,7 @@
51
51
  }
52
52
 
53
53
  @include m(disabled) {
54
- @include disabled;
54
+ @include disabled-text;
55
55
  }
56
56
 
57
57
  @include m-not(disabled) {
@@ -0,0 +1,29 @@
1
+ import { type CheckIconProps } from './common';
2
+ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<CheckIconProps>, {
3
+ shape: string;
4
+ type: string;
5
+ }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<CheckIconProps>, {
6
+ shape: string;
7
+ type: string;
8
+ }>>>, {
9
+ type: "empty" | "dot" | "check" | "dash";
10
+ shape: "circle" | "square";
11
+ }, {}>;
12
+ export default _default;
13
+ type __VLS_WithDefaults<P, D> = {
14
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
15
+ default: D[K];
16
+ }> : P[K];
17
+ };
18
+ type __VLS_Prettify<T> = {
19
+ [K in keyof T]: T[K];
20
+ } & {};
21
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
22
+ type __VLS_TypePropsToOption<T> = {
23
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
24
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
25
+ } : {
26
+ type: import('vue').PropType<T[K]>;
27
+ required: true;
28
+ };
29
+ };
@@ -0,0 +1,50 @@
1
+ <template>
2
+ <view :class="checkIconClass">
3
+ <sar-icon v-if="iconName" :name="iconName" />
4
+ </view>
5
+ </template>
6
+
7
+ <script>
8
+ import { defineComponent as _defineComponent } from "vue";
9
+ import { computed } from "vue";
10
+ import { classNames, createBem } from "../../utils";
11
+ import SarIcon from "../icon/icon.vue";
12
+ export default _defineComponent({
13
+ ...{
14
+ options: {
15
+ virtualHost: true,
16
+ styleIsolation: "shared"
17
+ }
18
+ },
19
+ __name: "check-icon",
20
+ props: {
21
+ rootStyle: { type: [Boolean, null, String, Object, Array], required: false, skipCheck: true },
22
+ rootClass: { type: String, required: false },
23
+ disabled: { type: Boolean, required: false },
24
+ shape: { type: String, required: false, default: "square" },
25
+ type: { type: String, required: false, default: "check" }
26
+ },
27
+ setup(__props, { expose: __expose }) {
28
+ __expose();
29
+ const props = __props;
30
+ const bem = createBem("check-icon");
31
+ const iconName = computed(() => {
32
+ return props.disabled && props.type === "check" ? "check" : props.disabled && props.type === "dash" ? "dash" : props.type === "check" ? `check-${props.shape}-fill` : props.type === "dash" ? `dash-${props.shape}-fill` : props.type === "dot" ? `record-circle` : void 0;
33
+ });
34
+ const checkIconClass = computed(() => {
35
+ return classNames(
36
+ bem.b(),
37
+ bem.m(props.shape),
38
+ bem.m(props.type),
39
+ bem.m("disabled", props.disabled)
40
+ );
41
+ });
42
+ const __returned__ = { props, bem, iconName, checkIconClass, SarIcon };
43
+ return __returned__;
44
+ }
45
+ });
46
+ </script>
47
+
48
+ <style lang="scss">
49
+ @import './index.scss';
50
+ </style>
@@ -0,0 +1,8 @@
1
+ import { StyleValue } from 'vue';
2
+ export interface CheckIconProps {
3
+ rootStyle?: StyleValue;
4
+ rootClass?: string;
5
+ disabled?: boolean;
6
+ shape?: 'circle' | 'square';
7
+ type?: 'empty' | 'check' | 'dot' | 'dash';
8
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,30 @@
1
+ @use '../style/base' as *;
2
+
3
+ @include bem(check-icon) {
4
+ @include b() {
5
+ @include universal;
6
+ justify-content: center;
7
+ align-items: center;
8
+ width: var(--sar-check-icon-size);
9
+ height: var(--sar-check-icon-size);
10
+ border: 1px solid var(--sar-check-icon-border-color);
11
+
12
+ @include m(square) {
13
+ border-radius: var(--sar-check-icon-square-border-radius);
14
+ }
15
+
16
+ @include m(circle) {
17
+ border-radius: 50%;
18
+ }
19
+
20
+ @include m(check, dot, dash) {
21
+ border-color: transparent;
22
+ }
23
+
24
+ @include m(disabled) {
25
+ color: var(--sar-check-icon-disabled-color);
26
+ background-color: var(--sar-check-icon-disabled-bg);
27
+ border-color: var(--sar-check-icon-disabled-border-color);
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,11 @@
1
+ // #variables
2
+ page {
3
+ --sar-check-icon-size: 1em;
4
+ --sar-check-icon-square-border-radius: 0.15em;
5
+ --sar-check-icon-border-color: var(--sar-quaternary-color);
6
+
7
+ --sar-check-icon-disabled-color: var(--sar-disabled-color);
8
+ --sar-check-icon-disabled-bg: var(--sar-disabled-shallow-bg);
9
+ --sar-check-icon-disabled-border-color: var(--sar-disabled-border-color);
10
+ }
11
+ // #endvariables
@@ -4,9 +4,11 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
4
4
  }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
5
5
  click: (event: any) => void;
6
6
  "update:checked": (checked: boolean) => void;
7
+ change: (checked: boolean) => void;
7
8
  }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<CheckboxProps>, {
8
9
  validateEvent: boolean;
9
10
  }>>> & {
11
+ onChange?: ((checked: boolean) => any) | undefined;
10
12
  onClick?: ((event: any) => any) | undefined;
11
13
  "onUpdate:checked"?: ((checked: boolean) => any) | undefined;
12
14
  }, {
@@ -2,7 +2,11 @@
2
2
  <view :class="checkboxClass" :style="checkboxStyle" @click="onClick">
3
3
  <view :class="iconClass" :style="iconStyle">
4
4
  <slot name="icon" :checked="innerChecked">
5
- <sar-icon v-if="!$slots.icon" :name="iconName" />
5
+ <sar-check-icon
6
+ :shape="checkIconShape"
7
+ :type="checkIconType"
8
+ :disabled="isDisabled"
9
+ />
6
10
  </slot>
7
11
  </view>
8
12
  <view v-if="$slots.default || label" :class="labelClass">
@@ -17,10 +21,9 @@ import { computed, provide, inject, ref, watch } from "vue";
17
21
  import { classNames, createBem, stringifyStyle } from "../../utils";
18
22
  import {
19
23
  checkboxContextSymbol,
20
- mapTypeIcon,
21
24
  checkboxPropsDefaults
22
25
  } from "./common";
23
- import SarIcon from "../icon/icon.vue";
26
+ import SarCheckIcon from "../check-icon/check-icon.vue";
24
27
  import { useFormContext, useFormItemContext } from "../form/common";
25
28
  export default _defineComponent({
26
29
  ...{
@@ -34,6 +37,7 @@ export default _defineComponent({
34
37
  rootStyle: { type: [Boolean, null, String, Object, Array], required: false, skipCheck: true },
35
38
  rootClass: { type: String, required: false },
36
39
  checked: { type: Boolean, required: false },
40
+ indeterminate: { type: Boolean, required: false },
37
41
  value: { type: null, required: false },
38
42
  label: { type: String, required: false },
39
43
  disabled: { type: Boolean, required: false },
@@ -43,7 +47,7 @@ export default _defineComponent({
43
47
  checkedColor: { type: String, required: false },
44
48
  validateEvent: { type: Boolean, required: false }
45
49
  }, checkboxPropsDefaults),
46
- emits: ["click", "update:checked"],
50
+ emits: ["click", "update:checked", "change"],
47
51
  setup(__props, { expose: __expose, emit: __emit }) {
48
52
  __expose();
49
53
  const props = __props;
@@ -88,6 +92,7 @@ export default _defineComponent({
88
92
  } else {
89
93
  innerChecked.value = !innerChecked.value;
90
94
  emit("update:checked", innerChecked.value);
95
+ emit("change", innerChecked.value);
91
96
  }
92
97
  }
93
98
  emit("click", event);
@@ -105,9 +110,11 @@ export default _defineComponent({
105
110
  const checkboxStyle = computed(() => {
106
111
  return stringifyStyle(props.rootStyle);
107
112
  });
108
- const iconName = computed(() => {
109
- const type = props.type ?? groupContext?.type ?? "square";
110
- return mapTypeIcon[type][innerChecked.value ? 1 : 0];
113
+ const checkIconShape = computed(() => {
114
+ return props.type ?? groupContext?.type ?? "square";
115
+ });
116
+ const checkIconType = computed(() => {
117
+ return innerChecked.value ? "check" : props.indeterminate ? "dash" : "empty";
111
118
  });
112
119
  const iconColor = computed(() => {
113
120
  return innerChecked.value && !isDisabled.value ? props.checkedColor ?? groupContext?.checkedColor : void 0;
@@ -115,7 +122,8 @@ export default _defineComponent({
115
122
  const iconClass = computed(() => {
116
123
  return classNames(
117
124
  bem.e("icon"),
118
- bem.em("icon", "checked", innerChecked.value)
125
+ bem.em("icon", "checked", innerChecked.value),
126
+ bem.em("icon", "indeterminate", props.indeterminate)
119
127
  );
120
128
  });
121
129
  const iconStyle = computed(() => {
@@ -127,7 +135,7 @@ export default _defineComponent({
127
135
  const labelClass = computed(() => {
128
136
  return classNames(bem.e("label"));
129
137
  });
130
- const __returned__ = { props, emit, bem, groupContext, formContext, formItemContext, isDisabled, isReadonly, innerChecked, onClick, checkboxClass, checkboxStyle, iconName, iconColor, iconClass, iconStyle, labelClass, SarIcon };
138
+ const __returned__ = { props, emit, bem, groupContext, formContext, formItemContext, isDisabled, isReadonly, innerChecked, onClick, checkboxClass, checkboxStyle, checkIconShape, checkIconType, iconColor, iconClass, iconStyle, labelClass, SarCheckIcon };
131
139
  return __returned__;
132
140
  }
133
141
  });
@@ -4,6 +4,7 @@ export interface CheckboxProps {
4
4
  rootStyle?: StyleValue;
5
5
  rootClass?: string;
6
6
  checked?: boolean;
7
+ indeterminate?: boolean;
7
8
  value?: any;
8
9
  label?: string;
9
10
  disabled?: boolean;
@@ -25,6 +26,7 @@ export interface CheckboxSlots {
25
26
  export interface CheckboxEmits {
26
27
  (e: 'click', event: any): void;
27
28
  (e: 'update:checked', checked: boolean): void;
29
+ (e: 'change', checked: boolean): void;
28
30
  }
29
31
  export declare const defaultOptionKeys: {
30
32
  label: string;
@@ -65,6 +67,7 @@ export interface CheckboxGroupSlots {
65
67
  export interface CheckboxGroupEmits {
66
68
  (e: 'click', event: any): void;
67
69
  (e: 'update:model-value', value: any[]): void;
70
+ (e: 'change', value: any[]): void;
68
71
  }
69
72
  export interface CheckboxContext {
70
73
  disabled: CheckboxGroupProps['disabled'];
@@ -76,7 +79,3 @@ export interface CheckboxContext {
76
79
  toggle: (value: any) => void;
77
80
  }
78
81
  export declare const checkboxContextSymbol: unique symbol;
79
- export declare const mapTypeIcon: {
80
- square: string[];
81
- circle: string[];
82
- };
@@ -6,7 +6,3 @@ export const defaultOptionKeys = {
6
6
  };
7
7
  export const checkboxGroupPropsDefaults = defaultConfig.checkboxGroup;
8
8
  export const checkboxContextSymbol = Symbol('checkbox-context');
9
- export const mapTypeIcon = {
10
- square: ['square', 'check-square-fill'],
11
- circle: ['circle', 'check-circle-fill'],
12
- };
@@ -15,7 +15,7 @@
15
15
  color: var(--sar-checkbox-icon-color);
16
16
  transition: color var(--sar-checkbox-icon-transition-duration);
17
17
 
18
- @include m(checked) {
18
+ @include m(checked, indeterminate) {
19
19
  color: var(--sar-checkbox-icon-checked-color);
20
20
  }
21
21
  }
@@ -27,14 +27,14 @@
27
27
  }
28
28
 
29
29
  @include m(readonly) {
30
- cursor: default;
30
+ cursor: unset;
31
31
  }
32
32
 
33
33
  @include m(disabled) {
34
34
  cursor: var(--sar-disabled-cursor);
35
35
 
36
36
  @include e(icon) {
37
- @include disabled;
37
+ color: var(--sar-checkbox-icon-disabled-color);
38
38
  }
39
39
 
40
40
  @include e(label) {
@@ -6,6 +6,7 @@ page {
6
6
  --sar-checkbox-icon-font-size: 40rpx;
7
7
  --sar-checkbox-icon-color: var(--sar-quaternary-color);
8
8
  --sar-checkbox-icon-checked-color: var(--sar-primary);
9
+ --sar-checkbox-icon-disabled-color: var(--sar-disabled-color);
9
10
  --sar-checkbox-icon-transition-duration: var(--sar-duration);
10
11
 
11
12
  --sar-checkbox-label-margin-left: 16rpx;