@douyinfe/semi-foundation 2.56.4-alpha.4 → 2.57.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.
- package/form/foundation.ts +1 -0
- package/lib/cjs/form/foundation.d.ts +1 -0
- package/lib/cjs/form/foundation.js +1 -0
- package/lib/cjs/modal/modalFoundation.d.ts +1 -0
- package/lib/cjs/select/foundation.d.ts +5 -1
- package/lib/cjs/select/foundation.js +48 -15
- package/lib/cjs/treeSelect/foundation.d.ts +2 -2
- package/lib/cjs/treeSelect/foundation.js +6 -3
- package/lib/es/form/foundation.d.ts +1 -0
- package/lib/es/form/foundation.js +1 -0
- package/lib/es/modal/modalFoundation.d.ts +1 -0
- package/lib/es/select/foundation.d.ts +5 -1
- package/lib/es/select/foundation.js +48 -15
- package/lib/es/treeSelect/foundation.d.ts +2 -2
- package/lib/es/treeSelect/foundation.js +6 -3
- package/modal/modalFoundation.ts +1 -0
- package/package.json +3 -6
- package/select/foundation.ts +31 -16
- package/treeSelect/foundation.ts +8 -6
- package/lib/cjs/markdownRender/constants.d.ts +0 -5
- package/lib/cjs/markdownRender/constants.js +0 -13
- package/lib/cjs/markdownRender/foundation.d.ts +0 -20
- package/lib/cjs/markdownRender/foundation.js +0 -65
- package/lib/cjs/markdownRender/markdownRender.css +0 -26
- package/lib/cjs/markdownRender/markdownRender.scss +0 -38
- package/lib/cjs/markdownRender/variables.scss +0 -15
- package/lib/es/markdownRender/constants.d.ts +0 -5
- package/lib/es/markdownRender/constants.js +0 -6
- package/lib/es/markdownRender/foundation.d.ts +0 -20
- package/lib/es/markdownRender/foundation.js +0 -57
- package/lib/es/markdownRender/markdownRender.css +0 -26
- package/lib/es/markdownRender/markdownRender.scss +0 -38
- package/lib/es/markdownRender/variables.scss +0 -15
- package/markdownRender/constants.ts +0 -11
- package/markdownRender/foundation.ts +0 -69
- package/markdownRender/markdownRender.scss +0 -38
- package/markdownRender/variables.scss +0 -15
package/form/foundation.ts
CHANGED
|
@@ -613,6 +613,7 @@ export default class FormFoundation extends BaseFoundation<BaseFormAdapter> {
|
|
|
613
613
|
getValue: (field?: string) => this.getValue(field, { needClone: true }),
|
|
614
614
|
getValues: () => this.getValue(undefined, { needClone: true }),
|
|
615
615
|
getFormState: () => this.getFormState(true),
|
|
616
|
+
getFormProps: (props?: Array<string>) => this.getFormProps(props),
|
|
616
617
|
getInitValue: (field: string) => this.getInitValue(field),
|
|
617
618
|
getInitValues: () => this.getInitValues(),
|
|
618
619
|
getTouched: (field?: string) => this.getTouched(field),
|
|
@@ -76,6 +76,7 @@ export default class FormFoundation extends BaseFoundation<BaseFormAdapter> {
|
|
|
76
76
|
getValue: (field?: string) => any;
|
|
77
77
|
getValues: () => any;
|
|
78
78
|
getFormState: () => FormState<any>;
|
|
79
|
+
getFormProps: (props?: Array<string>) => ComponentProps;
|
|
79
80
|
getInitValue: (field: string) => any;
|
|
80
81
|
getInitValues: () => any;
|
|
81
82
|
getTouched: (field?: string) => boolean | Record<string, any>;
|
|
@@ -599,6 +599,7 @@ class FormFoundation extends _foundation.default {
|
|
|
599
599
|
needClone: true
|
|
600
600
|
}),
|
|
601
601
|
getFormState: () => this.getFormState(true),
|
|
602
|
+
getFormProps: props => this.getFormProps(props),
|
|
602
603
|
getInitValue: field => this.getInitValue(field),
|
|
603
604
|
getInitValues: () => this.getInitValues(),
|
|
604
605
|
getTouched: field => this.getTouched(field),
|
|
@@ -71,7 +71,11 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
|
|
|
71
71
|
handleClick(e: any): void;
|
|
72
72
|
open(acInput?: string, originalOptions?: BasicOptionProps[]): void;
|
|
73
73
|
toggle2SearchInput(isShow: boolean): void;
|
|
74
|
-
close(
|
|
74
|
+
close(closeConfig?: {
|
|
75
|
+
event?: any;
|
|
76
|
+
closeCb?: () => void;
|
|
77
|
+
notToggleInput?: boolean;
|
|
78
|
+
}): void;
|
|
75
79
|
onSelect(option: BasicOptionProps, optionIndex: number, event: MouseEvent | KeyboardEvent): void;
|
|
76
80
|
_handleSingleSelect({ value, label, ...rest }: BasicOptionProps, event: any): void;
|
|
77
81
|
_handleMultipleSelect({ value, label, ...rest }: BasicOptionProps, event: MouseEvent | KeyboardEvent): void;
|
|
@@ -323,7 +323,9 @@ class SelectFoundation extends _foundation.default {
|
|
|
323
323
|
this.open();
|
|
324
324
|
this._notifyFocus(e);
|
|
325
325
|
} else if (isOpen && clickToHide) {
|
|
326
|
-
this.close(
|
|
326
|
+
this.close({
|
|
327
|
+
event: e
|
|
328
|
+
});
|
|
327
329
|
} else if (isOpen && !clickToHide) {
|
|
328
330
|
this.focusInput();
|
|
329
331
|
}
|
|
@@ -348,7 +350,9 @@ class SelectFoundation extends _foundation.default {
|
|
|
348
350
|
this._adapter.notifyDropdownVisibleChange(true);
|
|
349
351
|
this.bindKeyBoardEvent();
|
|
350
352
|
this._adapter.registerClickOutsideHandler(e => {
|
|
351
|
-
this.close(
|
|
353
|
+
this.close({
|
|
354
|
+
event: e
|
|
355
|
+
});
|
|
352
356
|
this._notifyBlur(e);
|
|
353
357
|
this._adapter.updateFocusState(false);
|
|
354
358
|
});
|
|
@@ -361,8 +365,13 @@ class SelectFoundation extends _foundation.default {
|
|
|
361
365
|
this._adapter.toggleInputShow(isShow, () => undefined);
|
|
362
366
|
}
|
|
363
367
|
}
|
|
364
|
-
close(
|
|
368
|
+
close(closeConfig) {
|
|
365
369
|
// to support A11y, closing the panel trigger does not necessarily lose focus
|
|
370
|
+
const {
|
|
371
|
+
event,
|
|
372
|
+
closeCb,
|
|
373
|
+
notToggleInput
|
|
374
|
+
} = closeConfig || {};
|
|
366
375
|
this._adapter.closeMenu();
|
|
367
376
|
this._adapter.notifyDropdownVisibleChange(false);
|
|
368
377
|
this._adapter.setIsFocusInContainer(false);
|
|
@@ -371,12 +380,13 @@ class SelectFoundation extends _foundation.default {
|
|
|
371
380
|
// this._adapter.updateFocusState(false);
|
|
372
381
|
this._adapter.unregisterClickOutsideHandler();
|
|
373
382
|
const isFilterable = this._isFilterable();
|
|
374
|
-
|
|
383
|
+
// notToggleInput will only be true when in controlled mode - handleSingeleSelect process
|
|
384
|
+
if (isFilterable && !notToggleInput) {
|
|
375
385
|
this.toggle2SearchInput(false);
|
|
376
386
|
}
|
|
377
387
|
this._adapter.once('popoverClose', () => {
|
|
378
388
|
if (isFilterable) {
|
|
379
|
-
this.clearInput(
|
|
389
|
+
this.clearInput(event);
|
|
380
390
|
}
|
|
381
391
|
if (closeCb) {
|
|
382
392
|
closeCb();
|
|
@@ -419,17 +429,30 @@ class SelectFoundation extends _foundation.default {
|
|
|
419
429
|
// If it is a controlled component, directly notify
|
|
420
430
|
// Make sure that the operations of updating updateOptions are done after the animation ends
|
|
421
431
|
// otherwise the content will be updated when the popup layer is not collapsed, and it looks like it will flash once when it is closed
|
|
432
|
+
const isFilterable = this._isFilterable();
|
|
422
433
|
if (this._isControlledComponent()) {
|
|
423
|
-
this.close(
|
|
424
|
-
|
|
434
|
+
this.close({
|
|
435
|
+
event: event,
|
|
436
|
+
notToggleInput: true,
|
|
437
|
+
closeCb: () => {
|
|
438
|
+
// trigger props.onChange -> update props.value -> updateSelection
|
|
439
|
+
this._notifyChange(selections);
|
|
440
|
+
// make sure toggleSearchInput update after updateSelection in controlled mode, otherwise text in inactive DOM will update quicker than selection, looks like flash text
|
|
441
|
+
if (isFilterable) {
|
|
442
|
+
this.toggle2SearchInput(false);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
425
445
|
});
|
|
426
446
|
} else {
|
|
427
447
|
this._adapter.updateSelection(selections);
|
|
428
448
|
// notify user
|
|
429
449
|
this._notifyChange(selections);
|
|
430
|
-
this.close(
|
|
431
|
-
|
|
432
|
-
|
|
450
|
+
this.close({
|
|
451
|
+
event: event,
|
|
452
|
+
closeCb: () => {
|
|
453
|
+
// Update the selected item in the drop-down box
|
|
454
|
+
this.updateOptionsActiveStatus(selections);
|
|
455
|
+
}
|
|
433
456
|
});
|
|
434
457
|
}
|
|
435
458
|
}
|
|
@@ -729,7 +752,9 @@ class SelectFoundation extends _foundation.default {
|
|
|
729
752
|
this._handleEnterKeyDown(event);
|
|
730
753
|
break;
|
|
731
754
|
case _keyCode.default.ESC:
|
|
732
|
-
isOpen && this.close(
|
|
755
|
+
isOpen && this.close({
|
|
756
|
+
event: event
|
|
757
|
+
});
|
|
733
758
|
filter && !multiple && this._focusTrigger();
|
|
734
759
|
break;
|
|
735
760
|
case _keyCode.default.TAB:
|
|
@@ -823,7 +848,9 @@ class SelectFoundation extends _foundation.default {
|
|
|
823
848
|
}
|
|
824
849
|
} else {
|
|
825
850
|
// there are no focusable elements inside the container, tab to next element and trigger blur
|
|
826
|
-
this.close(
|
|
851
|
+
this.close({
|
|
852
|
+
event: event
|
|
853
|
+
});
|
|
827
854
|
this._notifyBlur(event);
|
|
828
855
|
}
|
|
829
856
|
} else {
|
|
@@ -842,7 +869,9 @@ class SelectFoundation extends _foundation.default {
|
|
|
842
869
|
} else if (activeElement === focusableElements[focusableElements.length - 1]) {
|
|
843
870
|
// focus in the last element in container, focus back to trigger and close panel
|
|
844
871
|
this._focusTrigger();
|
|
845
|
-
this.close(
|
|
872
|
+
this.close({
|
|
873
|
+
event
|
|
874
|
+
});
|
|
846
875
|
(0, _a11y.handlePrevent)(event);
|
|
847
876
|
}
|
|
848
877
|
}
|
|
@@ -851,7 +880,9 @@ class SelectFoundation extends _foundation.default {
|
|
|
851
880
|
const isFocusInContainer = this._adapter.getIsFocusInContainer();
|
|
852
881
|
if (!isFocusInContainer) {
|
|
853
882
|
// focus in trigger, close the panel, shift tab to previe element and trigger blur
|
|
854
|
-
this.close(
|
|
883
|
+
this.close({
|
|
884
|
+
event
|
|
885
|
+
});
|
|
855
886
|
this._notifyBlur(event);
|
|
856
887
|
} else if (activeElement === focusableElements[0]) {
|
|
857
888
|
// focus in the first element in container, focus back to trigger
|
|
@@ -886,7 +917,9 @@ class SelectFoundation extends _foundation.default {
|
|
|
886
917
|
this.onSelect(selectedOption, focusIndex, event);
|
|
887
918
|
}
|
|
888
919
|
} else {
|
|
889
|
-
this.close(
|
|
920
|
+
this.close({
|
|
921
|
+
event
|
|
922
|
+
});
|
|
890
923
|
}
|
|
891
924
|
}
|
|
892
925
|
}
|
|
@@ -69,7 +69,7 @@ export interface BasicTreeSelectProps extends Pick<BasicTreeProps, 'virtualize'
|
|
|
69
69
|
renderSelectedItem?: BasicRenderSelectedItem;
|
|
70
70
|
getPopupContainer?: () => HTMLElement;
|
|
71
71
|
onBlur?: (e: any) => void;
|
|
72
|
-
onSearch?: (sunInput: string, filteredExpandedKeys: string[]) => void;
|
|
72
|
+
onSearch?: (sunInput: string, filteredExpandedKeys: string[], filteredNodes: BasicTreeNodeData[]) => void;
|
|
73
73
|
onChange?: BasicOnChange;
|
|
74
74
|
onFocus?: (e: any) => void;
|
|
75
75
|
onVisibleChange?: (isVisible: boolean) => void;
|
|
@@ -90,7 +90,7 @@ export interface TreeSelectAdapter<P = Record<string, any>, S = Record<string, a
|
|
|
90
90
|
rePositionDropdown: () => void;
|
|
91
91
|
updateState: (states: Partial<BasicTreeSelectInnerData>) => void;
|
|
92
92
|
notifySelect: (selectedKey: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
|
|
93
|
-
notifySearch: (input: string, filteredExpandedKeys: string[]) => void;
|
|
93
|
+
notifySearch: (input: string, filteredExpandedKeys: string[], filteredNodes: BasicTreeNodeData[]) => void;
|
|
94
94
|
cacheFlattenNodes: (bool: boolean) => void;
|
|
95
95
|
openMenu: () => void;
|
|
96
96
|
closeMenu: (cb?: () => void) => void;
|
|
@@ -475,6 +475,7 @@ class TreeSelectFoundation extends _foundation.default {
|
|
|
475
475
|
} = this.getProps();
|
|
476
476
|
const realFilterProp = treeNodeFilterProp !== 'label' ? treeNodeFilterProp : (0, _get2.default)(keyMaps, 'label', 'label');
|
|
477
477
|
const newExpandedKeys = new Set(expandedKeys);
|
|
478
|
+
let filteredNodes = [];
|
|
478
479
|
let filteredOptsKeys = [];
|
|
479
480
|
let expandedOptsKeys = [];
|
|
480
481
|
let newFlattenNodes = [];
|
|
@@ -484,19 +485,21 @@ class TreeSelectFoundation extends _foundation.default {
|
|
|
484
485
|
expandedOptsKeys.forEach(item => newExpandedKeys.add(item));
|
|
485
486
|
newFlattenNodes = (0, _treeUtil.flattenTreeData)(treeData, newExpandedKeys, keyMaps);
|
|
486
487
|
} else {
|
|
487
|
-
|
|
488
|
+
const filteredOpts = Object.values(keyEntities).filter(item => {
|
|
488
489
|
const {
|
|
489
490
|
data
|
|
490
491
|
} = item;
|
|
491
492
|
return (0, _treeUtil.filter)(sugInput, data, filterTreeNode, realFilterProp);
|
|
492
|
-
})
|
|
493
|
+
});
|
|
494
|
+
filteredNodes = filteredOpts.map(item => item.data);
|
|
495
|
+
filteredOptsKeys = filteredOpts.map(item => item.key);
|
|
493
496
|
expandedOptsKeys = (0, _treeUtil.findAncestorKeys)(filteredOptsKeys, keyEntities, false);
|
|
494
497
|
const shownChildKeys = (0, _treeUtil.findDescendantKeys)(filteredOptsKeys, keyEntities, true);
|
|
495
498
|
filteredShownKeys = new Set([...shownChildKeys, ...expandedOptsKeys]);
|
|
496
499
|
newFlattenNodes = (0, _treeUtil.flattenTreeData)(treeData, new Set(expandedOptsKeys), keyMaps, showFilteredOnly && filteredShownKeys);
|
|
497
500
|
}
|
|
498
501
|
const newFilteredExpandedKeys = new Set(expandedOptsKeys);
|
|
499
|
-
this._adapter.notifySearch(sugInput, Array.from(newFilteredExpandedKeys));
|
|
502
|
+
this._adapter.notifySearch(sugInput, Array.from(newFilteredExpandedKeys), filteredNodes);
|
|
500
503
|
this._adapter.updateState({
|
|
501
504
|
expandedKeys: newExpandedKeys,
|
|
502
505
|
flattenNodes: newFlattenNodes,
|
|
@@ -76,6 +76,7 @@ export default class FormFoundation extends BaseFoundation<BaseFormAdapter> {
|
|
|
76
76
|
getValue: (field?: string) => any;
|
|
77
77
|
getValues: () => any;
|
|
78
78
|
getFormState: () => FormState<any>;
|
|
79
|
+
getFormProps: (props?: Array<string>) => ComponentProps;
|
|
79
80
|
getInitValue: (field: string) => any;
|
|
80
81
|
getInitValues: () => any;
|
|
81
82
|
getTouched: (field?: string) => boolean | Record<string, any>;
|
|
@@ -590,6 +590,7 @@ export default class FormFoundation extends BaseFoundation {
|
|
|
590
590
|
needClone: true
|
|
591
591
|
}),
|
|
592
592
|
getFormState: () => this.getFormState(true),
|
|
593
|
+
getFormProps: props => this.getFormProps(props),
|
|
593
594
|
getInitValue: field => this.getInitValue(field),
|
|
594
595
|
getInitValues: () => this.getInitValues(),
|
|
595
596
|
getTouched: field => this.getTouched(field),
|
|
@@ -71,7 +71,11 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
|
|
|
71
71
|
handleClick(e: any): void;
|
|
72
72
|
open(acInput?: string, originalOptions?: BasicOptionProps[]): void;
|
|
73
73
|
toggle2SearchInput(isShow: boolean): void;
|
|
74
|
-
close(
|
|
74
|
+
close(closeConfig?: {
|
|
75
|
+
event?: any;
|
|
76
|
+
closeCb?: () => void;
|
|
77
|
+
notToggleInput?: boolean;
|
|
78
|
+
}): void;
|
|
75
79
|
onSelect(option: BasicOptionProps, optionIndex: number, event: MouseEvent | KeyboardEvent): void;
|
|
76
80
|
_handleSingleSelect({ value, label, ...rest }: BasicOptionProps, event: any): void;
|
|
77
81
|
_handleMultipleSelect({ value, label, ...rest }: BasicOptionProps, event: MouseEvent | KeyboardEvent): void;
|
|
@@ -314,7 +314,9 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
314
314
|
this.open();
|
|
315
315
|
this._notifyFocus(e);
|
|
316
316
|
} else if (isOpen && clickToHide) {
|
|
317
|
-
this.close(
|
|
317
|
+
this.close({
|
|
318
|
+
event: e
|
|
319
|
+
});
|
|
318
320
|
} else if (isOpen && !clickToHide) {
|
|
319
321
|
this.focusInput();
|
|
320
322
|
}
|
|
@@ -339,7 +341,9 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
339
341
|
this._adapter.notifyDropdownVisibleChange(true);
|
|
340
342
|
this.bindKeyBoardEvent();
|
|
341
343
|
this._adapter.registerClickOutsideHandler(e => {
|
|
342
|
-
this.close(
|
|
344
|
+
this.close({
|
|
345
|
+
event: e
|
|
346
|
+
});
|
|
343
347
|
this._notifyBlur(e);
|
|
344
348
|
this._adapter.updateFocusState(false);
|
|
345
349
|
});
|
|
@@ -352,8 +356,13 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
352
356
|
this._adapter.toggleInputShow(isShow, () => undefined);
|
|
353
357
|
}
|
|
354
358
|
}
|
|
355
|
-
close(
|
|
359
|
+
close(closeConfig) {
|
|
356
360
|
// to support A11y, closing the panel trigger does not necessarily lose focus
|
|
361
|
+
const {
|
|
362
|
+
event,
|
|
363
|
+
closeCb,
|
|
364
|
+
notToggleInput
|
|
365
|
+
} = closeConfig || {};
|
|
357
366
|
this._adapter.closeMenu();
|
|
358
367
|
this._adapter.notifyDropdownVisibleChange(false);
|
|
359
368
|
this._adapter.setIsFocusInContainer(false);
|
|
@@ -362,12 +371,13 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
362
371
|
// this._adapter.updateFocusState(false);
|
|
363
372
|
this._adapter.unregisterClickOutsideHandler();
|
|
364
373
|
const isFilterable = this._isFilterable();
|
|
365
|
-
|
|
374
|
+
// notToggleInput will only be true when in controlled mode - handleSingeleSelect process
|
|
375
|
+
if (isFilterable && !notToggleInput) {
|
|
366
376
|
this.toggle2SearchInput(false);
|
|
367
377
|
}
|
|
368
378
|
this._adapter.once('popoverClose', () => {
|
|
369
379
|
if (isFilterable) {
|
|
370
|
-
this.clearInput(
|
|
380
|
+
this.clearInput(event);
|
|
371
381
|
}
|
|
372
382
|
if (closeCb) {
|
|
373
383
|
closeCb();
|
|
@@ -410,17 +420,30 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
410
420
|
// If it is a controlled component, directly notify
|
|
411
421
|
// Make sure that the operations of updating updateOptions are done after the animation ends
|
|
412
422
|
// otherwise the content will be updated when the popup layer is not collapsed, and it looks like it will flash once when it is closed
|
|
423
|
+
const isFilterable = this._isFilterable();
|
|
413
424
|
if (this._isControlledComponent()) {
|
|
414
|
-
this.close(
|
|
415
|
-
|
|
425
|
+
this.close({
|
|
426
|
+
event: event,
|
|
427
|
+
notToggleInput: true,
|
|
428
|
+
closeCb: () => {
|
|
429
|
+
// trigger props.onChange -> update props.value -> updateSelection
|
|
430
|
+
this._notifyChange(selections);
|
|
431
|
+
// make sure toggleSearchInput update after updateSelection in controlled mode, otherwise text in inactive DOM will update quicker than selection, looks like flash text
|
|
432
|
+
if (isFilterable) {
|
|
433
|
+
this.toggle2SearchInput(false);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
416
436
|
});
|
|
417
437
|
} else {
|
|
418
438
|
this._adapter.updateSelection(selections);
|
|
419
439
|
// notify user
|
|
420
440
|
this._notifyChange(selections);
|
|
421
|
-
this.close(
|
|
422
|
-
|
|
423
|
-
|
|
441
|
+
this.close({
|
|
442
|
+
event: event,
|
|
443
|
+
closeCb: () => {
|
|
444
|
+
// Update the selected item in the drop-down box
|
|
445
|
+
this.updateOptionsActiveStatus(selections);
|
|
446
|
+
}
|
|
424
447
|
});
|
|
425
448
|
}
|
|
426
449
|
}
|
|
@@ -720,7 +743,9 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
720
743
|
this._handleEnterKeyDown(event);
|
|
721
744
|
break;
|
|
722
745
|
case KeyCode.ESC:
|
|
723
|
-
isOpen && this.close(
|
|
746
|
+
isOpen && this.close({
|
|
747
|
+
event: event
|
|
748
|
+
});
|
|
724
749
|
filter && !multiple && this._focusTrigger();
|
|
725
750
|
break;
|
|
726
751
|
case KeyCode.TAB:
|
|
@@ -814,7 +839,9 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
814
839
|
}
|
|
815
840
|
} else {
|
|
816
841
|
// there are no focusable elements inside the container, tab to next element and trigger blur
|
|
817
|
-
this.close(
|
|
842
|
+
this.close({
|
|
843
|
+
event: event
|
|
844
|
+
});
|
|
818
845
|
this._notifyBlur(event);
|
|
819
846
|
}
|
|
820
847
|
} else {
|
|
@@ -833,7 +860,9 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
833
860
|
} else if (activeElement === focusableElements[focusableElements.length - 1]) {
|
|
834
861
|
// focus in the last element in container, focus back to trigger and close panel
|
|
835
862
|
this._focusTrigger();
|
|
836
|
-
this.close(
|
|
863
|
+
this.close({
|
|
864
|
+
event
|
|
865
|
+
});
|
|
837
866
|
handlePrevent(event);
|
|
838
867
|
}
|
|
839
868
|
}
|
|
@@ -842,7 +871,9 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
842
871
|
const isFocusInContainer = this._adapter.getIsFocusInContainer();
|
|
843
872
|
if (!isFocusInContainer) {
|
|
844
873
|
// focus in trigger, close the panel, shift tab to previe element and trigger blur
|
|
845
|
-
this.close(
|
|
874
|
+
this.close({
|
|
875
|
+
event
|
|
876
|
+
});
|
|
846
877
|
this._notifyBlur(event);
|
|
847
878
|
} else if (activeElement === focusableElements[0]) {
|
|
848
879
|
// focus in the first element in container, focus back to trigger
|
|
@@ -877,7 +908,9 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
877
908
|
this.onSelect(selectedOption, focusIndex, event);
|
|
878
909
|
}
|
|
879
910
|
} else {
|
|
880
|
-
this.close(
|
|
911
|
+
this.close({
|
|
912
|
+
event
|
|
913
|
+
});
|
|
881
914
|
}
|
|
882
915
|
}
|
|
883
916
|
}
|
|
@@ -69,7 +69,7 @@ export interface BasicTreeSelectProps extends Pick<BasicTreeProps, 'virtualize'
|
|
|
69
69
|
renderSelectedItem?: BasicRenderSelectedItem;
|
|
70
70
|
getPopupContainer?: () => HTMLElement;
|
|
71
71
|
onBlur?: (e: any) => void;
|
|
72
|
-
onSearch?: (sunInput: string, filteredExpandedKeys: string[]) => void;
|
|
72
|
+
onSearch?: (sunInput: string, filteredExpandedKeys: string[], filteredNodes: BasicTreeNodeData[]) => void;
|
|
73
73
|
onChange?: BasicOnChange;
|
|
74
74
|
onFocus?: (e: any) => void;
|
|
75
75
|
onVisibleChange?: (isVisible: boolean) => void;
|
|
@@ -90,7 +90,7 @@ export interface TreeSelectAdapter<P = Record<string, any>, S = Record<string, a
|
|
|
90
90
|
rePositionDropdown: () => void;
|
|
91
91
|
updateState: (states: Partial<BasicTreeSelectInnerData>) => void;
|
|
92
92
|
notifySelect: (selectedKey: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
|
|
93
|
-
notifySearch: (input: string, filteredExpandedKeys: string[]) => void;
|
|
93
|
+
notifySearch: (input: string, filteredExpandedKeys: string[], filteredNodes: BasicTreeNodeData[]) => void;
|
|
94
94
|
cacheFlattenNodes: (bool: boolean) => void;
|
|
95
95
|
openMenu: () => void;
|
|
96
96
|
closeMenu: (cb?: () => void) => void;
|
|
@@ -468,6 +468,7 @@ export default class TreeSelectFoundation extends BaseFoundation {
|
|
|
468
468
|
} = this.getProps();
|
|
469
469
|
const realFilterProp = treeNodeFilterProp !== 'label' ? treeNodeFilterProp : _get(keyMaps, 'label', 'label');
|
|
470
470
|
const newExpandedKeys = new Set(expandedKeys);
|
|
471
|
+
let filteredNodes = [];
|
|
471
472
|
let filteredOptsKeys = [];
|
|
472
473
|
let expandedOptsKeys = [];
|
|
473
474
|
let newFlattenNodes = [];
|
|
@@ -477,19 +478,21 @@ export default class TreeSelectFoundation extends BaseFoundation {
|
|
|
477
478
|
expandedOptsKeys.forEach(item => newExpandedKeys.add(item));
|
|
478
479
|
newFlattenNodes = flattenTreeData(treeData, newExpandedKeys, keyMaps);
|
|
479
480
|
} else {
|
|
480
|
-
|
|
481
|
+
const filteredOpts = Object.values(keyEntities).filter(item => {
|
|
481
482
|
const {
|
|
482
483
|
data
|
|
483
484
|
} = item;
|
|
484
485
|
return filter(sugInput, data, filterTreeNode, realFilterProp);
|
|
485
|
-
})
|
|
486
|
+
});
|
|
487
|
+
filteredNodes = filteredOpts.map(item => item.data);
|
|
488
|
+
filteredOptsKeys = filteredOpts.map(item => item.key);
|
|
486
489
|
expandedOptsKeys = findAncestorKeys(filteredOptsKeys, keyEntities, false);
|
|
487
490
|
const shownChildKeys = findDescendantKeys(filteredOptsKeys, keyEntities, true);
|
|
488
491
|
filteredShownKeys = new Set([...shownChildKeys, ...expandedOptsKeys]);
|
|
489
492
|
newFlattenNodes = flattenTreeData(treeData, new Set(expandedOptsKeys), keyMaps, showFilteredOnly && filteredShownKeys);
|
|
490
493
|
}
|
|
491
494
|
const newFilteredExpandedKeys = new Set(expandedOptsKeys);
|
|
492
|
-
this._adapter.notifySearch(sugInput, Array.from(newFilteredExpandedKeys));
|
|
495
|
+
this._adapter.notifySearch(sugInput, Array.from(newFilteredExpandedKeys), filteredNodes);
|
|
493
496
|
this._adapter.updateState({
|
|
494
497
|
expandedKeys: newExpandedKeys,
|
|
495
498
|
flattenNodes: newFlattenNodes,
|
package/modal/modalFoundation.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-foundation",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.57.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.
|
|
11
|
-
"@mdx-js/mdx": "^3.0.1",
|
|
10
|
+
"@douyinfe/semi-animation": "2.57.0-beta.0",
|
|
12
11
|
"async-validator": "^3.5.0",
|
|
13
12
|
"classnames": "^2.2.6",
|
|
14
13
|
"date-fns": "^2.29.3",
|
|
@@ -16,7 +15,6 @@
|
|
|
16
15
|
"fast-copy": "^3.0.1 ",
|
|
17
16
|
"lodash": "^4.17.21",
|
|
18
17
|
"memoize-one": "^5.2.1",
|
|
19
|
-
"remark-gfm": "^4.0.0",
|
|
20
18
|
"scroll-into-view-if-needed": "^2.2.24"
|
|
21
19
|
},
|
|
22
20
|
"keywords": [],
|
|
@@ -26,12 +24,11 @@
|
|
|
26
24
|
"*.scss",
|
|
27
25
|
"*.css"
|
|
28
26
|
],
|
|
29
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "416d798f9c062670475631c9ffce2172e7abfd60",
|
|
30
28
|
"devDependencies": {
|
|
31
29
|
"@babel/plugin-transform-runtime": "^7.15.8",
|
|
32
30
|
"@babel/preset-env": "^7.15.8",
|
|
33
31
|
"@types/lodash": "^4.14.176",
|
|
34
|
-
"@types/mdx": "^2.0.13",
|
|
35
32
|
"babel-plugin-lodash": "^3.3.4",
|
|
36
33
|
"del": "^6.0.0",
|
|
37
34
|
"gulp": "^4.0.2",
|
package/select/foundation.ts
CHANGED
|
@@ -346,7 +346,7 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
|
|
|
346
346
|
this.open();
|
|
347
347
|
this._notifyFocus(e);
|
|
348
348
|
} else if (isOpen && clickToHide) {
|
|
349
|
-
this.close(e);
|
|
349
|
+
this.close({ event: e });
|
|
350
350
|
} else if (isOpen && !clickToHide) {
|
|
351
351
|
this.focusInput();
|
|
352
352
|
}
|
|
@@ -374,7 +374,7 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
|
|
|
374
374
|
this.bindKeyBoardEvent();
|
|
375
375
|
|
|
376
376
|
this._adapter.registerClickOutsideHandler((e: MouseEvent) => {
|
|
377
|
-
this.close(e);
|
|
377
|
+
this.close({ event: e });
|
|
378
378
|
this._notifyBlur(e);
|
|
379
379
|
this._adapter.updateFocusState(false);
|
|
380
380
|
});
|
|
@@ -389,9 +389,9 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
|
|
|
389
389
|
}
|
|
390
390
|
}
|
|
391
391
|
|
|
392
|
-
close(
|
|
392
|
+
close(closeConfig?: { event?: any; closeCb?: () => void; notToggleInput?: boolean }) {
|
|
393
393
|
// to support A11y, closing the panel trigger does not necessarily lose focus
|
|
394
|
-
|
|
394
|
+
const { event, closeCb, notToggleInput } = closeConfig || {};
|
|
395
395
|
this._adapter.closeMenu();
|
|
396
396
|
this._adapter.notifyDropdownVisibleChange(false);
|
|
397
397
|
this._adapter.setIsFocusInContainer(false);
|
|
@@ -401,13 +401,14 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
|
|
|
401
401
|
this._adapter.unregisterClickOutsideHandler();
|
|
402
402
|
|
|
403
403
|
const isFilterable = this._isFilterable();
|
|
404
|
-
|
|
404
|
+
// notToggleInput will only be true when in controlled mode - handleSingeleSelect process
|
|
405
|
+
if (isFilterable && !notToggleInput) {
|
|
405
406
|
this.toggle2SearchInput(false);
|
|
406
407
|
}
|
|
407
408
|
|
|
408
409
|
this._adapter.once('popoverClose', () => {
|
|
409
410
|
if (isFilterable) {
|
|
410
|
-
this.clearInput(
|
|
411
|
+
this.clearInput(event);
|
|
411
412
|
}
|
|
412
413
|
if (closeCb) {
|
|
413
414
|
closeCb();
|
|
@@ -443,18 +444,32 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
|
|
|
443
444
|
// If it is a controlled component, directly notify
|
|
444
445
|
// Make sure that the operations of updating updateOptions are done after the animation ends
|
|
445
446
|
// otherwise the content will be updated when the popup layer is not collapsed, and it looks like it will flash once when it is closed
|
|
447
|
+
const isFilterable = this._isFilterable();
|
|
448
|
+
|
|
446
449
|
if (this._isControlledComponent()) {
|
|
447
|
-
this.close(
|
|
448
|
-
|
|
450
|
+
this.close({
|
|
451
|
+
event: event,
|
|
452
|
+
notToggleInput: true,
|
|
453
|
+
closeCb: () => {
|
|
454
|
+
// trigger props.onChange -> update props.value -> updateSelection
|
|
455
|
+
this._notifyChange(selections);
|
|
456
|
+
// make sure toggleSearchInput update after updateSelection in controlled mode, otherwise text in inactive DOM will update quicker than selection, looks like flash text
|
|
457
|
+
if (isFilterable) {
|
|
458
|
+
this.toggle2SearchInput(false);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
449
461
|
});
|
|
450
462
|
} else {
|
|
451
463
|
this._adapter.updateSelection(selections);
|
|
452
464
|
// notify user
|
|
453
465
|
this._notifyChange(selections);
|
|
454
466
|
|
|
455
|
-
this.close(
|
|
456
|
-
|
|
457
|
-
|
|
467
|
+
this.close({
|
|
468
|
+
event: event,
|
|
469
|
+
closeCb: () => {
|
|
470
|
+
// Update the selected item in the drop-down box
|
|
471
|
+
this.updateOptionsActiveStatus(selections);
|
|
472
|
+
},
|
|
458
473
|
});
|
|
459
474
|
}
|
|
460
475
|
}
|
|
@@ -730,7 +745,7 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
|
|
|
730
745
|
this._handleEnterKeyDown(event);
|
|
731
746
|
break;
|
|
732
747
|
case KeyCode.ESC:
|
|
733
|
-
isOpen && this.close(event);
|
|
748
|
+
isOpen && this.close({ event: event });
|
|
734
749
|
filter && !multiple && this._focusTrigger();
|
|
735
750
|
break;
|
|
736
751
|
case KeyCode.TAB:
|
|
@@ -822,7 +837,7 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
|
|
|
822
837
|
}
|
|
823
838
|
} else {
|
|
824
839
|
// there are no focusable elements inside the container, tab to next element and trigger blur
|
|
825
|
-
this.close(event);
|
|
840
|
+
this.close({ event: event });
|
|
826
841
|
this._notifyBlur(event);
|
|
827
842
|
}
|
|
828
843
|
} else {
|
|
@@ -842,7 +857,7 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
|
|
|
842
857
|
} else if (activeElement === focusableElements[focusableElements.length - 1]) {
|
|
843
858
|
// focus in the last element in container, focus back to trigger and close panel
|
|
844
859
|
this._focusTrigger();
|
|
845
|
-
this.close(event);
|
|
860
|
+
this.close({ event });
|
|
846
861
|
handlePrevent(event);
|
|
847
862
|
}
|
|
848
863
|
}
|
|
@@ -853,7 +868,7 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
|
|
|
853
868
|
|
|
854
869
|
if (!isFocusInContainer) {
|
|
855
870
|
// focus in trigger, close the panel, shift tab to previe element and trigger blur
|
|
856
|
-
this.close(event);
|
|
871
|
+
this.close({ event });
|
|
857
872
|
this._notifyBlur(event);
|
|
858
873
|
} else if (activeElement === focusableElements[0]) {
|
|
859
874
|
// focus in the first element in container, focus back to trigger
|
|
@@ -883,7 +898,7 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
|
|
|
883
898
|
this.onSelect(selectedOption, focusIndex, event);
|
|
884
899
|
}
|
|
885
900
|
} else {
|
|
886
|
-
this.close(event);
|
|
901
|
+
this.close({ event });
|
|
887
902
|
}
|
|
888
903
|
}
|
|
889
904
|
}
|
package/treeSelect/foundation.ts
CHANGED
|
@@ -139,7 +139,7 @@ export interface BasicTreeSelectProps extends Pick<BasicTreeProps,
|
|
|
139
139
|
getPopupContainer?: () => HTMLElement;
|
|
140
140
|
// triggerRender?: (props: BasicTriggerRenderProps) => any;
|
|
141
141
|
onBlur?: (e: any) => void;
|
|
142
|
-
onSearch?: (sunInput: string, filteredExpandedKeys: string[]) => void;
|
|
142
|
+
onSearch?: (sunInput: string, filteredExpandedKeys: string[], filteredNodes: BasicTreeNodeData[]) => void;
|
|
143
143
|
onChange?: BasicOnChange;
|
|
144
144
|
onFocus?: (e: any) => void;
|
|
145
145
|
onVisibleChange?: (isVisible: boolean) => void;
|
|
@@ -183,7 +183,7 @@ export interface TreeSelectAdapter<P = Record<string, any>, S = Record<string, a
|
|
|
183
183
|
rePositionDropdown: () => void;
|
|
184
184
|
updateState: (states: Partial<BasicTreeSelectInnerData>) => void;
|
|
185
185
|
notifySelect: (selectedKey: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
|
|
186
|
-
notifySearch: (input: string, filteredExpandedKeys: string[]) => void;
|
|
186
|
+
notifySearch: (input: string, filteredExpandedKeys: string[], filteredNodes: BasicTreeNodeData[]) => void;
|
|
187
187
|
cacheFlattenNodes: (bool: boolean) => void;
|
|
188
188
|
openMenu: () => void;
|
|
189
189
|
closeMenu: (cb?: () => void) => void;
|
|
@@ -613,6 +613,7 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
613
613
|
const { showFilteredOnly, filterTreeNode, treeNodeFilterProp, keyMaps } = this.getProps();
|
|
614
614
|
const realFilterProp = treeNodeFilterProp !== 'label' ? treeNodeFilterProp : get(keyMaps, 'label', 'label');
|
|
615
615
|
const newExpandedKeys: Set<string> = new Set(expandedKeys);
|
|
616
|
+
let filteredNodes: BasicTreeNodeData[] = [];
|
|
616
617
|
let filteredOptsKeys: string[] = [];
|
|
617
618
|
let expandedOptsKeys = [];
|
|
618
619
|
let newFlattenNodes = [];
|
|
@@ -622,19 +623,20 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
622
623
|
expandedOptsKeys.forEach(item => newExpandedKeys.add(item));
|
|
623
624
|
newFlattenNodes = flattenTreeData(treeData, newExpandedKeys, keyMaps);
|
|
624
625
|
} else {
|
|
625
|
-
|
|
626
|
+
const filteredOpts = Object.values(keyEntities)
|
|
626
627
|
.filter((item: BasicKeyEntity) => {
|
|
627
628
|
const { data } = item;
|
|
628
629
|
return filter(sugInput, data, filterTreeNode, realFilterProp);
|
|
629
|
-
})
|
|
630
|
-
|
|
630
|
+
});
|
|
631
|
+
filteredNodes = filteredOpts.map((item: BasicKeyEntity) => item.data);
|
|
632
|
+
filteredOptsKeys = filteredOpts.map((item: BasicKeyEntity) => item.key);
|
|
631
633
|
expandedOptsKeys = findAncestorKeys(filteredOptsKeys, keyEntities, false);
|
|
632
634
|
const shownChildKeys = findDescendantKeys(filteredOptsKeys, keyEntities, true);
|
|
633
635
|
filteredShownKeys = new Set([...shownChildKeys, ...expandedOptsKeys]);
|
|
634
636
|
newFlattenNodes = flattenTreeData(treeData, new Set(expandedOptsKeys), keyMaps, showFilteredOnly && filteredShownKeys);
|
|
635
637
|
}
|
|
636
638
|
const newFilteredExpandedKeys = new Set(expandedOptsKeys);
|
|
637
|
-
this._adapter.notifySearch(sugInput, Array.from(newFilteredExpandedKeys));
|
|
639
|
+
this._adapter.notifySearch(sugInput, Array.from(newFilteredExpandedKeys), filteredNodes);
|
|
638
640
|
this._adapter.updateState({
|
|
639
641
|
expandedKeys: newExpandedKeys,
|
|
640
642
|
flattenNodes: newFlattenNodes,
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.strings = exports.cssClasses = void 0;
|
|
7
|
-
var _constants = require("../base/constants");
|
|
8
|
-
const cssClasses = {
|
|
9
|
-
PREFIX: `${_constants.BASE_CLASS_PREFIX}-markdownRender`
|
|
10
|
-
};
|
|
11
|
-
exports.cssClasses = cssClasses;
|
|
12
|
-
const strings = {};
|
|
13
|
-
exports.strings = strings;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import BaseFoundation, { DefaultAdapter } from '../base/foundation';
|
|
2
|
-
import { MDXProps } from 'mdx/types';
|
|
3
|
-
export interface MarkdownRenderAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
|
|
4
|
-
getRuntime: () => any;
|
|
5
|
-
}
|
|
6
|
-
export interface MarkdownRenderBaseProps {
|
|
7
|
-
raw: string;
|
|
8
|
-
components: MDXProps['components'];
|
|
9
|
-
format: "md" | "mdx";
|
|
10
|
-
}
|
|
11
|
-
export interface MarkdownRenderBaseState {
|
|
12
|
-
MDXContentComponent: any;
|
|
13
|
-
}
|
|
14
|
-
declare class MarkdownRenderFoundation extends BaseFoundation<MarkdownRenderAdapter> {
|
|
15
|
-
private getOptions;
|
|
16
|
-
compile: (mdxRaw: string) => Promise<import("vfile").VFile>;
|
|
17
|
-
evaluate: (mdxRaw: string) => Promise<import("mdx/types").MDXContent>;
|
|
18
|
-
evaluateSync: (mdxRaw: string) => import("mdx/types").MDXContent;
|
|
19
|
-
}
|
|
20
|
-
export default MarkdownRenderFoundation;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _foundation = _interopRequireDefault(require("../base/foundation"));
|
|
8
|
-
var _mdx = require("@mdx-js/mdx");
|
|
9
|
-
var _remarkGfm = _interopRequireDefault(require("remark-gfm"));
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
|
|
12
|
-
function adopt(value) {
|
|
13
|
-
return value instanceof P ? value : new P(function (resolve) {
|
|
14
|
-
resolve(value);
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
18
|
-
function fulfilled(value) {
|
|
19
|
-
try {
|
|
20
|
-
step(generator.next(value));
|
|
21
|
-
} catch (e) {
|
|
22
|
-
reject(e);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
function rejected(value) {
|
|
26
|
-
try {
|
|
27
|
-
step(generator["throw"](value));
|
|
28
|
-
} catch (e) {
|
|
29
|
-
reject(e);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
function step(result) {
|
|
33
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
34
|
-
}
|
|
35
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
class MarkdownRenderFoundation extends _foundation.default {
|
|
39
|
-
constructor() {
|
|
40
|
-
super(...arguments);
|
|
41
|
-
this.getOptions = () => {
|
|
42
|
-
return {
|
|
43
|
-
evaluateOptions: {
|
|
44
|
-
remarkPlugins: [_remarkGfm.default],
|
|
45
|
-
format: this.getProp("format")
|
|
46
|
-
},
|
|
47
|
-
compileOptions: {
|
|
48
|
-
format: this.getProp("format")
|
|
49
|
-
},
|
|
50
|
-
runOptions: {}
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
this.compile = mdxRaw => __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
return yield (0, _mdx.compile)(mdxRaw, this.getOptions().compileOptions);
|
|
55
|
-
});
|
|
56
|
-
this.evaluate = mdxRaw => __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
return (yield (0, _mdx.evaluate)(mdxRaw, Object.assign(Object.assign(Object.assign({}, this.getOptions().runOptions), this.getOptions().evaluateOptions), this._adapter.getRuntime()))).default;
|
|
58
|
-
});
|
|
59
|
-
this.evaluateSync = mdxRaw => {
|
|
60
|
-
return (0, _mdx.evaluateSync)(mdxRaw, Object.assign(Object.assign(Object.assign({}, this.getOptions().runOptions), this.getOptions().evaluateOptions), this._adapter.getRuntime())).default;
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
var _default = MarkdownRenderFoundation;
|
|
65
|
-
exports.default = _default;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/* shadow */
|
|
2
|
-
/* sizing */
|
|
3
|
-
/* spacing */
|
|
4
|
-
.semi-markdownRender ul, .semi-markdownRender li {
|
|
5
|
-
color: var(--semi-color-text-0);
|
|
6
|
-
}
|
|
7
|
-
.semi-markdownRender-component-image {
|
|
8
|
-
margin: 16px 16px 16px 16px;
|
|
9
|
-
max-width: 50%;
|
|
10
|
-
max-height: 500px;
|
|
11
|
-
display: flex;
|
|
12
|
-
flex-direction: column;
|
|
13
|
-
justify-content: center;
|
|
14
|
-
}
|
|
15
|
-
.semi-markdownRender-component-image-alt {
|
|
16
|
-
margin-top: 8px;
|
|
17
|
-
text-align: center;
|
|
18
|
-
color: var(--semi-color-tertiary);
|
|
19
|
-
}
|
|
20
|
-
.semi-markdownRender .semi-markdownRender-component-header {
|
|
21
|
-
margin-top: 16px;
|
|
22
|
-
margin-bottom: 16px;
|
|
23
|
-
}
|
|
24
|
-
.semi-markdownRender-component-p strong {
|
|
25
|
-
font-weight: 600;
|
|
26
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
@import "./variables.scss";
|
|
2
|
-
|
|
3
|
-
$module: #{$prefix}-markdownRender;
|
|
4
|
-
|
|
5
|
-
.#{$module} {
|
|
6
|
-
|
|
7
|
-
ul, li {
|
|
8
|
-
color: $color-markdownRender_component_list
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
&-component-image {
|
|
12
|
-
margin: $spacing-markdownRender_component_image-marginTop $spacing-markdownRender_component_image-marginRight $spacing-markdownRender_component_image-marginBottom $spacing-markdownRender_component_image-marginLeft;
|
|
13
|
-
max-width: $width-markdownRender_component_image-maxWidth;
|
|
14
|
-
max-height: $width-markdownRender_component_image-maxHeight;
|
|
15
|
-
display: flex;
|
|
16
|
-
flex-direction: column;
|
|
17
|
-
justify-content: center;
|
|
18
|
-
|
|
19
|
-
&-alt {
|
|
20
|
-
margin-top: $spacing-markdownRender_component_image_alt-marginTop;
|
|
21
|
-
text-align: center;
|
|
22
|
-
color: $color-markdownRender_component_image_alt;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
& &-component-header {
|
|
27
|
-
margin-top: $spacing-markdownRender_component_header-marginTop;
|
|
28
|
-
margin-bottom: $spacing-markdownRender_component_header-marginBottom;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
&-component-p {
|
|
32
|
-
strong {
|
|
33
|
-
font-weight: $font-weight-bold;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
$spacing-markdownRender_component_image-marginLeft: 16px;
|
|
2
|
-
$spacing-markdownRender_component_image-marginRight: 16px;
|
|
3
|
-
$spacing-markdownRender_component_image-marginTop: 16px;
|
|
4
|
-
$spacing-markdownRender_component_image-marginBottom: 16px;
|
|
5
|
-
$width-markdownRender_component_image-maxWidth: 50%;
|
|
6
|
-
$width-markdownRender_component_image-maxHeight: 500px;
|
|
7
|
-
$spacing-markdownRender_component_image_alt-marginTop: 8px;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
$spacing-markdownRender_component_header-marginTop: 16px;
|
|
11
|
-
$spacing-markdownRender_component_header-marginBottom: 16px;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
$color-markdownRender_component_list: var(--semi-color-text-0);
|
|
15
|
-
$color-markdownRender_component_image_alt: var(--semi-color-tertiary);
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import BaseFoundation, { DefaultAdapter } from '../base/foundation';
|
|
2
|
-
import { MDXProps } from 'mdx/types';
|
|
3
|
-
export interface MarkdownRenderAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
|
|
4
|
-
getRuntime: () => any;
|
|
5
|
-
}
|
|
6
|
-
export interface MarkdownRenderBaseProps {
|
|
7
|
-
raw: string;
|
|
8
|
-
components: MDXProps['components'];
|
|
9
|
-
format: "md" | "mdx";
|
|
10
|
-
}
|
|
11
|
-
export interface MarkdownRenderBaseState {
|
|
12
|
-
MDXContentComponent: any;
|
|
13
|
-
}
|
|
14
|
-
declare class MarkdownRenderFoundation extends BaseFoundation<MarkdownRenderAdapter> {
|
|
15
|
-
private getOptions;
|
|
16
|
-
compile: (mdxRaw: string) => Promise<import("vfile").VFile>;
|
|
17
|
-
evaluate: (mdxRaw: string) => Promise<import("mdx/types").MDXContent>;
|
|
18
|
-
evaluateSync: (mdxRaw: string) => import("mdx/types").MDXContent;
|
|
19
|
-
}
|
|
20
|
-
export default MarkdownRenderFoundation;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) {
|
|
3
|
-
return value instanceof P ? value : new P(function (resolve) {
|
|
4
|
-
resolve(value);
|
|
5
|
-
});
|
|
6
|
-
}
|
|
7
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
8
|
-
function fulfilled(value) {
|
|
9
|
-
try {
|
|
10
|
-
step(generator.next(value));
|
|
11
|
-
} catch (e) {
|
|
12
|
-
reject(e);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
function rejected(value) {
|
|
16
|
-
try {
|
|
17
|
-
step(generator["throw"](value));
|
|
18
|
-
} catch (e) {
|
|
19
|
-
reject(e);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
function step(result) {
|
|
23
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
24
|
-
}
|
|
25
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
import BaseFoundation from '../base/foundation';
|
|
29
|
-
import { evaluate, compile, evaluateSync } from '@mdx-js/mdx';
|
|
30
|
-
import remarkGfm from 'remark-gfm';
|
|
31
|
-
class MarkdownRenderFoundation extends BaseFoundation {
|
|
32
|
-
constructor() {
|
|
33
|
-
super(...arguments);
|
|
34
|
-
this.getOptions = () => {
|
|
35
|
-
return {
|
|
36
|
-
evaluateOptions: {
|
|
37
|
-
remarkPlugins: [remarkGfm],
|
|
38
|
-
format: this.getProp("format")
|
|
39
|
-
},
|
|
40
|
-
compileOptions: {
|
|
41
|
-
format: this.getProp("format")
|
|
42
|
-
},
|
|
43
|
-
runOptions: {}
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
this.compile = mdxRaw => __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
return yield compile(mdxRaw, this.getOptions().compileOptions);
|
|
48
|
-
});
|
|
49
|
-
this.evaluate = mdxRaw => __awaiter(this, void 0, void 0, function* () {
|
|
50
|
-
return (yield evaluate(mdxRaw, Object.assign(Object.assign(Object.assign({}, this.getOptions().runOptions), this.getOptions().evaluateOptions), this._adapter.getRuntime()))).default;
|
|
51
|
-
});
|
|
52
|
-
this.evaluateSync = mdxRaw => {
|
|
53
|
-
return evaluateSync(mdxRaw, Object.assign(Object.assign(Object.assign({}, this.getOptions().runOptions), this.getOptions().evaluateOptions), this._adapter.getRuntime())).default;
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
export default MarkdownRenderFoundation;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/* shadow */
|
|
2
|
-
/* sizing */
|
|
3
|
-
/* spacing */
|
|
4
|
-
.semi-markdownRender ul, .semi-markdownRender li {
|
|
5
|
-
color: var(--semi-color-text-0);
|
|
6
|
-
}
|
|
7
|
-
.semi-markdownRender-component-image {
|
|
8
|
-
margin: 16px 16px 16px 16px;
|
|
9
|
-
max-width: 50%;
|
|
10
|
-
max-height: 500px;
|
|
11
|
-
display: flex;
|
|
12
|
-
flex-direction: column;
|
|
13
|
-
justify-content: center;
|
|
14
|
-
}
|
|
15
|
-
.semi-markdownRender-component-image-alt {
|
|
16
|
-
margin-top: 8px;
|
|
17
|
-
text-align: center;
|
|
18
|
-
color: var(--semi-color-tertiary);
|
|
19
|
-
}
|
|
20
|
-
.semi-markdownRender .semi-markdownRender-component-header {
|
|
21
|
-
margin-top: 16px;
|
|
22
|
-
margin-bottom: 16px;
|
|
23
|
-
}
|
|
24
|
-
.semi-markdownRender-component-p strong {
|
|
25
|
-
font-weight: 600;
|
|
26
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
@import "./variables.scss";
|
|
2
|
-
|
|
3
|
-
$module: #{$prefix}-markdownRender;
|
|
4
|
-
|
|
5
|
-
.#{$module} {
|
|
6
|
-
|
|
7
|
-
ul, li {
|
|
8
|
-
color: $color-markdownRender_component_list
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
&-component-image {
|
|
12
|
-
margin: $spacing-markdownRender_component_image-marginTop $spacing-markdownRender_component_image-marginRight $spacing-markdownRender_component_image-marginBottom $spacing-markdownRender_component_image-marginLeft;
|
|
13
|
-
max-width: $width-markdownRender_component_image-maxWidth;
|
|
14
|
-
max-height: $width-markdownRender_component_image-maxHeight;
|
|
15
|
-
display: flex;
|
|
16
|
-
flex-direction: column;
|
|
17
|
-
justify-content: center;
|
|
18
|
-
|
|
19
|
-
&-alt {
|
|
20
|
-
margin-top: $spacing-markdownRender_component_image_alt-marginTop;
|
|
21
|
-
text-align: center;
|
|
22
|
-
color: $color-markdownRender_component_image_alt;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
& &-component-header {
|
|
27
|
-
margin-top: $spacing-markdownRender_component_header-marginTop;
|
|
28
|
-
margin-bottom: $spacing-markdownRender_component_header-marginBottom;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
&-component-p {
|
|
32
|
-
strong {
|
|
33
|
-
font-weight: $font-weight-bold;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
$spacing-markdownRender_component_image-marginLeft: 16px;
|
|
2
|
-
$spacing-markdownRender_component_image-marginRight: 16px;
|
|
3
|
-
$spacing-markdownRender_component_image-marginTop: 16px;
|
|
4
|
-
$spacing-markdownRender_component_image-marginBottom: 16px;
|
|
5
|
-
$width-markdownRender_component_image-maxWidth: 50%;
|
|
6
|
-
$width-markdownRender_component_image-maxHeight: 500px;
|
|
7
|
-
$spacing-markdownRender_component_image_alt-marginTop: 8px;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
$spacing-markdownRender_component_header-marginTop: 16px;
|
|
11
|
-
$spacing-markdownRender_component_header-marginBottom: 16px;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
$color-markdownRender_component_list: var(--semi-color-text-0);
|
|
15
|
-
$color-markdownRender_component_image_alt: var(--semi-color-tertiary);
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import BaseFoundation, { DefaultAdapter } from '../base/foundation';
|
|
2
|
-
import { CompileOptions, evaluate, compile, EvaluateOptions, evaluateSync, RunOptions } from '@mdx-js/mdx';
|
|
3
|
-
import { MDXProps } from 'mdx/types';
|
|
4
|
-
import remarkGfm from 'remark-gfm';
|
|
5
|
-
export interface MarkdownRenderAdapter <P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
|
|
6
|
-
getRuntime: () => any
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export interface MarkdownRenderBaseProps{
|
|
14
|
-
raw: string;
|
|
15
|
-
components: MDXProps['components'];
|
|
16
|
-
format: "md"|"mdx"
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export interface MarkdownRenderBaseState{
|
|
21
|
-
MDXContentComponent: any
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
class MarkdownRenderFoundation extends BaseFoundation<MarkdownRenderAdapter> {
|
|
25
|
-
|
|
26
|
-
private getOptions = ()=>{
|
|
27
|
-
return {
|
|
28
|
-
evaluateOptions: {
|
|
29
|
-
remarkPlugins: [remarkGfm],
|
|
30
|
-
format: this.getProp("format")
|
|
31
|
-
},
|
|
32
|
-
compileOptions: {
|
|
33
|
-
format: this.getProp("format")
|
|
34
|
-
},
|
|
35
|
-
runOptions: {
|
|
36
|
-
}
|
|
37
|
-
} as {
|
|
38
|
-
evaluateOptions: EvaluateOptions;
|
|
39
|
-
compileOptions: CompileOptions;
|
|
40
|
-
runOptions: RunOptions
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
compile = async (mdxRaw: string)=>{
|
|
45
|
-
return await compile(mdxRaw, this.getOptions().compileOptions);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
evaluate = async (mdxRaw: string)=>{
|
|
49
|
-
return (await evaluate(mdxRaw, {
|
|
50
|
-
...this.getOptions().runOptions,
|
|
51
|
-
...this.getOptions().evaluateOptions,
|
|
52
|
-
...this._adapter.getRuntime()
|
|
53
|
-
})).default;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
evaluateSync = (mdxRaw: string)=>{
|
|
57
|
-
return ( evaluateSync(mdxRaw, {
|
|
58
|
-
...this.getOptions().runOptions,
|
|
59
|
-
...this.getOptions().evaluateOptions,
|
|
60
|
-
...this._adapter.getRuntime()
|
|
61
|
-
})).default;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export default MarkdownRenderFoundation;
|
|
69
|
-
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
@import "./variables.scss";
|
|
2
|
-
|
|
3
|
-
$module: #{$prefix}-markdownRender;
|
|
4
|
-
|
|
5
|
-
.#{$module} {
|
|
6
|
-
|
|
7
|
-
ul, li {
|
|
8
|
-
color: $color-markdownRender_component_list
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
&-component-image {
|
|
12
|
-
margin: $spacing-markdownRender_component_image-marginTop $spacing-markdownRender_component_image-marginRight $spacing-markdownRender_component_image-marginBottom $spacing-markdownRender_component_image-marginLeft;
|
|
13
|
-
max-width: $width-markdownRender_component_image-maxWidth;
|
|
14
|
-
max-height: $width-markdownRender_component_image-maxHeight;
|
|
15
|
-
display: flex;
|
|
16
|
-
flex-direction: column;
|
|
17
|
-
justify-content: center;
|
|
18
|
-
|
|
19
|
-
&-alt {
|
|
20
|
-
margin-top: $spacing-markdownRender_component_image_alt-marginTop;
|
|
21
|
-
text-align: center;
|
|
22
|
-
color: $color-markdownRender_component_image_alt;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
& &-component-header {
|
|
27
|
-
margin-top: $spacing-markdownRender_component_header-marginTop;
|
|
28
|
-
margin-bottom: $spacing-markdownRender_component_header-marginBottom;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
&-component-p {
|
|
32
|
-
strong {
|
|
33
|
-
font-weight: $font-weight-bold;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
$spacing-markdownRender_component_image-marginLeft: 16px;
|
|
2
|
-
$spacing-markdownRender_component_image-marginRight: 16px;
|
|
3
|
-
$spacing-markdownRender_component_image-marginTop: 16px;
|
|
4
|
-
$spacing-markdownRender_component_image-marginBottom: 16px;
|
|
5
|
-
$width-markdownRender_component_image-maxWidth: 50%;
|
|
6
|
-
$width-markdownRender_component_image-maxHeight: 500px;
|
|
7
|
-
$spacing-markdownRender_component_image_alt-marginTop: 8px;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
$spacing-markdownRender_component_header-marginTop: 16px;
|
|
11
|
-
$spacing-markdownRender_component_header-marginBottom: 16px;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
$color-markdownRender_component_list: var(--semi-color-text-0);
|
|
15
|
-
$color-markdownRender_component_image_alt: var(--semi-color-tertiary);
|