@mittwald/flow-react-components 1.3.0-next.24 → 1.3.0-next.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/component-index.json +1 -1
- package/dist/assets/doc-properties.json +1 -1
- package/dist/js/packages/components/src/components/CopyButton/CopyButton.mjs +4 -3
- package/dist/js/packages/components/src/components/CopyButton/CopyButton.mjs.map +1 -1
- package/dist/js/packages/components/src/components/List/components/Items/Items.mjs +3 -6
- package/dist/js/packages/components/src/components/List/components/Items/Items.mjs.map +1 -1
- package/dist/js/packages/components/src/components/List/components/Table/Table.mjs +6 -2
- package/dist/js/packages/components/src/components/List/components/Table/Table.mjs.map +1 -1
- package/dist/js/packages/components/src/components/List/{components/Items/hooks → hooks}/useInfiniteScrollTrigger.mjs +11 -12
- package/dist/js/packages/components/src/components/List/hooks/useInfiniteScrollTrigger.mjs.map +1 -0
- package/dist/types/components/CopyButton/CopyButton.d.ts +5 -0
- package/dist/types/components/List/hooks/useInfiniteScrollTrigger.d.ts +17 -0
- package/package.json +9 -9
- package/dist/js/packages/components/src/components/List/components/Items/hooks/useInfiniteScrollTrigger.mjs.map +0 -1
- package/dist/types/components/List/components/Items/hooks/useInfiniteScrollTrigger.d.ts +0 -3
|
@@ -14,10 +14,11 @@ import { onlyText } from "react-children-utilities";
|
|
|
14
14
|
//#region src/components/CopyButton/CopyButton.tsx
|
|
15
15
|
/** @flr-generate all */
|
|
16
16
|
var CopyButton = flowComponent("CopyButton", (props) => {
|
|
17
|
-
const { text = "", ref, variant = "plain", color = "secondary", ...buttonProps } = props;
|
|
17
|
+
const { text = "", ref, variant = "plain", color = "secondary", onCopy, ...buttonProps } = props;
|
|
18
18
|
const tooltip = useLocalizedStringFormatter(__locale_default, "CopyButton").format("copy");
|
|
19
|
-
const copyValue = () => {
|
|
20
|
-
|
|
19
|
+
const copyValue = async () => {
|
|
20
|
+
const copiedText = onlyText(text);
|
|
21
|
+
if (await copy(copiedText)) onCopy?.(copiedText);
|
|
21
22
|
};
|
|
22
23
|
return /* @__PURE__ */ jsxs(TooltipTrigger, { children: [/* @__PURE__ */ jsx(Action, {
|
|
23
24
|
onAction: copyValue,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopyButton.mjs","names":[],"sources":["../../../../../../../src/components/CopyButton/CopyButton.tsx"],"sourcesContent":["import copy from \"copy-to-clipboard\";\nimport type { ButtonProps } from \"@/components/Button\";\nimport { Button } from \"@/components/Button\";\nimport { IconCopy } from \"@/components/Icon/components/icons\";\nimport locales from \"./locales/*.locale.json\";\nimport { useLocalizedStringFormatter } from \"@/components/TranslationProvider/useLocalizedStringFormatter\";\nimport { Tooltip, TooltipTrigger } from \"@/components/Tooltip\";\nimport { onlyText } from \"react-children-utilities\";\nimport type { FlowComponentProps } from \"@/lib/componentFactory/flowComponent\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport { Action } from \"@/components/Action\";\n\nexport interface CopyButtonProps\n extends\n Omit<ButtonProps, \"onPress\" | \"aria-label\" | \"render\">,\n FlowComponentProps<HTMLButtonElement> {\n /** The text to copy. */\n text?: string;\n}\n\n/** @flr-generate all */\nexport const CopyButton = flowComponent(\"CopyButton\", (props) => {\n const {\n text = \"\",\n ref,\n variant = \"plain\",\n color = \"secondary\",\n ...buttonProps\n } = props;\n\n const stringFormatter = useLocalizedStringFormatter(locales, \"CopyButton\");\n\n const tooltip = stringFormatter.format(\"copy\");\n\n const copyValue = () => {\n
|
|
1
|
+
{"version":3,"file":"CopyButton.mjs","names":[],"sources":["../../../../../../../src/components/CopyButton/CopyButton.tsx"],"sourcesContent":["import copy from \"copy-to-clipboard\";\nimport type { ButtonProps } from \"@/components/Button\";\nimport { Button } from \"@/components/Button\";\nimport { IconCopy } from \"@/components/Icon/components/icons\";\nimport locales from \"./locales/*.locale.json\";\nimport { useLocalizedStringFormatter } from \"@/components/TranslationProvider/useLocalizedStringFormatter\";\nimport { Tooltip, TooltipTrigger } from \"@/components/Tooltip\";\nimport { onlyText } from \"react-children-utilities\";\nimport type { FlowComponentProps } from \"@/lib/componentFactory/flowComponent\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport { Action } from \"@/components/Action\";\n\nexport interface CopyButtonProps\n extends\n Omit<ButtonProps, \"onPress\" | \"aria-label\" | \"render\">,\n FlowComponentProps<HTMLButtonElement> {\n /** The text to copy. */\n text?: string;\n /**\n * Called with the copied text once it has been written to the clipboard. Not\n * called when copying fails.\n */\n onCopy?: (text: string) => void;\n}\n\n/** @flr-generate all */\nexport const CopyButton = flowComponent(\"CopyButton\", (props) => {\n const {\n text = \"\",\n ref,\n variant = \"plain\",\n color = \"secondary\",\n onCopy,\n ...buttonProps\n } = props;\n\n const stringFormatter = useLocalizedStringFormatter(locales, \"CopyButton\");\n\n const tooltip = stringFormatter.format(\"copy\");\n\n const copyValue = async () => {\n const copiedText = onlyText(text);\n if (await copy(copiedText)) {\n onCopy?.(copiedText);\n }\n };\n\n return (\n <TooltipTrigger>\n <Action onAction={copyValue} showFeedback>\n <Button\n aria-label={tooltip}\n {...buttonProps}\n ref={ref}\n variant={variant}\n color={color}\n >\n <IconCopy />\n </Button>\n </Action>\n <Tooltip>{tooltip}</Tooltip>\n </TooltipTrigger>\n );\n});\n\nexport default CopyButton;\n"],"mappings":";;;;;;;;;;;;;;;AA0BA,IAAa,aAAa,cAAc,eAAe,UAAU;CAC/D,MAAM,EACJ,OAAO,IACP,KACA,UAAU,SACV,QAAQ,aACR,QACA,GAAG,gBACD;CAIJ,MAAM,UAFkB,4BAA4B,kBAAS,YAE7C,CAAA,CAAgB,OAAO,MAAM;CAE7C,MAAM,YAAY,YAAY;EAC5B,MAAM,aAAa,SAAS,IAAI;EAChC,IAAI,MAAM,KAAK,UAAU,GACvB,SAAS,UAAU;CAEvB;CAEA,OACE,qBAAC,gBAAD,EAAA,UAAA,CACE,oBAAC,QAAD;EAAQ,UAAU;EAAW,cAAA;EAC3B,UAAA,oBAAC,QAAD;GACE,cAAY;GACZ,GAAI;GACC;GACI;GACF;GAEP,UAAA,oBAAC,UAAD,CAAW,CAAA;EACL,CAAA;CACF,CAAA,GACR,oBAAC,SAAD,EAAA,UAAU,QAAiB,CAAA,CACb,EAAA,CAAA;AAEpB,CAAC"}
|
|
@@ -6,9 +6,8 @@ import { useList } from "../../hooks/useList.mjs";
|
|
|
6
6
|
import { Item } from "./components/Item/Item.mjs";
|
|
7
7
|
import ItemsGridListView from "../../../../views/ItemsGridListView.mjs";
|
|
8
8
|
import { FallbackItems } from "./components/FallbackItems/FallbackItems.mjs";
|
|
9
|
-
import {
|
|
9
|
+
import { useInfiniteScrollTrigger } from "../../hooks/useInfiniteScrollTrigger.mjs";
|
|
10
10
|
import clsx from "clsx";
|
|
11
|
-
import { useRef } from "react";
|
|
12
11
|
import { jsx } from "react/jsx-runtime";
|
|
13
12
|
//#region src/components/List/components/Items/Items.tsx
|
|
14
13
|
var Items = () => {
|
|
@@ -17,16 +16,14 @@ var Items = () => {
|
|
|
17
16
|
const isLoading = list.loader.useIsLoading();
|
|
18
17
|
const isInitiallyLoading = list.loader.useIsInitiallyLoading();
|
|
19
18
|
const isLoadingMore = list.loader.useIsLoadingMore();
|
|
20
|
-
const triggerRef =
|
|
21
|
-
useInfiniteScrollTrigger(triggerRef);
|
|
19
|
+
const { triggerRef, triggerIndex } = useInfiniteScrollTrigger();
|
|
22
20
|
if (!list.itemView) return null;
|
|
23
|
-
const triggerIndex = Math.max(0, list.items.entries.length - getLoadMoreThresholdRows(list.batches.batchSize));
|
|
24
21
|
const items = list.items.entries.map((item, index) => /* @__PURE__ */ jsx(Item, {
|
|
25
22
|
data: item.data,
|
|
26
23
|
id: item.id,
|
|
27
24
|
list,
|
|
28
25
|
isTile: tiles,
|
|
29
|
-
triggerRef:
|
|
26
|
+
triggerRef: index === triggerIndex ? triggerRef : void 0
|
|
30
27
|
}, item.id));
|
|
31
28
|
const rootClassName = clsx(Items_module_default.items, isLoading && !(list.infiniteScroll && isLoadingMore) && Items_module_default.isLoading, tiles && Items_module_default.tiles);
|
|
32
29
|
const { "aria-labelledby": ariaLabelledby, "aria-label": ariaLabel, ...rest } = list.componentProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Items.mjs","names":[],"sources":["../../../../../../../../../src/components/List/components/Items/Items.tsx"],"sourcesContent":["import Item from \"@/components/List/components/Items/components/Item/Item\";\nimport { useList } from \"@/components/List/hooks/useList\";\nimport DivView from \"@/views/DivView\";\nimport ItemsGridListView from \"@/views/ItemsGridListView\";\nimport clsx from \"clsx\";\nimport type { FC } from \"react\";\nimport
|
|
1
|
+
{"version":3,"file":"Items.mjs","names":[],"sources":["../../../../../../../../../src/components/List/components/Items/Items.tsx"],"sourcesContent":["import Item from \"@/components/List/components/Items/components/Item/Item\";\nimport { useList } from \"@/components/List/hooks/useList\";\nimport DivView from \"@/views/DivView\";\nimport ItemsGridListView from \"@/views/ItemsGridListView\";\nimport clsx from \"clsx\";\nimport type { FC } from \"react\";\nimport styles from \"./Items.module.scss\";\nimport { FallbackItems } from \"./components/FallbackItems\";\nimport { useInfiniteScrollTrigger } from \"@/components/List/hooks/useInfiniteScrollTrigger\";\n\nexport const Items: FC = () => {\n const list = useList();\n const tiles = list.viewMode.isTiles;\n const isLoading = list.loader.useIsLoading();\n const isInitiallyLoading = list.loader.useIsInitiallyLoading();\n const isLoadingMore = list.loader.useIsLoadingMore();\n\n const { triggerRef, triggerIndex } = useInfiniteScrollTrigger();\n\n if (!list.itemView) {\n return null;\n }\n\n const items = list.items.entries.map((item, index) => (\n <Item\n key={item.id}\n data={item.data}\n id={item.id}\n list={list}\n isTile={tiles}\n triggerRef={index === triggerIndex ? triggerRef : undefined}\n />\n ));\n\n const rootClassName = clsx(\n styles.items,\n isLoading && !(list.infiniteScroll && isLoadingMore) && styles.isLoading,\n tiles && styles.tiles,\n );\n\n const {\n \"aria-labelledby\": ariaLabelledby,\n \"aria-label\": ariaLabel,\n ...rest\n } = list.componentProps;\n\n return (\n <DivView aria-hidden={isInitiallyLoading} aria-busy={isLoading}>\n <ItemsGridListView\n className={rootClassName}\n {...rest}\n aria-labelledby={ariaLabel ? undefined : ariaLabelledby}\n aria-label={ariaLabel}\n layout={tiles ? \"grid\" : \"stack\"}\n tileMaxWidth={list.itemView.tileMaxWidth}\n >\n {items.length === 0 && isInitiallyLoading ? <FallbackItems /> : items}\n </ItemsGridListView>\n </DivView>\n );\n};\n\nexport default Items;\n"],"mappings":";;;;;;;;;;;;AAUA,IAAa,cAAkB;CAC7B,MAAM,OAAO,QAAQ;CACrB,MAAM,QAAQ,KAAK,SAAS;CAC5B,MAAM,YAAY,KAAK,OAAO,aAAa;CAC3C,MAAM,qBAAqB,KAAK,OAAO,sBAAsB;CAC7D,MAAM,gBAAgB,KAAK,OAAO,iBAAiB;CAEnD,MAAM,EAAE,YAAY,iBAAiB,yBAAyB;CAE9D,IAAI,CAAC,KAAK,UACR,OAAO;CAGT,MAAM,QAAQ,KAAK,MAAM,QAAQ,KAAK,MAAM,UAC1C,oBAAC,MAAD;EAEE,MAAM,KAAK;EACX,IAAI,KAAK;EACH;EACN,QAAQ;EACR,YAAY,UAAU,eAAe,aAAa,KAAA;CACnD,GANM,KAAK,EAMX,CACF;CAED,MAAM,gBAAgB,KACpB,qBAAO,OACP,aAAa,EAAE,KAAK,kBAAkB,kBAAkB,qBAAO,WAC/D,SAAS,qBAAO,KAClB;CAEA,MAAM,EACJ,mBAAmB,gBACnB,cAAc,WACd,GAAG,SACD,KAAK;CAET,OACE,oBAAC,SAAD;EAAS,eAAa;EAAoB,aAAW;EACnD,UAAA,oBAAC,mBAAD;GACE,WAAW;GACX,GAAI;GACJ,mBAAiB,YAAY,KAAA,IAAY;GACzC,cAAY;GACZ,QAAQ,QAAQ,SAAS;GACzB,cAAc,KAAK,SAAS;GAE3B,UAAA,MAAM,WAAW,KAAK,qBAAqB,oBAAC,eAAD,CAAgB,CAAA,IAAI;EAC/C,CAAA;CACZ,CAAA;AAEb"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
3
|
import { useList } from "../../hooks/useList.mjs";
|
|
4
|
+
import { useInfiniteScrollTrigger } from "../../hooks/useInfiniteScrollTrigger.mjs";
|
|
4
5
|
import Table_module_default from "./Table.module.mjs";
|
|
5
6
|
import TableView from "../../../../views/TableView.mjs";
|
|
6
7
|
import TableHeaderView from "../../../../views/TableHeaderView.mjs";
|
|
@@ -18,14 +19,17 @@ var Table = () => {
|
|
|
18
19
|
const listIsEmpty = list.useIsEmpty();
|
|
19
20
|
const isLoading = list.loader.useIsLoading();
|
|
20
21
|
const isInitiallyLoading = list.loader.useIsInitiallyLoading();
|
|
22
|
+
const isLoadingMore = list.loader.useIsLoadingMore();
|
|
23
|
+
const { triggerRef, triggerIndex } = useInfiniteScrollTrigger();
|
|
21
24
|
if (!table || listIsEmpty) return null;
|
|
22
25
|
const rowAction = table.list.onAction;
|
|
23
|
-
const tableClassName = clsx(Table_module_default.table, isLoading && Table_module_default.isLoading, table.componentProps.className);
|
|
24
|
-
const rows = list.items.entries.map((item) => /* @__PURE__ */ jsx(TableRowView, {
|
|
26
|
+
const tableClassName = clsx(Table_module_default.table, isLoading && !(list.infiniteScroll && isLoadingMore) && Table_module_default.isLoading, table.componentProps.className);
|
|
27
|
+
const rows = list.items.entries.map((item, index) => /* @__PURE__ */ jsx(TableRowView, {
|
|
25
28
|
className: clsx(Table_module_default.row, rowAction && Table_module_default.hasAction, table.body.row.componentProps.className),
|
|
26
29
|
id: item.id,
|
|
27
30
|
onAction: rowAction ? () => rowAction(item.data) : void 0,
|
|
28
31
|
...table.body.row.componentProps,
|
|
32
|
+
...index === triggerIndex ? { ref: triggerRef } : {},
|
|
29
33
|
children: table.body.row?.cells.map((cell, i) => /* @__PURE__ */ jsx(TableCellView, {
|
|
30
34
|
...cell.componentProps,
|
|
31
35
|
children: cell.renderFn ? cell.renderFn(item.data, list) : void 0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Table.mjs","names":[],"sources":["../../../../../../../../../src/components/List/components/Table/Table.tsx"],"sourcesContent":["import type { FC } from \"react\";\nimport { useList } from \"@/components/List\";\nimport styles from \"./Table.module.scss\";\nimport clsx from \"clsx\";\nimport TableView from \"@/views/TableView\";\nimport TableHeaderView from \"@/views/TableHeaderView\";\nimport TableBodyView from \"@/views/TableBodyView\";\nimport TableRowView from \"@/views/TableRowView\";\nimport TableCellView from \"@/views/TableCellView\";\nimport TableColumnView from \"@/views/TableColumnView\";\nimport { TableBodyLoadingView } from \"@/components/List/components/Table/components/TableBodyLoadingView\";\n\nexport const Table: FC = () => {\n const list = useList();\n const table = list.table;\n const listIsEmpty = list.useIsEmpty();\n\n const isLoading = list.loader.useIsLoading();\n const isInitiallyLoading = list.loader.useIsInitiallyLoading();\n\n if (!table || listIsEmpty) {\n return null;\n }\n\n const rowAction = table.list.onAction;\n\n const tableClassName = clsx(\n styles.table,\n isLoading && styles.isLoading,\n table.componentProps.className,\n );\n\n const rows = list.items.entries.map((item) => (\n <TableRowView\n className={clsx(\n styles.row,\n rowAction && styles.hasAction,\n table.body.row.componentProps.className,\n )}\n key={item.id}\n id={item.id}\n onAction={rowAction ? () => rowAction(item.data) : undefined}\n {...table.body.row.componentProps}\n >\n {table.body.row?.cells.map((cell, i) => (\n <TableCellView key={i} {...cell.componentProps}>\n {cell.renderFn ? cell.renderFn(item.data, list) : undefined}\n </TableCellView>\n ))}\n </TableRowView>\n ));\n\n return (\n <TableView\n {...list.componentProps}\n {...table.componentProps}\n className={tableClassName}\n aria-hidden={isInitiallyLoading}\n aria-busy={isLoading}\n >\n <TableHeaderView {...table.header.componentProps}>\n {table.header.columns.map((col, i) => (\n <TableColumnView key={i} {...col.componentProps} />\n ))}\n </TableHeaderView>\n <TableBodyView {...table.body.componentProps}>\n {isInitiallyLoading ? <TableBodyLoadingView /> : rows}\n </TableBodyView>\n </TableView>\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Table.mjs","names":[],"sources":["../../../../../../../../../src/components/List/components/Table/Table.tsx"],"sourcesContent":["import type { FC } from \"react\";\nimport { useList } from \"@/components/List\";\nimport styles from \"./Table.module.scss\";\nimport clsx from \"clsx\";\nimport TableView from \"@/views/TableView\";\nimport TableHeaderView from \"@/views/TableHeaderView\";\nimport TableBodyView from \"@/views/TableBodyView\";\nimport TableRowView from \"@/views/TableRowView\";\nimport TableCellView from \"@/views/TableCellView\";\nimport TableColumnView from \"@/views/TableColumnView\";\nimport { TableBodyLoadingView } from \"@/components/List/components/Table/components/TableBodyLoadingView\";\nimport { useInfiniteScrollTrigger } from \"@/components/List/hooks/useInfiniteScrollTrigger\";\n\nexport const Table: FC = () => {\n const list = useList();\n const table = list.table;\n const listIsEmpty = list.useIsEmpty();\n\n const isLoading = list.loader.useIsLoading();\n const isInitiallyLoading = list.loader.useIsInitiallyLoading();\n const isLoadingMore = list.loader.useIsLoadingMore();\n\n const { triggerRef, triggerIndex } = useInfiniteScrollTrigger();\n\n if (!table || listIsEmpty) {\n return null;\n }\n\n const rowAction = table.list.onAction;\n\n const tableClassName = clsx(\n styles.table,\n isLoading && !(list.infiniteScroll && isLoadingMore) && styles.isLoading,\n table.componentProps.className,\n );\n\n const rows = list.items.entries.map((item, index) => (\n <TableRowView\n className={clsx(\n styles.row,\n rowAction && styles.hasAction,\n table.body.row.componentProps.className,\n )}\n key={item.id}\n id={item.id}\n onAction={rowAction ? () => rowAction(item.data) : undefined}\n {...table.body.row.componentProps}\n {...(index === triggerIndex ? { ref: triggerRef } : {})}\n >\n {table.body.row?.cells.map((cell, i) => (\n <TableCellView key={i} {...cell.componentProps}>\n {cell.renderFn ? cell.renderFn(item.data, list) : undefined}\n </TableCellView>\n ))}\n </TableRowView>\n ));\n\n return (\n <TableView\n {...list.componentProps}\n {...table.componentProps}\n className={tableClassName}\n aria-hidden={isInitiallyLoading}\n aria-busy={isLoading}\n >\n <TableHeaderView {...table.header.componentProps}>\n {table.header.columns.map((col, i) => (\n <TableColumnView key={i} {...col.componentProps} />\n ))}\n </TableHeaderView>\n <TableBodyView {...table.body.componentProps}>\n {isInitiallyLoading ? <TableBodyLoadingView /> : rows}\n </TableBodyView>\n </TableView>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;AAaA,IAAa,cAAkB;CAC7B,MAAM,OAAO,QAAQ;CACrB,MAAM,QAAQ,KAAK;CACnB,MAAM,cAAc,KAAK,WAAW;CAEpC,MAAM,YAAY,KAAK,OAAO,aAAa;CAC3C,MAAM,qBAAqB,KAAK,OAAO,sBAAsB;CAC7D,MAAM,gBAAgB,KAAK,OAAO,iBAAiB;CAEnD,MAAM,EAAE,YAAY,iBAAiB,yBAAyB;CAE9D,IAAI,CAAC,SAAS,aACZ,OAAO;CAGT,MAAM,YAAY,MAAM,KAAK;CAE7B,MAAM,iBAAiB,KACrB,qBAAO,OACP,aAAa,EAAE,KAAK,kBAAkB,kBAAkB,qBAAO,WAC/D,MAAM,eAAe,SACvB;CAEA,MAAM,OAAO,KAAK,MAAM,QAAQ,KAAK,MAAM,UACzC,oBAAC,cAAD;EACE,WAAW,KACT,qBAAO,KACP,aAAa,qBAAO,WACpB,MAAM,KAAK,IAAI,eAAe,SAChC;EAEA,IAAI,KAAK;EACT,UAAU,kBAAkB,UAAU,KAAK,IAAI,IAAI,KAAA;EACnD,GAAI,MAAM,KAAK,IAAI;EACnB,GAAK,UAAU,eAAe,EAAE,KAAK,WAAW,IAAI,CAAC;EAEpD,UAAA,MAAM,KAAK,KAAK,MAAM,KAAK,MAAM,MAChC,oBAAC,eAAD;GAAuB,GAAI,KAAK;GAC7B,UAAA,KAAK,WAAW,KAAK,SAAS,KAAK,MAAM,IAAI,IAAI,KAAA;EACrC,GAFK,CAEL,CAChB;CACW,GAXP,KAAK,EAWE,CACf;CAED,OACE,qBAAC,WAAD;EACE,GAAI,KAAK;EACT,GAAI,MAAM;EACV,WAAW;EACX,eAAa;EACb,aAAW;EALb,UAAA,CAOE,oBAAC,iBAAD;GAAiB,GAAI,MAAM,OAAO;GAC/B,UAAA,MAAM,OAAO,QAAQ,KAAK,KAAK,MAC9B,oBAAC,iBAAD,EAAyB,GAAI,IAAI,eAAiB,GAA5B,CAA4B,CACnD;EACc,CAAA,GACjB,oBAAC,eAAD;GAAe,GAAI,MAAM,KAAK;GAC3B,UAAA,qBAAqB,oBAAC,sBAAD,CAAuB,CAAA,IAAI;EACpC,CAAA,CACN;;AAEf"}
|
|
@@ -1,34 +1,33 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
|
-
import { useList } from "
|
|
4
|
-
import { useEffect, useEffectEvent } from "react";
|
|
5
|
-
//#region src/components/List/
|
|
3
|
+
import { useList } from "./useList.mjs";
|
|
4
|
+
import { useEffect, useEffectEvent, useState } from "react";
|
|
5
|
+
//#region src/components/List/hooks/useInfiniteScrollTrigger.ts
|
|
6
6
|
var loadMoreThresholdFactor = .2;
|
|
7
7
|
var minLoadMoreThresholdRows = 1;
|
|
8
8
|
var maxLoadMoreThresholdRows = 8;
|
|
9
9
|
var getLoadMoreThresholdRows = (batchSize) => Math.min(maxLoadMoreThresholdRows, Math.max(minLoadMoreThresholdRows, Math.round(batchSize * loadMoreThresholdFactor)));
|
|
10
|
-
var useInfiniteScrollTrigger = (
|
|
10
|
+
var useInfiniteScrollTrigger = () => {
|
|
11
11
|
const list = useList();
|
|
12
12
|
const isLoading = list.loader.useIsLoading();
|
|
13
|
-
const
|
|
13
|
+
const [trigger, setTrigger] = useState(null);
|
|
14
14
|
const loadNextBatch = useEffectEvent(() => {
|
|
15
15
|
if (list.batches.hasNextBatch() && !isLoading) list.batches.nextBatch();
|
|
16
16
|
});
|
|
17
17
|
useEffect(() => {
|
|
18
|
-
const trigger = triggerRef.current;
|
|
19
18
|
if (!trigger) return;
|
|
20
19
|
const observer = new IntersectionObserver((entries) => {
|
|
21
20
|
if (entries.some((entry) => entry.isIntersecting)) loadNextBatch();
|
|
22
21
|
});
|
|
23
22
|
observer.observe(trigger);
|
|
24
23
|
return () => observer.disconnect();
|
|
25
|
-
}, [
|
|
26
|
-
|
|
27
|
-
triggerRef,
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
}, [trigger]);
|
|
25
|
+
return {
|
|
26
|
+
triggerRef: setTrigger,
|
|
27
|
+
triggerIndex: list.infiniteScroll ? Math.max(0, list.items.entries.length - getLoadMoreThresholdRows(list.batches.batchSize)) : void 0
|
|
28
|
+
};
|
|
30
29
|
};
|
|
31
30
|
//#endregion
|
|
32
|
-
export {
|
|
31
|
+
export { useInfiniteScrollTrigger };
|
|
33
32
|
|
|
34
33
|
//# sourceMappingURL=useInfiniteScrollTrigger.mjs.map
|
package/dist/js/packages/components/src/components/List/hooks/useInfiniteScrollTrigger.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useInfiniteScrollTrigger.mjs","names":[],"sources":["../../../../../../../../src/components/List/hooks/useInfiniteScrollTrigger.ts"],"sourcesContent":["import { useEffect, useEffectEvent, useState, type RefCallback } from \"react\";\nimport { useList } from \"./useList\";\n\nconst loadMoreThresholdFactor = 0.2;\nconst minLoadMoreThresholdRows = 1;\nconst maxLoadMoreThresholdRows = 8;\n\nconst getLoadMoreThresholdRows = (batchSize: number): number =>\n Math.min(\n maxLoadMoreThresholdRows,\n Math.max(\n minLoadMoreThresholdRows,\n Math.round(batchSize * loadMoreThresholdFactor),\n ),\n );\n\ninterface InfiniteScrollTrigger {\n /**\n * Attach to whatever the view renders for `triggerIndex`. A callback ref, so\n * the observer follows the trigger as it moves on with every loaded batch — a\n * ref object would leave the effect without a signal that the element it\n * observes has been replaced.\n */\n triggerRef: RefCallback<HTMLElement>;\n /**\n * Index of the item that loads the next batch once it scrolls into view, or\n * `undefined` while infinite scrolling is off.\n */\n triggerIndex: number | undefined;\n}\n\nexport const useInfiniteScrollTrigger = (): InfiniteScrollTrigger => {\n const list = useList();\n const isLoading = list.loader.useIsLoading();\n const [trigger, setTrigger] = useState<HTMLElement | null>(null);\n\n const loadNextBatch = useEffectEvent(() => {\n if (list.batches.hasNextBatch() && !isLoading) {\n list.batches.nextBatch();\n }\n });\n\n useEffect(() => {\n if (!trigger) {\n return;\n }\n\n const observer = new IntersectionObserver((entries) => {\n if (entries.some((entry) => entry.isIntersecting)) {\n loadNextBatch();\n }\n });\n observer.observe(trigger);\n\n return () => observer.disconnect();\n }, [trigger]);\n\n return {\n triggerRef: setTrigger,\n triggerIndex: list.infiniteScroll\n ? Math.max(\n 0,\n list.items.entries.length -\n getLoadMoreThresholdRows(list.batches.batchSize),\n )\n : undefined,\n };\n};\n"],"mappings":";;;;;AAGA,IAAM,0BAA0B;AAChC,IAAM,2BAA2B;AACjC,IAAM,2BAA2B;AAEjC,IAAM,4BAA4B,cAChC,KAAK,IACH,0BACA,KAAK,IACH,0BACA,KAAK,MAAM,YAAY,uBAAuB,CAChD,CACF;AAiBF,IAAa,iCAAwD;CACnE,MAAM,OAAO,QAAQ;CACrB,MAAM,YAAY,KAAK,OAAO,aAAa;CAC3C,MAAM,CAAC,SAAS,cAAc,SAA6B,IAAI;CAE/D,MAAM,gBAAgB,qBAAqB;EACzC,IAAI,KAAK,QAAQ,aAAa,KAAK,CAAC,WAClC,KAAK,QAAQ,UAAU;CAE3B,CAAC;CAED,gBAAgB;EACd,IAAI,CAAC,SACH;EAGF,MAAM,WAAW,IAAI,sBAAsB,YAAY;GACrD,IAAI,QAAQ,MAAM,UAAU,MAAM,cAAc,GAC9C,cAAc;EAElB,CAAC;EACD,SAAS,QAAQ,OAAO;EAExB,aAAa,SAAS,WAAW;CACnC,GAAG,CAAC,OAAO,CAAC;CAEZ,OAAO;EACL,YAAY;EACZ,cAAc,KAAK,iBACf,KAAK,IACH,GACA,KAAK,MAAM,QAAQ,SACjB,yBAAyB,KAAK,QAAQ,SAAS,CACnD,IACA,KAAA;CACN;AACF"}
|
|
@@ -3,6 +3,11 @@ import { FlowComponentProps } from '../../lib/componentFactory/flowComponent';
|
|
|
3
3
|
export interface CopyButtonProps extends Omit<ButtonProps, "onPress" | "aria-label" | "render">, FlowComponentProps<HTMLButtonElement> {
|
|
4
4
|
/** The text to copy. */
|
|
5
5
|
text?: string;
|
|
6
|
+
/**
|
|
7
|
+
* Called with the copied text once it has been written to the clipboard. Not
|
|
8
|
+
* called when copying fails.
|
|
9
|
+
*/
|
|
10
|
+
onCopy?: (text: string) => void;
|
|
6
11
|
}
|
|
7
12
|
/** @flr-generate all */
|
|
8
13
|
export declare const CopyButton: import('react').FunctionComponent<CopyButtonProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { RefCallback } from 'react';
|
|
2
|
+
interface InfiniteScrollTrigger {
|
|
3
|
+
/**
|
|
4
|
+
* Attach to whatever the view renders for `triggerIndex`. A callback ref, so
|
|
5
|
+
* the observer follows the trigger as it moves on with every loaded batch — a
|
|
6
|
+
* ref object would leave the effect without a signal that the element it
|
|
7
|
+
* observes has been replaced.
|
|
8
|
+
*/
|
|
9
|
+
triggerRef: RefCallback<HTMLElement>;
|
|
10
|
+
/**
|
|
11
|
+
* Index of the item that loads the next batch once it scrolls into view, or
|
|
12
|
+
* `undefined` while infinite scrolling is off.
|
|
13
|
+
*/
|
|
14
|
+
triggerIndex: number | undefined;
|
|
15
|
+
}
|
|
16
|
+
export declare const useInfiniteScrollTrigger: () => InfiniteScrollTrigger;
|
|
17
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mittwald/flow-react-components",
|
|
3
|
-
"version": "1.3.0-next.
|
|
3
|
+
"version": "1.3.0-next.26",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A React implementation of Flow, mittwald’s design system",
|
|
6
6
|
"homepage": "https://flow.mittwald.de",
|
|
@@ -83,9 +83,9 @@
|
|
|
83
83
|
"@internationalized/string-compiler": "^3.4.1",
|
|
84
84
|
"@lezer/common": "^1.5.2",
|
|
85
85
|
"@lezer/highlight": "^1.2.3",
|
|
86
|
-
"@mittwald/flow-icons": "^1.3.0-next.
|
|
86
|
+
"@mittwald/flow-icons": "^1.3.0-next.26",
|
|
87
87
|
"@mittwald/password-tools-js": "^3.0.0",
|
|
88
|
-
"@mittwald/react-tunnel": "^1.3.0-next.
|
|
88
|
+
"@mittwald/react-tunnel": "^1.3.0-next.26",
|
|
89
89
|
"@mittwald/react-use-promise": "^4.2.2",
|
|
90
90
|
"@react-aria/form": "^3.2.1",
|
|
91
91
|
"@react-aria/i18n": "^3.13.1",
|
|
@@ -138,12 +138,12 @@
|
|
|
138
138
|
"@internationalized/date": "^3.12.3",
|
|
139
139
|
"@lezer/generator": "^1.8.0",
|
|
140
140
|
"@lezer/lr": "^1.4.10",
|
|
141
|
-
"@mittwald/flow-core": "1.3.0-next.
|
|
142
|
-
"@mittwald/flow-design-tokens": "1.3.0-next.
|
|
143
|
-
"@mittwald/flow-icons-base": "1.3.0-next.
|
|
141
|
+
"@mittwald/flow-core": "1.3.0-next.26",
|
|
142
|
+
"@mittwald/flow-design-tokens": "1.3.0-next.26",
|
|
143
|
+
"@mittwald/flow-icons-base": "1.3.0-next.26",
|
|
144
144
|
"@mittwald/react-use-promise": "^4.2.2",
|
|
145
145
|
"@mittwald/remote-dom-react": "1.2.2-mittwald.10",
|
|
146
|
-
"@mittwald/typescript-config": "1.3.0-next.
|
|
146
|
+
"@mittwald/typescript-config": "1.3.0-next.26",
|
|
147
147
|
"@nx/storybook": "^22.7.6",
|
|
148
148
|
"@storybook/addon-a11y": "^10.5.10",
|
|
149
149
|
"@storybook/addon-actions": "^9.0.8",
|
|
@@ -195,7 +195,7 @@
|
|
|
195
195
|
},
|
|
196
196
|
"peerDependencies": {
|
|
197
197
|
"@internationalized/date": "^3.12.2",
|
|
198
|
-
"@mittwald/flow-icons-pro": "1.3.0-next.
|
|
198
|
+
"@mittwald/flow-icons-pro": "1.3.0-next.26",
|
|
199
199
|
"@mittwald/react-use-promise": "^4.2.2",
|
|
200
200
|
"next": "^16.2.3",
|
|
201
201
|
"react": "^19.2.0",
|
|
@@ -219,5 +219,5 @@
|
|
|
219
219
|
"browserslist": [
|
|
220
220
|
"baseline widely available"
|
|
221
221
|
],
|
|
222
|
-
"gitHead": "
|
|
222
|
+
"gitHead": "2f6521f9dc61015d6d83e588f0dc01fa8bc01680"
|
|
223
223
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useInfiniteScrollTrigger.mjs","names":[],"sources":["../../../../../../../../../../src/components/List/components/Items/hooks/useInfiniteScrollTrigger.ts"],"sourcesContent":["import { useEffect, useEffectEvent, type RefObject } from \"react\";\nimport { useList } from \"@/components/List/hooks/useList\";\n\nconst loadMoreThresholdFactor = 0.2;\nconst minLoadMoreThresholdRows = 1;\nconst maxLoadMoreThresholdRows = 8;\n\nexport const getLoadMoreThresholdRows = (batchSize: number): number =>\n Math.min(\n maxLoadMoreThresholdRows,\n Math.max(\n minLoadMoreThresholdRows,\n Math.round(batchSize * loadMoreThresholdFactor),\n ),\n );\n\nexport const useInfiniteScrollTrigger = (\n triggerRef: RefObject<HTMLElement | null>,\n): void => {\n const list = useList();\n const isLoading = list.loader.useIsLoading();\n const visibleItemsCount = list.batches.getVisibleItemsCount();\n\n const loadNextBatch = useEffectEvent(() => {\n if (list.batches.hasNextBatch() && !isLoading) {\n list.batches.nextBatch();\n }\n });\n\n useEffect(() => {\n const trigger = triggerRef.current;\n if (!trigger) {\n return;\n }\n\n const observer = new IntersectionObserver((entries) => {\n if (entries.some((entry) => entry.isIntersecting)) {\n loadNextBatch();\n }\n });\n observer.observe(trigger);\n\n return () => observer.disconnect();\n }, [loadNextBatch, triggerRef, visibleItemsCount]);\n};\n"],"mappings":";;;;;AAGA,IAAM,0BAA0B;AAChC,IAAM,2BAA2B;AACjC,IAAM,2BAA2B;AAEjC,IAAa,4BAA4B,cACvC,KAAK,IACH,0BACA,KAAK,IACH,0BACA,KAAK,MAAM,YAAY,uBAAuB,CAChD,CACF;AAEF,IAAa,4BACX,eACS;CACT,MAAM,OAAO,QAAQ;CACrB,MAAM,YAAY,KAAK,OAAO,aAAa;CAC3C,MAAM,oBAAoB,KAAK,QAAQ,qBAAqB;CAE5D,MAAM,gBAAgB,qBAAqB;EACzC,IAAI,KAAK,QAAQ,aAAa,KAAK,CAAC,WAClC,KAAK,QAAQ,UAAU;CAE3B,CAAC;CAED,gBAAgB;EACd,MAAM,UAAU,WAAW;EAC3B,IAAI,CAAC,SACH;EAGF,MAAM,WAAW,IAAI,sBAAsB,YAAY;GACrD,IAAI,QAAQ,MAAM,UAAU,MAAM,cAAc,GAC9C,cAAc;EAElB,CAAC;EACD,SAAS,QAAQ,OAAO;EAExB,aAAa,SAAS,WAAW;CACnC,GAAG;EAAC;EAAe;EAAY;CAAiB,CAAC;AACnD"}
|