@douyinfe/semi-foundation 2.39.3 → 2.40.0-beta.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.
@@ -248,19 +248,19 @@ export default class FormFoundation extends BaseFoundation<BaseFormAdapter> {
248
248
  });
249
249
  }
250
250
 
251
- submit(): void {
251
+ submit(e?: any): void {
252
252
  const { values } = this.data;
253
253
  // validate form
254
254
  this.validate()
255
255
  .then((resolveValues: any) => {
256
256
  // if valid do submit
257
257
  const _values = this._adapter.cloneDeep(resolveValues);
258
- this._adapter.notifySubmit(_values);
258
+ this._adapter.notifySubmit(_values, e);
259
259
  })
260
260
  .catch(errors => {
261
261
  const _errors = this._adapter.cloneDeep(errors);
262
262
  const _values = this._adapter.cloneDeep(values);
263
- this._adapter.notifySubmitFail(_errors, _values);
263
+ this._adapter.notifySubmitFail(_errors, _values, e);
264
264
  });
265
265
  }
266
266
 
package/form/interface.ts CHANGED
@@ -12,8 +12,8 @@ export type BasicFieldError = Array<any>;
12
12
 
13
13
  export interface BaseFormAdapter<P = Record<string, any>, S = Record<string, any>, Values extends object = any> extends DefaultAdapter<P, S> {
14
14
  cloneDeep: (val: any, ...rest: any[]) => any;
15
- notifySubmit: (values: any) => void;
16
- notifySubmitFail: (errors: Record<keyof Values, BasicFieldError>, values: Partial<Values>) => void;
15
+ notifySubmit: (values: any, e?: any) => void;
16
+ notifySubmitFail: (errors: Record<keyof Values, BasicFieldError>, values: Partial<Values>, e?: any) => void;
17
17
  forceUpdate: (callback?: () => void) => void;
18
18
  notifyChange: (formState: FormState) => void;
19
19
  notifyValueChange: (values: any, changedValues: any) => void;
package/image/image.scss CHANGED
@@ -123,10 +123,14 @@ $module: #{$prefix}-image;
123
123
  &-footer {
124
124
  display: flex;
125
125
  align-items: center;
126
- padding: $spacing-image_preview_footer-paddingY $spacing-image_preview_footer-paddingX;
127
- background: $color-image_preview_footer-bg;
128
- border-radius: $radius-image_preview_footer;
129
- height: $height-image_preview_footer;
126
+
127
+ &-content {
128
+ padding: $spacing-image_preview_footer-paddingY $spacing-image_preview_footer-paddingX;
129
+ background: $color-image_preview_footer-bg;
130
+ border-radius: $radius-image_preview_footer;
131
+ height: $height-image_preview_footer;
132
+ }
133
+
130
134
 
131
135
  &-wrapper {
132
136
  position: absolute;
@@ -21,7 +21,8 @@ export interface PreviewInnerAdapter<P = Record<string, any>, S = Record<string,
21
21
  setStartMouseDown: (x: number, y: number) => void;
22
22
  setMouseActiveTime: (time: number) => void;
23
23
  disabledBodyScroll: () => void;
24
- enabledBodyScroll: () => void
24
+ enabledBodyScroll: () => void;
25
+ getSetDownloadFunc: () => (src: string) => string
25
26
  }
26
27
 
27
28
 
@@ -129,8 +130,9 @@ export default class PreviewInnerFoundation<P = Record<string, any>, S = Record<
129
130
 
130
131
  handleDownload = () => {
131
132
  const { currentIndex, imgSrc } = this.getStates();
133
+ const setDownloadName = this._adapter.getSetDownloadFunc();
132
134
  const downloadSrc = imgSrc[currentIndex];
133
- const downloadName = downloadSrc.slice(downloadSrc.lastIndexOf("/") + 1);
135
+ const downloadName = setDownloadName ? setDownloadName(downloadSrc) : downloadSrc.slice(downloadSrc.lastIndexOf("/") + 1);
134
136
  downloadImage(downloadSrc, downloadName);
135
137
  this._adapter.notifyDownload(downloadSrc, currentIndex);
136
138
  }
@@ -19,7 +19,7 @@ export default class FormFoundation extends BaseFoundation<BaseFormAdapter> {
19
19
  validate(fieldPaths?: Array<string>): Promise<unknown>;
20
20
  _formValidate(): Promise<unknown>;
21
21
  _fieldsValidate(fieldPaths: Array<string>): Promise<unknown>;
22
- submit(): void;
22
+ submit(e?: any): void;
23
23
  /**
24
24
  * Case A:
25
25
  * All fields: a[0]、a[1]、b.type、b.name[2]、b.name[0]
@@ -232,7 +232,7 @@ class FormFoundation extends _foundation.default {
232
232
  });
233
233
  });
234
234
  }
235
- submit() {
235
+ submit(e) {
236
236
  const {
237
237
  values
238
238
  } = this.data;
@@ -240,11 +240,11 @@ class FormFoundation extends _foundation.default {
240
240
  this.validate().then(resolveValues => {
241
241
  // if valid do submit
242
242
  const _values = this._adapter.cloneDeep(resolveValues);
243
- this._adapter.notifySubmit(_values);
243
+ this._adapter.notifySubmit(_values, e);
244
244
  }).catch(errors => {
245
245
  const _errors = this._adapter.cloneDeep(errors);
246
246
  const _values = this._adapter.cloneDeep(values);
247
- this._adapter.notifySubmitFail(_errors, _values);
247
+ this._adapter.notifySubmitFail(_errors, _values, e);
248
248
  });
249
249
  }
250
250
  /**
@@ -6,8 +6,8 @@ export type CommonFieldError = boolean | string | Array<any> | undefined | unkno
6
6
  export type BasicFieldError = Array<any>;
7
7
  export interface BaseFormAdapter<P = Record<string, any>, S = Record<string, any>, Values extends object = any> extends DefaultAdapter<P, S> {
8
8
  cloneDeep: (val: any, ...rest: any[]) => any;
9
- notifySubmit: (values: any) => void;
10
- notifySubmitFail: (errors: Record<keyof Values, BasicFieldError>, values: Partial<Values>) => void;
9
+ notifySubmit: (values: any, e?: any) => void;
10
+ notifySubmitFail: (errors: Record<keyof Values, BasicFieldError>, values: Partial<Values>, e?: any) => void;
11
11
  forceUpdate: (callback?: () => void) => void;
12
12
  notifyChange: (formState: FormState) => void;
13
13
  notifyValueChange: (values: any, changedValues: any) => void;
@@ -109,6 +109,8 @@
109
109
  .semi-image-preview-footer {
110
110
  display: flex;
111
111
  align-items: center;
112
+ }
113
+ .semi-image-preview-footer-content {
112
114
  padding: 0 16px;
113
115
  background: rgba(0, 0, 0, 0.75);
114
116
  border-radius: 6px;
@@ -123,10 +123,14 @@ $module: #{$prefix}-image;
123
123
  &-footer {
124
124
  display: flex;
125
125
  align-items: center;
126
- padding: $spacing-image_preview_footer-paddingY $spacing-image_preview_footer-paddingX;
127
- background: $color-image_preview_footer-bg;
128
- border-radius: $radius-image_preview_footer;
129
- height: $height-image_preview_footer;
126
+
127
+ &-content {
128
+ padding: $spacing-image_preview_footer-paddingY $spacing-image_preview_footer-paddingX;
129
+ background: $color-image_preview_footer-bg;
130
+ border-radius: $radius-image_preview_footer;
131
+ height: $height-image_preview_footer;
132
+ }
133
+
130
134
 
131
135
  &-wrapper {
132
136
  position: absolute;
@@ -22,6 +22,7 @@ export interface PreviewInnerAdapter<P = Record<string, any>, S = Record<string,
22
22
  setMouseActiveTime: (time: number) => void;
23
23
  disabledBodyScroll: () => void;
24
24
  enabledBodyScroll: () => void;
25
+ getSetDownloadFunc: () => (src: string) => string;
25
26
  }
26
27
  export default class PreviewInnerFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<PreviewInnerAdapter<P, S>, P, S> {
27
28
  constructor(adapter: PreviewInnerAdapter<P, S>);
@@ -115,8 +115,9 @@ class PreviewInnerFoundation extends _foundation.default {
115
115
  currentIndex,
116
116
  imgSrc
117
117
  } = this.getStates();
118
+ const setDownloadName = this._adapter.getSetDownloadFunc();
118
119
  const downloadSrc = imgSrc[currentIndex];
119
- const downloadName = downloadSrc.slice(downloadSrc.lastIndexOf("/") + 1);
120
+ const downloadName = setDownloadName ? setDownloadName(downloadSrc) : downloadSrc.slice(downloadSrc.lastIndexOf("/") + 1);
120
121
  (0, _utils.downloadImage)(downloadSrc, downloadName);
121
122
  this._adapter.notifyDownload(downloadSrc, currentIndex);
122
123
  };
@@ -175,6 +175,7 @@
175
175
  .semi-radio-content {
176
176
  display: flex;
177
177
  flex-direction: column;
178
+ row-gap: 4px;
178
179
  }
179
180
  .semi-radio:hover .semi-radio-inner-display {
180
181
  background: var(--semi-color-fill-0);
@@ -241,6 +241,7 @@ $inner-width: $width-icon-medium;
241
241
  &-content {
242
242
  display: flex;
243
243
  flex-direction: column;
244
+ row-gap: $spacing-radio_content-rowGap;
244
245
  }
245
246
 
246
247
  &:hover {
@@ -77,6 +77,7 @@ $spacing-radio_addon_buttonRadio_middle-paddingX: $spacing-base; // 中尺寸按
77
77
  $spacing-radio_addon_buttonRadio_middle-paddingY: $spacing-extra-tight; // 中尺寸按钮式单选按钮垂直内边距
78
78
  $spacing-radio_addon_buttonRadio_marginLeft: $spacing-none; // 按钮式单选按钮左侧外边距
79
79
  $spacing-radio_extra-paddingLeft: $width-radio_inner + $spacing-tight; // 单选副标题左侧内边距
80
+ $spacing-radio_content-rowGap: 4px; // 内容行间距
80
81
 
81
82
  $spacing-radio_group_vertical-marginBottom: $spacing-base-tight; // 垂直布局单选框组底部外边距
82
83
  $spacing-radio_card_group_vertical-marginBottom: $spacing-base; // 垂直布局卡片式单选框组底部外边距
@@ -165,13 +165,13 @@ class TimePickerFoundation extends _foundation.default {
165
165
  if (this.isValidTimeZone(timeZone)) {
166
166
  dates = dates.map(date => (0, _dateFnsExtra.utcToZonedTime)(this.isValidTimeZone(__prevTimeZone) ? (0, _dateFnsExtra.zonedTimeToUtc)(date, __prevTimeZone) : date, timeZone));
167
167
  }
168
- const inputValue = this.formatValue(dates);
169
- this.setState({
170
- value: dates,
171
- invalid,
172
- inputValue
173
- });
174
168
  }
169
+ const inputValue = this.formatValue(dates);
170
+ this.setState({
171
+ value: dates,
172
+ invalid,
173
+ inputValue
174
+ });
175
175
  }
176
176
  handleFocus(e) {
177
177
  if (!this.getState('open')) {
@@ -32,6 +32,8 @@ const parseToDate = function (input) {
32
32
  });
33
33
  // console.log(curDate, formatToken);
34
34
  return curDate;
35
+ } else if (typeof input === 'undefined') {
36
+ return undefined;
35
37
  }
36
38
  return new Date();
37
39
  };
@@ -19,7 +19,7 @@ export default class FormFoundation extends BaseFoundation<BaseFormAdapter> {
19
19
  validate(fieldPaths?: Array<string>): Promise<unknown>;
20
20
  _formValidate(): Promise<unknown>;
21
21
  _fieldsValidate(fieldPaths: Array<string>): Promise<unknown>;
22
- submit(): void;
22
+ submit(e?: any): void;
23
23
  /**
24
24
  * Case A:
25
25
  * All fields: a[0]、a[1]、b.type、b.name[2]、b.name[0]
@@ -223,7 +223,7 @@ export default class FormFoundation extends BaseFoundation {
223
223
  });
224
224
  });
225
225
  }
226
- submit() {
226
+ submit(e) {
227
227
  const {
228
228
  values
229
229
  } = this.data;
@@ -231,11 +231,11 @@ export default class FormFoundation extends BaseFoundation {
231
231
  this.validate().then(resolveValues => {
232
232
  // if valid do submit
233
233
  const _values = this._adapter.cloneDeep(resolveValues);
234
- this._adapter.notifySubmit(_values);
234
+ this._adapter.notifySubmit(_values, e);
235
235
  }).catch(errors => {
236
236
  const _errors = this._adapter.cloneDeep(errors);
237
237
  const _values = this._adapter.cloneDeep(values);
238
- this._adapter.notifySubmitFail(_errors, _values);
238
+ this._adapter.notifySubmitFail(_errors, _values, e);
239
239
  });
240
240
  }
241
241
  /**
@@ -6,8 +6,8 @@ export type CommonFieldError = boolean | string | Array<any> | undefined | unkno
6
6
  export type BasicFieldError = Array<any>;
7
7
  export interface BaseFormAdapter<P = Record<string, any>, S = Record<string, any>, Values extends object = any> extends DefaultAdapter<P, S> {
8
8
  cloneDeep: (val: any, ...rest: any[]) => any;
9
- notifySubmit: (values: any) => void;
10
- notifySubmitFail: (errors: Record<keyof Values, BasicFieldError>, values: Partial<Values>) => void;
9
+ notifySubmit: (values: any, e?: any) => void;
10
+ notifySubmitFail: (errors: Record<keyof Values, BasicFieldError>, values: Partial<Values>, e?: any) => void;
11
11
  forceUpdate: (callback?: () => void) => void;
12
12
  notifyChange: (formState: FormState) => void;
13
13
  notifyValueChange: (values: any, changedValues: any) => void;
@@ -109,6 +109,8 @@
109
109
  .semi-image-preview-footer {
110
110
  display: flex;
111
111
  align-items: center;
112
+ }
113
+ .semi-image-preview-footer-content {
112
114
  padding: 0 16px;
113
115
  background: rgba(0, 0, 0, 0.75);
114
116
  border-radius: 6px;
@@ -123,10 +123,14 @@ $module: #{$prefix}-image;
123
123
  &-footer {
124
124
  display: flex;
125
125
  align-items: center;
126
- padding: $spacing-image_preview_footer-paddingY $spacing-image_preview_footer-paddingX;
127
- background: $color-image_preview_footer-bg;
128
- border-radius: $radius-image_preview_footer;
129
- height: $height-image_preview_footer;
126
+
127
+ &-content {
128
+ padding: $spacing-image_preview_footer-paddingY $spacing-image_preview_footer-paddingX;
129
+ background: $color-image_preview_footer-bg;
130
+ border-radius: $radius-image_preview_footer;
131
+ height: $height-image_preview_footer;
132
+ }
133
+
130
134
 
131
135
  &-wrapper {
132
136
  position: absolute;
@@ -22,6 +22,7 @@ export interface PreviewInnerAdapter<P = Record<string, any>, S = Record<string,
22
22
  setMouseActiveTime: (time: number) => void;
23
23
  disabledBodyScroll: () => void;
24
24
  enabledBodyScroll: () => void;
25
+ getSetDownloadFunc: () => (src: string) => string;
25
26
  }
26
27
  export default class PreviewInnerFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<PreviewInnerAdapter<P, S>, P, S> {
27
28
  constructor(adapter: PreviewInnerAdapter<P, S>);
@@ -108,8 +108,9 @@ export default class PreviewInnerFoundation extends BaseFoundation {
108
108
  currentIndex,
109
109
  imgSrc
110
110
  } = this.getStates();
111
+ const setDownloadName = this._adapter.getSetDownloadFunc();
111
112
  const downloadSrc = imgSrc[currentIndex];
112
- const downloadName = downloadSrc.slice(downloadSrc.lastIndexOf("/") + 1);
113
+ const downloadName = setDownloadName ? setDownloadName(downloadSrc) : downloadSrc.slice(downloadSrc.lastIndexOf("/") + 1);
113
114
  downloadImage(downloadSrc, downloadName);
114
115
  this._adapter.notifyDownload(downloadSrc, currentIndex);
115
116
  };
@@ -175,6 +175,7 @@
175
175
  .semi-radio-content {
176
176
  display: flex;
177
177
  flex-direction: column;
178
+ row-gap: 4px;
178
179
  }
179
180
  .semi-radio:hover .semi-radio-inner-display {
180
181
  background: var(--semi-color-fill-0);
@@ -241,6 +241,7 @@ $inner-width: $width-icon-medium;
241
241
  &-content {
242
242
  display: flex;
243
243
  flex-direction: column;
244
+ row-gap: $spacing-radio_content-rowGap;
244
245
  }
245
246
 
246
247
  &:hover {
@@ -77,6 +77,7 @@ $spacing-radio_addon_buttonRadio_middle-paddingX: $spacing-base; // 中尺寸按
77
77
  $spacing-radio_addon_buttonRadio_middle-paddingY: $spacing-extra-tight; // 中尺寸按钮式单选按钮垂直内边距
78
78
  $spacing-radio_addon_buttonRadio_marginLeft: $spacing-none; // 按钮式单选按钮左侧外边距
79
79
  $spacing-radio_extra-paddingLeft: $width-radio_inner + $spacing-tight; // 单选副标题左侧内边距
80
+ $spacing-radio_content-rowGap: 4px; // 内容行间距
80
81
 
81
82
  $spacing-radio_group_vertical-marginBottom: $spacing-base-tight; // 垂直布局单选框组底部外边距
82
83
  $spacing-radio_card_group_vertical-marginBottom: $spacing-base; // 垂直布局卡片式单选框组底部外边距
@@ -158,13 +158,13 @@ class TimePickerFoundation extends BaseFoundation {
158
158
  if (this.isValidTimeZone(timeZone)) {
159
159
  dates = dates.map(date => utcToZonedTime(this.isValidTimeZone(__prevTimeZone) ? zonedTimeToUtc(date, __prevTimeZone) : date, timeZone));
160
160
  }
161
- const inputValue = this.formatValue(dates);
162
- this.setState({
163
- value: dates,
164
- invalid,
165
- inputValue
166
- });
167
161
  }
162
+ const inputValue = this.formatValue(dates);
163
+ this.setState({
164
+ value: dates,
165
+ invalid,
166
+ inputValue
167
+ });
168
168
  }
169
169
  handleFocus(e) {
170
170
  if (!this.getState('open')) {
@@ -25,6 +25,8 @@ export const parseToDate = function (input) {
25
25
  });
26
26
  // console.log(curDate, formatToken);
27
27
  return curDate;
28
+ } else if (typeof input === 'undefined') {
29
+ return undefined;
28
30
  }
29
31
  return new Date();
30
32
  };
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-foundation",
3
- "version": "2.39.3",
3
+ "version": "2.40.0-beta.0",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build:lib": "node ./scripts/compileLib.js",
7
7
  "prepublishOnly": "npm run build:lib"
8
8
  },
9
9
  "dependencies": {
10
- "@douyinfe/semi-animation": "2.39.3",
10
+ "@douyinfe/semi-animation": "2.40.0-beta.0",
11
11
  "async-validator": "^3.5.0",
12
12
  "classnames": "^2.2.6",
13
13
  "date-fns": "^2.29.3",
@@ -23,7 +23,7 @@
23
23
  "*.scss",
24
24
  "*.css"
25
25
  ],
26
- "gitHead": "3f036a160c7c671248a66274c749eeaaf3e92343",
26
+ "gitHead": "f42587885c81ecb266aa0d32d2feaa7633e01e67",
27
27
  "devDependencies": {
28
28
  "@babel/plugin-transform-runtime": "^7.15.8",
29
29
  "@babel/preset-env": "^7.15.8",
package/radio/radio.scss CHANGED
@@ -241,6 +241,7 @@ $inner-width: $width-icon-medium;
241
241
  &-content {
242
242
  display: flex;
243
243
  flex-direction: column;
244
+ row-gap: $spacing-radio_content-rowGap;
244
245
  }
245
246
 
246
247
  &:hover {
@@ -77,6 +77,7 @@ $spacing-radio_addon_buttonRadio_middle-paddingX: $spacing-base; // 中尺寸按
77
77
  $spacing-radio_addon_buttonRadio_middle-paddingY: $spacing-extra-tight; // 中尺寸按钮式单选按钮垂直内边距
78
78
  $spacing-radio_addon_buttonRadio_marginLeft: $spacing-none; // 按钮式单选按钮左侧外边距
79
79
  $spacing-radio_extra-paddingLeft: $width-radio_inner + $spacing-tight; // 单选副标题左侧内边距
80
+ $spacing-radio_content-rowGap: 4px; // 内容行间距
80
81
 
81
82
  $spacing-radio_group_vertical-marginBottom: $spacing-base-tight; // 垂直布局单选框组底部外边距
82
83
  $spacing-radio_card_group_vertical-marginBottom: $spacing-base; // 垂直布局卡片式单选框组底部外边距
@@ -213,14 +213,14 @@ class TimePickerFoundation<P = Record<string, any>, S = Record<string, any>> ext
213
213
  )
214
214
  );
215
215
  }
216
- const inputValue = this.formatValue(dates);
217
-
218
- this.setState({
219
- value: dates,
220
- invalid,
221
- inputValue,
222
- } as any);
223
216
  }
217
+ const inputValue = this.formatValue(dates);
218
+
219
+ this.setState({
220
+ value: dates,
221
+ invalid,
222
+ inputValue,
223
+ } as any);
224
224
  }
225
225
 
226
226
  handleFocus(e: any) {
@@ -25,6 +25,8 @@ export const parseToDate = (input: string | Date | number, formatToken = strings
25
25
  // console.log(curDate, formatToken);
26
26
 
27
27
  return curDate;
28
+ } else if (typeof input === 'undefined') {
29
+ return undefined;
28
30
  }
29
31
 
30
32
  return new Date();