@gcsa/console-react 0.1.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/dist/ConsoleHeader.d.ts +9 -0
- package/dist/ConsoleHeader.js +21 -0
- package/dist/ConsoleHeader.js.map +1 -0
- package/dist/ConsolePage.d.ts +8 -0
- package/dist/ConsolePage.js +14 -0
- package/dist/ConsolePage.js.map +1 -0
- package/dist/ConsoleShell.d.ts +23 -0
- package/dist/ConsoleShell.js +133 -0
- package/dist/ConsoleShell.js.map +1 -0
- package/dist/ConsoleSidebar.d.ts +11 -0
- package/dist/ConsoleSidebar.js +52 -0
- package/dist/ConsoleSidebar.js.map +1 -0
- package/dist/GcsaAlert.d.ts +9 -0
- package/dist/GcsaAlert.js +24 -0
- package/dist/GcsaAlert.js.map +1 -0
- package/dist/GcsaAutoComplete.d.ts +15 -0
- package/dist/GcsaAutoComplete.js +106 -0
- package/dist/GcsaAutoComplete.js.map +1 -0
- package/dist/GcsaAvatar.d.ts +8 -0
- package/dist/GcsaAvatar.js +13 -0
- package/dist/GcsaAvatar.js.map +1 -0
- package/dist/GcsaBadge.d.ts +7 -0
- package/dist/GcsaBadge.js +8 -0
- package/dist/GcsaBadge.js.map +1 -0
- package/dist/GcsaBrandMark.d.ts +4 -0
- package/dist/GcsaBrandMark.js +21 -0
- package/dist/GcsaBrandMark.js.map +1 -0
- package/dist/GcsaBreadcrumb.d.ts +9 -0
- package/dist/GcsaBreadcrumb.js +20 -0
- package/dist/GcsaBreadcrumb.js.map +1 -0
- package/dist/GcsaButton.d.ts +8 -0
- package/dist/GcsaButton.js +38 -0
- package/dist/GcsaButton.js.map +1 -0
- package/dist/GcsaCalendar.d.ts +11 -0
- package/dist/GcsaCalendar.js +35 -0
- package/dist/GcsaCalendar.js.map +1 -0
- package/dist/GcsaCard.d.ts +8 -0
- package/dist/GcsaCard.js +11 -0
- package/dist/GcsaCard.js.map +1 -0
- package/dist/GcsaCascader.d.ts +14 -0
- package/dist/GcsaCascader.js +91 -0
- package/dist/GcsaCascader.js.map +1 -0
- package/dist/GcsaChatPanel.d.ts +43 -0
- package/dist/GcsaChatPanel.js +180 -0
- package/dist/GcsaChatPanel.js.map +1 -0
- package/dist/GcsaCheckbox.d.ts +11 -0
- package/dist/GcsaCheckbox.js +45 -0
- package/dist/GcsaCheckbox.js.map +1 -0
- package/dist/GcsaCollapse.d.ts +16 -0
- package/dist/GcsaCollapse.js +20 -0
- package/dist/GcsaCollapse.js.map +1 -0
- package/dist/GcsaConfigProvider.d.ts +13 -0
- package/dist/GcsaConfigProvider.js +68 -0
- package/dist/GcsaConfigProvider.js.map +1 -0
- package/dist/GcsaDataTable.d.ts +119 -0
- package/dist/GcsaDataTable.js +508 -0
- package/dist/GcsaDataTable.js.map +1 -0
- package/dist/GcsaDatePicker.d.ts +16 -0
- package/dist/GcsaDatePicker.js +211 -0
- package/dist/GcsaDatePicker.js.map +1 -0
- package/dist/GcsaDateRangePicker.d.ts +17 -0
- package/dist/GcsaDateRangePicker.js +222 -0
- package/dist/GcsaDateRangePicker.js.map +1 -0
- package/dist/GcsaDateTimePicker.d.ts +13 -0
- package/dist/GcsaDateTimePicker.js +300 -0
- package/dist/GcsaDateTimePicker.js.map +1 -0
- package/dist/GcsaDescriptions.d.ts +9 -0
- package/dist/GcsaDescriptions.js +11 -0
- package/dist/GcsaDescriptions.js.map +1 -0
- package/dist/GcsaDivider.d.ts +4 -0
- package/dist/GcsaDivider.js +8 -0
- package/dist/GcsaDivider.js.map +1 -0
- package/dist/GcsaDrawer.d.ts +15 -0
- package/dist/GcsaDrawer.js +68 -0
- package/dist/GcsaDrawer.js.map +1 -0
- package/dist/GcsaDropdown.d.ts +20 -0
- package/dist/GcsaDropdown.js +46 -0
- package/dist/GcsaDropdown.js.map +1 -0
- package/dist/GcsaEmpty.d.ts +9 -0
- package/dist/GcsaEmpty.js +16 -0
- package/dist/GcsaEmpty.js.map +1 -0
- package/dist/GcsaField.d.ts +11 -0
- package/dist/GcsaField.js +26 -0
- package/dist/GcsaField.js.map +1 -0
- package/dist/GcsaForm.d.ts +13 -0
- package/dist/GcsaForm.js +60 -0
- package/dist/GcsaForm.js.map +1 -0
- package/dist/GcsaFormField.d.ts +16 -0
- package/dist/GcsaFormField.js +39 -0
- package/dist/GcsaFormField.js.map +1 -0
- package/dist/GcsaIcon.d.ts +7 -0
- package/dist/GcsaIcon.js +17 -0
- package/dist/GcsaIcon.js.map +1 -0
- package/dist/GcsaImagePreview.d.ts +8 -0
- package/dist/GcsaImagePreview.js +18 -0
- package/dist/GcsaImagePreview.js.map +1 -0
- package/dist/GcsaInput.d.ts +13 -0
- package/dist/GcsaInput.js +76 -0
- package/dist/GcsaInput.js.map +1 -0
- package/dist/GcsaInputGroup.d.ts +11 -0
- package/dist/GcsaInputGroup.js +27 -0
- package/dist/GcsaInputGroup.js.map +1 -0
- package/dist/GcsaInputNumber.d.ts +18 -0
- package/dist/GcsaInputNumber.js +108 -0
- package/dist/GcsaInputNumber.js.map +1 -0
- package/dist/GcsaLoading.d.ts +24 -0
- package/dist/GcsaLoading.js +101 -0
- package/dist/GcsaLoading.js.map +1 -0
- package/dist/GcsaLoadingMask.d.ts +8 -0
- package/dist/GcsaLoadingMask.js +39 -0
- package/dist/GcsaLoadingMask.js.map +1 -0
- package/dist/GcsaMarkdownRenderer.d.ts +6 -0
- package/dist/GcsaMarkdownRenderer.js +32 -0
- package/dist/GcsaMarkdownRenderer.js.map +1 -0
- package/dist/GcsaMenu.d.ts +16 -0
- package/dist/GcsaMenu.js +241 -0
- package/dist/GcsaMenu.js.map +1 -0
- package/dist/GcsaModal.d.ts +10 -0
- package/dist/GcsaModal.js +45 -0
- package/dist/GcsaModal.js.map +1 -0
- package/dist/GcsaMultiSelect.d.ts +23 -0
- package/dist/GcsaMultiSelect.js +149 -0
- package/dist/GcsaMultiSelect.js.map +1 -0
- package/dist/GcsaPagination.d.ts +17 -0
- package/dist/GcsaPagination.js +108 -0
- package/dist/GcsaPagination.js.map +1 -0
- package/dist/GcsaPopconfirm.d.ts +18 -0
- package/dist/GcsaPopconfirm.js +68 -0
- package/dist/GcsaPopconfirm.js.map +1 -0
- package/dist/GcsaPopover.d.ts +30 -0
- package/dist/GcsaPopover.js +65 -0
- package/dist/GcsaPopover.js.map +1 -0
- package/dist/GcsaPopoverClose.d.ts +6 -0
- package/dist/GcsaPopoverClose.js +9 -0
- package/dist/GcsaPopoverClose.js.map +1 -0
- package/dist/GcsaProgress.d.ts +5 -0
- package/dist/GcsaProgress.js +18 -0
- package/dist/GcsaProgress.js.map +1 -0
- package/dist/GcsaRadioGroup.d.ts +9 -0
- package/dist/GcsaRadioGroup.js +37 -0
- package/dist/GcsaRadioGroup.js.map +1 -0
- package/dist/GcsaResult.d.ts +9 -0
- package/dist/GcsaResult.js +14 -0
- package/dist/GcsaResult.js.map +1 -0
- package/dist/GcsaRow.d.ts +7 -0
- package/dist/GcsaRow.js +8 -0
- package/dist/GcsaRow.js.map +1 -0
- package/dist/GcsaSelect.d.ts +20 -0
- package/dist/GcsaSelect.js +117 -0
- package/dist/GcsaSelect.js.map +1 -0
- package/dist/GcsaSkeleton.d.ts +6 -0
- package/dist/GcsaSkeleton.js +19 -0
- package/dist/GcsaSkeleton.js.map +1 -0
- package/dist/GcsaSpace.d.ts +7 -0
- package/dist/GcsaSpace.js +14 -0
- package/dist/GcsaSpace.js.map +1 -0
- package/dist/GcsaSpin.d.ts +7 -0
- package/dist/GcsaSpin.js +16 -0
- package/dist/GcsaSpin.js.map +1 -0
- package/dist/GcsaStatistic.d.ts +8 -0
- package/dist/GcsaStatistic.js +11 -0
- package/dist/GcsaStatistic.js.map +1 -0
- package/dist/GcsaSteps.d.ts +10 -0
- package/dist/GcsaSteps.js +54 -0
- package/dist/GcsaSteps.js.map +1 -0
- package/dist/GcsaSwitch.d.ts +11 -0
- package/dist/GcsaSwitch.js +36 -0
- package/dist/GcsaSwitch.js.map +1 -0
- package/dist/GcsaTabs.d.ts +15 -0
- package/dist/GcsaTabs.js +39 -0
- package/dist/GcsaTabs.js.map +1 -0
- package/dist/GcsaTag.d.ts +7 -0
- package/dist/GcsaTag.js +9 -0
- package/dist/GcsaTag.js.map +1 -0
- package/dist/GcsaTextarea.d.ts +13 -0
- package/dist/GcsaTextarea.js +76 -0
- package/dist/GcsaTextarea.js.map +1 -0
- package/dist/GcsaTimePicker.d.ts +12 -0
- package/dist/GcsaTimePicker.js +221 -0
- package/dist/GcsaTimePicker.js.map +1 -0
- package/dist/GcsaTimeline.d.ts +5 -0
- package/dist/GcsaTimeline.js +19 -0
- package/dist/GcsaTimeline.js.map +1 -0
- package/dist/GcsaToastStack.d.ts +11 -0
- package/dist/GcsaToastStack.js +45 -0
- package/dist/GcsaToastStack.js.map +1 -0
- package/dist/GcsaTooltip.d.ts +17 -0
- package/dist/GcsaTooltip.js +43 -0
- package/dist/GcsaTooltip.js.map +1 -0
- package/dist/GcsaTransfer.d.ts +11 -0
- package/dist/GcsaTransfer.js +95 -0
- package/dist/GcsaTransfer.js.map +1 -0
- package/dist/GcsaTree.d.ts +17 -0
- package/dist/GcsaTree.js +38 -0
- package/dist/GcsaTree.js.map +1 -0
- package/dist/GcsaTypography.d.ts +8 -0
- package/dist/GcsaTypography.js +14 -0
- package/dist/GcsaTypography.js.map +1 -0
- package/dist/GcsaUpload.d.ts +24 -0
- package/dist/GcsaUpload.js +146 -0
- package/dist/GcsaUpload.js.map +1 -0
- package/dist/hooks/gcsaFormTypes.d.ts +7 -0
- package/dist/hooks/useDocumentThemeSync.d.ts +3 -0
- package/dist/hooks/useDocumentThemeSync.js +7 -0
- package/dist/hooks/useDocumentThemeSync.js.map +1 -0
- package/dist/hooks/useGcsaComponentSize.d.ts +5 -0
- package/dist/hooks/useGcsaComponentSize.js +21 -0
- package/dist/hooks/useGcsaComponentSize.js.map +1 -0
- package/dist/hooks/useGcsaFormField.d.ts +26 -0
- package/dist/hooks/useGcsaFormField.js +47 -0
- package/dist/hooks/useGcsaFormField.js.map +1 -0
- package/dist/hooks/useGcsaFormSchema.d.ts +7 -0
- package/dist/hooks/useGcsaFormSchema.js +6 -0
- package/dist/hooks/useGcsaFormSchema.js.map +1 -0
- package/dist/hooks/useGcsaLocale.d.ts +4 -0
- package/dist/hooks/useGcsaLocale.js +15 -0
- package/dist/hooks/useGcsaLocale.js.map +1 -0
- package/dist/hooks/useGcsaPopupZIndex.d.ts +6 -0
- package/dist/hooks/useGcsaPopupZIndex.js +18 -0
- package/dist/hooks/useGcsaPopupZIndex.js.map +1 -0
- package/dist/hooks/useGcsaTextCount.d.ts +16 -0
- package/dist/hooks/useGcsaTextCount.js +16 -0
- package/dist/hooks/useGcsaTextCount.js.map +1 -0
- package/dist/hooks/useGcsaTheme.d.ts +7 -0
- package/dist/hooks/useGcsaTheme.js +19 -0
- package/dist/hooks/useGcsaTheme.js.map +1 -0
- package/dist/hooks/useGcsaZIndex.d.ts +13 -0
- package/dist/hooks/useGcsaZIndex.js +37 -0
- package/dist/hooks/useGcsaZIndex.js.map +1 -0
- package/dist/hooks/useMessage.d.ts +6 -0
- package/dist/hooks/useOverlayZIndex.d.ts +8 -0
- package/dist/hooks/useOverlayZIndex.js +14 -0
- package/dist/hooks/useOverlayZIndex.js.map +1 -0
- package/dist/hooks/usePreventHiddenInputScroll.d.ts +13 -0
- package/dist/hooks/usePreventHiddenInputScroll.js +124 -0
- package/dist/hooks/usePreventHiddenInputScroll.js.map +1 -0
- package/dist/icons/iconNames.d.ts +7 -0
- package/dist/icons/iconNames.js +24 -0
- package/dist/icons/iconNames.js.map +1 -0
- package/dist/icons/index.d.ts +2 -0
- package/dist/icons/registry.d.ts +3 -0
- package/dist/icons/registry.js +58 -0
- package/dist/icons/registry.js.map +1 -0
- package/dist/icons/svg/alert.svg.js +9 -0
- package/dist/icons/svg/alert.svg.js.map +1 -0
- package/dist/icons/svg/assets.svg.js +9 -0
- package/dist/icons/svg/assets.svg.js.map +1 -0
- package/dist/icons/svg/chat.svg.js +8 -0
- package/dist/icons/svg/chat.svg.js.map +1 -0
- package/dist/icons/svg/check.svg.js +8 -0
- package/dist/icons/svg/check.svg.js.map +1 -0
- package/dist/icons/svg/chevron-down.svg.js +8 -0
- package/dist/icons/svg/chevron-down.svg.js.map +1 -0
- package/dist/icons/svg/chevron-left.svg.js +8 -0
- package/dist/icons/svg/chevron-left.svg.js.map +1 -0
- package/dist/icons/svg/chevron-right.svg.js +8 -0
- package/dist/icons/svg/chevron-right.svg.js.map +1 -0
- package/dist/icons/svg/chevron-up.svg.js +8 -0
- package/dist/icons/svg/chevron-up.svg.js.map +1 -0
- package/dist/icons/svg/close.svg.js +6 -0
- package/dist/icons/svg/close.svg.js.map +1 -0
- package/dist/icons/svg/dashboard.svg.js +8 -0
- package/dist/icons/svg/dashboard.svg.js.map +1 -0
- package/dist/icons/svg/menu.svg.js +8 -0
- package/dist/icons/svg/menu.svg.js.map +1 -0
- package/dist/icons/svg/plus.svg.js +6 -0
- package/dist/icons/svg/plus.svg.js.map +1 -0
- package/dist/icons/svg/result-empty.svg.js +6 -0
- package/dist/icons/svg/result-empty.svg.js.map +1 -0
- package/dist/icons/svg/settings.svg.js +8 -0
- package/dist/icons/svg/settings.svg.js.map +1 -0
- package/dist/icons/svg/users.svg.js +11 -0
- package/dist/icons/svg/users.svg.js.map +1 -0
- package/dist/index.d.ts +151 -0
- package/dist/index.js +166 -0
- package/dist/index.js.map +1 -0
- package/dist/style.css +8028 -0
- package/dist/utils/gcsaDateValue.d.ts +25 -0
- package/dist/utils/gcsaDateValue.js +60 -0
- package/dist/utils/gcsaDateValue.js.map +1 -0
- package/dist/utils/gcsaTableColumns.d.ts +19 -0
- package/dist/utils/gcsaTableColumns.js +43 -0
- package/dist/utils/gcsaTableColumns.js.map +1 -0
- package/dist/utils/preserveDrawerScroll.d.ts +2 -0
- package/dist/utils/preserveDrawerScroll.js +13 -0
- package/dist/utils/preserveDrawerScroll.js.map +1 -0
- package/dist/utils/zodValidators.d.ts +21 -0
- package/dist/utils/zodValidators.js +35 -0
- package/dist/utils/zodValidators.js.map +1 -0
- package/package.json +58 -0
- package/src/ConsoleHeader.tsx +24 -0
- package/src/ConsolePage.tsx +22 -0
- package/src/ConsoleShell.tsx +248 -0
- package/src/ConsoleSidebar.tsx +61 -0
- package/src/GcsaAlert.tsx +29 -0
- package/src/GcsaAutoComplete.tsx +163 -0
- package/src/GcsaAvatar.tsx +21 -0
- package/src/GcsaBadge.tsx +15 -0
- package/src/GcsaBrandMark.tsx +18 -0
- package/src/GcsaBreadcrumb.tsx +35 -0
- package/src/GcsaButton.tsx +44 -0
- package/src/GcsaCalendar.tsx +14 -0
- package/src/GcsaCard.tsx +21 -0
- package/src/GcsaCascader.tsx +121 -0
- package/src/GcsaChatPanel.tsx +320 -0
- package/src/GcsaCheckbox.tsx +55 -0
- package/src/GcsaCollapse.tsx +23 -0
- package/src/GcsaConfigProvider.tsx +121 -0
- package/src/GcsaDataTable.tsx +779 -0
- package/src/GcsaDatePicker.tsx +284 -0
- package/src/GcsaDateRangePicker.tsx +310 -0
- package/src/GcsaDateTimePicker.tsx +407 -0
- package/src/GcsaDescriptions.tsx +22 -0
- package/src/GcsaDivider.tsx +7 -0
- package/src/GcsaDrawer.tsx +87 -0
- package/src/GcsaDropdown.tsx +84 -0
- package/src/GcsaEmpty.tsx +27 -0
- package/src/GcsaField.tsx +50 -0
- package/src/GcsaForm.tsx +82 -0
- package/src/GcsaFormField.tsx +67 -0
- package/src/GcsaIcon.tsx +21 -0
- package/src/GcsaImagePreview.tsx +30 -0
- package/src/GcsaInput.tsx +87 -0
- package/src/GcsaInputGroup.tsx +32 -0
- package/src/GcsaInputNumber.tsx +155 -0
- package/src/GcsaLoading.ts +206 -0
- package/src/GcsaLoadingMask.tsx +53 -0
- package/src/GcsaMarkdownRenderer.tsx +40 -0
- package/src/GcsaMenu.tsx +340 -0
- package/src/GcsaModal.tsx +68 -0
- package/src/GcsaMultiSelect.tsx +246 -0
- package/src/GcsaPagination.tsx +194 -0
- package/src/GcsaPopconfirm.tsx +104 -0
- package/src/GcsaPopover.tsx +131 -0
- package/src/GcsaPopoverClose.tsx +11 -0
- package/src/GcsaProgress.tsx +18 -0
- package/src/GcsaRadioGroup.tsx +42 -0
- package/src/GcsaResult.tsx +23 -0
- package/src/GcsaRow.tsx +13 -0
- package/src/GcsaSelect.tsx +186 -0
- package/src/GcsaSkeleton.tsx +19 -0
- package/src/GcsaSpace.tsx +17 -0
- package/src/GcsaSpin.tsx +25 -0
- package/src/GcsaStatistic.tsx +17 -0
- package/src/GcsaSteps.tsx +73 -0
- package/src/GcsaSwitch.tsx +45 -0
- package/src/GcsaTabs.tsx +53 -0
- package/src/GcsaTag.tsx +16 -0
- package/src/GcsaTextarea.tsx +87 -0
- package/src/GcsaTimePicker.tsx +298 -0
- package/src/GcsaTimeline.tsx +27 -0
- package/src/GcsaToastStack.tsx +67 -0
- package/src/GcsaTooltip.tsx +75 -0
- package/src/GcsaTransfer.tsx +129 -0
- package/src/GcsaTree.tsx +43 -0
- package/src/GcsaTypography.tsx +24 -0
- package/src/GcsaUpload.tsx +206 -0
- package/src/hooks/gcsaFormTypes.ts +23 -0
- package/src/hooks/useDocumentThemeSync.ts +6 -0
- package/src/hooks/useGcsaComponentSize.ts +24 -0
- package/src/hooks/useGcsaFormField.ts +49 -0
- package/src/hooks/useGcsaFormSchema.ts +6 -0
- package/src/hooks/useGcsaLocale.ts +16 -0
- package/src/hooks/useGcsaPopupZIndex.ts +23 -0
- package/src/hooks/useGcsaTextCount.ts +44 -0
- package/src/hooks/useGcsaTheme.ts +19 -0
- package/src/hooks/useGcsaZIndex.ts +60 -0
- package/src/hooks/useMessage.ts +7 -0
- package/src/hooks/useOverlayZIndex.ts +23 -0
- package/src/hooks/usePreventHiddenInputScroll.ts +233 -0
- package/src/icons/iconNames.ts +27 -0
- package/src/icons/index.ts +8 -0
- package/src/icons/registry.ts +38 -0
- package/src/icons/svg/alert.svg +4 -0
- package/src/icons/svg/assets.svg +4 -0
- package/src/icons/svg/chat.svg +3 -0
- package/src/icons/svg/check.svg +3 -0
- package/src/icons/svg/chevron-down.svg +3 -0
- package/src/icons/svg/chevron-left.svg +3 -0
- package/src/icons/svg/chevron-right.svg +3 -0
- package/src/icons/svg/chevron-up.svg +3 -0
- package/src/icons/svg/close.svg +1 -0
- package/src/icons/svg/dashboard.svg +3 -0
- package/src/icons/svg/menu.svg +3 -0
- package/src/icons/svg/plus.svg +1 -0
- package/src/icons/svg/result-empty.svg +1 -0
- package/src/icons/svg/settings.svg +3 -0
- package/src/icons/svg/users.svg +6 -0
- package/src/index.ts +166 -0
- package/src/utils/gcsaDateValue.ts +99 -0
- package/src/utils/gcsaTableColumns.ts +97 -0
- package/src/utils/preserveDrawerScroll.ts +20 -0
- package/src/utils/zodValidators.ts +45 -0
- package/src/vite-env.d.ts +6 -0
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { useCallback, useLayoutEffect, useRef, type RefObject } from 'react';
|
|
2
|
+
|
|
3
|
+
function getDrawerPanel(root: HTMLElement): HTMLElement | null {
|
|
4
|
+
const panel = root.closest('.gcsa-drawer__panel');
|
|
5
|
+
return panel instanceof HTMLElement ? panel : null;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function resetDrawerPanelScroll(root: HTMLElement | null | undefined) {
|
|
9
|
+
const panel = root ? getDrawerPanel(root) : null;
|
|
10
|
+
if (panel && panel.scrollTop !== 0) {
|
|
11
|
+
panel.scrollTop = 0;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function collectScrollTops(start: HTMLElement | null): Map<Element, number> {
|
|
16
|
+
const saved = new Map<Element, number>();
|
|
17
|
+
let el = start;
|
|
18
|
+
while (el) {
|
|
19
|
+
const { overflowY } = getComputedStyle(el);
|
|
20
|
+
if (
|
|
21
|
+
(overflowY === 'auto' || overflowY === 'scroll' || overflowY === 'overlay')
|
|
22
|
+
&& el.scrollHeight > el.clientHeight
|
|
23
|
+
) {
|
|
24
|
+
saved.set(el, el.scrollTop);
|
|
25
|
+
}
|
|
26
|
+
el = el.parentElement;
|
|
27
|
+
}
|
|
28
|
+
return saved;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function restoreScrollTops(saved: Map<Element, number>, root?: HTMLElement | null) {
|
|
32
|
+
saved.forEach((top, el) => {
|
|
33
|
+
if (el instanceof HTMLElement) el.scrollTop = top;
|
|
34
|
+
});
|
|
35
|
+
resetDrawerPanelScroll(root);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function scheduleScrollRestore(saved: Map<Element, number>, root?: HTMLElement | null) {
|
|
39
|
+
const run = () => restoreScrollTops(saved, root);
|
|
40
|
+
run();
|
|
41
|
+
requestAnimationFrame(() => {
|
|
42
|
+
run();
|
|
43
|
+
requestAnimationFrame(run);
|
|
44
|
+
});
|
|
45
|
+
window.setTimeout(run, 0);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const patchedElements = new WeakSet<HTMLElement>();
|
|
49
|
+
|
|
50
|
+
/** 拦截 focus() 的 scrollIntoView,用于 Drawer 内 Input / Select / Button 等。 */
|
|
51
|
+
export function patchFocusPreventScroll(element: HTMLElement) {
|
|
52
|
+
if (patchedElements.has(element)) return;
|
|
53
|
+
if (!('focus' in element) || typeof element.focus !== 'function') return;
|
|
54
|
+
patchedElements.add(element);
|
|
55
|
+
const nativeFocus = element.focus.bind(element);
|
|
56
|
+
element.focus = (options?: FocusOptions) => nativeFocus({ ...options, preventScroll: true });
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function isHiddenCheckbox(target: EventTarget | null, root: HTMLElement): target is HTMLInputElement {
|
|
60
|
+
return (
|
|
61
|
+
target instanceof HTMLInputElement
|
|
62
|
+
&& target.type === 'checkbox'
|
|
63
|
+
&& root.contains(target)
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Ark/Zag Switch & Checkbox 使用 visually-hidden 的 native input。
|
|
69
|
+
* 点击时 focus 会把 Drawer/Modal 滚飞;在 Root 上保存/恢复 scroll,避免 scroll 监听卡死。
|
|
70
|
+
*/
|
|
71
|
+
function setupHiddenInputScrollLock(root: HTMLElement) {
|
|
72
|
+
let savedScroll = new Map<Element, number>();
|
|
73
|
+
|
|
74
|
+
const onPressStart = () => {
|
|
75
|
+
savedScroll = collectScrollTops(root);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const onFocusIn = (event: FocusEvent) => {
|
|
79
|
+
if (!isHiddenCheckbox(event.target, root)) return;
|
|
80
|
+
patchFocusPreventScroll(event.target);
|
|
81
|
+
scheduleScrollRestore(savedScroll, root);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
root.addEventListener('pointerdown', onPressStart, true);
|
|
85
|
+
root.addEventListener('mousedown', onPressStart, true);
|
|
86
|
+
root.addEventListener('focusin', onFocusIn);
|
|
87
|
+
|
|
88
|
+
const input = root.querySelector('input[type="checkbox"]');
|
|
89
|
+
if (input instanceof HTMLInputElement) patchFocusPreventScroll(input);
|
|
90
|
+
|
|
91
|
+
return () => {
|
|
92
|
+
root.removeEventListener('pointerdown', onPressStart, true);
|
|
93
|
+
root.removeEventListener('mousedown', onPressStart, true);
|
|
94
|
+
root.removeEventListener('focusin', onFocusIn);
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* 在 Switch/Checkbox Root 上绑定,HiddenInput 不转发 ref。
|
|
100
|
+
*/
|
|
101
|
+
export function usePreventHiddenInputScroll(rootRef: RefObject<HTMLElement | null>) {
|
|
102
|
+
useLayoutEffect(() => {
|
|
103
|
+
const root = rootRef.current;
|
|
104
|
+
if (!root) return;
|
|
105
|
+
return setupHiddenInputScrollLock(root);
|
|
106
|
+
}, [rootRef]);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const POPUP_INTERACTION_SELECTOR =
|
|
110
|
+
'.gcsa-select-content, .gcsa-select-positioner, .gcsa-autocomplete__panel';
|
|
111
|
+
|
|
112
|
+
export const GCSA_PRESERVE_SCROLL_EVENT = 'gcsa-preserve-scroll';
|
|
113
|
+
|
|
114
|
+
function setupPreserveScrollOnFocus(root: HTMLElement) {
|
|
115
|
+
const panel = getDrawerPanel(root);
|
|
116
|
+
resetDrawerPanelScroll(root);
|
|
117
|
+
|
|
118
|
+
let savedScroll = collectScrollTops(root);
|
|
119
|
+
let lockedScroll: Map<Element, number> | null = null;
|
|
120
|
+
let lockUntil = 0;
|
|
121
|
+
|
|
122
|
+
const lockScroll = () => {
|
|
123
|
+
resetDrawerPanelScroll(root);
|
|
124
|
+
lockedScroll = collectScrollTops(root);
|
|
125
|
+
savedScroll = lockedScroll;
|
|
126
|
+
lockUntil = performance.now() + 480;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const saveScroll = () => {
|
|
130
|
+
if (lockedScroll && performance.now() < lockUntil) return;
|
|
131
|
+
savedScroll = collectScrollTops(root);
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const restoreScroll = () => {
|
|
135
|
+
scheduleScrollRestore(lockedScroll ?? savedScroll, root);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const enforceLockedScroll = () => {
|
|
139
|
+
resetDrawerPanelScroll(root);
|
|
140
|
+
if (!lockedScroll || performance.now() >= lockUntil) return;
|
|
141
|
+
const lockedTop = lockedScroll.get(root);
|
|
142
|
+
if (lockedTop == null) return;
|
|
143
|
+
if (Math.abs(root.scrollTop - lockedTop) > 1) {
|
|
144
|
+
root.scrollTop = lockedTop;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const onPanelScroll = () => {
|
|
149
|
+
resetDrawerPanelScroll(root);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const patchFocusables = () => {
|
|
153
|
+
root.querySelectorAll('input, textarea, select, button').forEach(el => {
|
|
154
|
+
if (el instanceof HTMLElement) patchFocusPreventScroll(el);
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const onScroll = () => {
|
|
159
|
+
if (lockedScroll && performance.now() < lockUntil) {
|
|
160
|
+
enforceLockedScroll();
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
saveScroll();
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const onPressStart = () => lockScroll();
|
|
167
|
+
|
|
168
|
+
const onFocusIn = (event: FocusEvent) => {
|
|
169
|
+
if (!(event.target instanceof Node) || !root.contains(event.target)) return;
|
|
170
|
+
restoreScroll();
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
const onDocPointerDown = (event: PointerEvent) => {
|
|
174
|
+
const target = event.target;
|
|
175
|
+
if (!(target instanceof Node)) return;
|
|
176
|
+
if (root.contains(target)) {
|
|
177
|
+
lockScroll();
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
if (target instanceof Element && target.closest(POPUP_INTERACTION_SELECTOR)) {
|
|
181
|
+
lockScroll();
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
patchFocusables();
|
|
186
|
+
const observer = new MutationObserver(() => patchFocusables());
|
|
187
|
+
|
|
188
|
+
const onPreserveEvent = () => restoreScroll();
|
|
189
|
+
|
|
190
|
+
root.addEventListener('scroll', onScroll, { passive: true });
|
|
191
|
+
root.addEventListener('pointerdown', onPressStart, true);
|
|
192
|
+
root.addEventListener('mousedown', onPressStart, true);
|
|
193
|
+
root.addEventListener('focusin', onFocusIn);
|
|
194
|
+
root.addEventListener(GCSA_PRESERVE_SCROLL_EVENT, onPreserveEvent);
|
|
195
|
+
panel?.addEventListener('scroll', onPanelScroll, { passive: true });
|
|
196
|
+
document.addEventListener('pointerdown', onDocPointerDown, true);
|
|
197
|
+
observer.observe(root, { childList: true, subtree: true });
|
|
198
|
+
|
|
199
|
+
return () => {
|
|
200
|
+
root.removeEventListener('scroll', onScroll);
|
|
201
|
+
root.removeEventListener('pointerdown', onPressStart, true);
|
|
202
|
+
root.removeEventListener('mousedown', onPressStart, true);
|
|
203
|
+
root.removeEventListener('focusin', onFocusIn);
|
|
204
|
+
root.removeEventListener(GCSA_PRESERVE_SCROLL_EVENT, onPreserveEvent);
|
|
205
|
+
panel?.removeEventListener('scroll', onPanelScroll);
|
|
206
|
+
document.removeEventListener('pointerdown', onDocPointerDown, true);
|
|
207
|
+
observer.disconnect();
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Drawer/Modal 内容区:pointer / focus 后恢复滚动,避免 Select 打开或 Input 聚焦把 body 滚飞。
|
|
213
|
+
* 返回 callback ref;须与 Drawer open 同步(lazyMount 下 DOM 晚于 effect 挂载)。
|
|
214
|
+
*/
|
|
215
|
+
export function usePreserveScrollOnFocus(active = true) {
|
|
216
|
+
const cleanupRef = useRef<(() => void) | undefined>(undefined);
|
|
217
|
+
|
|
218
|
+
useLayoutEffect(() => () => {
|
|
219
|
+
cleanupRef.current?.();
|
|
220
|
+
cleanupRef.current = undefined;
|
|
221
|
+
}, []);
|
|
222
|
+
|
|
223
|
+
return useCallback(
|
|
224
|
+
(node: HTMLElement | null) => {
|
|
225
|
+
cleanupRef.current?.();
|
|
226
|
+
cleanupRef.current = undefined;
|
|
227
|
+
if (active && node) {
|
|
228
|
+
cleanupRef.current = setupPreserveScrollOnFocus(node);
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
[active],
|
|
232
|
+
);
|
|
233
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** 导航侧栏图标 — 与 @gcsa/console-core GcsaNavItem.iconKey 对齐 */
|
|
2
|
+
export const GCSA_NAV_ICON_NAMES = [
|
|
3
|
+
'dashboard',
|
|
4
|
+
'alert',
|
|
5
|
+
'assets',
|
|
6
|
+
'settings',
|
|
7
|
+
'users',
|
|
8
|
+
'chat'
|
|
9
|
+
] as const;
|
|
10
|
+
|
|
11
|
+
/** 组件内部 UI 图标(文件名 kebab-case → 注册为 camelCase key) */
|
|
12
|
+
export const GCSA_UI_ICON_NAMES = [
|
|
13
|
+
'chevronDown',
|
|
14
|
+
'chevronUp',
|
|
15
|
+
'chevronLeft',
|
|
16
|
+
'chevronRight',
|
|
17
|
+
'check',
|
|
18
|
+
'close',
|
|
19
|
+
'menu',
|
|
20
|
+
'plus',
|
|
21
|
+
'resultEmpty'
|
|
22
|
+
] as const;
|
|
23
|
+
|
|
24
|
+
export const GCSA_ICON_NAMES = [...GCSA_NAV_ICON_NAMES, ...GCSA_UI_ICON_NAMES] as const;
|
|
25
|
+
|
|
26
|
+
export type GcsaNavIconName = (typeof GCSA_NAV_ICON_NAMES)[number];
|
|
27
|
+
export type GcsaIconName = (typeof GCSA_ICON_NAMES)[number];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { GCSA_ICON_NAMES, type GcsaIconName } from './iconNames';
|
|
2
|
+
import chevronLeftSvg from './svg/chevron-left.svg?raw';
|
|
3
|
+
import menuSvg from './svg/menu.svg?raw';
|
|
4
|
+
|
|
5
|
+
const svgModules = import.meta.glob('./svg/*.svg', {
|
|
6
|
+
query: '?raw',
|
|
7
|
+
import: 'default',
|
|
8
|
+
eager: true
|
|
9
|
+
}) as Record<string, string>;
|
|
10
|
+
|
|
11
|
+
function fileStem(path: string): string {
|
|
12
|
+
const file = path.slice(path.lastIndexOf('/') + 1);
|
|
13
|
+
return file.replace(/\.svg$/, '');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function toIconKey(stem: string): string {
|
|
17
|
+
return stem.replace(/-([a-z])/g, (_, letter: string) => letter.toUpperCase());
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const registry = {
|
|
21
|
+
...Object.fromEntries(
|
|
22
|
+
Object.entries(svgModules).map(([path, svg]) => [toIconKey(fileStem(path)), svg])
|
|
23
|
+
),
|
|
24
|
+
menu: menuSvg,
|
|
25
|
+
chevronLeft: chevronLeftSvg
|
|
26
|
+
} as Record<GcsaIconName, string>;
|
|
27
|
+
|
|
28
|
+
for (const name of GCSA_ICON_NAMES) {
|
|
29
|
+
if (!registry[name]) {
|
|
30
|
+
throw new Error(`[gcsa-icons] missing svg file for icon "${name}"`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const GcsaIcons = registry;
|
|
35
|
+
|
|
36
|
+
export function getGcsaIconSvg(name: GcsaIconName): string {
|
|
37
|
+
return GcsaIcons[name];
|
|
38
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg viewBox="0 0 17.1429 17.1429" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
2
|
+
<path d="M8.57108 2.06954C8.8166 2.06954 9.05831 2.13268 9.27225 2.25313C9.48607 2.37358 9.66548 2.54721 9.79276 2.75704L15.8426 12.8566C15.9673 13.0727 16.0333 13.3181 16.034 13.5676C16.0346 13.8169 15.9699 14.0619 15.8465 14.2785C15.7229 14.4952 15.5449 14.6764 15.3299 14.8029C15.1149 14.9294 14.8703 14.9975 14.6209 15.0002H2.52127C2.27191 14.9975 2.02724 14.9294 1.81229 14.8029C1.5973 14.6764 1.41921 14.4952 1.29569 14.2785C1.17227 14.0619 1.10753 13.8169 1.10819 13.5676C1.10888 13.3181 1.17486 13.0727 1.29959 12.8566L7.3494 2.75704C7.47668 2.54721 7.65608 2.37358 7.86991 2.25313C8.08385 2.13268 8.32555 2.06954 8.57108 2.06954ZM7.75076 11.094V12.5227H9.17948V11.094H7.75076ZM7.75076 6.09395V9.66524H9.17948V6.09395H7.75076Z" fill="currentColor" />
|
|
3
|
+
<path d="M8.57129 12.1428H8.57772" stroke="currentColor" stroke-width="1.42857" />
|
|
4
|
+
</svg>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
2
|
+
<path d="M5 6.42853L13.1357 3.31417C13.1812 3.30135 13.2289 3.29788 13.2757 3.30397C13.3226 3.31007 13.3678 3.3256 13.4085 3.34963C13.4492 3.37366 13.4847 3.40569 13.5127 3.44379C13.5407 3.4819 13.5607 3.52527 13.5714 3.57131L14.6429 6.07139" stroke="currentColor" stroke-width="1.42857" stroke-linecap="square" stroke-linejoin="round" />
|
|
3
|
+
<path d="M15.3102 5.71431C15.6065 5.71443 15.8907 5.83136 16.1003 6.03951C16.3099 6.24788 16.4274 6.53096 16.4274 6.82564V8.57174H12.1423C11.7481 8.57198 11.4286 8.89148 11.4284 9.2856V12.143C11.4285 12.4881 11.6733 12.7766 11.9987 12.8432L12.1423 12.8579H16.4274V14.603C16.4274 14.8977 16.3099 15.1807 16.1003 15.3891C15.8907 15.5973 15.6065 15.7142 15.3102 15.7143H4.68913C4.39265 15.7143 4.10777 15.5974 3.89811 15.3891C3.68844 15.1807 3.57096 14.8977 3.57096 14.603V6.82564C3.57096 6.53096 3.68844 6.24788 3.89811 6.03951C4.10776 5.83124 4.39269 5.71431 4.68913 5.71431H15.3102ZM16.4274 11.4292H12.8571V10.0004H16.4274V11.4292Z" fill="currentColor" />
|
|
4
|
+
</svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18" /></svg>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
2
|
+
<path d="M9.99984 2.85712C13.9448 2.85712 17.1427 6.05498 17.1427 9.99998C17.1427 13.945 13.9448 17.1428 9.99984 17.1428C6.05484 17.1428 2.85699 13.945 2.85699 9.99998C2.85699 6.05498 6.05484 2.85712 9.99984 2.85712ZM9.99984 4.99998C9.02451 4.9999 8.07045 5.28508 7.25516 5.8204C6.43986 6.35571 5.79893 7.11779 5.4113 8.01278C5.02367 8.90778 4.90625 9.8966 5.07352 10.8575C5.24079 11.8184 5.68544 12.7093 6.3527 13.4207L6.46413 13.535L7.47413 12.525C6.91785 11.9691 6.5606 11.2452 6.45781 10.4655C6.35502 9.68585 6.51243 8.89406 6.90563 8.213C7.29883 7.53195 7.90582 6.99971 8.63242 6.69889C9.35902 6.39806 10.1646 6.34547 10.9241 6.54927L12.0413 5.43498C11.3991 5.14749 10.7034 4.99923 9.99984 4.99998ZM14.5656 7.95927L13.4506 9.07498C13.6122 9.68067 13.6118 10.3182 13.4495 10.9237C13.2871 11.5292 12.9685 12.0814 12.5256 12.525L13.5356 13.5357C14.0005 13.0719 14.3693 12.5207 14.6206 11.914C14.8719 11.3072 15.0008 10.6567 14.9998 9.99998C15.0007 9.29671 14.8527 8.60123 14.5656 7.95927ZM13.0298 5.95927L10.3691 8.61998C10.1575 8.5638 9.93584 8.55693 9.72116 8.5999C9.50647 8.64288 9.30452 8.73455 9.13084 8.86786C8.95716 9.00117 8.8164 9.17256 8.71939 9.36884C8.62237 9.56512 8.5717 9.78104 8.57127 9.99998C8.57126 10.2033 8.61466 10.4043 8.69857 10.5895C8.78247 10.7747 8.90495 10.9399 9.05781 11.074C9.21067 11.2081 9.3904 11.308 9.58497 11.367C9.77954 11.4261 9.98448 11.4429 10.1861 11.4164C10.3877 11.3899 10.5813 11.3207 10.754 11.2133C10.9267 11.106 11.0745 10.963 11.1875 10.794C11.3005 10.6249 11.3761 10.4337 11.4093 10.2331C11.4424 10.0325 11.4324 9.82712 11.3798 9.63069L14.0406 6.96927L13.0306 5.95927H13.0298Z" fill="currentColor" />
|
|
3
|
+
</svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg viewBox="0 0 23 23" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M0 11.5C0 10.6716 0.671573 10 1.5 10H21.5C22.3284 10 23 10.6716 23 11.5C23 12.3284 22.3284 13 21.5 13H1.5C0.671573 13 0 12.3284 0 11.5Z" fill="currentColor"/><path d="M11.5 0C12.3284 0 13 0.671574 13 1.5V21.5C13 22.3284 12.3284 23 11.5 23C10.6716 23 10 22.3284 10 21.5V1.5C10 0.671573 10.6716 0 11.5 0Z" fill="currentColor"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg viewBox="0 0 29 36" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path opacity="0.3" d="M2 0C0.895432 0 0 0.895431 0 2V34C0 35.1046 0.895431 36 2 36H27C28.1046 36 29 35.1046 29 34V11H17.9511V0H2Z" fill="currentColor"/><path d="M14.1667 23.5V21.8333H15C16.4167 21.8333 17.5 20.75 17.5 19.3333V18.5C17.5 17.0833 16.4167 16 15 16C13.5833 16 12.5 17.0833 12.5 18.5V19.3333H10.8333V18.5C10.8333 16.1667 12.6667 14.3333 15 14.3333C17.3333 14.3333 19.1667 16.1667 19.1667 18.5V19.3333C19.1667 21.3333 17.75 23 15.8333 23.4167V25.1667H14.1667V23.5ZM14.1667 26H15.8333V27.6667H14.1667V26Z" fill="currentColor"/><path opacity="0.3" d="M20.0234 0V9H29L20.0234 0Z" fill="currentColor"/></svg>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
2
|
+
<path d="M9.63281 2.71987C9.8588 2.5845 10.1412 2.5845 10.3672 2.71987L15.9033 6.04214C16.1184 6.17124 16.25 6.40361 16.25 6.65444V13.3449C16.25 13.5958 16.1185 13.8291 15.9033 13.9582L10.3672 17.2794C10.1411 17.4149 9.85887 17.4149 9.63281 17.2794L4.09668 13.9582C3.88154 13.8291 3.75 13.5958 3.75 13.3449V6.65444C3.75 6.40361 3.88163 6.17124 4.09668 6.04214L9.63281 2.71987ZM10 7.50015C8.61929 7.50015 7.5 8.61943 7.5 10.0001C7.5001 11.3808 8.61935 12.5001 10 12.5001C11.3807 12.5001 12.4999 11.3808 12.5 10.0001C12.5 8.61943 11.3807 7.50015 10 7.50015Z" fill="currentColor" />
|
|
3
|
+
</svg>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
|
|
2
|
+
<path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2" />
|
|
3
|
+
<circle cx="9" cy="7" r="4" />
|
|
4
|
+
<path d="M22 21v-2a4 4 0 0 0-3-3.87" />
|
|
5
|
+
<path d="M16 3.13a4 4 0 0 1 0 7.75" />
|
|
6
|
+
</svg>
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
export { GcsaConfigProvider } from './GcsaConfigProvider';
|
|
2
|
+
export { ConsoleShell } from './ConsoleShell';
|
|
3
|
+
export { ConsoleSidebar } from './ConsoleSidebar';
|
|
4
|
+
export { ConsoleHeader } from './ConsoleHeader';
|
|
5
|
+
export { ConsolePage } from './ConsolePage';
|
|
6
|
+
export { GcsaBrandMark } from './GcsaBrandMark';
|
|
7
|
+
|
|
8
|
+
export { GcsaButton } from './GcsaButton';
|
|
9
|
+
export { GcsaBadge } from './GcsaBadge';
|
|
10
|
+
export { GcsaCard } from './GcsaCard';
|
|
11
|
+
export { GcsaField } from './GcsaField';
|
|
12
|
+
export { GcsaInput } from './GcsaInput';
|
|
13
|
+
export { GcsaInputGroup } from './GcsaInputGroup';
|
|
14
|
+
export { GcsaTextarea } from './GcsaTextarea';
|
|
15
|
+
export { GcsaSelect } from './GcsaSelect';
|
|
16
|
+
export { GcsaMultiSelect } from './GcsaMultiSelect';
|
|
17
|
+
export { GcsaAutoComplete } from './GcsaAutoComplete';
|
|
18
|
+
export { GcsaCheckbox } from './GcsaCheckbox';
|
|
19
|
+
export { GcsaRadioGroup } from './GcsaRadioGroup';
|
|
20
|
+
export { GcsaSwitch } from './GcsaSwitch';
|
|
21
|
+
export { GcsaInputNumber } from './GcsaInputNumber';
|
|
22
|
+
export { GcsaDatePicker } from './GcsaDatePicker';
|
|
23
|
+
export { GcsaCalendar } from './GcsaCalendar';
|
|
24
|
+
export { GcsaDateRangePicker } from './GcsaDateRangePicker';
|
|
25
|
+
export { GcsaDateTimePicker } from './GcsaDateTimePicker';
|
|
26
|
+
export { GcsaTimePicker } from './GcsaTimePicker';
|
|
27
|
+
export { GcsaUpload } from './GcsaUpload';
|
|
28
|
+
export { GcsaCollapse } from './GcsaCollapse';
|
|
29
|
+
export { GcsaTree } from './GcsaTree';
|
|
30
|
+
export { GcsaCascader } from './GcsaCascader';
|
|
31
|
+
export { GcsaTransfer } from './GcsaTransfer';
|
|
32
|
+
export { GcsaImagePreview } from './GcsaImagePreview';
|
|
33
|
+
export { GcsaSteps } from './GcsaSteps';
|
|
34
|
+
export { GcsaTimeline } from './GcsaTimeline';
|
|
35
|
+
export type { GcsaCollapseProps } from './GcsaCollapse';
|
|
36
|
+
export type { GcsaCollapseItem } from './GcsaCollapse';
|
|
37
|
+
export type { GcsaTreeProps, GcsaTreeNode } from './GcsaTree';
|
|
38
|
+
export type { GcsaCascaderProps } from './GcsaCascader';
|
|
39
|
+
export type { GcsaTransferProps } from './GcsaTransfer';
|
|
40
|
+
export type { GcsaImagePreviewProps } from './GcsaImagePreview';
|
|
41
|
+
export type { GcsaStepsProps } from './GcsaSteps';
|
|
42
|
+
export type { GcsaTimelineProps } from './GcsaTimeline';
|
|
43
|
+
|
|
44
|
+
export { GcsaDataTable } from './GcsaDataTable';
|
|
45
|
+
export { GcsaForm } from './GcsaForm';
|
|
46
|
+
export { GcsaFormField } from './GcsaFormField';
|
|
47
|
+
export { GcsaPagination } from './GcsaPagination';
|
|
48
|
+
|
|
49
|
+
export { GcsaAlert } from './GcsaAlert';
|
|
50
|
+
export { GcsaSpin } from './GcsaSpin';
|
|
51
|
+
export { GcsaLoadingMask } from './GcsaLoadingMask';
|
|
52
|
+
export { GcsaLoading } from './GcsaLoading';
|
|
53
|
+
export type { GcsaLoadingInstance, GcsaLoadingOptions } from './GcsaLoading';
|
|
54
|
+
export type { GcsaLoadingMaskProps } from './GcsaLoadingMask';
|
|
55
|
+
export { GcsaSkeleton } from './GcsaSkeleton';
|
|
56
|
+
export { GcsaModal } from './GcsaModal';
|
|
57
|
+
export { GcsaDrawer } from './GcsaDrawer';
|
|
58
|
+
export { GcsaProgress } from './GcsaProgress';
|
|
59
|
+
export { GcsaResult } from './GcsaResult';
|
|
60
|
+
|
|
61
|
+
export { GcsaTabs } from './GcsaTabs';
|
|
62
|
+
export { GcsaBreadcrumb } from './GcsaBreadcrumb';
|
|
63
|
+
export { GcsaTag } from './GcsaTag';
|
|
64
|
+
export { GcsaStatistic } from './GcsaStatistic';
|
|
65
|
+
export { GcsaDescriptions } from './GcsaDescriptions';
|
|
66
|
+
export { GcsaAvatar } from './GcsaAvatar';
|
|
67
|
+
export { GcsaEmpty } from './GcsaEmpty';
|
|
68
|
+
export { GcsaChatPanel } from './GcsaChatPanel';
|
|
69
|
+
export { GcsaMarkdownRenderer } from './GcsaMarkdownRenderer';
|
|
70
|
+
|
|
71
|
+
export { GcsaDivider } from './GcsaDivider';
|
|
72
|
+
export { GcsaSpace } from './GcsaSpace';
|
|
73
|
+
export { GcsaTypography } from './GcsaTypography';
|
|
74
|
+
export { GcsaRow } from './GcsaRow';
|
|
75
|
+
export { GcsaIcon } from './GcsaIcon';
|
|
76
|
+
export { GcsaTooltip } from './GcsaTooltip';
|
|
77
|
+
export { GcsaPopover } from './GcsaPopover';
|
|
78
|
+
export { GcsaPopoverClose } from './GcsaPopoverClose';
|
|
79
|
+
export { GcsaDropdown } from './GcsaDropdown';
|
|
80
|
+
export { GcsaMenu } from './GcsaMenu';
|
|
81
|
+
export { GcsaPopconfirm } from './GcsaPopconfirm';
|
|
82
|
+
|
|
83
|
+
export { useGcsaMessage, useGcsaTheme } from './hooks/useGcsaTheme';
|
|
84
|
+
export { useGcsaComponentSize, useGcsaComponentSizeConfig, useGcsaButtonSize } from './hooks/useGcsaComponentSize';
|
|
85
|
+
export { useGcsaLocale, useGcsaLocaleMessages } from './hooks/useGcsaLocale';
|
|
86
|
+
export { useGcsaZIndex } from './hooks/useGcsaZIndex';
|
|
87
|
+
export { GCSA_RESTORE_DOCUMENT_THEME_KEY } from './hooks/useDocumentThemeSync';
|
|
88
|
+
export {
|
|
89
|
+
gcsaBooleanFieldBindings,
|
|
90
|
+
gcsaFieldError,
|
|
91
|
+
gcsaFieldInvalid,
|
|
92
|
+
gcsaNumberFieldBindings,
|
|
93
|
+
gcsaRadioFieldBindings,
|
|
94
|
+
gcsaTextFieldBindings
|
|
95
|
+
} from './hooks/useGcsaFormField';
|
|
96
|
+
export type { GcsaFormApi, GcsaFormValues } from './hooks/gcsaFormTypes';
|
|
97
|
+
export type { GcsaAnyFieldApi } from './hooks/useGcsaFormField';
|
|
98
|
+
export type { GcsaDropdownItem, GcsaDropdownPlacement, GcsaDropdownProps } from './GcsaDropdown';
|
|
99
|
+
export type { GcsaMenuProps, GcsaMenuItem, GcsaMenuMode } from './GcsaMenu';
|
|
100
|
+
export type { GcsaTooltipPlacement } from './GcsaTooltip';
|
|
101
|
+
export type { GcsaPopoverPlacement } from './GcsaPopover';
|
|
102
|
+
export type { GcsaPopconfirmPlacement } from './GcsaPopconfirm';
|
|
103
|
+
export type { GcsaIconName, GcsaNavIconName } from './icons';
|
|
104
|
+
export { GCSA_ICON_NAMES, GCSA_NAV_ICON_NAMES, GCSA_UI_ICON_NAMES } from './icons';
|
|
105
|
+
export type { GcsaTableCellSlotProps, GcsaTableHeaderSlotProps } from './utils/gcsaTableColumns';
|
|
106
|
+
export { gcsaTableColumnsToDefs, resolveGcsaTableColumns } from './utils/gcsaTableColumns';
|
|
107
|
+
|
|
108
|
+
export { gcsaLoginSchema, gcsaNotifySchema } from '@gcsa/console-core';
|
|
109
|
+
export type * from '@gcsa/console-core';
|
|
110
|
+
|
|
111
|
+
export type { GcsaBrandMarkProps } from './GcsaBrandMark';
|
|
112
|
+
export type { ConsoleSidebarProps } from './ConsoleSidebar';
|
|
113
|
+
export type { ConsoleHeaderProps } from './ConsoleHeader';
|
|
114
|
+
export type { ConsolePageProps } from './ConsolePage';
|
|
115
|
+
export type { GcsaButtonProps } from './GcsaButton';
|
|
116
|
+
export type { GcsaDataTableApi, GcsaDataTableProps } from './GcsaDataTable';
|
|
117
|
+
export type { GcsaChatPanelProps } from './GcsaChatPanel';
|
|
118
|
+
export type { GcsaMarkdownRendererProps } from './GcsaMarkdownRenderer';
|
|
119
|
+
export type { GcsaConfigProviderProps } from './GcsaConfigProvider';
|
|
120
|
+
export type { GcsaBadgeProps } from './GcsaBadge';
|
|
121
|
+
export type { GcsaCardProps } from './GcsaCard';
|
|
122
|
+
export type { GcsaTagProps } from './GcsaTag';
|
|
123
|
+
export type { GcsaDividerProps } from './GcsaDivider';
|
|
124
|
+
export type { GcsaSpaceProps } from './GcsaSpace';
|
|
125
|
+
export type { GcsaTypographyProps } from './GcsaTypography';
|
|
126
|
+
export type { GcsaRowProps } from './GcsaRow';
|
|
127
|
+
export type { GcsaAlertProps } from './GcsaAlert';
|
|
128
|
+
export type { GcsaEmptyProps } from './GcsaEmpty';
|
|
129
|
+
export type { GcsaSpinProps } from './GcsaSpin';
|
|
130
|
+
export type { GcsaSkeletonProps } from './GcsaSkeleton';
|
|
131
|
+
export type { GcsaAvatarProps } from './GcsaAvatar';
|
|
132
|
+
export type { GcsaStatisticProps } from './GcsaStatistic';
|
|
133
|
+
export type { GcsaProgressProps } from './GcsaProgress';
|
|
134
|
+
export type { GcsaResultProps } from './GcsaResult';
|
|
135
|
+
export type { GcsaTooltipProps } from './GcsaTooltip';
|
|
136
|
+
export type { GcsaPopoverProps, GcsaPopoverSize } from './GcsaPopover';
|
|
137
|
+
export type { GcsaPopconfirmProps } from './GcsaPopconfirm';
|
|
138
|
+
export type { GcsaModalProps } from './GcsaModal';
|
|
139
|
+
export type { GcsaDrawerProps, GcsaDrawerSize } from './GcsaDrawer';
|
|
140
|
+
export type { GcsaSelectProps, GcsaSelectPlacement } from './GcsaSelect';
|
|
141
|
+
export type { GcsaMultiSelectProps, GcsaMultiSelectPlacement } from './GcsaMultiSelect';
|
|
142
|
+
export type { GcsaAutoCompleteProps, GcsaAutoCompleteOption } from './GcsaAutoComplete';
|
|
143
|
+
export type { GcsaCheckboxProps } from './GcsaCheckbox';
|
|
144
|
+
export type { GcsaRadioGroupProps } from './GcsaRadioGroup';
|
|
145
|
+
export type { GcsaSwitchProps } from './GcsaSwitch';
|
|
146
|
+
export type { GcsaInputNumberProps } from './GcsaInputNumber';
|
|
147
|
+
export type { GcsaDatePickerProps } from './GcsaDatePicker';
|
|
148
|
+
export type { GcsaCalendarProps } from './GcsaCalendar';
|
|
149
|
+
export type { GcsaDateRangePickerProps } from './GcsaDateRangePicker';
|
|
150
|
+
export type { GcsaDateTimePickerProps } from './GcsaDateTimePicker';
|
|
151
|
+
export type { GcsaUploadProps } from './GcsaUpload';
|
|
152
|
+
export type { GcsaInputProps } from './GcsaInput';
|
|
153
|
+
export type { GcsaInputGroupProps } from './GcsaInputGroup';
|
|
154
|
+
export type { GcsaTextareaProps } from './GcsaTextarea';
|
|
155
|
+
export type { GcsaFieldProps } from './GcsaField';
|
|
156
|
+
export type { GcsaTabsProps, GcsaTabItem } from './GcsaTabs';
|
|
157
|
+
export type { GcsaPaginationProps } from './GcsaPagination';
|
|
158
|
+
export type { GcsaBreadcrumbProps, GcsaBreadcrumbItem } from './GcsaBreadcrumb';
|
|
159
|
+
export type { GcsaDescriptionsProps, GcsaDescriptionsItem } from './GcsaDescriptions';
|
|
160
|
+
export type { GcsaIconProps } from './GcsaIcon';
|
|
161
|
+
export type { GcsaFormProps } from './GcsaForm';
|
|
162
|
+
export type { GcsaFormFieldProps } from './GcsaFormField';
|
|
163
|
+
export type { GcsaTimePickerProps } from './GcsaTimePicker';
|
|
164
|
+
export type { GcsaPopoverCloseProps } from './GcsaPopoverClose';
|
|
165
|
+
export type { GcsaToastItem, GcsaToastStackProps } from './GcsaToastStack';
|
|
166
|
+
export type { ConsoleShellProps } from './ConsoleShell';
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import {
|
|
2
|
+
formatGcsaDateParts,
|
|
3
|
+
formatGcsaMonthParts,
|
|
4
|
+
type GcsaDatePickerMode,
|
|
5
|
+
type GcsaDateRangeValue,
|
|
6
|
+
type GcsaMonthRangeValue
|
|
7
|
+
} from '@gcsa/console-core';
|
|
8
|
+
import type { GcsaSelectOption } from '@gcsa/console-core';
|
|
9
|
+
import { parseDate, type DateValue } from '@ark-ui/react/date-picker';
|
|
10
|
+
|
|
11
|
+
export type GcsaDatePickerSelectCell = {
|
|
12
|
+
label: string;
|
|
13
|
+
value: number;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export function gcsaDatePickerCellsToOptions(cells: GcsaDatePickerSelectCell[]): GcsaSelectOption[] {
|
|
18
|
+
return cells.map(cell => ({
|
|
19
|
+
label: cell.label,
|
|
20
|
+
value: String(cell.value),
|
|
21
|
+
disabled: cell.disabled
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function gcsaNormalizeDateBoundary(value: string | undefined, mode: GcsaDatePickerMode): string | undefined {
|
|
26
|
+
if (!value) return undefined;
|
|
27
|
+
if (mode === 'month' && /^\d{4}-\d{2}$/.test(value)) return `${value}-01`;
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function gcsaDateValueToOutputString(
|
|
32
|
+
value: DateValue | undefined | null,
|
|
33
|
+
mode: GcsaDatePickerMode
|
|
34
|
+
): string {
|
|
35
|
+
if (!value || !('month' in value)) return '';
|
|
36
|
+
if (mode === 'month') return formatGcsaMonthParts(value.year, value.month);
|
|
37
|
+
if ('day' in value) return formatGcsaDateParts(value.year, value.month, value.day);
|
|
38
|
+
return '';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function gcsaDateValueToString(value: DateValue | undefined | null): string {
|
|
42
|
+
return gcsaDateValueToOutputString(value, 'date');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function gcsaStringToDateValues(
|
|
46
|
+
value: string | undefined | null,
|
|
47
|
+
mode: GcsaDatePickerMode = 'date'
|
|
48
|
+
): DateValue[] | undefined {
|
|
49
|
+
if (!value) return undefined;
|
|
50
|
+
const normalized = gcsaNormalizeDateBoundary(value, mode);
|
|
51
|
+
if (!normalized) return undefined;
|
|
52
|
+
try {
|
|
53
|
+
return [parseDate(normalized)];
|
|
54
|
+
} catch {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function gcsaDateRangeToDateValues(
|
|
60
|
+
range: GcsaDateRangeValue | GcsaMonthRangeValue | undefined | null,
|
|
61
|
+
mode: GcsaDatePickerMode = 'date'
|
|
62
|
+
): DateValue[] | undefined {
|
|
63
|
+
if (!range) return undefined;
|
|
64
|
+
const values: DateValue[] = [];
|
|
65
|
+
for (const part of range) {
|
|
66
|
+
if (!part) continue;
|
|
67
|
+
const parsed = gcsaStringToDateValues(part, mode);
|
|
68
|
+
if (parsed?.[0]) values.push(parsed[0]);
|
|
69
|
+
}
|
|
70
|
+
return values.length ? values : undefined;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function gcsaDateValuesToRange(
|
|
74
|
+
values: DateValue[] | undefined | null,
|
|
75
|
+
mode: GcsaDatePickerMode = 'date'
|
|
76
|
+
): GcsaDateRangeValue | GcsaMonthRangeValue {
|
|
77
|
+
return [gcsaDateValueToOutputString(values?.[0], mode), gcsaDateValueToOutputString(values?.[1], mode)];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function gcsaDatePickerFormat(
|
|
81
|
+
date: DateValue,
|
|
82
|
+
_details: { locale: string; timeZone: string },
|
|
83
|
+
mode: GcsaDatePickerMode
|
|
84
|
+
): string {
|
|
85
|
+
return gcsaDateValueToOutputString(date, mode);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function gcsaDatePickerParse(
|
|
89
|
+
value: string,
|
|
90
|
+
_details: { locale: string; timeZone: string },
|
|
91
|
+
mode: GcsaDatePickerMode
|
|
92
|
+
): DateValue | undefined {
|
|
93
|
+
const parsed = gcsaStringToDateValues(value, mode);
|
|
94
|
+
return parsed?.[0];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** ISO 日期时间字符串 YYYY-MM-DD HH:mm:ss */
|
|
98
|
+
export type { GcsaDateTimeString } from '@gcsa/console-core';
|
|
99
|
+
export { gcsaJoinDateTime, gcsaSplitDateTime } from '@gcsa/console-core';
|