@tendaui/components 1.0.0

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 (245) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +176 -0
  3. package/alert/Alert.tsx +147 -0
  4. package/alert/defaultProps.ts +3 -0
  5. package/alert/index.ts +9 -0
  6. package/alert/style/css.js +1 -0
  7. package/alert/style/index.js +1 -0
  8. package/alert/type.ts +44 -0
  9. package/badge/Badge.tsx +85 -0
  10. package/badge/defaultProps.ts +10 -0
  11. package/badge/index.ts +9 -0
  12. package/badge/style/css.js +1 -0
  13. package/badge/style/index.js +1 -0
  14. package/badge/type.ts +51 -0
  15. package/button/Button.tsx +95 -0
  16. package/button/defaultProps.ts +13 -0
  17. package/button/index.ts +7 -0
  18. package/button/style/css.js +1 -0
  19. package/button/style/index.js +1 -0
  20. package/button/type.ts +82 -0
  21. package/checkbox/Checkbox.tsx +19 -0
  22. package/checkbox/CheckboxGroup.tsx +207 -0
  23. package/checkbox/defaultProps.ts +14 -0
  24. package/checkbox/index.ts +10 -0
  25. package/checkbox/style/css.js +1 -0
  26. package/checkbox/style/index.js +1 -0
  27. package/checkbox/type.ts +117 -0
  28. package/common/Check.tsx +131 -0
  29. package/common/FakeArrow.tsx +36 -0
  30. package/common/PluginContainer.tsx +21 -0
  31. package/common/Portal.tsx +67 -0
  32. package/common.ts +76 -0
  33. package/config-provider/ConfigContext.tsx +21 -0
  34. package/config-provider/ConfigProvider.tsx +53 -0
  35. package/config-provider/index.ts +9 -0
  36. package/config-provider/type.ts +1062 -0
  37. package/dialog/Dialog.tsx +254 -0
  38. package/dialog/DialogCard.tsx +152 -0
  39. package/dialog/defaultProps.ts +25 -0
  40. package/dialog/hooks/useDialogDrag.ts +50 -0
  41. package/dialog/hooks/useDialogEsc.ts +31 -0
  42. package/dialog/hooks/useDialogPosition.ts +36 -0
  43. package/dialog/hooks/useLockStyle.ts +54 -0
  44. package/dialog/index.ts +13 -0
  45. package/dialog/plugin.tsx +78 -0
  46. package/dialog/style/css.js +1 -0
  47. package/dialog/style/index.js +1 -0
  48. package/dialog/type.ts +241 -0
  49. package/dialog/utils.ts +4 -0
  50. package/form/Form.tsx +136 -0
  51. package/form/FormContext.tsx +64 -0
  52. package/form/FormItem.tsx +554 -0
  53. package/form/FormList.tsx +303 -0
  54. package/form/const.ts +6 -0
  55. package/form/defaultProps.ts +26 -0
  56. package/form/formModel.ts +117 -0
  57. package/form/hooks/interface.ts +20 -0
  58. package/form/hooks/useForm.ts +122 -0
  59. package/form/hooks/useFormItemInitialData.ts +95 -0
  60. package/form/hooks/useFormItemStyle.tsx +122 -0
  61. package/form/hooks/useInstance.tsx +275 -0
  62. package/form/hooks/useWatch.ts +42 -0
  63. package/form/index.ts +11 -0
  64. package/form/style/css.js +1 -0
  65. package/form/style/index.js +1 -0
  66. package/form/type.ts +519 -0
  67. package/form/utils/index.ts +69 -0
  68. package/hooks/useAttach.ts +24 -0
  69. package/hooks/useCommonClassName.ts +45 -0
  70. package/hooks/useConfig.ts +3 -0
  71. package/hooks/useControlled.ts +39 -0
  72. package/hooks/useDefaultProps.ts +16 -0
  73. package/hooks/useDomCallback.ts +13 -0
  74. package/hooks/useDomRefCallback.ts +12 -0
  75. package/hooks/useDragSorter.tsx +151 -0
  76. package/hooks/useEventCallback.ts +47 -0
  77. package/hooks/useGlobalConfig.ts +14 -0
  78. package/hooks/useGlobalIcon.ts +14 -0
  79. package/hooks/useLastest.ts +13 -0
  80. package/hooks/useLayoutEffect.ts +7 -0
  81. package/hooks/useMouseEvent.ts +142 -0
  82. package/hooks/useMutationObserver.ts +56 -0
  83. package/hooks/usePopper.ts +189 -0
  84. package/hooks/useRipple.ts +0 -0
  85. package/hooks/useSetState.ts +25 -0
  86. package/hooks/useVirtualScroll.ts +246 -0
  87. package/hooks/useWindowSize.ts +31 -0
  88. package/index.ts +70 -0
  89. package/input/Input.tsx +383 -0
  90. package/input/InputGroup.tsx +29 -0
  91. package/input/defaultProps.ts +22 -0
  92. package/input/index.ts +11 -0
  93. package/input/style/css.js +1 -0
  94. package/input/style/index.js +1 -0
  95. package/input/type.ts +219 -0
  96. package/loading/Gradient.tsx +36 -0
  97. package/loading/Loading.tsx +169 -0
  98. package/loading/circleAdapter.ts +44 -0
  99. package/loading/defaultProps.ts +12 -0
  100. package/loading/index.ts +13 -0
  101. package/loading/style/css.js +1 -0
  102. package/loading/style/index.js +1 -0
  103. package/loading/type.ts +71 -0
  104. package/loading/utils/setStyle.ts +13 -0
  105. package/myform/index.ts +0 -0
  106. package/notification/Notify.ts +24 -0
  107. package/notification/NotifyContainer.tsx +90 -0
  108. package/notification/NotifyContext.tsx +173 -0
  109. package/notification/NotifyItem.tsx +121 -0
  110. package/notification/index.ts +3 -0
  111. package/notification/style/css.js +1 -0
  112. package/notification/style/index.js +1 -0
  113. package/notification/type.ts +23 -0
  114. package/package.json +52 -0
  115. package/popup/Popup.tsx +264 -0
  116. package/popup/defaultProps.ts +13 -0
  117. package/popup/hooks/useTrigger.ts +276 -0
  118. package/popup/index.ts +6 -0
  119. package/popup/style/css.js +1 -0
  120. package/popup/style/index.js +1 -0
  121. package/popup/type.ts +130 -0
  122. package/portal/Portal.tsx +63 -0
  123. package/portal/index.ts +1 -0
  124. package/select/Option.tsx +162 -0
  125. package/select/OptionGroup.tsx +30 -0
  126. package/select/PopupContent.tsx +271 -0
  127. package/select/Select.tsx +586 -0
  128. package/select/defaultProps.ts +27 -0
  129. package/select/hooks/useOptions.ts +120 -0
  130. package/select/hooks/usePanelVirtualScroll.ts +111 -0
  131. package/select/index.ts +9 -0
  132. package/select/style/css.js +1 -0
  133. package/select/style/index.js +2 -0
  134. package/select/type.ts +382 -0
  135. package/select/utils/helper.ts +256 -0
  136. package/select-input/SelectInput.tsx +98 -0
  137. package/select-input/defaultProps.ts +15 -0
  138. package/select-input/hook/useMultiple.tsx +100 -0
  139. package/select-input/hook/useOverlayInnerStyle.ts +84 -0
  140. package/select-input/hook/useSingle.tsx +112 -0
  141. package/select-input/index.ts +6 -0
  142. package/select-input/interface.ts +18 -0
  143. package/select-input/style/css.js +1 -0
  144. package/select-input/style/index.js +1 -0
  145. package/select-input/type.ts +280 -0
  146. package/space/defaultProps.ts +0 -0
  147. package/space/index.ts +0 -0
  148. package/space/type.ts +0 -0
  149. package/style/index.js +2 -0
  150. package/styles/_global.scss +39 -0
  151. package/styles/_vars.scss +386 -0
  152. package/styles/components/alert/_index.scss +175 -0
  153. package/styles/components/alert/_vars.scss +39 -0
  154. package/styles/components/badge/_index.scss +70 -0
  155. package/styles/components/badge/_vars.scss +25 -0
  156. package/styles/components/button/_index.scss +511 -0
  157. package/styles/components/button/_mixins.scss +39 -0
  158. package/styles/components/button/_vars.scss +122 -0
  159. package/styles/components/checkbox/_index.scss +158 -0
  160. package/styles/components/checkbox/_mixin.scss +0 -0
  161. package/styles/components/checkbox/_var.scss +60 -0
  162. package/styles/components/dialog/_animate.scss +135 -0
  163. package/styles/components/dialog/_index.scss +311 -0
  164. package/styles/components/dialog/_mixins.scss +0 -0
  165. package/styles/components/dialog/_vars.scss +59 -0
  166. package/styles/components/form/_index.scss +174 -0
  167. package/styles/components/form/_mixins.scss +76 -0
  168. package/styles/components/form/_vars.scss +100 -0
  169. package/styles/components/input/_index.scss +349 -0
  170. package/styles/components/input/_map.scss +0 -0
  171. package/styles/components/input/_mixins.scss +116 -0
  172. package/styles/components/input/_vars.scss +134 -0
  173. package/styles/components/loading/_index.scss +112 -0
  174. package/styles/components/loading/_vars.scss +39 -0
  175. package/styles/components/notification/_index.scss +160 -0
  176. package/styles/components/notification/_mixins.scss +12 -0
  177. package/styles/components/notification/_vars.scss +59 -0
  178. package/styles/components/popup/_index.scss +82 -0
  179. package/styles/components/popup/_mixin.scss +149 -0
  180. package/styles/components/popup/_var.scss +31 -0
  181. package/styles/components/select/_index.scss +290 -0
  182. package/styles/components/select/_var.scss +65 -0
  183. package/styles/components/select-input/_index.scss +5 -0
  184. package/styles/components/select-input/_var.scss +3 -0
  185. package/styles/components/switch/_index.scss +279 -0
  186. package/styles/components/switch/_mixins.scss +0 -0
  187. package/styles/components/switch/_vars.scss +61 -0
  188. package/styles/components/tag/_index.scss +316 -0
  189. package/styles/components/tag/_var.scss +85 -0
  190. package/styles/components/tag-input/_index.scss +163 -0
  191. package/styles/components/tag-input/_vars.scss +16 -0
  192. package/styles/globals.css +250 -0
  193. package/styles/mixins/_focus.scss +7 -0
  194. package/styles/mixins/_layout.scss +32 -0
  195. package/styles/mixins/_reset.scss +10 -0
  196. package/styles/mixins/_scrollbar.scss +31 -0
  197. package/styles/mixins/_text.scss +48 -0
  198. package/styles/rillple.css +16 -0
  199. package/styles/scrollbar.css +42 -0
  200. package/styles/themes/_dark.scss +191 -0
  201. package/styles/themes/_font.scss +79 -0
  202. package/styles/themes/_index.scss +5 -0
  203. package/styles/themes/_light.scss +190 -0
  204. package/styles/themes/_radius.scss +9 -0
  205. package/styles/themes/_size.scss +68 -0
  206. package/styles/themes.css +66 -0
  207. package/styles/utilities/_animation.scss +57 -0
  208. package/styles/utilities/_tips.scss +9 -0
  209. package/switch/Switch.tsx +120 -0
  210. package/switch/defaultProps.ts +3 -0
  211. package/switch/index.ts +7 -0
  212. package/switch/style/css.js +1 -0
  213. package/switch/style/index.js +1 -0
  214. package/switch/type.ts +46 -0
  215. package/tag/Tag.tsx +149 -0
  216. package/tag/defaultProps.ts +19 -0
  217. package/tag/index.ts +8 -0
  218. package/tag/style/css.js +1 -0
  219. package/tag/style/index.js +1 -0
  220. package/tag/type.ts +170 -0
  221. package/tag-input/TagInput.tsx +215 -0
  222. package/tag-input/defaultProps.ts +15 -0
  223. package/tag-input/hooks/useHover.ts +28 -0
  224. package/tag-input/hooks/useTagList.tsx +131 -0
  225. package/tag-input/hooks/useTagScroll.ts +105 -0
  226. package/tag-input/index.ts +9 -0
  227. package/tag-input/style/css.js +1 -0
  228. package/tag-input/style/index.js +1 -0
  229. package/tag-input/type.ts +224 -0
  230. package/tag-input/useTagList.tsx +131 -0
  231. package/utils/composeRefs.ts +14 -0
  232. package/utils/dom.ts +29 -0
  233. package/utils/forwardRefWithStatics.ts +12 -0
  234. package/utils/getScrollbarWidth.ts +11 -0
  235. package/utils/helper.ts +161 -0
  236. package/utils/isFragment.ts +22 -0
  237. package/utils/listener.ts +37 -0
  238. package/utils/noop.ts +3 -0
  239. package/utils/parentTNode.ts +38 -0
  240. package/utils/parseTNode.ts +38 -0
  241. package/utils/react-render.ts +108 -0
  242. package/utils/ref.ts +6 -0
  243. package/utils/refs.ts +81 -0
  244. package/utils/style.ts +60 -0
  245. package/utils/transition.ts +28 -0
@@ -0,0 +1,290 @@
1
+ @import '../../_vars.scss';
2
+
3
+ @import './_var.scss';
4
+
5
+ @import '../../mixins/_text.scss';
6
+
7
+ @import '../../mixins/_reset.scss';
8
+
9
+ @import '../../mixins/_scrollbar.scss';
10
+
11
+ // select
12
+ .#{$prefix}-select__wrap {
13
+ width: 100%;
14
+ }
15
+
16
+ // dropdown
17
+ .#{$prefix}-select__dropdown {
18
+ .#{$prefix}-popup__content {
19
+ @include scrollbar(8px, 2px);
20
+
21
+ margin: $select-dropdown-margin;
22
+ padding: 0; // 展开动画 如果有padding会直接生长 需要移动到内部
23
+ max-height: $select-dropdown-max-height;
24
+ overflow-y: auto;
25
+ overscroll-behavior: contain;
26
+ box-shadow: $select-dropdown-shadow;
27
+ }
28
+
29
+ &-inner {
30
+ min-height: $select-height-default;
31
+
32
+ // 嵌套无需 padding
33
+ .#{$prefix}-select__list .#{$prefix}-select__list {
34
+ padding: 0;
35
+ }
36
+
37
+ .#{$prefix}-select__list,
38
+ .#{$prefix}-tree {
39
+ padding: $select-dropdown-padding;
40
+ }
41
+
42
+ &--size-s {
43
+ min-height: $select-height-s;
44
+
45
+ .#{$prefix}-select__list,
46
+ .#{$prefix}-tree {
47
+ padding: $select-dropdown-padding-s;
48
+ }
49
+ }
50
+
51
+ &--size-l {
52
+ min-height: $select-height-l;
53
+
54
+ .#{$prefix}-select__list,
55
+ .#{$prefix}-tree {
56
+ padding: $select-dropdown-padding-l;
57
+ }
58
+ }
59
+ }
60
+ }
61
+
62
+ // 抹平 ul li 自带样式
63
+ .#{$prefix}-select__list {
64
+ margin: 0;
65
+ padding: 0;
66
+ list-style: none;
67
+ }
68
+
69
+ .#{$prefix}-select__dropdown.#{$prefix}-popup {
70
+ padding: $select-dropdown-popup-padding;
71
+ }
72
+ // empty
73
+ .#{$prefix}-select__empty.#{$prefix}-size-s {
74
+ line-height: $select-height-s;
75
+ }
76
+
77
+ .#{$prefix}-select__empty {
78
+ text-align: center;
79
+ color: $select-color-empty;
80
+ line-height: $select-height-default;
81
+ padding: $select-empty-padding;
82
+ }
83
+
84
+ .#{$prefix}-select__empty.#{$prefix}-size-l {
85
+ line-height: $select-height-l;
86
+ }
87
+
88
+ // loading tips
89
+ .#{$prefix}-select__loading-tips.#{$prefix}-size-s {
90
+ min-height: $select-height-s;
91
+ line-height: $select-height-s;
92
+ }
93
+
94
+ .#{$prefix}-select__loading-tips {
95
+ position: fixed;
96
+ top: $select-loading-tips-padding;
97
+ left: 0;
98
+ bottom: $select-loading-tips-padding;
99
+ right: 0;
100
+ display: flex;
101
+ align-items: center;
102
+ justify-content: center;
103
+ background-color: $select-loading-tips-bg-color;
104
+ border-radius: $select-border-radius;
105
+ min-height: $select-height-default;
106
+ line-height: $select-height-default;
107
+ color: $select-color-empty;
108
+ z-index: 1000;
109
+ }
110
+
111
+ .#{$prefix}-select__loading-tips.#{$prefix}-size-l {
112
+ min-height: $select-height-l;
113
+ line-height: $select-height-l;
114
+ }
115
+
116
+ // option group
117
+ .#{$prefix}-select-option-group + .#{$prefix}-select-option-group {
118
+ padding-top: $select-optiongroup-border-padding;
119
+ margin-top: $select-optiongroup-border-margin;
120
+ }
121
+
122
+ .#{$prefix}-select-option-group__divider
123
+ + .#{$prefix}-select-option-group__divider {
124
+ position: relative;
125
+
126
+ &::before {
127
+ content: '';
128
+ width: 100%;
129
+ height: 1px;
130
+ padding: $select-option-padding-default;
131
+ position: absolute;
132
+ top: 0;
133
+ left: 0;
134
+ box-sizing: border-box;
135
+ background-color: $select-optiongroup-border-color;
136
+ background-clip: content-box;
137
+ }
138
+ }
139
+
140
+ .#{$prefix}-select-option-group__header {
141
+ // & 表示 .#{$prefix}-select-option-group__header
142
+ &,
143
+ ul#{&} {
144
+ color: $select-option-group-header-color;
145
+ display: block;
146
+ height: $select-option-height-default;
147
+ line-height: $select-option-height-default;
148
+ padding: $select-option-padding-default;
149
+ box-sizing: border-box;
150
+ @include text-ellipsis();
151
+ }
152
+ }
153
+
154
+ .#{$prefix}-select-option-group__header.#{$prefix}-size-l {
155
+ height: $select-option-height-l;
156
+ line-height: $select-option-height-l;
157
+ padding: $select-option-padding-l;
158
+ }
159
+
160
+ .#{$prefix}-select-option-group__header.#{$prefix}-size-s {
161
+ height: $select-option-height-s;
162
+ line-height: $select-option-height-s;
163
+ padding: $select-option-padding-s;
164
+ }
165
+
166
+ // option
167
+ .#{$prefix}-select-option {
168
+ display: flex;
169
+ align-items: center;
170
+ border-radius: $select-option-border-radius;
171
+ height: $select-option-height-default;
172
+ font: $font-body-medium;
173
+ cursor: pointer;
174
+ padding: $select-option-padding-default;
175
+ color: $select-option-color;
176
+ transition: background-color $anim-duration-base $anim-time-fn-easing;
177
+ box-sizing: border-box;
178
+
179
+ span {
180
+ position: relative;
181
+ @include text-ellipsis;
182
+ }
183
+
184
+ &:not(.#{$prefix}-is-disabled):not(.#{$prefix}-is-selected):hover {
185
+ background-color: $select-option-bg-color-hover;
186
+
187
+ .#{$prefix}-checkbox__label {
188
+ color: $select-option-checkbox-label-color-hover;
189
+ }
190
+
191
+ .#{$prefix}-checkbox__input {
192
+ border-color: $select-option-checkbox-input-color-hover;
193
+ }
194
+ }
195
+
196
+ .#{$prefix}-checkbox__label {
197
+ color: $select-option-color;
198
+ flex: 1;
199
+ @include text-ellipsis;
200
+ }
201
+
202
+ .#{$prefix}-checkbox {
203
+ width: 100%;
204
+ }
205
+
206
+ --ripple-color: $bg-color-container-active;
207
+ }
208
+
209
+ .#{$prefix}-select-option.#{$prefix}-is-disabled {
210
+ cursor: not-allowed;
211
+ color: $select-color-disabled;
212
+ background: $select-bg-color;
213
+
214
+ &:hover,
215
+ :active {
216
+ background: $select-bg-color;
217
+ }
218
+ }
219
+
220
+ .#{$prefix}-select-option.#{$prefix}-size-l {
221
+ height: $select-option-height-l;
222
+ padding: $select-option-padding-l;
223
+ font: $select-font-l;
224
+ }
225
+ .#{$prefix}-select-option.#{$prefix}-size-m {
226
+ font: $select-font-m;
227
+ }
228
+ .#{$prefix}-select-option.#{$prefix}-size-s {
229
+ height: $select-option-height-s;
230
+ padding: $select-option-padding-s;
231
+ font: $select-font-s;
232
+ }
233
+
234
+ .#{$prefix}-select-option.#{$prefix}-is-selected:not(.#{$prefix}-is-disabled) {
235
+ color: $select-selected-color;
236
+ background-color: $select-selected-bg-color;
237
+ transition: all $anim-duration-base linear;
238
+
239
+ .#{$prefix}-checkbox__label {
240
+ color: $select-selected-color;
241
+ }
242
+
243
+ &:hover {
244
+ background-color: $select-selected-bg-color-hover;
245
+ }
246
+ }
247
+
248
+ /** 规范 CSS 类名为 --hover */
249
+ .#{$prefix}-select-option.#{$prefix}-select-option__hover,
250
+ .#{$prefix}-select-option.#{$prefix}-select-option--hover {
251
+ &:not(.#{$prefix}-is-disabled),
252
+ &:not(.#{$prefix}-is-selected) {
253
+ background-color: $select-option-bg-color-hover;
254
+ .#{$prefix}-checkbox__input {
255
+ border-color: $select-option-checkbox-input-color-hover;
256
+ }
257
+ }
258
+ .#{$prefix}-checkbox__label {
259
+ color: $select-option-checkbox-label-color-hover;
260
+ }
261
+ }
262
+
263
+ .#{$prefix}-select-option + .#{$prefix}-select-option {
264
+ margin-top: $select-options-margin-top;
265
+ }
266
+
267
+ .#{$prefix}-select {
268
+ &.#{$prefix}-select-input--borderless {
269
+ .#{$prefix}-select__right-icon {
270
+ position: relative;
271
+ margin: 0;
272
+ }
273
+ }
274
+
275
+ .#{$prefix}-fake-arrow {
276
+ color: $select-placeholder-color;
277
+
278
+ &--active {
279
+ color: $select-border-color-active;
280
+ }
281
+ }
282
+ }
283
+
284
+ .#{$prefix}-is-selected.#{$prefix}-select-option__hover {
285
+ background-color: $brand-color-light-hover;
286
+
287
+ .#{$prefix}-checkbox__label {
288
+ color: $select-selected-color;
289
+ }
290
+ }
@@ -0,0 +1,65 @@
1
+ // 颜色
2
+ $select-bg-color: $bg-color-specialcomponent;
3
+ $select-border-color: $border-level-2-color;
4
+ $select-border-color-active: $brand-color;
5
+ $select-selected-color: $brand-color;
6
+ $select-selected-bg-color: $brand-color-light;
7
+ $select-selected-bg-color-hover: $select-selected-bg-color;
8
+ $select-option-bg-color-hover: $bg-color-container-hover;
9
+ $select-option-bg-color-active: $bg-color-container-active;
10
+ $select-option-checkbox-color: $bg-color-container-hover;
11
+ $select-option-group-header-color: $text-color-placeholder;
12
+ $select-option-color: $text-color-primary;
13
+ $select-bg-color-disabled: $bg-color-component-disabled;
14
+ $select-placeholder-color: $text-color-placeholder;
15
+ $select-placeholder-color-disabled: $text-color-disabled;
16
+ $select-color-disabled: $text-color-disabled;
17
+ $select-color-empty: $text-color-disabled;
18
+ $select-icon-color: $text-color-placeholder;
19
+ $select-icon-color-disabled: $text-color-disabled;
20
+ $select-optiongroup-border-color: $border-level-1-color;
21
+ $select-input-color: $text-color-primary;
22
+ $select-option-checkbox-label-color-hover: inherit;
23
+ $select-option-checkbox-input-color-hover: $brand-color;
24
+ $select-right-icon-hover: $brand-color;
25
+ $select-loading-tips-bg-color: $bg-color-container;
26
+
27
+ // 尺寸
28
+ $select-height-s: $comp-size-xs;
29
+ $select-height-default: $comp-size-m;
30
+ $select-height-l: $comp-size-xl;
31
+ $select-option-height-s: $comp-size-xxs;
32
+ $select-option-height-default: $comp-size-s;
33
+ $select-option-height-l: $comp-size-l;
34
+ $select-dropdown-max-height: 300px;
35
+
36
+ // font
37
+ $select-font-s: $font-body-small;
38
+ $select-font-l: $font-body-large;
39
+ $select-font-m: $font-body-medium;
40
+
41
+ //阴影
42
+ $select-dropdown-shadow: $shadow-2;
43
+ $select-input-shadow: 0 0 0 2px $brand-color-focus;
44
+
45
+ //radius
46
+ $select-border-radius: $border-radius-default;
47
+ $select-option-border-radius: $border-radius-default;
48
+
49
+ //透明度
50
+
51
+ // padding
52
+ $select-option-padding-s: 0 $comp-paddingLR-s;
53
+ $select-option-padding-default: 0 $comp-paddingLR-s;
54
+ $select-option-padding-l: 0 $comp-paddingLR-m;
55
+ $select-optiongroup-border-padding: $comp-margin-xs;
56
+ $select-dropdown-padding: $pop-padding-m;
57
+ $select-dropdown-padding-l: $pop-padding-l;
58
+ $select-dropdown-padding-s: $pop-padding-s;
59
+ $select-dropdown-popup-padding: 0;
60
+ // margin
61
+ $select-optiongroup-border-margin: $comp-margin-xs;
62
+ $select-dropdown-margin: $comp-paddingTB-s 0;
63
+ $select-options-margin-top: $comp-paddingTB-xxs;
64
+ $select-empty-padding: 0 $comp-paddingLR-s;
65
+ $select-loading-tips-padding: $comp-paddingTB-s;
@@ -0,0 +1,5 @@
1
+ @import '../../vars.scss';
2
+
3
+ @import './_var.scss';
4
+
5
+ @import '../../mixins/_reset.scss';
@@ -0,0 +1,3 @@
1
+ $select-input-focus-bg: $bg-color-container-hover;
2
+ $select-input-border-radius: $border-radius-default;
3
+ $select-input-shadow: 0 0 0 2px $brand-color-focus;
@@ -0,0 +1,279 @@
1
+ @import '../../_vars.scss';
2
+
3
+ @import './_vars.scss';
4
+
5
+ @import './_mixins.scss';
6
+
7
+ @import '../../mixins/_reset.scss';
8
+
9
+ .#{$prefix}-switch {
10
+ @include reset;
11
+
12
+ position: relative;
13
+ display: inline-flex;
14
+ vertical-align: middle;
15
+ align-items: center;
16
+ outline: none;
17
+ border: 0;
18
+ padding: 0;
19
+ margin: 0;
20
+ height: $switch-height-default;
21
+ line-height: $switch-height-default;
22
+ border-radius: $border-radius-round;
23
+ min-width: $switch-min-width-default;
24
+ transition: $switch-transition;
25
+ background-color: $switch-unchecked-bg-color;
26
+ cursor: pointer;
27
+ user-select: none;
28
+
29
+ &:hover {
30
+ background-color: $switch-unchecked-bg-color-hover;
31
+ }
32
+
33
+ &__handle {
34
+ position: absolute;
35
+ display: flex;
36
+ align-items: center;
37
+ justify-content: center;
38
+ top: $switch-width-border-default;
39
+ left: $switch-width-border-default;
40
+ width: calc($switch-height-default - 2 * $switch-width-border-default);
41
+ height: calc($switch-height-default - 2 * $switch-width-border-default);
42
+ border-radius: $border-radius-round;
43
+ transition: $switch-handle-transition;
44
+ box-shadow: $shadow-1;
45
+
46
+ .t-icon {
47
+ font-size: calc($switch-height-default - 4px);
48
+ color: transparent;
49
+ }
50
+
51
+ &::before {
52
+ content: '';
53
+ position: absolute;
54
+ top: 0;
55
+ left: 0;
56
+ right: 0;
57
+ bottom: 0;
58
+ border-radius: $border-radius-round;
59
+ background-color: $switch-handle-bg-color;
60
+ transition: $switch-handle-transition;
61
+ }
62
+ }
63
+
64
+ &:active:not(.#{$prefix}-is-disabled):not(.#{$prefix}-is-loading) {
65
+ .#{$prefix}-switch__handle::before {
66
+ left: 0;
67
+ right: -6px;
68
+ }
69
+
70
+ &.#{$prefix}-is-checked {
71
+ .#{$prefix}-switch__handle::before {
72
+ right: 0;
73
+ left: -6px;
74
+ }
75
+ }
76
+
77
+ .#{$prefix}-switch__content {
78
+ opacity: 0;
79
+ }
80
+ }
81
+
82
+ &__content {
83
+ box-sizing: border-box;
84
+ display: inline-flex;
85
+ align-items: center;
86
+ color: $switch-content-color-unchecked;
87
+ padding: 0 $switch-content-margin-right-default 0
88
+ $switch-content-margin-left-default;
89
+ font-size: $switch-content-font-size-default;
90
+ min-width: $switch-min-width-default;
91
+ transition: $switch-content-transition;
92
+
93
+ .t-icon {
94
+ font-size: $font-size-l;
95
+ }
96
+ }
97
+
98
+ &.#{$prefix}-is-checked {
99
+ background-color: $switch-checked-bg-color;
100
+
101
+ &:hover {
102
+ background-color: $switch-checked-bg-color-hover;
103
+ }
104
+
105
+ .#{$prefix}-switch__handle {
106
+ left: calc(100% - $switch-width-border-check-default);
107
+ transform: translate(-100%, 0);
108
+ width: calc(
109
+ $switch-height-default - 2 * $switch-width-border-check-default
110
+ );
111
+ height: calc(
112
+ $switch-height-default - 2 * $switch-width-border-check-default
113
+ );
114
+ top: $switch-width-border-check-default;
115
+ }
116
+
117
+ .#{$prefix}-switch__content {
118
+ padding: 0 $switch-content-margin-left-default 0
119
+ $switch-content-margin-right-default;
120
+ color: $switch-content-color-checked;
121
+ }
122
+ }
123
+
124
+ &.#{$prefix}-is-loading {
125
+ cursor: not-allowed;
126
+ background-color: $switch-unchecked-bg-color-loading;
127
+
128
+ .#{$prefix}-loading {
129
+ display: inline-flex;
130
+ }
131
+
132
+ .#{$prefix}-switch__handle {
133
+ .t-icon {
134
+ color: $switch-unchecked-bg-color-loading;
135
+ }
136
+ }
137
+
138
+ &.#{$prefix}-is-checked {
139
+ background-color: $switch-checked-bg-color-loading;
140
+
141
+ .#{$prefix}-switch__handle {
142
+ .t-icon {
143
+ color: $switch-checked-bg-color-loading;
144
+ }
145
+ }
146
+ }
147
+ }
148
+
149
+ &.#{$prefix}-is-disabled {
150
+ cursor: not-allowed;
151
+ background-color: $switch-unchecked-bg-color-disabled;
152
+
153
+ .#{$prefix}-switch__handle {
154
+ box-shadow: none;
155
+ }
156
+
157
+ &.#{$prefix}-is-checked {
158
+ background-color: $switch-checked-bg-color-disabled;
159
+
160
+ .#{$prefix}-switch__handle {
161
+ box-shadow: none;
162
+
163
+ .t-icon {
164
+ color: $switch-checked-bg-color-disabled;
165
+ }
166
+ }
167
+ }
168
+ }
169
+ }
170
+
171
+ .#{$prefix}-switch.#{$prefix}-size-l {
172
+ min-width: $switch-min-width-l;
173
+ height: $switch-height-l;
174
+ line-height: $switch-height-l;
175
+ border-radius: $border-radius-round;
176
+
177
+ &:active:not(.#{$prefix}-is-disabled):not(.#{$prefix}-is-loading) {
178
+ .#{$prefix}-switch__handle::before {
179
+ left: 0;
180
+ right: -8px;
181
+ }
182
+
183
+ &.#{$prefix}-is-checked {
184
+ .#{$prefix}-switch__handle::before {
185
+ right: 0;
186
+ left: -8px;
187
+ }
188
+ }
189
+ }
190
+
191
+ .#{$prefix}-switch__handle {
192
+ top: $switch-width-border-l;
193
+ left: $switch-width-border-l;
194
+ width: calc($switch-height-l - 2 * $switch-width-border-l);
195
+ height: calc($switch-height-l - 2 * $switch-width-border-l);
196
+
197
+ .t-icon {
198
+ font-size: calc($switch-height-l - 4px);
199
+ }
200
+ }
201
+
202
+ .#{$prefix}-switch__content {
203
+ padding: 0 $switch-content-margin-right-l 0 $switch-content-margin-left-l;
204
+ min-width: $switch-min-width-l;
205
+ font-size: $switch-content-font-size-l;
206
+
207
+ .t-icon {
208
+ font-size: $switch-content-font-size-l;
209
+ }
210
+ }
211
+
212
+ &.#{$prefix}-is-checked {
213
+ .#{$prefix}-switch__handle {
214
+ left: calc(100% - $switch-width-border-check-l);
215
+ top: $switch-width-border-check-l;
216
+ width: calc($switch-height-l - 2 * $switch-width-border-check-l);
217
+ height: calc($switch-height-l - 2 * $switch-width-border-check-l);
218
+ }
219
+
220
+ .#{$prefix}-switch__content {
221
+ padding: 0 $switch-content-margin-left-l 0 $switch-content-margin-right-l;
222
+ }
223
+ }
224
+ }
225
+
226
+ .#{$prefix}-switch.#{$prefix}-size-s {
227
+ min-width: $switch-min-width-s;
228
+ height: $switch-height-s;
229
+ line-height: $switch-height-s;
230
+ border-radius: $border-radius-round;
231
+
232
+ &:active:not(.#{$prefix}-is-disabled):not(.#{$prefix}-is-loading) {
233
+ .#{$prefix}-switch__handle::before {
234
+ left: 0;
235
+ right: -4px;
236
+ }
237
+
238
+ &.#{$prefix}-is-checked {
239
+ .#{$prefix}-switch__handle::before {
240
+ right: 0;
241
+ left: -4px;
242
+ }
243
+ }
244
+ }
245
+
246
+ .#{$prefix}-switch__handle {
247
+ top: $switch-width-border-s;
248
+ left: $switch-width-border-s;
249
+ width: calc($switch-height-s - 2 * $switch-width-border-s);
250
+ height: calc($switch-height-s - 2 * $switch-width-border-s);
251
+
252
+ .t-icon {
253
+ font-size: calc($switch-height-s - 4px);
254
+ }
255
+ }
256
+
257
+ .#{$prefix}-switch__content {
258
+ padding: 0 $switch-content-margin-right-s 0 $switch-content-margin-left-s;
259
+ min-width: $switch-min-width-s;
260
+ font-size: $switch-content-font-size-s;
261
+
262
+ .t-icon {
263
+ font-size: $switch-content-font-size-l;
264
+ }
265
+ }
266
+
267
+ &.#{$prefix}-is-checked {
268
+ .#{$prefix}-switch__handle {
269
+ left: calc(100% - $switch-width-border-check-s);
270
+ top: $switch-width-border-check-s;
271
+ width: calc($switch-height-s - 2 * $switch-width-border-check-s);
272
+ height: calc($switch-height-s - 2 * $switch-width-border-check-s);
273
+ }
274
+
275
+ .#{$prefix}-switch__content {
276
+ padding: 0 $switch-content-margin-left-s 0 $switch-content-margin-right-s;
277
+ }
278
+ }
279
+ }
File without changes
@@ -0,0 +1,61 @@
1
+
2
+ // 颜色
3
+ $switch-checked-bg-color: $brand-color;
4
+ $switch-checked-bg-color-hover: $brand-color-hover;
5
+ $switch-checked-bg-color-loading: $brand-color-focus;
6
+ $switch-checked-bg-color-disabled: $brand-color-disabled;
7
+
8
+ $switch-unchecked-bg-color: $bg-color-secondarycomponent;
9
+ $switch-unchecked-bg-color-hover: $bg-color-secondarycomponent-hover;
10
+ $switch-unchecked-bg-color-loading: $bg-color-component-disabled;
11
+ $switch-unchecked-bg-color-disabled: $bg-color-component-disabled;
12
+
13
+ $switch-handle-bg-color: #fff;
14
+ $switch-content-color-checked: $text-color-anti;
15
+ $switch-content-color-unchecked: $text-color-anti;
16
+
17
+ // 尺寸
18
+ $switch-height-l: $comp-size-xs;
19
+ $switch-height-default: $comp-size-xxs;
20
+ $switch-height-s: $comp-size-xxxs;
21
+
22
+ $switch-min-width-l: calc($switch-height-l / .618);
23
+ $switch-min-width-default: calc($switch-height-default / .618);
24
+ $switch-min-width-s: calc($switch-height-s / .618);
25
+
26
+ //change uncheck handle size
27
+ $switch-width-border-base: 5px;
28
+ $switch-width-border-value: 1px; //公差值
29
+
30
+ $switch-width-border-l: $switch-width-border-base;
31
+ $switch-width-border-default: ($switch-width-border-base - $switch-width-border-value * 1);
32
+ $switch-width-border-s: ($switch-width-border-base - $switch-width-border-value * 2);
33
+
34
+ //change check handle size
35
+ $switch-width-border-check-base: 3px;
36
+ $switch-width-border-check-value: .5px; //公差值
37
+
38
+ $switch-width-border-check-l: $switch-width-border-check-base;
39
+ $switch-width-border-check-default: ($switch-width-border-check-base - $switch-width-border-check-value * 1);
40
+ $switch-width-border-check-s: ($switch-width-border-check-base - $switch-width-border-check-value * 2);
41
+
42
+ // 字体
43
+ $switch-content-font-size-l: $font-size-l;
44
+ $switch-content-font-size-default: $font-size-s;
45
+ $switch-content-font-size-s: 9px;
46
+
47
+ // 间距
48
+ $switch-content-margin-left-l: calc($switch-min-width-l / 2 + 4px);
49
+ $switch-content-margin-right-l: $comp-margin-s;
50
+
51
+ $switch-content-margin-left-default: calc($switch-min-width-default / 2 + 2px);
52
+ $switch-content-margin-right-default: $comp-margin-xs;
53
+
54
+ $switch-content-margin-left-s: calc($switch-min-width-s / 2 + 2px);
55
+ $switch-content-margin-right-s: $comp-margin-xxs;
56
+
57
+ // 动画
58
+ $switch-transition: all $anim-duration-base $anim-time-fn-easing;
59
+ $switch-handle-transition: all $anim-duration-base $anim-time-fn-easing;
60
+ $switch-content-transition: padding $anim-duration-base $anim-time-fn-easing,
61
+ opacity $anim-duration-base linear;