@khipu/design-system 0.2.0-alpha.76 → 0.2.0-alpha.78
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/beercss/khipu-beercss.css +48 -4
- package/dist/beercss/khipu-beercss.min.css +1 -1
- package/dist/beercss/khipu-beercss.scoped.css +48 -4
- package/dist/beercss/khipu-beercss.scoped.min.css +1 -1
- package/dist/beercss/metadata.json +5 -5
- package/dist/index.d.mts +42 -1
- package/dist/index.d.ts +42 -1
- package/dist/index.js +79 -0
- package/dist/index.mjs +78 -0
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khipu/design-system/beercss",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.78",
|
|
4
4
|
"description": "Khipu BeerCSS bundle with Material Design 3 and Khipu customizations",
|
|
5
|
-
"buildDate": "2026-06-
|
|
5
|
+
"buildDate": "2026-06-26T12:31:17.989Z",
|
|
6
6
|
"includes": {
|
|
7
7
|
"beercss": "4.0.1",
|
|
8
8
|
"khipu-tokens": "latest",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
},
|
|
20
20
|
"scopeClass": ".kds-theme-root",
|
|
21
21
|
"cdn": {
|
|
22
|
-
"css": "https://cdn.jsdelivr.net/npm/@khipu/design-system@0.2.0-alpha.
|
|
23
|
-
"cssScoped": "https://cdn.jsdelivr.net/npm/@khipu/design-system@0.2.0-alpha.
|
|
24
|
-
"js": "https://cdn.jsdelivr.net/npm/@khipu/design-system@0.2.0-alpha.
|
|
22
|
+
"css": "https://cdn.jsdelivr.net/npm/@khipu/design-system@0.2.0-alpha.78/dist/beercss/khipu-beercss.min.css",
|
|
23
|
+
"cssScoped": "https://cdn.jsdelivr.net/npm/@khipu/design-system@0.2.0-alpha.78/dist/beercss/khipu-beercss.scoped.min.css",
|
|
24
|
+
"js": "https://cdn.jsdelivr.net/npm/@khipu/design-system@0.2.0-alpha.78/dist/beercss/khipu-beercss.min.js"
|
|
25
25
|
}
|
|
26
26
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -3667,6 +3667,47 @@ declare function useTabsKeyboard(tabCount: number, activeIndex: number, onChange
|
|
|
3667
3667
|
onKeyDown: (e: React.KeyboardEvent) => void;
|
|
3668
3668
|
};
|
|
3669
3669
|
|
|
3670
|
+
/**
|
|
3671
|
+
* Options for {@link useStickyInvoiceCollapse}.
|
|
3672
|
+
*/
|
|
3673
|
+
interface UseStickyInvoiceCollapseOptions {
|
|
3674
|
+
/**
|
|
3675
|
+
* Called once each time the sticky header *starts* collapsing (scroll crosses the
|
|
3676
|
+
* threshold, progress 0 → >0). Use it to close any open expand panel from React
|
|
3677
|
+
* state — mirrors the vanilla DS behavior that closes `[data-expand-toggle]` panels
|
|
3678
|
+
* as soon as the header begins to collapse. Not fired again until the header
|
|
3679
|
+
* fully expands (progress returns to 0).
|
|
3680
|
+
*/
|
|
3681
|
+
onCollapseStart?: () => void;
|
|
3682
|
+
/**
|
|
3683
|
+
* Scroll/collapse range end in px (header is fully collapsed at this scroll). Default 20.
|
|
3684
|
+
*/
|
|
3685
|
+
collapseEnd?: number;
|
|
3686
|
+
/**
|
|
3687
|
+
* Max viewport width (px) for the collapse to apply. Desktop is always expanded. Default 768.
|
|
3688
|
+
*/
|
|
3689
|
+
mobileBreakpoint?: number;
|
|
3690
|
+
}
|
|
3691
|
+
/**
|
|
3692
|
+
* React port of the DS vanilla `initStickyInvoice` (`khipu-init.js`).
|
|
3693
|
+
*
|
|
3694
|
+
* On **mobile only** (< `mobileBreakpoint`), maps scroll (0 → `collapseEnd`px) to
|
|
3695
|
+
* `--collapse-progress` (0 → 1) on `.kds-screen.active`; the scoped DS CSS interpolates
|
|
3696
|
+
* the sticky-header collapse + box-shadow. Also caches `--collapse-collapsible-h`,
|
|
3697
|
+
* toggles `.is-collapsed` on `.kds-invoice-sticky`, and closes any open expand panel as
|
|
3698
|
+
* soon as the header starts collapsing (DOM `[data-expand-toggle]` / `.kds-expand-toggle`
|
|
3699
|
+
* for uncontrolled consumers, plus the {@link UseStickyInvoiceCollapseOptions.onCollapseStart}
|
|
3700
|
+
* callback for React-controlled toggles).
|
|
3701
|
+
*
|
|
3702
|
+
* Works standalone (`window.scrollY`) and **embedded in an iframe**, where the widget does
|
|
3703
|
+
* not scroll internally and the parent posts the scroll offset via
|
|
3704
|
+
* `postMessage({ type: 'VIEWPORT_OFFSET', offsetTop })`.
|
|
3705
|
+
*
|
|
3706
|
+
* This hook only reads/writes the DOM and `window` listeners; it renders nothing and
|
|
3707
|
+
* returns nothing. Call it once near the root of the payment screen.
|
|
3708
|
+
*/
|
|
3709
|
+
declare function useStickyInvoiceCollapse(options?: UseStickyInvoiceCollapseOptions): void;
|
|
3710
|
+
|
|
3670
3711
|
/**
|
|
3671
3712
|
* Khipu Design System - Core Utilities
|
|
3672
3713
|
*
|
|
@@ -3685,4 +3726,4 @@ declare function getContrastColor(hex: string): string;
|
|
|
3685
3726
|
*/
|
|
3686
3727
|
declare function lighten(hex: string, amount: number): string;
|
|
3687
3728
|
|
|
3688
|
-
export { type Colors, KdsAccordion, KdsAccordionDetails, type KdsAccordionDetailsProps, type KdsAccordionProps, KdsAccordionSummary, type KdsAccordionSummaryProps, KdsAlert, type KdsAlertProps, type KdsAlertSeverity, KdsBankList, type KdsBankListProps, KdsBankModal, type KdsBankModalProps, KdsBankRow, type KdsBankRowProps, KdsBillAttachment, type KdsBillAttachmentProps, KdsBillAttachments, type KdsBillAttachmentsProps, KdsBottomSheet, type KdsBottomSheetProps, KdsButton, type KdsButtonProps, type KdsButtonSize, type KdsButtonVariant, KdsCard, KdsCardBody, KdsCardFooter, KdsCardHeader, KdsCardPlan, type KdsCardPlanProps, type KdsCardProps, type KdsCardSectionProps, KdsCardSelector, type KdsCardSelectorProps, type KdsCardVariant, KdsCheckbox, type KdsCheckboxProps, KdsChip, type KdsChipColor, type KdsChipProps, KdsCopyButton, type KdsCopyButtonProps, KdsCopyRow, type KdsCopyRowProps, KdsCopyableTable, type KdsCopyableTableProps, type KdsCopyableTableRow, KdsCountdown, type KdsCountdownProps, KdsDivider, type KdsDividerProps, KdsExpandPanel, type KdsExpandPanelProps, KdsInvoiceSticky, type KdsInvoiceStickyProps, KdsLinearProgress, type KdsLinearProgressProps, KdsMerchantTile, type KdsMerchantTileProps, KdsMontoRow, type KdsMontoRowProps, KdsPaymentTotal, type KdsPaymentTotalProps, type KdsPaymentTotalVariant, KdsQrRow, type KdsQrRowProps, KdsRadioGroup, type KdsRadioGroupProps, type KdsRadioOption, type KdsRecapItem, KdsRecapList, type KdsRecapListProps, KdsSearchField, type KdsSearchFieldProps, KdsSectionNote, type KdsSectionNoteProps, KdsSecureFooter, type KdsSecureFooterProps, KdsSecureLoader, type KdsSecureLoaderProps, KdsSegmentedTabs, type KdsSegmentedTabsProps, KdsSelect, type KdsSelectOption, type KdsSelectProps, KdsSnackbar, type KdsSnackbarProps, type KdsSnackbarType, KdsSpinner, type KdsSpinnerProps, type KdsSpinnerSize, KdsStatusBlock, type KdsStatusBlockProps, type KdsStatusType, KdsStepper, type KdsStepperProps, KdsTab, KdsTabPanel, type KdsTabPanelProps, type KdsTabProps, KdsTabs, type KdsTabsProps, KdsTextField, type KdsTextFieldProps, KdsThemeProvider, type KdsThemeProviderProps, KdsTooltip, type KdsTooltipPlacement, type KdsTooltipProps, KdsTypography, type KdsTypographyProps, type KdsTypographyVariant, type ThemeMode, type Tokens, type TokensByMode, type Typography as TypographyTokens, borderRadius, breakpoints, colors, colorsByMode, fontFamilies, fontSizes, fontWeights, getContrastColor, letterSpacings, lighten, lineHeights, semanticSpacing, shadows, spacing, tokens, tokensByMode, transitions, typography, useAutoHide, useCopyToClipboard, useCountdown, useTabsKeyboard, zIndex };
|
|
3729
|
+
export { type Colors, KdsAccordion, KdsAccordionDetails, type KdsAccordionDetailsProps, type KdsAccordionProps, KdsAccordionSummary, type KdsAccordionSummaryProps, KdsAlert, type KdsAlertProps, type KdsAlertSeverity, KdsBankList, type KdsBankListProps, KdsBankModal, type KdsBankModalProps, KdsBankRow, type KdsBankRowProps, KdsBillAttachment, type KdsBillAttachmentProps, KdsBillAttachments, type KdsBillAttachmentsProps, KdsBottomSheet, type KdsBottomSheetProps, KdsButton, type KdsButtonProps, type KdsButtonSize, type KdsButtonVariant, KdsCard, KdsCardBody, KdsCardFooter, KdsCardHeader, KdsCardPlan, type KdsCardPlanProps, type KdsCardProps, type KdsCardSectionProps, KdsCardSelector, type KdsCardSelectorProps, type KdsCardVariant, KdsCheckbox, type KdsCheckboxProps, KdsChip, type KdsChipColor, type KdsChipProps, KdsCopyButton, type KdsCopyButtonProps, KdsCopyRow, type KdsCopyRowProps, KdsCopyableTable, type KdsCopyableTableProps, type KdsCopyableTableRow, KdsCountdown, type KdsCountdownProps, KdsDivider, type KdsDividerProps, KdsExpandPanel, type KdsExpandPanelProps, KdsInvoiceSticky, type KdsInvoiceStickyProps, KdsLinearProgress, type KdsLinearProgressProps, KdsMerchantTile, type KdsMerchantTileProps, KdsMontoRow, type KdsMontoRowProps, KdsPaymentTotal, type KdsPaymentTotalProps, type KdsPaymentTotalVariant, KdsQrRow, type KdsQrRowProps, KdsRadioGroup, type KdsRadioGroupProps, type KdsRadioOption, type KdsRecapItem, KdsRecapList, type KdsRecapListProps, KdsSearchField, type KdsSearchFieldProps, KdsSectionNote, type KdsSectionNoteProps, KdsSecureFooter, type KdsSecureFooterProps, KdsSecureLoader, type KdsSecureLoaderProps, KdsSegmentedTabs, type KdsSegmentedTabsProps, KdsSelect, type KdsSelectOption, type KdsSelectProps, KdsSnackbar, type KdsSnackbarProps, type KdsSnackbarType, KdsSpinner, type KdsSpinnerProps, type KdsSpinnerSize, KdsStatusBlock, type KdsStatusBlockProps, type KdsStatusType, KdsStepper, type KdsStepperProps, KdsTab, KdsTabPanel, type KdsTabPanelProps, type KdsTabProps, KdsTabs, type KdsTabsProps, KdsTextField, type KdsTextFieldProps, KdsThemeProvider, type KdsThemeProviderProps, KdsTooltip, type KdsTooltipPlacement, type KdsTooltipProps, KdsTypography, type KdsTypographyProps, type KdsTypographyVariant, type ThemeMode, type Tokens, type TokensByMode, type Typography as TypographyTokens, type UseStickyInvoiceCollapseOptions, borderRadius, breakpoints, colors, colorsByMode, fontFamilies, fontSizes, fontWeights, getContrastColor, letterSpacings, lighten, lineHeights, semanticSpacing, shadows, spacing, tokens, tokensByMode, transitions, typography, useAutoHide, useCopyToClipboard, useCountdown, useStickyInvoiceCollapse, useTabsKeyboard, zIndex };
|
package/dist/index.d.ts
CHANGED
|
@@ -3667,6 +3667,47 @@ declare function useTabsKeyboard(tabCount: number, activeIndex: number, onChange
|
|
|
3667
3667
|
onKeyDown: (e: React.KeyboardEvent) => void;
|
|
3668
3668
|
};
|
|
3669
3669
|
|
|
3670
|
+
/**
|
|
3671
|
+
* Options for {@link useStickyInvoiceCollapse}.
|
|
3672
|
+
*/
|
|
3673
|
+
interface UseStickyInvoiceCollapseOptions {
|
|
3674
|
+
/**
|
|
3675
|
+
* Called once each time the sticky header *starts* collapsing (scroll crosses the
|
|
3676
|
+
* threshold, progress 0 → >0). Use it to close any open expand panel from React
|
|
3677
|
+
* state — mirrors the vanilla DS behavior that closes `[data-expand-toggle]` panels
|
|
3678
|
+
* as soon as the header begins to collapse. Not fired again until the header
|
|
3679
|
+
* fully expands (progress returns to 0).
|
|
3680
|
+
*/
|
|
3681
|
+
onCollapseStart?: () => void;
|
|
3682
|
+
/**
|
|
3683
|
+
* Scroll/collapse range end in px (header is fully collapsed at this scroll). Default 20.
|
|
3684
|
+
*/
|
|
3685
|
+
collapseEnd?: number;
|
|
3686
|
+
/**
|
|
3687
|
+
* Max viewport width (px) for the collapse to apply. Desktop is always expanded. Default 768.
|
|
3688
|
+
*/
|
|
3689
|
+
mobileBreakpoint?: number;
|
|
3690
|
+
}
|
|
3691
|
+
/**
|
|
3692
|
+
* React port of the DS vanilla `initStickyInvoice` (`khipu-init.js`).
|
|
3693
|
+
*
|
|
3694
|
+
* On **mobile only** (< `mobileBreakpoint`), maps scroll (0 → `collapseEnd`px) to
|
|
3695
|
+
* `--collapse-progress` (0 → 1) on `.kds-screen.active`; the scoped DS CSS interpolates
|
|
3696
|
+
* the sticky-header collapse + box-shadow. Also caches `--collapse-collapsible-h`,
|
|
3697
|
+
* toggles `.is-collapsed` on `.kds-invoice-sticky`, and closes any open expand panel as
|
|
3698
|
+
* soon as the header starts collapsing (DOM `[data-expand-toggle]` / `.kds-expand-toggle`
|
|
3699
|
+
* for uncontrolled consumers, plus the {@link UseStickyInvoiceCollapseOptions.onCollapseStart}
|
|
3700
|
+
* callback for React-controlled toggles).
|
|
3701
|
+
*
|
|
3702
|
+
* Works standalone (`window.scrollY`) and **embedded in an iframe**, where the widget does
|
|
3703
|
+
* not scroll internally and the parent posts the scroll offset via
|
|
3704
|
+
* `postMessage({ type: 'VIEWPORT_OFFSET', offsetTop })`.
|
|
3705
|
+
*
|
|
3706
|
+
* This hook only reads/writes the DOM and `window` listeners; it renders nothing and
|
|
3707
|
+
* returns nothing. Call it once near the root of the payment screen.
|
|
3708
|
+
*/
|
|
3709
|
+
declare function useStickyInvoiceCollapse(options?: UseStickyInvoiceCollapseOptions): void;
|
|
3710
|
+
|
|
3670
3711
|
/**
|
|
3671
3712
|
* Khipu Design System - Core Utilities
|
|
3672
3713
|
*
|
|
@@ -3685,4 +3726,4 @@ declare function getContrastColor(hex: string): string;
|
|
|
3685
3726
|
*/
|
|
3686
3727
|
declare function lighten(hex: string, amount: number): string;
|
|
3687
3728
|
|
|
3688
|
-
export { type Colors, KdsAccordion, KdsAccordionDetails, type KdsAccordionDetailsProps, type KdsAccordionProps, KdsAccordionSummary, type KdsAccordionSummaryProps, KdsAlert, type KdsAlertProps, type KdsAlertSeverity, KdsBankList, type KdsBankListProps, KdsBankModal, type KdsBankModalProps, KdsBankRow, type KdsBankRowProps, KdsBillAttachment, type KdsBillAttachmentProps, KdsBillAttachments, type KdsBillAttachmentsProps, KdsBottomSheet, type KdsBottomSheetProps, KdsButton, type KdsButtonProps, type KdsButtonSize, type KdsButtonVariant, KdsCard, KdsCardBody, KdsCardFooter, KdsCardHeader, KdsCardPlan, type KdsCardPlanProps, type KdsCardProps, type KdsCardSectionProps, KdsCardSelector, type KdsCardSelectorProps, type KdsCardVariant, KdsCheckbox, type KdsCheckboxProps, KdsChip, type KdsChipColor, type KdsChipProps, KdsCopyButton, type KdsCopyButtonProps, KdsCopyRow, type KdsCopyRowProps, KdsCopyableTable, type KdsCopyableTableProps, type KdsCopyableTableRow, KdsCountdown, type KdsCountdownProps, KdsDivider, type KdsDividerProps, KdsExpandPanel, type KdsExpandPanelProps, KdsInvoiceSticky, type KdsInvoiceStickyProps, KdsLinearProgress, type KdsLinearProgressProps, KdsMerchantTile, type KdsMerchantTileProps, KdsMontoRow, type KdsMontoRowProps, KdsPaymentTotal, type KdsPaymentTotalProps, type KdsPaymentTotalVariant, KdsQrRow, type KdsQrRowProps, KdsRadioGroup, type KdsRadioGroupProps, type KdsRadioOption, type KdsRecapItem, KdsRecapList, type KdsRecapListProps, KdsSearchField, type KdsSearchFieldProps, KdsSectionNote, type KdsSectionNoteProps, KdsSecureFooter, type KdsSecureFooterProps, KdsSecureLoader, type KdsSecureLoaderProps, KdsSegmentedTabs, type KdsSegmentedTabsProps, KdsSelect, type KdsSelectOption, type KdsSelectProps, KdsSnackbar, type KdsSnackbarProps, type KdsSnackbarType, KdsSpinner, type KdsSpinnerProps, type KdsSpinnerSize, KdsStatusBlock, type KdsStatusBlockProps, type KdsStatusType, KdsStepper, type KdsStepperProps, KdsTab, KdsTabPanel, type KdsTabPanelProps, type KdsTabProps, KdsTabs, type KdsTabsProps, KdsTextField, type KdsTextFieldProps, KdsThemeProvider, type KdsThemeProviderProps, KdsTooltip, type KdsTooltipPlacement, type KdsTooltipProps, KdsTypography, type KdsTypographyProps, type KdsTypographyVariant, type ThemeMode, type Tokens, type TokensByMode, type Typography as TypographyTokens, borderRadius, breakpoints, colors, colorsByMode, fontFamilies, fontSizes, fontWeights, getContrastColor, letterSpacings, lighten, lineHeights, semanticSpacing, shadows, spacing, tokens, tokensByMode, transitions, typography, useAutoHide, useCopyToClipboard, useCountdown, useTabsKeyboard, zIndex };
|
|
3729
|
+
export { type Colors, KdsAccordion, KdsAccordionDetails, type KdsAccordionDetailsProps, type KdsAccordionProps, KdsAccordionSummary, type KdsAccordionSummaryProps, KdsAlert, type KdsAlertProps, type KdsAlertSeverity, KdsBankList, type KdsBankListProps, KdsBankModal, type KdsBankModalProps, KdsBankRow, type KdsBankRowProps, KdsBillAttachment, type KdsBillAttachmentProps, KdsBillAttachments, type KdsBillAttachmentsProps, KdsBottomSheet, type KdsBottomSheetProps, KdsButton, type KdsButtonProps, type KdsButtonSize, type KdsButtonVariant, KdsCard, KdsCardBody, KdsCardFooter, KdsCardHeader, KdsCardPlan, type KdsCardPlanProps, type KdsCardProps, type KdsCardSectionProps, KdsCardSelector, type KdsCardSelectorProps, type KdsCardVariant, KdsCheckbox, type KdsCheckboxProps, KdsChip, type KdsChipColor, type KdsChipProps, KdsCopyButton, type KdsCopyButtonProps, KdsCopyRow, type KdsCopyRowProps, KdsCopyableTable, type KdsCopyableTableProps, type KdsCopyableTableRow, KdsCountdown, type KdsCountdownProps, KdsDivider, type KdsDividerProps, KdsExpandPanel, type KdsExpandPanelProps, KdsInvoiceSticky, type KdsInvoiceStickyProps, KdsLinearProgress, type KdsLinearProgressProps, KdsMerchantTile, type KdsMerchantTileProps, KdsMontoRow, type KdsMontoRowProps, KdsPaymentTotal, type KdsPaymentTotalProps, type KdsPaymentTotalVariant, KdsQrRow, type KdsQrRowProps, KdsRadioGroup, type KdsRadioGroupProps, type KdsRadioOption, type KdsRecapItem, KdsRecapList, type KdsRecapListProps, KdsSearchField, type KdsSearchFieldProps, KdsSectionNote, type KdsSectionNoteProps, KdsSecureFooter, type KdsSecureFooterProps, KdsSecureLoader, type KdsSecureLoaderProps, KdsSegmentedTabs, type KdsSegmentedTabsProps, KdsSelect, type KdsSelectOption, type KdsSelectProps, KdsSnackbar, type KdsSnackbarProps, type KdsSnackbarType, KdsSpinner, type KdsSpinnerProps, type KdsSpinnerSize, KdsStatusBlock, type KdsStatusBlockProps, type KdsStatusType, KdsStepper, type KdsStepperProps, KdsTab, KdsTabPanel, type KdsTabPanelProps, type KdsTabProps, KdsTabs, type KdsTabsProps, KdsTextField, type KdsTextFieldProps, KdsThemeProvider, type KdsThemeProviderProps, KdsTooltip, type KdsTooltipPlacement, type KdsTooltipProps, KdsTypography, type KdsTypographyProps, type KdsTypographyVariant, type ThemeMode, type Tokens, type TokensByMode, type Typography as TypographyTokens, type UseStickyInvoiceCollapseOptions, borderRadius, breakpoints, colors, colorsByMode, fontFamilies, fontSizes, fontWeights, getContrastColor, letterSpacings, lighten, lineHeights, semanticSpacing, shadows, spacing, tokens, tokensByMode, transitions, typography, useAutoHide, useCopyToClipboard, useCountdown, useStickyInvoiceCollapse, useTabsKeyboard, zIndex };
|
package/dist/index.js
CHANGED
|
@@ -102,6 +102,7 @@ __export(index_exports, {
|
|
|
102
102
|
useAutoHide: () => useAutoHide,
|
|
103
103
|
useCopyToClipboard: () => useCopyToClipboard,
|
|
104
104
|
useCountdown: () => useCountdown,
|
|
105
|
+
useStickyInvoiceCollapse: () => useStickyInvoiceCollapse,
|
|
105
106
|
useTabsKeyboard: () => useTabsKeyboard,
|
|
106
107
|
zIndex: () => zIndex
|
|
107
108
|
});
|
|
@@ -2627,6 +2628,83 @@ var KdsBillAttachments = (0, import_react45.forwardRef)(
|
|
|
2627
2628
|
({ children, className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { ref, className: (0, import_clsx.clsx)("kds-bill-attachments", className), ...props, children })
|
|
2628
2629
|
);
|
|
2629
2630
|
KdsBillAttachments.displayName = "KdsBillAttachments";
|
|
2631
|
+
|
|
2632
|
+
// src/components/core/hooks/useStickyInvoiceCollapse.ts
|
|
2633
|
+
var import_react46 = require("react");
|
|
2634
|
+
function useStickyInvoiceCollapse(options = {}) {
|
|
2635
|
+
const { onCollapseStart, collapseEnd = 20, mobileBreakpoint = 768 } = options;
|
|
2636
|
+
const onCollapseStartRef = (0, import_react46.useRef)(onCollapseStart);
|
|
2637
|
+
onCollapseStartRef.current = onCollapseStart;
|
|
2638
|
+
(0, import_react46.useEffect)(() => {
|
|
2639
|
+
let viewportOffset = 0;
|
|
2640
|
+
let ticking = false;
|
|
2641
|
+
let wasCollapsing = false;
|
|
2642
|
+
const isMobile = () => window.innerWidth < mobileBreakpoint;
|
|
2643
|
+
const closeOpenPanels = (sticky) => {
|
|
2644
|
+
const toggles = sticky.querySelectorAll(
|
|
2645
|
+
'[data-expand-toggle][aria-expanded="true"], .kds-expand-toggle[aria-expanded="true"]'
|
|
2646
|
+
);
|
|
2647
|
+
toggles.forEach((toggle) => {
|
|
2648
|
+
toggle.setAttribute("aria-expanded", "false");
|
|
2649
|
+
const panelId = toggle.getAttribute("aria-controls");
|
|
2650
|
+
const panel = panelId ? document.getElementById(panelId) : toggle.parentElement?.querySelector("[data-expand-panel], .kds-expand-panel");
|
|
2651
|
+
panel?.classList.remove("open");
|
|
2652
|
+
});
|
|
2653
|
+
};
|
|
2654
|
+
const apply = () => {
|
|
2655
|
+
ticking = false;
|
|
2656
|
+
const screen = document.querySelector(".kds-screen.active");
|
|
2657
|
+
if (!screen) return;
|
|
2658
|
+
const sticky = screen.querySelector(".kds-invoice-sticky");
|
|
2659
|
+
if (!sticky || !isMobile()) {
|
|
2660
|
+
screen.style.removeProperty("--collapse-progress");
|
|
2661
|
+
screen.style.removeProperty("--collapse-collapsible-h");
|
|
2662
|
+
sticky?.classList.remove("is-collapsed");
|
|
2663
|
+
wasCollapsing = false;
|
|
2664
|
+
return;
|
|
2665
|
+
}
|
|
2666
|
+
const scrollY = Math.max(window.scrollY || window.pageYOffset || 0, viewportOffset);
|
|
2667
|
+
const progress = Math.min(Math.max(scrollY / collapseEnd, 0), 1);
|
|
2668
|
+
if (!screen.style.getPropertyValue("--collapse-collapsible-h")) {
|
|
2669
|
+
const collapsible = sticky.querySelector(".kds-invoice-collapsible");
|
|
2670
|
+
if (collapsible) {
|
|
2671
|
+
screen.style.setProperty("--collapse-collapsible-h", `${collapsible.offsetHeight}px`);
|
|
2672
|
+
}
|
|
2673
|
+
}
|
|
2674
|
+
screen.style.setProperty("--collapse-progress", String(progress));
|
|
2675
|
+
sticky.classList.toggle("is-collapsed", progress >= 1);
|
|
2676
|
+
if (progress > 0) {
|
|
2677
|
+
if (!wasCollapsing) {
|
|
2678
|
+
wasCollapsing = true;
|
|
2679
|
+
closeOpenPanels(sticky);
|
|
2680
|
+
onCollapseStartRef.current?.();
|
|
2681
|
+
}
|
|
2682
|
+
} else {
|
|
2683
|
+
wasCollapsing = false;
|
|
2684
|
+
}
|
|
2685
|
+
};
|
|
2686
|
+
const onScroll = () => {
|
|
2687
|
+
if (ticking) return;
|
|
2688
|
+
ticking = true;
|
|
2689
|
+
window.requestAnimationFrame(apply);
|
|
2690
|
+
};
|
|
2691
|
+
const onMessage = (event) => {
|
|
2692
|
+
if (event.data && event.data.type === "VIEWPORT_OFFSET") {
|
|
2693
|
+
viewportOffset = Math.max(0, event.data.offsetTop || 0);
|
|
2694
|
+
onScroll();
|
|
2695
|
+
}
|
|
2696
|
+
};
|
|
2697
|
+
window.addEventListener("scroll", onScroll, { passive: true });
|
|
2698
|
+
window.addEventListener("resize", onScroll);
|
|
2699
|
+
window.addEventListener("message", onMessage);
|
|
2700
|
+
apply();
|
|
2701
|
+
return () => {
|
|
2702
|
+
window.removeEventListener("scroll", onScroll);
|
|
2703
|
+
window.removeEventListener("resize", onScroll);
|
|
2704
|
+
window.removeEventListener("message", onMessage);
|
|
2705
|
+
};
|
|
2706
|
+
}, [collapseEnd, mobileBreakpoint]);
|
|
2707
|
+
}
|
|
2630
2708
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2631
2709
|
0 && (module.exports = {
|
|
2632
2710
|
KdsAccordion,
|
|
@@ -2701,6 +2779,7 @@ KdsBillAttachments.displayName = "KdsBillAttachments";
|
|
|
2701
2779
|
useAutoHide,
|
|
2702
2780
|
useCopyToClipboard,
|
|
2703
2781
|
useCountdown,
|
|
2782
|
+
useStickyInvoiceCollapse,
|
|
2704
2783
|
useTabsKeyboard,
|
|
2705
2784
|
zIndex
|
|
2706
2785
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -2518,6 +2518,83 @@ var KdsBillAttachments = forwardRef41(
|
|
|
2518
2518
|
({ children, className, ...props }, ref) => /* @__PURE__ */ jsx43("div", { ref, className: clsx("kds-bill-attachments", className), ...props, children })
|
|
2519
2519
|
);
|
|
2520
2520
|
KdsBillAttachments.displayName = "KdsBillAttachments";
|
|
2521
|
+
|
|
2522
|
+
// src/components/core/hooks/useStickyInvoiceCollapse.ts
|
|
2523
|
+
import { useEffect as useEffect4, useRef as useRef4 } from "react";
|
|
2524
|
+
function useStickyInvoiceCollapse(options = {}) {
|
|
2525
|
+
const { onCollapseStart, collapseEnd = 20, mobileBreakpoint = 768 } = options;
|
|
2526
|
+
const onCollapseStartRef = useRef4(onCollapseStart);
|
|
2527
|
+
onCollapseStartRef.current = onCollapseStart;
|
|
2528
|
+
useEffect4(() => {
|
|
2529
|
+
let viewportOffset = 0;
|
|
2530
|
+
let ticking = false;
|
|
2531
|
+
let wasCollapsing = false;
|
|
2532
|
+
const isMobile = () => window.innerWidth < mobileBreakpoint;
|
|
2533
|
+
const closeOpenPanels = (sticky) => {
|
|
2534
|
+
const toggles = sticky.querySelectorAll(
|
|
2535
|
+
'[data-expand-toggle][aria-expanded="true"], .kds-expand-toggle[aria-expanded="true"]'
|
|
2536
|
+
);
|
|
2537
|
+
toggles.forEach((toggle) => {
|
|
2538
|
+
toggle.setAttribute("aria-expanded", "false");
|
|
2539
|
+
const panelId = toggle.getAttribute("aria-controls");
|
|
2540
|
+
const panel = panelId ? document.getElementById(panelId) : toggle.parentElement?.querySelector("[data-expand-panel], .kds-expand-panel");
|
|
2541
|
+
panel?.classList.remove("open");
|
|
2542
|
+
});
|
|
2543
|
+
};
|
|
2544
|
+
const apply = () => {
|
|
2545
|
+
ticking = false;
|
|
2546
|
+
const screen = document.querySelector(".kds-screen.active");
|
|
2547
|
+
if (!screen) return;
|
|
2548
|
+
const sticky = screen.querySelector(".kds-invoice-sticky");
|
|
2549
|
+
if (!sticky || !isMobile()) {
|
|
2550
|
+
screen.style.removeProperty("--collapse-progress");
|
|
2551
|
+
screen.style.removeProperty("--collapse-collapsible-h");
|
|
2552
|
+
sticky?.classList.remove("is-collapsed");
|
|
2553
|
+
wasCollapsing = false;
|
|
2554
|
+
return;
|
|
2555
|
+
}
|
|
2556
|
+
const scrollY = Math.max(window.scrollY || window.pageYOffset || 0, viewportOffset);
|
|
2557
|
+
const progress = Math.min(Math.max(scrollY / collapseEnd, 0), 1);
|
|
2558
|
+
if (!screen.style.getPropertyValue("--collapse-collapsible-h")) {
|
|
2559
|
+
const collapsible = sticky.querySelector(".kds-invoice-collapsible");
|
|
2560
|
+
if (collapsible) {
|
|
2561
|
+
screen.style.setProperty("--collapse-collapsible-h", `${collapsible.offsetHeight}px`);
|
|
2562
|
+
}
|
|
2563
|
+
}
|
|
2564
|
+
screen.style.setProperty("--collapse-progress", String(progress));
|
|
2565
|
+
sticky.classList.toggle("is-collapsed", progress >= 1);
|
|
2566
|
+
if (progress > 0) {
|
|
2567
|
+
if (!wasCollapsing) {
|
|
2568
|
+
wasCollapsing = true;
|
|
2569
|
+
closeOpenPanels(sticky);
|
|
2570
|
+
onCollapseStartRef.current?.();
|
|
2571
|
+
}
|
|
2572
|
+
} else {
|
|
2573
|
+
wasCollapsing = false;
|
|
2574
|
+
}
|
|
2575
|
+
};
|
|
2576
|
+
const onScroll = () => {
|
|
2577
|
+
if (ticking) return;
|
|
2578
|
+
ticking = true;
|
|
2579
|
+
window.requestAnimationFrame(apply);
|
|
2580
|
+
};
|
|
2581
|
+
const onMessage = (event) => {
|
|
2582
|
+
if (event.data && event.data.type === "VIEWPORT_OFFSET") {
|
|
2583
|
+
viewportOffset = Math.max(0, event.data.offsetTop || 0);
|
|
2584
|
+
onScroll();
|
|
2585
|
+
}
|
|
2586
|
+
};
|
|
2587
|
+
window.addEventListener("scroll", onScroll, { passive: true });
|
|
2588
|
+
window.addEventListener("resize", onScroll);
|
|
2589
|
+
window.addEventListener("message", onMessage);
|
|
2590
|
+
apply();
|
|
2591
|
+
return () => {
|
|
2592
|
+
window.removeEventListener("scroll", onScroll);
|
|
2593
|
+
window.removeEventListener("resize", onScroll);
|
|
2594
|
+
window.removeEventListener("message", onMessage);
|
|
2595
|
+
};
|
|
2596
|
+
}, [collapseEnd, mobileBreakpoint]);
|
|
2597
|
+
}
|
|
2521
2598
|
export {
|
|
2522
2599
|
KdsAccordion,
|
|
2523
2600
|
KdsAccordionDetails,
|
|
@@ -2591,6 +2668,7 @@ export {
|
|
|
2591
2668
|
useAutoHide,
|
|
2592
2669
|
useCopyToClipboard,
|
|
2593
2670
|
useCountdown,
|
|
2671
|
+
useStickyInvoiceCollapse,
|
|
2594
2672
|
useTabsKeyboard,
|
|
2595
2673
|
zIndex
|
|
2596
2674
|
};
|
package/package.json
CHANGED