@bi-digital/react 0.11.0 → 0.11.2

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.
Files changed (126) hide show
  1. package/dist/{alert-footer-D_kCDrhn.d.mts → alert-footer-CIn6xe4F.d.mts} +71 -75
  2. package/dist/components/alert/alert-footer.d.mts +1 -1
  3. package/dist/components/alert/alert.d.mts +1 -1
  4. package/dist/components/alert/index.d.mts +1 -1
  5. package/dist/components/avatar/avatar.d.mts +1 -1
  6. package/dist/components/avatar/index.d.mts +1 -1
  7. package/dist/components/badge/badge.d.mts +1 -1
  8. package/dist/components/badge/index.d.mts +1 -1
  9. package/dist/components/button/button.d.mts +1 -1
  10. package/dist/components/button/index.d.mts +1 -1
  11. package/dist/components/card/card-action.d.mts +1 -1
  12. package/dist/components/card/card-actions.d.mts +1 -1
  13. package/dist/components/card/card-content.d.mts +1 -1
  14. package/dist/components/card/card-date.d.mts +1 -1
  15. package/dist/components/card/card-header.d.mts +1 -1
  16. package/dist/components/card/card-media.d.mts +1 -1
  17. package/dist/components/card/card.d.mts +1 -1
  18. package/dist/components/card/index.d.mts +1 -1
  19. package/dist/components/checkbox/checkbox-subsection.d.mts +1 -1
  20. package/dist/components/checkbox/checkbox.d.mts +1 -1
  21. package/dist/components/checkbox/index.d.mts +1 -1
  22. package/dist/components/chip/chip.d.mts +1 -1
  23. package/dist/components/chip/index.d.mts +1 -1
  24. package/dist/components/details/details-content.d.mts +1 -1
  25. package/dist/components/details/details-summary.d.mts +1 -1
  26. package/dist/components/details/details.d.mts +1 -1
  27. package/dist/components/details/index.d.mts +1 -1
  28. package/dist/components/dialog/dialog-close-button.d.mts +1 -1
  29. package/dist/components/dialog/dialog-content.d.mts +1 -1
  30. package/dist/components/dialog/dialog-footer.d.mts +1 -1
  31. package/dist/components/dialog/dialog-header.d.mts +1 -1
  32. package/dist/components/dialog/dialog-trigger-context.d.mts +1 -1
  33. package/dist/components/dialog/dialog-trigger.d.mts +1 -1
  34. package/dist/components/dialog/dialog.d.mts +1 -1
  35. package/dist/components/dialog/index.d.mts +2 -2
  36. package/dist/components/dropdown/dropdown-button.d.mts +1 -1
  37. package/dist/components/dropdown/dropdown-item.d.mts +1 -1
  38. package/dist/components/dropdown/dropdown-list.d.mts +1 -1
  39. package/dist/components/dropdown/dropdown-trigger-context.d.mts +1 -1
  40. package/dist/components/dropdown/dropdown-trigger.d.mts +1 -1
  41. package/dist/components/dropdown/dropdown.d.mts +1 -1
  42. package/dist/components/dropdown/index.d.mts +3 -3
  43. package/dist/components/field/field-affix.d.mts +1 -1
  44. package/dist/components/field/field-description.d.mts +1 -1
  45. package/dist/components/field/field.d.mts +1 -1
  46. package/dist/components/field/index.d.mts +1 -1
  47. package/dist/components/fieldset/fieldset-description.d.mts +1 -1
  48. package/dist/components/fieldset/fieldset-legend.d.mts +1 -1
  49. package/dist/components/fieldset/fieldset.d.mts +1 -1
  50. package/dist/components/fieldset/index.d.mts +1 -1
  51. package/dist/components/filter-group/filter-group.d.mts +1 -1
  52. package/dist/components/filter-group/index.d.mts +1 -1
  53. package/dist/components/footer/footer-links.d.mts +1 -1
  54. package/dist/components/footer/footer.d.mts +1 -1
  55. package/dist/components/footer/index.d.mts +2 -2
  56. package/dist/components/index.d.mts +8 -8
  57. package/dist/components/input/index.d.mts +1 -1
  58. package/dist/components/input/input.d.mts +1 -1
  59. package/dist/components/label/index.d.mts +1 -1
  60. package/dist/components/label/label.d.mts +1 -1
  61. package/dist/components/link/index.d.mts +1 -1
  62. package/dist/components/link/link.d.mts +1 -1
  63. package/dist/components/logo/index.d.mts +1 -1
  64. package/dist/components/logo/logo.d.mts +1 -1
  65. package/dist/components/navbar/index.d.mts +1 -1
  66. package/dist/components/navbar/navbar.d.mts +1 -1
  67. package/dist/components/navbar/sub-navbar.d.mts +1 -1
  68. package/dist/components/pagination/index.d.mts +2 -2
  69. package/dist/components/pagination/pagination-button.d.mts +1 -1
  70. package/dist/components/pagination/pagination-item.d.mts +1 -1
  71. package/dist/components/pagination/pagination.d.mts +1 -1
  72. package/dist/components/popover/index.d.mts +2 -2
  73. package/dist/components/popover/popover-trigger-context.d.mts +1 -1
  74. package/dist/components/popover/popover-trigger.d.mts +1 -1
  75. package/dist/components/popover/popover.d.mts +1 -1
  76. package/dist/components/radio/index.d.mts +1 -1
  77. package/dist/components/radio/radio.d.mts +1 -1
  78. package/dist/components/search/index.d.mts +1 -1
  79. package/dist/components/search/search.d.mts +1 -1
  80. package/dist/components/select/index.d.mts +1 -1
  81. package/dist/components/select/select-optgroup.d.mts +1 -1
  82. package/dist/components/select/select-option.d.mts +1 -1
  83. package/dist/components/select/select.d.mts +1 -1
  84. package/dist/components/selectfield/index.d.mts +1 -1
  85. package/dist/components/selectfield/selectfield.d.mts +1 -1
  86. package/dist/components/skip-link/index.d.mts +1 -1
  87. package/dist/components/skip-link/skip-link.d.mts +1 -1
  88. package/dist/components/spinner/index.d.mts +1 -1
  89. package/dist/components/spinner/spinner.d.mts +1 -1
  90. package/dist/components/sticky-header/index.d.mts +1 -1
  91. package/dist/components/sticky-header/sticky-header.d.mts +1 -1
  92. package/dist/components/switch/index.d.mts +1 -1
  93. package/dist/components/switch/switch.d.mts +1 -1
  94. package/dist/components/tabs/index.d.mts +1 -1
  95. package/dist/components/tabs/tab.d.mts +1 -1
  96. package/dist/components/tabs/tab.mjs +1 -2
  97. package/dist/components/tabs/tab.mjs.map +1 -1
  98. package/dist/components/tabs/tabs-list.d.mts +1 -1
  99. package/dist/components/tabs/tabs-list.mjs +2 -2
  100. package/dist/components/tabs/tabs-list.mjs.map +1 -1
  101. package/dist/components/tabs/tabs-panel.d.mts +1 -1
  102. package/dist/components/tabs/tabs-panel.mjs +2 -2
  103. package/dist/components/tabs/tabs-panel.mjs.map +1 -1
  104. package/dist/components/tabs/tabs.d.mts +1 -1
  105. package/dist/components/tabs/tabs.mjs +7 -2
  106. package/dist/components/tabs/tabs.mjs.map +1 -1
  107. package/dist/components/textarea/index.d.mts +1 -1
  108. package/dist/components/textarea/textarea.d.mts +1 -1
  109. package/dist/components/textfield/index.d.mts +1 -1
  110. package/dist/components/textfield/textfield.d.mts +1 -1
  111. package/dist/components/validation-message/index.d.mts +1 -1
  112. package/dist/components/validation-message/validation-message.d.mts +1 -1
  113. package/dist/{dialog-trigger-context-CAC7jh1K.d.mts → dialog-trigger-context-DbUhxoNL.d.mts} +5 -5
  114. package/dist/{dropdown-item-aYyDctA9.d.mts → dropdown-item-bA64wFOZ.d.mts} +3 -3
  115. package/dist/{dropdown-list-Dg3yJhKc.d.mts → dropdown-list-CaYz-O1j.d.mts} +3 -3
  116. package/dist/{footer-links-BiBVxNWE.d.mts → footer-links-DwBghNrz.d.mts} +3 -3
  117. package/dist/main.d.mts +8 -8
  118. package/dist/{pagination-item-BNyKs6wz.d.mts → pagination-item-DJicBrIN.d.mts} +3 -3
  119. package/dist/{popover-trigger-context-DTh-_AMm.d.mts → popover-trigger-context-BLjAozBn.d.mts} +5 -5
  120. package/dist/{sticky-header-CLZPboYg.d.mts → sticky-header-CVfE0TUC.d.mts} +3 -3
  121. package/dist/utilities/hooks/index.d.mts +1 -1
  122. package/dist/utilities/hooks/usePagination/usePagination.d.mts +1 -1
  123. package/dist/utilities/index.d.mts +1 -1
  124. package/dist/vanilla/sub-navbar/index.mjs +6 -5
  125. package/dist/vanilla/sub-navbar/index.mjs.map +1 -1
  126. package/package.json +10 -11
@@ -1,2 +1,2 @@
1
- import { _ as Context, b as TabsProps, v as Tabs, y as TabsContext } from "../../alert-footer-D_kCDrhn.mjs";
1
+ import { _ as Context, b as TabsProps, v as Tabs, y as TabsContext } from "../../alert-footer-CIn6xe4F.mjs";
2
2
  export { Context, Tabs, TabsContext, TabsProps };
@@ -28,11 +28,16 @@ const Tabs = ({ defaultValue, value: valueProp, onChange, children, className, d
28
28
  }
29
29
  });
30
30
  }, [valueProp]);
31
+ useEffect(() => {
32
+ if (!isControlled && defaultValue && tabsRef.current) tabsRef.current?.tabList?.tabs?.forEach((tab) => {
33
+ const isSelected = tab.getAttribute("data-value") === defaultValue;
34
+ tab.setAttribute("aria-selected", isSelected ? "true" : "false");
35
+ });
36
+ }, []);
31
37
  return /* @__PURE__ */ jsx(Context, {
32
38
  value: {
33
39
  isControlled,
34
40
  currentValue: value,
35
- defaultValue,
36
41
  onChange: setValue,
37
42
  getPrefixedValue: (value) => value && `${valuePrefix}-${value}`
38
43
  },
@@ -40,7 +45,7 @@ const Tabs = ({ defaultValue, value: valueProp, onChange, children, className, d
40
45
  suppressHydrationWarning: true,
41
46
  ref: mergedRefs,
42
47
  className: clsx("bi-tabs", className),
43
- "data-dark": dark,
48
+ "data-dark": dark ? "true" : "false",
44
49
  ...props,
45
50
  children
46
51
  })
@@ -1 +1 @@
1
- {"version":3,"file":"tabs.mjs","names":[],"sources":["../../../src/components/tabs/tabs.tsx"],"sourcesContent":["import { createContext, useEffect, useId, useRef } from 'react';\nimport type { HTMLAttributes, Ref } from 'react';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport type { DSTabsElement } from '@digdir/designsystemet-web';\nimport '@digdir/designsystemet-web'; // Import ds-tabs custom element\nimport clsx from 'clsx/lite';\nimport type { DefaultProps } from '../../types';\nimport type { MergeRight } from '../../utilities';\nimport { useMergeRefs } from '../../utilities/hooks/useMergeRefs/useMergeRefs';\n\nexport type TabsProps = MergeRight<\n DefaultProps & HTMLAttributes<DSTabsElement>,\n {\n /** The value of the tab that should be active when initially rendered. Use when you do not need to control the state of the tabs. */\n defaultValue?: string;\n /** The controlled value of the tab to activate. Should be used together with `onChange`. */\n value?: string;\n /** Event handler called when the value changes. */\n onChange?: (value: string) => void;\n ref?: Ref<DSTabsElement>;\n }\n>;\n\nexport type TabsContext = {\n isControlled?: boolean;\n currentValue?: string;\n defaultValue?: string;\n onChange?: (value: string) => void;\n getPrefixedValue?: (value?: string) => string | undefined;\n};\n\nexport const Context = createContext<TabsContext>({});\n\nexport const Tabs = ({\n defaultValue,\n value: valueProp,\n onChange,\n children,\n className,\n dark,\n ref,\n ...props\n}: TabsProps) => {\n const isControlled = valueProp !== undefined;\n const tabsRef = useRef<DSTabsElement>(null);\n const isProgrammaticClick = useRef(false);\n const valuePrefix = useId(); // Used for generation of unique value-based ids for tabs and panels\n const mergedRefs = useMergeRefs([ref, tabsRef]);\n const [value, setValue] = useControllableState({\n prop: valueProp,\n onChange,\n defaultProp: defaultValue || '',\n caller: 'Tabs',\n });\n\n useEffect(() => {\n if (!tabsRef.current || valueProp === undefined) return;\n tabsRef.current?.tabList?.tabs?.forEach((tab) => {\n if (tab.getAttribute('data-value') === valueProp) {\n isProgrammaticClick.current = true;\n tab.click();\n isProgrammaticClick.current = false;\n }\n });\n }, [valueProp]);\n\n return (\n <Context\n value={{\n isControlled,\n currentValue: value,\n defaultValue,\n onChange: setValue,\n getPrefixedValue: (value?: string) => value && `${valuePrefix}-${value}`,\n }}\n >\n <ds-tabs\n suppressHydrationWarning // Since <ds-tablist> adds attributes\n ref={mergedRefs}\n className={clsx('bi-tabs', className)}\n data-dark={dark}\n {...props}\n >\n {children}\n </ds-tabs>\n </Context>\n );\n};\n"],"mappings":";;;;;;;AA+BA,MAAa,UAAU,cAA2B,EAAE,CAAC;AAErD,MAAa,QAAQ,EACnB,cACA,OAAO,WACP,UACA,UACA,WACA,MACA,KACA,GAAG,YACY;CACf,MAAM,eAAe,cAAc,KAAA;CACnC,MAAM,UAAU,OAAsB,KAAK;CAC3C,MAAM,sBAAsB,OAAO,MAAM;CACzC,MAAM,cAAc,OAAO;CAC3B,MAAM,aAAa,aAAa,CAAC,KAAK,QAAQ,CAAC;CAC/C,MAAM,CAAC,OAAO,YAAY,qBAAqB;EAC7C,MAAM;EACN;EACA,aAAa,gBAAgB;EAC7B,QAAQ;EACT,CAAC;AAEF,iBAAgB;AACd,MAAI,CAAC,QAAQ,WAAW,cAAc,KAAA,EAAW;AACjD,UAAQ,SAAS,SAAS,MAAM,SAAS,QAAQ;AAC/C,OAAI,IAAI,aAAa,aAAa,KAAK,WAAW;AAChD,wBAAoB,UAAU;AAC9B,QAAI,OAAO;AACX,wBAAoB,UAAU;;IAEhC;IACD,CAAC,UAAU,CAAC;AAEf,QACE,oBAAC,SAAD;EACE,OAAO;GACL;GACA,cAAc;GACd;GACA,UAAU;GACV,mBAAmB,UAAmB,SAAS,GAAG,YAAY,GAAG;GAClE;YAED,oBAAC,WAAD;GACE,0BAAA;GACA,KAAK;GACL,WAAW,KAAK,WAAW,UAAU;GACrC,aAAW;GACX,GAAI;GAEH;GACO,CAAA;EACF,CAAA"}
1
+ {"version":3,"file":"tabs.mjs","names":[],"sources":["../../../src/components/tabs/tabs.tsx"],"sourcesContent":["import { createContext, useEffect, useId, useRef } from 'react';\nimport type { HTMLAttributes, Ref } from 'react';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport type { DSTabsElement } from '@digdir/designsystemet-web';\nimport '@digdir/designsystemet-web'; // Import ds-tabs custom element\nimport clsx from 'clsx/lite';\nimport type { DefaultProps } from '../../types';\nimport type { MergeRight } from '../../utilities';\nimport { useMergeRefs } from '../../utilities/hooks/useMergeRefs/useMergeRefs';\n\nexport type TabsProps = MergeRight<\n DefaultProps & HTMLAttributes<DSTabsElement>,\n {\n /** The value of the tab that should be active when initially rendered. Use when you do not need to control the state of the tabs. */\n defaultValue?: string;\n /** The controlled value of the tab to activate. Should be used together with `onChange`. */\n value?: string;\n /** Event handler called when the value changes. */\n onChange?: (value: string) => void;\n ref?: Ref<DSTabsElement>;\n }\n>;\n\nexport type TabsContext = {\n isControlled?: boolean;\n currentValue?: string;\n onChange?: (value: string) => void;\n getPrefixedValue?: (value?: string) => string | undefined;\n};\n\nexport const Context = createContext<TabsContext>({});\n\nexport const Tabs = ({\n defaultValue,\n value: valueProp,\n onChange,\n children,\n className,\n dark,\n ref,\n ...props\n}: TabsProps) => {\n const isControlled = valueProp !== undefined;\n const tabsRef = useRef<DSTabsElement>(null);\n const isProgrammaticClick = useRef(false);\n const valuePrefix = useId(); // Used for generation of unique value-based ids for tabs and panels\n const mergedRefs = useMergeRefs([ref, tabsRef]);\n const [value, setValue] = useControllableState({\n prop: valueProp,\n onChange,\n defaultProp: defaultValue || '',\n caller: 'Tabs',\n });\n\n useEffect(() => {\n if (!tabsRef.current || valueProp === undefined) return;\n tabsRef.current?.tabList?.tabs?.forEach((tab) => {\n if (tab.getAttribute('data-value') === valueProp) {\n isProgrammaticClick.current = true;\n tab.click();\n isProgrammaticClick.current = false;\n }\n });\n }, [valueProp]);\n\n useEffect(() => {\n if (!isControlled && defaultValue && tabsRef.current) {\n tabsRef.current?.tabList?.tabs?.forEach((tab) => {\n const isSelected = tab.getAttribute('data-value') === defaultValue;\n tab.setAttribute('aria-selected', isSelected ? 'true' : 'false');\n });\n }\n // oxlint-disable-next-line eslint-plugin-react-hooks/exhaustive-deps\n }, []);\n\n return (\n <Context\n value={{\n isControlled,\n currentValue: value,\n onChange: setValue,\n getPrefixedValue: (value?: string) => value && `${valuePrefix}-${value}`,\n }}\n >\n <ds-tabs\n suppressHydrationWarning // Since <ds-tablist> adds attributes\n ref={mergedRefs}\n className={clsx('bi-tabs', className)}\n data-dark={dark ? 'true' : 'false'}\n {...props}\n >\n {children}\n </ds-tabs>\n </Context>\n );\n};\n"],"mappings":";;;;;;;AA8BA,MAAa,UAAU,cAA2B,EAAE,CAAC;AAErD,MAAa,QAAQ,EACnB,cACA,OAAO,WACP,UACA,UACA,WACA,MACA,KACA,GAAG,YACY;CACf,MAAM,eAAe,cAAc,KAAA;CACnC,MAAM,UAAU,OAAsB,KAAK;CAC3C,MAAM,sBAAsB,OAAO,MAAM;CACzC,MAAM,cAAc,OAAO;CAC3B,MAAM,aAAa,aAAa,CAAC,KAAK,QAAQ,CAAC;CAC/C,MAAM,CAAC,OAAO,YAAY,qBAAqB;EAC7C,MAAM;EACN;EACA,aAAa,gBAAgB;EAC7B,QAAQ;EACT,CAAC;AAEF,iBAAgB;AACd,MAAI,CAAC,QAAQ,WAAW,cAAc,KAAA,EAAW;AACjD,UAAQ,SAAS,SAAS,MAAM,SAAS,QAAQ;AAC/C,OAAI,IAAI,aAAa,aAAa,KAAK,WAAW;AAChD,wBAAoB,UAAU;AAC9B,QAAI,OAAO;AACX,wBAAoB,UAAU;;IAEhC;IACD,CAAC,UAAU,CAAC;AAEf,iBAAgB;AACd,MAAI,CAAC,gBAAgB,gBAAgB,QAAQ,QAC3C,SAAQ,SAAS,SAAS,MAAM,SAAS,QAAQ;GAC/C,MAAM,aAAa,IAAI,aAAa,aAAa,KAAK;AACtD,OAAI,aAAa,iBAAiB,aAAa,SAAS,QAAQ;IAChE;IAGH,EAAE,CAAC;AAEN,QACE,oBAAC,SAAD;EACE,OAAO;GACL;GACA,cAAc;GACd,UAAU;GACV,mBAAmB,UAAmB,SAAS,GAAG,YAAY,GAAG;GAClE;YAED,oBAAC,WAAD;GACE,0BAAA;GACA,KAAK;GACL,WAAW,KAAK,WAAW,UAAU;GACrC,aAAW,OAAO,SAAS;GAC3B,GAAI;GAEH;GACO,CAAA;EACF,CAAA"}
@@ -1,2 +1,2 @@
1
- import { l as Textarea, u as TextareaProps } from "../../alert-footer-D_kCDrhn.mjs";
1
+ import { l as Textarea, u as TextareaProps } from "../../alert-footer-CIn6xe4F.mjs";
2
2
  export { Textarea, TextareaProps };
@@ -1,2 +1,2 @@
1
- import { l as Textarea, u as TextareaProps } from "../../alert-footer-D_kCDrhn.mjs";
1
+ import { l as Textarea, u as TextareaProps } from "../../alert-footer-CIn6xe4F.mjs";
2
2
  export { Textarea, TextareaProps };
@@ -1,2 +1,2 @@
1
- import { c as TextfieldProps, s as Textfield } from "../../alert-footer-D_kCDrhn.mjs";
1
+ import { c as TextfieldProps, s as Textfield } from "../../alert-footer-CIn6xe4F.mjs";
2
2
  export { Textfield, TextfieldProps };
@@ -1,2 +1,2 @@
1
- import { c as TextfieldProps, s as Textfield } from "../../alert-footer-D_kCDrhn.mjs";
1
+ import { c as TextfieldProps, s as Textfield } from "../../alert-footer-CIn6xe4F.mjs";
2
2
  export { Textfield, TextfieldProps };
@@ -1,2 +1,2 @@
1
- import { a as ValidationMessage, o as ValidationMessageProps } from "../../alert-footer-D_kCDrhn.mjs";
1
+ import { a as ValidationMessage, o as ValidationMessageProps } from "../../alert-footer-CIn6xe4F.mjs";
2
2
  export { ValidationMessage, ValidationMessageProps };
@@ -1,2 +1,2 @@
1
- import { a as ValidationMessage, o as ValidationMessageProps } from "../../alert-footer-D_kCDrhn.mjs";
1
+ import { a as ValidationMessage, o as ValidationMessageProps } from "../../alert-footer-CIn6xe4F.mjs";
2
2
  export { ValidationMessage, ValidationMessageProps };
@@ -1,12 +1,12 @@
1
- import * as react_jsx_runtime0 from "react/jsx-runtime";
2
- import * as react from "react";
1
+ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
2
+ import * as _$react from "react";
3
3
  import { ReactNode } from "react";
4
4
 
5
5
  //#region src/components/dialog/dialog-trigger-context.d.ts
6
6
  type DialogContext = {
7
7
  id?: string;
8
8
  };
9
- declare const Context: react.Context<DialogContext & {
9
+ declare const Context: _$react.Context<DialogContext & {
10
10
  setContext?: (context: DialogContext) => void;
11
11
  }>;
12
12
  type DialogTriggerContextProps = {
@@ -14,7 +14,7 @@ type DialogTriggerContextProps = {
14
14
  };
15
15
  declare const DialogTriggerContext: ({
16
16
  children
17
- }: DialogTriggerContextProps) => react_jsx_runtime0.JSX.Element;
17
+ }: DialogTriggerContextProps) => _$react_jsx_runtime0.JSX.Element;
18
18
  //#endregion
19
19
  export { DialogTriggerContext as n, DialogTriggerContextProps as r, Context as t };
20
- //# sourceMappingURL=dialog-trigger-context-CAC7jh1K.d.mts.map
20
+ //# sourceMappingURL=dialog-trigger-context-DbUhxoNL.d.mts.map
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime0 from "react/jsx-runtime";
1
+ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
2
2
  import { HTMLAttributes, Ref } from "react";
3
3
 
4
4
  //#region src/components/dropdown/dropdown-item.d.ts
@@ -8,7 +8,7 @@ type DropdownItemProps = HTMLAttributes<HTMLLIElement> & {
8
8
  declare const DropdownItem: ({
9
9
  ref,
10
10
  ...rest
11
- }: DropdownItemProps) => react_jsx_runtime0.JSX.Element;
11
+ }: DropdownItemProps) => _$react_jsx_runtime0.JSX.Element;
12
12
  //#endregion
13
13
  export { DropdownItemProps as n, DropdownItem as t };
14
- //# sourceMappingURL=dropdown-item-aYyDctA9.d.mts.map
14
+ //# sourceMappingURL=dropdown-item-bA64wFOZ.d.mts.map
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime0 from "react/jsx-runtime";
1
+ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
2
2
  import { HTMLAttributes, Ref } from "react";
3
3
 
4
4
  //#region src/components/dropdown/dropdown-list.d.ts
@@ -8,7 +8,7 @@ type DropdownListProps = HTMLAttributes<HTMLUListElement> & {
8
8
  declare const DropdownList: ({
9
9
  ref,
10
10
  ...rest
11
- }: DropdownListProps) => react_jsx_runtime0.JSX.Element;
11
+ }: DropdownListProps) => _$react_jsx_runtime0.JSX.Element;
12
12
  //#endregion
13
13
  export { DropdownListProps as n, DropdownList as t };
14
- //# sourceMappingURL=dropdown-list-Dg3yJhKc.d.mts.map
14
+ //# sourceMappingURL=dropdown-list-CaYz-O1j.d.mts.map
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime0 from "react/jsx-runtime";
1
+ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
2
2
  import { HTMLAttributes, Ref } from "react";
3
3
 
4
4
  //#region src/components/footer/footer-links.d.ts
@@ -14,7 +14,7 @@ declare const FooterLinks: ({
14
14
  children,
15
15
  ref,
16
16
  ...props
17
- }: FooterLinksProps) => react_jsx_runtime0.JSX.Element;
17
+ }: FooterLinksProps) => _$react_jsx_runtime0.JSX.Element;
18
18
  //#endregion
19
19
  export { FooterLinksProps as n, FooterLinks as t };
20
- //# sourceMappingURL=footer-links-BiBVxNWE.d.mts.map
20
+ //# sourceMappingURL=footer-links-DwBghNrz.d.mts.map
package/dist/main.d.mts CHANGED
@@ -1,13 +1,13 @@
1
1
  import { r as useCheckboxGroup, t as UseCheckboxGroupOptions } from "./useCheckboxGroup-Boc_tLJ3.mjs";
2
2
  import { t as useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect-DXCY5AxR.mjs";
3
- import { $ as FilterGroup, $t as Input, A as SelectOptgroupProps, At as DialogCloseButtonProps, B as PaginationButtonProps, Bt as DialogProps, C as Spinner, Ct as Dropdown, D as Selectfield, Dt as Popover, E as SkipLinkProps, Et as PopoverTriggerProps, F as Search, Ft as DialogHeader, G as Navbar, Gt as Details, H as PaginationProps, Ht as DetailsSummaryProps, I as SearchProps, It as DialogHeaderProps, J as LogoProps, Jt as ChipProps, K as NavbarProps, Kt as DetailsProps, L as Radio, Lt as DialogContent, M as SelectOptionProps, Mt as DialogTriggerProps, N as Select, Nt as DialogFooter, O as SelectfieldProps, Ot as PopoverProps, P as SelectProps, Pt as DialogFooterProps, Q as FooterProps, Qt as CheckboxProps, R as RadioProps, Rt as DialogContentProps, S as SwitchProps, Sn as AlertProps, St as DropdownButtonProps, T as SkipLink, Tt as PopoverTrigger, U as SubNavbar, Ut as DetailsContent, V as Pagination, Vt as DetailsSummary, W as SubNavbarProps, Wt as DetailsContentProps, X as LinkProps, Xt as CheckboxSubsectionProps, Y as Link, Yt as CheckboxSubsection, Z as Footer, Zt as Checkbox, _n as Badge, _t as DropdownTriggerContext, a as ValidationMessage, an as CardHeader, at as FieldsetDescription, b as TabsProps, bn as AvatarProps, bt as DropdownTriggerProps, c as TextfieldProps, cn as CardContentProps, ct as FieldsetProps, d as TabsPanel, dn as CardActions, dt as FieldAffixes, en as InputProps, et as FilterGroupProps, f as TabsPanelProps, fn as CardActionsProps, ft as FieldAffixesProps, g as TabProps, gn as ButtonProps, gt as FieldProps, h as Tab, hn as Button, ht as Field, i as usePagination, in as CardMediaProps, it as LabelProps, j as SelectOption, jt as DialogTrigger, k as SelectOptgroup, kt as DialogCloseButton, l as Textarea, ln as CardAction, lt as FieldAffix, m as TabsListProps, mn as CardProps, mt as FieldDescriptionProps, n as AlertFooterProps, nn as CardDateProps, nt as FieldsetLegendProps, o as ValidationMessageProps, on as CardHeaderProps, ot as FieldsetDescriptionProps, p as TabsList, pn as Card, pt as FieldDescription, q as Logo, qt as Chip, r as UsePaginationProps, rn as CardMedia, rt as Label, s as Textfield, sn as CardContent, st as Fieldset, t as AlertFooter, tn as CardDate, tt as FieldsetLegend, u as TextareaProps, un as CardActionProps, ut as FieldAffixProps, v as Tabs, vn as BadgeProps, vt as DropdownTriggerContextProps, w as SpinnerProps, wt as DropdownProps, x as Switch, xn as Alert, xt as DropdownButton, y as TabsContext, yn as Avatar, yt as DropdownTrigger, z as PaginationButton, zt as Dialog } from "./alert-footer-D_kCDrhn.mjs";
4
- import { n as DialogTriggerContext, r as DialogTriggerContextProps, t as Context } from "./dialog-trigger-context-CAC7jh1K.mjs";
5
- import { n as PopoverTriggerContext, r as PopoverTriggerContextProps } from "./popover-trigger-context-DTh-_AMm.mjs";
6
- import { n as DropdownItemProps, t as DropdownItem } from "./dropdown-item-aYyDctA9.mjs";
7
- import { n as DropdownListProps, t as DropdownList } from "./dropdown-list-Dg3yJhKc.mjs";
8
- import { n as FooterLinksProps, t as FooterLinks } from "./footer-links-BiBVxNWE.mjs";
9
- import { n as PaginationItemProps, t as PaginationItem } from "./pagination-item-BNyKs6wz.mjs";
10
- import { n as StickyHeaderProps, t as StickyHeader } from "./sticky-header-CLZPboYg.mjs";
3
+ import { $ as FilterGroup, $t as Input, A as SelectOptgroupProps, At as DialogCloseButtonProps, B as PaginationButtonProps, Bt as DialogProps, C as Spinner, Ct as Dropdown, D as Selectfield, Dt as Popover, E as SkipLinkProps, Et as PopoverTriggerProps, F as Search, Ft as DialogHeader, G as Navbar, Gt as Details, H as PaginationProps, Ht as DetailsSummaryProps, I as SearchProps, It as DialogHeaderProps, J as LogoProps, Jt as ChipProps, K as NavbarProps, Kt as DetailsProps, L as Radio, Lt as DialogContent, M as SelectOptionProps, Mt as DialogTriggerProps, N as Select, Nt as DialogFooter, O as SelectfieldProps, Ot as PopoverProps, P as SelectProps, Pt as DialogFooterProps, Q as FooterProps, Qt as CheckboxProps, R as RadioProps, Rt as DialogContentProps, S as SwitchProps, Sn as AlertProps, St as DropdownButtonProps, T as SkipLink, Tt as PopoverTrigger, U as SubNavbar, Ut as DetailsContent, V as Pagination, Vt as DetailsSummary, W as SubNavbarProps, Wt as DetailsContentProps, X as LinkProps, Xt as CheckboxSubsectionProps, Y as Link, Yt as CheckboxSubsection, Z as Footer, Zt as Checkbox, _n as Badge, _t as DropdownTriggerContext, a as ValidationMessage, an as CardHeader, at as FieldsetDescription, b as TabsProps, bn as AvatarProps, bt as DropdownTriggerProps, c as TextfieldProps, cn as CardContentProps, ct as FieldsetProps, d as TabsPanel, dn as CardActions, dt as FieldAffixes, en as InputProps, et as FilterGroupProps, f as TabsPanelProps, fn as CardActionsProps, ft as FieldAffixesProps, g as TabProps, gn as ButtonProps, gt as FieldProps, h as Tab, hn as Button, ht as Field, i as usePagination, in as CardMediaProps, it as LabelProps, j as SelectOption, jt as DialogTrigger, k as SelectOptgroup, kt as DialogCloseButton, l as Textarea, ln as CardAction, lt as FieldAffix, m as TabsListProps, mn as CardProps, mt as FieldDescriptionProps, n as AlertFooterProps, nn as CardDateProps, nt as FieldsetLegendProps, o as ValidationMessageProps, on as CardHeaderProps, ot as FieldsetDescriptionProps, p as TabsList, pn as Card, pt as FieldDescription, q as Logo, qt as Chip, r as UsePaginationProps, rn as CardMedia, rt as Label, s as Textfield, sn as CardContent, st as Fieldset, t as AlertFooter, tn as CardDate, tt as FieldsetLegend, u as TextareaProps, un as CardActionProps, ut as FieldAffixProps, v as Tabs, vn as BadgeProps, vt as DropdownTriggerContextProps, w as SpinnerProps, wt as DropdownProps, x as Switch, xn as Alert, xt as DropdownButton, y as TabsContext, yn as Avatar, yt as DropdownTrigger, z as PaginationButton, zt as Dialog } from "./alert-footer-CIn6xe4F.mjs";
4
+ import { n as DialogTriggerContext, r as DialogTriggerContextProps, t as Context } from "./dialog-trigger-context-DbUhxoNL.mjs";
5
+ import { n as PopoverTriggerContext, r as PopoverTriggerContextProps } from "./popover-trigger-context-BLjAozBn.mjs";
6
+ import { n as DropdownItemProps, t as DropdownItem } from "./dropdown-item-bA64wFOZ.mjs";
7
+ import { n as DropdownListProps, t as DropdownList } from "./dropdown-list-CaYz-O1j.mjs";
8
+ import { n as FooterLinksProps, t as FooterLinks } from "./footer-links-DwBghNrz.mjs";
9
+ import { n as PaginationItemProps, t as PaginationItem } from "./pagination-item-DJicBrIN.mjs";
10
+ import { n as StickyHeaderProps, t as StickyHeader } from "./sticky-header-CVfE0TUC.mjs";
11
11
  import { t as useIsElementAboveViewport } from "./useIsElementAboveViewport-DmYCeDwm.mjs";
12
12
  import { t as useScrollDirection } from "./useScrollDirection-CepdY5lA.mjs";
13
13
  import { n as useMediaQuery, t as UseMediaQueryOptions } from "./useMediaQuery-Cz0DvE8S.mjs";
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime0 from "react/jsx-runtime";
1
+ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
2
2
  import { HTMLAttributes, Ref } from "react";
3
3
 
4
4
  //#region src/components/pagination/pagination-item.d.ts
@@ -15,7 +15,7 @@ declare const PaginationItem: ({
15
15
  asChild,
16
16
  children,
17
17
  ...rest
18
- }: PaginationItemProps) => react_jsx_runtime0.JSX.Element;
18
+ }: PaginationItemProps) => _$react_jsx_runtime0.JSX.Element;
19
19
  //#endregion
20
20
  export { PaginationItemProps as n, PaginationItem as t };
21
- //# sourceMappingURL=pagination-item-BNyKs6wz.d.mts.map
21
+ //# sourceMappingURL=pagination-item-DJicBrIN.d.mts.map
@@ -1,9 +1,9 @@
1
- import * as react_jsx_runtime0 from "react/jsx-runtime";
2
- import * as react from "react";
1
+ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
2
+ import * as _$react from "react";
3
3
  import { ReactNode } from "react";
4
4
 
5
5
  //#region src/components/popover/popover-trigger-context.d.ts
6
- declare const Context: react.Context<{
6
+ declare const Context: _$react.Context<{
7
7
  popoverId?: string;
8
8
  setPopoverId?: (id: string) => void;
9
9
  popoverOpen?: boolean;
@@ -37,7 +37,7 @@ declare const PopoverTriggerContext: ({
37
37
  children,
38
38
  open,
39
39
  onOpenChange
40
- }: PopoverTriggerContextProps) => react_jsx_runtime0.JSX.Element;
40
+ }: PopoverTriggerContextProps) => _$react_jsx_runtime0.JSX.Element;
41
41
  //#endregion
42
42
  export { PopoverTriggerContext as n, PopoverTriggerContextProps as r, Context as t };
43
- //# sourceMappingURL=popover-trigger-context-DTh-_AMm.d.mts.map
43
+ //# sourceMappingURL=popover-trigger-context-BLjAozBn.d.mts.map
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime0 from "react/jsx-runtime";
1
+ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
2
2
  import { ReactNode } from "react";
3
3
 
4
4
  //#region src/components/sticky-header/sticky-header.d.ts
@@ -13,7 +13,7 @@ type StickyHeaderProps = {
13
13
  */
14
14
  declare const StickyHeader: ({
15
15
  children
16
- }: StickyHeaderProps) => react_jsx_runtime0.JSX.Element;
16
+ }: StickyHeaderProps) => _$react_jsx_runtime0.JSX.Element;
17
17
  //#endregion
18
18
  export { StickyHeaderProps as n, StickyHeader as t };
19
- //# sourceMappingURL=sticky-header-CLZPboYg.d.mts.map
19
+ //# sourceMappingURL=sticky-header-CVfE0TUC.d.mts.map
@@ -1,6 +1,6 @@
1
1
  import { r as useCheckboxGroup, t as UseCheckboxGroupOptions } from "../../useCheckboxGroup-Boc_tLJ3.mjs";
2
2
  import { t as useIsomorphicLayoutEffect } from "../../useIsomorphicLayoutEffect-DXCY5AxR.mjs";
3
- import { i as usePagination, r as UsePaginationProps } from "../../alert-footer-D_kCDrhn.mjs";
3
+ import { i as usePagination, r as UsePaginationProps } from "../../alert-footer-CIn6xe4F.mjs";
4
4
  import { t as useIsElementAboveViewport } from "../../useIsElementAboveViewport-DmYCeDwm.mjs";
5
5
  import { t as useScrollDirection } from "../../useScrollDirection-CepdY5lA.mjs";
6
6
  import { n as useMediaQuery, t as UseMediaQueryOptions } from "../../useMediaQuery-Cz0DvE8S.mjs";
@@ -1,2 +1,2 @@
1
- import { i as usePagination, r as UsePaginationProps } from "../../../alert-footer-D_kCDrhn.mjs";
1
+ import { i as usePagination, r as UsePaginationProps } from "../../../alert-footer-CIn6xe4F.mjs";
2
2
  export { UsePaginationProps, usePagination };
@@ -1,6 +1,6 @@
1
1
  import { r as useCheckboxGroup, t as UseCheckboxGroupOptions } from "../useCheckboxGroup-Boc_tLJ3.mjs";
2
2
  import { t as useIsomorphicLayoutEffect } from "../useIsomorphicLayoutEffect-DXCY5AxR.mjs";
3
- import { i as usePagination, r as UsePaginationProps } from "../alert-footer-D_kCDrhn.mjs";
3
+ import { i as usePagination, r as UsePaginationProps } from "../alert-footer-CIn6xe4F.mjs";
4
4
  import { t as useIsElementAboveViewport } from "../useIsElementAboveViewport-DmYCeDwm.mjs";
5
5
  import { t as useScrollDirection } from "../useScrollDirection-CepdY5lA.mjs";
6
6
  import { n as useMediaQuery, t as UseMediaQueryOptions } from "../useMediaQuery-Cz0DvE8S.mjs";
@@ -5,10 +5,10 @@
5
5
  * exceeds a 5px threshold to prevent sensitivity to minor scroll jitter.
6
6
  */
7
7
  var ScrollDirectionTracker = class {
8
+ scrollDirection = null;
9
+ lastScrollY = window.pageYOffset;
10
+ callbacks = /* @__PURE__ */ new Set();
8
11
  constructor() {
9
- this.scrollDirection = null;
10
- this.lastScrollY = window.pageYOffset;
11
- this.callbacks = /* @__PURE__ */ new Set();
12
12
  this.updateScrollDirection = this.updateScrollDirection.bind(this);
13
13
  window.addEventListener("scroll", this.updateScrollDirection);
14
14
  }
@@ -37,10 +37,11 @@ var ScrollDirectionTracker = class {
37
37
  * Detects when an element is scrolled past and is no longer in the viewport.
38
38
  */
39
39
  var ElementAboveViewportTracker = class {
40
+ isAboveViewport = false;
41
+ observer;
42
+ callbacks = /* @__PURE__ */ new Set();
40
43
  constructor(element) {
41
44
  this.element = element;
42
- this.isAboveViewport = false;
43
- this.callbacks = /* @__PURE__ */ new Set();
44
45
  this.observer = new IntersectionObserver(([entry]) => {
45
46
  const newIsAbove = entry.boundingClientRect.y < 0;
46
47
  if (newIsAbove !== this.isAboveViewport) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/vanilla/sub-navbar/index.ts"],"sourcesContent":["/**\n * Detects the vertical scroll direction of the page.\n * Returns 'up' | 'down' | null. The direction is only updated if the scroll distance\n * exceeds a 5px threshold to prevent sensitivity to minor scroll jitter.\n */\nclass ScrollDirectionTracker {\n private scrollDirection: 'up' | 'down' | null = null;\n private lastScrollY = window.pageYOffset;\n private callbacks = new Set<(direction: 'up' | 'down' | null) => void>();\n\n constructor() {\n this.updateScrollDirection = this.updateScrollDirection.bind(this);\n window.addEventListener('scroll', this.updateScrollDirection);\n }\n\n private updateScrollDirection() {\n const scrollY = window.pageYOffset;\n const direction = scrollY > this.lastScrollY ? 'down' : 'up';\n\n if (direction !== this.scrollDirection && (scrollY - this.lastScrollY > 5 || scrollY - this.lastScrollY < -5)) {\n this.scrollDirection = direction;\n this.callbacks.forEach((callback) => callback(this.scrollDirection));\n }\n\n this.lastScrollY = scrollY > 0 ? scrollY : 0;\n }\n\n subscribe(callback: (direction: 'up' | 'down' | null) => void) {\n this.callbacks.add(callback);\n return () => this.callbacks.delete(callback);\n }\n\n destroy() {\n window.removeEventListener('scroll', this.updateScrollDirection);\n this.callbacks.clear();\n }\n\n getCurrentDirection() {\n return this.scrollDirection;\n }\n}\n\n/**\n * Detects when an element is scrolled past and is no longer in the viewport.\n */\nclass ElementAboveViewportTracker {\n private isAboveViewport = false;\n private observer: IntersectionObserver;\n private callbacks = new Set<(isAbove: boolean) => void>();\n\n constructor(private element: HTMLElement) {\n this.observer = new IntersectionObserver(\n ([entry]) => {\n const newIsAbove = entry.boundingClientRect.y < 0;\n if (newIsAbove !== this.isAboveViewport) {\n this.isAboveViewport = newIsAbove;\n this.callbacks.forEach((callback) => callback(this.isAboveViewport));\n }\n },\n { threshold: [0] },\n );\n\n this.observer.observe(this.element);\n }\n\n subscribe(callback: (isAbove: boolean) => void) {\n this.callbacks.add(callback);\n return () => this.callbacks.delete(callback);\n }\n\n destroy() {\n this.observer.disconnect();\n this.callbacks.clear();\n }\n\n getIsAboveViewport() {\n return this.isAboveViewport;\n }\n}\n\nexport type InitSubNavbarOptions = {\n /**\n * Custom selector to find sub-navbars.\n * @default '.bi-sub-navbar'\n */\n selector?: string;\n};\n\n/**\n * Initializes all sub-navbars on the page to handle scroll-based behavior.\n * This includes:\n * - Setting data-fixed attribute when the navbar is scrolled past\n * - Setting data-scroll-dir attribute based on scroll direction when fixed\n *\n * @param options Configuration options\n * @returns Cleanup function to remove all event listeners and observers\n */\nexport const initSubNavbar = ({ selector = '.bi-sub-navbar' }: InitSubNavbarOptions = {}) => {\n const subNavbars = document.querySelectorAll<HTMLElement>(selector);\n\n if (subNavbars.length === 0) {\n console.warn(`No elements found with selector: ${selector}`);\n return () => {};\n }\n\n const scrollTracker = new ScrollDirectionTracker();\n const cleanupFunctions: (() => void)[] = [];\n\n subNavbars.forEach((navbar) => {\n const wrapper = navbar.closest('.bi-sub-navbar--wrapper') as HTMLElement;\n if (!wrapper) {\n console.warn('Sub-navbar must be wrapped in an element with class \"bi-sub-navbar--wrapper\"');\n return;\n }\n\n // Find or create the reference element (empty div) that acts as the scroll trigger\n let referenceElement = wrapper.querySelector<HTMLElement>('div:first-child');\n if (!referenceElement || referenceElement === navbar) {\n referenceElement = document.createElement('div');\n wrapper.insertBefore(referenceElement, navbar);\n }\n\n const viewportTracker = new ElementAboveViewportTracker(referenceElement);\n\n // Subscribe to viewport changes\n const unsubscribeViewport = viewportTracker.subscribe((isAbove) => {\n navbar.setAttribute('data-fixed', String(isAbove));\n\n // Only set scroll direction when fixed\n if (isAbove) {\n const currentDirection = scrollTracker.getCurrentDirection();\n if (currentDirection) {\n navbar.setAttribute('data-scroll-dir', currentDirection);\n }\n } else {\n navbar.removeAttribute('data-scroll-dir');\n }\n });\n\n // Subscribe to scroll direction changes\n const unsubscribeScroll = scrollTracker.subscribe((direction) => {\n const isFixed = navbar.getAttribute('data-fixed') === 'true';\n if (isFixed && direction) {\n navbar.setAttribute('data-scroll-dir', direction);\n }\n });\n\n cleanupFunctions.push(() => {\n unsubscribeViewport();\n unsubscribeScroll();\n viewportTracker.destroy();\n });\n });\n\n // Return cleanup function\n return () => {\n cleanupFunctions.forEach((cleanup) => cleanup());\n scrollTracker.destroy();\n };\n};\n"],"mappings":";;;;;;AAKA,IAAM,yBAAN,MAA6B;CAK3B,cAAc;yBAJkC;qBAC1B,OAAO;mCACT,IAAI,KAAgD;AAGtE,OAAK,wBAAwB,KAAK,sBAAsB,KAAK,KAAK;AAClE,SAAO,iBAAiB,UAAU,KAAK,sBAAsB;;CAG/D,wBAAgC;EAC9B,MAAM,UAAU,OAAO;EACvB,MAAM,YAAY,UAAU,KAAK,cAAc,SAAS;AAExD,MAAI,cAAc,KAAK,oBAAoB,UAAU,KAAK,cAAc,KAAK,UAAU,KAAK,cAAc,KAAK;AAC7G,QAAK,kBAAkB;AACvB,QAAK,UAAU,SAAS,aAAa,SAAS,KAAK,gBAAgB,CAAC;;AAGtE,OAAK,cAAc,UAAU,IAAI,UAAU;;CAG7C,UAAU,UAAqD;AAC7D,OAAK,UAAU,IAAI,SAAS;AAC5B,eAAa,KAAK,UAAU,OAAO,SAAS;;CAG9C,UAAU;AACR,SAAO,oBAAoB,UAAU,KAAK,sBAAsB;AAChE,OAAK,UAAU,OAAO;;CAGxB,sBAAsB;AACpB,SAAO,KAAK;;;;;;AAOhB,IAAM,8BAAN,MAAkC;CAKhC,YAAY,SAA8B;AAAtB,OAAA,UAAA;yBAJM;mCAEN,IAAI,KAAiC;AAGvD,OAAK,WAAW,IAAI,sBACjB,CAAC,WAAW;GACX,MAAM,aAAa,MAAM,mBAAmB,IAAI;AAChD,OAAI,eAAe,KAAK,iBAAiB;AACvC,SAAK,kBAAkB;AACvB,SAAK,UAAU,SAAS,aAAa,SAAS,KAAK,gBAAgB,CAAC;;KAGxE,EAAE,WAAW,CAAC,EAAE,EAAE,CACnB;AAED,OAAK,SAAS,QAAQ,KAAK,QAAQ;;CAGrC,UAAU,UAAsC;AAC9C,OAAK,UAAU,IAAI,SAAS;AAC5B,eAAa,KAAK,UAAU,OAAO,SAAS;;CAG9C,UAAU;AACR,OAAK,SAAS,YAAY;AAC1B,OAAK,UAAU,OAAO;;CAGxB,qBAAqB;AACnB,SAAO,KAAK;;;;;;;;;;;;AAqBhB,MAAa,iBAAiB,EAAE,WAAW,qBAA2C,EAAE,KAAK;CAC3F,MAAM,aAAa,SAAS,iBAA8B,SAAS;AAEnE,KAAI,WAAW,WAAW,GAAG;AAC3B,UAAQ,KAAK,oCAAoC,WAAW;AAC5D,eAAa;;CAGf,MAAM,gBAAgB,IAAI,wBAAwB;CAClD,MAAM,mBAAmC,EAAE;AAE3C,YAAW,SAAS,WAAW;EAC7B,MAAM,UAAU,OAAO,QAAQ,0BAA0B;AACzD,MAAI,CAAC,SAAS;AACZ,WAAQ,KAAK,iFAA+E;AAC5F;;EAIF,IAAI,mBAAmB,QAAQ,cAA2B,kBAAkB;AAC5E,MAAI,CAAC,oBAAoB,qBAAqB,QAAQ;AACpD,sBAAmB,SAAS,cAAc,MAAM;AAChD,WAAQ,aAAa,kBAAkB,OAAO;;EAGhD,MAAM,kBAAkB,IAAI,4BAA4B,iBAAiB;EAGzE,MAAM,sBAAsB,gBAAgB,WAAW,YAAY;AACjE,UAAO,aAAa,cAAc,OAAO,QAAQ,CAAC;AAGlD,OAAI,SAAS;IACX,MAAM,mBAAmB,cAAc,qBAAqB;AAC5D,QAAI,iBACF,QAAO,aAAa,mBAAmB,iBAAiB;SAG1D,QAAO,gBAAgB,kBAAkB;IAE3C;EAGF,MAAM,oBAAoB,cAAc,WAAW,cAAc;AAE/D,OADgB,OAAO,aAAa,aAAa,KAAK,UACvC,UACb,QAAO,aAAa,mBAAmB,UAAU;IAEnD;AAEF,mBAAiB,WAAW;AAC1B,wBAAqB;AACrB,sBAAmB;AACnB,mBAAgB,SAAS;IACzB;GACF;AAGF,cAAa;AACX,mBAAiB,SAAS,YAAY,SAAS,CAAC;AAChD,gBAAc,SAAS"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/vanilla/sub-navbar/index.ts"],"sourcesContent":["/**\n * Detects the vertical scroll direction of the page.\n * Returns 'up' | 'down' | null. The direction is only updated if the scroll distance\n * exceeds a 5px threshold to prevent sensitivity to minor scroll jitter.\n */\nclass ScrollDirectionTracker {\n private scrollDirection: 'up' | 'down' | null = null;\n private lastScrollY = window.pageYOffset;\n private callbacks = new Set<(direction: 'up' | 'down' | null) => void>();\n\n constructor() {\n this.updateScrollDirection = this.updateScrollDirection.bind(this);\n window.addEventListener('scroll', this.updateScrollDirection);\n }\n\n private updateScrollDirection() {\n const scrollY = window.pageYOffset;\n const direction = scrollY > this.lastScrollY ? 'down' : 'up';\n\n if (direction !== this.scrollDirection && (scrollY - this.lastScrollY > 5 || scrollY - this.lastScrollY < -5)) {\n this.scrollDirection = direction;\n this.callbacks.forEach((callback) => callback(this.scrollDirection));\n }\n\n this.lastScrollY = scrollY > 0 ? scrollY : 0;\n }\n\n subscribe(callback: (direction: 'up' | 'down' | null) => void) {\n this.callbacks.add(callback);\n return () => this.callbacks.delete(callback);\n }\n\n destroy() {\n window.removeEventListener('scroll', this.updateScrollDirection);\n this.callbacks.clear();\n }\n\n getCurrentDirection() {\n return this.scrollDirection;\n }\n}\n\n/**\n * Detects when an element is scrolled past and is no longer in the viewport.\n */\nclass ElementAboveViewportTracker {\n private isAboveViewport = false;\n private observer: IntersectionObserver;\n private callbacks = new Set<(isAbove: boolean) => void>();\n\n constructor(private element: HTMLElement) {\n this.observer = new IntersectionObserver(\n ([entry]) => {\n const newIsAbove = entry.boundingClientRect.y < 0;\n if (newIsAbove !== this.isAboveViewport) {\n this.isAboveViewport = newIsAbove;\n this.callbacks.forEach((callback) => callback(this.isAboveViewport));\n }\n },\n { threshold: [0] },\n );\n\n this.observer.observe(this.element);\n }\n\n subscribe(callback: (isAbove: boolean) => void) {\n this.callbacks.add(callback);\n return () => this.callbacks.delete(callback);\n }\n\n destroy() {\n this.observer.disconnect();\n this.callbacks.clear();\n }\n\n getIsAboveViewport() {\n return this.isAboveViewport;\n }\n}\n\nexport type InitSubNavbarOptions = {\n /**\n * Custom selector to find sub-navbars.\n * @default '.bi-sub-navbar'\n */\n selector?: string;\n};\n\n/**\n * Initializes all sub-navbars on the page to handle scroll-based behavior.\n * This includes:\n * - Setting data-fixed attribute when the navbar is scrolled past\n * - Setting data-scroll-dir attribute based on scroll direction when fixed\n *\n * @param options Configuration options\n * @returns Cleanup function to remove all event listeners and observers\n */\nexport const initSubNavbar = ({ selector = '.bi-sub-navbar' }: InitSubNavbarOptions = {}) => {\n const subNavbars = document.querySelectorAll<HTMLElement>(selector);\n\n if (subNavbars.length === 0) {\n console.warn(`No elements found with selector: ${selector}`);\n return () => {};\n }\n\n const scrollTracker = new ScrollDirectionTracker();\n const cleanupFunctions: (() => void)[] = [];\n\n subNavbars.forEach((navbar) => {\n const wrapper = navbar.closest('.bi-sub-navbar--wrapper') as HTMLElement;\n if (!wrapper) {\n console.warn('Sub-navbar must be wrapped in an element with class \"bi-sub-navbar--wrapper\"');\n return;\n }\n\n // Find or create the reference element (empty div) that acts as the scroll trigger\n let referenceElement = wrapper.querySelector<HTMLElement>('div:first-child');\n if (!referenceElement || referenceElement === navbar) {\n referenceElement = document.createElement('div');\n wrapper.insertBefore(referenceElement, navbar);\n }\n\n const viewportTracker = new ElementAboveViewportTracker(referenceElement);\n\n // Subscribe to viewport changes\n const unsubscribeViewport = viewportTracker.subscribe((isAbove) => {\n navbar.setAttribute('data-fixed', String(isAbove));\n\n // Only set scroll direction when fixed\n if (isAbove) {\n const currentDirection = scrollTracker.getCurrentDirection();\n if (currentDirection) {\n navbar.setAttribute('data-scroll-dir', currentDirection);\n }\n } else {\n navbar.removeAttribute('data-scroll-dir');\n }\n });\n\n // Subscribe to scroll direction changes\n const unsubscribeScroll = scrollTracker.subscribe((direction) => {\n const isFixed = navbar.getAttribute('data-fixed') === 'true';\n if (isFixed && direction) {\n navbar.setAttribute('data-scroll-dir', direction);\n }\n });\n\n cleanupFunctions.push(() => {\n unsubscribeViewport();\n unsubscribeScroll();\n viewportTracker.destroy();\n });\n });\n\n // Return cleanup function\n return () => {\n cleanupFunctions.forEach((cleanup) => cleanup());\n scrollTracker.destroy();\n };\n};\n"],"mappings":";;;;;;AAKA,IAAM,yBAAN,MAA6B;CAC3B,kBAAgD;CAChD,cAAsB,OAAO;CAC7B,4BAAoB,IAAI,KAAgD;CAExE,cAAc;AACZ,OAAK,wBAAwB,KAAK,sBAAsB,KAAK,KAAK;AAClE,SAAO,iBAAiB,UAAU,KAAK,sBAAsB;;CAG/D,wBAAgC;EAC9B,MAAM,UAAU,OAAO;EACvB,MAAM,YAAY,UAAU,KAAK,cAAc,SAAS;AAExD,MAAI,cAAc,KAAK,oBAAoB,UAAU,KAAK,cAAc,KAAK,UAAU,KAAK,cAAc,KAAK;AAC7G,QAAK,kBAAkB;AACvB,QAAK,UAAU,SAAS,aAAa,SAAS,KAAK,gBAAgB,CAAC;;AAGtE,OAAK,cAAc,UAAU,IAAI,UAAU;;CAG7C,UAAU,UAAqD;AAC7D,OAAK,UAAU,IAAI,SAAS;AAC5B,eAAa,KAAK,UAAU,OAAO,SAAS;;CAG9C,UAAU;AACR,SAAO,oBAAoB,UAAU,KAAK,sBAAsB;AAChE,OAAK,UAAU,OAAO;;CAGxB,sBAAsB;AACpB,SAAO,KAAK;;;;;;AAOhB,IAAM,8BAAN,MAAkC;CAChC,kBAA0B;CAC1B;CACA,4BAAoB,IAAI,KAAiC;CAEzD,YAAY,SAA8B;AAAtB,OAAA,UAAA;AAClB,OAAK,WAAW,IAAI,sBACjB,CAAC,WAAW;GACX,MAAM,aAAa,MAAM,mBAAmB,IAAI;AAChD,OAAI,eAAe,KAAK,iBAAiB;AACvC,SAAK,kBAAkB;AACvB,SAAK,UAAU,SAAS,aAAa,SAAS,KAAK,gBAAgB,CAAC;;KAGxE,EAAE,WAAW,CAAC,EAAE,EAAE,CACnB;AAED,OAAK,SAAS,QAAQ,KAAK,QAAQ;;CAGrC,UAAU,UAAsC;AAC9C,OAAK,UAAU,IAAI,SAAS;AAC5B,eAAa,KAAK,UAAU,OAAO,SAAS;;CAG9C,UAAU;AACR,OAAK,SAAS,YAAY;AAC1B,OAAK,UAAU,OAAO;;CAGxB,qBAAqB;AACnB,SAAO,KAAK;;;;;;;;;;;;AAqBhB,MAAa,iBAAiB,EAAE,WAAW,qBAA2C,EAAE,KAAK;CAC3F,MAAM,aAAa,SAAS,iBAA8B,SAAS;AAEnE,KAAI,WAAW,WAAW,GAAG;AAC3B,UAAQ,KAAK,oCAAoC,WAAW;AAC5D,eAAa;;CAGf,MAAM,gBAAgB,IAAI,wBAAwB;CAClD,MAAM,mBAAmC,EAAE;AAE3C,YAAW,SAAS,WAAW;EAC7B,MAAM,UAAU,OAAO,QAAQ,0BAA0B;AACzD,MAAI,CAAC,SAAS;AACZ,WAAQ,KAAK,iFAA+E;AAC5F;;EAIF,IAAI,mBAAmB,QAAQ,cAA2B,kBAAkB;AAC5E,MAAI,CAAC,oBAAoB,qBAAqB,QAAQ;AACpD,sBAAmB,SAAS,cAAc,MAAM;AAChD,WAAQ,aAAa,kBAAkB,OAAO;;EAGhD,MAAM,kBAAkB,IAAI,4BAA4B,iBAAiB;EAGzE,MAAM,sBAAsB,gBAAgB,WAAW,YAAY;AACjE,UAAO,aAAa,cAAc,OAAO,QAAQ,CAAC;AAGlD,OAAI,SAAS;IACX,MAAM,mBAAmB,cAAc,qBAAqB;AAC5D,QAAI,iBACF,QAAO,aAAa,mBAAmB,iBAAiB;SAG1D,QAAO,gBAAgB,kBAAkB;IAE3C;EAGF,MAAM,oBAAoB,cAAc,WAAW,cAAc;AAE/D,OADgB,OAAO,aAAa,aAAa,KAAK,UACvC,UACb,QAAO,aAAa,mBAAmB,UAAU;IAEnD;AAEF,mBAAiB,WAAW;AAC1B,wBAAqB;AACrB,sBAAmB;AACnB,mBAAgB,SAAS;IACzB;GACF;AAGF,cAAa;AACX,mBAAiB,SAAS,YAAY,SAAS,CAAC;AAChD,gBAAc,SAAS"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bi-digital/react",
3
3
  "type": "module",
4
- "version": "0.11.0",
4
+ "version": "0.11.2",
5
5
  "description": "React components from BI Digital",
6
6
  "author": "BI Digital",
7
7
  "homepage": "https://designsystem.bi.no/",
@@ -38,26 +38,25 @@
38
38
  "@radix-ui/react-slot": "^1.2.4",
39
39
  "@radix-ui/react-use-controllable-state": "^1.2.2",
40
40
  "clsx": "^2.1.1",
41
- "@bi-digital/icons": "0.11.0"
41
+ "@bi-digital/icons": "0.11.2"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/react": "^19.2.14",
45
45
  "@types/react-dom": "^19.2.3",
46
- "@vitest/browser-playwright": "^4.1.0",
47
- "@vitest/coverage-v8": "^4.1.0",
48
- "@vitest/expect": "^4.1.0",
49
- "playwright": "^1.58.2",
46
+ "@vitest/browser-playwright": "^4.1.4",
47
+ "@vitest/coverage-v8": "^4.1.4",
48
+ "@vitest/expect": "^4.1.4",
49
+ "playwright": "^1.59.1",
50
50
  "react": "^19.2.0",
51
51
  "react-dom": "^19.2.0",
52
- "tsconfck": "^3.1.6",
53
- "tsdown": "^0.21.0",
54
- "vitest": "^4.1.0",
55
- "vitest-browser-react": "^2.1.0"
52
+ "tsdown": "^0.21.7",
53
+ "vitest": "^4.1.4",
54
+ "vitest-browser-react": "^2.2.0"
56
55
  },
57
56
  "peerDependencies": {
58
57
  "react": "^19",
59
58
  "react-dom": "^19",
60
- "@bi-digital/css": "0.11.0"
59
+ "@bi-digital/css": "0.11.2"
61
60
  },
62
61
  "scripts": {
63
62
  "build": "tsdown",