@rio-cloud/rio-uikit 2.3.0-beta.2 → 2.3.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/Marker.js +9 -5
- package/Table.js +10 -9
- package/TableNext.js +10 -9
- package/TableRowActionsDropdown.d.ts +2 -0
- package/TableRowActionsDropdown.js +5 -0
- package/TableRowActionsDropdown.js.map +1 -0
- package/components/analyticsAnalysisOverlay/AnalyticsAnalysisBanner.d.ts +38 -3
- package/components/analyticsAnalysisOverlay/AnalyticsAnalysisBanner.js +104 -109
- package/components/analyticsAnalysisOverlay/AnalyticsAnalysisBanner.js.map +1 -1
- package/components/analyticsAnalysisOverlay/AnalyticsAnalysisOverlay.d.ts +24 -5
- package/components/analyticsAnalysisOverlay/AnalyticsAnalysisOverlay.js +60 -56
- package/components/analyticsAnalysisOverlay/AnalyticsAnalysisOverlay.js.map +1 -1
- package/components/datepicker/DayPicker.js +72 -70
- package/components/datepicker/DayPicker.js.map +1 -1
- package/components/datepicker/DayPickerDropdown.d.ts +1 -0
- package/components/datepicker/DayPickerDropdown.js +61 -48
- package/components/datepicker/DayPickerDropdown.js.map +1 -1
- package/components/datepicker/useStackedDayPickerCalendars.js +26 -26
- package/components/datepicker/useStackedDayPickerCalendars.js.map +1 -1
- package/components/dropdown/ButtonDropdown.d.ts +4 -0
- package/components/dropdown/ButtonDropdown.js +82 -80
- package/components/dropdown/ButtonDropdown.js.map +1 -1
- package/components/listMenu/ListMenu.d.ts +8 -0
- package/components/listMenu/ListMenu.js +74 -66
- package/components/listMenu/ListMenu.js.map +1 -1
- package/components/map/components/Map.js +207 -156
- package/components/map/components/Map.js.map +1 -1
- package/components/map/components/MapContext.d.ts +3 -0
- package/components/map/components/MapContext.js +9 -6
- package/components/map/components/MapContext.js.map +1 -1
- package/components/map/components/features/MapZoom.js +19 -19
- package/components/map/components/features/MapZoom.js.map +1 -1
- package/components/map/components/features/Route.d.ts +65 -1
- package/components/map/components/features/Route.js +184 -98
- package/components/map/components/features/Route.js.map +1 -1
- package/components/map/components/features/basics/Marker.d.ts +21 -1
- package/components/map/components/features/basics/Marker.js +99 -40
- package/components/map/components/features/basics/Marker.js.map +1 -1
- package/components/map/components/features/basics/Polygon.d.ts +24 -1
- package/components/map/components/features/basics/Polygon.js +72 -19
- package/components/map/components/features/basics/Polygon.js.map +1 -1
- package/components/map/components/features/basics/Polyline.d.ts +29 -0
- package/components/map/components/features/basics/Polyline.js +69 -39
- package/components/map/components/features/basics/Polyline.js.map +1 -1
- package/components/map/components/features/layers/MarkerLayer.js +8 -8
- package/components/map/components/features/layers/MarkerLayer.js.map +1 -1
- package/components/map/components/features/layers/clustering/SimpleClusterLayer.js +13 -6
- package/components/map/components/features/layers/clustering/SimpleClusterLayer.js.map +1 -1
- package/components/map/utils/clustering.d.ts +1 -1
- package/components/map/utils/clustering.js +30 -30
- package/components/map/utils/clustering.js.map +1 -1
- package/components/map/utils/mapTypes.d.ts +141 -0
- package/components/map/utils/mapTypes.js.map +1 -1
- package/components/map/utils/mapUtils.d.ts +2 -0
- package/components/map/utils/mapUtils.js +4 -0
- package/components/map/utils/mapUtils.js.map +1 -1
- package/components/mapMarker/ClusterMapMarker.d.ts +2 -0
- package/components/mapMarker/ClusterMapMarker.js.map +1 -1
- package/components/mapMarker/SingleMapMarker.d.ts +2 -0
- package/components/mapMarker/SingleMapMarker.js.map +1 -1
- package/components/selects/ClearButton.js +9 -7
- package/components/selects/ClearButton.js.map +1 -1
- package/components/table/Table.d.ts +3 -1
- package/components/table/Table.js +239 -216
- package/components/table/Table.js.map +1 -1
- package/components/table/Table.types.d.ts +62 -4
- package/components/table/TableColumn.d.ts +8 -1
- package/components/table/TableColumn.js +66 -64
- package/components/table/TableColumn.js.map +1 -1
- package/components/table/TableExpandedRow.d.ts +4 -0
- package/components/table/TableExpandedRow.js +70 -67
- package/components/table/TableExpandedRow.js.map +1 -1
- package/components/table/TableGroupRow.d.ts +3 -1
- package/components/table/TableGroupRow.js +15 -14
- package/components/table/TableGroupRow.js.map +1 -1
- package/components/table/TableHeader.d.ts +9 -0
- package/components/table/TableHeader.js +110 -81
- package/components/table/TableHeader.js.map +1 -1
- package/components/table/TableHeaderColumn.d.ts +11 -1
- package/components/table/TableHeaderColumn.js +63 -58
- package/components/table/TableHeaderColumn.js.map +1 -1
- package/components/table/TableRow.d.ts +12 -0
- package/components/table/TableRow.js +78 -74
- package/components/table/TableRow.js.map +1 -1
- package/components/table/TableRowActionsDropdown.d.ts +11 -0
- package/components/table/TableRowActionsDropdown.js +22 -0
- package/components/table/TableRowActionsDropdown.js.map +1 -0
- package/components/table/TableStickyRowButton.d.ts +25 -0
- package/components/table/TableStickyRowButton.js +32 -0
- package/components/table/TableStickyRowButton.js.map +1 -0
- package/components/table/TableToolbar.d.ts +24 -3
- package/components/table/TableToolbar.js +78 -37
- package/components/table/TableToolbar.js.map +1 -1
- package/components/table/TableViewToggles.js +5 -5
- package/components/table/TableViewToggles.js.map +1 -1
- package/components/table/context/TableInteractionContext.d.ts +3 -0
- package/components/table/context/TableInteractionContext.js.map +1 -1
- package/components/table/context/TableLayoutContext.d.ts +1 -0
- package/components/table/context/TableLayoutContext.js.map +1 -1
- package/components/table/context/TableRenderContext.d.ts +1 -0
- package/components/table/context/TableRenderContext.js.map +1 -1
- package/components/table/layout/useHorizontalSectionSync.d.ts +2 -1
- package/components/table/layout/useHorizontalSectionSync.js +32 -31
- package/components/table/layout/useHorizontalSectionSync.js.map +1 -1
- package/components/table/layout/useMeasuredColumnMaxWidths.js +52 -54
- package/components/table/layout/useMeasuredColumnMaxWidths.js.map +1 -1
- package/components/table/layout/useTableLayout.d.ts +6 -2
- package/components/table/layout/useTableLayout.js +61 -48
- package/components/table/layout/useTableLayout.js.map +1 -1
- package/components/table/layout/useTableVirtualization.js +51 -56
- package/components/table/layout/useTableVirtualization.js.map +1 -1
- package/components/table/model/resolveResponsiveViewType.d.ts +2 -0
- package/components/table/model/resolveResponsiveViewType.js +27 -0
- package/components/table/model/resolveResponsiveViewType.js.map +1 -0
- package/components/table/render/header/TableDraggableHeaderCell.js +38 -36
- package/components/table/render/header/TableDraggableHeaderCell.js.map +1 -1
- package/components/table/render/header/TableHeader.types.d.ts +2 -0
- package/components/table/render/header/TableHeaderCellContent.js +16 -16
- package/components/table/render/header/TableHeaderCellContent.js.map +1 -1
- package/components/table/render/header/TableHeaderSelectionCell.d.ts +1 -0
- package/components/table/render/header/TableHeaderSelectionCell.js +13 -12
- package/components/table/render/header/TableHeaderSelectionCell.js.map +1 -1
- package/components/table/render/header/TableStaticHeaderCell.js +31 -29
- package/components/table/render/header/TableStaticHeaderCell.js.map +1 -1
- package/components/table/render/header/resolveHeaderCellClassName.d.ts +1 -0
- package/components/table/render/header/resolveHeaderCellClassName.js +10 -9
- package/components/table/render/header/resolveHeaderCellClassName.js.map +1 -1
- package/components/table/runtime/useResolvedRenderColumns.d.ts +4 -4
- package/components/table/runtime/useResolvedRenderColumns.js +13 -13
- package/components/table/runtime/useResolvedRenderColumns.js.map +1 -1
- package/components/table/runtime/useResolvedRenderHeader.d.ts +1 -1
- package/components/table/runtime/useResolvedRenderHeader.js.map +1 -1
- package/components/table/runtime/useResponsiveResolvedViewType.d.ts +23 -0
- package/components/table/runtime/useResponsiveResolvedViewType.js +22 -0
- package/components/table/runtime/useResponsiveResolvedViewType.js.map +1 -0
- package/components/table/selection/useInternalTableSelectionState.d.ts +2 -0
- package/components/table/selection/useInternalTableSelectionState.js +27 -17
- package/components/table/selection/useInternalTableSelectionState.js.map +1 -1
- package/components/table/selection/useTableSelection.d.ts +5 -1
- package/components/table/selection/useTableSelection.js +37 -26
- package/components/table/selection/useTableSelection.js.map +1 -1
- package/components/table/shared/parsePixelSize.d.ts +2 -0
- package/components/table/shared/parsePixelSize.js +13 -0
- package/components/table/shared/parsePixelSize.js.map +1 -0
- package/hooks/useDraggableElement.d.ts +27 -5
- package/hooks/useDraggableElement.js +100 -23
- package/hooks/useDraggableElement.js.map +1 -1
- package/hooks/usePopperDropdown.d.ts +1 -0
- package/hooks/usePopperDropdown.js +15 -12
- package/hooks/usePopperDropdown.js.map +1 -1
- package/hooks/useResizeObserver.d.ts +25 -6
- package/hooks/useResizeObserver.js +20 -18
- package/hooks/useResizeObserver.js.map +1 -1
- package/package.json +10 -10
- package/utils/analytics/createAnalyticsOverlayTooltip.js.map +1 -1
- package/utils/init/initConfig.js +5 -5
- package/utils/init/initConfig.js.map +1 -1
- package/version.d.ts +1 -1
- package/version.js +2 -2
- package/version.js.map +1 -1
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
const
|
|
5
|
-
const [
|
|
6
|
-
const
|
|
7
|
-
if (!
|
|
1
|
+
import { useState as A, useCallback as b, useEffect as B } from "react";
|
|
2
|
+
import M from "../../hooks/useResizeObserver.js";
|
|
3
|
+
import k from "../../hooks/useWindowResize.js";
|
|
4
|
+
const q = 480, _ = (f = []) => {
|
|
5
|
+
const [l, , { inlineSize: u }] = M(), [g, o] = A(!1), s = b(() => {
|
|
6
|
+
const n = l.current;
|
|
7
|
+
if (!n || typeof window > "u")
|
|
8
8
|
return;
|
|
9
|
-
const
|
|
10
|
-
if (!
|
|
11
|
-
|
|
9
|
+
const r = n.querySelector(".rdp-months"), d = r ? Array.from(r.querySelectorAll(".rdp-month")) : [], m = d[0];
|
|
10
|
+
if (!r || !m) {
|
|
11
|
+
o(!1);
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
|
-
const
|
|
15
|
-
if (!
|
|
16
|
-
|
|
14
|
+
const i = n.parentElement, a = i?.parentElement, h = a?.parentElement, c = window.document.documentElement.clientWidth;
|
|
15
|
+
if (!i || !a || !h || !u || !c) {
|
|
16
|
+
o(!1);
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
|
-
if (
|
|
20
|
-
|
|
19
|
+
if (c < q) {
|
|
20
|
+
o(!1);
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
|
-
const
|
|
23
|
+
const p = Number.parseFloat(window.getComputedStyle(r).columnGap || "0") || 0, w = m.getBoundingClientRect().width, C = Math.max(
|
|
24
24
|
0,
|
|
25
|
-
|
|
26
|
-
),
|
|
27
|
-
|
|
28
|
-
}, [
|
|
29
|
-
return
|
|
30
|
-
|
|
31
|
-
}, [
|
|
32
|
-
calendarsRef:
|
|
33
|
-
stackCalendars:
|
|
25
|
+
n.getBoundingClientRect().width - r.getBoundingClientRect().width
|
|
26
|
+
), E = w * d.length + p * (d.length - 1) + C, S = Array.from(i.children).reduce((e, t) => t === n ? e : e + t.getBoundingClientRect().width, 0), R = Array.from(a.children).reduce((e, t) => t === i ? e : Math.max(e, t.getBoundingClientRect().width), 0), y = Array.from(h.children).reduce((e, t) => t === a ? e : e + t.getBoundingClientRect().width, 0), W = Math.max(E + S, R);
|
|
27
|
+
o(W + y > c - 32);
|
|
28
|
+
}, [u, l]);
|
|
29
|
+
return k(s), B(() => {
|
|
30
|
+
s();
|
|
31
|
+
}, [s, ...f]), {
|
|
32
|
+
calendarsRef: l,
|
|
33
|
+
stackCalendars: g
|
|
34
34
|
};
|
|
35
35
|
};
|
|
36
36
|
export {
|
|
37
|
-
|
|
37
|
+
_ as default
|
|
38
38
|
};
|
|
39
39
|
//# sourceMappingURL=useStackedDayPickerCalendars.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStackedDayPickerCalendars.js","sources":["../../../src/components/datepicker/useStackedDayPickerCalendars.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react';\n\nimport useResizeObserver from '../../hooks/useResizeObserver';\nimport useWindowResize from '../../hooks/useWindowResize';\n\nconst STACKED_CALENDARS_XS_MAX = 480;\n\nconst useStackedDayPickerCalendars = (dependencies: readonly unknown[] = []) => {\n const [calendarsRef, , { inlineSize: calendarsInlineSize }] = useResizeObserver<HTMLDivElement>();\n const [stackCalendars, setStackCalendars] = useState(false);\n\n const updateCalendarLayout = useCallback(() => {\n const calendarsElement = calendarsRef.current;\n if (!calendarsElement || typeof window === 'undefined') {\n return;\n }\n\n const monthsWrapper = calendarsElement.querySelector<HTMLElement>('.rdp-months');\n const monthElements = monthsWrapper\n ? Array.from(monthsWrapper.querySelectorAll<HTMLElement>('.rdp-month'))\n : [];\n const firstMonthElement = monthElements[0];\n\n if (!monthsWrapper || !firstMonthElement) {\n setStackCalendars(false);\n return;\n }\n\n const rowElement = calendarsElement.parentElement;\n const viewportWidth = window.document.documentElement.clientWidth;\n\n if (!rowElement || !calendarsInlineSize || !viewportWidth) {\n setStackCalendars(false);\n return;\n }\n\n // XS layouts are always stacked via CSS so Popper measures the compact layout immediately.\n if (viewportWidth < STACKED_CALENDARS_XS_MAX) {\n setStackCalendars(false);\n return;\n }\n\n const monthsGap = Number.parseFloat(window.getComputedStyle(monthsWrapper).columnGap || '0') || 0;\n const monthWidth = firstMonthElement.getBoundingClientRect().width;\n const calendarsExtraWidth = Math.max(\n 0,\n calendarsElement.getBoundingClientRect().width - monthsWrapper.getBoundingClientRect().width\n );\n const requiredCalendarsWidth =\n monthWidth * monthElements.length + monthsGap * (monthElements.length - 1) + calendarsExtraWidth;\n const
|
|
1
|
+
{"version":3,"file":"useStackedDayPickerCalendars.js","sources":["../../../src/components/datepicker/useStackedDayPickerCalendars.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react';\n\nimport useResizeObserver from '../../hooks/useResizeObserver';\nimport useWindowResize from '../../hooks/useWindowResize';\n\nconst STACKED_CALENDARS_XS_MAX = 480;\n\nconst useStackedDayPickerCalendars = (dependencies: readonly unknown[] = []) => {\n const [calendarsRef, , { inlineSize: calendarsInlineSize }] = useResizeObserver<HTMLDivElement>();\n const [stackCalendars, setStackCalendars] = useState(false);\n\n const updateCalendarLayout = useCallback(() => {\n const calendarsElement = calendarsRef.current;\n if (!calendarsElement || typeof window === 'undefined') {\n return;\n }\n\n const monthsWrapper = calendarsElement.querySelector<HTMLElement>('.rdp-months');\n const monthElements = monthsWrapper\n ? Array.from(monthsWrapper.querySelectorAll<HTMLElement>('.rdp-month'))\n : [];\n const firstMonthElement = monthElements[0];\n\n if (!monthsWrapper || !firstMonthElement) {\n setStackCalendars(false);\n return;\n }\n\n const rowElement = calendarsElement.parentElement;\n const mainColumnElement = rowElement?.parentElement;\n const outerRowElement = mainColumnElement?.parentElement;\n const viewportWidth = window.document.documentElement.clientWidth;\n\n if (!rowElement || !mainColumnElement || !outerRowElement || !calendarsInlineSize || !viewportWidth) {\n setStackCalendars(false);\n return;\n }\n\n // XS layouts are always stacked via CSS so Popper measures the compact layout immediately.\n if (viewportWidth < STACKED_CALENDARS_XS_MAX) {\n setStackCalendars(false);\n return;\n }\n\n const monthsGap = Number.parseFloat(window.getComputedStyle(monthsWrapper).columnGap || '0') || 0;\n const monthWidth = firstMonthElement.getBoundingClientRect().width;\n\n const calendarsExtraWidth = Math.max(\n 0,\n calendarsElement.getBoundingClientRect().width - monthsWrapper.getBoundingClientRect().width\n );\n\n const requiredCalendarsWidth =\n monthWidth * monthElements.length + monthsGap * (monthElements.length - 1) + calendarsExtraWidth;\n\n const rowSiblingWidth = Array.from(rowElement.children).reduce((sum, child) => {\n if (child === calendarsElement) {\n return sum;\n }\n\n return sum + (child as HTMLElement).getBoundingClientRect().width;\n }, 0);\n\n const mainColumnSiblingWidth = Array.from(mainColumnElement.children).reduce((maxWidth, child) => {\n if (child === rowElement) {\n return maxWidth;\n }\n\n return Math.max(maxWidth, (child as HTMLElement).getBoundingClientRect().width);\n }, 0);\n\n const outerRowSiblingWidth = Array.from(outerRowElement.children).reduce((sum, child) => {\n if (child === mainColumnElement) {\n return sum;\n }\n\n return sum + (child as HTMLElement).getBoundingClientRect().width;\n }, 0);\n\n const requiredMainColumnWidth = Math.max(requiredCalendarsWidth + rowSiblingWidth, mainColumnSiblingWidth);\n\n setStackCalendars(requiredMainColumnWidth + outerRowSiblingWidth > viewportWidth - 32);\n }, [calendarsInlineSize, calendarsRef]);\n\n useWindowResize(updateCalendarLayout);\n\n useEffect(() => {\n updateCalendarLayout();\n }, [updateCalendarLayout, ...dependencies]);\n\n return {\n calendarsRef,\n stackCalendars,\n };\n};\n\nexport default useStackedDayPickerCalendars;\n"],"names":["STACKED_CALENDARS_XS_MAX","useStackedDayPickerCalendars","dependencies","calendarsRef","calendarsInlineSize","useResizeObserver","stackCalendars","setStackCalendars","useState","updateCalendarLayout","useCallback","calendarsElement","monthsWrapper","monthElements","firstMonthElement","rowElement","mainColumnElement","outerRowElement","viewportWidth","monthsGap","monthWidth","calendarsExtraWidth","requiredCalendarsWidth","rowSiblingWidth","sum","child","mainColumnSiblingWidth","maxWidth","outerRowSiblingWidth","requiredMainColumnWidth","useWindowResize","useEffect"],"mappings":";;;AAKA,MAAMA,IAA2B,KAE3BC,IAA+B,CAACC,IAAmC,OAAO;AAC5E,QAAM,CAACC,KAAgB,EAAE,YAAYC,EAAA,CAAqB,IAAIC,EAAA,GACxD,CAACC,GAAgBC,CAAiB,IAAIC,EAAS,EAAK,GAEpDC,IAAuBC,EAAY,MAAM;AAC3C,UAAMC,IAAmBR,EAAa;AACtC,QAAI,CAACQ,KAAoB,OAAO,SAAW;AACvC;AAGJ,UAAMC,IAAgBD,EAAiB,cAA2B,aAAa,GACzEE,IAAgBD,IAChB,MAAM,KAAKA,EAAc,iBAA8B,YAAY,CAAC,IACpE,CAAA,GACAE,IAAoBD,EAAc,CAAC;AAEzC,QAAI,CAACD,KAAiB,CAACE,GAAmB;AACtC,MAAAP,EAAkB,EAAK;AACvB;AAAA,IACJ;AAEA,UAAMQ,IAAaJ,EAAiB,eAC9BK,IAAoBD,GAAY,eAChCE,IAAkBD,GAAmB,eACrCE,IAAgB,OAAO,SAAS,gBAAgB;AAEtD,QAAI,CAACH,KAAc,CAACC,KAAqB,CAACC,KAAmB,CAACb,KAAuB,CAACc,GAAe;AACjG,MAAAX,EAAkB,EAAK;AACvB;AAAA,IACJ;AAGA,QAAIW,IAAgBlB,GAA0B;AAC1C,MAAAO,EAAkB,EAAK;AACvB;AAAA,IACJ;AAEA,UAAMY,IAAY,OAAO,WAAW,OAAO,iBAAiBP,CAAa,EAAE,aAAa,GAAG,KAAK,GAC1FQ,IAAaN,EAAkB,sBAAA,EAAwB,OAEvDO,IAAsB,KAAK;AAAA,MAC7B;AAAA,MACAV,EAAiB,sBAAA,EAAwB,QAAQC,EAAc,wBAAwB;AAAA,IAAA,GAGrFU,IACFF,IAAaP,EAAc,SAASM,KAAaN,EAAc,SAAS,KAAKQ,GAE3EE,IAAkB,MAAM,KAAKR,EAAW,QAAQ,EAAE,OAAO,CAACS,GAAKC,MAC7DA,MAAUd,IACHa,IAGJA,IAAOC,EAAsB,sBAAA,EAAwB,OAC7D,CAAC,GAEEC,IAAyB,MAAM,KAAKV,EAAkB,QAAQ,EAAE,OAAO,CAACW,GAAUF,MAChFA,MAAUV,IACHY,IAGJ,KAAK,IAAIA,GAAWF,EAAsB,sBAAA,EAAwB,KAAK,GAC/E,CAAC,GAEEG,IAAuB,MAAM,KAAKX,EAAgB,QAAQ,EAAE,OAAO,CAACO,GAAKC,MACvEA,MAAUT,IACHQ,IAGJA,IAAOC,EAAsB,sBAAA,EAAwB,OAC7D,CAAC,GAEEI,IAA0B,KAAK,IAAIP,IAAyBC,GAAiBG,CAAsB;AAEzG,IAAAnB,EAAkBsB,IAA0BD,IAAuBV,IAAgB,EAAE;AAAA,EACzF,GAAG,CAACd,GAAqBD,CAAY,CAAC;AAEtC,SAAA2B,EAAgBrB,CAAoB,GAEpCsB,EAAU,MAAM;AACZ,IAAAtB,EAAA;AAAA,EACJ,GAAG,CAACA,GAAsB,GAAGP,CAAY,CAAC,GAEnC;AAAA,IACH,cAAAC;AAAA,IACA,gBAAAG;AAAA,EAAA;AAER;"}
|
|
@@ -7,6 +7,10 @@ export type ButtonDropdownProps<T extends DropdownToggleButtonType = 'button'> =
|
|
|
7
7
|
* Unique button id. If not present a random id is generated.
|
|
8
8
|
*/
|
|
9
9
|
id?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Accessible label applied to the dropdown toggle button.
|
|
12
|
+
*/
|
|
13
|
+
'aria-label'?: string;
|
|
10
14
|
/**
|
|
11
15
|
* The button title. This may be also a node, like a <span> or a <FormattedMessage>.
|
|
12
16
|
*/
|
|
@@ -1,124 +1,126 @@
|
|
|
1
1
|
import { jsx as i, jsxs as h } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef as
|
|
2
|
+
import { forwardRef as lo, useState as c, useEffect as ao } from "react";
|
|
3
3
|
import po from "react-dom";
|
|
4
|
-
import { usePopper as
|
|
4
|
+
import { usePopper as io } from "react-popper";
|
|
5
5
|
import { noop as u } from "es-toolkit/function";
|
|
6
|
-
import { isNil as
|
|
6
|
+
import { isNil as co } from "es-toolkit/predicate";
|
|
7
7
|
import P from "../../utils/classNames.js";
|
|
8
|
-
import { getOrCreatePortalRoot as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
8
|
+
import { getOrCreatePortalRoot as fo } from "../../utils/portalRoot.js";
|
|
9
|
+
import mo, { DEFAULT_EVENT_TYPES as uo } from "../../hooks/useClickOutside.js";
|
|
10
|
+
import go from "../menuItems/MenuItems.js";
|
|
11
|
+
import wo from "../menuItems/MenuItemList.js";
|
|
12
|
+
import Co from "./DropdownToggleButton.js";
|
|
13
|
+
import bo from "./SplitCaretButton.js";
|
|
14
14
|
import Bo from "./Caret.js";
|
|
15
|
-
const Do = (r, s) => r && s ? "top-end" : !r && s ? "top-start" : r && !s ? "bottom-end" : "bottom-start", No = () =>
|
|
15
|
+
const Do = (r, s) => r && s ? "top-end" : !r && s ? "top-start" : r && !s ? "bottom-end" : "bottom-start", No = () => lo((r, s) => {
|
|
16
16
|
const {
|
|
17
17
|
id: g = Math.random().toString(36).slice(2, 16),
|
|
18
|
-
|
|
18
|
+
"aria-label": R,
|
|
19
|
+
items: T = [],
|
|
19
20
|
bsSize: w = "md",
|
|
20
21
|
bsStyle: C = "default",
|
|
21
|
-
variant:
|
|
22
|
-
disabled:
|
|
23
|
-
iconName:
|
|
24
|
-
iconOnly:
|
|
25
|
-
title:
|
|
26
|
-
splitButton:
|
|
27
|
-
customDropdown:
|
|
28
|
-
open:
|
|
29
|
-
dropup:
|
|
22
|
+
variant: k,
|
|
23
|
+
disabled: b = !1,
|
|
24
|
+
iconName: y,
|
|
25
|
+
iconOnly: B = !1,
|
|
26
|
+
title: E,
|
|
27
|
+
splitButton: e = !1,
|
|
28
|
+
customDropdown: D,
|
|
29
|
+
open: t,
|
|
30
|
+
dropup: L = !1,
|
|
30
31
|
pullRight: f = !1,
|
|
31
|
-
noCaret:
|
|
32
|
-
onOpen:
|
|
33
|
-
onClose:
|
|
34
|
-
onLabelButtonClick:
|
|
32
|
+
noCaret: x = !1,
|
|
33
|
+
onOpen: I = u,
|
|
34
|
+
onClose: j = u,
|
|
35
|
+
onLabelButtonClick: U = u,
|
|
35
36
|
usePortal: l = !1,
|
|
36
|
-
popperConfig:
|
|
37
|
-
toggleButtonType:
|
|
38
|
-
toggleClassName:
|
|
39
|
-
dropdownClassName:
|
|
40
|
-
className:
|
|
41
|
-
...
|
|
42
|
-
} = r, [
|
|
43
|
-
placement: Do(f,
|
|
37
|
+
popperConfig: _,
|
|
38
|
+
toggleButtonType: v = "button",
|
|
39
|
+
toggleClassName: N = "",
|
|
40
|
+
dropdownClassName: z,
|
|
41
|
+
className: A = "",
|
|
42
|
+
...F
|
|
43
|
+
} = r, [O, m] = c(t), [V, Y] = c(null), [S, q] = c(null), [G, H] = c(null), J = {
|
|
44
|
+
placement: Do(f, L),
|
|
44
45
|
modifiers: []
|
|
45
|
-
},
|
|
46
|
+
}, K = e && f ? G : V, { styles: Q, attributes: W } = io(K, S, _ || J), n = co(t), a = n ? O : t, X = mo(
|
|
46
47
|
(o) => {
|
|
47
|
-
l &&
|
|
48
|
+
l && S?.contains(o.target) || p();
|
|
48
49
|
},
|
|
49
|
-
|
|
50
|
-
!!
|
|
50
|
+
uo,
|
|
51
|
+
!!a
|
|
51
52
|
// only listen to clicks outside when the dropdown is open
|
|
52
|
-
),
|
|
53
|
-
|
|
54
|
-
n || m(
|
|
55
|
-
}, [n,
|
|
53
|
+
), Z = fo(), $ = !x && !e && !B;
|
|
54
|
+
ao(() => {
|
|
55
|
+
n || m(t);
|
|
56
|
+
}, [n, t]);
|
|
56
57
|
const d = (o) => {
|
|
57
|
-
(n ?
|
|
58
|
-
},
|
|
59
|
-
n && m(!0), o &&
|
|
60
|
-
},
|
|
61
|
-
n && m(!1),
|
|
62
|
-
},
|
|
63
|
-
|
|
58
|
+
(n ? O : t) ? p() : oo(o);
|
|
59
|
+
}, oo = (o) => {
|
|
60
|
+
n && m(!0), o && I(o);
|
|
61
|
+
}, p = () => {
|
|
62
|
+
n && m(!1), j();
|
|
63
|
+
}, eo = () => {
|
|
64
|
+
p(), U();
|
|
64
65
|
}, to = (o) => {
|
|
65
66
|
d(o);
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
},
|
|
67
|
+
}, no = (o) => {
|
|
68
|
+
e ? eo() : d(o);
|
|
69
|
+
}, ro = P("dropdown", "btn-group", a && "open", A), so = P(
|
|
69
70
|
l && "dropdown-portal",
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
e && f && "pull-right",
|
|
72
|
+
z
|
|
72
73
|
), M = /* @__PURE__ */ i(
|
|
73
|
-
|
|
74
|
+
wo,
|
|
74
75
|
{
|
|
75
|
-
className:
|
|
76
|
-
ref:
|
|
77
|
-
style:
|
|
78
|
-
...
|
|
79
|
-
children:
|
|
76
|
+
className: so,
|
|
77
|
+
ref: q,
|
|
78
|
+
style: Q.popper,
|
|
79
|
+
...W.popper,
|
|
80
|
+
children: D || /* @__PURE__ */ i(go, { items: T, closeMenu: d })
|
|
80
81
|
}
|
|
81
82
|
);
|
|
82
|
-
return /* @__PURE__ */ h("div", { ...
|
|
83
|
+
return /* @__PURE__ */ h("div", { ...F, className: ro, ref: X, children: [
|
|
83
84
|
/* @__PURE__ */ h(
|
|
84
|
-
|
|
85
|
+
Co,
|
|
85
86
|
{
|
|
86
87
|
id: g,
|
|
87
|
-
|
|
88
|
+
"aria-label": R,
|
|
89
|
+
splitButton: e,
|
|
88
90
|
bsStyle: C,
|
|
89
91
|
bsSize: w,
|
|
90
|
-
variant:
|
|
91
|
-
iconOnly:
|
|
92
|
-
iconName:
|
|
93
|
-
disabled:
|
|
94
|
-
ref:
|
|
95
|
-
onClick:
|
|
92
|
+
variant: k,
|
|
93
|
+
iconOnly: B,
|
|
94
|
+
iconName: y,
|
|
95
|
+
disabled: b,
|
|
96
|
+
ref: Y,
|
|
97
|
+
onClick: no,
|
|
96
98
|
outerRef: s,
|
|
97
|
-
toggleButtonType:
|
|
98
|
-
className:
|
|
99
|
+
toggleButtonType: v,
|
|
100
|
+
className: N,
|
|
99
101
|
children: [
|
|
100
|
-
|
|
101
|
-
|
|
102
|
+
E,
|
|
103
|
+
$ && /* @__PURE__ */ i(Bo, {})
|
|
102
104
|
]
|
|
103
105
|
}
|
|
104
106
|
),
|
|
105
|
-
|
|
106
|
-
|
|
107
|
+
e && /* @__PURE__ */ i(
|
|
108
|
+
bo,
|
|
107
109
|
{
|
|
108
110
|
id: g,
|
|
109
111
|
bsStyle: C,
|
|
110
112
|
bsSize: w,
|
|
111
|
-
disabled:
|
|
112
|
-
className:
|
|
113
|
+
disabled: b,
|
|
114
|
+
className: N,
|
|
113
115
|
onClick: to,
|
|
114
|
-
ref:
|
|
116
|
+
ref: H
|
|
115
117
|
}
|
|
116
118
|
),
|
|
117
|
-
|
|
118
|
-
|
|
119
|
+
a && l && po.createPortal(M, Z),
|
|
120
|
+
a && !l && M
|
|
119
121
|
] });
|
|
120
|
-
}),
|
|
122
|
+
}), _o = No();
|
|
121
123
|
export {
|
|
122
|
-
|
|
124
|
+
_o as default
|
|
123
125
|
};
|
|
124
126
|
//# sourceMappingURL=ButtonDropdown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonDropdown.js","sources":["../../../src/components/dropdown/ButtonDropdown.tsx"],"sourcesContent":["import React, { useState, useEffect, forwardRef, type PropsWithChildren } from 'react';\nimport ReactDOM from 'react-dom';\nimport { usePopper } from 'react-popper';\nimport { noop } from 'es-toolkit/function';\nimport { isNil } from 'es-toolkit/predicate';\n\nimport classNames from '../../utils/classNames';\nimport { getOrCreatePortalRoot } from '../../utils/portalRoot';\nimport useClickOutside, { DEFAULT_EVENT_TYPES } from '../../hooks/useClickOutside';\nimport MenuItems from '../menuItems/MenuItems';\nimport MenuItemList from '../menuItems/MenuItemList';\nimport DropdownToggleButton, { type DropdownToggleEvent, type DropdownToggleButtonType } from './DropdownToggleButton';\nimport SplitCaretButton from './SplitCaretButton';\nimport Caret from './Caret';\nimport type { MenuItemProps as MenuItem } from '../menuItems/MenuItem';\nimport type { BUTTON_SIZE, BUTTON_STYLE, BUTTON_VARIANT } from '../button/Button';\n\nconst getPlacement = (pullRight: boolean, dropup: boolean) => {\n if (pullRight && dropup) {\n return 'top-end';\n }\n if (!pullRight && dropup) {\n return 'top-start';\n }\n if (pullRight && !dropup) {\n return 'bottom-end';\n }\n return 'bottom-start';\n};\n\nexport type ButtonDropdownProps<T extends DropdownToggleButtonType = 'button'> = {\n /**\n * Unique button id. If not present a random id is generated.\n */\n id?: string;\n\n /**\n * The button title. This may be also a node, like a <span> or a <FormattedMessage>.\n */\n title: string | React.ReactNode;\n\n /**\n * Defined weather or not the menu is rendered.\n * Use this to control the component from the outside.\n *\n * @default undefined\n */\n open?: boolean;\n\n /**\n * Defines whether the dropdown opens above or below.\n * Set it to \"true\" additionally disables the automatic position feature.\n *\n * @default false\n */\n dropup?: boolean;\n\n /**\n * Defines whether the dropdown opens right aligned to the dropdown or not.\n */\n pullRight?: boolean;\n\n /**\n * Defines how large the button will be rendered.\n *\n * Possible values are: `xs`, `sm`, `md`, `lg`\n *\n * @default 'md'\n */\n bsSize?: BUTTON_SIZE;\n\n /**\n * Defines the button color.\n *\n * Possible values are: `default`, `primary`, `secondary`, `info`, `warning`, `danger`, `success`, `muted`\n *\n * @default 'default'\n */\n bsStyle?: BUTTON_STYLE;\n\n /**\n * Defines the variation of the button design.\n *\n * Possible values are: `link`, `link-inline`, `outline`, `action`\n */\n variant?: BUTTON_VARIANT;\n\n /**\n * Specify the toggle element type.\n * It supports the following types: \"button\" | \"tag\" | \"label\"\n *\n * @default 'button'\n */\n toggleButtonType?: DropdownToggleButtonType;\n\n /**\n * Optional prop to defines whether the dropdown title is icon only which\n * applies different padding so the button is a square.\n *\n * @default false\n */\n iconOnly?: boolean;\n\n /**\n * Optional rioglyph icon name forwarded to the underlying button toggle.\n */\n iconName?: string;\n\n /**\n * Defines whether the caret is shown or not.\n *\n * @default false\n */\n noCaret?: boolean;\n\n /**\n * Defines whether the dropdown-toggle (with caret) should be in a separate button.\n *\n * @default false\n */\n splitButton?: boolean;\n\n /**\n * Renders the dropdown into a dedicated react portal\n *\n * @default false\n */\n usePortal?: boolean;\n\n /**\n * Items to display in the dropdown menu. If you use a custom dropdown you can skip this prop.\n */\n items?: MenuItem[];\n\n /**\n * Disables the dropdown button.\n *\n * @default false\n */\n disabled?: boolean;\n\n /**\n * Callback for splitButton label button click.\n */\n onLabelButtonClick?: () => void;\n\n /**\n * Callback for when the toggle button was clicked to open it.\n * @param event\n * @returns\n */\n onOpen?: (event: DropdownToggleEvent<T>) => void;\n\n /**\n * Callback for when the toggle button was clicked to close it.\n * @returns\n */\n onClose?: () => void;\n\n /**\n * Allows to pass in custom dropdown menu content.\n */\n customDropdown?: React.ReactNode;\n\n /**\n * Define custom popper.js configuration for dropdown placement and modifiers.\n */\n popperConfig?: object;\n\n /**\n * Additional classes to be set on the dropdown-toggle button.\n */\n toggleClassName?: string;\n\n /**\n * Additional classes to be set on the dropdown.\n */\n dropdownClassName?: string;\n\n /**\n * Additional classes to be set to the wrapper element.\n */\n className?: string;\n};\n\nconst createButtonDropdown = <T extends DropdownToggleButtonType = 'button'>() => {\n return forwardRef<\n T extends 'button' ? HTMLButtonElement : HTMLDivElement,\n PropsWithChildren<ButtonDropdownProps<T>>\n >((props, ref) => {\n const {\n id = Math.random().toString(36).slice(2, 16),\n items = [],\n bsSize = 'md',\n bsStyle = 'default',\n variant,\n disabled = false,\n iconName,\n iconOnly = false,\n title,\n splitButton = false,\n customDropdown,\n open,\n dropup = false,\n pullRight = false,\n noCaret = false,\n onOpen = noop,\n onClose = noop,\n onLabelButtonClick = noop,\n usePortal = false,\n popperConfig,\n toggleButtonType = 'button',\n toggleClassName = '',\n dropdownClassName,\n className = '',\n ...remainingProps\n } = props;\n\n const [internalOpen, setInternalOpen] = useState(open);\n\n const [refDropdownToggle, setRefDropdownToggle] = useState<HTMLButtonElement | HTMLDivElement | null>(null);\n const [refDropdownMenu, setRefDropdownMenu] = useState<HTMLUListElement | null>(null);\n const [refSplitButtonToggle, setRefSplitButtonToggle] = useState<HTMLButtonElement | null>(null);\n\n const defaultPopperConfig = {\n placement: getPlacement(pullRight, dropup),\n modifiers: [],\n };\n\n const popperParentRef = splitButton && pullRight ? refSplitButtonToggle : refDropdownToggle;\n\n const { styles, attributes } = usePopper(popperParentRef, refDropdownMenu, popperConfig || defaultPopperConfig);\n\n const isUncontrolled = isNil(open);\n const isOpen = isUncontrolled ? internalOpen : open;\n\n const wrapperRef = useClickOutside(\n event => {\n if (usePortal) {\n // In case the dropdown is rendered via portal the clickOutside the toggle button element is\n // triggered since the dropdown is not a child of the wrapper element.\n // In this case we need to check if the event target is inside the dropdown-menu and prevent closing\n // the dropdown\n if (!refDropdownMenu?.contains(event.target as Node)) {\n closeMenu();\n }\n } else {\n closeMenu();\n }\n },\n DEFAULT_EVENT_TYPES,\n Boolean(isOpen) // only listen to clicks outside when the dropdown is open\n );\n\n const dropdownRoot = getOrCreatePortalRoot();\n\n const shouldShowCaret = !noCaret && !splitButton && !iconOnly;\n\n useEffect(() => {\n if (!isUncontrolled) {\n setInternalOpen(open);\n }\n }, [isUncontrolled, open]);\n\n const toggleOpen = (event?: DropdownToggleEvent<T>) => {\n const isDropdownOpen = isUncontrolled ? internalOpen : open;\n\n if (isDropdownOpen) {\n closeMenu();\n } else {\n openMenu(event);\n }\n };\n\n const openMenu = (event?: DropdownToggleEvent<T>) => {\n if (isUncontrolled) {\n setInternalOpen(true);\n }\n if (event) {\n onOpen(event);\n }\n };\n\n const closeMenu = () => {\n if (isUncontrolled) {\n setInternalOpen(false);\n }\n onClose();\n };\n\n const handleSplitLabelButtonClick = () => {\n closeMenu();\n onLabelButtonClick();\n };\n\n const handleSplitCaretButtonClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n toggleOpen(event as DropdownToggleEvent<T>);\n };\n\n const handleDropdownButtonClick = (event: React.MouseEvent<HTMLButtonElement | HTMLDivElement>) => {\n if (splitButton) {\n handleSplitLabelButtonClick();\n } else {\n toggleOpen(event as DropdownToggleEvent<T>);\n }\n };\n\n const wrapperClasses = classNames('dropdown', 'btn-group', isOpen && 'open', className);\n\n const dropdownClasses = classNames(\n usePortal && 'dropdown-portal',\n splitButton && pullRight && 'pull-right',\n dropdownClassName\n );\n\n const dropdownMenu = (\n <MenuItemList\n className={dropdownClasses}\n ref={setRefDropdownMenu}\n style={styles.popper}\n {...attributes.popper}\n >\n {customDropdown ? customDropdown : <MenuItems items={items} closeMenu={toggleOpen} />}\n </MenuItemList>\n );\n\n return (\n <div {...remainingProps} className={wrapperClasses} ref={wrapperRef}>\n <DropdownToggleButton\n id={id}\n splitButton={splitButton}\n bsStyle={bsStyle}\n bsSize={bsSize}\n variant={variant}\n iconOnly={iconOnly}\n iconName={iconName}\n disabled={disabled}\n ref={setRefDropdownToggle}\n onClick={handleDropdownButtonClick}\n outerRef={ref}\n toggleButtonType={toggleButtonType}\n className={toggleClassName}\n >\n {title}\n {shouldShowCaret && <Caret />}\n </DropdownToggleButton>\n {splitButton && (\n <SplitCaretButton\n id={id}\n bsStyle={bsStyle}\n bsSize={bsSize}\n disabled={disabled}\n className={toggleClassName}\n onClick={handleSplitCaretButtonClick}\n ref={setRefSplitButtonToggle}\n />\n )}\n {isOpen && usePortal && ReactDOM.createPortal(dropdownMenu, dropdownRoot)}\n {isOpen && !usePortal && dropdownMenu}\n </div>\n );\n });\n};\n\nconst ButtonDropdown = createButtonDropdown();\n\nexport default ButtonDropdown;\n"],"names":["getPlacement","pullRight","dropup","createButtonDropdown","forwardRef","props","ref","id","items","bsSize","bsStyle","variant","disabled","iconName","iconOnly","title","splitButton","customDropdown","open","noCaret","onOpen","noop","onClose","onLabelButtonClick","usePortal","popperConfig","toggleButtonType","toggleClassName","dropdownClassName","className","remainingProps","internalOpen","setInternalOpen","useState","refDropdownToggle","setRefDropdownToggle","refDropdownMenu","setRefDropdownMenu","refSplitButtonToggle","setRefSplitButtonToggle","defaultPopperConfig","popperParentRef","styles","attributes","usePopper","isUncontrolled","isNil","isOpen","wrapperRef","useClickOutside","event","closeMenu","DEFAULT_EVENT_TYPES","dropdownRoot","getOrCreatePortalRoot","shouldShowCaret","useEffect","toggleOpen","openMenu","handleSplitLabelButtonClick","handleSplitCaretButtonClick","handleDropdownButtonClick","wrapperClasses","classNames","dropdownClasses","dropdownMenu","jsx","MenuItemList","MenuItems","jsxs","DropdownToggleButton","Caret","SplitCaretButton","ReactDOM","ButtonDropdown"],"mappings":";;;;;;;;;;;;;;AAiBA,MAAMA,KAAe,CAACC,GAAoBC,MAClCD,KAAaC,IACN,YAEP,CAACD,KAAaC,IACP,cAEPD,KAAa,CAACC,IACP,eAEJ,gBA8JLC,KAAuB,MAClBC,GAGL,CAACC,GAAOC,MAAQ;AACd,QAAM;AAAA,IACF,IAAAC,IAAK,KAAK,SAAS,SAAS,EAAE,EAAE,MAAM,GAAG,EAAE;AAAA,IAC3C,OAAAC,IAAQ,CAAA;AAAA,IACR,QAAAC,IAAS;AAAA,IACT,SAAAC,IAAU;AAAA,IACV,SAAAC;AAAA,IACA,UAAAC,IAAW;AAAA,IACX,UAAAC;AAAA,IACA,UAAAC,IAAW;AAAA,IACX,OAAA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AAA,QACA,WAAWC;AAAA,QAEV,UAAA;AAAA,UAAAZ;AAAA,UACAwC,uBAAoBgB,IAAA,CAAA,CAAM;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,IAE9BvD,KACG,gBAAAkD;AAAA,MAACM;AAAA,MAAA;AAAA,QACG,IAAAjE;AAAA,QACA,SAAAG;AAAA,QACA,QAAAD;AAAA,QACA,UAAAG;AAAA,QACA,WAAWe;AAAA,QACX,SAASiC;AAAA,QACT,KAAKrB;AAAA,MAAA;AAAA,IAAA;AAAA,IAGZQ,KAAUvB,KAAaiD,GAAS,aAAaR,GAAcZ,CAAY;AAAA,IACvEN,KAAU,CAACvB,KAAayC;AAAA,EAAA,GAC7B;AAER,CAAC,GAGCS,KAAiBvE,GAAA;"}
|
|
1
|
+
{"version":3,"file":"ButtonDropdown.js","sources":["../../../src/components/dropdown/ButtonDropdown.tsx"],"sourcesContent":["import React, { useState, useEffect, forwardRef, type PropsWithChildren } from 'react';\nimport ReactDOM from 'react-dom';\nimport { usePopper } from 'react-popper';\nimport { noop } from 'es-toolkit/function';\nimport { isNil } from 'es-toolkit/predicate';\n\nimport classNames from '../../utils/classNames';\nimport { getOrCreatePortalRoot } from '../../utils/portalRoot';\nimport useClickOutside, { DEFAULT_EVENT_TYPES } from '../../hooks/useClickOutside';\nimport MenuItems from '../menuItems/MenuItems';\nimport MenuItemList from '../menuItems/MenuItemList';\nimport DropdownToggleButton, { type DropdownToggleEvent, type DropdownToggleButtonType } from './DropdownToggleButton';\nimport SplitCaretButton from './SplitCaretButton';\nimport Caret from './Caret';\nimport type { MenuItemProps as MenuItem } from '../menuItems/MenuItem';\nimport type { BUTTON_SIZE, BUTTON_STYLE, BUTTON_VARIANT } from '../button/Button';\n\nconst getPlacement = (pullRight: boolean, dropup: boolean) => {\n if (pullRight && dropup) {\n return 'top-end';\n }\n if (!pullRight && dropup) {\n return 'top-start';\n }\n if (pullRight && !dropup) {\n return 'bottom-end';\n }\n return 'bottom-start';\n};\n\nexport type ButtonDropdownProps<T extends DropdownToggleButtonType = 'button'> = {\n /**\n * Unique button id. If not present a random id is generated.\n */\n id?: string;\n\n /**\n * Accessible label applied to the dropdown toggle button.\n */\n 'aria-label'?: string;\n\n /**\n * The button title. This may be also a node, like a <span> or a <FormattedMessage>.\n */\n title: string | React.ReactNode;\n\n /**\n * Defined weather or not the menu is rendered.\n * Use this to control the component from the outside.\n *\n * @default undefined\n */\n open?: boolean;\n\n /**\n * Defines whether the dropdown opens above or below.\n * Set it to \"true\" additionally disables the automatic position feature.\n *\n * @default false\n */\n dropup?: boolean;\n\n /**\n * Defines whether the dropdown opens right aligned to the dropdown or not.\n */\n pullRight?: boolean;\n\n /**\n * Defines how large the button will be rendered.\n *\n * Possible values are: `xs`, `sm`, `md`, `lg`\n *\n * @default 'md'\n */\n bsSize?: BUTTON_SIZE;\n\n /**\n * Defines the button color.\n *\n * Possible values are: `default`, `primary`, `secondary`, `info`, `warning`, `danger`, `success`, `muted`\n *\n * @default 'default'\n */\n bsStyle?: BUTTON_STYLE;\n\n /**\n * Defines the variation of the button design.\n *\n * Possible values are: `link`, `link-inline`, `outline`, `action`\n */\n variant?: BUTTON_VARIANT;\n\n /**\n * Specify the toggle element type.\n * It supports the following types: \"button\" | \"tag\" | \"label\"\n *\n * @default 'button'\n */\n toggleButtonType?: DropdownToggleButtonType;\n\n /**\n * Optional prop to defines whether the dropdown title is icon only which\n * applies different padding so the button is a square.\n *\n * @default false\n */\n iconOnly?: boolean;\n\n /**\n * Optional rioglyph icon name forwarded to the underlying button toggle.\n */\n iconName?: string;\n\n /**\n * Defines whether the caret is shown or not.\n *\n * @default false\n */\n noCaret?: boolean;\n\n /**\n * Defines whether the dropdown-toggle (with caret) should be in a separate button.\n *\n * @default false\n */\n splitButton?: boolean;\n\n /**\n * Renders the dropdown into a dedicated react portal\n *\n * @default false\n */\n usePortal?: boolean;\n\n /**\n * Items to display in the dropdown menu. If you use a custom dropdown you can skip this prop.\n */\n items?: MenuItem[];\n\n /**\n * Disables the dropdown button.\n *\n * @default false\n */\n disabled?: boolean;\n\n /**\n * Callback for splitButton label button click.\n */\n onLabelButtonClick?: () => void;\n\n /**\n * Callback for when the toggle button was clicked to open it.\n * @param event\n * @returns\n */\n onOpen?: (event: DropdownToggleEvent<T>) => void;\n\n /**\n * Callback for when the toggle button was clicked to close it.\n * @returns\n */\n onClose?: () => void;\n\n /**\n * Allows to pass in custom dropdown menu content.\n */\n customDropdown?: React.ReactNode;\n\n /**\n * Define custom popper.js configuration for dropdown placement and modifiers.\n */\n popperConfig?: object;\n\n /**\n * Additional classes to be set on the dropdown-toggle button.\n */\n toggleClassName?: string;\n\n /**\n * Additional classes to be set on the dropdown.\n */\n dropdownClassName?: string;\n\n /**\n * Additional classes to be set to the wrapper element.\n */\n className?: string;\n};\n\nconst createButtonDropdown = <T extends DropdownToggleButtonType = 'button'>() => {\n return forwardRef<\n T extends 'button' ? HTMLButtonElement : HTMLDivElement,\n PropsWithChildren<ButtonDropdownProps<T>>\n >((props, ref) => {\n const {\n id = Math.random().toString(36).slice(2, 16),\n 'aria-label': ariaLabel,\n items = [],\n bsSize = 'md',\n bsStyle = 'default',\n variant,\n disabled = false,\n iconName,\n iconOnly = false,\n title,\n splitButton = false,\n customDropdown,\n open,\n dropup = false,\n pullRight = false,\n noCaret = false,\n onOpen = noop,\n onClose = noop,\n onLabelButtonClick = noop,\n usePortal = false,\n popperConfig,\n toggleButtonType = 'button',\n toggleClassName = '',\n dropdownClassName,\n className = '',\n ...remainingProps\n } = props;\n\n const [internalOpen, setInternalOpen] = useState(open);\n\n const [refDropdownToggle, setRefDropdownToggle] = useState<HTMLButtonElement | HTMLDivElement | null>(null);\n const [refDropdownMenu, setRefDropdownMenu] = useState<HTMLUListElement | null>(null);\n const [refSplitButtonToggle, setRefSplitButtonToggle] = useState<HTMLButtonElement | null>(null);\n\n const defaultPopperConfig = {\n placement: getPlacement(pullRight, dropup),\n modifiers: [],\n };\n\n const popperParentRef = splitButton && pullRight ? refSplitButtonToggle : refDropdownToggle;\n\n const { styles, attributes } = usePopper(popperParentRef, refDropdownMenu, popperConfig || defaultPopperConfig);\n\n const isUncontrolled = isNil(open);\n const isOpen = isUncontrolled ? internalOpen : open;\n\n const wrapperRef = useClickOutside(\n event => {\n if (usePortal) {\n // In case the dropdown is rendered via portal the clickOutside the toggle button element is\n // triggered since the dropdown is not a child of the wrapper element.\n // In this case we need to check if the event target is inside the dropdown-menu and prevent closing\n // the dropdown\n if (!refDropdownMenu?.contains(event.target as Node)) {\n closeMenu();\n }\n } else {\n closeMenu();\n }\n },\n DEFAULT_EVENT_TYPES,\n Boolean(isOpen) // only listen to clicks outside when the dropdown is open\n );\n\n const dropdownRoot = getOrCreatePortalRoot();\n\n const shouldShowCaret = !noCaret && !splitButton && !iconOnly;\n\n useEffect(() => {\n if (!isUncontrolled) {\n setInternalOpen(open);\n }\n }, [isUncontrolled, open]);\n\n const toggleOpen = (event?: DropdownToggleEvent<T>) => {\n const isDropdownOpen = isUncontrolled ? internalOpen : open;\n\n if (isDropdownOpen) {\n closeMenu();\n } else {\n openMenu(event);\n }\n };\n\n const openMenu = (event?: DropdownToggleEvent<T>) => {\n if (isUncontrolled) {\n setInternalOpen(true);\n }\n if (event) {\n onOpen(event);\n }\n };\n\n const closeMenu = () => {\n if (isUncontrolled) {\n setInternalOpen(false);\n }\n onClose();\n };\n\n const handleSplitLabelButtonClick = () => {\n closeMenu();\n onLabelButtonClick();\n };\n\n const handleSplitCaretButtonClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n toggleOpen(event as DropdownToggleEvent<T>);\n };\n\n const handleDropdownButtonClick = (event: React.MouseEvent<HTMLButtonElement | HTMLDivElement>) => {\n if (splitButton) {\n handleSplitLabelButtonClick();\n } else {\n toggleOpen(event as DropdownToggleEvent<T>);\n }\n };\n\n const wrapperClasses = classNames('dropdown', 'btn-group', isOpen && 'open', className);\n\n const dropdownClasses = classNames(\n usePortal && 'dropdown-portal',\n splitButton && pullRight && 'pull-right',\n dropdownClassName\n );\n\n const dropdownMenu = (\n <MenuItemList\n className={dropdownClasses}\n ref={setRefDropdownMenu}\n style={styles.popper}\n {...attributes.popper}\n >\n {customDropdown ? customDropdown : <MenuItems items={items} closeMenu={toggleOpen} />}\n </MenuItemList>\n );\n\n return (\n <div {...remainingProps} className={wrapperClasses} ref={wrapperRef}>\n <DropdownToggleButton\n id={id}\n aria-label={ariaLabel}\n splitButton={splitButton}\n bsStyle={bsStyle}\n bsSize={bsSize}\n variant={variant}\n iconOnly={iconOnly}\n iconName={iconName}\n disabled={disabled}\n ref={setRefDropdownToggle}\n onClick={handleDropdownButtonClick}\n outerRef={ref}\n toggleButtonType={toggleButtonType}\n className={toggleClassName}\n >\n {title}\n {shouldShowCaret && <Caret />}\n </DropdownToggleButton>\n {splitButton && (\n <SplitCaretButton\n id={id}\n bsStyle={bsStyle}\n bsSize={bsSize}\n disabled={disabled}\n className={toggleClassName}\n onClick={handleSplitCaretButtonClick}\n ref={setRefSplitButtonToggle}\n />\n )}\n {isOpen && usePortal && ReactDOM.createPortal(dropdownMenu, dropdownRoot)}\n {isOpen && !usePortal && dropdownMenu}\n </div>\n );\n });\n};\n\nconst ButtonDropdown = createButtonDropdown();\n\nexport default ButtonDropdown;\n"],"names":["getPlacement","pullRight","dropup","createButtonDropdown","forwardRef","props","ref","id","ariaLabel","items","bsSize","bsStyle","variant","disabled","iconName","iconOnly","title","splitButton","customDropdown","open","noCaret","onOpen","noop","onClose","onLabelButtonClick","usePortal","popperConfig","toggleButtonType","toggleClassName","dropdownClassName","className","remainingProps","internalOpen","setInternalOpen","useState","refDropdownToggle","setRefDropdownToggle","refDropdownMenu","setRefDropdownMenu","refSplitButtonToggle","setRefSplitButtonToggle","defaultPopperConfig","popperParentRef","styles","attributes","usePopper","isUncontrolled","isNil","isOpen","wrapperRef","useClickOutside","event","closeMenu","DEFAULT_EVENT_TYPES","dropdownRoot","getOrCreatePortalRoot","shouldShowCaret","useEffect","toggleOpen","openMenu","handleSplitLabelButtonClick","handleSplitCaretButtonClick","handleDropdownButtonClick","wrapperClasses","classNames","dropdownClasses","dropdownMenu","jsx","MenuItemList","MenuItems","jsxs","DropdownToggleButton","Caret","SplitCaretButton","ReactDOM","ButtonDropdown"],"mappings":";;;;;;;;;;;;;;AAiBA,MAAMA,KAAe,CAACC,GAAoBC,MAClCD,KAAaC,IACN,YAEP,CAACD,KAAaC,IACP,cAEPD,KAAa,CAACC,IACP,eAEJ,gBAmKLC,KAAuB,MAClBC,GAGL,CAACC,GAAOC,MAAQ;AACd,QAAM;AAAA,IACF,IAAAC,IAAK,KAAK,SAAS,SAAS,EAAE,EAAE,MAAM,GAAG,EAAE;AAAA,IAC3C,cAAcC;AAAA,IACd,OAAAC,IAAQ,CAAA;AAAA,IACR,QAAAC,IAAS;AAAA,IACT,SAAAC,IAAU;AAAA,IACV,SAAAC;AAAA,IACA,UAAAC,IAAW;AAAA,IACX,UAAAC;AAAA,IACA,UAAAC,IAAW;AAAA,IACX,OAAAC;AAAA,IACA,aAAAC,IAAc;AAAA,IACd,gBAAAC;AAAA,IACA,MAAAC;AAAA,IACA,QAAAjB,IAAS;AAAA,IACT,WAAAD,IAAY;AAAA,IACZ,SAAAmB,IAAU;AAAA,IACV,QAAAC,IAASC;AAAA,IACT,SAAAC,IAAUD;AAAA,IACV,oBAAAE,IAAqBF;AAAA,IACrB,WAAAG,IAAY;AAAA,IACZ,cAAAC;AAAA,IACA,kBAAAC,IAAmB;AAAA,IACnB,iBAAAC,IAAkB;AAAA,IAClB,mBAAAC;AAAA,IACA,WAAAC,IAAY;AAAA,IACZ,GAAGC;AAAA,EAAA,IACH1B,GAEE,CAAC2B,GAAcC,CAAe,IAAIC,EAASf,CAAI,GAE/C,CAACgB,GAAmBC,CAAoB,IAAIF,EAAoD,IAAI,GACpG,CAACG,GAAiBC,CAAkB,IAAIJ,EAAkC,IAAI,GAC9E,CAACK,GAAsBC,CAAuB,IAAIN,EAAmC,IAAI,GAEzFO,IAAs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enuGroup';
|
|
3
3
|
export type { ListMenuNavItem, ListMenuItem } from './ListMenuGroup';
|
|
4
|
+
type ListMenuFilterFn<T extends ListMenuNavItem> = (items: ListMenuItem<T>[], value: string, filterKey: keyof T) => ListMenuItem<T>[];
|
|
4
5
|
export type ListMenuProps<T extends ListMenuNavItem> = {
|
|
5
6
|
/**
|
|
6
7
|
* List of menu item groups to be shown.
|
|
@@ -68,6 +69,13 @@ export type ListMenuProps<T extends ListMenuNavItem> = {
|
|
|
68
69
|
* Additional classes to be set on the wrapper element.
|
|
69
70
|
*/
|
|
70
71
|
className?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Optional custom filter function.
|
|
74
|
+
*
|
|
75
|
+
* Use this when filtering should do more than a simple substring match,
|
|
76
|
+
* for example fuzzy ranking or multi-field weighting.
|
|
77
|
+
*/
|
|
78
|
+
filterFn?: ListMenuFilterFn<T>;
|
|
71
79
|
};
|
|
72
80
|
declare const ListMenu: <T extends ListMenuNavItem>(props: ListMenuProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
73
81
|
export default ListMenu;
|
|
@@ -1,68 +1,76 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { isEmpty as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import X from "../../hooks/
|
|
11
|
-
import Z from "../../hooks/
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { jsxs as f, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useState as l, useRef as x, useEffect as v } from "react";
|
|
3
|
+
import { isEmpty as j } from "es-toolkit/compat";
|
|
4
|
+
import A from "../../utils/classNames.js";
|
|
5
|
+
import D from "../../hooks/useEffectOnce.js";
|
|
6
|
+
import G from "../../hooks/useSearchHighlight.js";
|
|
7
|
+
import V from "../clearableInput/ClearableInput.js";
|
|
8
|
+
import $ from "../expander/ExpanderPanel.js";
|
|
9
|
+
import q from "./ListMenuGroup.js";
|
|
10
|
+
import X from "../../hooks/useEsc.js";
|
|
11
|
+
import Z from "../../hooks/useWindowResize.js";
|
|
12
|
+
import J from "../../hooks/useKey.js";
|
|
13
|
+
import { debounce as Q } from "es-toolkit/function";
|
|
14
|
+
const U = 10, Y = 580, ee = (r, s, o) => r.map((n) => ({
|
|
15
|
+
...n,
|
|
16
|
+
navItems: n.navItems.filter(
|
|
17
|
+
(c) => c[o].toLowerCase().includes(s.toLowerCase())
|
|
17
18
|
)
|
|
18
|
-
})),
|
|
19
|
+
})), te = (r) => r.find(({ navItems: s }) => !j(s)), he = (r) => {
|
|
19
20
|
const {
|
|
20
21
|
menuItems: s,
|
|
21
|
-
focusFilter:
|
|
22
|
-
enableFilter:
|
|
23
|
-
filterPlaceholder:
|
|
24
|
-
onFilterChange:
|
|
22
|
+
focusFilter: o = !1,
|
|
23
|
+
enableFilter: n = !1,
|
|
24
|
+
filterPlaceholder: c,
|
|
25
|
+
onFilterChange: h = () => {
|
|
25
26
|
},
|
|
26
27
|
notFoundMessage: L,
|
|
27
28
|
className: w = "",
|
|
28
|
-
groupClassName:
|
|
29
|
-
responsive:
|
|
30
|
-
autoClose:
|
|
31
|
-
filterKey:
|
|
32
|
-
trailingInputAddon:
|
|
29
|
+
groupClassName: F = "",
|
|
30
|
+
responsive: g = !0,
|
|
31
|
+
autoClose: k = !0,
|
|
32
|
+
filterKey: H = "key",
|
|
33
|
+
trailingInputAddon: y,
|
|
34
|
+
filterFn: O,
|
|
33
35
|
...R
|
|
34
|
-
} =
|
|
35
|
-
if (
|
|
36
|
-
const [e] =
|
|
37
|
-
|
|
38
|
-
/* @__PURE__ */
|
|
36
|
+
} = r, [i, M] = l(""), [T, S] = l(!1), [N, E] = l(!1), [K, z] = l(""), m = x(null), a = x(null), I = () => {
|
|
37
|
+
if (g && a.current) {
|
|
38
|
+
const [e] = a.current.getElementsByClassName("active");
|
|
39
|
+
z(
|
|
40
|
+
/* @__PURE__ */ f("div", { className: "display-flex align-items-center", children: [
|
|
39
41
|
/* @__PURE__ */ t("span", { className: "rioglyph rioglyph-menu-hamburger margin-right-10" }),
|
|
40
42
|
/* @__PURE__ */ t("span", { children: e?.innerText })
|
|
41
43
|
] })
|
|
42
44
|
);
|
|
43
45
|
}
|
|
44
46
|
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
X(() => {
|
|
48
|
+
n && m.current === document.activeElement && (M(""), h(""));
|
|
47
49
|
});
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
},
|
|
51
|
-
|
|
50
|
+
const C = Q(() => {
|
|
51
|
+
I(), S(window.innerWidth < Y);
|
|
52
|
+
}, U);
|
|
53
|
+
v(C, []), Z(C);
|
|
52
54
|
const d = () => {
|
|
53
|
-
|
|
55
|
+
m.current?.focus();
|
|
54
56
|
};
|
|
55
|
-
|
|
57
|
+
J((e) => {
|
|
56
58
|
(e.metaKey || e.ctrlKey) && e.key === "k" && (e.preventDefault(), d());
|
|
57
|
-
}),
|
|
58
|
-
|
|
59
|
-
}),
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
}), D(() => {
|
|
60
|
+
o && d();
|
|
61
|
+
}), v(I, [s]);
|
|
62
|
+
const B = () => o && d(), P = (e) => {
|
|
63
|
+
M(e), h(e);
|
|
64
|
+
}, p = n ? (O ?? ee)(s, i, H) : s;
|
|
65
|
+
G({
|
|
66
|
+
ref: a,
|
|
67
|
+
query: n ? i : "",
|
|
68
|
+
deps: [p]
|
|
69
|
+
});
|
|
70
|
+
const W = (e) => {
|
|
71
|
+
const u = e.target.parentElement?.tagName.toLowerCase() === "li";
|
|
72
|
+
k && u && E(!1);
|
|
73
|
+
}, _ = A(
|
|
66
74
|
"form-group",
|
|
67
75
|
"margin-bottom-5",
|
|
68
76
|
"padding-left-15",
|
|
@@ -71,38 +79,38 @@ const J = 10, Q = 580, U = (n, s, r) => n.map((o) => ({
|
|
|
71
79
|
"position-sticky",
|
|
72
80
|
"top-0",
|
|
73
81
|
"z-index-1"
|
|
74
|
-
),
|
|
75
|
-
|
|
82
|
+
), b = /* @__PURE__ */ f("div", { ...R, className: `ListMenu ${w} ${i ? "filtered" : ""}`, ref: a, children: [
|
|
83
|
+
n && /* @__PURE__ */ t("div", { className: _, children: /* @__PURE__ */ f("div", { className: "input-group width-100pct", children: [
|
|
76
84
|
/* @__PURE__ */ t("span", { className: "input-group-addon", children: /* @__PURE__ */ t("span", { className: "rioglyph rioglyph-search", "aria-hidden": "true" }) }),
|
|
77
85
|
/* @__PURE__ */ t(
|
|
78
|
-
|
|
86
|
+
V,
|
|
79
87
|
{
|
|
80
|
-
value:
|
|
81
|
-
inputRef:
|
|
82
|
-
placeholder:
|
|
83
|
-
onChange:
|
|
84
|
-
onClear:
|
|
88
|
+
value: i,
|
|
89
|
+
inputRef: m,
|
|
90
|
+
placeholder: c,
|
|
91
|
+
onChange: P,
|
|
92
|
+
onClear: B
|
|
85
93
|
}
|
|
86
94
|
),
|
|
87
|
-
|
|
95
|
+
y && y
|
|
88
96
|
] }) }),
|
|
89
|
-
!
|
|
90
|
-
|
|
97
|
+
!te(p) && /* @__PURE__ */ t("div", { className: "padding-top-25 text-center text-color-gray", children: L }),
|
|
98
|
+
p.map((e, u) => /* @__PURE__ */ t(q, { className: F, menuGroup: e }, u))
|
|
91
99
|
] });
|
|
92
|
-
return
|
|
93
|
-
|
|
100
|
+
return g && T ? /* @__PURE__ */ t(
|
|
101
|
+
$,
|
|
94
102
|
{
|
|
95
103
|
title: K,
|
|
96
104
|
bsStyle: "default",
|
|
97
|
-
open:
|
|
98
|
-
onToggle: () =>
|
|
105
|
+
open: N,
|
|
106
|
+
onToggle: () => E(!N),
|
|
99
107
|
unmountOnExit: !1,
|
|
100
108
|
className: "shadow-default",
|
|
101
|
-
children: /* @__PURE__ */ t("div", { onClick:
|
|
109
|
+
children: /* @__PURE__ */ t("div", { onClick: W, children: b })
|
|
102
110
|
}
|
|
103
|
-
) :
|
|
111
|
+
) : b;
|
|
104
112
|
};
|
|
105
113
|
export {
|
|
106
|
-
|
|
114
|
+
he as default
|
|
107
115
|
};
|
|
108
116
|
//# sourceMappingURL=ListMenu.js.map
|