tempest-react-sdk 0.64.0 → 0.66.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.
Files changed (121) hide show
  1. package/README.md +4 -4
  2. package/dist/auth/create-tempest-auth.cjs +1 -1
  3. package/dist/auth/create-tempest-auth.cjs.map +1 -1
  4. package/dist/auth/create-tempest-auth.js +31 -36
  5. package/dist/auth/create-tempest-auth.js.map +1 -1
  6. package/dist/components/Command/Command.module.cjs.map +1 -1
  7. package/dist/components/Command/Command.module.js.map +1 -1
  8. package/dist/components/ContextMenu/ContextMenu.module.cjs.map +1 -1
  9. package/dist/components/ContextMenu/ContextMenu.module.js.map +1 -1
  10. package/dist/components/DataTable/DataTable.cjs +1 -1
  11. package/dist/components/DataTable/DataTable.cjs.map +1 -1
  12. package/dist/components/DataTable/DataTable.js +1 -0
  13. package/dist/components/DataTable/DataTable.js.map +1 -1
  14. package/dist/components/DataTable/use-dev-warnings.cjs +1 -1
  15. package/dist/components/DataTable/use-dev-warnings.cjs.map +1 -1
  16. package/dist/components/DataTable/use-dev-warnings.js +4 -3
  17. package/dist/components/DataTable/use-dev-warnings.js.map +1 -1
  18. package/dist/components/DropdownMenu/DropdownMenu.module.cjs.map +1 -1
  19. package/dist/components/DropdownMenu/DropdownMenu.module.js.map +1 -1
  20. package/dist/components/InstallBanner/InstallBanner.cjs +1 -1
  21. package/dist/components/InstallBanner/InstallBanner.cjs.map +1 -1
  22. package/dist/components/InstallBanner/InstallBanner.js +62 -37
  23. package/dist/components/InstallBanner/InstallBanner.js.map +1 -1
  24. package/dist/components/InstallBanner/InstallBanner.module.cjs +1 -1
  25. package/dist/components/InstallBanner/InstallBanner.module.cjs.map +1 -1
  26. package/dist/components/InstallBanner/InstallBanner.module.js +4 -3
  27. package/dist/components/InstallBanner/InstallBanner.module.js.map +1 -1
  28. package/dist/components/InstallButton/InstallButton.cjs +1 -1
  29. package/dist/components/InstallButton/InstallButton.cjs.map +1 -1
  30. package/dist/components/InstallButton/InstallButton.js +34 -10
  31. package/dist/components/InstallButton/InstallButton.js.map +1 -1
  32. package/dist/components/InstallButton/InstallButton.module.cjs +3 -0
  33. package/dist/components/InstallButton/InstallButton.module.cjs.map +1 -0
  34. package/dist/components/InstallButton/InstallButton.module.js +10 -0
  35. package/dist/components/InstallButton/InstallButton.module.js.map +1 -0
  36. package/dist/components/InstallButton/install-hints.cjs +2 -0
  37. package/dist/components/InstallButton/install-hints.cjs.map +1 -0
  38. package/dist/components/InstallButton/install-hints.js +32 -0
  39. package/dist/components/InstallButton/install-hints.js.map +1 -0
  40. package/dist/components/SegmentedControl/SegmentedControl.module.cjs.map +1 -1
  41. package/dist/components/SegmentedControl/SegmentedControl.module.js.map +1 -1
  42. package/dist/components/Select/Select.cjs +1 -1
  43. package/dist/components/Select/Select.cjs.map +1 -1
  44. package/dist/components/Select/Select.js +43 -40
  45. package/dist/components/Select/Select.js.map +1 -1
  46. package/dist/components/Select/Select.module.cjs +1 -1
  47. package/dist/components/Select/Select.module.cjs.map +1 -1
  48. package/dist/components/Select/Select.module.js +5 -3
  49. package/dist/components/Select/Select.module.js.map +1 -1
  50. package/dist/hooks/use-install-prompt.cjs +1 -1
  51. package/dist/hooks/use-install-prompt.cjs.map +1 -1
  52. package/dist/hooks/use-install-prompt.js +9 -2
  53. package/dist/hooks/use-install-prompt.js.map +1 -1
  54. package/dist/http/api-client.cjs +1 -1
  55. package/dist/http/api-client.cjs.map +1 -1
  56. package/dist/http/api-client.js +93 -85
  57. package/dist/http/api-client.js.map +1 -1
  58. package/dist/http/credential-scope.cjs +2 -0
  59. package/dist/http/credential-scope.cjs.map +1 -0
  60. package/dist/http/credential-scope.js +23 -0
  61. package/dist/http/credential-scope.js.map +1 -0
  62. package/dist/http/decode-response.cjs +2 -0
  63. package/dist/http/decode-response.cjs.map +1 -0
  64. package/dist/http/decode-response.js +28 -0
  65. package/dist/http/decode-response.js.map +1 -0
  66. package/dist/http/resumable-upload.cjs +1 -1
  67. package/dist/http/resumable-upload.cjs.map +1 -1
  68. package/dist/http/resumable-upload.js +121 -120
  69. package/dist/http/resumable-upload.js.map +1 -1
  70. package/dist/http/upload-with-progress.cjs +1 -1
  71. package/dist/http/upload-with-progress.cjs.map +1 -1
  72. package/dist/http/upload-with-progress.js +35 -34
  73. package/dist/http/upload-with-progress.js.map +1 -1
  74. package/dist/styles/InstallButton.css +2 -0
  75. package/dist/styles/actions.css +6 -1
  76. package/dist/styles/advanced.css +2 -2
  77. package/dist/styles/component/Command.css +1 -1
  78. package/dist/styles/component/ContextMenu.css +1 -1
  79. package/dist/styles/component/DropdownMenu.css +1 -1
  80. package/dist/styles/component/InstallBanner.css +2 -0
  81. package/dist/styles/component/InstallButton.css +4 -0
  82. package/dist/styles/component/SegmentedControl.css +1 -1
  83. package/dist/styles/component/Select.css +4 -0
  84. package/dist/styles/core.css +2 -2
  85. package/dist/styles/forms.css +4 -0
  86. package/dist/styles/manifest.json +2 -1
  87. package/dist/styles/navigation.css +1 -1
  88. package/dist/styles/tokens.css +2 -2
  89. package/dist/styles.css +1 -1
  90. package/dist/tempest-react-sdk.cjs +1 -1
  91. package/dist/tempest-react-sdk.d.ts +473 -40
  92. package/dist/tempest-react-sdk.js +321 -318
  93. package/dist/theme/ThemeProvider.cjs +1 -1
  94. package/dist/theme/ThemeProvider.cjs.map +1 -1
  95. package/dist/theme/ThemeProvider.js +40 -45
  96. package/dist/theme/ThemeProvider.js.map +1 -1
  97. package/dist/theme/create-theme.cjs +1 -1
  98. package/dist/theme/create-theme.cjs.map +1 -1
  99. package/dist/theme/create-theme.js +1 -1
  100. package/dist/theme/create-theme.js.map +1 -1
  101. package/dist/theme/initial-theme.cjs +2 -2
  102. package/dist/theme/initial-theme.cjs.map +1 -1
  103. package/dist/theme/initial-theme.js +7 -12
  104. package/dist/theme/initial-theme.js.map +1 -1
  105. package/dist/utils/absent.cjs +2 -0
  106. package/dist/utils/absent.cjs.map +1 -0
  107. package/dist/utils/absent.js +12 -0
  108. package/dist/utils/absent.js.map +1 -0
  109. package/dist/utils/format.cjs +1 -1
  110. package/dist/utils/format.cjs.map +1 -1
  111. package/dist/utils/format.js +42 -35
  112. package/dist/utils/format.js.map +1 -1
  113. package/dist/utils/numbers.cjs +1 -1
  114. package/dist/utils/numbers.cjs.map +1 -1
  115. package/dist/utils/numbers.js +14 -12
  116. package/dist/utils/numbers.js.map +1 -1
  117. package/dist/utils/storage.cjs +1 -1
  118. package/dist/utils/storage.cjs.map +1 -1
  119. package/dist/utils/storage.js +13 -0
  120. package/dist/utils/storage.js.map +1 -1
  121. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"DataTable.js","names":[],"sources":["../../../src/components/DataTable/DataTable.tsx"],"sourcesContent":["/**\n * @tempest-limits file-lines, props-count, function-lines — the table does four jobs\n * a caller turns on independently — paging (pageSize), search (searchable,\n * searchKeys), sort (initialSort) and inline edit (onCellChange, editLabels) — over\n * one row model (data, columns, rowKey, emptyMessage). The body is long because\n * those four share the derived-rows pipeline: filter, then sort, then page, then map\n * to cells, in that order and off the same memo.\n *\n * Each of the four also runs in a second mode, where the caller owns the work and\n * the table only reports intent: totalItems/page/onPageChange, onSearchChange,\n * manualSort/onSortChange, loading/loadingRows. That doubles the props without\n * adding a fifth job — every manual prop short-circuits one stage of the same\n * pipeline.\n */\nimport { useCallback, useEffect, useMemo, useState } from \"react\";\nimport type { HTMLAttributes, ReactNode } from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport { compareValues } from \"@/utils/compare-values\";\nimport { usePagination } from \"@/hooks\";\nimport { useAnnounce } from \"@/hooks/use-announce\";\nimport { Table, type TableAlign, type TableColumn, type TablePriority } from \"../Table\";\nimport { Pagination } from \"../Pagination\";\nimport { SearchBar } from \"../SearchBar\";\nimport { EditableCell } from \"./EditableCell\";\nimport { LoadingRows } from \"./LoadingRows\";\nimport { useDevWarnings } from \"./use-dev-warnings\";\nimport { DEFAULT_EDIT_LABELS, type CellCommitMove, type DataTableEditLabels } from \"./edit-labels\";\nimport styles from \"./DataTable.module.css\";\n\nexport type SortDirection = \"asc\" | \"desc\";\n\nexport interface DataTableSort<T> {\n key: keyof T;\n direction: SortDirection;\n}\n\n/** Input types an editable column can use. */\nexport type DataTableEditorType = \"text\" | \"number\" | \"date\" | \"email\" | \"tel\" | \"url\";\n\n/** One accepted cell edit, handed to `onCellChange`. */\nexport interface DataTableCellChange<T> {\n /** The row as it was before the edit. */\n row: T;\n /** Which column changed. */\n key: keyof T;\n /** The parsed new value. */\n value: unknown;\n /** The value that was displayed before the edit. */\n previous: unknown;\n /** Index of the row in the full `data` array. */\n rowIndex: number;\n}\n\n/**\n * Column definition for {@link DataTable}. Extends the headless {@link Table}\n * column shape with a typed `key`, opt-in sorting, opt-in inline editing, and the\n * visual options that are forwarded to the underlying Table cell.\n */\nexport interface DataTableColumn<T> {\n /** Property of the row this column reads from. Doubles as the cell key. */\n key: keyof T;\n /** Column heading. */\n header: ReactNode;\n /** Custom cell renderer. Defaults to `String(row[key])`. */\n render?: (row: T) => ReactNode;\n /** Enable click-to-sort on this column's header. */\n sortable?: boolean;\n /** Text alignment forwarded to the Table cell. */\n align?: TableAlign;\n /** Responsive visibility priority forwarded to the Table cell. */\n priority?: TablePriority;\n /** Fixed column width forwarded to the Table cell. */\n width?: string | number;\n /**\n * Let cells in this column be edited in place. Requires `onCellChange` on the\n * table; without it the column stays read-only.\n */\n editable?: boolean;\n /** Editor input type. Default `\"text\"`. */\n editorType?: DataTableEditorType;\n /** Text the editor opens with. Defaults to `String(value ?? \"\")`. */\n formatEdit?: (row: T) => string;\n /**\n * Turn the typed string into the stored value. Defaults to the trimmed string,\n * or `Number(raw)` when `editorType` is `\"number\"`.\n */\n parse?: (raw: string, row: T) => unknown;\n /** Return a message to reject the edit, or `null` to accept it. */\n validate?: (value: unknown, row: T) => string | null;\n}\n\n/** Everything a table needs regardless of who owns paging, sorting and searching. */\nexport interface DataTableBaseProps<T> extends HTMLAttributes<HTMLDivElement> {\n /**\n * The rows to work with.\n *\n * By default this is the **full** dataset and sorting, searching and paging\n * all happen in memory. Pass `totalItems` and it becomes the current page as\n * the server returned it, with those three delegated to the caller.\n */\n data: T[];\n /** Column definitions. */\n columns: DataTableColumn<T>[];\n /** Rows per page. Default 10. */\n pageSize?: number;\n /** Render a search input above the table. Default false. */\n searchable?: boolean;\n /**\n * Keys to match the search term against. When omitted, every column whose\n * value is a string or number is searched.\n */\n searchKeys?: (keyof T)[];\n /** Initial sort applied before any header interaction. */\n initialSort?: DataTableSort<T>;\n /** Stable key extractor for rows. Defaults to the row index. */\n rowKey?: (row: T, index: number) => string | number;\n /** Content shown when no rows match. */\n emptyMessage?: ReactNode;\n /**\n * Persist an accepted cell edit. Return a promise: while it is pending the cell\n * already shows the new value, and a rejection rolls that back and surfaces the\n * error in the cell. Without this prop no column is editable.\n */\n onCellChange?: (change: DataTableCellChange<T>) => void | Promise<void>;\n /** Override the PT-BR copy of the editing affordances. */\n editLabels?: Partial<DataTableEditLabels>;\n /**\n * A fetch is in flight.\n *\n * With rows already on screen they stay put, dimmed and `aria-busy`, so the\n * page does not jump under the cursor between pages. With no rows yet it\n * renders placeholder lines at full height, which is a different statement\n * from `emptyMessage`: \"loading\" and \"there is nothing\" are not the same\n * screen.\n */\n loading?: boolean;\n}\n\n/**\n * Paging, as one of the three shapes that actually work.\n *\n * These used to be three optional props, so the compiler accepted\n * `totalItems` with no `page` — a table whose pager moves an internal page while\n * `data` keeps showing page one. Every prop was optional on its own, so the only\n * place left to catch it was a `console.warn` in dev, in the browser, with the\n * component mounted. As a union the same mistake is a build error at the call\n * site, for free, everywhere.\n */\nexport type DataTablePagingProps =\n | {\n /** Not server mode. */\n totalItems?: never;\n /** The table owns the page. */\n page?: never;\n /** Nothing to report to. */\n onPageChange?: never;\n }\n | {\n /**\n * Total row count across every page — the `total` of a paginated envelope.\n *\n * Passing it switches the table to **server mode**: `data` is read as the\n * current page, the page count comes from this number instead of\n * `data.length`, and sorting and searching are delegated to the caller\n * (see `manualSort` / `manualSearch`, which are implied here). Pair it with\n * `page` and `onPageChange`.\n */\n totalItems?: never;\n /** Current page, 1-based. Controlled — required in server mode. */\n page: number;\n /** Called with the next page. Required whenever `page` is controlled. */\n onPageChange: (page: number) => void;\n }\n | {\n /**\n * Total row count across every page — the `total` of a paginated envelope.\n *\n * Passing it switches the table to **server mode**: `data` is read as the\n * current page, the page count comes from this number instead of\n * `data.length`, and sorting and searching are delegated to the caller\n * (see `manualSort` / `manualSearch`, which are implied here). `page` and\n * `onPageChange` come with it — the type says so, because a server-mode\n * table without them silently shows page one forever.\n */\n totalItems: number;\n /** Current page, 1-based. Controlled, and required in server mode. */\n page: number;\n /** Called with the next page. */\n onPageChange: (page: number) => void;\n };\n\n/**\n * Sorting: delegated, and therefore reported, or neither.\n *\n * `manualSort` without `onSortChange` renders a header that moves its arrow and\n * changes nothing else — the arrow is a lie the compiler can now catch.\n */\nexport type DataTableSortProps<T> =\n | {\n /** The table sorts the rows it has. */\n manualSort?: false;\n /** Called with the next sort state — `null` when the header cycles back to unsorted. */\n onSortChange?: (sort: DataTableSort<T> | null) => void;\n }\n | {\n /**\n * Sorting is the caller's job: clicking a header reports through\n * `onSortChange` and the rows are left in the order they arrived.\n *\n * Implied by `totalItems`, because sorting the page in memory would sort\n * *that page only* while the header claims the whole table is ordered.\n */\n manualSort: true;\n /** Where the click goes. Required, since nothing else acts on it. */\n onSortChange: (sort: DataTableSort<T> | null) => void;\n };\n\n/**\n * Searching: delegated, and therefore reported, or neither.\n *\n * `manualSearch` without `onSearchChange` renders a search box that filters\n * nothing and tells nobody — the same shape of lie as a header arrow that turns\n * without sorting.\n *\n * Independent of the paging axis on purpose, and that leaves one gap this type\n * does not close: `totalItems` *implies* `manualSearch`, so a server-mode table\n * with `searchable` and no `onSearchChange` falls into the same hole without ever\n * writing `manualSearch`. Closing it means the search axis has to read the paging\n * axis, which crosses two three-member unions into nine and turns every mismatch\n * into a wall of candidate shapes. That case is a dev warning instead — the one\n * spot where runtime really is the cheaper check, and `use-dev-warnings.ts` says\n * so at the call site.\n */\nexport type DataTableSearchProps =\n | {\n /** The table filters the rows it has. */\n manualSearch?: false;\n /** Called with the current search term (debouncing, if any, is the caller's). */\n onSearchChange?: (term: string) => void;\n }\n | {\n /**\n * Searching is the caller's job: typing reports through `onSearchChange`\n * and the rows are left as they arrived.\n *\n * Implied by `totalItems`. Filtering the current page would hide the rows\n * that do not match *on this page* and show nothing for a term that only\n * matches on page three — an empty table that looks like \"no results\".\n */\n manualSearch: true;\n /** Where the typing goes. Required, since nothing else acts on it. */\n onSearchChange: (term: string) => void;\n };\n\n/**\n * The table's props: the shared half, plus one valid paging shape and one valid\n * sorting shape.\n */\nexport type DataTableProps<T> = DataTableBaseProps<T> &\n DataTablePagingProps &\n DataTableSortProps<T> &\n DataTableSearchProps;\n\n/** Identity of one cell, stable across re-renders and pagination. */\nfunction cellId(rowKeyValue: string | number, columnKey: PropertyKey): string {\n return `${String(rowKeyValue)}::${String(columnKey)}`;\n}\n\nfunction headerText<T>(column: DataTableColumn<T>): string {\n return typeof column.header === \"string\" ? column.header : String(column.key);\n}\n\n/**\n * Stateful, headless data table built on top of {@link Table}. Adds\n * client-side searching, click-to-sort columns, pagination and opt-in inline\n * editing while delegating all table markup to the underlying Table component.\n *\n * - Clicking a sortable header cycles asc → desc → unsorted.\n * - Search matches a case-insensitive substring across `searchKeys`\n * (or every string/number column when not provided).\n * - Pagination is hidden when the result fits on a single page.\n * - A column with `editable` renders a button that opens an inline editor;\n * `Enter` commits, `Escape` discards, `Tab` walks to the next editable cell.\n *\n * Editing is strictly opt-in: with no `editable` column (or no `onCellChange`) the\n * rendered markup is byte-for-byte what it was before the feature existed, which\n * matters because the component is published.\n *\n * ## Optimistic, with a visible rollback\n *\n * An accepted edit is shown immediately and `onCellChange` runs in the background.\n * If it rejects, the cell returns to the old value **and** shows the reason as a\n * `role=\"alert\"` tied to the cell. A silent revert is worse than no optimistic\n * update at all: the user watched their edit appear and has no reason to doubt it.\n *\n * The header memo depends on `columns`, `sort` and the editing state only:\n * `toggleSort` and the commit callbacks are recreated each render but always close\n * over the same setters, so including them would rebuild every header on every\n * render without changing behaviour. That is why `exhaustive-deps` is silenced on\n * that dependency array.\n */\nexport function DataTable<T>({\n data,\n columns,\n pageSize = 10,\n searchable = false,\n searchKeys,\n initialSort,\n rowKey = (_row, index) => index,\n emptyMessage,\n onCellChange,\n editLabels,\n totalItems,\n page: controlledPage,\n onPageChange,\n manualSort,\n onSortChange,\n manualSearch,\n onSearchChange,\n loading = false,\n className,\n ...rest\n}: DataTableProps<T>) {\n const [search, setSearch] = useState<string>(\"\");\n const [sort, setSort] = useState<DataTableSort<T> | null>(initialSort ?? null);\n const { page: internalPage, setPage: setInternalPage } = usePagination(1, pageSize);\n const announce = useAnnounce();\n\n const serverMode = totalItems !== undefined;\n const sortIsManual = manualSort ?? serverMode;\n const searchIsManual = manualSearch ?? serverMode;\n const page = controlledPage ?? internalPage;\n\n const setPage = useCallback(\n (next: number) => {\n if (controlledPage === undefined) setInternalPage(next);\n onPageChange?.(next);\n },\n [controlledPage, setInternalPage, onPageChange],\n );\n\n useDevWarnings({\n serverMode,\n controlledPage,\n onPageChange,\n sortIsManual,\n onSortChange,\n searchable,\n onSearchChange,\n });\n\n const [editing, setEditing] = useState<string | null>(null);\n const [refocus, setRefocus] = useState<string | null>(null);\n const [overrides, setOverrides] = useState<Record<string, unknown>>({});\n const [errors, setErrors] = useState<Record<string, string>>({});\n const [saving, setSaving] = useState<Record<string, boolean>>({});\n\n const labels = useMemo<DataTableEditLabels>(\n () => ({ ...DEFAULT_EDIT_LABELS, ...editLabels }),\n [editLabels],\n );\n const editingEnabled = onCellChange !== undefined && columns.some((column) => column.editable);\n\n const effectiveSearchKeys = useMemo<(keyof T)[]>(() => {\n if (!searchable || searchIsManual) return [];\n if (searchKeys && searchKeys.length > 0) return searchKeys;\n return columns\n .filter((column) => {\n const sample = data.find((row) => row[column.key] != null);\n const value = sample ? sample[column.key] : undefined;\n return typeof value === \"string\" || typeof value === \"number\";\n })\n .map((column) => column.key);\n }, [searchable, searchIsManual, searchKeys, columns, data]);\n\n const filtered = useMemo<T[]>(() => {\n const term = search.trim().toLowerCase();\n if (!term || !searchable || searchIsManual) return data;\n return data.filter((row) =>\n effectiveSearchKeys.some((key) => {\n const value = row[key];\n return value != null && String(value).toLowerCase().includes(term);\n }),\n );\n }, [data, search, searchable, searchIsManual, effectiveSearchKeys]);\n\n const sorted = useMemo<T[]>(() => {\n if (!sort || sortIsManual) return filtered;\n const factor = sort.direction === \"asc\" ? 1 : -1;\n return [...filtered].sort((a, b) => compareValues(a[sort.key], b[sort.key]) * factor);\n }, [filtered, sort, sortIsManual]);\n\n const rowCount = totalItems ?? sorted.length;\n const totalPages = Math.max(1, Math.ceil(rowCount / pageSize));\n\n /**\n * Clamp the current page when the dataset shrinks (e.g. after filtering).\n *\n * Skipped in server mode: `page` belongs to the caller there, and a clamp\n * fired against a `totalItems` that has not caught up with the new filter\n * yet would send them a page they did not ask for, mid-fetch.\n */\n useEffect(() => {\n if (!serverMode && page > totalPages) setPage(totalPages);\n }, [serverMode, page, totalPages, setPage]);\n\n const safePage = serverMode ? page : Math.min(page, totalPages);\n const pageRows = useMemo<T[]>(() => {\n if (serverMode) return sorted;\n const start = (safePage - 1) * pageSize;\n return sorted.slice(start, start + pageSize);\n }, [serverMode, sorted, safePage, pageSize]);\n\n function toggleSort(key: keyof T): void {\n const current = sort;\n const next: DataTableSort<T> | null =\n !current || current.key !== key\n ? { key, direction: \"asc\" }\n : current.direction === \"asc\"\n ? { key, direction: \"desc\" }\n : null;\n setSort(next);\n onSortChange?.(next);\n }\n\n const absoluteIndex = useCallback(\n (pageIndex: number) => (safePage - 1) * pageSize + pageIndex,\n [safePage, pageSize],\n );\n\n /**\n * Every editable cell on the page, row-major — the order `Tab` walks.\n *\n * Row-major and not column-major because a row is the record a user is\n * correcting; walking down a column would make them re-find their place on\n * every keystroke.\n */\n const editableCellIds = useMemo<string[]>(() => {\n if (!editingEnabled) return [];\n const ids: string[] = [];\n pageRows.forEach((row, index) => {\n const key = rowKey(row, absoluteIndex(index));\n for (const column of columns) {\n if (column.editable) ids.push(cellId(key, column.key));\n }\n });\n return ids;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [editingEnabled, pageRows, columns, absoluteIndex]);\n\n const displayed = useCallback(\n (row: T, column: DataTableColumn<T>, id: string): unknown =>\n id in overrides ? overrides[id] : row[column.key],\n [overrides],\n );\n\n /**\n * Run the caller's `onCellChange` behind the optimistic update.\n *\n * Only the *success* is announced. The failure already renders as a\n * `role=\"alert\"` inside the cell, which screen readers read on insertion —\n * announcing it again from the shared region would read it twice and put the\n * same text in the document twice.\n */\n const persist = useCallback(\n async (id: string, column: DataTableColumn<T>, change: DataTableCellChange<T>) => {\n setSaving((current) => ({ ...current, [id]: true }));\n try {\n await onCellChange?.(change);\n announce(labels.saved(headerText(column)));\n } catch (error) {\n setOverrides((current) => {\n const next = { ...current };\n delete next[id];\n return next;\n });\n const message =\n error instanceof Error && error.message\n ? error.message\n : labels.saveFailed(headerText(column));\n setErrors((current) => ({ ...current, [id]: message }));\n } finally {\n setSaving((current) => {\n const next = { ...current };\n delete next[id];\n return next;\n });\n }\n },\n [onCellChange, announce, labels],\n );\n\n const moveFrom = useCallback(\n (id: string, move: CellCommitMove): void => {\n if (move === \"none\") {\n setEditing(null);\n setRefocus(id);\n return;\n }\n const index = editableCellIds.indexOf(id);\n const target = editableCellIds[index + (move === \"next\" ? 1 : -1)];\n if (target === undefined) {\n setEditing(null);\n setRefocus(id);\n return;\n }\n setEditing(target);\n setRefocus(null);\n },\n [editableCellIds],\n );\n\n /**\n * Parse, validate, stage optimistically, then save in the background.\n *\n * Validation runs before anything is staged, and a rejection leaves the editor\n * open with the message attached to the input — the user has to be able to fix\n * what they typed without retyping it.\n */\n const commit = useCallback(\n (\n row: T,\n column: DataTableColumn<T>,\n id: string,\n pageIndex: number,\n raw: string,\n move: CellCommitMove,\n ): void => {\n const previous = displayed(row, column, id);\n const currentText = column.formatEdit ? column.formatEdit(row) : String(previous ?? \"\");\n if (raw === currentText) {\n moveFrom(id, move);\n return;\n }\n\n const value = column.parse\n ? column.parse(raw, row)\n : column.editorType === \"number\"\n ? Number(raw)\n : raw.trim();\n\n const invalid = column.validate?.(value, row) ?? null;\n if (invalid) {\n setErrors((current) => ({ ...current, [id]: invalid }));\n return;\n }\n\n setErrors((current) => {\n const next = { ...current };\n delete next[id];\n return next;\n });\n setOverrides((current) => ({ ...current, [id]: value }));\n moveFrom(id, move);\n void persist(id, column, {\n row,\n key: column.key,\n value,\n previous,\n rowIndex: absoluteIndex(pageIndex),\n });\n },\n [displayed, moveFrom, persist, absoluteIndex],\n );\n\n const tableColumns = useMemo<TableColumn<T>[]>(\n () =>\n columns.map((column) => {\n const isSorted = sort?.key === column.key;\n const indicator = isSorted ? (sort?.direction === \"asc\" ? \" ▲\" : \" ▼\") : \"\";\n const header = column.sortable ? (\n <button\n type=\"button\"\n className={styles.sortButton}\n onClick={() => toggleSort(column.key)}\n aria-label={`Ordenar por ${headerText(column)}`}\n >\n {column.header}\n <span className={styles.sortIndicator} aria-hidden>\n {indicator}\n </span>\n </button>\n ) : (\n column.header\n );\n\n const plainCell = (row: T): ReactNode => {\n if (column.render) return column.render(row);\n return (row[column.key] as ReactNode) ?? null;\n };\n\n /**\n * Render an editable cell's content against the optimistic value.\n *\n * The row is shallow-patched rather than the value passed alongside it,\n * because a column with a custom `render` (a `<Money>`, a badge) reads\n * the row — handing it the stale row would show the old number under a\n * cell the user just changed.\n */\n const patchedCell = (row: T, value: unknown): ReactNode => {\n const patched = { ...row, [column.key]: value } as T;\n if (column.render) return column.render(patched);\n return (patched[column.key] as ReactNode) ?? null;\n };\n\n const editable = editingEnabled && column.editable === true;\n\n return {\n key: String(column.key),\n header,\n align: column.align,\n priority: column.priority,\n width: column.width,\n render: editable\n ? (row: T, index: number) => {\n const id = cellId(rowKey(row, absoluteIndex(index)), column.key);\n const value = displayed(row, column, id);\n const text = column.formatEdit\n ? column.formatEdit(row)\n : String(value ?? \"\");\n return (\n <EditableCell\n text={text}\n columnLabel={headerText(column)}\n rowNumber={index + 1}\n inputType={column.editorType ?? \"text\"}\n editing={editing === id}\n refocus={refocus === id}\n saving={saving[id] === true}\n error={errors[id] ?? null}\n errorId={`tempest-cell-error-${id.replace(/[^\\w-]/g, \"_\")}`}\n labels={labels}\n onOpen={() => {\n setEditing(id);\n setRefocus(null);\n }}\n onCommit={(raw, move) =>\n commit(row, column, id, index, raw, move)\n }\n onCancel={() => {\n setEditing(null);\n setRefocus(id);\n setErrors((current) => {\n const next = { ...current };\n delete next[id];\n return next;\n });\n }}\n >\n {patchedCell(row, value)}\n </EditableCell>\n );\n }\n : plainCell,\n };\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [\n columns,\n sort,\n editingEnabled,\n editing,\n refocus,\n saving,\n errors,\n labels,\n overrides,\n absoluteIndex,\n commit,\n ],\n );\n\n const showSkeleton = loading && pageRows.length === 0;\n\n return (\n <div className={cn(styles.wrapper, className)} {...rest}>\n {searchable && (\n <SearchBar\n value={search}\n onChange={(value) => {\n setSearch(value);\n setPage(1);\n onSearchChange?.(value);\n }}\n wrapperClassName={styles.search}\n />\n )}\n <div\n className={cn(loading && !showSkeleton && styles.pending)}\n aria-busy={loading || undefined}\n data-testid=\"tempest-datatable-body\"\n >\n {showSkeleton ? (\n <LoadingRows columns={tableColumns.length} rows={Math.min(pageSize, 8)} />\n ) : (\n <Table\n columns={tableColumns}\n data={pageRows}\n rowKey={(row, index) => rowKey(row, absoluteIndex(index))}\n emptyMessage={emptyMessage}\n />\n )}\n </div>\n {totalPages > 1 && (\n <Pagination\n page={safePage}\n totalPages={totalPages}\n onPageChange={setPage}\n totalItems={rowCount}\n />\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAwQA,SAAS,GAAO,GAA8B,GAAgC;CAC1E,OAAO,GAAG,OAAO,CAAW,EAAE,IA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K,CAAI;KAE5C,gBAAgB;MAGZ,AAFA,EAAW,IAAI,GACf,EAAW,CAAE,GACb,GAAW,MAAY;OACnB,IAAM,IAAO,EAAE,GAAG,EAAQ;OAE1B,OADA,OAAO,EAAK,IACL;MACX,CAAC;KACL;KAEC,UAAA,EAAY,GAAK,CAAK;IACb,CAAA;GAEtB,IACA;EACV;CACJ,CAAC,GAEL;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACJ,CACJ,GAEM,IAAe,KAAW,EAAS,WAAW;CAEpD,OACI,kBAAC,OAAD;EAAK,WAAW,EAAG,EAAO,SAAS,EAAS;EAAG,GAAI;EAAnD,UAAA;GACK,KACG,kBAAC,GAAD;IACI,OAAO;IACP,WAAW,MAAU;KAGjB,AAFA,GAAU,CAAK,GACf,EAAQ,CAAC,GACT,IAAiB,CAAK;IAC1B;IACA,kBAAkB,EAAO;GAC5B,CAAA;GAEL,kBAAC,OAAD;IACI,WAAW,EAAG,KAAW,CAAC,KAAgB,EAAO,OAAO;IACxD,aAAW,KAAW,KAAA;IACtB,eAAY;IAEX,UAAA,IACG,kBAAC,IAAD;KAAa,SAAS,GAAa;KAAQ,MAAM,KAAK,IAAI,GAAU,CAAC;IAAI,CAAA,IAEzE,kBAAC,GAAD;KACI,SAAS;KACT,MAAM;KACN,SAAS,GAAK,MAAU,EAAO,GAAK,EAAc,CAAK,CAAC;KAC1C;IACjB,CAAA;GAEJ,CAAA;GACJ,IAAa,KACV,kBAAC,GAAD;IACI,MAAM;IACM;IACZ,cAAc;IACd,YAAY;GACf,CAAA;EAEJ;;AAEb"}
1
+ {"version":3,"file":"DataTable.js","names":[],"sources":["../../../src/components/DataTable/DataTable.tsx"],"sourcesContent":["/**\n * @tempest-limits file-lines, props-count, function-lines — the table does four jobs\n * a caller turns on independently — paging (pageSize), search (searchable,\n * searchKeys), sort (initialSort) and inline edit (onCellChange, editLabels) — over\n * one row model (data, columns, rowKey, emptyMessage). The body is long because\n * those four share the derived-rows pipeline: filter, then sort, then page, then map\n * to cells, in that order and off the same memo.\n *\n * Each of the four also runs in a second mode, where the caller owns the work and\n * the table only reports intent: totalItems/page/onPageChange, onSearchChange,\n * manualSort/onSortChange, loading/loadingRows. That doubles the props without\n * adding a fifth job — every manual prop short-circuits one stage of the same\n * pipeline.\n */\nimport { useCallback, useEffect, useMemo, useState } from \"react\";\nimport type { HTMLAttributes, ReactNode } from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport { compareValues } from \"@/utils/compare-values\";\nimport { usePagination } from \"@/hooks\";\nimport { useAnnounce } from \"@/hooks/use-announce\";\nimport { Table, type TableAlign, type TableColumn, type TablePriority } from \"../Table\";\nimport { Pagination } from \"../Pagination\";\nimport { SearchBar } from \"../SearchBar\";\nimport { EditableCell } from \"./EditableCell\";\nimport { LoadingRows } from \"./LoadingRows\";\nimport { useDevWarnings } from \"./use-dev-warnings\";\nimport { DEFAULT_EDIT_LABELS, type CellCommitMove, type DataTableEditLabels } from \"./edit-labels\";\nimport styles from \"./DataTable.module.css\";\n\nexport type SortDirection = \"asc\" | \"desc\";\n\nexport interface DataTableSort<T> {\n key: keyof T;\n direction: SortDirection;\n}\n\n/** Input types an editable column can use. */\nexport type DataTableEditorType = \"text\" | \"number\" | \"date\" | \"email\" | \"tel\" | \"url\";\n\n/** One accepted cell edit, handed to `onCellChange`. */\nexport interface DataTableCellChange<T> {\n /** The row as it was before the edit. */\n row: T;\n /** Which column changed. */\n key: keyof T;\n /** The parsed new value. */\n value: unknown;\n /** The value that was displayed before the edit. */\n previous: unknown;\n /** Index of the row in the full `data` array. */\n rowIndex: number;\n}\n\n/**\n * Column definition for {@link DataTable}. Extends the headless {@link Table}\n * column shape with a typed `key`, opt-in sorting, opt-in inline editing, and the\n * visual options that are forwarded to the underlying Table cell.\n */\nexport interface DataTableColumn<T> {\n /** Property of the row this column reads from. Doubles as the cell key. */\n key: keyof T;\n /** Column heading. */\n header: ReactNode;\n /** Custom cell renderer. Defaults to `String(row[key])`. */\n render?: (row: T) => ReactNode;\n /** Enable click-to-sort on this column's header. */\n sortable?: boolean;\n /** Text alignment forwarded to the Table cell. */\n align?: TableAlign;\n /** Responsive visibility priority forwarded to the Table cell. */\n priority?: TablePriority;\n /** Fixed column width forwarded to the Table cell. */\n width?: string | number;\n /**\n * Let cells in this column be edited in place. Requires `onCellChange` on the\n * table; without it the column stays read-only.\n */\n editable?: boolean;\n /** Editor input type. Default `\"text\"`. */\n editorType?: DataTableEditorType;\n /** Text the editor opens with. Defaults to `String(value ?? \"\")`. */\n formatEdit?: (row: T) => string;\n /**\n * Turn the typed string into the stored value. Defaults to the trimmed string,\n * or `Number(raw)` when `editorType` is `\"number\"`.\n */\n parse?: (raw: string, row: T) => unknown;\n /** Return a message to reject the edit, or `null` to accept it. */\n validate?: (value: unknown, row: T) => string | null;\n}\n\n/** Everything a table needs regardless of who owns paging, sorting and searching. */\nexport interface DataTableBaseProps<T> extends HTMLAttributes<HTMLDivElement> {\n /**\n * The rows to work with.\n *\n * By default this is the **full** dataset and sorting, searching and paging\n * all happen in memory. Pass `totalItems` and it becomes the current page as\n * the server returned it, with those three delegated to the caller.\n */\n data: T[];\n /** Column definitions. */\n columns: DataTableColumn<T>[];\n /** Rows per page. Default 10. */\n pageSize?: number;\n /** Render a search input above the table. Default false. */\n searchable?: boolean;\n /**\n * Keys to match the search term against. When omitted, every column whose\n * value is a string or number is searched.\n */\n searchKeys?: (keyof T)[];\n /** Initial sort applied before any header interaction. */\n initialSort?: DataTableSort<T>;\n /** Stable key extractor for rows. Defaults to the row index. */\n rowKey?: (row: T, index: number) => string | number;\n /** Content shown when no rows match. */\n emptyMessage?: ReactNode;\n /**\n * Persist an accepted cell edit. Return a promise: while it is pending the cell\n * already shows the new value, and a rejection rolls that back and surfaces the\n * error in the cell. Without this prop no column is editable.\n */\n onCellChange?: (change: DataTableCellChange<T>) => void | Promise<void>;\n /** Override the PT-BR copy of the editing affordances. */\n editLabels?: Partial<DataTableEditLabels>;\n /**\n * A fetch is in flight.\n *\n * With rows already on screen they stay put, dimmed and `aria-busy`, so the\n * page does not jump under the cursor between pages. With no rows yet it\n * renders placeholder lines at full height, which is a different statement\n * from `emptyMessage`: \"loading\" and \"there is nothing\" are not the same\n * screen.\n */\n loading?: boolean;\n}\n\n/**\n * Paging, as one of the three shapes that actually work.\n *\n * These used to be three optional props, so the compiler accepted\n * `totalItems` with no `page` — a table whose pager moves an internal page while\n * `data` keeps showing page one. Every prop was optional on its own, so the only\n * place left to catch it was a `console.warn` in dev, in the browser, with the\n * component mounted. As a union the same mistake is a build error at the call\n * site, for free, everywhere.\n */\nexport type DataTablePagingProps =\n | {\n /** Not server mode. */\n totalItems?: never;\n /** The table owns the page. */\n page?: never;\n /** Nothing to report to. */\n onPageChange?: never;\n }\n | {\n /**\n * Total row count across every page — the `total` of a paginated envelope.\n *\n * Passing it switches the table to **server mode**: `data` is read as the\n * current page, the page count comes from this number instead of\n * `data.length`, and sorting and searching are delegated to the caller\n * (see `manualSort` / `manualSearch`, which are implied here). Pair it with\n * `page` and `onPageChange`.\n */\n totalItems?: never;\n /** Current page, 1-based. Controlled — required in server mode. */\n page: number;\n /** Called with the next page. Required whenever `page` is controlled. */\n onPageChange: (page: number) => void;\n }\n | {\n /**\n * Total row count across every page — the `total` of a paginated envelope.\n *\n * Passing it switches the table to **server mode**: `data` is read as the\n * current page, the page count comes from this number instead of\n * `data.length`, and sorting and searching are delegated to the caller\n * (see `manualSort` / `manualSearch`, which are implied here). `page` and\n * `onPageChange` come with it — the type says so, because a server-mode\n * table without them silently shows page one forever.\n */\n totalItems: number;\n /** Current page, 1-based. Controlled, and required in server mode. */\n page: number;\n /** Called with the next page. */\n onPageChange: (page: number) => void;\n };\n\n/**\n * Sorting: delegated, and therefore reported, or neither.\n *\n * `manualSort` without `onSortChange` renders a header that moves its arrow and\n * changes nothing else — the arrow is a lie the compiler can now catch.\n */\nexport type DataTableSortProps<T> =\n | {\n /** The table sorts the rows it has. */\n manualSort?: false;\n /** Called with the next sort state — `null` when the header cycles back to unsorted. */\n onSortChange?: (sort: DataTableSort<T> | null) => void;\n }\n | {\n /**\n * Sorting is the caller's job: clicking a header reports through\n * `onSortChange` and the rows are left in the order they arrived.\n *\n * Implied by `totalItems`, because sorting the page in memory would sort\n * *that page only* while the header claims the whole table is ordered.\n */\n manualSort: true;\n /** Where the click goes. Required, since nothing else acts on it. */\n onSortChange: (sort: DataTableSort<T> | null) => void;\n };\n\n/**\n * Searching: delegated, and therefore reported, or neither.\n *\n * `manualSearch` without `onSearchChange` renders a search box that filters\n * nothing and tells nobody — the same shape of lie as a header arrow that turns\n * without sorting.\n *\n * Independent of the paging axis on purpose, and that leaves one gap this type\n * does not close: `totalItems` *implies* `manualSearch`, so a server-mode table\n * with `searchable` and no `onSearchChange` falls into the same hole without ever\n * writing `manualSearch`. Closing it means the search axis has to read the paging\n * axis, which crosses two three-member unions into nine and turns every mismatch\n * into a wall of candidate shapes. That case is a dev warning instead — the one\n * spot where runtime really is the cheaper check, and `use-dev-warnings.ts` says\n * so at the call site.\n */\nexport type DataTableSearchProps =\n | {\n /** The table filters the rows it has. */\n manualSearch?: false;\n /** Called with the current search term (debouncing, if any, is the caller's). */\n onSearchChange?: (term: string) => void;\n }\n | {\n /**\n * Searching is the caller's job: typing reports through `onSearchChange`\n * and the rows are left as they arrived.\n *\n * Implied by `totalItems`. Filtering the current page would hide the rows\n * that do not match *on this page* and show nothing for a term that only\n * matches on page three — an empty table that looks like \"no results\".\n */\n manualSearch: true;\n /** Where the typing goes. Required, since nothing else acts on it. */\n onSearchChange: (term: string) => void;\n };\n\n/**\n * The table's props: the shared half, plus one valid paging shape and one valid\n * sorting shape.\n */\nexport type DataTableProps<T> = DataTableBaseProps<T> &\n DataTablePagingProps &\n DataTableSortProps<T> &\n DataTableSearchProps;\n\n/** Identity of one cell, stable across re-renders and pagination. */\nfunction cellId(rowKeyValue: string | number, columnKey: PropertyKey): string {\n return `${String(rowKeyValue)}::${String(columnKey)}`;\n}\n\nfunction headerText<T>(column: DataTableColumn<T>): string {\n return typeof column.header === \"string\" ? column.header : String(column.key);\n}\n\n/**\n * Stateful, headless data table built on top of {@link Table}. Adds\n * client-side searching, click-to-sort columns, pagination and opt-in inline\n * editing while delegating all table markup to the underlying Table component.\n *\n * - Clicking a sortable header cycles asc → desc → unsorted.\n * - Search matches a case-insensitive substring across `searchKeys`\n * (or every string/number column when not provided).\n * - Pagination is hidden when the result fits on a single page.\n * - A column with `editable` renders a button that opens an inline editor;\n * `Enter` commits, `Escape` discards, `Tab` walks to the next editable cell.\n *\n * Editing is strictly opt-in: with no `editable` column (or no `onCellChange`) the\n * rendered markup is byte-for-byte what it was before the feature existed, which\n * matters because the component is published.\n *\n * ## Optimistic, with a visible rollback\n *\n * An accepted edit is shown immediately and `onCellChange` runs in the background.\n * If it rejects, the cell returns to the old value **and** shows the reason as a\n * `role=\"alert\"` tied to the cell. A silent revert is worse than no optimistic\n * update at all: the user watched their edit appear and has no reason to doubt it.\n *\n * The header memo depends on `columns`, `sort` and the editing state only:\n * `toggleSort` and the commit callbacks are recreated each render but always close\n * over the same setters, so including them would rebuild every header on every\n * render without changing behaviour. That is why `exhaustive-deps` is silenced on\n * that dependency array.\n */\nexport function DataTable<T>({\n data,\n columns,\n pageSize = 10,\n searchable = false,\n searchKeys,\n initialSort,\n rowKey = (_row, index) => index,\n emptyMessage,\n onCellChange,\n editLabels,\n totalItems,\n page: controlledPage,\n onPageChange,\n manualSort,\n onSortChange,\n manualSearch,\n onSearchChange,\n loading = false,\n className,\n ...rest\n}: DataTableProps<T>) {\n const [search, setSearch] = useState<string>(\"\");\n const [sort, setSort] = useState<DataTableSort<T> | null>(initialSort ?? null);\n const { page: internalPage, setPage: setInternalPage } = usePagination(1, pageSize);\n const announce = useAnnounce();\n\n const serverMode = totalItems !== undefined;\n const sortIsManual = manualSort ?? serverMode;\n const searchIsManual = manualSearch ?? serverMode;\n const page = controlledPage ?? internalPage;\n\n const setPage = useCallback(\n (next: number) => {\n if (controlledPage === undefined) setInternalPage(next);\n onPageChange?.(next);\n },\n [controlledPage, setInternalPage, onPageChange],\n );\n\n useDevWarnings({\n serverMode,\n controlledPage,\n onPageChange,\n sortIsManual,\n hasSortableColumn: columns.some((column) => column.sortable),\n onSortChange,\n searchable,\n onSearchChange,\n });\n\n const [editing, setEditing] = useState<string | null>(null);\n const [refocus, setRefocus] = useState<string | null>(null);\n const [overrides, setOverrides] = useState<Record<string, unknown>>({});\n const [errors, setErrors] = useState<Record<string, string>>({});\n const [saving, setSaving] = useState<Record<string, boolean>>({});\n\n const labels = useMemo<DataTableEditLabels>(\n () => ({ ...DEFAULT_EDIT_LABELS, ...editLabels }),\n [editLabels],\n );\n const editingEnabled = onCellChange !== undefined && columns.some((column) => column.editable);\n\n const effectiveSearchKeys = useMemo<(keyof T)[]>(() => {\n if (!searchable || searchIsManual) return [];\n if (searchKeys && searchKeys.length > 0) return searchKeys;\n return columns\n .filter((column) => {\n const sample = data.find((row) => row[column.key] != null);\n const value = sample ? sample[column.key] : undefined;\n return typeof value === \"string\" || typeof value === \"number\";\n })\n .map((column) => column.key);\n }, [searchable, searchIsManual, searchKeys, columns, data]);\n\n const filtered = useMemo<T[]>(() => {\n const term = search.trim().toLowerCase();\n if (!term || !searchable || searchIsManual) return data;\n return data.filter((row) =>\n effectiveSearchKeys.some((key) => {\n const value = row[key];\n return value != null && String(value).toLowerCase().includes(term);\n }),\n );\n }, [data, search, searchable, searchIsManual, effectiveSearchKeys]);\n\n const sorted = useMemo<T[]>(() => {\n if (!sort || sortIsManual) return filtered;\n const factor = sort.direction === \"asc\" ? 1 : -1;\n return [...filtered].sort((a, b) => compareValues(a[sort.key], b[sort.key]) * factor);\n }, [filtered, sort, sortIsManual]);\n\n const rowCount = totalItems ?? sorted.length;\n const totalPages = Math.max(1, Math.ceil(rowCount / pageSize));\n\n /**\n * Clamp the current page when the dataset shrinks (e.g. after filtering).\n *\n * Skipped in server mode: `page` belongs to the caller there, and a clamp\n * fired against a `totalItems` that has not caught up with the new filter\n * yet would send them a page they did not ask for, mid-fetch.\n */\n useEffect(() => {\n if (!serverMode && page > totalPages) setPage(totalPages);\n }, [serverMode, page, totalPages, setPage]);\n\n const safePage = serverMode ? page : Math.min(page, totalPages);\n const pageRows = useMemo<T[]>(() => {\n if (serverMode) return sorted;\n const start = (safePage - 1) * pageSize;\n return sorted.slice(start, start + pageSize);\n }, [serverMode, sorted, safePage, pageSize]);\n\n function toggleSort(key: keyof T): void {\n const current = sort;\n const next: DataTableSort<T> | null =\n !current || current.key !== key\n ? { key, direction: \"asc\" }\n : current.direction === \"asc\"\n ? { key, direction: \"desc\" }\n : null;\n setSort(next);\n onSortChange?.(next);\n }\n\n const absoluteIndex = useCallback(\n (pageIndex: number) => (safePage - 1) * pageSize + pageIndex,\n [safePage, pageSize],\n );\n\n /**\n * Every editable cell on the page, row-major — the order `Tab` walks.\n *\n * Row-major and not column-major because a row is the record a user is\n * correcting; walking down a column would make them re-find their place on\n * every keystroke.\n */\n const editableCellIds = useMemo<string[]>(() => {\n if (!editingEnabled) return [];\n const ids: string[] = [];\n pageRows.forEach((row, index) => {\n const key = rowKey(row, absoluteIndex(index));\n for (const column of columns) {\n if (column.editable) ids.push(cellId(key, column.key));\n }\n });\n return ids;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [editingEnabled, pageRows, columns, absoluteIndex]);\n\n const displayed = useCallback(\n (row: T, column: DataTableColumn<T>, id: string): unknown =>\n id in overrides ? overrides[id] : row[column.key],\n [overrides],\n );\n\n /**\n * Run the caller's `onCellChange` behind the optimistic update.\n *\n * Only the *success* is announced. The failure already renders as a\n * `role=\"alert\"` inside the cell, which screen readers read on insertion —\n * announcing it again from the shared region would read it twice and put the\n * same text in the document twice.\n */\n const persist = useCallback(\n async (id: string, column: DataTableColumn<T>, change: DataTableCellChange<T>) => {\n setSaving((current) => ({ ...current, [id]: true }));\n try {\n await onCellChange?.(change);\n announce(labels.saved(headerText(column)));\n } catch (error) {\n setOverrides((current) => {\n const next = { ...current };\n delete next[id];\n return next;\n });\n const message =\n error instanceof Error && error.message\n ? error.message\n : labels.saveFailed(headerText(column));\n setErrors((current) => ({ ...current, [id]: message }));\n } finally {\n setSaving((current) => {\n const next = { ...current };\n delete next[id];\n return next;\n });\n }\n },\n [onCellChange, announce, labels],\n );\n\n const moveFrom = useCallback(\n (id: string, move: CellCommitMove): void => {\n if (move === \"none\") {\n setEditing(null);\n setRefocus(id);\n return;\n }\n const index = editableCellIds.indexOf(id);\n const target = editableCellIds[index + (move === \"next\" ? 1 : -1)];\n if (target === undefined) {\n setEditing(null);\n setRefocus(id);\n return;\n }\n setEditing(target);\n setRefocus(null);\n },\n [editableCellIds],\n );\n\n /**\n * Parse, validate, stage optimistically, then save in the background.\n *\n * Validation runs before anything is staged, and a rejection leaves the editor\n * open with the message attached to the input — the user has to be able to fix\n * what they typed without retyping it.\n */\n const commit = useCallback(\n (\n row: T,\n column: DataTableColumn<T>,\n id: string,\n pageIndex: number,\n raw: string,\n move: CellCommitMove,\n ): void => {\n const previous = displayed(row, column, id);\n const currentText = column.formatEdit ? column.formatEdit(row) : String(previous ?? \"\");\n if (raw === currentText) {\n moveFrom(id, move);\n return;\n }\n\n const value = column.parse\n ? column.parse(raw, row)\n : column.editorType === \"number\"\n ? Number(raw)\n : raw.trim();\n\n const invalid = column.validate?.(value, row) ?? null;\n if (invalid) {\n setErrors((current) => ({ ...current, [id]: invalid }));\n return;\n }\n\n setErrors((current) => {\n const next = { ...current };\n delete next[id];\n return next;\n });\n setOverrides((current) => ({ ...current, [id]: value }));\n moveFrom(id, move);\n void persist(id, column, {\n row,\n key: column.key,\n value,\n previous,\n rowIndex: absoluteIndex(pageIndex),\n });\n },\n [displayed, moveFrom, persist, absoluteIndex],\n );\n\n const tableColumns = useMemo<TableColumn<T>[]>(\n () =>\n columns.map((column) => {\n const isSorted = sort?.key === column.key;\n const indicator = isSorted ? (sort?.direction === \"asc\" ? \" ▲\" : \" ▼\") : \"\";\n const header = column.sortable ? (\n <button\n type=\"button\"\n className={styles.sortButton}\n onClick={() => toggleSort(column.key)}\n aria-label={`Ordenar por ${headerText(column)}`}\n >\n {column.header}\n <span className={styles.sortIndicator} aria-hidden>\n {indicator}\n </span>\n </button>\n ) : (\n column.header\n );\n\n const plainCell = (row: T): ReactNode => {\n if (column.render) return column.render(row);\n return (row[column.key] as ReactNode) ?? null;\n };\n\n /**\n * Render an editable cell's content against the optimistic value.\n *\n * The row is shallow-patched rather than the value passed alongside it,\n * because a column with a custom `render` (a `<Money>`, a badge) reads\n * the row — handing it the stale row would show the old number under a\n * cell the user just changed.\n */\n const patchedCell = (row: T, value: unknown): ReactNode => {\n const patched = { ...row, [column.key]: value } as T;\n if (column.render) return column.render(patched);\n return (patched[column.key] as ReactNode) ?? null;\n };\n\n const editable = editingEnabled && column.editable === true;\n\n return {\n key: String(column.key),\n header,\n align: column.align,\n priority: column.priority,\n width: column.width,\n render: editable\n ? (row: T, index: number) => {\n const id = cellId(rowKey(row, absoluteIndex(index)), column.key);\n const value = displayed(row, column, id);\n const text = column.formatEdit\n ? column.formatEdit(row)\n : String(value ?? \"\");\n return (\n <EditableCell\n text={text}\n columnLabel={headerText(column)}\n rowNumber={index + 1}\n inputType={column.editorType ?? \"text\"}\n editing={editing === id}\n refocus={refocus === id}\n saving={saving[id] === true}\n error={errors[id] ?? null}\n errorId={`tempest-cell-error-${id.replace(/[^\\w-]/g, \"_\")}`}\n labels={labels}\n onOpen={() => {\n setEditing(id);\n setRefocus(null);\n }}\n onCommit={(raw, move) =>\n commit(row, column, id, index, raw, move)\n }\n onCancel={() => {\n setEditing(null);\n setRefocus(id);\n setErrors((current) => {\n const next = { ...current };\n delete next[id];\n return next;\n });\n }}\n >\n {patchedCell(row, value)}\n </EditableCell>\n );\n }\n : plainCell,\n };\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [\n columns,\n sort,\n editingEnabled,\n editing,\n refocus,\n saving,\n errors,\n labels,\n overrides,\n absoluteIndex,\n commit,\n ],\n );\n\n const showSkeleton = loading && pageRows.length === 0;\n\n return (\n <div className={cn(styles.wrapper, className)} {...rest}>\n {searchable && (\n <SearchBar\n value={search}\n onChange={(value) => {\n setSearch(value);\n setPage(1);\n onSearchChange?.(value);\n }}\n wrapperClassName={styles.search}\n />\n )}\n <div\n className={cn(loading && !showSkeleton && styles.pending)}\n aria-busy={loading || undefined}\n data-testid=\"tempest-datatable-body\"\n >\n {showSkeleton ? (\n <LoadingRows columns={tableColumns.length} rows={Math.min(pageSize, 8)} />\n ) : (\n <Table\n columns={tableColumns}\n data={pageRows}\n rowKey={(row, index) => rowKey(row, absoluteIndex(index))}\n emptyMessage={emptyMessage}\n />\n )}\n </div>\n {totalPages > 1 && (\n <Pagination\n page={safePage}\n totalPages={totalPages}\n onPageChange={setPage}\n totalItems={rowCount}\n />\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAwQA,SAAS,GAAO,GAA8B,GAAgC;CAC1E,OAAO,GAAG,OAAO,CAAW,EAAE,IAAI,OAAO,CAAS;AACtD;AAEA,SAAS,EAAc,GAAoC;CACvD,OAAO,OAAO,EAAO,UAAW,WAAW,EAAO,SAAS,OAAO,EAAO,GAAG;AAChF;AA+BA,SAAgB,EAAa,EACzB,SACA,YACA,cAAW,IACX,gBAAa,IACb,eACA,iBACA,aAAU,GAAM,MAAU,GAC1B,kBACA,iBACA,gBACA,gBACA,MAAM,GACN,iBACA,gBACA,kBACA,kBACA,mBACA,aAAU,IACV,eACA,GAAG,MACe;CAClB,IAAM,CAAC,GAAQ,MAAa,EAAiB,EAAE,GACzC,CAAC,GAAM,MAAW,EAAkC,MAAe,IAAI,GACvE,EAAE,MAAM,IAAc,SAAS,OAAoB,EAAc,GAAG,CAAQ,GAC5E,KAAW,EAAY,GAEvB,IAAa,OAAe,KAAA,GAC5B,IAAe,MAAc,GAC7B,IAAiB,MAAgB,GACjC,IAAO,KAAkB,IAEzB,IAAU,GACX,MAAiB;EAEd,AADI,MAA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kBAAkB,EAAO;GAC5B,CAAA;GAEL,kBAAC,OAAD;IACI,WAAW,EAAG,KAAW,CAAC,KAAgB,EAAO,OAAO;IACxD,aAAW,KAAW,KAAA;IACtB,eAAY;IAEX,UAAA,IACG,kBAAC,IAAD;KAAa,SAAS,GAAa;KAAQ,MAAM,KAAK,IAAI,GAAU,CAAC;IAAI,CAAA,IAEzE,kBAAC,GAAD;KACI,SAAS;KACT,MAAM;KACN,SAAS,GAAK,MAAU,EAAO,GAAK,EAAc,CAAK,CAAC;KAC1C;IACjB,CAAA;GAEJ,CAAA;GACJ,IAAa,KACV,kBAAC,GAAD;IACI,MAAM;IACM;IACZ,cAAc;IACd,YAAY;GACf,CAAA;EAEJ;;AAEb"}
@@ -1,2 +1,2 @@
1
- const e=require("../../utils/dev-mode.cjs");let t=require("react");function n({serverMode:n,controlledPage:r,onPageChange:i,sortIsManual:a,onSortChange:o,searchable:s,onSearchChange:c}){(0,t.useEffect)(()=>{e.isDevBuild()&&(n&&r===void 0&&console.warn("[tempest] <DataTable totalItems> is server mode, which needs a controlled `page`. Without it the pager moves the internal page while `data` keeps showing page 1."),r!==void 0&&!i&&console.warn("[tempest] <DataTable page> is controlled but `onPageChange` is missing, so the pager cannot do anything."),n&&s&&!c&&console.warn("[tempest] <DataTable totalItems searchable> delegates searching, so the box needs `onSearchChange`. Without it the user types and nothing filters and nothing is reported."),a&&!o&&console.warn("[tempest] <DataTable> is sorting manually but `onSortChange` is missing: clicking a sortable header changes the arrow and nothing else."))},[n,r,i,a,o,s,c])}exports.useDevWarnings=n;
1
+ const e=require("../../utils/dev-mode.cjs");let t=require("react");function n({serverMode:n,controlledPage:r,onPageChange:i,sortIsManual:a,hasSortableColumn:o,onSortChange:s,searchable:c,onSearchChange:l}){(0,t.useEffect)(()=>{e.isDevBuild()&&(n&&r===void 0&&console.warn("[tempest] <DataTable totalItems> is server mode, which needs a controlled `page`. Without it the pager moves the internal page while `data` keeps showing page 1."),r!==void 0&&!i&&console.warn("[tempest] <DataTable page> is controlled but `onPageChange` is missing, so the pager cannot do anything."),n&&c&&!l&&console.warn("[tempest] <DataTable totalItems searchable> delegates searching, so the box needs `onSearchChange`. Without it the user types and nothing filters and nothing is reported."),a&&o&&!s&&console.warn("[tempest] <DataTable> is sorting manually but `onSortChange` is missing: clicking a sortable header changes the arrow and nothing else."))},[n,r,i,a,o,s,c,l])}exports.useDevWarnings=n;
2
2
  //# sourceMappingURL=use-dev-warnings.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-dev-warnings.cjs","names":[],"sources":["../../../src/components/DataTable/use-dev-warnings.ts"],"sourcesContent":["import { useEffect } from \"react\";\n\nimport { isDevBuild } from \"../../utils/dev-mode\";\n\n/** What {@link useDevWarnings} needs to judge the prop combination. */\nexport interface DataTableDevWarningsInput {\n /** Whether `totalItems` was passed. */\n serverMode: boolean;\n /** The controlled `page`, if any. */\n controlledPage: number | undefined;\n /** The page callback, if any. */\n onPageChange: ((page: number) => void) | undefined;\n /** Whether sorting is delegated. */\n sortIsManual: boolean;\n /** The sort callback, if any. */\n onSortChange: ((sort: never) => void) | undefined;\n /** Whether a search box is rendered at all. */\n searchable: boolean;\n /** The search callback, if any. */\n onSearchChange: ((term: string) => void) | undefined;\n}\n\n/**\n * Warn, in development only, about prop combinations that render a table which\n * silently lies.\n *\n * Each of these produces a screen that looks like it works: the header sorts and\n * nothing moves, the pager renders and clicking it does nothing.\n *\n * Three of them **are** type errors now — `DataTablePagingProps`,\n * `DataTableSortProps` and `DataTableSearchProps` reject them at the call site —\n * so those warnings only reach a caller the types cannot: plain JavaScript, or\n * props arriving through an `any`-typed spread.\n *\n * The fourth is the one the types genuinely cannot afford. `totalItems` *implies*\n * `manualSearch`, so `searchable` with no `onSearchChange` is an inert search box\n * in server mode without anybody writing `manualSearch`. Expressing that means\n * the search axis has to read the paging axis, crossing two three-member unions\n * into nine — so it stays here, which is what \"runtime is the cheaper check\"\n * actually looks like when it is true.\n *\n * @param input - The resolved prop combination.\n */\nexport function useDevWarnings({\n serverMode,\n controlledPage,\n onPageChange,\n sortIsManual,\n onSortChange,\n searchable,\n onSearchChange,\n}: DataTableDevWarningsInput): void {\n useEffect(() => {\n if (!isDevBuild()) return;\n\n if (serverMode && controlledPage === undefined) {\n console.warn(\n \"[tempest] <DataTable totalItems> is server mode, which needs a controlled `page`. \" +\n \"Without it the pager moves the internal page while `data` keeps showing page 1.\",\n );\n }\n if (controlledPage !== undefined && !onPageChange) {\n console.warn(\n \"[tempest] <DataTable page> is controlled but `onPageChange` is missing, so the pager cannot do anything.\",\n );\n }\n if (serverMode && searchable && !onSearchChange) {\n console.warn(\n \"[tempest] <DataTable totalItems searchable> delegates searching, so the box needs \" +\n \"`onSearchChange`. Without it the user types and nothing filters and nothing is reported.\",\n );\n }\n if (sortIsManual && !onSortChange) {\n console.warn(\n \"[tempest] <DataTable> is sorting manually but `onSortChange` is missing: clicking a sortable header changes the arrow and nothing else.\",\n );\n }\n }, [\n serverMode,\n controlledPage,\n onPageChange,\n sortIsManual,\n onSortChange,\n searchable,\n onSearchChange,\n ]);\n}\n"],"mappings":"mEA2CA,SAAgB,EAAe,CAC3B,aACA,iBACA,eACA,eACA,eACA,aACA,kBACgC,EAChC,EAAA,EAAA,UAAA,KAAgB,CACP,EAAA,WAAW,IAEZ,GAAc,IAAmB,IAAA,IACjC,QAAQ,KACJ,mKAEJ,EAEA,IAAmB,IAAA,IAAa,CAAC,GACjC,QAAQ,KACJ,0GACJ,EAEA,GAAc,GAAc,CAAC,GAC7B,QAAQ,KACJ,4KAEJ,EAEA,GAAgB,CAAC,GACjB,QAAQ,KACJ,yIACJ,EAER,EAAG,CACC,EACA,EACA,EACA,EACA,EACA,EACA,CACJ,CAAC,CACL"}
1
+ {"version":3,"file":"use-dev-warnings.cjs","names":[],"sources":["../../../src/components/DataTable/use-dev-warnings.ts"],"sourcesContent":["import { useEffect } from \"react\";\n\nimport { isDevBuild } from \"../../utils/dev-mode\";\n\n/** What {@link useDevWarnings} needs to judge the prop combination. */\nexport interface DataTableDevWarningsInput {\n /** Whether `totalItems` was passed. */\n serverMode: boolean;\n /** The controlled `page`, if any. */\n controlledPage: number | undefined;\n /** The page callback, if any. */\n onPageChange: ((page: number) => void) | undefined;\n /** Whether sorting is delegated. */\n sortIsManual: boolean;\n /** Whether any column renders a header the user can click to sort. */\n hasSortableColumn: boolean;\n /** The sort callback, if any. */\n onSortChange: ((sort: never) => void) | undefined;\n /** Whether a search box is rendered at all. */\n searchable: boolean;\n /** The search callback, if any. */\n onSearchChange: ((term: string) => void) | undefined;\n}\n\n/**\n * Warn, in development only, about prop combinations that render a table which\n * silently lies.\n *\n * Each of these produces a screen that looks like it works: the header sorts and\n * nothing moves, the pager renders and clicking it does nothing.\n *\n * Three of them **are** type errors now — `DataTablePagingProps`,\n * `DataTableSortProps` and `DataTableSearchProps` reject them at the call site —\n * so those warnings only reach a caller the types cannot: plain JavaScript, or\n * props arriving through an `any`-typed spread.\n *\n * Each one also has to be reachable. `totalItems` implies `manualSort`, so the\n * sort warning fired on every server-mode table — including one whose columns are\n * all plain, where no header is clickable and the sentence it prints (\"clicking a\n * sortable header changes the arrow and nothing else\") describes a state the user\n * cannot reach. A warning nobody can act on is not a warning: it teaches the\n * reader to skim past the two next to it, which *are* real, and the way out it\n * suggests is `onSortChange={() => {}}` — a callback that does nothing, that the\n * type-checker accepts, and that would hide the warning on the day a `sortable`\n * column does appear. So the sort warning asks for a sortable column first, the\n * way the search one already asks for `searchable`.\n *\n * The fourth is the one the types genuinely cannot afford. `totalItems` *implies*\n * `manualSearch`, so `searchable` with no `onSearchChange` is an inert search box\n * in server mode without anybody writing `manualSearch`. Expressing that means\n * the search axis has to read the paging axis, crossing two three-member unions\n * into nine — so it stays here, which is what \"runtime is the cheaper check\"\n * actually looks like when it is true.\n *\n * @param input - The resolved prop combination.\n */\nexport function useDevWarnings({\n serverMode,\n controlledPage,\n onPageChange,\n sortIsManual,\n hasSortableColumn,\n onSortChange,\n searchable,\n onSearchChange,\n}: DataTableDevWarningsInput): void {\n useEffect(() => {\n if (!isDevBuild()) return;\n\n if (serverMode && controlledPage === undefined) {\n console.warn(\n \"[tempest] <DataTable totalItems> is server mode, which needs a controlled `page`. \" +\n \"Without it the pager moves the internal page while `data` keeps showing page 1.\",\n );\n }\n if (controlledPage !== undefined && !onPageChange) {\n console.warn(\n \"[tempest] <DataTable page> is controlled but `onPageChange` is missing, so the pager cannot do anything.\",\n );\n }\n if (serverMode && searchable && !onSearchChange) {\n console.warn(\n \"[tempest] <DataTable totalItems searchable> delegates searching, so the box needs \" +\n \"`onSearchChange`. Without it the user types and nothing filters and nothing is reported.\",\n );\n }\n if (sortIsManual && hasSortableColumn && !onSortChange) {\n console.warn(\n \"[tempest] <DataTable> is sorting manually but `onSortChange` is missing: clicking a sortable header changes the arrow and nothing else.\",\n );\n }\n }, [\n serverMode,\n controlledPage,\n onPageChange,\n sortIsManual,\n hasSortableColumn,\n onSortChange,\n searchable,\n onSearchChange,\n ]);\n}\n"],"mappings":"mEAwDA,SAAgB,EAAe,CAC3B,aACA,iBACA,eACA,eACA,oBACA,eACA,aACA,kBACgC,EAChC,EAAA,EAAA,UAAA,KAAgB,CACP,EAAA,WAAW,IAEZ,GAAc,IAAmB,IAAA,IACjC,QAAQ,KACJ,mKAEJ,EAEA,IAAmB,IAAA,IAAa,CAAC,GACjC,QAAQ,KACJ,0GACJ,EAEA,GAAc,GAAc,CAAC,GAC7B,QAAQ,KACJ,4KAEJ,EAEA,GAAgB,GAAqB,CAAC,GACtC,QAAQ,KACJ,yIACJ,EAER,EAAG,CACC,EACA,EACA,EACA,EACA,EACA,EACA,EACA,CACJ,CAAC,CACL"}
@@ -1,9 +1,9 @@
1
1
  import { isDevBuild as e } from "../../utils/dev-mode.js";
2
2
  import { useEffect as t } from "react";
3
3
  //#region src/components/DataTable/use-dev-warnings.ts
4
- function n({ serverMode: n, controlledPage: r, onPageChange: i, sortIsManual: a, onSortChange: o, searchable: s, onSearchChange: c }) {
4
+ function n({ serverMode: n, controlledPage: r, onPageChange: i, sortIsManual: a, hasSortableColumn: o, onSortChange: s, searchable: c, onSearchChange: l }) {
5
5
  t(() => {
6
- e() && (n && r === void 0 && console.warn("[tempest] <DataTable totalItems> is server mode, which needs a controlled `page`. Without it the pager moves the internal page while `data` keeps showing page 1."), r !== void 0 && !i && console.warn("[tempest] <DataTable page> is controlled but `onPageChange` is missing, so the pager cannot do anything."), n && s && !c && console.warn("[tempest] <DataTable totalItems searchable> delegates searching, so the box needs `onSearchChange`. Without it the user types and nothing filters and nothing is reported."), a && !o && console.warn("[tempest] <DataTable> is sorting manually but `onSortChange` is missing: clicking a sortable header changes the arrow and nothing else."));
6
+ e() && (n && r === void 0 && console.warn("[tempest] <DataTable totalItems> is server mode, which needs a controlled `page`. Without it the pager moves the internal page while `data` keeps showing page 1."), r !== void 0 && !i && console.warn("[tempest] <DataTable page> is controlled but `onPageChange` is missing, so the pager cannot do anything."), n && c && !l && console.warn("[tempest] <DataTable totalItems searchable> delegates searching, so the box needs `onSearchChange`. Without it the user types and nothing filters and nothing is reported."), a && o && !s && console.warn("[tempest] <DataTable> is sorting manually but `onSortChange` is missing: clicking a sortable header changes the arrow and nothing else."));
7
7
  }, [
8
8
  n,
9
9
  r,
@@ -11,7 +11,8 @@ function n({ serverMode: n, controlledPage: r, onPageChange: i, sortIsManual: a,
11
11
  a,
12
12
  o,
13
13
  s,
14
- c
14
+ c,
15
+ l
15
16
  ]);
16
17
  }
17
18
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"use-dev-warnings.js","names":[],"sources":["../../../src/components/DataTable/use-dev-warnings.ts"],"sourcesContent":["import { useEffect } from \"react\";\n\nimport { isDevBuild } from \"../../utils/dev-mode\";\n\n/** What {@link useDevWarnings} needs to judge the prop combination. */\nexport interface DataTableDevWarningsInput {\n /** Whether `totalItems` was passed. */\n serverMode: boolean;\n /** The controlled `page`, if any. */\n controlledPage: number | undefined;\n /** The page callback, if any. */\n onPageChange: ((page: number) => void) | undefined;\n /** Whether sorting is delegated. */\n sortIsManual: boolean;\n /** The sort callback, if any. */\n onSortChange: ((sort: never) => void) | undefined;\n /** Whether a search box is rendered at all. */\n searchable: boolean;\n /** The search callback, if any. */\n onSearchChange: ((term: string) => void) | undefined;\n}\n\n/**\n * Warn, in development only, about prop combinations that render a table which\n * silently lies.\n *\n * Each of these produces a screen that looks like it works: the header sorts and\n * nothing moves, the pager renders and clicking it does nothing.\n *\n * Three of them **are** type errors now — `DataTablePagingProps`,\n * `DataTableSortProps` and `DataTableSearchProps` reject them at the call site —\n * so those warnings only reach a caller the types cannot: plain JavaScript, or\n * props arriving through an `any`-typed spread.\n *\n * The fourth is the one the types genuinely cannot afford. `totalItems` *implies*\n * `manualSearch`, so `searchable` with no `onSearchChange` is an inert search box\n * in server mode without anybody writing `manualSearch`. Expressing that means\n * the search axis has to read the paging axis, crossing two three-member unions\n * into nine — so it stays here, which is what \"runtime is the cheaper check\"\n * actually looks like when it is true.\n *\n * @param input - The resolved prop combination.\n */\nexport function useDevWarnings({\n serverMode,\n controlledPage,\n onPageChange,\n sortIsManual,\n onSortChange,\n searchable,\n onSearchChange,\n}: DataTableDevWarningsInput): void {\n useEffect(() => {\n if (!isDevBuild()) return;\n\n if (serverMode && controlledPage === undefined) {\n console.warn(\n \"[tempest] <DataTable totalItems> is server mode, which needs a controlled `page`. \" +\n \"Without it the pager moves the internal page while `data` keeps showing page 1.\",\n );\n }\n if (controlledPage !== undefined && !onPageChange) {\n console.warn(\n \"[tempest] <DataTable page> is controlled but `onPageChange` is missing, so the pager cannot do anything.\",\n );\n }\n if (serverMode && searchable && !onSearchChange) {\n console.warn(\n \"[tempest] <DataTable totalItems searchable> delegates searching, so the box needs \" +\n \"`onSearchChange`. Without it the user types and nothing filters and nothing is reported.\",\n );\n }\n if (sortIsManual && !onSortChange) {\n console.warn(\n \"[tempest] <DataTable> is sorting manually but `onSortChange` is missing: clicking a sortable header changes the arrow and nothing else.\",\n );\n }\n }, [\n serverMode,\n controlledPage,\n onPageChange,\n sortIsManual,\n onSortChange,\n searchable,\n onSearchChange,\n ]);\n}\n"],"mappings":";;;AA2CA,SAAgB,EAAe,EAC3B,eACA,mBACA,iBACA,iBACA,iBACA,eACA,qBACgC;CAChC,QAAgB;EACP,EAAW,MAEZ,KAAc,MAAmB,KAAA,KACjC,QAAQ,KACJ,mKAEJ,GAEA,MAAmB,KAAA,KAAa,CAAC,KACjC,QAAQ,KACJ,0GACJ,GAEA,KAAc,KAAc,CAAC,KAC7B,QAAQ,KACJ,4KAEJ,GAEA,KAAgB,CAAC,KACjB,QAAQ,KACJ,yIACJ;CAER,GAAG;EACC;EACA;EACA;EACA;EACA;EACA;EACA;CACJ,CAAC;AACL"}
1
+ {"version":3,"file":"use-dev-warnings.js","names":[],"sources":["../../../src/components/DataTable/use-dev-warnings.ts"],"sourcesContent":["import { useEffect } from \"react\";\n\nimport { isDevBuild } from \"../../utils/dev-mode\";\n\n/** What {@link useDevWarnings} needs to judge the prop combination. */\nexport interface DataTableDevWarningsInput {\n /** Whether `totalItems` was passed. */\n serverMode: boolean;\n /** The controlled `page`, if any. */\n controlledPage: number | undefined;\n /** The page callback, if any. */\n onPageChange: ((page: number) => void) | undefined;\n /** Whether sorting is delegated. */\n sortIsManual: boolean;\n /** Whether any column renders a header the user can click to sort. */\n hasSortableColumn: boolean;\n /** The sort callback, if any. */\n onSortChange: ((sort: never) => void) | undefined;\n /** Whether a search box is rendered at all. */\n searchable: boolean;\n /** The search callback, if any. */\n onSearchChange: ((term: string) => void) | undefined;\n}\n\n/**\n * Warn, in development only, about prop combinations that render a table which\n * silently lies.\n *\n * Each of these produces a screen that looks like it works: the header sorts and\n * nothing moves, the pager renders and clicking it does nothing.\n *\n * Three of them **are** type errors now — `DataTablePagingProps`,\n * `DataTableSortProps` and `DataTableSearchProps` reject them at the call site —\n * so those warnings only reach a caller the types cannot: plain JavaScript, or\n * props arriving through an `any`-typed spread.\n *\n * Each one also has to be reachable. `totalItems` implies `manualSort`, so the\n * sort warning fired on every server-mode table — including one whose columns are\n * all plain, where no header is clickable and the sentence it prints (\"clicking a\n * sortable header changes the arrow and nothing else\") describes a state the user\n * cannot reach. A warning nobody can act on is not a warning: it teaches the\n * reader to skim past the two next to it, which *are* real, and the way out it\n * suggests is `onSortChange={() => {}}` — a callback that does nothing, that the\n * type-checker accepts, and that would hide the warning on the day a `sortable`\n * column does appear. So the sort warning asks for a sortable column first, the\n * way the search one already asks for `searchable`.\n *\n * The fourth is the one the types genuinely cannot afford. `totalItems` *implies*\n * `manualSearch`, so `searchable` with no `onSearchChange` is an inert search box\n * in server mode without anybody writing `manualSearch`. Expressing that means\n * the search axis has to read the paging axis, crossing two three-member unions\n * into nine — so it stays here, which is what \"runtime is the cheaper check\"\n * actually looks like when it is true.\n *\n * @param input - The resolved prop combination.\n */\nexport function useDevWarnings({\n serverMode,\n controlledPage,\n onPageChange,\n sortIsManual,\n hasSortableColumn,\n onSortChange,\n searchable,\n onSearchChange,\n}: DataTableDevWarningsInput): void {\n useEffect(() => {\n if (!isDevBuild()) return;\n\n if (serverMode && controlledPage === undefined) {\n console.warn(\n \"[tempest] <DataTable totalItems> is server mode, which needs a controlled `page`. \" +\n \"Without it the pager moves the internal page while `data` keeps showing page 1.\",\n );\n }\n if (controlledPage !== undefined && !onPageChange) {\n console.warn(\n \"[tempest] <DataTable page> is controlled but `onPageChange` is missing, so the pager cannot do anything.\",\n );\n }\n if (serverMode && searchable && !onSearchChange) {\n console.warn(\n \"[tempest] <DataTable totalItems searchable> delegates searching, so the box needs \" +\n \"`onSearchChange`. Without it the user types and nothing filters and nothing is reported.\",\n );\n }\n if (sortIsManual && hasSortableColumn && !onSortChange) {\n console.warn(\n \"[tempest] <DataTable> is sorting manually but `onSortChange` is missing: clicking a sortable header changes the arrow and nothing else.\",\n );\n }\n }, [\n serverMode,\n controlledPage,\n onPageChange,\n sortIsManual,\n hasSortableColumn,\n onSortChange,\n searchable,\n onSearchChange,\n ]);\n}\n"],"mappings":";;;AAwDA,SAAgB,EAAe,EAC3B,eACA,mBACA,iBACA,iBACA,sBACA,iBACA,eACA,qBACgC;CAChC,QAAgB;EACP,EAAW,MAEZ,KAAc,MAAmB,KAAA,KACjC,QAAQ,KACJ,mKAEJ,GAEA,MAAmB,KAAA,KAAa,CAAC,KACjC,QAAQ,KACJ,0GACJ,GAEA,KAAc,KAAc,CAAC,KAC7B,QAAQ,KACJ,4KAEJ,GAEA,KAAgB,KAAqB,CAAC,KACtC,QAAQ,KACJ,yIACJ;CAER,GAAG;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACJ,CAAC;AACL"}
@@ -1 +1 @@
1
- {"version":3,"file":"DropdownMenu.module.cjs","names":[],"sources":["../../../src/components/DropdownMenu/DropdownMenu.module.css"],"sourcesContent":[".root {\n position: relative;\n display: inline-flex;\n}\n\n.menu {\n position: absolute;\n z-index: var(--tempest-z-dropdown);\n min-width: 180px;\n max-width: 320px;\n background-color: var(--tempest-bg);\n border: 1px solid var(--tempest-border);\n border-radius: var(--tempest-radius-lg);\n box-shadow: var(--tempest-shadow-lg);\n padding: var(--tempest-space-1);\n font-family: var(--tempest-font-sans);\n font-size: var(--tempest-text-base);\n list-style: none;\n margin: 0;\n animation: tempest-menu-in var(--tempest-duration-fast) var(--tempest-ease-out);\n}\n\n.bottomStart {\n top: calc(100% + 4px);\n left: 0;\n}\n.bottomEnd {\n top: calc(100% + 4px);\n right: 0;\n}\n.topStart {\n bottom: calc(100% + 4px);\n left: 0;\n}\n.topEnd {\n bottom: calc(100% + 4px);\n right: 0;\n}\n\n.item {\n display: flex;\n align-items: center;\n gap: var(--tempest-space-2);\n width: 100%;\n padding: var(--tempest-space-2) var(--tempest-space-3);\n background: none;\n border: none;\n border-radius: var(--tempest-radius-sm);\n color: var(--tempest-text);\n font-family: inherit;\n font-size: inherit;\n line-height: var(--tempest-leading-snug);\n text-align: left;\n cursor: pointer;\n transition: var(--tempest-transition-color);\n}\n\n@media (hover: hover) and (pointer: fine) {\n .item:hover:not(:disabled) {\n background-color: var(--tempest-surface);\n }\n}\n\n.item:focus,\n.item.active {\n outline: none;\n background-color: var(--tempest-surface);\n}\n\n.item:disabled {\n opacity: 0.55;\n cursor: not-allowed;\n}\n\n.item.danger {\n color: var(--tempest-danger);\n}\n\n.separator {\n height: 1px;\n background-color: var(--tempest-border);\n margin: var(--tempest-space-1) 0;\n}\n\n.label {\n padding: var(--tempest-space-1) var(--tempest-space-3);\n font-size: var(--tempest-text-xs);\n font-weight: var(--tempest-weight-semibold);\n color: var(--tempest-text-muted);\n text-transform: uppercase;\n letter-spacing: var(--tempest-tracking-wider);\n}\n\n@keyframes tempest-menu-in {\n from {\n opacity: 0;\n transform: translateY(-4px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .menu {\n animation: none;\n }\n}\n"],"mappings":";"}
1
+ {"version":3,"file":"DropdownMenu.module.cjs","names":[],"sources":["../../../src/components/DropdownMenu/DropdownMenu.module.css"],"sourcesContent":[".root {\n position: relative;\n display: inline-flex;\n}\n\n.menu {\n position: absolute;\n z-index: var(--tempest-z-dropdown);\n min-width: 180px;\n max-width: 320px;\n background-color: var(--tempest-bg);\n border: 1px solid var(--tempest-border);\n border-radius: var(--tempest-radius-lg);\n box-shadow: var(--tempest-shadow-lg);\n padding: var(--tempest-space-1);\n font-family: var(--tempest-font-sans);\n font-size: var(--tempest-text-base);\n list-style: none;\n margin: 0;\n animation: tempest-menu-in var(--tempest-duration-fast) var(--tempest-ease-out);\n}\n\n.bottomStart {\n top: calc(100% + 4px);\n left: 0;\n}\n.bottomEnd {\n top: calc(100% + 4px);\n right: 0;\n}\n.topStart {\n bottom: calc(100% + 4px);\n left: 0;\n}\n.topEnd {\n bottom: calc(100% + 4px);\n right: 0;\n}\n\n.item {\n display: flex;\n align-items: center;\n gap: var(--tempest-space-2);\n width: 100%;\n padding: var(--tempest-space-2) var(--tempest-space-3);\n background: none;\n border: none;\n border-radius: var(--tempest-radius-sm);\n color: var(--tempest-text);\n font-family: inherit;\n font-size: inherit;\n line-height: var(--tempest-leading-snug);\n text-align: left;\n cursor: pointer;\n transition: var(--tempest-transition-color);\n}\n\n@media (hover: hover) and (pointer: fine) {\n .item:hover:not(:disabled) {\n background-color: var(--tempest-surface);\n }\n}\n\n.item:focus,\n.item.active {\n outline: none;\n background-color: var(--tempest-primary-soft);\n color: var(--tempest-primary-on-soft);\n box-shadow: inset 3px 0 0 0 var(--tempest-selected-indicator);\n}\n\n.item:disabled {\n opacity: 0.55;\n cursor: not-allowed;\n}\n\n.item.danger {\n color: var(--tempest-danger);\n}\n\n.separator {\n height: 1px;\n background-color: var(--tempest-border);\n margin: var(--tempest-space-1) 0;\n}\n\n.label {\n padding: var(--tempest-space-1) var(--tempest-space-3);\n font-size: var(--tempest-text-xs);\n font-weight: var(--tempest-weight-semibold);\n color: var(--tempest-text-muted);\n text-transform: uppercase;\n letter-spacing: var(--tempest-tracking-wider);\n}\n\n@keyframes tempest-menu-in {\n from {\n opacity: 0;\n transform: translateY(-4px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .menu {\n animation: none;\n }\n}\n"],"mappings":";"}
@@ -1 +1 @@
1
- {"version":3,"file":"DropdownMenu.module.js","names":[],"sources":["../../../src/components/DropdownMenu/DropdownMenu.module.css"],"sourcesContent":[".root {\n position: relative;\n display: inline-flex;\n}\n\n.menu {\n position: absolute;\n z-index: var(--tempest-z-dropdown);\n min-width: 180px;\n max-width: 320px;\n background-color: var(--tempest-bg);\n border: 1px solid var(--tempest-border);\n border-radius: var(--tempest-radius-lg);\n box-shadow: var(--tempest-shadow-lg);\n padding: var(--tempest-space-1);\n font-family: var(--tempest-font-sans);\n font-size: var(--tempest-text-base);\n list-style: none;\n margin: 0;\n animation: tempest-menu-in var(--tempest-duration-fast) var(--tempest-ease-out);\n}\n\n.bottomStart {\n top: calc(100% + 4px);\n left: 0;\n}\n.bottomEnd {\n top: calc(100% + 4px);\n right: 0;\n}\n.topStart {\n bottom: calc(100% + 4px);\n left: 0;\n}\n.topEnd {\n bottom: calc(100% + 4px);\n right: 0;\n}\n\n.item {\n display: flex;\n align-items: center;\n gap: var(--tempest-space-2);\n width: 100%;\n padding: var(--tempest-space-2) var(--tempest-space-3);\n background: none;\n border: none;\n border-radius: var(--tempest-radius-sm);\n color: var(--tempest-text);\n font-family: inherit;\n font-size: inherit;\n line-height: var(--tempest-leading-snug);\n text-align: left;\n cursor: pointer;\n transition: var(--tempest-transition-color);\n}\n\n@media (hover: hover) and (pointer: fine) {\n .item:hover:not(:disabled) {\n background-color: var(--tempest-surface);\n }\n}\n\n.item:focus,\n.item.active {\n outline: none;\n background-color: var(--tempest-surface);\n}\n\n.item:disabled {\n opacity: 0.55;\n cursor: not-allowed;\n}\n\n.item.danger {\n color: var(--tempest-danger);\n}\n\n.separator {\n height: 1px;\n background-color: var(--tempest-border);\n margin: var(--tempest-space-1) 0;\n}\n\n.label {\n padding: var(--tempest-space-1) var(--tempest-space-3);\n font-size: var(--tempest-text-xs);\n font-weight: var(--tempest-weight-semibold);\n color: var(--tempest-text-muted);\n text-transform: uppercase;\n letter-spacing: var(--tempest-tracking-wider);\n}\n\n@keyframes tempest-menu-in {\n from {\n opacity: 0;\n transform: translateY(-4px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .menu {\n animation: none;\n }\n}\n"],"mappings":";"}
1
+ {"version":3,"file":"DropdownMenu.module.js","names":[],"sources":["../../../src/components/DropdownMenu/DropdownMenu.module.css"],"sourcesContent":[".root {\n position: relative;\n display: inline-flex;\n}\n\n.menu {\n position: absolute;\n z-index: var(--tempest-z-dropdown);\n min-width: 180px;\n max-width: 320px;\n background-color: var(--tempest-bg);\n border: 1px solid var(--tempest-border);\n border-radius: var(--tempest-radius-lg);\n box-shadow: var(--tempest-shadow-lg);\n padding: var(--tempest-space-1);\n font-family: var(--tempest-font-sans);\n font-size: var(--tempest-text-base);\n list-style: none;\n margin: 0;\n animation: tempest-menu-in var(--tempest-duration-fast) var(--tempest-ease-out);\n}\n\n.bottomStart {\n top: calc(100% + 4px);\n left: 0;\n}\n.bottomEnd {\n top: calc(100% + 4px);\n right: 0;\n}\n.topStart {\n bottom: calc(100% + 4px);\n left: 0;\n}\n.topEnd {\n bottom: calc(100% + 4px);\n right: 0;\n}\n\n.item {\n display: flex;\n align-items: center;\n gap: var(--tempest-space-2);\n width: 100%;\n padding: var(--tempest-space-2) var(--tempest-space-3);\n background: none;\n border: none;\n border-radius: var(--tempest-radius-sm);\n color: var(--tempest-text);\n font-family: inherit;\n font-size: inherit;\n line-height: var(--tempest-leading-snug);\n text-align: left;\n cursor: pointer;\n transition: var(--tempest-transition-color);\n}\n\n@media (hover: hover) and (pointer: fine) {\n .item:hover:not(:disabled) {\n background-color: var(--tempest-surface);\n }\n}\n\n.item:focus,\n.item.active {\n outline: none;\n background-color: var(--tempest-primary-soft);\n color: var(--tempest-primary-on-soft);\n box-shadow: inset 3px 0 0 0 var(--tempest-selected-indicator);\n}\n\n.item:disabled {\n opacity: 0.55;\n cursor: not-allowed;\n}\n\n.item.danger {\n color: var(--tempest-danger);\n}\n\n.separator {\n height: 1px;\n background-color: var(--tempest-border);\n margin: var(--tempest-space-1) 0;\n}\n\n.label {\n padding: var(--tempest-space-1) var(--tempest-space-3);\n font-size: var(--tempest-text-xs);\n font-weight: var(--tempest-weight-semibold);\n color: var(--tempest-text-muted);\n text-transform: uppercase;\n letter-spacing: var(--tempest-tracking-wider);\n}\n\n@keyframes tempest-menu-in {\n from {\n opacity: 0;\n transform: translateY(-4px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .menu {\n animation: none;\n }\n}\n"],"mappings":";"}
@@ -1,2 +1,2 @@
1
- const e=require("../../utils/cn.cjs"),t=require("../Button/Button.cjs"),n=require("../../hooks/use-before-install-prompt.cjs"),r=require("./InstallBanner.module.cjs");let i=require("react"),a=require("react/jsx-runtime"),o=require("lucide-react");function s(e){if(!e||typeof window>`u`)return!1;try{return window.localStorage.getItem(e)===`1`}catch{return!1}}function c({title:c=`Instale o app`,description:l,installLabel:u=`Instalar`,dismissLabel:d=`Dispensar`,icon:f,storageKey:p,onResult:m,className:h}){let{installable:g,installed:_,isStandalone:v,prompt:y}=n.useBeforeInstallPrompt(),[b,x]=(0,i.useState)(()=>s(p));return!g||_||v||b?null:(0,a.jsxs)(`div`,{className:e.cn(r.default.banner,h),role:`region`,"aria-label":String(c),children:[f&&(0,a.jsx)(`span`,{className:r.default.icon,children:f}),(0,a.jsxs)(`div`,{className:r.default.body,children:[(0,a.jsx)(`p`,{className:r.default.title,children:c}),l&&(0,a.jsx)(`p`,{className:r.default.description,children:l})]}),(0,a.jsx)(t.Button,{size:`sm`,onClick:async()=>{m?.(await y())},children:u}),(0,a.jsx)(`button`,{type:`button`,className:r.default.close,"aria-label":d,onClick:()=>{if(x(!0),p&&typeof window<`u`)try{window.localStorage.setItem(p,`1`)}catch{}},children:(0,a.jsx)(o.X,{size:18,"aria-hidden":!0})})]})}exports.InstallBanner=c;
1
+ const e=require("../../utils/cn.cjs"),t=require("../Button/Button.cjs"),n=require("../../hooks/use-install-prompt.cjs"),r=require("../InstallButton/install-hints.cjs"),i=require("./InstallBanner.module.cjs");let a=require("react"),o=require("react/jsx-runtime"),s=require("lucide-react");function c(e,t){if(!e||typeof window>`u`)return!1;try{let n=window.localStorage.getItem(e);if(!n)return!1;if(n===`1`)return!0;let r=Number(n);return Number.isFinite(r)?t===void 0||Date.now()-r<t:!1}catch{return!1}}function l({title:l=`Instale o app`,description:u,installLabel:d=`Instalar`,hintLabel:f=`Como instalar`,dismissLabel:p=`Dispensar`,icon:m,storageKey:h,declineCooldownMs:g,renderHint:_=r.defaultInstallHint,manualFallbackDelayMs:v,onResult:y,className:b}){let{method:x,openInChromeIntent:S,install:C}=n.useInstallPrompt({manualFallbackDelayMs:v}),[w,T]=(0,a.useState)(()=>c(h,g)),[E,D]=(0,a.useState)(!1),O=(0,a.useId)();if(x===`none`||w)return null;let k=()=>{if(T(!0),h&&typeof window<`u`)try{window.localStorage.setItem(h,g===void 0?`1`:String(Date.now()))}catch{}},A=x===`native`?null:_({method:x,openInChromeIntent:S});return(0,o.jsxs)(`div`,{className:e.cn(i.default.banner,b),role:`region`,"aria-label":String(l),children:[m&&(0,o.jsx)(`span`,{className:i.default.icon,children:m}),(0,o.jsxs)(`div`,{className:i.default.body,children:[(0,o.jsx)(`p`,{className:i.default.title,children:l}),u&&(0,o.jsx)(`p`,{className:i.default.description,children:u}),E&&A?(0,o.jsx)(`p`,{className:i.default.hint,id:O,children:A}):null]}),x===`native`?(0,o.jsx)(t.Button,{size:`sm`,onClick:async()=>{let e=await C();y?.(e?`accepted`:`dismissed`)},children:d}):(0,o.jsx)(t.Button,{size:`sm`,"aria-expanded":E,"aria-controls":E&&A?O:void 0,onClick:()=>D(e=>!e),children:f}),(0,o.jsx)(`button`,{type:`button`,className:i.default.close,"aria-label":p,onClick:k,children:(0,o.jsx)(s.X,{size:18,"aria-hidden":!0})})]})}exports.InstallBanner=l;
2
2
  //# sourceMappingURL=InstallBanner.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"InstallBanner.cjs","names":[],"sources":["../../../src/components/InstallBanner/InstallBanner.tsx"],"sourcesContent":["/**\n * @tempest-limits props-count — title, description, installLabel and dismissLabel\n * are four strings the app has to write, icon and className the look, storageKey the\n * dismissal memory and onResult the outcome. An install prompt with SDK-authored\n * copy is the one thing nobody ships.\n */\nimport { useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { X } from \"lucide-react\";\nimport { cn } from \"@/utils/cn\";\nimport { Button } from \"@/components/Button\";\nimport { useBeforeInstallPrompt } from \"@/hooks/use-before-install-prompt\";\nimport type { InstallOutcome } from \"@/components/InstallButton\";\nimport styles from \"./InstallBanner.module.css\";\n\nexport interface InstallBannerProps {\n /** Headline. Default `\"Instale o app\"`. */\n title?: ReactNode;\n /** Supporting copy under the title. */\n description?: ReactNode;\n /** Install button label. Default `\"Instalar\"`. */\n installLabel?: string;\n /** Accessible label for the dismiss button. Default `\"Dispensar\"`. */\n dismissLabel?: string;\n /** Optional leading icon. */\n icon?: ReactNode;\n /**\n * `localStorage` key used to remember dismissal across reloads. Omit to\n * make dismissal last only for the current session (component state).\n */\n storageKey?: string;\n /** Called with the user's choice after the install prompt resolves. */\n onResult?: (outcome: InstallOutcome) => void;\n className?: string;\n}\n\nfunction readDismissed(storageKey?: string): boolean {\n if (!storageKey || typeof window === \"undefined\") return false;\n try {\n return window.localStorage.getItem(storageKey) === \"1\";\n } catch {\n return false;\n }\n}\n\n/**\n * Dismissible bottom banner that invites the user to install the PWA. Wired to\n * {@link useBeforeInstallPrompt}: it renders only when the browser captured an\n * install prompt and the app is not already running standalone — so on\n * platforms that never fire `beforeinstallprompt` (e.g. iOS Safari) it stays\n * hidden and you can surface manual instructions elsewhere.\n *\n * @tempest-limits empty-catch — persisting the dismissal is a courtesy, not the\n * feature. When `localStorage` refuses the write (quota, private mode) the banner\n * still hides for this session; the worst case is that it comes back next visit,\n * which beats an error thrown out of a click handler that only closed a banner.\n *\n * @example\n * <InstallBanner\n * title=\"Instale o FAMACHApp\"\n * description=\"Acesso offline e atalho na tela inicial.\"\n * storageKey=\"famacha:install-dismissed\"\n * />\n */\nexport function InstallBanner({\n title = \"Instale o app\",\n description,\n installLabel = \"Instalar\",\n dismissLabel = \"Dispensar\",\n icon,\n storageKey,\n onResult,\n className,\n}: InstallBannerProps) {\n const { installable, installed, isStandalone, prompt } = useBeforeInstallPrompt();\n const [dismissed, setDismissed] = useState<boolean>(() => readDismissed(storageKey));\n\n if (!installable || installed || isStandalone || dismissed) return null;\n\n const dismiss = (): void => {\n setDismissed(true);\n if (storageKey && typeof window !== \"undefined\") {\n try {\n window.localStorage.setItem(storageKey, \"1\");\n } catch {\n /* empty */\n }\n }\n };\n\n return (\n <div className={cn(styles.banner, className)} role=\"region\" aria-label={String(title)}>\n {icon && <span className={styles.icon}>{icon}</span>}\n <div className={styles.body}>\n <p className={styles.title}>{title}</p>\n {description && <p className={styles.description}>{description}</p>}\n </div>\n <Button\n size=\"sm\"\n onClick={async () => {\n onResult?.(await prompt());\n }}\n >\n {installLabel}\n </Button>\n <button\n type=\"button\"\n className={styles.close}\n aria-label={dismissLabel}\n onClick={dismiss}\n >\n <X size={18} aria-hidden />\n </button>\n </div>\n );\n}\n"],"mappings":"uPAoCA,SAAS,EAAc,EAA8B,CACjD,GAAI,CAAC,GAAc,OAAO,OAAW,IAAa,MAAO,GACzD,GAAI,CACA,OAAO,OAAO,aAAa,QAAQ,CAAU,IAAM,GACvD,MAAQ,CACJ,MAAO,EACX,CACJ,CAqBA,SAAgB,EAAc,CAC1B,QAAQ,gBACR,cACA,eAAe,WACf,eAAe,YACf,OACA,aACA,WACA,aACmB,CACnB,GAAM,CAAE,cAAa,YAAW,eAAc,UAAW,EAAA,uBAAuB,EAC1E,CAAC,EAAW,IAAA,EAAgB,EAAA,SAAA,KAAwB,EAAc,CAAU,CAAC,EAenF,MAbI,CAAC,GAAe,GAAa,GAAgB,EAAkB,MAc/D,EAAA,EAAA,KAAA,CAAC,MAAD,CAAK,UAAW,EAAA,GAAG,EAAA,QAAO,OAAQ,CAAS,EAAG,KAAK,SAAS,aAAY,OAAO,CAAK,EAApF,SAAA,CACK,IAAQ,EAAA,EAAA,IAAA,CAAC,OAAD,CAAM,UAAW,EAAA,QAAO,KAAO,SAAA,CAAW,CAAA,GACnD,EAAA,EAAA,KAAA,CAAC,MAAD,CAAK,UAAW,EAAA,QAAO,KAAvB,SAAA,EACI,EAAA,EAAA,IAAA,CAAC,IAAD,CAAG,UAAW,EAAA,QAAO,MAAQ,SAAA,CAAS,CAAA,EACrC,IAAe,EAAA,EAAA,IAAA,CAAC,IAAD,CAAG,UAAW,EAAA,QAAO,YAAc,SAAA,CAAe,CAAA,CACjE,KACL,EAAA,EAAA,IAAA,CAAC,EAAA,OAAD,CACI,KAAK,KACL,QAAS,SAAY,CACjB,IAAW,MAAM,EAAO,CAAC,CAC7B,EAEC,SAAA,CACG,CAAA,GACR,EAAA,EAAA,IAAA,CAAC,SAAD,CACI,KAAK,SACL,UAAW,EAAA,QAAO,MAClB,aAAY,EACZ,YA9BgB,CAExB,GADA,EAAa,EAAI,EACb,GAAc,OAAO,OAAW,IAChC,GAAI,CACA,OAAO,aAAa,QAAQ,EAAY,GAAG,CAC/C,MAAQ,CAER,CAER,EAuBY,UAAA,EAAA,EAAA,IAAA,CAAC,EAAA,EAAD,CAAG,KAAM,GAAI,cAAA,EAAa,CAAA,CACtB,CAAA,CACP,GAEb"}
1
+ {"version":3,"file":"InstallBanner.cjs","names":[],"sources":["../../../src/components/InstallBanner/InstallBanner.tsx"],"sourcesContent":["/**\n * @tempest-limits props-count — title, description, installLabel and dismissLabel\n * are four strings the app has to write, icon and className the look, storageKey the\n * dismissal memory and onResult the outcome. An install prompt with SDK-authored\n * copy is the one thing nobody ships.\n */\nimport { useId, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { X } from \"lucide-react\";\nimport { cn } from \"@/utils/cn\";\nimport { Button } from \"@/components/Button\";\nimport { useInstallPrompt } from \"@/hooks/use-install-prompt\";\nimport { defaultInstallHint } from \"@/components/InstallButton/install-hints\";\nimport type { RenderInstallHint } from \"@/components/InstallButton/install-hints\";\nimport type { InstallOutcome } from \"@/components/InstallButton\";\nimport styles from \"./InstallBanner.module.css\";\n\nexport interface InstallBannerProps {\n /** Headline. Default `\"Instale o app\"`. */\n title?: ReactNode;\n /** Supporting copy under the title. */\n description?: ReactNode;\n /** Install button label. Default `\"Instalar\"`. */\n installLabel?: string;\n /** Accessible label for the dismiss button. Default `\"Dispensar\"`. */\n dismissLabel?: string;\n /** Optional leading icon. */\n icon?: ReactNode;\n /**\n * `localStorage` key used to remember dismissal across reloads. Omit to\n * make dismissal last only for the current session (component state).\n */\n storageKey?: string;\n /**\n * How long, in ms, a dismissal lasts before the banner may return.\n *\n * Omitted, a dismissal written to `storageKey` is permanent, which is what\n * the component always did and what a stored `\"1\"` keeps meaning. With a\n * cooldown the dismissal is stored as a timestamp instead, so the banner\n * comes back after the window — the same shape `useInstallPrompt` uses for\n * its own decline.\n */\n declineCooldownMs?: number;\n /**\n * Install button label used when the browser cannot be prompted and the\n * banner shows the manual instruction. Default `\"Como instalar\"`.\n */\n hintLabel?: string;\n /**\n * Replaces the instruction shown for the `\"ios\"` and `\"manual\"` methods.\n *\n * The default copy is in PT-BR and names the real menu entries.\n */\n renderHint?: RenderInstallHint;\n /**\n * How long, in ms, to wait for `beforeinstallprompt` before falling back to\n * the manual instruction. Forwarded to {@link useInstallPrompt}; defaults to\n * 3000 there.\n */\n manualFallbackDelayMs?: number;\n /** Called with the user's choice after the install prompt resolves. */\n onResult?: (outcome: InstallOutcome) => void;\n className?: string;\n}\n\n/**\n * Whether the user already dismissed this banner.\n *\n * Two stored shapes, and both have to keep working: `\"1\"` is the permanent\n * dismissal the component has always written, and a timestamp is what a banner\n * with `declineCooldownMs` writes. A `\"1\"` found while a cooldown is configured\n * still counts as dismissed forever — it was written under the old contract, and\n * reviving a banner the user turned off is worse than keeping it off.\n *\n * @param storageKey - The key holding the dismissal, if any.\n * @param declineCooldownMs - How long a timestamped dismissal lasts.\n * @returns Whether the banner should stay hidden.\n */\nfunction readDismissed(storageKey?: string, declineCooldownMs?: number): boolean {\n if (!storageKey || typeof window === \"undefined\") return false;\n try {\n const raw = window.localStorage.getItem(storageKey);\n if (!raw) return false;\n if (raw === \"1\") return true;\n const dismissedAt = Number(raw);\n if (!Number.isFinite(dismissedAt)) return false;\n if (declineCooldownMs === undefined) return true;\n return Date.now() - dismissedAt < declineCooldownMs;\n } catch {\n return false;\n }\n}\n\n/**\n * Dismissible bottom banner that invites the user to install the PWA, wired to\n * {@link useInstallPrompt}.\n *\n * Where the browser fires `beforeinstallprompt`, the button installs. Where it\n * does not — iOS Safari, and the Android Chromium forks that strip the API — the\n * banner shows that platform's instruction instead of disappearing. It used to\n * disappear: built on `useBeforeInstallPrompt`, it rendered `null` exactly where\n * the user has no other way to find the install entry, which is why every app\n * kept a local copy of this component just to add the two missing paths.\n *\n * @tempest-limits empty-catch — persisting the dismissal is a courtesy, not the\n * feature. When `localStorage` refuses the write (quota, private mode) the banner\n * still hides for this session; the worst case is that it comes back next visit,\n * which beats an error thrown out of a click handler that only closed a banner.\n *\n * @example\n * <InstallBanner\n * title=\"Instale o FAMACHApp\"\n * description=\"Acesso offline e atalho na tela inicial.\"\n * storageKey=\"famacha:install-dismissed\"\n * />\n */\nexport function InstallBanner({\n title = \"Instale o app\",\n description,\n installLabel = \"Instalar\",\n hintLabel = \"Como instalar\",\n dismissLabel = \"Dispensar\",\n icon,\n storageKey,\n declineCooldownMs,\n renderHint = defaultInstallHint,\n manualFallbackDelayMs,\n onResult,\n className,\n}: InstallBannerProps) {\n const { method, openInChromeIntent, install } = useInstallPrompt({ manualFallbackDelayMs });\n const [dismissed, setDismissed] = useState<boolean>(() =>\n readDismissed(storageKey, declineCooldownMs),\n );\n const [hintOpen, setHintOpen] = useState(false);\n const hintId = useId();\n\n if (method === \"none\" || dismissed) return null;\n\n const dismiss = (): void => {\n setDismissed(true);\n if (storageKey && typeof window !== \"undefined\") {\n try {\n window.localStorage.setItem(\n storageKey,\n declineCooldownMs === undefined ? \"1\" : String(Date.now()),\n );\n } catch {\n /* empty */\n }\n }\n };\n\n const hint = method === \"native\" ? null : renderHint({ method, openInChromeIntent });\n\n return (\n <div className={cn(styles.banner, className)} role=\"region\" aria-label={String(title)}>\n {icon && <span className={styles.icon}>{icon}</span>}\n <div className={styles.body}>\n <p className={styles.title}>{title}</p>\n {description && <p className={styles.description}>{description}</p>}\n {hintOpen && hint ? (\n <p className={styles.hint} id={hintId}>\n {hint}\n </p>\n ) : null}\n </div>\n {method === \"native\" ? (\n <Button\n size=\"sm\"\n onClick={async () => {\n const accepted = await install();\n onResult?.(accepted ? \"accepted\" : \"dismissed\");\n }}\n >\n {installLabel}\n </Button>\n ) : (\n <Button\n size=\"sm\"\n aria-expanded={hintOpen}\n aria-controls={hintOpen && hint ? hintId : undefined}\n onClick={() => setHintOpen((open) => !open)}\n >\n {hintLabel}\n </Button>\n )}\n <button\n type=\"button\"\n className={styles.close}\n aria-label={dismissLabel}\n onClick={dismiss}\n >\n <X size={18} aria-hidden />\n </button>\n </div>\n );\n}\n"],"mappings":"gSA8EA,SAAS,EAAc,EAAqB,EAAqC,CAC7E,GAAI,CAAC,GAAc,OAAO,OAAW,IAAa,MAAO,GACzD,GAAI,CACA,IAAM,EAAM,OAAO,aAAa,QAAQ,CAAU,EAClD,GAAI,CAAC,EAAK,MAAO,GACjB,GAAI,IAAQ,IAAK,MAAO,GACxB,IAAM,EAAc,OAAO,CAAG,EAG9B,OAFK,OAAO,SAAS,CAAW,EAC5B,IAAsB,IAAA,IACnB,KAAK,IAAI,EAAI,EAAc,EAFQ,EAG9C,MAAQ,CACJ,MAAO,EACX,CACJ,CAyBA,SAAgB,EAAc,CAC1B,QAAQ,gBACR,cACA,eAAe,WACf,YAAY,gBACZ,eAAe,YACf,OACA,aACA,oBACA,aAAa,EAAA,mBACb,wBACA,WACA,aACmB,CACnB,GAAM,CAAE,SAAQ,qBAAoB,WAAY,EAAA,iBAAiB,CAAE,uBAAsB,CAAC,EACpF,CAAC,EAAW,IAAA,EAAgB,EAAA,SAAA,KAC9B,EAAc,EAAY,CAAiB,CAC/C,EACM,CAAC,EAAU,IAAA,EAAe,EAAA,SAAA,CAAS,EAAK,EACxC,GAAA,EAAS,EAAA,MAAA,CAAM,EAErB,GAAI,IAAW,QAAU,EAAW,OAAO,KAE3C,IAAM,MAAsB,CAExB,GADA,EAAa,EAAI,EACb,GAAc,OAAO,OAAW,IAChC,GAAI,CACA,OAAO,aAAa,QAChB,EACA,IAAsB,IAAA,GAAY,IAAM,OAAO,KAAK,IAAI,CAAC,CAC7D,CACJ,MAAQ,CAER,CAER,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../utils/cn.js";
2
2
  import { Button as t } from "../Button/Button.js";
3
- import { useBeforeInstallPrompt as n } from "../../hooks/use-before-install-prompt.js";
4
- import r from "./InstallBanner.module.js";
5
- import { useState as i } from "react";
6
- import { jsx as a, jsxs as o } from "react/jsx-runtime";
7
- import { X as s } from "lucide-react";
3
+ import { useInstallPrompt as n } from "../../hooks/use-install-prompt.js";
4
+ import { defaultInstallHint as r } from "../InstallButton/install-hints.js";
5
+ import i from "./InstallBanner.module.js";
6
+ import { useId as a, useState as o } from "react";
7
+ import { jsx as s, jsxs as c } from "react/jsx-runtime";
8
+ import { X as l } from "lucide-react";
8
9
  //#region src/components/InstallBanner/InstallBanner.tsx
9
- function c(e) {
10
+ function u(e, t) {
10
11
  if (!e || typeof window > "u") return !1;
11
12
  try {
12
- return window.localStorage.getItem(e) === "1";
13
+ let n = window.localStorage.getItem(e);
14
+ if (!n) return !1;
15
+ if (n === "1") return !0;
16
+ let r = Number(n);
17
+ return Number.isFinite(r) ? t === void 0 || Date.now() - r < t : !1;
13
18
  } catch {
14
19
  return !1;
15
20
  }
16
21
  }
17
- function l({ title: l = "Instale o app", description: u, installLabel: d = "Instalar", dismissLabel: f = "Dispensar", icon: p, storageKey: m, onResult: h, className: g }) {
18
- let { installable: _, installed: v, isStandalone: y, prompt: b } = n(), [x, S] = i(() => c(m));
19
- return !_ || v || y || x ? null : /* @__PURE__ */ o("div", {
20
- className: e(r.banner, g),
22
+ function d({ title: d = "Instale o app", description: f, installLabel: p = "Instalar", hintLabel: m = "Como instalar", dismissLabel: h = "Dispensar", icon: g, storageKey: _, declineCooldownMs: v, renderHint: y = r, manualFallbackDelayMs: b, onResult: x, className: S }) {
23
+ let { method: C, openInChromeIntent: w, install: T } = n({ manualFallbackDelayMs: b }), [E, D] = o(() => u(_, v)), [O, k] = o(!1), A = a();
24
+ if (C === "none" || E) return null;
25
+ let j = () => {
26
+ if (D(!0), _ && typeof window < "u") try {
27
+ window.localStorage.setItem(_, v === void 0 ? "1" : String(Date.now()));
28
+ } catch {}
29
+ }, M = C === "native" ? null : y({
30
+ method: C,
31
+ openInChromeIntent: w
32
+ });
33
+ return /* @__PURE__ */ c("div", {
34
+ className: e(i.banner, S),
21
35
  role: "region",
22
- "aria-label": String(l),
36
+ "aria-label": String(d),
23
37
  children: [
24
- p && /* @__PURE__ */ a("span", {
25
- className: r.icon,
26
- children: p
38
+ g && /* @__PURE__ */ s("span", {
39
+ className: i.icon,
40
+ children: g
27
41
  }),
28
- /* @__PURE__ */ o("div", {
29
- className: r.body,
30
- children: [/* @__PURE__ */ a("p", {
31
- className: r.title,
32
- children: l
33
- }), u && /* @__PURE__ */ a("p", {
34
- className: r.description,
35
- children: u
36
- })]
42
+ /* @__PURE__ */ c("div", {
43
+ className: i.body,
44
+ children: [
45
+ /* @__PURE__ */ s("p", {
46
+ className: i.title,
47
+ children: d
48
+ }),
49
+ f && /* @__PURE__ */ s("p", {
50
+ className: i.description,
51
+ children: f
52
+ }),
53
+ O && M ? /* @__PURE__ */ s("p", {
54
+ className: i.hint,
55
+ id: A,
56
+ children: M
57
+ }) : null
58
+ ]
37
59
  }),
38
- /* @__PURE__ */ a(t, {
60
+ C === "native" ? /* @__PURE__ */ s(t, {
39
61
  size: "sm",
40
62
  onClick: async () => {
41
- h?.(await b());
63
+ let e = await T();
64
+ x?.(e ? "accepted" : "dismissed");
42
65
  },
43
- children: d
66
+ children: p
67
+ }) : /* @__PURE__ */ s(t, {
68
+ size: "sm",
69
+ "aria-expanded": O,
70
+ "aria-controls": O && M ? A : void 0,
71
+ onClick: () => k((e) => !e),
72
+ children: m
44
73
  }),
45
- /* @__PURE__ */ a("button", {
74
+ /* @__PURE__ */ s("button", {
46
75
  type: "button",
47
- className: r.close,
48
- "aria-label": f,
49
- onClick: () => {
50
- if (S(!0), m && typeof window < "u") try {
51
- window.localStorage.setItem(m, "1");
52
- } catch {}
53
- },
54
- children: /* @__PURE__ */ a(s, {
76
+ className: i.close,
77
+ "aria-label": h,
78
+ onClick: j,
79
+ children: /* @__PURE__ */ s(l, {
55
80
  size: 18,
56
81
  "aria-hidden": !0
57
82
  })
@@ -60,6 +85,6 @@ function l({ title: l = "Instale o app", description: u, installLabel: d = "Inst
60
85
  });
61
86
  }
62
87
  //#endregion
63
- export { l as InstallBanner };
88
+ export { d as InstallBanner };
64
89
 
65
90
  //# sourceMappingURL=InstallBanner.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"InstallBanner.js","names":[],"sources":["../../../src/components/InstallBanner/InstallBanner.tsx"],"sourcesContent":["/**\n * @tempest-limits props-count — title, description, installLabel and dismissLabel\n * are four strings the app has to write, icon and className the look, storageKey the\n * dismissal memory and onResult the outcome. An install prompt with SDK-authored\n * copy is the one thing nobody ships.\n */\nimport { useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { X } from \"lucide-react\";\nimport { cn } from \"@/utils/cn\";\nimport { Button } from \"@/components/Button\";\nimport { useBeforeInstallPrompt } from \"@/hooks/use-before-install-prompt\";\nimport type { InstallOutcome } from \"@/components/InstallButton\";\nimport styles from \"./InstallBanner.module.css\";\n\nexport interface InstallBannerProps {\n /** Headline. Default `\"Instale o app\"`. */\n title?: ReactNode;\n /** Supporting copy under the title. */\n description?: ReactNode;\n /** Install button label. Default `\"Instalar\"`. */\n installLabel?: string;\n /** Accessible label for the dismiss button. Default `\"Dispensar\"`. */\n dismissLabel?: string;\n /** Optional leading icon. */\n icon?: ReactNode;\n /**\n * `localStorage` key used to remember dismissal across reloads. Omit to\n * make dismissal last only for the current session (component state).\n */\n storageKey?: string;\n /** Called with the user's choice after the install prompt resolves. */\n onResult?: (outcome: InstallOutcome) => void;\n className?: string;\n}\n\nfunction readDismissed(storageKey?: string): boolean {\n if (!storageKey || typeof window === \"undefined\") return false;\n try {\n return window.localStorage.getItem(storageKey) === \"1\";\n } catch {\n return false;\n }\n}\n\n/**\n * Dismissible bottom banner that invites the user to install the PWA. Wired to\n * {@link useBeforeInstallPrompt}: it renders only when the browser captured an\n * install prompt and the app is not already running standalone — so on\n * platforms that never fire `beforeinstallprompt` (e.g. iOS Safari) it stays\n * hidden and you can surface manual instructions elsewhere.\n *\n * @tempest-limits empty-catch — persisting the dismissal is a courtesy, not the\n * feature. When `localStorage` refuses the write (quota, private mode) the banner\n * still hides for this session; the worst case is that it comes back next visit,\n * which beats an error thrown out of a click handler that only closed a banner.\n *\n * @example\n * <InstallBanner\n * title=\"Instale o FAMACHApp\"\n * description=\"Acesso offline e atalho na tela inicial.\"\n * storageKey=\"famacha:install-dismissed\"\n * />\n */\nexport function InstallBanner({\n title = \"Instale o app\",\n description,\n installLabel = \"Instalar\",\n dismissLabel = \"Dispensar\",\n icon,\n storageKey,\n onResult,\n className,\n}: InstallBannerProps) {\n const { installable, installed, isStandalone, prompt } = useBeforeInstallPrompt();\n const [dismissed, setDismissed] = useState<boolean>(() => readDismissed(storageKey));\n\n if (!installable || installed || isStandalone || dismissed) return null;\n\n const dismiss = (): void => {\n setDismissed(true);\n if (storageKey && typeof window !== \"undefined\") {\n try {\n window.localStorage.setItem(storageKey, \"1\");\n } catch {\n /* empty */\n }\n }\n };\n\n return (\n <div className={cn(styles.banner, className)} role=\"region\" aria-label={String(title)}>\n {icon && <span className={styles.icon}>{icon}</span>}\n <div className={styles.body}>\n <p className={styles.title}>{title}</p>\n {description && <p className={styles.description}>{description}</p>}\n </div>\n <Button\n size=\"sm\"\n onClick={async () => {\n onResult?.(await prompt());\n }}\n >\n {installLabel}\n </Button>\n <button\n type=\"button\"\n className={styles.close}\n aria-label={dismissLabel}\n onClick={dismiss}\n >\n <X size={18} aria-hidden />\n </button>\n </div>\n );\n}\n"],"mappings":";;;;;;;;AAoCA,SAAS,EAAc,GAA8B;CACjD,IAAI,CAAC,KAAc,OAAO,SAAW,KAAa,OAAO;CACzD,IAAI;EACA,OAAO,OAAO,aAAa,QAAQ,CAAU,MAAM;CACvD,QAAQ;EACJ,OAAO;CACX;AACJ;AAqBA,SAAgB,EAAc,EAC1B,WAAQ,iBACR,gBACA,kBAAe,YACf,kBAAe,aACf,SACA,eACA,aACA,gBACmB;CACnB,IAAM,EAAE,gBAAa,cAAW,iBAAc,cAAW,EAAuB,GAC1E,CAAC,GAAW,KAAgB,QAAwB,EAAc,CAAU,CAAC;CAenF,OAbI,CAAC,KAAe,KAAa,KAAgB,IAAkB,OAc/D,kBAAC,OAAD;EAAK,WAAW,EAAG,EAAO,QAAQ,CAAS;EAAG,MAAK;EAAS,cAAY,OAAO,CAAK;EAApF,UAAA;GACK,KAAQ,kBAAC,QAAD;IAAM,WAAW,EAAO;IAAO,UAAA;GAAW,CAAA;GACnD,kBAAC,OAAD;IAAK,WAAW,EAAO;IAAvB,UAAA,CACI,kBAAC,KAAD;KAAG,WAAW,EAAO;KAAQ,UAAA;IAAS,CAAA,GACrC,KAAe,kBAAC,KAAD;KAAG,WAAW,EAAO;KAAc,UAAA;IAAe,CAAA,CACjE;;GACL,kBAAC,GAAD;IACI,MAAK;IACL,SAAS,YAAY;KACjB,IAAW,MAAM,EAAO,CAAC;IAC7B;IAEC,UAAA;GACG,CAAA;GACR,kBAAC,UAAD;IACI,MAAK;IACL,WAAW,EAAO;IAClB,cAAY;IACZ,eA9BgB;KAExB,IADA,EAAa,EAAI,GACb,KAAc,OAAO,SAAW,KAChC,IAAI;MACA,OAAO,aAAa,QAAQ,GAAY,GAAG;KAC/C,QAAQ,CAER;IAER;IAuBY,UAAA,kBAAC,GAAD;KAAG,MAAM;KAAI,eAAA;IAAa,CAAA;GACtB,CAAA;EACP;;AAEb"}
1
+ {"version":3,"file":"InstallBanner.js","names":[],"sources":["../../../src/components/InstallBanner/InstallBanner.tsx"],"sourcesContent":["/**\n * @tempest-limits props-count — title, description, installLabel and dismissLabel\n * are four strings the app has to write, icon and className the look, storageKey the\n * dismissal memory and onResult the outcome. An install prompt with SDK-authored\n * copy is the one thing nobody ships.\n */\nimport { useId, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { X } from \"lucide-react\";\nimport { cn } from \"@/utils/cn\";\nimport { Button } from \"@/components/Button\";\nimport { useInstallPrompt } from \"@/hooks/use-install-prompt\";\nimport { defaultInstallHint } from \"@/components/InstallButton/install-hints\";\nimport type { RenderInstallHint } from \"@/components/InstallButton/install-hints\";\nimport type { InstallOutcome } from \"@/components/InstallButton\";\nimport styles from \"./InstallBanner.module.css\";\n\nexport interface InstallBannerProps {\n /** Headline. Default `\"Instale o app\"`. */\n title?: ReactNode;\n /** Supporting copy under the title. */\n description?: ReactNode;\n /** Install button label. Default `\"Instalar\"`. */\n installLabel?: string;\n /** Accessible label for the dismiss button. Default `\"Dispensar\"`. */\n dismissLabel?: string;\n /** Optional leading icon. */\n icon?: ReactNode;\n /**\n * `localStorage` key used to remember dismissal across reloads. Omit to\n * make dismissal last only for the current session (component state).\n */\n storageKey?: string;\n /**\n * How long, in ms, a dismissal lasts before the banner may return.\n *\n * Omitted, a dismissal written to `storageKey` is permanent, which is what\n * the component always did and what a stored `\"1\"` keeps meaning. With a\n * cooldown the dismissal is stored as a timestamp instead, so the banner\n * comes back after the window — the same shape `useInstallPrompt` uses for\n * its own decline.\n */\n declineCooldownMs?: number;\n /**\n * Install button label used when the browser cannot be prompted and the\n * banner shows the manual instruction. Default `\"Como instalar\"`.\n */\n hintLabel?: string;\n /**\n * Replaces the instruction shown for the `\"ios\"` and `\"manual\"` methods.\n *\n * The default copy is in PT-BR and names the real menu entries.\n */\n renderHint?: RenderInstallHint;\n /**\n * How long, in ms, to wait for `beforeinstallprompt` before falling back to\n * the manual instruction. Forwarded to {@link useInstallPrompt}; defaults to\n * 3000 there.\n */\n manualFallbackDelayMs?: number;\n /** Called with the user's choice after the install prompt resolves. */\n onResult?: (outcome: InstallOutcome) => void;\n className?: string;\n}\n\n/**\n * Whether the user already dismissed this banner.\n *\n * Two stored shapes, and both have to keep working: `\"1\"` is the permanent\n * dismissal the component has always written, and a timestamp is what a banner\n * with `declineCooldownMs` writes. A `\"1\"` found while a cooldown is configured\n * still counts as dismissed forever — it was written under the old contract, and\n * reviving a banner the user turned off is worse than keeping it off.\n *\n * @param storageKey - The key holding the dismissal, if any.\n * @param declineCooldownMs - How long a timestamped dismissal lasts.\n * @returns Whether the banner should stay hidden.\n */\nfunction readDismissed(storageKey?: string, declineCooldownMs?: number): boolean {\n if (!storageKey || typeof window === \"undefined\") return false;\n try {\n const raw = window.localStorage.getItem(storageKey);\n if (!raw) return false;\n if (raw === \"1\") return true;\n const dismissedAt = Number(raw);\n if (!Number.isFinite(dismissedAt)) return false;\n if (declineCooldownMs === undefined) return true;\n return Date.now() - dismissedAt < declineCooldownMs;\n } catch {\n return false;\n }\n}\n\n/**\n * Dismissible bottom banner that invites the user to install the PWA, wired to\n * {@link useInstallPrompt}.\n *\n * Where the browser fires `beforeinstallprompt`, the button installs. Where it\n * does not — iOS Safari, and the Android Chromium forks that strip the API — the\n * banner shows that platform's instruction instead of disappearing. It used to\n * disappear: built on `useBeforeInstallPrompt`, it rendered `null` exactly where\n * the user has no other way to find the install entry, which is why every app\n * kept a local copy of this component just to add the two missing paths.\n *\n * @tempest-limits empty-catch — persisting the dismissal is a courtesy, not the\n * feature. When `localStorage` refuses the write (quota, private mode) the banner\n * still hides for this session; the worst case is that it comes back next visit,\n * which beats an error thrown out of a click handler that only closed a banner.\n *\n * @example\n * <InstallBanner\n * title=\"Instale o FAMACHApp\"\n * description=\"Acesso offline e atalho na tela inicial.\"\n * storageKey=\"famacha:install-dismissed\"\n * />\n */\nexport function InstallBanner({\n title = \"Instale o app\",\n description,\n installLabel = \"Instalar\",\n hintLabel = \"Como instalar\",\n dismissLabel = \"Dispensar\",\n icon,\n storageKey,\n declineCooldownMs,\n renderHint = defaultInstallHint,\n manualFallbackDelayMs,\n onResult,\n className,\n}: InstallBannerProps) {\n const { method, openInChromeIntent, install } = useInstallPrompt({ manualFallbackDelayMs });\n const [dismissed, setDismissed] = useState<boolean>(() =>\n readDismissed(storageKey, declineCooldownMs),\n );\n const [hintOpen, setHintOpen] = useState(false);\n const hintId = useId();\n\n if (method === \"none\" || dismissed) return null;\n\n const dismiss = (): void => {\n setDismissed(true);\n if (storageKey && typeof window !== \"undefined\") {\n try {\n window.localStorage.setItem(\n storageKey,\n declineCooldownMs === undefined ? \"1\" : String(Date.now()),\n );\n } catch {\n /* empty */\n }\n }\n };\n\n const hint = method === \"native\" ? null : renderHint({ method, openInChromeIntent });\n\n return (\n <div className={cn(styles.banner, className)} role=\"region\" aria-label={String(title)}>\n {icon && <span className={styles.icon}>{icon}</span>}\n <div className={styles.body}>\n <p className={styles.title}>{title}</p>\n {description && <p className={styles.description}>{description}</p>}\n {hintOpen && hint ? (\n <p className={styles.hint} id={hintId}>\n {hint}\n </p>\n ) : null}\n </div>\n {method === \"native\" ? (\n <Button\n size=\"sm\"\n onClick={async () => {\n const accepted = await install();\n onResult?.(accepted ? \"accepted\" : \"dismissed\");\n }}\n >\n {installLabel}\n </Button>\n ) : (\n <Button\n size=\"sm\"\n aria-expanded={hintOpen}\n aria-controls={hintOpen && hint ? hintId : undefined}\n onClick={() => setHintOpen((open) => !open)}\n >\n {hintLabel}\n </Button>\n )}\n <button\n type=\"button\"\n className={styles.close}\n aria-label={dismissLabel}\n onClick={dismiss}\n >\n <X size={18} aria-hidden />\n </button>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AA8EA,SAAS,EAAc,GAAqB,GAAqC;CAC7E,IAAI,CAAC,KAAc,OAAO,SAAW,KAAa,OAAO;CACzD,IAAI;EACA,IAAM,IAAM,OAAO,aAAa,QAAQ,CAAU;EAClD,IAAI,CAAC,GAAK,OAAO;EACjB,IAAI,MAAQ,KAAK,OAAO;EACxB,IAAM,IAAc,OAAO,CAAG;EAG9B,OAFK,OAAO,SAAS,CAAW,IAC5B,MAAsB,KAAA,KACnB,KAAK,IAAI,IAAI,IAAc,IAFQ;CAG9C,QAAQ;EACJ,OAAO;CACX;AACJ;AAyBA,SAAgB,EAAc,EAC1B,WAAQ,iBACR,gBACA,kBAAe,YACf,eAAY,iBACZ,kBAAe,aACf,SAC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AA;GACG,CAAA;GAEZ,kBAAC,UAAD;IACI,MAAK;IACL,WAAW,EAAO;IAClB,cAAY;IACZ,SAAS;IAET,UAAA,kBAAC,GAAD;KAAG,MAAM;KAAI,eAAA;IAAa,CAAA;GACtB,CAAA;EACP;;AAEb"}
@@ -1,3 +1,3 @@
1
1
  require("../../styles/component/InstallBanner.css");
2
- var e=`tempest_banner_0oCIc`,t=`tempest_icon_izjRL`,n=`tempest_body_9JAQv`,r=`tempest_title_1E50X`,i=`tempest_description_QY25-`,a=`tempest_close_RN6FO`,o={banner:e,icon:t,body:n,title:r,description:i,close:a};exports.banner=e,exports.body=n,exports.close=a,exports.default=o,exports.description=i,exports.icon=t,exports.title=r;
2
+ var e=`tempest_banner_0oCIc`,t=`tempest_icon_izjRL`,n=`tempest_body_9JAQv`,r=`tempest_title_1E50X`,i=`tempest_description_QY25-`,a=`tempest_close_RN6FO`,o=`tempest_hint_aYJgR`,s={banner:e,icon:t,body:n,title:r,description:i,close:a,hint:o};exports.banner=e,exports.body=n,exports.close=a,exports.default=s,exports.description=i,exports.hint=o,exports.icon=t,exports.title=r;
3
3
  //# sourceMappingURL=InstallBanner.module.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"InstallBanner.module.cjs","names":[],"sources":["../../../src/components/InstallBanner/InstallBanner.module.css"],"sourcesContent":[".banner {\n display: flex;\n align-items: center;\n gap: var(--tempest-space-3);\n padding: var(--tempest-space-3) var(--tempest-space-4);\n border-radius: var(--tempest-radius-lg);\n border: 1px solid var(--tempest-border);\n background: var(--tempest-surface);\n color: var(--tempest-text);\n box-shadow: var(--tempest-shadow-lg);\n width: 100%;\n font-family: var(--tempest-font-sans);\n font-size: var(--tempest-text-sm);\n line-height: var(--tempest-leading-snug);\n}\n\n.icon {\n flex: 0 0 auto;\n display: inline-flex;\n align-items: center;\n line-height: 1;\n color: var(--tempest-primary);\n}\n\n.body {\n flex: 1 1 auto;\n min-width: 0;\n}\n\n.title {\n margin: 0;\n font-weight: var(--tempest-weight-semibold);\n color: var(--tempest-text);\n}\n\n.description {\n margin: var(--tempest-space-1) 0 0;\n color: var(--tempest-text-muted);\n}\n\n.close {\n flex: 0 0 auto;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: none;\n border: 0;\n color: var(--tempest-text-muted);\n cursor: pointer;\n padding: 0;\n width: 28px;\n height: 28px;\n border-radius: var(--tempest-radius-sm);\n}\n\n.close:hover {\n background: color-mix(in srgb, currentColor 10%, transparent);\n}\n"],"mappings":";"}
1
+ {"version":3,"file":"InstallBanner.module.cjs","names":[],"sources":["../../../src/components/InstallBanner/InstallBanner.module.css"],"sourcesContent":[".banner {\n display: flex;\n align-items: center;\n gap: var(--tempest-space-3);\n padding: var(--tempest-space-3) var(--tempest-space-4);\n border-radius: var(--tempest-radius-lg);\n border: 1px solid var(--tempest-border);\n background: var(--tempest-surface);\n color: var(--tempest-text);\n box-shadow: var(--tempest-shadow-lg);\n width: 100%;\n font-family: var(--tempest-font-sans);\n font-size: var(--tempest-text-sm);\n line-height: var(--tempest-leading-snug);\n}\n\n.icon {\n flex: 0 0 auto;\n display: inline-flex;\n align-items: center;\n line-height: 1;\n color: var(--tempest-primary);\n}\n\n.body {\n flex: 1 1 auto;\n min-width: 0;\n}\n\n.title {\n margin: 0;\n font-weight: var(--tempest-weight-semibold);\n color: var(--tempest-text);\n}\n\n.description {\n margin: var(--tempest-space-1) 0 0;\n color: var(--tempest-text-muted);\n}\n\n.close {\n flex: 0 0 auto;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: none;\n border: 0;\n color: var(--tempest-text-muted);\n cursor: pointer;\n padding: 0;\n width: 28px;\n height: 28px;\n border-radius: var(--tempest-radius-sm);\n}\n\n.close:hover {\n background: color-mix(in srgb, currentColor 10%, transparent);\n}\n\n.hint {\n margin: var(--tempest-space-2) 0 0;\n color: var(--tempest-text-muted);\n}\n\n.hint a {\n color: var(--tempest-primary);\n}\n"],"mappings":";"}
@@ -1,14 +1,15 @@
1
1
  import "../../styles/component/InstallBanner.css";
2
2
  //#region src/components/InstallBanner/InstallBanner.module.css
3
- var e = "tempest_banner_0oCIc", t = "tempest_icon_izjRL", n = "tempest_body_9JAQv", r = "tempest_title_1E50X", i = "tempest_description_QY25-", a = "tempest_close_RN6FO", o = {
3
+ var e = "tempest_banner_0oCIc", t = "tempest_icon_izjRL", n = "tempest_body_9JAQv", r = "tempest_title_1E50X", i = "tempest_description_QY25-", a = "tempest_close_RN6FO", o = "tempest_hint_aYJgR", s = {
4
4
  banner: e,
5
5
  icon: t,
6
6
  body: n,
7
7
  title: r,
8
8
  description: i,
9
- close: a
9
+ close: a,
10
+ hint: o
10
11
  };
11
12
  //#endregion
12
- export { e as banner, n as body, a as close, o as default, i as description, t as icon, r as title };
13
+ export { e as banner, n as body, a as close, s as default, i as description, o as hint, t as icon, r as title };
13
14
 
14
15
  //# sourceMappingURL=InstallBanner.module.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"InstallBanner.module.js","names":[],"sources":["../../../src/components/InstallBanner/InstallBanner.module.css"],"sourcesContent":[".banner {\n display: flex;\n align-items: center;\n gap: var(--tempest-space-3);\n padding: var(--tempest-space-3) var(--tempest-space-4);\n border-radius: var(--tempest-radius-lg);\n border: 1px solid var(--tempest-border);\n background: var(--tempest-surface);\n color: var(--tempest-text);\n box-shadow: var(--tempest-shadow-lg);\n width: 100%;\n font-family: var(--tempest-font-sans);\n font-size: var(--tempest-text-sm);\n line-height: var(--tempest-leading-snug);\n}\n\n.icon {\n flex: 0 0 auto;\n display: inline-flex;\n align-items: center;\n line-height: 1;\n color: var(--tempest-primary);\n}\n\n.body {\n flex: 1 1 auto;\n min-width: 0;\n}\n\n.title {\n margin: 0;\n font-weight: var(--tempest-weight-semibold);\n color: var(--tempest-text);\n}\n\n.description {\n margin: var(--tempest-space-1) 0 0;\n color: var(--tempest-text-muted);\n}\n\n.close {\n flex: 0 0 auto;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: none;\n border: 0;\n color: var(--tempest-text-muted);\n cursor: pointer;\n padding: 0;\n width: 28px;\n height: 28px;\n border-radius: var(--tempest-radius-sm);\n}\n\n.close:hover {\n background: color-mix(in srgb, currentColor 10%, transparent);\n}\n"],"mappings":";"}
1
+ {"version":3,"file":"InstallBanner.module.js","names":[],"sources":["../../../src/components/InstallBanner/InstallBanner.module.css"],"sourcesContent":[".banner {\n display: flex;\n align-items: center;\n gap: var(--tempest-space-3);\n padding: var(--tempest-space-3) var(--tempest-space-4);\n border-radius: var(--tempest-radius-lg);\n border: 1px solid var(--tempest-border);\n background: var(--tempest-surface);\n color: var(--tempest-text);\n box-shadow: var(--tempest-shadow-lg);\n width: 100%;\n font-family: var(--tempest-font-sans);\n font-size: var(--tempest-text-sm);\n line-height: var(--tempest-leading-snug);\n}\n\n.icon {\n flex: 0 0 auto;\n display: inline-flex;\n align-items: center;\n line-height: 1;\n color: var(--tempest-primary);\n}\n\n.body {\n flex: 1 1 auto;\n min-width: 0;\n}\n\n.title {\n margin: 0;\n font-weight: var(--tempest-weight-semibold);\n color: var(--tempest-text);\n}\n\n.description {\n margin: var(--tempest-space-1) 0 0;\n color: var(--tempest-text-muted);\n}\n\n.close {\n flex: 0 0 auto;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: none;\n border: 0;\n color: var(--tempest-text-muted);\n cursor: pointer;\n padding: 0;\n width: 28px;\n height: 28px;\n border-radius: var(--tempest-radius-sm);\n}\n\n.close:hover {\n background: color-mix(in srgb, currentColor 10%, transparent);\n}\n\n.hint {\n margin: var(--tempest-space-2) 0 0;\n color: var(--tempest-text-muted);\n}\n\n.hint a {\n color: var(--tempest-primary);\n}\n"],"mappings":";"}