@sellmate/design-system-react 1.0.62 → 1.0.64
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/README.md +1 -1
- package/dist/components/components.d.ts +55 -13
- package/dist/components/components.js +97 -19
- package/dist/components/components.server.d.ts +55 -13
- package/dist/components/components.server.js +144 -18
- package/dist/hooks/useSdTableVirtualScroll.d.ts +11 -0
- package/dist/hooks/useSdTableVirtualScroll.js +56 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +2 -1
- package/dist/sdModal.d.ts +2 -1
- package/dist/sdModal.js +4 -6
- package/lib/components/components.server.ts +220 -72
- package/lib/components/components.ts +147 -28
- package/lib/hooks/useSdTableVirtualScroll.ts +82 -0
- package/lib/index.ts +4 -3
- package/lib/sdModal.ts +6 -9
- package/package.json +2 -2
- package/dist/SdTable.d.ts +0 -40
- package/dist/SdTable.js +0 -74
- package/lib/SdTable.tsx +0 -185
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
/* eslint-disable */
|
|
9
9
|
|
|
10
|
-
import { type CheckedType, type DateRangeValue, type DropdownButtonValue, type Event, type RadioValue, type SdBarcodeInputCustomEvent, type SdButtonCustomEvent, type SdButtonV2CustomEvent, type SdCheckboxCustomEvent, type SdDateRangePickerCustomEvent, type SdDropdownButtonCustomEvent, type SdFilePickerCustomEvent, type SdGhostButtonCustomEvent, type SdInputCustomEvent, type SdNumberInputCustomEvent, type
|
|
10
|
+
import { type CheckedType, type DateRangeValue, type DropdownButtonValue, type Event, type RadioValue, type Row, type SdBarcodeInputCustomEvent, type SdButtonCustomEvent, type SdButtonV2CustomEvent, type SdCheckboxCustomEvent, type SdDateRangePickerCustomEvent, type SdDropdownButtonCustomEvent, type SdFilePickerCustomEvent, type SdGhostButtonCustomEvent, type SdInputCustomEvent, type SdNumberInputCustomEvent, type SdRadioButtonCustomEvent, type SdRadioCustomEvent, type SdRadioGroupCustomEvent, type SdSelectCustomEvent, type SdSelectDropdownCustomEvent, type SdSelectGroupCustomEvent, type SdSelectMultipleCustomEvent, type SdSelectMultipleGroupCustomEvent, type SdSelectOptionCustomEvent, type SdSelectOptionGroupCustomEvent, type SdSelectV2CustomEvent, type SdSelectV2ListItemCustomEvent, type SdSelectV2ListboxCustomEvent, type SdTableCustomEvent, type SdTextareaCustomEvent, type SelectEvents, type SelectMultipleEvents, type SelectOption, type SelectOptionGroup, type SelectV2Option, type SelectV2OptionSelectDetail, type SelectV2Value } from "@sellmate/design-system";
|
|
11
11
|
import { SdActionModal as SdActionModalElement, defineCustomElement as defineSdActionModal } from "@sellmate/design-system/dist/components/sd-action-modal.js";
|
|
12
12
|
import { SdBadge as SdBadgeElement, defineCustomElement as defineSdBadge } from "@sellmate/design-system/dist/components/sd-badge.js";
|
|
13
13
|
import { SdBarcodeInput as SdBarcodeInputElement, defineCustomElement as defineSdBarcodeInput } from "@sellmate/design-system/dist/components/sd-barcode-input.js";
|
|
@@ -16,6 +16,7 @@ import { SdButton as SdButtonElement, defineCustomElement as defineSdButton } fr
|
|
|
16
16
|
import { SdCalendar as SdCalendarElement, defineCustomElement as defineSdCalendar } from "@sellmate/design-system/dist/components/sd-calendar.js";
|
|
17
17
|
import { SdCard as SdCardElement, defineCustomElement as defineSdCard } from "@sellmate/design-system/dist/components/sd-card.js";
|
|
18
18
|
import { SdCheckbox as SdCheckboxElement, defineCustomElement as defineSdCheckbox } from "@sellmate/design-system/dist/components/sd-checkbox.js";
|
|
19
|
+
import { SdCircleProgress as SdCircleProgressElement, defineCustomElement as defineSdCircleProgress } from "@sellmate/design-system/dist/components/sd-circle-progress.js";
|
|
19
20
|
import { SdConfirmModal as SdConfirmModalElement, defineCustomElement as defineSdConfirmModal } from "@sellmate/design-system/dist/components/sd-confirm-modal.js";
|
|
20
21
|
import { SdDateBox as SdDateBoxElement, defineCustomElement as defineSdDateBox } from "@sellmate/design-system/dist/components/sd-date-box.js";
|
|
21
22
|
import { SdDatePickerCalendar as SdDatePickerCalendarElement, defineCustomElement as defineSdDatePickerCalendar } from "@sellmate/design-system/dist/components/sd-date-picker-calendar.js";
|
|
@@ -32,14 +33,15 @@ import { SdGhostButton as SdGhostButtonElement, defineCustomElement as defineSdG
|
|
|
32
33
|
import { SdGuide as SdGuideElement, defineCustomElement as defineSdGuide } from "@sellmate/design-system/dist/components/sd-guide.js";
|
|
33
34
|
import { SdIcon as SdIconElement, defineCustomElement as defineSdIcon } from "@sellmate/design-system/dist/components/sd-icon.js";
|
|
34
35
|
import { SdInput as SdInputElement, defineCustomElement as defineSdInput } from "@sellmate/design-system/dist/components/sd-input.js";
|
|
35
|
-
import {
|
|
36
|
+
import { SdLoadingContainer as SdLoadingContainerElement, defineCustomElement as defineSdLoadingContainer } from "@sellmate/design-system/dist/components/sd-loading-container.js";
|
|
37
|
+
import { SdLoadingModal as SdLoadingModalElement, defineCustomElement as defineSdLoadingModal } from "@sellmate/design-system/dist/components/sd-loading-modal.js";
|
|
36
38
|
import { SdModalContainer as SdModalContainerElement, defineCustomElement as defineSdModalContainer } from "@sellmate/design-system/dist/components/sd-modal-container.js";
|
|
37
39
|
import { SdNumberInput as SdNumberInputElement, defineCustomElement as defineSdNumberInput } from "@sellmate/design-system/dist/components/sd-number-input.js";
|
|
38
40
|
import { SdPagination as SdPaginationElement, defineCustomElement as defineSdPagination } from "@sellmate/design-system/dist/components/sd-pagination.js";
|
|
39
41
|
import { SdPopover as SdPopoverElement, defineCustomElement as defineSdPopover } from "@sellmate/design-system/dist/components/sd-popover.js";
|
|
40
42
|
import { SdPortal as SdPortalElement, defineCustomElement as defineSdPortal } from "@sellmate/design-system/dist/components/sd-portal.js";
|
|
41
43
|
import { SdProgress as SdProgressElement, defineCustomElement as defineSdProgress } from "@sellmate/design-system/dist/components/sd-progress.js";
|
|
42
|
-
import {
|
|
44
|
+
import { SdRadioButton as SdRadioButtonElement, defineCustomElement as defineSdRadioButton } from "@sellmate/design-system/dist/components/sd-radio-button.js";
|
|
43
45
|
import { SdRadioGroup as SdRadioGroupElement, defineCustomElement as defineSdRadioGroup } from "@sellmate/design-system/dist/components/sd-radio-group.js";
|
|
44
46
|
import { SdRadio as SdRadioElement, defineCustomElement as defineSdRadio } from "@sellmate/design-system/dist/components/sd-radio.js";
|
|
45
47
|
import { SdSelectDropdown as SdSelectDropdownElement, defineCustomElement as defineSdSelectDropdown } from "@sellmate/design-system/dist/components/sd-select-dropdown.js";
|
|
@@ -55,15 +57,21 @@ import { SdSelectV2Listbox as SdSelectV2ListboxElement, defineCustomElement as d
|
|
|
55
57
|
import { SdSelectV2Trigger as SdSelectV2TriggerElement, defineCustomElement as defineSdSelectV2Trigger } from "@sellmate/design-system/dist/components/sd-select-v2-trigger.js";
|
|
56
58
|
import { SdSelectV2 as SdSelectV2Element, defineCustomElement as defineSdSelectV2 } from "@sellmate/design-system/dist/components/sd-select-v2.js";
|
|
57
59
|
import { SdSelect as SdSelectElement, defineCustomElement as defineSdSelect } from "@sellmate/design-system/dist/components/sd-select.js";
|
|
60
|
+
import { SdSwitch as SdSwitchElement, defineCustomElement as defineSdSwitch } from "@sellmate/design-system/dist/components/sd-switch.js";
|
|
61
|
+
import { SdTable as SdTableElement, defineCustomElement as defineSdTable } from "@sellmate/design-system/dist/components/sd-table.js";
|
|
58
62
|
import { SdTabs as SdTabsElement, defineCustomElement as defineSdTabs } from "@sellmate/design-system/dist/components/sd-tabs.js";
|
|
59
63
|
import { SdTag as SdTagElement, defineCustomElement as defineSdTag } from "@sellmate/design-system/dist/components/sd-tag.js";
|
|
64
|
+
import { SdTbody as SdTbodyElement, defineCustomElement as defineSdTbody } from "@sellmate/design-system/dist/components/sd-tbody.js";
|
|
65
|
+
import { SdTd as SdTdElement, defineCustomElement as defineSdTd } from "@sellmate/design-system/dist/components/sd-td.js";
|
|
60
66
|
import { SdTextLink as SdTextLinkElement, defineCustomElement as defineSdTextLink } from "@sellmate/design-system/dist/components/sd-text-link.js";
|
|
61
67
|
import { SdTextarea as SdTextareaElement, defineCustomElement as defineSdTextarea } from "@sellmate/design-system/dist/components/sd-textarea.js";
|
|
68
|
+
import { SdThead as SdTheadElement, defineCustomElement as defineSdThead } from "@sellmate/design-system/dist/components/sd-thead.js";
|
|
62
69
|
import { SdToastContainer as SdToastContainerElement, defineCustomElement as defineSdToastContainer } from "@sellmate/design-system/dist/components/sd-toast-container.js";
|
|
63
70
|
import { SdToast as SdToastElement, defineCustomElement as defineSdToast } from "@sellmate/design-system/dist/components/sd-toast.js";
|
|
64
|
-
import { SdToggleButton as SdToggleButtonElement, defineCustomElement as defineSdToggleButton } from "@sellmate/design-system/dist/components/sd-toggle-button.js";
|
|
65
71
|
import { SdToggle as SdToggleElement, defineCustomElement as defineSdToggle } from "@sellmate/design-system/dist/components/sd-toggle.js";
|
|
66
72
|
import { SdTooltip as SdTooltipElement, defineCustomElement as defineSdTooltip } from "@sellmate/design-system/dist/components/sd-tooltip.js";
|
|
73
|
+
import { SdTr as SdTrElement, defineCustomElement as defineSdTr } from "@sellmate/design-system/dist/components/sd-tr.js";
|
|
74
|
+
import { TableTest as TableTestElement, defineCustomElement as defineTableTest } from "@sellmate/design-system/dist/components/table-test.js";
|
|
67
75
|
import type { EventName, StencilReactComponent } from '@stencil/react-output-target/runtime';
|
|
68
76
|
import { createComponent } from '@stencil/react-output-target/runtime';
|
|
69
77
|
import React from 'react';
|
|
@@ -176,6 +184,17 @@ export const SdCheckbox: StencilReactComponent<SdCheckboxElement, SdCheckboxEven
|
|
|
176
184
|
defineCustomElement: defineSdCheckbox
|
|
177
185
|
});
|
|
178
186
|
|
|
187
|
+
export type SdCircleProgressEvents = NonNullable<unknown>;
|
|
188
|
+
|
|
189
|
+
export const SdCircleProgress: StencilReactComponent<SdCircleProgressElement, SdCircleProgressEvents> = /*@__PURE__*/ createComponent<SdCircleProgressElement, SdCircleProgressEvents>({
|
|
190
|
+
tagName: 'sd-circle-progress',
|
|
191
|
+
elementClass: SdCircleProgressElement,
|
|
192
|
+
// @ts-ignore - ignore potential React type mismatches between the Stencil Output Target and your project.
|
|
193
|
+
react: React,
|
|
194
|
+
events: {} as SdCircleProgressEvents,
|
|
195
|
+
defineCustomElement: defineSdCircleProgress
|
|
196
|
+
});
|
|
197
|
+
|
|
179
198
|
export type SdConfirmModalEvents = {
|
|
180
199
|
onSdClose: EventName<CustomEvent<void>>,
|
|
181
200
|
onSdCancel: EventName<CustomEvent<void>>,
|
|
@@ -321,7 +340,10 @@ export const SdField: StencilReactComponent<SdFieldElement, SdFieldEvents> = /*@
|
|
|
321
340
|
|
|
322
341
|
export type SdFilePickerEvents = {
|
|
323
342
|
onSdUpdate: EventName<SdFilePickerCustomEvent<File[] | File | null>>,
|
|
324
|
-
onSdReject: EventName<SdFilePickerCustomEvent<{
|
|
343
|
+
onSdReject: EventName<SdFilePickerCustomEvent<{
|
|
344
|
+
files: File[];
|
|
345
|
+
reason: 'max-file-size' | 'max-total-size' | 'max-files';
|
|
346
|
+
}>>
|
|
325
347
|
};
|
|
326
348
|
|
|
327
349
|
export const SdFilePicker: StencilReactComponent<SdFilePickerElement, SdFilePickerEvents> = /*@__PURE__*/ createComponent<SdFilePickerElement, SdFilePickerEvents>({
|
|
@@ -416,15 +438,26 @@ export const SdInput: StencilReactComponent<SdInputElement, SdInputEvents> = /*@
|
|
|
416
438
|
defineCustomElement: defineSdInput
|
|
417
439
|
});
|
|
418
440
|
|
|
419
|
-
export type
|
|
441
|
+
export type SdLoadingContainerEvents = NonNullable<unknown>;
|
|
442
|
+
|
|
443
|
+
export const SdLoadingContainer: StencilReactComponent<SdLoadingContainerElement, SdLoadingContainerEvents> = /*@__PURE__*/ createComponent<SdLoadingContainerElement, SdLoadingContainerEvents>({
|
|
444
|
+
tagName: 'sd-loading-container',
|
|
445
|
+
elementClass: SdLoadingContainerElement,
|
|
446
|
+
// @ts-ignore - ignore potential React type mismatches between the Stencil Output Target and your project.
|
|
447
|
+
react: React,
|
|
448
|
+
events: {} as SdLoadingContainerEvents,
|
|
449
|
+
defineCustomElement: defineSdLoadingContainer
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
export type SdLoadingModalEvents = { onSdClick: EventName<CustomEvent<void>> };
|
|
420
453
|
|
|
421
|
-
export const
|
|
422
|
-
tagName: 'sd-loading-
|
|
423
|
-
elementClass:
|
|
454
|
+
export const SdLoadingModal: StencilReactComponent<SdLoadingModalElement, SdLoadingModalEvents> = /*@__PURE__*/ createComponent<SdLoadingModalElement, SdLoadingModalEvents>({
|
|
455
|
+
tagName: 'sd-loading-modal',
|
|
456
|
+
elementClass: SdLoadingModalElement,
|
|
424
457
|
// @ts-ignore - ignore potential React type mismatches between the Stencil Output Target and your project.
|
|
425
458
|
react: React,
|
|
426
|
-
events: {} as
|
|
427
|
-
defineCustomElement:
|
|
459
|
+
events: { onSdClick: 'sdClick' } as SdLoadingModalEvents,
|
|
460
|
+
defineCustomElement: defineSdLoadingModal
|
|
428
461
|
});
|
|
429
462
|
|
|
430
463
|
export type SdModalContainerEvents = NonNullable<unknown>;
|
|
@@ -512,15 +545,15 @@ export const SdRadio: StencilReactComponent<SdRadioElement, SdRadioEvents> = /*@
|
|
|
512
545
|
defineCustomElement: defineSdRadio
|
|
513
546
|
});
|
|
514
547
|
|
|
515
|
-
export type
|
|
548
|
+
export type SdRadioButtonEvents = { onSdUpdate: EventName<SdRadioButtonCustomEvent<RadioValue>> };
|
|
516
549
|
|
|
517
|
-
export const
|
|
518
|
-
tagName: 'sd-radio-button
|
|
519
|
-
elementClass:
|
|
550
|
+
export const SdRadioButton: StencilReactComponent<SdRadioButtonElement, SdRadioButtonEvents> = /*@__PURE__*/ createComponent<SdRadioButtonElement, SdRadioButtonEvents>({
|
|
551
|
+
tagName: 'sd-radio-button',
|
|
552
|
+
elementClass: SdRadioButtonElement,
|
|
520
553
|
// @ts-ignore - ignore potential React type mismatches between the Stencil Output Target and your project.
|
|
521
554
|
react: React,
|
|
522
|
-
events: { onSdUpdate: 'sdUpdate' } as
|
|
523
|
-
defineCustomElement:
|
|
555
|
+
events: { onSdUpdate: 'sdUpdate' } as SdRadioButtonEvents,
|
|
556
|
+
defineCustomElement: defineSdRadioButton
|
|
524
557
|
});
|
|
525
558
|
|
|
526
559
|
export type SdRadioGroupEvents = { onSdUpdate: EventName<SdRadioGroupCustomEvent<RadioValue>> };
|
|
@@ -744,6 +777,48 @@ export const SdSelectV2Trigger: StencilReactComponent<SdSelectV2TriggerElement,
|
|
|
744
777
|
defineCustomElement: defineSdSelectV2Trigger
|
|
745
778
|
});
|
|
746
779
|
|
|
780
|
+
export type SdSwitchEvents = { onSdUpdate: EventName<CustomEvent<boolean>> };
|
|
781
|
+
|
|
782
|
+
export const SdSwitch: StencilReactComponent<SdSwitchElement, SdSwitchEvents> = /*@__PURE__*/ createComponent<SdSwitchElement, SdSwitchEvents>({
|
|
783
|
+
tagName: 'sd-switch',
|
|
784
|
+
elementClass: SdSwitchElement,
|
|
785
|
+
// @ts-ignore - ignore potential React type mismatches between the Stencil Output Target and your project.
|
|
786
|
+
react: React,
|
|
787
|
+
events: { onSdUpdate: 'sdUpdate' } as SdSwitchEvents,
|
|
788
|
+
defineCustomElement: defineSdSwitch
|
|
789
|
+
});
|
|
790
|
+
|
|
791
|
+
export type SdTableEvents = {
|
|
792
|
+
onSdSelectChange: EventName<SdTableCustomEvent<Row[]>>,
|
|
793
|
+
onSdPageChange: EventName<CustomEvent<number>>,
|
|
794
|
+
onSdRowsPerPageChange: EventName<CustomEvent<number>>,
|
|
795
|
+
onSdVirtualUpdate: EventName<CustomEvent<{
|
|
796
|
+
from: number;
|
|
797
|
+
to: number;
|
|
798
|
+
}>>,
|
|
799
|
+
onSdVirtualReachEnd: EventName<CustomEvent<{
|
|
800
|
+
from: number;
|
|
801
|
+
to: number;
|
|
802
|
+
rowCount: number;
|
|
803
|
+
threshold: number;
|
|
804
|
+
}>>
|
|
805
|
+
};
|
|
806
|
+
|
|
807
|
+
export const SdTable: StencilReactComponent<SdTableElement, SdTableEvents> = /*@__PURE__*/ createComponent<SdTableElement, SdTableEvents>({
|
|
808
|
+
tagName: 'sd-table',
|
|
809
|
+
elementClass: SdTableElement,
|
|
810
|
+
// @ts-ignore - ignore potential React type mismatches between the Stencil Output Target and your project.
|
|
811
|
+
react: React,
|
|
812
|
+
events: {
|
|
813
|
+
onSdSelectChange: 'sdSelectChange',
|
|
814
|
+
onSdPageChange: 'sdPageChange',
|
|
815
|
+
onSdRowsPerPageChange: 'sdRowsPerPageChange',
|
|
816
|
+
onSdVirtualUpdate: 'sdVirtualUpdate',
|
|
817
|
+
onSdVirtualReachEnd: 'sdVirtualReachEnd'
|
|
818
|
+
} as SdTableEvents,
|
|
819
|
+
defineCustomElement: defineSdTable
|
|
820
|
+
});
|
|
821
|
+
|
|
747
822
|
export type SdTabsEvents = { onSdUpdate: EventName<CustomEvent<string>> };
|
|
748
823
|
|
|
749
824
|
export const SdTabs: StencilReactComponent<SdTabsElement, SdTabsEvents> = /*@__PURE__*/ createComponent<SdTabsElement, SdTabsEvents>({
|
|
@@ -766,6 +841,28 @@ export const SdTag: StencilReactComponent<SdTagElement, SdTagEvents> = /*@__PURE
|
|
|
766
841
|
defineCustomElement: defineSdTag
|
|
767
842
|
});
|
|
768
843
|
|
|
844
|
+
export type SdTbodyEvents = NonNullable<unknown>;
|
|
845
|
+
|
|
846
|
+
export const SdTbody: StencilReactComponent<SdTbodyElement, SdTbodyEvents> = /*@__PURE__*/ createComponent<SdTbodyElement, SdTbodyEvents>({
|
|
847
|
+
tagName: 'sd-tbody',
|
|
848
|
+
elementClass: SdTbodyElement,
|
|
849
|
+
// @ts-ignore - ignore potential React type mismatches between the Stencil Output Target and your project.
|
|
850
|
+
react: React,
|
|
851
|
+
events: {} as SdTbodyEvents,
|
|
852
|
+
defineCustomElement: defineSdTbody
|
|
853
|
+
});
|
|
854
|
+
|
|
855
|
+
export type SdTdEvents = NonNullable<unknown>;
|
|
856
|
+
|
|
857
|
+
export const SdTd: StencilReactComponent<SdTdElement, SdTdEvents> = /*@__PURE__*/ createComponent<SdTdElement, SdTdEvents>({
|
|
858
|
+
tagName: 'sd-td',
|
|
859
|
+
elementClass: SdTdElement,
|
|
860
|
+
// @ts-ignore - ignore potential React type mismatches between the Stencil Output Target and your project.
|
|
861
|
+
react: React,
|
|
862
|
+
events: {} as SdTdEvents,
|
|
863
|
+
defineCustomElement: defineSdTd
|
|
864
|
+
});
|
|
865
|
+
|
|
769
866
|
export type SdTextLinkEvents = { onSdClick: EventName<CustomEvent<void>> };
|
|
770
867
|
|
|
771
868
|
export const SdTextLink: StencilReactComponent<SdTextLinkElement, SdTextLinkEvents> = /*@__PURE__*/ createComponent<SdTextLinkElement, SdTextLinkEvents>({
|
|
@@ -796,6 +893,17 @@ export const SdTextarea: StencilReactComponent<SdTextareaElement, SdTextareaEven
|
|
|
796
893
|
defineCustomElement: defineSdTextarea
|
|
797
894
|
});
|
|
798
895
|
|
|
896
|
+
export type SdTheadEvents = NonNullable<unknown>;
|
|
897
|
+
|
|
898
|
+
export const SdThead: StencilReactComponent<SdTheadElement, SdTheadEvents> = /*@__PURE__*/ createComponent<SdTheadElement, SdTheadEvents>({
|
|
899
|
+
tagName: 'sd-thead',
|
|
900
|
+
elementClass: SdTheadElement,
|
|
901
|
+
// @ts-ignore - ignore potential React type mismatches between the Stencil Output Target and your project.
|
|
902
|
+
react: React,
|
|
903
|
+
events: {} as SdTheadEvents,
|
|
904
|
+
defineCustomElement: defineSdThead
|
|
905
|
+
});
|
|
906
|
+
|
|
799
907
|
export type SdToastEvents = { onSdClose: EventName<CustomEvent<void>> };
|
|
800
908
|
|
|
801
909
|
export const SdToast: StencilReactComponent<SdToastElement, SdToastEvents> = /*@__PURE__*/ createComponent<SdToastElement, SdToastEvents>({
|
|
@@ -835,17 +943,6 @@ export const SdToggle: StencilReactComponent<SdToggleElement, SdToggleEvents> =
|
|
|
835
943
|
defineCustomElement: defineSdToggle
|
|
836
944
|
});
|
|
837
945
|
|
|
838
|
-
export type SdToggleButtonEvents = { onSdUpdate: EventName<CustomEvent<boolean>> };
|
|
839
|
-
|
|
840
|
-
export const SdToggleButton: StencilReactComponent<SdToggleButtonElement, SdToggleButtonEvents> = /*@__PURE__*/ createComponent<SdToggleButtonElement, SdToggleButtonEvents>({
|
|
841
|
-
tagName: 'sd-toggle-button',
|
|
842
|
-
elementClass: SdToggleButtonElement,
|
|
843
|
-
// @ts-ignore - ignore potential React type mismatches between the Stencil Output Target and your project.
|
|
844
|
-
react: React,
|
|
845
|
-
events: { onSdUpdate: 'sdUpdate' } as SdToggleButtonEvents,
|
|
846
|
-
defineCustomElement: defineSdToggleButton
|
|
847
|
-
});
|
|
848
|
-
|
|
849
946
|
export type SdTooltipEvents = NonNullable<unknown>;
|
|
850
947
|
|
|
851
948
|
export const SdTooltip: StencilReactComponent<SdTooltipElement, SdTooltipEvents> = /*@__PURE__*/ createComponent<SdTooltipElement, SdTooltipEvents>({
|
|
@@ -856,3 +953,25 @@ export const SdTooltip: StencilReactComponent<SdTooltipElement, SdTooltipEvents>
|
|
|
856
953
|
events: {} as SdTooltipEvents,
|
|
857
954
|
defineCustomElement: defineSdTooltip
|
|
858
955
|
});
|
|
956
|
+
|
|
957
|
+
export type SdTrEvents = NonNullable<unknown>;
|
|
958
|
+
|
|
959
|
+
export const SdTr: StencilReactComponent<SdTrElement, SdTrEvents> = /*@__PURE__*/ createComponent<SdTrElement, SdTrEvents>({
|
|
960
|
+
tagName: 'sd-tr',
|
|
961
|
+
elementClass: SdTrElement,
|
|
962
|
+
// @ts-ignore - ignore potential React type mismatches between the Stencil Output Target and your project.
|
|
963
|
+
react: React,
|
|
964
|
+
events: {} as SdTrEvents,
|
|
965
|
+
defineCustomElement: defineSdTr
|
|
966
|
+
});
|
|
967
|
+
|
|
968
|
+
export type TableTestEvents = { onTableReady: EventName<CustomEvent<void>> };
|
|
969
|
+
|
|
970
|
+
export const TableTest: StencilReactComponent<TableTestElement, TableTestEvents> = /*@__PURE__*/ createComponent<TableTestElement, TableTestEvents>({
|
|
971
|
+
tagName: 'table-test',
|
|
972
|
+
elementClass: TableTestElement,
|
|
973
|
+
// @ts-ignore - ignore potential React type mismatches between the Stencil Output Target and your project.
|
|
974
|
+
react: React,
|
|
975
|
+
events: { onTableReady: 'tableReady' } as TableTestEvents,
|
|
976
|
+
defineCustomElement: defineTableTest
|
|
977
|
+
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { useEffect, useMemo, useState, type RefObject } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface VirtualRow<T = Record<string, any>> {
|
|
4
|
+
/** 전체 rows 기준 절대 인덱스 — SdTr의 rowKey로 사용 */
|
|
5
|
+
index: number;
|
|
6
|
+
row: T;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface SdVirtualUpdateDetail {
|
|
10
|
+
from: number;
|
|
11
|
+
to: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function useSdTableVirtualScroll<T extends Record<string, any>>(
|
|
15
|
+
tableRef: RefObject<HTMLElement | null>,
|
|
16
|
+
rows: T[],
|
|
17
|
+
) {
|
|
18
|
+
const [range, setRange] = useState<{ from: number; to: number } | null>(null);
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
let targetEl: HTMLElement | null = null;
|
|
22
|
+
let rafId = 0;
|
|
23
|
+
|
|
24
|
+
const onVirtualUpdate = (e: Event) => {
|
|
25
|
+
const { from, to } = (e as CustomEvent<SdVirtualUpdateDetail>).detail;
|
|
26
|
+
setRange({ from, to });
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const syncRange = (el: HTMLElement): boolean => {
|
|
30
|
+
const currentRange = (el as any).getVirtualScrollRangeSync?.();
|
|
31
|
+
if (
|
|
32
|
+
currentRange &&
|
|
33
|
+
typeof currentRange.from === 'number' &&
|
|
34
|
+
typeof currentRange.to === 'number'
|
|
35
|
+
) {
|
|
36
|
+
setRange({ from: currentRange.from, to: currentRange.to });
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const attachWhenReady = () => {
|
|
43
|
+
const el = tableRef.current;
|
|
44
|
+
if (!el) {
|
|
45
|
+
rafId = requestAnimationFrame(attachWhenReady);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
targetEl = el;
|
|
50
|
+
targetEl.addEventListener('sdVirtualUpdate', onVirtualUpdate);
|
|
51
|
+
|
|
52
|
+
const trySync = () => {
|
|
53
|
+
if (!targetEl) return;
|
|
54
|
+
if (!syncRange(targetEl)) {
|
|
55
|
+
rafId = requestAnimationFrame(trySync);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
trySync();
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
attachWhenReady();
|
|
63
|
+
|
|
64
|
+
return () => {
|
|
65
|
+
cancelAnimationFrame(rafId);
|
|
66
|
+
targetEl?.removeEventListener('sdVirtualUpdate', onVirtualUpdate);
|
|
67
|
+
};
|
|
68
|
+
}, [tableRef]);
|
|
69
|
+
|
|
70
|
+
const virtualRows = useMemo<VirtualRow<T>[]>(() => {
|
|
71
|
+
if (!range) return [];
|
|
72
|
+
return rows
|
|
73
|
+
.slice(range.from, range.to)
|
|
74
|
+
.map((row, i) => ({ index: range.from + i, row }));
|
|
75
|
+
}, [rows, range]);
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
virtualRows,
|
|
79
|
+
from: range?.from ?? 0,
|
|
80
|
+
to: range?.to ?? 0,
|
|
81
|
+
};
|
|
82
|
+
}
|
package/lib/index.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
export * from './components/components.js';
|
|
4
|
+
export { useSdTableVirtualScroll } from './hooks/useSdTableVirtualScroll';
|
|
5
|
+
export type { VirtualRow } from './hooks/useSdTableVirtualScroll';
|
|
4
6
|
export { defineCustomElements } from '@sellmate/design-system/loader';
|
|
5
|
-
export { SdTable } from './SdTable';
|
|
6
|
-
export type { SdTableProps } from './SdTable';
|
|
7
7
|
export { sdModal } from './sdModal';
|
|
8
8
|
export type { SdModalCreateOption } from './sdModal';
|
|
9
|
+
export { sdLoading } from '@sellmate/design-system/utils';
|
|
10
|
+
export type { SdLoadingShowOptions } from '@sellmate/design-system/utils';
|
|
9
11
|
|
|
10
12
|
// Export commonly used types for React usage
|
|
11
13
|
export type {
|
|
12
14
|
// Table types
|
|
13
|
-
SdTableSortDir,
|
|
14
15
|
SdTableColumn,
|
|
15
16
|
Row as SdTableRow,
|
|
16
17
|
// Select types
|
package/lib/sdModal.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
_createSdModalRef,
|
|
9
9
|
_attachSdModalWithRef,
|
|
10
10
|
type ConfirmModalOptions,
|
|
11
|
+
type LoadingModalOptions,
|
|
11
12
|
type ModalDialogRef,
|
|
12
13
|
type SdModalCreateOption as CoreSdModalCreateOption,
|
|
13
14
|
type SdModalGlobalOptions,
|
|
@@ -44,15 +45,7 @@ function mountReactComponent(
|
|
|
44
45
|
root.render(createElement(component, componentProps));
|
|
45
46
|
});
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
if (!el) {
|
|
49
|
-
root.unmount();
|
|
50
|
-
throw new Error(
|
|
51
|
-
'[sdModal] 전달한 React 컴포넌트의 루트는 단일 요소여야 합니다.',
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return { el, host, root };
|
|
48
|
+
return { el: host, host, root };
|
|
56
49
|
}
|
|
57
50
|
|
|
58
51
|
/**
|
|
@@ -74,6 +67,10 @@ export const sdModal = {
|
|
|
74
67
|
return coreSdModal.confirm(options);
|
|
75
68
|
},
|
|
76
69
|
|
|
70
|
+
loading(options: LoadingModalOptions = {}): ModalDialogRef {
|
|
71
|
+
return coreSdModal.loading(options);
|
|
72
|
+
},
|
|
73
|
+
|
|
77
74
|
configure(options: SdModalGlobalOptions): void {
|
|
78
75
|
coreSdModal.configure(options);
|
|
79
76
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sellmate/design-system-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.64",
|
|
4
4
|
"description": "Design System - React Component Wrappers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"dev": "tsc --watch"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@sellmate/design-system": "^1.0.
|
|
57
|
+
"@sellmate/design-system": "^1.0.64",
|
|
58
58
|
"@stencil/react-output-target": "^1.2.0"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
package/dist/SdTable.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { Row as SdTableRow, SdTableColumn } from '@sellmate/design-system';
|
|
3
|
-
import { SdTable as SdTableElement } from '@sellmate/design-system/dist/components/sd-table.js';
|
|
4
|
-
import { type EventName } from '@stencil/react-output-target/runtime';
|
|
5
|
-
type TablePagination = {
|
|
6
|
-
page: number;
|
|
7
|
-
rowsPerPage: number;
|
|
8
|
-
lastPage?: number;
|
|
9
|
-
};
|
|
10
|
-
type HeaderRenderContext = {
|
|
11
|
-
column: SdTableColumn;
|
|
12
|
-
};
|
|
13
|
-
type CellRenderContext<RowType extends SdTableRow> = {
|
|
14
|
-
column: SdTableColumn;
|
|
15
|
-
row: RowType;
|
|
16
|
-
rowIndex: number;
|
|
17
|
-
value: any;
|
|
18
|
-
};
|
|
19
|
-
type HeaderRendererMap = Partial<Record<string, (context: HeaderRenderContext) => React.ReactNode>>;
|
|
20
|
-
type CellRendererMap<RowType extends SdTableRow> = Partial<Record<string, (context: CellRenderContext<RowType>) => React.ReactNode>>;
|
|
21
|
-
type SdTableBaseEvents = {
|
|
22
|
-
onSdSelectChange: EventName<CustomEvent<SdTableRow[]>>;
|
|
23
|
-
onSdPageChange: EventName<CustomEvent<number>>;
|
|
24
|
-
onSdRowsPerPageChange: EventName<CustomEvent<number>>;
|
|
25
|
-
};
|
|
26
|
-
declare const SdTableBase: import("@stencil/react-output-target/runtime").StencilReactComponent<SdTableElement, SdTableBaseEvents>;
|
|
27
|
-
export type SdTableProps<RowType extends SdTableRow = SdTableRow> = Omit<React.ComponentProps<typeof SdTableBase>, 'columns' | 'rows' | 'selected' | 'children'> & {
|
|
28
|
-
columns: SdTableColumn[];
|
|
29
|
-
rows?: RowType[] | null;
|
|
30
|
-
selected?: RowType[];
|
|
31
|
-
pagination?: TablePagination;
|
|
32
|
-
useInternalPagination?: boolean;
|
|
33
|
-
headerRenderers?: HeaderRendererMap;
|
|
34
|
-
cellRenderers?: CellRendererMap<RowType>;
|
|
35
|
-
renderHeader?: (context: HeaderRenderContext) => React.ReactNode;
|
|
36
|
-
renderCell?: (context: CellRenderContext<RowType>) => React.ReactNode;
|
|
37
|
-
noDataContent?: React.ReactNode;
|
|
38
|
-
};
|
|
39
|
-
export declare function SdTable<RowType extends SdTableRow = SdTableRow>({ columns, rows, selected, pagination, useInternalPagination, headerRenderers, cellRenderers, renderHeader, renderCell, noDataContent, onSdPageChange, onSdRowsPerPageChange, ...props }: SdTableProps<RowType>): React.JSX.Element;
|
|
40
|
-
export default SdTable;
|
package/dist/SdTable.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import React, { useEffect, useState } from 'react';
|
|
3
|
-
import { SdTable as SdTableElement, defineCustomElement as defineSdTable } from '@sellmate/design-system/dist/components/sd-table.js';
|
|
4
|
-
import { createComponent } from '@stencil/react-output-target/runtime';
|
|
5
|
-
const SLOT_WRAPPER_STYLE = {
|
|
6
|
-
display: 'contents',
|
|
7
|
-
};
|
|
8
|
-
const SdTableBase = /* @__PURE__ */ createComponent({
|
|
9
|
-
tagName: 'sd-table',
|
|
10
|
-
elementClass: SdTableElement,
|
|
11
|
-
react: React,
|
|
12
|
-
events: {
|
|
13
|
-
onSdSelectChange: 'sdSelectChange',
|
|
14
|
-
onSdPageChange: 'sdPageChange',
|
|
15
|
-
onSdRowsPerPageChange: 'sdRowsPerPageChange',
|
|
16
|
-
},
|
|
17
|
-
defineCustomElement: defineSdTable,
|
|
18
|
-
});
|
|
19
|
-
const getCellValue = (column, row) => {
|
|
20
|
-
const { field, format, name } = column;
|
|
21
|
-
const value = typeof field === 'function' ? field(row) : field ? row[field] : row[name];
|
|
22
|
-
return format ? format(value, row) : value;
|
|
23
|
-
};
|
|
24
|
-
export function SdTable({ columns, rows, selected, pagination, useInternalPagination = false, headerRenderers, cellRenderers, renderHeader, renderCell, noDataContent, onSdPageChange, onSdRowsPerPageChange, ...props }) {
|
|
25
|
-
const normalizedRows = rows ?? [];
|
|
26
|
-
const [currentPage, setCurrentPage] = useState(pagination?.page || 1);
|
|
27
|
-
const [currentRowsPerPage, setCurrentRowsPerPage] = useState(pagination?.rowsPerPage || normalizedRows.length || 0);
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
setCurrentPage(pagination?.page || 1);
|
|
30
|
-
setCurrentRowsPerPage(pagination?.rowsPerPage || normalizedRows.length || 0);
|
|
31
|
-
}, [pagination?.page, pagination?.rowsPerPage, normalizedRows.length]);
|
|
32
|
-
const renderedRows = useInternalPagination && currentRowsPerPage
|
|
33
|
-
? normalizedRows.slice((currentPage - 1) * currentRowsPerPage, currentPage * currentRowsPerPage)
|
|
34
|
-
: normalizedRows;
|
|
35
|
-
const slotChildren = [];
|
|
36
|
-
if (noDataContent !== undefined) {
|
|
37
|
-
slotChildren.push(React.createElement("span", { key: "no-data", slot: "no-data", style: SLOT_WRAPPER_STYLE }, noDataContent));
|
|
38
|
-
}
|
|
39
|
-
columns.forEach(column => {
|
|
40
|
-
const renderer = headerRenderers?.[column.name] || renderHeader;
|
|
41
|
-
if (!renderer)
|
|
42
|
-
return;
|
|
43
|
-
const rendered = renderer({ column });
|
|
44
|
-
if (rendered == null)
|
|
45
|
-
return;
|
|
46
|
-
slotChildren.push(React.createElement("span", { key: `header-${column.name}`, slot: `header-cell-${column.name}`, style: SLOT_WRAPPER_STYLE }, rendered));
|
|
47
|
-
});
|
|
48
|
-
renderedRows.forEach((row, rowIndex) => {
|
|
49
|
-
columns.forEach(column => {
|
|
50
|
-
const renderer = cellRenderers?.[column.name] || renderCell;
|
|
51
|
-
if (!renderer)
|
|
52
|
-
return;
|
|
53
|
-
const rendered = renderer({
|
|
54
|
-
column,
|
|
55
|
-
row,
|
|
56
|
-
rowIndex,
|
|
57
|
-
value: getCellValue(column, row),
|
|
58
|
-
});
|
|
59
|
-
if (rendered == null)
|
|
60
|
-
return;
|
|
61
|
-
slotChildren.push(React.createElement("span", { key: `cell-${column.name}-${rowIndex}`, slot: `body-cell-${column.name}-${rowIndex}`, style: SLOT_WRAPPER_STYLE }, rendered));
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
return (React.createElement(SdTableBase, { ...props, columns: columns, rows: normalizedRows, selected: selected, pagination: pagination, useInternalPagination: useInternalPagination, onSdPageChange: event => {
|
|
65
|
-
setCurrentPage(event.detail);
|
|
66
|
-
onSdPageChange?.(event);
|
|
67
|
-
}, onSdRowsPerPageChange: event => {
|
|
68
|
-
setCurrentRowsPerPage(event.detail);
|
|
69
|
-
const lastPage = Math.max(1, Math.ceil(normalizedRows.length / event.detail));
|
|
70
|
-
setCurrentPage(previousPage => Math.min(previousPage, lastPage));
|
|
71
|
-
onSdRowsPerPageChange?.(event);
|
|
72
|
-
} }, slotChildren));
|
|
73
|
-
}
|
|
74
|
-
export default SdTable;
|