@douyinfe/semi-foundation 2.9.1 → 2.10.0-alpha.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.
@@ -21,6 +21,8 @@ export interface CheckboxAdapter<P = Record<string, any>, S = Record<string, any
21
21
  setNativeControlChecked: (checked: boolean) => void;
22
22
  getState: noopFunction;
23
23
  notifyChange: (event: BasicCheckboxEvent) => void;
24
+ setAddonId: () => void;
25
+ setExtraId: () => void;
24
26
  }
25
27
 
26
28
  class CheckboxFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<CheckboxAdapter<P, S>, P, S> {
@@ -29,8 +31,15 @@ class CheckboxFoundation<P = Record<string, any>, S = Record<string, any>> exten
29
31
  super({ ...adapter });
30
32
  }
31
33
 
32
- // eslint-disable-next-line @typescript-eslint/no-empty-function
33
- init() {}
34
+ init() {
35
+ const { children, extra, extraId, addonId } = this.getProps();
36
+ if (children && !addonId) {
37
+ this._adapter.setAddonId();
38
+ }
39
+ if (extra && !extraId) {
40
+ this._adapter.setExtraId();
41
+ }
42
+ }
34
43
 
35
44
  getEvent(checked: boolean, e: any) {
36
45
  const props = this.getProps();
@@ -19,6 +19,8 @@ export interface CheckboxAdapter<P = Record<string, any>, S = Record<string, any
19
19
  setNativeControlChecked: (checked: boolean) => void;
20
20
  getState: noopFunction;
21
21
  notifyChange: (event: BasicCheckboxEvent) => void;
22
+ setAddonId: () => void;
23
+ setExtraId: () => void;
22
24
  }
23
25
  declare class CheckboxFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<CheckboxAdapter<P, S>, P, S> {
24
26
  constructor(adapter: CheckboxAdapter<P, S>);
@@ -21,10 +21,24 @@ var _isEnterPress = _interopRequireDefault(require("../utils/isEnterPress"));
21
21
  class CheckboxFoundation extends _foundation.default {
22
22
  constructor(adapter) {
23
23
  super((0, _assign.default)({}, adapter));
24
- } // eslint-disable-next-line @typescript-eslint/no-empty-function
24
+ }
25
+
26
+ init() {
27
+ const {
28
+ children,
29
+ extra,
30
+ extraId,
31
+ addonId
32
+ } = this.getProps();
25
33
 
34
+ if (children && !addonId) {
35
+ this._adapter.setAddonId();
36
+ }
26
37
 
27
- init() {}
38
+ if (extra && !extraId) {
39
+ this._adapter.setExtraId();
40
+ }
41
+ }
28
42
 
29
43
  getEvent(checked, e) {
30
44
  const props = this.getProps();
@@ -1,7 +1,10 @@
1
1
  import BaseFoundation, { DefaultAdapter } from '../base/foundation';
2
2
  export interface RadioAdapter extends DefaultAdapter {
3
3
  setHover: (hover: boolean) => void;
4
+ setAddonId: () => void;
5
+ setExtraId: () => void;
4
6
  }
5
7
  export default class RadioFoundation extends BaseFoundation<RadioAdapter> {
8
+ init(): void;
6
9
  setHover(hover: boolean): void;
7
10
  }
@@ -13,6 +13,23 @@ exports.default = void 0;
13
13
  var _foundation = _interopRequireDefault(require("../base/foundation"));
14
14
 
15
15
  class RadioFoundation extends _foundation.default {
16
+ init() {
17
+ const {
18
+ children,
19
+ extra,
20
+ extraId,
21
+ addonId
22
+ } = this._adapter.getProps();
23
+
24
+ if (children && !addonId) {
25
+ this._adapter.setAddonId();
26
+ }
27
+
28
+ if (extra && !extraId) {
29
+ this._adapter.setExtraId();
30
+ }
31
+ }
32
+
16
33
  setHover(hover) {
17
34
  this._adapter.setHover(hover);
18
35
  }
@@ -115,7 +115,6 @@
115
115
  }
116
116
  .semi-select-open:hover, .semi-select-focus:hover {
117
117
  background-color: var(--semi-color-fill-0);
118
- border: 1px solid var(--semi-color-focus-border);
119
118
  }
120
119
  .semi-select-warning {
121
120
  background-color: var(--semi-color-warning-light-default);
@@ -54,10 +54,9 @@ $multiple: #{$module}-multiple;
54
54
 
55
55
  &:hover {
56
56
  background-color: $color-select-bg-default;
57
- border: $border-thickness-control-focus solid $color-select_default-border-focus;
58
57
  }
59
58
  }
60
-
59
+
61
60
  &-warning {
62
61
  background-color: $color-select_warning-bg-default;
63
62
  border-color: $color-select_warning-border-default;
@@ -126,10 +126,6 @@ class TimePickerFoundation extends _foundation.default {
126
126
  parsedValues.push(this.isValidTimeZone() ? (0, _dateFnsExtra.utcToZonedTime)(pv, timeZone) : pv);
127
127
  }
128
128
  });
129
- const isAM = [true, false];
130
- (0, _map.default)(parsedValues).call(parsedValues, (item, idx) => {
131
- isAM[idx] = (0, _dateFns.getHours)(item) < 12;
132
- });
133
129
 
134
130
  if (parsedValues.length === value.length) {
135
131
  value = parsedValues;
@@ -148,7 +144,6 @@ class TimePickerFoundation extends _foundation.default {
148
144
  }
149
145
 
150
146
  this.setState({
151
- isAM,
152
147
  value,
153
148
  inputValue,
154
149
  invalid
@@ -186,12 +181,6 @@ class TimePickerFoundation extends _foundation.default {
186
181
  isAM[index] = panelIsAM;
187
182
  const inputValue = this.formatValue(value);
188
183
 
189
- if (this.getState('isAM')[index] !== result.isAM) {
190
- this.setState({
191
- isAM
192
- });
193
- }
194
-
195
184
  if (!this._isControlledComponent('value')) {
196
185
  const invalid = this.validateDates(value);
197
186
  this.setState({
@@ -47,6 +47,7 @@ export interface TooltipAdapter<P = Record<string, any>, S = Record<string, any>
47
47
  setInitialFocus(): void;
48
48
  notifyEscKeydown(event: any): void;
49
49
  getTriggerNode(): any;
50
+ setId(): void;
50
51
  }
51
52
  export declare type Position = ArrayElement<typeof strings.POSITION_SET>;
52
53
  export interface PopupContainerDOMRect extends DOMRectLikeType {
@@ -237,6 +237,9 @@ class Tooltip extends _foundation.default {
237
237
  }
238
238
 
239
239
  init() {
240
+ const {
241
+ wrapperId
242
+ } = this.getProps();
240
243
  this._mounted = true;
241
244
 
242
245
  this._bindEvent();
@@ -244,6 +247,10 @@ class Tooltip extends _foundation.default {
244
247
  this._shouldShow();
245
248
 
246
249
  this._initContainerPosition();
250
+
251
+ if (!wrapperId) {
252
+ this._adapter.setId();
253
+ }
247
254
  }
248
255
 
249
256
  destroy() {
@@ -88,4 +88,4 @@ $module-icon: #{$module}-icon-arrow;
88
88
  }
89
89
 
90
90
  @import './arrow.scss';
91
- @import './rtl.scss';
91
+ @import './rtl.scss';
@@ -19,6 +19,8 @@ export interface CheckboxAdapter<P = Record<string, any>, S = Record<string, any
19
19
  setNativeControlChecked: (checked: boolean) => void;
20
20
  getState: noopFunction;
21
21
  notifyChange: (event: BasicCheckboxEvent) => void;
22
+ setAddonId: () => void;
23
+ setExtraId: () => void;
22
24
  }
23
25
  declare class CheckboxFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<CheckboxAdapter<P, S>, P, S> {
24
26
  constructor(adapter: CheckboxAdapter<P, S>);
@@ -6,10 +6,24 @@ import isEnterPress from '../utils/isEnterPress';
6
6
  class CheckboxFoundation extends BaseFoundation {
7
7
  constructor(adapter) {
8
8
  super(_Object$assign({}, adapter));
9
- } // eslint-disable-next-line @typescript-eslint/no-empty-function
9
+ }
10
+
11
+ init() {
12
+ const {
13
+ children,
14
+ extra,
15
+ extraId,
16
+ addonId
17
+ } = this.getProps();
10
18
 
19
+ if (children && !addonId) {
20
+ this._adapter.setAddonId();
21
+ }
11
22
 
12
- init() {}
23
+ if (extra && !extraId) {
24
+ this._adapter.setExtraId();
25
+ }
26
+ }
13
27
 
14
28
  getEvent(checked, e) {
15
29
  const props = this.getProps();
@@ -1,7 +1,10 @@
1
1
  import BaseFoundation, { DefaultAdapter } from '../base/foundation';
2
2
  export interface RadioAdapter extends DefaultAdapter {
3
3
  setHover: (hover: boolean) => void;
4
+ setAddonId: () => void;
5
+ setExtraId: () => void;
4
6
  }
5
7
  export default class RadioFoundation extends BaseFoundation<RadioAdapter> {
8
+ init(): void;
6
9
  setHover(hover: boolean): void;
7
10
  }
@@ -1,5 +1,22 @@
1
1
  import BaseFoundation from '../base/foundation';
2
2
  export default class RadioFoundation extends BaseFoundation {
3
+ init() {
4
+ const {
5
+ children,
6
+ extra,
7
+ extraId,
8
+ addonId
9
+ } = this._adapter.getProps();
10
+
11
+ if (children && !addonId) {
12
+ this._adapter.setAddonId();
13
+ }
14
+
15
+ if (extra && !extraId) {
16
+ this._adapter.setExtraId();
17
+ }
18
+ }
19
+
3
20
  setHover(hover) {
4
21
  this._adapter.setHover(hover);
5
22
  }
@@ -115,7 +115,6 @@
115
115
  }
116
116
  .semi-select-open:hover, .semi-select-focus:hover {
117
117
  background-color: var(--semi-color-fill-0);
118
- border: 1px solid var(--semi-color-focus-border);
119
118
  }
120
119
  .semi-select-warning {
121
120
  background-color: var(--semi-color-warning-light-default);
@@ -54,10 +54,9 @@ $multiple: #{$module}-multiple;
54
54
 
55
55
  &:hover {
56
56
  background-color: $color-select-bg-default;
57
- border: $border-thickness-control-focus solid $color-select_default-border-focus;
58
57
  }
59
58
  }
60
-
59
+
61
60
  &-warning {
62
61
  background-color: $color-select_warning-bg-default;
63
62
  border-color: $color-select_warning-border-default;
@@ -10,7 +10,7 @@ import _someInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instanc
10
10
  import { strings } from './constants';
11
11
  import BaseFoundation from '../base/foundation';
12
12
  import { formatToString, parseToDate, hourIsDisabled, minuteIsDisabled, secondIsDisabled, transformToArray, isTimeFormatLike } from './utils';
13
- import { isValid, format, getHours } from 'date-fns';
13
+ import { isValid, format } from 'date-fns';
14
14
  import { utcToZonedTime, zonedTimeToUtc } from '../utils/date-fns-extra';
15
15
  import isNullOrUndefined from '../utils/isNullOrUndefined'; // TODO: split, timePicker different components cannot share a foundation
16
16
 
@@ -102,12 +102,6 @@ class TimePickerFoundation extends BaseFoundation {
102
102
  }
103
103
  });
104
104
 
105
- const isAM = [true, false];
106
-
107
- _mapInstanceProperty(parsedValues).call(parsedValues, (item, idx) => {
108
- isAM[idx] = getHours(item) < 12;
109
- });
110
-
111
105
  if (parsedValues.length === value.length) {
112
106
  value = parsedValues;
113
107
  } else {
@@ -125,7 +119,6 @@ class TimePickerFoundation extends BaseFoundation {
125
119
  }
126
120
 
127
121
  this.setState({
128
- isAM,
129
122
  value,
130
123
  inputValue,
131
124
  invalid
@@ -163,12 +156,6 @@ class TimePickerFoundation extends BaseFoundation {
163
156
  isAM[index] = panelIsAM;
164
157
  const inputValue = this.formatValue(value);
165
158
 
166
- if (this.getState('isAM')[index] !== result.isAM) {
167
- this.setState({
168
- isAM
169
- });
170
- }
171
-
172
159
  if (!this._isControlledComponent('value')) {
173
160
  const invalid = this.validateDates(value);
174
161
  this.setState({
@@ -47,6 +47,7 @@ export interface TooltipAdapter<P = Record<string, any>, S = Record<string, any>
47
47
  setInitialFocus(): void;
48
48
  notifyEscKeydown(event: any): void;
49
49
  getTriggerNode(): any;
50
+ setId(): void;
50
51
  }
51
52
  export declare type Position = ArrayElement<typeof strings.POSITION_SET>;
52
53
  export interface PopupContainerDOMRect extends DOMRectLikeType {
@@ -215,6 +215,9 @@ export default class Tooltip extends BaseFoundation {
215
215
  }
216
216
 
217
217
  init() {
218
+ const {
219
+ wrapperId
220
+ } = this.getProps();
218
221
  this._mounted = true;
219
222
 
220
223
  this._bindEvent();
@@ -222,6 +225,10 @@ export default class Tooltip extends BaseFoundation {
222
225
  this._shouldShow();
223
226
 
224
227
  this._initContainerPosition();
228
+
229
+ if (!wrapperId) {
230
+ this._adapter.setId();
231
+ }
225
232
  }
226
233
 
227
234
  destroy() {
@@ -88,4 +88,4 @@ $module-icon: #{$module}-icon-arrow;
88
88
  }
89
89
 
90
90
  @import './arrow.scss';
91
- @import './rtl.scss';
91
+ @import './rtl.scss';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-foundation",
3
- "version": "2.9.1",
3
+ "version": "2.10.0-alpha.0",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build:lib": "node ./scripts/compileLib.js",
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "@babel/runtime-corejs3": "^7.15.4",
11
- "@douyinfe/semi-animation": "2.9.1",
11
+ "@douyinfe/semi-animation": "2.9.0",
12
12
  "async-validator": "^3.5.0",
13
13
  "classnames": "^2.2.6",
14
14
  "date-fns": "^2.9.0",
@@ -24,7 +24,7 @@
24
24
  "*.scss",
25
25
  "*.css"
26
26
  ],
27
- "gitHead": "9593ab23b59b5a18305627ac402cfd4527072f9c",
27
+ "gitHead": "5d1bb1d031052d7584ecd5d1bc444cd13f861337",
28
28
  "devDependencies": {
29
29
  "@babel/plugin-proposal-decorators": "^7.15.8",
30
30
  "@babel/plugin-transform-runtime": "^7.15.8",
@@ -2,8 +2,19 @@ import BaseFoundation, { DefaultAdapter } from '../base/foundation';
2
2
 
3
3
  export interface RadioAdapter extends DefaultAdapter {
4
4
  setHover: (hover: boolean) => void;
5
+ setAddonId: () => void;
6
+ setExtraId: () => void;
5
7
  }
6
8
  export default class RadioFoundation extends BaseFoundation<RadioAdapter> {
9
+ init() {
10
+ const { children, extra, extraId, addonId } = this._adapter.getProps();
11
+ if (children && !addonId) {
12
+ this._adapter.setAddonId();
13
+ }
14
+ if (extra && !extraId) {
15
+ this._adapter.setExtraId();
16
+ }
17
+ }
7
18
  setHover(hover: boolean) {
8
19
  this._adapter.setHover(hover);
9
20
  }
@@ -54,10 +54,9 @@ $multiple: #{$module}-multiple;
54
54
 
55
55
  &:hover {
56
56
  background-color: $color-select-bg-default;
57
- border: $border-thickness-control-focus solid $color-select_default-border-focus;
58
57
  }
59
58
  }
60
-
59
+
61
60
  &-warning {
62
61
  background-color: $color-select_warning-bg-default;
63
62
  border-color: $color-select_warning-border-default;
@@ -11,7 +11,7 @@ import {
11
11
  isTimeFormatLike
12
12
  } from './utils';
13
13
  import { split } from 'lodash';
14
- import { isValid, format, getHours } from 'date-fns';
14
+ import { isValid, format } from 'date-fns';
15
15
  import { utcToZonedTime, zonedTimeToUtc } from '../utils/date-fns-extra';
16
16
  import isNullOrUndefined from '../utils/isNullOrUndefined';
17
17
 
@@ -125,11 +125,6 @@ class TimePickerFoundation<P = Record<string, any>, S = Record<string, any>> ext
125
125
  }
126
126
  });
127
127
 
128
- const isAM = [true, false];
129
- parsedValues.map((item, idx)=>{
130
- isAM[idx]= getHours(item) < 12;
131
- });
132
-
133
128
  if (parsedValues.length === value.length) {
134
129
  value = parsedValues;
135
130
  } else {
@@ -147,7 +142,6 @@ class TimePickerFoundation<P = Record<string, any>, S = Record<string, any>> ext
147
142
  }
148
143
 
149
144
  this.setState({
150
- isAM,
151
145
  value,
152
146
  inputValue,
153
147
  invalid,
@@ -182,9 +176,6 @@ class TimePickerFoundation<P = Record<string, any>, S = Record<string, any>> ext
182
176
  isAM[index] = panelIsAM;
183
177
  const inputValue = this.formatValue(value);
184
178
 
185
- if (this.getState('isAM')[index] !== result.isAM){
186
- this.setState({ isAM } as any);
187
- }
188
179
  if (!this._isControlledComponent('value')) {
189
180
  const invalid = this.validateDates(value);
190
181
  this.setState({
@@ -316,7 +307,7 @@ class TimePickerFoundation<P = Record<string, any>, S = Record<string, any>> ext
316
307
 
317
308
  validateStr(inputValue = '') {
318
309
  const dates = this.parseInput(inputValue);
319
-
310
+
320
311
  return this.validateDates(dates);
321
312
  }
322
313
 
@@ -68,6 +68,7 @@ export interface TooltipAdapter<P = Record<string, any>, S = Record<string, any>
68
68
  setInitialFocus(): void;
69
69
  notifyEscKeydown(event: any): void;
70
70
  getTriggerNode(): any;
71
+ setId(): void;
71
72
  }
72
73
 
73
74
  export type Position = ArrayElement<typeof strings.POSITION_SET>;
@@ -87,10 +88,14 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
87
88
  }
88
89
 
89
90
  init() {
91
+ const { wrapperId } = this.getProps();
90
92
  this._mounted = true;
91
93
  this._bindEvent();
92
94
  this._shouldShow();
93
95
  this._initContainerPosition();
96
+ if (!wrapperId) {
97
+ this._adapter.setId();
98
+ }
94
99
  }
95
100
 
96
101
  destroy() {
@@ -88,4 +88,4 @@ $module-icon: #{$module}-icon-arrow;
88
88
  }
89
89
 
90
90
  @import './arrow.scss';
91
- @import './rtl.scss';
91
+ @import './rtl.scss';