@planningcenter/tapestry 4.13.0 → 4.14.0-rc.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 (154) hide show
  1. package/dist/componentRegistrars.d.ts +1 -0
  2. package/dist/componentRegistrars.d.ts.map +1 -1
  3. package/dist/componentRegistrars.js +7 -1
  4. package/dist/componentRegistrars.js.map +1 -1
  5. package/dist/components/DataTable/ActiveFilters.d.ts +3 -3
  6. package/dist/components/DataTable/ActiveFilters.d.ts.map +1 -1
  7. package/dist/components/DataTable/ActiveFilters.js +8 -5
  8. package/dist/components/DataTable/ActiveFilters.js.map +1 -1
  9. package/dist/components/DataTable/DataTable.d.ts +22 -21
  10. package/dist/components/DataTable/DataTable.d.ts.map +1 -1
  11. package/dist/components/DataTable/DataTable.js +47 -37
  12. package/dist/components/DataTable/DataTable.js.map +1 -1
  13. package/dist/components/DataTable/DataTableColumn.d.ts +15 -3
  14. package/dist/components/DataTable/DataTableColumn.d.ts.map +1 -1
  15. package/dist/components/DataTable/DataTableColumnTypes.d.ts.map +1 -1
  16. package/dist/components/DataTable/DataTableColumnTypes.js +9 -0
  17. package/dist/components/DataTable/DataTableColumnTypes.js.map +1 -1
  18. package/dist/components/DataTable/DeleteSavedViewAlertDialog.d.ts +1 -1
  19. package/dist/components/DataTable/DeleteSavedViewAlertDialog.d.ts.map +1 -1
  20. package/dist/components/DataTable/DeleteSavedViewAlertDialog.js.map +1 -1
  21. package/dist/components/DataTable/ManageViewsButton.d.ts +9 -0
  22. package/dist/components/DataTable/ManageViewsButton.d.ts.map +1 -0
  23. package/dist/components/DataTable/{ManageSavedViewsButton.js → ManageViewsButton.js} +5 -5
  24. package/dist/components/DataTable/ManageViewsButton.js.map +1 -0
  25. package/dist/components/DataTable/{ManageSavedViewsModal.d.ts → ManageViewsModal.d.ts} +7 -7
  26. package/dist/components/DataTable/ManageViewsModal.d.ts.map +1 -0
  27. package/dist/components/DataTable/{ManageSavedViewsModal.js → ManageViewsModal.js} +10 -10
  28. package/dist/components/DataTable/ManageViewsModal.js.map +1 -0
  29. package/dist/components/DataTable/ManageViewsModal.module.css.js +4 -0
  30. package/dist/components/DataTable/ManageViewsModal.module.css.js.map +1 -0
  31. package/dist/components/DataTable/NewSavedViewButton.js +1 -1
  32. package/dist/components/DataTable/NewSavedViewButton.js.map +1 -1
  33. package/dist/components/DataTable/OperatorSelect.js +4 -1
  34. package/dist/components/DataTable/OperatorSelect.js.map +1 -1
  35. package/dist/components/DataTable/RowActions.d.ts +4 -0
  36. package/dist/components/DataTable/RowActions.d.ts.map +1 -1
  37. package/dist/components/DataTable/RowActions.js +3 -3
  38. package/dist/components/DataTable/RowActions.js.map +1 -1
  39. package/dist/components/DataTable/ViewMenu.d.ts +18 -0
  40. package/dist/components/DataTable/ViewMenu.d.ts.map +1 -0
  41. package/dist/components/DataTable/{SavedViewMenu.js → ViewMenu.js} +5 -5
  42. package/dist/components/DataTable/ViewMenu.js.map +1 -0
  43. package/dist/components/DataTable/{SavedViewsBar.d.ts → ViewsBar.d.ts} +11 -11
  44. package/dist/components/DataTable/ViewsBar.d.ts.map +1 -0
  45. package/dist/components/DataTable/{SavedViewsBar.js → ViewsBar.js} +27 -27
  46. package/dist/components/DataTable/ViewsBar.js.map +1 -0
  47. package/dist/components/DataTable/dateFilter.d.ts +17 -3
  48. package/dist/components/DataTable/dateFilter.d.ts.map +1 -1
  49. package/dist/components/DataTable/dateFilter.js +19 -3
  50. package/dist/components/DataTable/dateFilter.js.map +1 -1
  51. package/dist/components/DataTable/index.d.ts +3 -3
  52. package/dist/components/DataTable/index.d.ts.map +1 -1
  53. package/dist/components/DataTable/useActiveView.d.ts +7 -0
  54. package/dist/components/DataTable/useActiveView.d.ts.map +1 -0
  55. package/dist/components/DataTable/{useActiveSavedView.js → useActiveView.js} +5 -5
  56. package/dist/components/DataTable/useActiveView.js.map +1 -0
  57. package/dist/components/DataTable/useColumnVisibility.d.ts +12 -8
  58. package/dist/components/DataTable/useColumnVisibility.d.ts.map +1 -1
  59. package/dist/components/DataTable/useColumnVisibility.js +28 -16
  60. package/dist/components/DataTable/useColumnVisibility.js.map +1 -1
  61. package/dist/components/DataTable/useSaveStatus.d.ts +6 -6
  62. package/dist/components/DataTable/useSaveStatus.d.ts.map +1 -1
  63. package/dist/components/DataTable/useSaveStatus.js +7 -7
  64. package/dist/components/DataTable/useSaveStatus.js.map +1 -1
  65. package/dist/components/DataTable/useSavedViewNameModal.d.ts +2 -2
  66. package/dist/components/DataTable/useSavedViewNameModal.d.ts.map +1 -1
  67. package/dist/components/DataTable/useSavedViewNameModal.js +2 -2
  68. package/dist/components/DataTable/useSavedViewNameModal.js.map +1 -1
  69. package/dist/components/DataTable/useSavedViewsClient.d.ts +3 -3
  70. package/dist/components/DataTable/useSavedViewsClient.d.ts.map +1 -1
  71. package/dist/components/DataTable/useSavedViewsClient.js +1 -1
  72. package/dist/components/DataTable/useSavedViewsClient.js.map +1 -1
  73. package/dist/components/DataTable/useSavedViewsState.d.ts +7 -7
  74. package/dist/components/DataTable/useSavedViewsState.d.ts.map +1 -1
  75. package/dist/components/DataTable/useSavedViewsState.js +1 -1
  76. package/dist/components/DataTable/useSavedViewsState.js.map +1 -1
  77. package/dist/components/DataTable/useUpdateSavedViewName.d.ts +1 -1
  78. package/dist/components/DataTable/useUpdateSavedViewName.d.ts.map +1 -1
  79. package/dist/components/DataTable/useUpdateSavedViewName.js.map +1 -1
  80. package/dist/components/DataTable/{useVisibleSavedViews.d.ts → useVisibleViews.d.ts} +2 -2
  81. package/dist/components/DataTable/useVisibleViews.d.ts.map +1 -0
  82. package/dist/components/DataTable/{useVisibleSavedViews.js → useVisibleViews.js} +6 -6
  83. package/dist/components/DataTable/useVisibleViews.js.map +1 -0
  84. package/dist/components/DataTable/views.d.ts +56 -0
  85. package/dist/components/DataTable/views.d.ts.map +1 -0
  86. package/dist/components/DataTable/{savedViews.js → views.js} +12 -11
  87. package/dist/components/DataTable/views.js.map +1 -0
  88. package/dist/components/button/ActionsDropdownIconButton.d.ts +2 -2
  89. package/dist/components/button/ActionsDropdownIconButton.d.ts.map +1 -1
  90. package/dist/components/button/ActionsDropdownIconButton.js.map +1 -1
  91. package/dist/components/button/IconButton.d.ts +2 -2
  92. package/dist/components/button/IconButton.d.ts.map +1 -1
  93. package/dist/components/button/IconButton.js.map +1 -1
  94. package/dist/components/checkbox-group/CheckboxGroup.d.ts +3 -1
  95. package/dist/components/checkbox-group/CheckboxGroup.d.ts.map +1 -1
  96. package/dist/components/checkbox-group/CheckboxGroup.js +2 -2
  97. package/dist/components/checkbox-group/CheckboxGroup.js.map +1 -1
  98. package/dist/components/date-picker/DatePicker.d.ts +7 -2
  99. package/dist/components/date-picker/DatePicker.d.ts.map +1 -1
  100. package/dist/components/date-picker/DatePicker.js +69 -14
  101. package/dist/components/date-picker/DatePicker.js.map +1 -1
  102. package/dist/components/dropdown/Dropdown.d.ts.map +1 -1
  103. package/dist/components/dropdown/Dropdown.js +10 -2
  104. package/dist/components/dropdown/Dropdown.js.map +1 -1
  105. package/dist/components/link/BaseLink.js +3 -3
  106. package/dist/components/link/BaseLink.js.map +1 -1
  107. package/dist/components/link/IconLink.js +4 -4
  108. package/dist/components/link/IconLink.js.map +1 -1
  109. package/dist/components/link/Link.js +2 -2
  110. package/dist/components/link/Link.js.map +1 -1
  111. package/dist/components/radio-group/RadioGroup.d.ts +7 -1
  112. package/dist/components/radio-group/RadioGroup.d.ts.map +1 -1
  113. package/dist/components/radio-group/RadioGroup.js +2 -2
  114. package/dist/components/radio-group/RadioGroup.js.map +1 -1
  115. package/dist/index.css +107 -27
  116. package/dist/index.css.map +1 -1
  117. package/dist/packages/tapestry-wc/dist/components/tds-page-header.js +2 -2
  118. package/dist/packages/tapestry-wc/dist/components/tds-page-header.js.map +1 -1
  119. package/dist/reactRender.css +1535 -1436
  120. package/dist/reactRender.css.map +1 -1
  121. package/dist/reactRender.js +1 -1
  122. package/dist/reactRenderLegacy.css +1535 -1436
  123. package/dist/reactRenderLegacy.css.map +1 -1
  124. package/dist/reactRenderLegacy.js +1 -1
  125. package/dist/tapestryMount.css +1535 -1436
  126. package/dist/tapestryMount.css.map +1 -1
  127. package/dist/tapestryMount.js +1 -1
  128. package/dist/tapestryMountLegacy.css +1535 -1436
  129. package/dist/tapestryMountLegacy.css.map +1 -1
  130. package/dist/tapestryMountLegacy.js +1 -1
  131. package/dist/unstable.css +381 -282
  132. package/dist/unstable.css.map +1 -1
  133. package/package.json +3 -3
  134. package/react-types/index.d.ts +5 -0
  135. package/dist/components/DataTable/ManageSavedViewsButton.d.ts +0 -9
  136. package/dist/components/DataTable/ManageSavedViewsButton.d.ts.map +0 -1
  137. package/dist/components/DataTable/ManageSavedViewsButton.js.map +0 -1
  138. package/dist/components/DataTable/ManageSavedViewsModal.d.ts.map +0 -1
  139. package/dist/components/DataTable/ManageSavedViewsModal.js.map +0 -1
  140. package/dist/components/DataTable/ManageSavedViewsModal.module.css.js +0 -4
  141. package/dist/components/DataTable/ManageSavedViewsModal.module.css.js.map +0 -1
  142. package/dist/components/DataTable/SavedViewMenu.d.ts +0 -18
  143. package/dist/components/DataTable/SavedViewMenu.d.ts.map +0 -1
  144. package/dist/components/DataTable/SavedViewMenu.js.map +0 -1
  145. package/dist/components/DataTable/SavedViewsBar.d.ts.map +0 -1
  146. package/dist/components/DataTable/SavedViewsBar.js.map +0 -1
  147. package/dist/components/DataTable/savedViews.d.ts +0 -45
  148. package/dist/components/DataTable/savedViews.d.ts.map +0 -1
  149. package/dist/components/DataTable/savedViews.js.map +0 -1
  150. package/dist/components/DataTable/useActiveSavedView.d.ts +0 -7
  151. package/dist/components/DataTable/useActiveSavedView.d.ts.map +0 -1
  152. package/dist/components/DataTable/useActiveSavedView.js.map +0 -1
  153. package/dist/components/DataTable/useVisibleSavedViews.d.ts.map +0 -1
  154. package/dist/components/DataTable/useVisibleSavedViews.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useSavedViewNameModal.js","sources":["../../../src/components/DataTable/useSavedViewNameModal.ts"],"sourcesContent":["import { useState } from \"react\"\n\nimport type { NewSavedViewModalProps } from \"./NewSavedViewModal\"\nimport { type SavedView, savedViewDuplicate } from \"./savedViews\"\nimport { useUpdateSavedViewName } from \"./useUpdateSavedViewName\"\n\n/**\n * The name modal's state, for a new view, a duplicate, or a rename. Spread\n * `modalProps` onto a `NewSavedViewModal`. What it saves outlives the modal's\n * open state, so the title holds while the modal fades out.\n */\nexport function useSavedViewNameModal(\n onUpdate?: (\n savedView: SavedView\n ) => Promise<SavedView | undefined> | SavedView\n) {\n const [draft, setDraft] = useState<{\n defaultName: string\n save: (name: string) => void\n title: string\n }>()\n const [isOpen, setIsOpen] = useState(false)\n const updateSavedViewName = useUpdateSavedViewName(onUpdate)\n\n const open = (\n title: string,\n defaultName: string,\n save: (name: string) => void\n ) => {\n setDraft({ defaultName, save, title })\n setIsOpen(true)\n }\n\n /** `create` gets the duplicate under the entered name, without an id. */\n const openDuplicate = (\n view: SavedView,\n create: (duplicate: Omit<SavedView, \"id\">) => void\n ) => {\n open(\"Duplicate view\", `${view.name} copy`, (name) =>\n create(savedViewDuplicate(view, name))\n )\n }\n\n /** `track` gets the rename's save. */\n const openRename = (\n view: SavedView,\n track: (saving: Promise<void>) => void\n ) => {\n open(\"Rename view\", view.name, (name) => {\n if (name !== view.name) track(updateSavedViewName(view, name))\n })\n }\n\n const modalProps: NewSavedViewModalProps = {\n defaultName: draft?.defaultName,\n onClose: () => setIsOpen(false),\n onSave: (name) => {\n setIsOpen(false)\n draft?.save(name)\n },\n open: isOpen,\n title: draft?.title,\n }\n\n return { modalProps, open, openDuplicate, openRename }\n}\n"],"names":[],"mappings":";;;;AAMA;;;;AAIG;AACG,SAAU,qBAAqB,CACnC,QAE+C,EAAA;IAE/C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAI9B;IACJ,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,KAA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/DataTable/useSavedViewNameModal.ts"],"sourcesContent":["import { useState } from \"react\"\n\nimport type { NewSavedViewModalProps } from \"./NewSavedViewModal\"\nimport { useUpdateSavedViewName } from \"./useUpdateSavedViewName\"\nimport { type SavedView, type View, viewDuplicate } from \"./views\"\n\n/**\n * The name modal's state, for a new view, a duplicate, or a rename. Spread\n * `modalProps` onto a `NewSavedViewModal`. What it saves outlives the modal's\n * open state, so the title holds while the modal fades out.\n */\nexport function useSavedViewNameModal(\n onUpdate?: (\n savedView: SavedView\n ) => Promise<SavedView | undefined> | SavedView\n) {\n const [draft, setDraft] = useState<{\n defaultName: string\n save: (name: string) => void\n title: string\n }>()\n const [isOpen, setIsOpen] = useState(false)\n const updateSavedViewName = useUpdateSavedViewName(onUpdate)\n\n const open = (\n title: string,\n defaultName: string,\n save: (name: string) => void\n ) => {\n setDraft({ defaultName, save, title })\n setIsOpen(true)\n }\n\n /** `create` gets the duplicate under the entered name, without an id. */\n const openDuplicate = (\n view: View,\n create: (duplicate: Omit<SavedView, \"id\">) => void\n ) => {\n open(\"Duplicate view\", `${view.name} copy`, (name) =>\n create(viewDuplicate(view, name))\n )\n }\n\n /** `track` gets the rename's save. */\n const openRename = (\n view: SavedView,\n track: (saving: Promise<void>) => void\n ) => {\n open(\"Rename view\", view.name, (name) => {\n if (name !== view.name) track(updateSavedViewName(view, name))\n })\n }\n\n const modalProps: NewSavedViewModalProps = {\n defaultName: draft?.defaultName,\n onClose: () => setIsOpen(false),\n onSave: (name) => {\n setIsOpen(false)\n draft?.save(name)\n },\n open: isOpen,\n title: draft?.title,\n }\n\n return { modalProps, open, openDuplicate, openRename }\n}\n"],"names":[],"mappings":";;;;AAMA;;;;AAIG;AACG,SAAU,qBAAqB,CACnC,QAE+C,EAAA;IAE/C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAI9B;IACJ,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;AAC3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./views";
2
2
  /**
3
3
  * Sends requests to the saved views API. Matches
4
4
  * `@planningcenter/api-client`'s `Client`, so auth, CSRF, and the API root stay
@@ -49,10 +49,10 @@ export declare function useSavedViewsClient({ client, tableKey, }: UseSavedViews
49
49
  sort?: import("./DataTable").Sort | undefined;
50
50
  name: string;
51
51
  activeFilters: import("./FilterTypes").ActiveFilter[];
52
- hiddenColumnNames?: string[] | undefined;
52
+ visibleColumnNames?: string[] | undefined;
53
53
  }>;
54
54
  onSavedViewDelete: (view: SavedView) => Promise<void>;
55
55
  onSavedViewReorder: (view: SavedView, after: SavedView | null) => Promise<void>;
56
- onSavedViewUpdate: (view: SavedView) => Promise<SavedView>;
56
+ onSavedViewUpdate: (view: SavedView) => Promise<import("./views").View>;
57
57
  };
58
58
  //# sourceMappingURL=useSavedViewsClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useSavedViewsClient.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/useSavedViewsClient.ts"],"names":[],"mappings":"AAGA,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,cAAc,CAAA;AAE1D;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACxB,MAAM,CAAC,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAClD,KAAK,CAAC,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAC/D,IAAI,CAAC,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CAC/D;AAED,MAAM,WAAW,0BAA0B;IACzC,MAAM,EAAE,SAAS,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,MAAM,EACN,QAAQ,GACT,EAAE,0BAA0B;gCA0Cc,MAAM,GAAG,MAAM;8BAnCjB,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC;;;;;;;8BA8BrB,SAAS;+BAdxC,SAAS,SACR,SAAS,GAAG,IAAI;8BARc,SAAS;EA0DjD"}
1
+ {"version":3,"file":"useSavedViewsClient.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/useSavedViewsClient.ts"],"names":[],"mappings":"AAGA,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,SAAS,CAAA;AAErD;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACxB,MAAM,CAAC,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAClD,KAAK,CAAC,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAC/D,IAAI,CAAC,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CAC/D;AAED,MAAM,WAAW,0BAA0B;IACzC,MAAM,EAAE,SAAS,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,MAAM,EACN,QAAQ,GACT,EAAE,0BAA0B;gCA0Cc,MAAM,GAAG,MAAM;8BAnCjB,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC;;;;;;;8BA8BrB,SAAS;+BAdxC,SAAS,SACR,SAAS,GAAG,IAAI;8BARc,SAAS;EA0DjD"}
@@ -1,5 +1,5 @@
1
1
  import { useRef } from 'react';
2
- import { initialView } from './savedViews.js';
2
+ import { initialView } from './views.js';
3
3
 
4
4
  /**
5
5
  * Returns DataTable's saved view callbacks, sending each change to the saved
@@ -1 +1 @@
1
- {"version":3,"file":"useSavedViewsClient.js","sources":["../../../src/components/DataTable/useSavedViewsClient.ts"],"sourcesContent":["import { useRef } from \"react\"\n\nimport type { DataTableProps } from \"./DataTable\"\nimport { initialView, type SavedView } from \"./savedViews\"\n\n/**\n * Sends requests to the saved views API. Matches\n * `@planningcenter/api-client`'s `Client`, so auth, CSRF, and the API root stay\n * in the app; pass one whose root serves the private graph. Each method\n * resolves to the parsed response and rejects on failure.\n */\nexport interface ApiClient {\n delete(request: { url: string }): Promise<unknown>\n patch(request: { data: object; url: string }): Promise<unknown>\n post(request: { data: object; url: string }): Promise<unknown>\n}\n\nexport interface UseSavedViewsClientOptions {\n client: ApiClient\n tableKey: string\n}\n\n/**\n * Returns DataTable's saved view callbacks, sending each change to the saved\n * views endpoints that `tapestry:saved_views` adds to pco-api's private graph:\n *\n * - `POST /data_tables/:table_key/saved_views`\n * - `PATCH /data_tables/:table_key/saved_views/:id` (also takes `after_id` to\n * reorder)\n * - `DELETE /data_tables/:table_key/saved_views/:id`\n * - `POST` and `DELETE /data_tables/:table_key/saved_view_default`\n *\n * Each callback resolves once its request succeeds and rejects with the\n * client's error. Default changes are sent one at a time, so the server keeps\n * the last one chosen. DataTable shows the change right away and undoes it on\n * rejection. Doesn't load views or hold state, so pass `data_table_props` to\n * DataTable too:\n *\n * ```tsx\n * <DataTable {...dataTableProps} {...useSavedViewsClient({ client, tableKey })} />\n * ```\n */\nexport function useSavedViewsClient({\n client,\n tableKey,\n}: UseSavedViewsClientOptions) {\n const tableUrl = `/data_tables/${encodeURIComponent(tableKey)}`\n const viewUrl = (id: SavedView[\"id\"]) =>\n `${tableUrl}/saved_views/${encodeURIComponent(String(id))}`\n const defaultUrl = `${tableUrl}/saved_view_default`\n const lastDefaultChange = useRef<Promise<unknown>>(Promise.resolve())\n\n const onSavedViewCreate = async (view: Omit<SavedView, \"id\">) => {\n // Only the id is read, since clients may reshape the response\n const { data } = (await client.post({\n data: savedViewDocument(view),\n url: `${tableUrl}/saved_views`,\n })) as { data: { id: number | string } }\n return { ...view, id: data.id }\n }\n\n const onSavedViewUpdate = async (view: SavedView) => {\n await client.patch({ data: savedViewDocument(view), url: viewUrl(view.id) })\n return view\n }\n\n /** Places the view after `after`, or first when it's `null`. */\n const onSavedViewReorder = async (\n view: SavedView,\n after: SavedView | null\n ) => {\n await client.patch({\n data: {\n data: {\n attributes: { after_id: after?.id ?? null },\n type: \"SavedView\",\n },\n },\n url: viewUrl(view.id),\n })\n }\n\n const onSavedViewDelete = async (view: SavedView) => {\n await client.delete({ url: viewUrl(view.id) })\n }\n\n /** Pass the initial view's id to reset the default. */\n const onDefaultViewIdChange = async (id: number | string) => {\n const send = () =>\n id === initialView.id\n ? client.delete({ url: defaultUrl })\n : client.post({\n data: {\n data: {\n attributes: { view: String(id) },\n type: \"SavedViewDefault\",\n },\n },\n url: defaultUrl,\n })\n const change = lastDefaultChange.current.then(send, send)\n lastDefaultChange.current = change\n await change\n }\n\n return {\n onDefaultViewIdChange,\n onSavedViewCreate,\n onSavedViewDelete,\n onSavedViewReorder,\n onSavedViewUpdate,\n } satisfies Pick<\n DataTableProps,\n | \"onDefaultViewIdChange\"\n | \"onSavedViewCreate\"\n | \"onSavedViewDelete\"\n | \"onSavedViewReorder\"\n | \"onSavedViewUpdate\"\n >\n}\n\nfunction savedViewDocument(view: Omit<SavedView, \"id\">) {\n const { id: _id, name, ...state } = view as SavedView\n return { data: { attributes: { name, state }, type: \"SavedView\" } }\n}\n"],"names":[],"mappings":";;;AAsBA;;;;;;;;;;;;;;;;;;;AAmBG;SACa,mBAAmB,CAAC,EAClC,MAAM,EACN,QAAQ,GACmB,EAAA;IAC3B,MAAM,QAAQ,GAAG,CAAA,aAAA,EAAgB,kBAAkB,CAAC,QAAQ,CAAC,EAAE;AAC/D,IAAA,MAAM,OAAO,GAAG,CAAC,EAAmB,KAClC,CAAA,EAAG,QAAQ,CAAA,aAA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AAE,GAAG,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;AAChD,IAAA,CAAC;;AAGD,IAAA,MAAM,qBAAqB,GAAG,OAAO,EAAmB,KAAI;QAC1D,MAAM,IAAI,GAAG,MACX,EAAE,KAAK,WAAW,CAAC;cACf,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE;AACnC,cAAE,MAAM,CAAC,IAAI,CAAC;AACV,gBAAA,IAAI,EAAE;AACJ,oBAAA,IAAI,EAAE;wBACJ,UAAU,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,EAAE;AAChC,wBAAA,IAAI,EAAE,kBAAkB;AACzB,qBAAA;AACF,iBAAA;AACD,gBAAA,GAAG,EAAE,UAAU;AAChB,aAAA,CAAC;AACR,QAAA,MAAM,MAAM,GAAG,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC;AACzD,QAAA,iBAAiB,CAAC,OAAO,GAAG,MAAM;AAClC,QAAA,MAAM,MAAM;AACd,IAAA,CAAC;IAED,OAAO;QACL,qBAAqB;QACrB,iBAAiB;QACjB,iBAAiB;QACjB,kBAAkB;QAClB,iBAAiB;KAQlB;AACH;AAEA,SAAS,iBAAiB,CAAC,IAA2B,EAAA;AACpD,IAAA,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,GAAG,IAAiB;AACrD,IAAA,OAAO,EAAE,IAAI,EAAE,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE;AACrE;;;;"}
1
+ {"version":3,"file":"useSavedViewsClient.js","sources":["../../../src/components/DataTable/useSavedViewsClient.ts"],"sourcesContent":["import { useRef } from \"react\"\n\nimport type { DataTableProps } from \"./DataTable\"\nimport { initialView, type SavedView } from \"./views\"\n\n/**\n * Sends requests to the saved views API. Matches\n * `@planningcenter/api-client`'s `Client`, so auth, CSRF, and the API root stay\n * in the app; pass one whose root serves the private graph. Each method\n * resolves to the parsed response and rejects on failure.\n */\nexport interface ApiClient {\n delete(request: { url: string }): Promise<unknown>\n patch(request: { data: object; url: string }): Promise<unknown>\n post(request: { data: object; url: string }): Promise<unknown>\n}\n\nexport interface UseSavedViewsClientOptions {\n client: ApiClient\n tableKey: string\n}\n\n/**\n * Returns DataTable's saved view callbacks, sending each change to the saved\n * views endpoints that `tapestry:saved_views` adds to pco-api's private graph:\n *\n * - `POST /data_tables/:table_key/saved_views`\n * - `PATCH /data_tables/:table_key/saved_views/:id` (also takes `after_id` to\n * reorder)\n * - `DELETE /data_tables/:table_key/saved_views/:id`\n * - `POST` and `DELETE /data_tables/:table_key/saved_view_default`\n *\n * Each callback resolves once its request succeeds and rejects with the\n * client's error. Default changes are sent one at a time, so the server keeps\n * the last one chosen. DataTable shows the change right away and undoes it on\n * rejection. Doesn't load views or hold state, so pass `data_table_props` to\n * DataTable too:\n *\n * ```tsx\n * <DataTable {...dataTableProps} {...useSavedViewsClient({ client, tableKey })} />\n * ```\n */\nexport function useSavedViewsClient({\n client,\n tableKey,\n}: UseSavedViewsClientOptions) {\n const tableUrl = `/data_tables/${encodeURIComponent(tableKey)}`\n const viewUrl = (id: SavedView[\"id\"]) =>\n `${tableUrl}/saved_views/${encodeURIComponent(String(id))}`\n const defaultUrl = `${tableUrl}/saved_view_default`\n const lastDefaultChange = useRef<Promise<unknown>>(Promise.resolve())\n\n const onSavedViewCreate = async (view: Omit<SavedView, \"id\">) => {\n // Only the id is read, since clients may reshape the response\n const { data } = (await client.post({\n data: savedViewDocument(view),\n url: `${tableUrl}/saved_views`,\n })) as { data: { id: number | string } }\n return { ...view, id: data.id }\n }\n\n const onSavedViewUpdate = async (view: SavedView) => {\n await client.patch({ data: savedViewDocument(view), url: viewUrl(view.id) })\n return view\n }\n\n /** Places the view after `after`, or first when it's `null`. */\n const onSavedViewReorder = async (\n view: SavedView,\n after: SavedView | null\n ) => {\n await client.patch({\n data: {\n data: {\n attributes: { after_id: after?.id ?? null },\n type: \"SavedView\",\n },\n },\n url: viewUrl(view.id),\n })\n }\n\n const onSavedViewDelete = async (view: SavedView) => {\n await client.delete({ url: viewUrl(view.id) })\n }\n\n /** Pass the initial view's id to reset the default. */\n const onDefaultViewIdChange = async (id: number | string) => {\n const send = () =>\n id === initialView.id\n ? client.delete({ url: defaultUrl })\n : client.post({\n data: {\n data: {\n attributes: { view: String(id) },\n type: \"SavedViewDefault\",\n },\n },\n url: defaultUrl,\n })\n const change = lastDefaultChange.current.then(send, send)\n lastDefaultChange.current = change\n await change\n }\n\n return {\n onDefaultViewIdChange,\n onSavedViewCreate,\n onSavedViewDelete,\n onSavedViewReorder,\n onSavedViewUpdate,\n } satisfies Pick<\n DataTableProps,\n | \"onDefaultViewIdChange\"\n | \"onSavedViewCreate\"\n | \"onSavedViewDelete\"\n | \"onSavedViewReorder\"\n | \"onSavedViewUpdate\"\n >\n}\n\nfunction savedViewDocument(view: Omit<SavedView, \"id\">) {\n const { id: _id, name, ...state } = view as SavedView\n return { data: { attributes: { name, state }, type: \"SavedView\" } }\n}\n"],"names":[],"mappings":";;;AAsBA;;;;;;;;;;;;;;;;;;;AAmBG;SACa,mBAAmB,CAAC,EAClC,MAAM,EACN,QAAQ,GACmB,EAAA;IAC3B,MAAM,QAAQ,GAAG,CAAA,aAAA,EAAgB,kBAAkB,CAAC,QAAQ,CAAC,EAAE;AAC/D,IAAA,MAAM,OAAO,GAAG,CAAC,EAAmB,KAClC,CAAA,EAAG,QAAQ,CAAA,aAAA,EAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE;AAC7D,IAAA,MAAM,UAAU,GAAG,CAAA,EAAG,QAAQ,qBAAqB;IACnD,MAAM,iBAAiB,GAAG,MAAM,CAAmB,OAAO,CAAC,OAAO,EAAE,CAAC;AAErE,IAAA,MAAM,iBAAiB,GAAG,OAAO,IAA2B,KAAI;;QA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AAE;AACnC,cAAE,MAAM,CAAC,IAAI,CAAC;AACV,gBAAA,IAAI,EAAE;AACJ,oBAAA,IAAI,EAAE;wBACJ,UAAU,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,EAAE;AAChC,wBAAA,IAAI,EAAE,kBAAkB;AACzB,qBAAA;AACF,iBAAA;AACD,gBAAA,GAAG,EAAE,UAAU;AAChB,aAAA,CAAC;AACR,QAAA,MAAM,MAAM,GAAG,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC;AACzD,QAAA,iBAAiB,CAAC,OAAO,GAAG,MAAM;AAClC,QAAA,MAAM,MAAM;AACd,IAAA,CAAC;IAED,OAAO;QACL,qBAAqB;QACrB,iBAAiB;QACjB,iBAAiB;QACjB,kBAAkB;QAClB,iBAAiB;KAQlB;AACH;AAEA,SAAS,iBAAiB,CAAC,IAA2B,EAAA;AACpD,IAAA,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,GAAG,IAAiB;AACrD,IAAA,OAAO,EAAE,IAAI,EAAE,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE;AACrE;;;;"}
@@ -1,11 +1,11 @@
1
- import { type SavedView } from "./savedViews";
1
+ import { type SavedView, type View } from "./views";
2
2
  interface SavedViewsStateOptions {
3
- initialDefaultViewId: NonNullable<SavedView["id"]>;
3
+ initialDefaultViewId: NonNullable<View["id"]>;
4
4
  initialSavedViews: SavedView[] | undefined;
5
5
  onCreate?: (savedView: Omit<SavedView, "id">) => Promise<SavedView> | SavedView;
6
6
  onDelete?: (savedView: SavedView) => Promise<void> | void;
7
7
  onReorder?: (savedView: SavedView, after: SavedView | null) => Promise<void> | void;
8
- onSetDefault?: (id: NonNullable<SavedView["id"]>) => Promise<void> | void;
8
+ onSetDefault?: (id: NonNullable<View["id"]>) => Promise<void> | void;
9
9
  onUpdate?: (savedView: SavedView) => Promise<SavedView> | SavedView;
10
10
  }
11
11
  /**
@@ -19,12 +19,12 @@ interface SavedViewsStateOptions {
19
19
  export declare function useSavedViewsState({ initialDefaultViewId, initialSavedViews, onCreate, onDelete, onReorder, onSetDefault, onUpdate, }: SavedViewsStateOptions): {
20
20
  defaultViewId: string | number;
21
21
  isReordering: boolean;
22
- onCreate: ((view: Omit<SavedView, "id">) => Promise<SavedView>) | undefined;
22
+ onCreate: ((view: Omit<SavedView, "id">) => Promise<View>) | undefined;
23
23
  onDelete: ((view: SavedView) => Promise<void>) | undefined;
24
24
  onReorder: ((view: SavedView, target: ReorderTarget) => Promise<void>) | undefined;
25
- onSetDefault: ((id: NonNullable<SavedView["id"]>) => Promise<void>) | undefined;
26
- onUpdate: ((view: SavedView) => Promise<SavedView>) | undefined;
27
- savedViews: SavedView[] | undefined;
25
+ onSetDefault: ((id: NonNullable<View["id"]>) => Promise<void>) | undefined;
26
+ onUpdate: ((view: SavedView) => Promise<View>) | undefined;
27
+ savedViews: View[] | undefined;
28
28
  };
29
29
  /** Where a view was dropped, as React Aria reports it. */
30
30
  export interface ReorderTarget {
@@ -1 +1 @@
1
- {"version":3,"file":"useSavedViewsState.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/useSavedViewsState.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAiB,MAAM,cAAc,CAAA;AAE5D,UAAU,sBAAsB;IAC9B,oBAAoB,EAAE,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAA;IAClD,iBAAiB,EAAE,SAAS,EAAE,GAAG,SAAS,CAAA;IAC1C,QAAQ,CAAC,EAAE,CACT,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,KAC7B,OAAO,CAAC,SAAS,CAAC,GAAG,SAAS,CAAA;IACnC,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,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SAAS,CAAC,GAAG,SAAS,CAAA;IACnC,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IACzD,SAAS,CAAC,EAAE,CACV,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,SAAS,GAAG,IAAI,KACpB,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IACzB,YAAY,CAAC,EAAE,CAAC,EAAE,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IACpE,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,OAAO,CAAC,SAAS,CAAC,GAAG,SAAS,CAAA;CACpE;AAgCD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,oBAAoB,EACpB,iBAAiB,EACjB,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,QAAQ,GACT,EAAE,sBAAsB;;;sBAwDL,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC;sBASrB,SAAS;uBA6BT,SAAS,UAAU,aAAa;wBA6BlC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;sBAarB,SAAS;;EAoB5B;AAED,0DAA0D;AAC1D,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,OAAO,GAAG,QAAQ,CAAA;IAChC,IAAI,EAAE,SAAS,CAAA;CAChB"}
@@ -1,5 +1,5 @@
1
1
  import { useState, useRef } from 'react';
2
- import { withoutSearch } from './savedViews.js';
2
+ import { withoutSearch } from './views.js';
3
3
 
4
4
  function startSaving(updates, view) {
5
5
  updates.saving.push(view);
@@ -1 +1 @@
1
- {"version":3,"file":"useSavedViewsState.js","sources":["../../../src/components/DataTable/useSavedViewsState.ts"],"sourcesContent":["import { useRef, useState } from \"react\"\n\nimport { type SavedView, withoutSearch } from \"./savedViews\"\n\ninterface SavedViewsStateOptions {\n initialDefaultViewId: NonNullable<SavedView[\"id\"]>\n initialSavedViews: SavedView[] | undefined\n onCreate?: (\n savedView: Omit<SavedView, \"id\">\n ) => Promise<SavedView> | SavedView\n onDelete?: (savedView: SavedView) => Promise<void> | void\n onReorder?: (\n savedView: SavedView,\n after: SavedView | null\n ) => Promise<void> | void\n onSetDefault?: (id: NonNullable<SavedView[\"id\"]>) => Promise<void> | void\n onUpdate?: (savedView: SavedView) => Promise<SavedView> | SavedView\n}\n\ninterface ViewUpdates {\n confirmed: SavedView\n confirmedOrder: number\n saving: SavedView[]\n}\n\nfunction startSaving(updates: ViewUpdates, view: SavedView) {\n updates.saving.push(view)\n}\n\nfunction stopSaving(updates: ViewUpdates, view: SavedView) {\n updates.saving = updates.saving.filter((pending) => pending !== view)\n}\n\n// A slower save of an older update doesn't replace a newer one.\nfunction confirmIfNewest(\n updates: ViewUpdates,\n saved: SavedView,\n order: number\n) {\n if (order <= updates.confirmedOrder) return\n updates.confirmed = saved\n updates.confirmedOrder = order\n}\n\n// The newest update still saving, or else the last saved version.\nfunction viewToRestore(updates: ViewUpdates) {\n return updates.saving.at(-1) ?? updates.confirmed\n}\n\n/**\n * Keeps the saved views and default view id after mount. Each callback is\n * wrapped to apply its change here, and stays undefined when the consumer's is,\n * since that hides the matching action. Updates, deletes, and default changes\n * show right away and are undone if the callback rejects, unless a newer\n * change has replaced them. Reorders save one at a time, so a failed one puts\n * back the order from before it.\n */\nexport function useSavedViewsState({\n initialDefaultViewId,\n initialSavedViews,\n onCreate,\n onDelete,\n onReorder,\n onSetDefault,\n onUpdate,\n}: SavedViewsStateOptions) {\n const [savedViews, setSavedViews] = useState(() =>\n initialSavedViews?.map(withoutSearch)\n )\n const [defaultViewId, setDefaultViewId] = useState(initialDefaultViewId)\n const latestDefaultChange = useRef(0)\n const latestUpdate = useRef(0)\n const updates = useRef(new Map<SavedView[\"id\"], ViewUpdates>())\n const [isReordering, setIsReordering] = useState(false)\n // So a second drop before a render is skipped too.\n const isReorderingNow = useRef(false)\n\n // Only swaps out `current` if it's still there, so a slow save doesn't\n // overwrite a newer change to the same view.\n const replaceView = (current: SavedView, next: SavedView) =>\n setSavedViews((views) =>\n views?.map((view) => (view === current ? next : view))\n )\n\n // Starts from the view as it was last saved, to restore if every update fails.\n const trackUpdates = (view: SavedView) => {\n let tracked = updates.current.get(view.id)\n if (!tracked) {\n const original = savedViews?.find(({ id }) => id === view.id)\n tracked = { confirmed: original ?? view, confirmedOrder: 0, saving: [] }\n updates.current.set(view.id, tracked)\n }\n return tracked\n }\n\n const showUpdate = (view: SavedView) =>\n setSavedViews((views) =>\n views?.map((current) => (current.id === view.id ? view : current))\n )\n\n // Returns an undo that does nothing once a newer default has been set.\n const changeDefault = (id: NonNullable<SavedView[\"id\"]>) => {\n const change = ++latestDefaultChange.current\n let previous = id\n setDefaultViewId((current) => {\n previous = current\n return id\n })\n // Read in an updater, since a callback that rejects right away runs this\n // before the change above has been applied.\n return () => {\n if (latestDefaultChange.current === change)\n setDefaultViewId(() => previous)\n }\n }\n\n return {\n defaultViewId,\n isReordering,\n onCreate:\n onCreate &&\n (async (view: Omit<SavedView, \"id\">) => {\n const created = await onCreate(view)\n const saved = created && withoutSearch(created)\n // Tolerates a consumer that returns nothing, leaving the list as is.\n if (saved) setSavedViews((views = []) => [...views, saved])\n return saved\n }),\n onDelete:\n onDelete &&\n (async (view: SavedView) => {\n let index = -1\n let removed: SavedView | undefined\n setSavedViews((views) => {\n index = views?.findIndex(({ id }) => id === view.id) ?? -1\n removed = views?.[index]\n return views?.filter(({ id }) => id !== view.id)\n })\n const undoDefault =\n view.id === defaultViewId ? changeDefault(\"initial\") : undefined\n try {\n await onDelete(view)\n } catch (error) {\n setSavedViews((views) =>\n !views || !removed || views.some(({ id }) => id === view.id)\n ? views\n : [...views.slice(0, index), removed, ...views.slice(index)]\n )\n undoDefault?.()\n throw error\n }\n // Saved only once the view is gone, so a failed delete has no reset\n // to take back.\n if (undoDefault) await onSetDefault?.(\"initial\")\n }),\n // Moves the view right away, and moves it back if the save fails. A drop\n // while another reorder saves is skipped.\n onReorder:\n onReorder &&\n (async (view: SavedView, target: ReorderTarget) => {\n if (isReorderingNow.current) return\n const views = savedViews ?? []\n const from = views.indexOf(view)\n const moved = moveView(views, view, target)\n const to = moved.indexOf(view)\n const after = moved[to - 1] ?? null\n if (from === -1 || from === to) return\n // The position is saved by the view it follows, which needs an id.\n if (after && after.id === undefined) return\n\n isReorderingNow.current = true\n setIsReordering(true)\n const previousOrder = views.map(({ id }) => id)\n setSavedViews((current) => current && moveView(current, view, target))\n try {\n await onReorder(view, after)\n } catch (error) {\n setSavedViews(\n (current) => current && restoreOrder(current, previousOrder)\n )\n throw error\n } finally {\n isReorderingNow.current = false\n setIsReordering(false)\n }\n }),\n onSetDefault:\n onSetDefault &&\n (async (id: NonNullable<SavedView[\"id\"]>) => {\n const undo = changeDefault(id)\n try {\n await onSetDefault(id)\n } catch (error) {\n undo()\n throw error\n }\n }),\n // Shows the change right away. If the save fails, puts back the newest\n // update still saving, or else the last saved version.\n onUpdate:\n onUpdate &&\n (async (view: SavedView) => {\n const order = ++latestUpdate.current\n const tracked = trackUpdates(view)\n startSaving(tracked, view)\n showUpdate(view)\n try {\n const updated = await onUpdate(view)\n const saved = updated && withoutSearch(updated)\n stopSaving(tracked, view)\n confirmIfNewest(tracked, saved ?? view, order)\n if (saved) replaceView(view, saved)\n return saved\n } catch (error) {\n stopSaving(tracked, view)\n replaceView(view, viewToRestore(tracked))\n throw error\n }\n }),\n savedViews,\n }\n}\n\n/** Where a view was dropped, as React Aria reports it. */\nexport interface ReorderTarget {\n dropPosition: \"after\" | \"before\"\n view: SavedView\n}\n\nfunction moveView(\n views: SavedView[],\n view: SavedView,\n { dropPosition, view: target }: ReorderTarget\n) {\n const rest = views.filter((existing) => existing !== view)\n const targetIndex = rest.indexOf(target)\n if (targetIndex === -1) return views\n const to = dropPosition === \"after\" ? targetIndex + 1 : targetIndex\n return [...rest.slice(0, to), view, ...rest.slice(to)]\n}\n\n// Matched by id, so views updated or deleted since keep those changes. Views\n// created since stay at the end.\nfunction restoreOrder(views: SavedView[], order: SavedView[\"id\"][]) {\n const indexOf = (view: SavedView) => {\n const index = order.indexOf(view.id)\n return index === -1 ? order.length : index\n }\n return [...views].sort((a, b) => indexOf(a) - indexOf(b))\n}\n"],"names":[],"mappings":";;;AAyBA,SAAS,WAAW,CAAC,OAAoB,EAAE,IAAe,EAAA;AACxD,IAAA,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;AAC3B;AAEA,SAAS,UAAU,CAAC,OAAoB,EAAE,IAAe,EAAA;AACvD,IAAA,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,KAAK,OAAO,KAAK,IAAI,CAAC;AACvE;AAEA;AACA,SAAS,eAAe,CACtB,OAAoB,EACpB,KAAgB,EAChB,KAAa,EAAA;AAEb,IAAA,IAAI,KAAK,IAAI,OAAO,CAAC,cAAc;QAAE;AACrC,IAAA,OAAO,CAAC,SAAS,GAAG,KAAK;AACzB,IAAA,OAAO,CAAC,cAAc,GAAG,KAAK;AAChC;AAEA;AACA,SAAS,aAAa,CAAC,OAAoB,EAAA;AACzC,IAAA,OAAO,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,OAAO,CAAC,SAAS;AACnD;AAEA;;;;;;;AAOG;SACa,kBAAkB,CAAC,EACjC,oBAAoB,EACpB,iBAAiB,EACjB,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,QAAQ,GACe,EAAA;AACvB,IAAA,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,MAC3C,iBAAiB,EAAE,GAAG,CAAC,aAAa,CAAC,CACtC;IACD,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAC,oBAAoB,CAAC;AACxE,IAAA,MAAM,mBAAmB,G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C,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;AACpC,QAAA,OAAO,KAAK,KAAK,EAAE,GAAG,KAAK,CAAC,MAAM,GAAG,KAAK;AAC5C,IAAA,CAAC;IACD,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAC3D;;;;"}
1
+ {"version":3,"file":"useSavedViewsState.js","sources":["../../../src/components/DataTable/useSavedViewsState.ts"],"sourcesContent":["import { useRef, useState } from \"react\"\n\nimport { type SavedView, type View, withoutSearch } from \"./views\"\n\ninterface SavedViewsStateOptions {\n initialDefaultViewId: NonNullable<View[\"id\"]>\n initialSavedViews: SavedView[] | undefined\n onCreate?: (\n savedView: Omit<SavedView, \"id\">\n ) => Promise<SavedView> | SavedView\n onDelete?: (savedView: SavedView) => Promise<void> | void\n onReorder?: (\n savedView: SavedView,\n after: SavedView | null\n ) => Promise<void> | void\n onSetDefault?: (id: NonNullable<View[\"id\"]>) => Promise<void> | void\n onUpdate?: (savedView: SavedView) => Promise<SavedView> | SavedView\n}\n\ninterface ViewUpdates {\n confirmed: SavedView\n confirmedOrder: number\n saving: SavedView[]\n}\n\nfunction startSaving(updates: ViewUpdates, view: SavedView) {\n updates.saving.push(view)\n}\n\nfunction stopSaving(updates: ViewUpdates, view: SavedView) {\n updates.saving = updates.saving.filter((pending) => pending !== view)\n}\n\n// A slower save of an older update doesn't replace a newer one.\nfunction confirmIfNewest(\n updates: ViewUpdates,\n saved: SavedView,\n order: number\n) {\n if (order <= updates.confirmedOrder) return\n updates.confirmed = saved\n updates.confirmedOrder = order\n}\n\n// The newest update still saving, or else the last saved version.\nfunction viewToRestore(updates: ViewUpdates) {\n return updates.saving.at(-1) ?? updates.confirmed\n}\n\n/**\n * Keeps the saved views and default view id after mount. Each callback is\n * wrapped to apply its change here, and stays undefined when the consumer's is,\n * since that hides the matching action. Updates, deletes, and default changes\n * show right away and are undone if the callback rejects, unless a newer\n * change has replaced them. Reorders save one at a time, so a failed one puts\n * back the order from before it.\n */\nexport function useSavedViewsState({\n initialDefaultViewId,\n initialSavedViews,\n onCreate,\n onDelete,\n onReorder,\n onSetDefault,\n onUpdate,\n}: SavedViewsStateOptions) {\n const [savedViews, setSavedViews] = useState(() =>\n initialSavedViews?.map(withoutSearch)\n )\n const [defaultViewId, setDefaultViewId] = useState(initialDefaultViewId)\n const latestDefaultChange = useRef(0)\n const latestUpdate = useRef(0)\n const updates = useRef(new Map<SavedView[\"id\"], ViewUpdates>())\n const [isReordering, setIsReordering] = useState(false)\n // So a second drop before a render is skipped too.\n const isReorderingNow = useRef(false)\n\n // Only swaps out `current` if it's still there, so a slow save doesn't\n // overwrite a newer change to the same view.\n const replaceView = (current: SavedView, next: SavedView) =>\n setSavedViews((views) =>\n views?.map((view) => (view === current ? next : view))\n )\n\n // Starts from the view as it was last saved, to restore if every update fails.\n const trackUpdates = (view: SavedView) => {\n let tracked = updates.current.get(view.id)\n if (!tracked) {\n const original = savedViews?.find(({ id }) => id === view.id)\n tracked = { confirmed: original ?? view, confirmedOrder: 0, saving: [] }\n updates.current.set(view.id, tracked)\n }\n return tracked\n }\n\n const showUpdate = (view: SavedView) =>\n setSavedViews((views) =>\n views?.map((current) => (current.id === view.id ? view : current))\n )\n\n // Returns an undo that does nothing once a newer default has been set.\n const changeDefault = (id: NonNullable<View[\"id\"]>) => {\n const change = ++latestDefaultChange.current\n let previous = id\n setDefaultViewId((current) => {\n previous = current\n return id\n })\n // Read in an updater, since a callback that rejects right away runs this\n // before the change above has been applied.\n return () => {\n if (latestDefaultChange.current === change)\n setDefaultViewId(() => previous)\n }\n }\n\n return {\n defaultViewId,\n isReordering,\n onCreate:\n onCreate &&\n (async (view: Omit<SavedView, \"id\">) => {\n const created = await onCreate(view)\n const saved = created && withoutSearch(created)\n // Tolerates a consumer that returns nothing, leaving the list as is.\n if (saved) setSavedViews((views = []) => [...views, saved])\n return saved\n }),\n onDelete:\n onDelete &&\n (async (view: SavedView) => {\n let index = -1\n let removed: SavedView | undefined\n setSavedViews((views) => {\n index = views?.findIndex(({ id }) => id === view.id) ?? -1\n removed = views?.[index]\n return views?.filter(({ id }) => id !== view.id)\n })\n const undoDefault =\n view.id === defaultViewId ? changeDefault(\"initial\") : undefined\n try {\n await onDelete(view)\n } catch (error) {\n setSavedViews((views) =>\n !views || !removed || views.some(({ id }) => id === view.id)\n ? views\n : [...views.slice(0, index), removed, ...views.slice(index)]\n )\n undoDefault?.()\n throw error\n }\n // Saved only once the view is gone, so a failed delete has no reset\n // to take back.\n if (undoDefault) await onSetDefault?.(\"initial\")\n }),\n // Moves the view right away, and moves it back if the save fails. A drop\n // while another reorder saves is skipped.\n onReorder:\n onReorder &&\n (async (view: SavedView, target: ReorderTarget) => {\n if (isReorderingNow.current) return\n const views = savedViews ?? []\n const from = views.indexOf(view)\n const moved = moveView(views, view, target)\n const to = moved.indexOf(view)\n const after = moved[to - 1] ?? null\n if (from === -1 || from === to) return\n // The position is saved by the view it follows, which needs an id.\n if (after && after.id === undefined) return\n\n isReorderingNow.current = true\n setIsReordering(true)\n const previousOrder = views.map(({ id }) => id)\n setSavedViews((current) => current && moveView(current, view, target))\n try {\n await onReorder(view, after)\n } catch (error) {\n setSavedViews(\n (current) => current && restoreOrder(current, previousOrder)\n )\n throw error\n } finally {\n isReorderingNow.current = false\n setIsReordering(false)\n }\n }),\n onSetDefault:\n onSetDefault &&\n (async (id: NonNullable<View[\"id\"]>) => {\n const undo = changeDefault(id)\n try {\n await onSetDefault(id)\n } catch (error) {\n undo()\n throw error\n }\n }),\n // Shows the change right away. If the save fails, puts back the newest\n // update still saving, or else the last saved version.\n onUpdate:\n onUpdate &&\n (async (view: SavedView) => {\n const order = ++latestUpdate.current\n const tracked = trackUpdates(view)\n startSaving(tracked, view)\n showUpdate(view)\n try {\n const updated = await onUpdate(view)\n const saved = updated && withoutSearch(updated)\n stopSaving(tracked, view)\n confirmIfNewest(tracked, saved ?? view, order)\n if (saved) replaceView(view, saved)\n return saved\n } catch (error) {\n stopSaving(tracked, view)\n replaceView(view, viewToRestore(tracked))\n throw error\n }\n }),\n savedViews,\n }\n}\n\n/** Where a view was dropped, as React Aria reports it. */\nexport interface ReorderTarget {\n dropPosition: \"after\" | \"before\"\n view: SavedView\n}\n\nfunction moveView(\n views: SavedView[],\n view: SavedView,\n { dropPosition, view: target }: ReorderTarget\n) {\n const rest = views.filter((existing) => existing !== view)\n const targetIndex = rest.indexOf(target)\n if (targetIndex === -1) return views\n const to = dropPosition === \"after\" ? targetIndex + 1 : targetIndex\n return [...rest.slice(0, to), view, ...rest.slice(to)]\n}\n\n// Matched by id, so views updated or deleted since keep those changes. Views\n// created since stay at the end.\nfunction restoreOrder(views: SavedView[], order: SavedView[\"id\"][]) {\n const indexOf = (view: SavedView) => {\n const index = order.indexOf(view.id)\n return index === -1 ? order.length : index\n }\n return [...views].sort((a, b) => indexOf(a) - indexOf(b))\n}\n"],"names":[],"mappings":";;;AAyBA,SAAS,WAAW,CAAC,OAAoB,EAAE,IAAe,EAAA;AACxD,IAAA,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;AAC3B;AAEA,SAAS,UAAU,CAAC,OAAoB,EAAE,IAAe,EAAA;AACvD,IAAA,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,KAAK,OAAO,KAAK,IAAI,CAAC;AACvE;AAEA;AACA,SAAS,eAAe,CACtB,OAAoB,EACpB,KAAgB,EAChB,KAAa,EAAA;AAEb,IAAA,IAAI,KAAK,IAAI,OAAO,CAAC,cAAc;QAAE;AACrC,IAAA,OAAO,CAAC,SAAS,GAAG,KAAK;AACzB,IAAA,OAAO,CAAC,cAAc,GAAG,KAAK;AAChC;AAEA;AACA,SAAS,aAAa,CAAC,OAAoB,EAAA;AACzC,IAAA,OAAO,OAAO,CAAC,MAAM,CAAC,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I,WAAW,KAAK,EAAE;AAAE,QAAA,OAAO,KAAK;AACpC,IAAA,MAAM,EAAE,GAAG,YAAY,KAAK,OAAO,GAAG,WAAW,GAAG,CAAC,GAAG,WAAW;IACnE,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AACxD;AAEA;AACA;AACA,SAAS,YAAY,CAAC,KAAkB,EAAE,KAAwB,EAAA;AAChE,IAAA,MAAM,OAAO,GAAG,CAAC,IAAe,KAAI;QAClC,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;AACpC,QAAA,OAAO,KAAK,KAAK,EAAE,GAAG,KAAK,CAAC,MAAM,GAAG,KAAK;AAC5C,IAAA,CAAC;IACD,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAC3D;;;;"}
@@ -1,4 +1,4 @@
1
- import type { SavedView } from "./savedViews";
1
+ import type { SavedView } from "./views";
2
2
  /**
3
3
  * Saves a view's new name, trimmed. Callers skip blank and unchanged names.
4
4
  */
@@ -1 +1 @@
1
- {"version":3,"file":"useUpdateSavedViewName.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/useUpdateSavedViewName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,CAAC,EAAE,CACT,SAAS,EAAE,SAAS,KACjB,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,GAAG,SAAS,IAEjC,MAAM,SAAS,EAAE,MAAM,MAAM,mBAG5C"}
1
+ {"version":3,"file":"useUpdateSavedViewName.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/useUpdateSavedViewName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAExC;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,CAAC,EAAE,CACT,SAAS,EAAE,SAAS,KACjB,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,GAAG,SAAS,IAEjC,MAAM,SAAS,EAAE,MAAM,MAAM,mBAG5C"}
@@ -1 +1 @@
1
- {"version":3,"file":"useUpdateSavedViewName.js","sources":["../../../src/components/DataTable/useUpdateSavedViewName.ts"],"sourcesContent":["import type { SavedView } from \"./savedViews\"\n\n/**\n * Saves a view's new name, trimmed. Callers skip blank and unchanged names.\n */\nexport function useUpdateSavedViewName(\n onUpdate?: (\n savedView: SavedView\n ) => Promise<SavedView | undefined> | SavedView\n) {\n return async (view: SavedView, name: string) => {\n await onUpdate?.({ ...view, name: name.trim() })\n }\n}\n"],"names":[],"mappings":"AAEA;;AAEG;AACG,SAAU,sBAAsB,CACpC,QAE+C,EAAA;AAE/C,IAAA,OAAO,OAAO,IAAe,EAAE,IAAY,KAAI;AAC7C,QAAA,MAAM,QAAQ,GAAG,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;AAClD,IAAA,CAAC;AACH;;;;"}
1
+ {"version":3,"file":"useUpdateSavedViewName.js","sources":["../../../src/components/DataTable/useUpdateSavedViewName.ts"],"sourcesContent":["import type { SavedView } from \"./views\"\n\n/**\n * Saves a view's new name, trimmed. Callers skip blank and unchanged names.\n */\nexport function useUpdateSavedViewName(\n onUpdate?: (\n savedView: SavedView\n ) => Promise<SavedView | undefined> | SavedView\n) {\n return async (view: SavedView, name: string) => {\n await onUpdate?.({ ...view, name: name.trim() })\n }\n}\n"],"names":[],"mappings":"AAEA;;AAEG;AACG,SAAU,sBAAsB,CACpC,QAE+C,EAAA;AAE/C,IAAA,OAAO,OAAO,IAAe,EAAE,IAAY,KAAI;AAC7C,QAAA,MAAM,QAAQ,GAAG,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;AAClD,IAAA,CAAC;AACH;;;;"}
@@ -13,7 +13,7 @@ import type { Key } from "react-aria-components/ListBox";
13
13
  * The list's items land a render after the list, so call `measure` once
14
14
  * they're in the DOM.
15
15
  */
16
- export declare function useVisibleSavedViews<T extends {
16
+ export declare function useVisibleViews<T extends {
17
17
  id: Key;
18
18
  }>({ activeKey, items, listRef, newViewRef, }: {
19
19
  activeKey: Key | null;
@@ -28,4 +28,4 @@ export declare function useVisibleSavedViews<T extends {
28
28
  overflowItems: T[];
29
29
  visibleItems: T[];
30
30
  };
31
- //# sourceMappingURL=useVisibleSavedViews.d.ts.map
31
+ //# sourceMappingURL=useVisibleViews.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useVisibleViews.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/useVisibleViews.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAqC,MAAM,OAAO,CAAA;AACzE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AAExD;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,GAAG,CAAA;CAAE,EAAE,EACrD,SAAS,EACT,KAAK,EACL,OAAO,EACP,UAAU,GACX,EAAE;IACD,SAAS,EAAE,GAAG,GAAG,IAAI,CAAA;IACrB,KAAK,EAAE,CAAC,EAAE,CAAA;IACV,OAAO,EAAE,SAAS,CAAC,WAAW,CAAC,CAAA;IAC/B,uEAAuE;IACvE,UAAU,EAAE,SAAS,CAAC,WAAW,CAAC,CAAA;CACnC;;;;;;EAiHA"}
@@ -13,7 +13,7 @@ import { useState, useRef, useLayoutEffect } from 'react';
13
13
  * The list's items land a render after the list, so call `measure` once
14
14
  * they're in the DOM.
15
15
  */
16
- function useVisibleSavedViews({ activeKey, items, listRef, newViewRef, }) {
16
+ function useVisibleViews({ activeKey, items, listRef, newViewRef, }) {
17
17
  // By `data-key`, which is a string.
18
18
  const [widths, setWidths] = useState(() => new Map());
19
19
  const [overflowWidth, setOverflowWidth] = useState();
@@ -126,9 +126,9 @@ function useVisibleSavedViews({ activeKey, items, listRef, newViewRef, }) {
126
126
  const isCollapsed = visibleItems.length === 1;
127
127
  return { isCollapsed, isMeasuring, measure, overflowItems, visibleItems };
128
128
  }
129
- const ITEM_SELECTOR = ".tds-data-table-saved-view-list-item";
130
- const NAME_SELECTOR = ".tds-data-table-saved-view-name";
131
- const OVERFLOW_SELECTOR = ".tds-btn--data-table-saved-views-overflow";
129
+ const ITEM_SELECTOR = ".tds-data-table-view-list-item";
130
+ const NAME_SELECTOR = ".tds-data-table-view-name";
131
+ const OVERFLOW_SELECTOR = ".tds-btn--data-table-views-overflow";
132
132
  /** The list's width, less the new view button, its save status, and a gap. */
133
133
  function readAvailable(list, newView, gap) {
134
134
  const newViewWidth = widthOf(newView);
@@ -174,5 +174,5 @@ function countFitting({ activeIndex, available, gap, overflowWidth, widths, }) {
174
174
  return Infinity;
175
175
  }
176
176
 
177
- export { useVisibleSavedViews };
178
- //# sourceMappingURL=useVisibleSavedViews.js.map
177
+ export { useVisibleViews };
178
+ //# sourceMappingURL=useVisibleViews.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useVisibleViews.js","sources":["../../../src/components/DataTable/useVisibleViews.ts"],"sourcesContent":["import { type RefObject, useLayoutEffect, useRef, useState } from \"react\"\nimport type { Key } from \"react-aria-components/ListBox\"\n\n/**\n * Splits `items` into the ones that fit on one line in `listRef` and the\n * ones that go in the overflow menu. Items keep their order. The active item\n * always shows, taking the last visible slot when it would otherwise\n * overflow.\n *\n * Item widths are kept from when each item last rendered, and a resize\n * observer on the rendered items, the overflow trigger, the list, and\n * `newViewRef` keeps them current. An item with no width yet, such as a new\n * one, renders every item and the overflow trigger for one measuring pass.\n * The list's items land a render after the list, so call `measure` once\n * they're in the DOM.\n */\nexport function useVisibleViews<T extends { id: Key }>({\n activeKey,\n items,\n listRef,\n newViewRef,\n}: {\n activeKey: Key | null\n items: T[]\n listRef: RefObject<HTMLElement>\n /** The new view button and its save status, which follow the items. */\n newViewRef: RefObject<HTMLElement>\n}) {\n // By `data-key`, which is a string.\n const [widths, setWidths] = useState(() => new Map<string, number>())\n const [overflowWidth, setOverflowWidth] = useState<number>()\n const [available, setAvailable] = useState(0)\n const [gap, setGap] = useState(0)\n const observerRef = useRef<ResizeObserver>()\n const observedRef = useRef(new Set<Element>())\n\n const isMeasuring =\n overflowWidth === undefined ||\n items.some(({ id }) => !widths.has(String(id)))\n\n // Only reads refs and sets state, so the observer can keep the first one.\n const read = () => {\n const list = listRef.current\n if (!list) return\n // Hidden, everything reads 0, so widths from before are kept.\n const isHidden = list.clientWidth === 0\n if (!isHidden) {\n const gap = readGap(list)\n setAvailable(readAvailable(list, newViewRef.current, gap))\n setGap(gap)\n }\n // Its count changes its width, which changes the count, so keep the\n // widest to settle on one count.\n const overflow = list.querySelector(OVERFLOW_SELECTOR)\n if (overflow) {\n const width = widthOf(overflow)\n setOverflowWidth((current) => Math.max(current ?? 0, width))\n }\n const itemElements = list.querySelectorAll<HTMLElement>(ITEM_SELECTOR)\n setWidths((current) => {\n let next = current\n for (const itemElement of itemElements) {\n const key = itemElement.dataset.key\n const width = fullWidthOf(itemElement)\n if (key === undefined || current.get(key) === width) continue\n if (isHidden && current.has(key)) continue\n if (next === current) next = new Map(current)\n next.set(key, width)\n }\n return next\n })\n }\n\n const measure = () => {\n const list = listRef.current\n if (!list) return\n const elements = new Set<Element>([\n list,\n ...(newViewRef.current ? [newViewRef.current] : []),\n ...list.querySelectorAll(`${ITEM_SELECTOR}, ${OVERFLOW_SELECTOR}`),\n ])\n const observed = observedRef.current\n // The observer reads size changes, so only added or removed elements\n // need reading here.\n const isSame =\n elements.size === observed.size &&\n [...elements].every((element) => observed.has(element))\n if (isSame) return\n observedRef.current = elements\n read()\n if (typeof ResizeObserver === \"undefined\") return\n observerRef.current ??= new ResizeObserver(read)\n for (const element of observed) {\n if (!elements.has(element)) observerRef.current.unobserve(element)\n }\n for (const element of elements) {\n if (!observed.has(element)) observerRef.current.observe(element)\n }\n }\n\n // Cleared too, so a remount, such as StrictMode's, observes again.\n useLayoutEffect(\n () => () => {\n observerRef.current?.disconnect()\n observerRef.current = undefined\n observedRef.current = new Set()\n },\n []\n )\n\n // Drops the widths of deleted items.\n useLayoutEffect(() => {\n const keys = new Set(items.map(({ id }) => String(id)))\n if ([...widths.keys()].some((key) => !keys.has(key))) {\n setWidths(new Map([...widths].filter(([key]) => keys.has(key))))\n }\n }, [items, widths])\n\n let visibleItems = items\n let overflowItems: T[] = []\n if (!isMeasuring) {\n let remaining = countFitting({\n activeIndex: items.findIndex(({ id }) => id === activeKey),\n available,\n gap,\n overflowWidth,\n widths: items.map(({ id }) => widths.get(String(id)) ?? 0),\n })\n visibleItems = []\n overflowItems = []\n for (const item of items) {\n if (item.id === activeKey || remaining-- > 0) visibleItems.push(item)\n else overflowItems.push(item)\n }\n }\n // Alone, the view truncates rather than overflow, whether the rest are in\n // the overflow menu or it's the only one.\n const isCollapsed = visibleItems.length === 1\n\n return { isCollapsed, isMeasuring, measure, overflowItems, visibleItems }\n}\n\nconst ITEM_SELECTOR = \".tds-data-table-view-list-item\"\nconst NAME_SELECTOR = \".tds-data-table-view-name\"\nconst OVERFLOW_SELECTOR = \".tds-btn--data-table-views-overflow\"\n\n/** The list's width, less the new view button, its save status, and a gap. */\nfunction readAvailable(\n list: HTMLElement,\n newView: HTMLElement | null,\n gap: number\n) {\n const newViewWidth = widthOf(newView)\n return list.clientWidth - (newViewWidth ? newViewWidth + gap : 0)\n}\n\nfunction readGap(element: Element) {\n return parseFloat(getComputedStyle(element).columnGap) || 0\n}\n\nfunction widthOf(element: Element | null) {\n return element?.getBoundingClientRect().width ?? 0\n}\n\n/** Includes the part of its name cut off by truncation. */\nfunction fullWidthOf(itemElement: Element) {\n const name = itemElement.querySelector(NAME_SELECTOR)\n const truncated = name ? name.scrollWidth - name.clientWidth : 0\n return widthOf(itemElement) + truncated\n}\n\n// Measured widths can be fractional, but the list's width is rounded.\nconst SUBPIXEL_SLACK = 1\n\nfunction countFitting({\n activeIndex,\n available,\n gap,\n overflowWidth,\n widths,\n}: {\n activeIndex: number\n available: number\n gap: number\n overflowWidth: number\n widths: number[]\n}) {\n const limit = available + SUBPIXEL_SLACK\n // Each item counts with the gap after it, which comes before the overflow\n // trigger, or after the last item doesn't exist. The active item's width is\n // set aside first so it always shows.\n let used = activeIndex === -1 ? 0 : widths[activeIndex] + gap\n // Items that still fit with the overflow trigger beside them.\n let fitsWithOverflow = 0\n for (let index = 0; index < widths.length; index++) {\n if (index === activeIndex) continue\n used += widths[index] + gap\n // Out of room, so the overflow trigger is needed. With no active item,\n // the first item shows anyway.\n if (used - gap > limit) {\n return activeIndex === -1\n ? Math.max(fitsWithOverflow, 1)\n : fitsWithOverflow\n }\n if (used + overflowWidth <= limit) fitsWithOverflow++\n }\n // Every item fits, so there's no overflow trigger.\n return Infinity\n}\n"],"names":[],"mappings":";;AAGA;;;;;;;;;;;;AAYG;AACG,SAAU,eAAe,CAAwB,EACrD,SAAS,EACT,KAAK,EACL,OAAO,EACP,UAAU,GAOX,EAAA;;AAEC,IAAA,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,MAAM,IAAI,GAAG,EAAkB,CAAC;IACrE,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,EAAU;IAC5D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;IAC7C,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;AACjC,IAAA,MAAM,WAAW,GAAG,MAAM,EAAkB;IAC5C,MAAM,WAAW,GAAG,MAAM,CAAC,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,MAAM,IAAI,GAAG,WAAW,CAAC,aAAa,CAAC,aAAa,CAAC;AACrD,IAAA,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,GAAG,CAAC;AAChE,IAAA,OAAO,OAAO,CAAC,WAAW,CAAC,GAAG,SAAS;AACzC;AAEA;AACA,MAAM,cAAc,GAAG,CAAC;AAExB,SAAS,YAAY,CAAC,EACpB,WAAW,EACX,SAAS,EACT,GAAG,EACH,aAAa,EACb,MAAM,GAOP,EAAA;AACC,IAAA,MAAM,KAAK,GAAG,SAAS,GAAG,cAAc;;;;AAIxC,IAAA,IAAI,IAAI,GAAG,WAAW,KAAK,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC,GAAG,GAAG;;IAE7D,IAAI,gBAAgB,GAAG,CAAC;AACxB,IAAA,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;QAClD,IAAI,KAAK,KAAK,WAAW;YAAE;AAC3B,QAAA,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,GAAG;;;AAG3B,QAAA,IAAI,IAAI,GAAG,GAAG,GAAG,KAAK,EAAE;YACtB,OAAO,WAAW,KAAK;kBACnB,IAAI,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;kBAC5B,gBAAgB;QACtB;AACA,QAAA,IAAI,IAAI,GAAG,aAAa,IAAI,KAAK;AAAE,YAAA,gBAAgB,EAAE;IACvD;;AAEA,IAAA,OAAO,QAAQ;AACjB;;;;"}
@@ -0,0 +1,56 @@
1
+ import type { Sort } from "./DataTable";
2
+ import type { ActiveFilter } from "./FilterTypes";
3
+ /** A static or saved view. */
4
+ export interface View {
5
+ /** A search (`q`) filter is ignored; applying a view keeps the search. */
6
+ activeFilters: ActiveFilter[];
7
+ /**
8
+ * Required on a static view. A saved view gets one from the consumer once
9
+ * it's saved.
10
+ */
11
+ id?: number | string;
12
+ name: string;
13
+ /** Omit to leave the current sort unchanged when applied. */
14
+ sort?: Sort;
15
+ /**
16
+ * The columns the view shows. A hideable column it doesn't name is hidden,
17
+ * so a column added later stays out of the view until it's saved with it.
18
+ * Omit to leave the current column visibility unchanged when applied.
19
+ */
20
+ visibleColumnNames?: string[];
21
+ }
22
+ /** A user-created view, stored by the consumer. */
23
+ export type SavedView = View;
24
+ /** An app-provided view. Read-only. */
25
+ export type StaticView = View & {
26
+ id: number | string;
27
+ };
28
+ /**
29
+ * Always listed, so there's a view to fall back to. Added before the static
30
+ * views unless one of them uses its id, which replaces it.
31
+ */
32
+ export declare const initialView: StaticView;
33
+ /**
34
+ * A view from the app, without any search. Search isn't part of a view, so
35
+ * views enter the table without it. A view without one is returned as is.
36
+ */
37
+ export declare function withoutSearch<T extends View>(view: T): T;
38
+ /**
39
+ * A duplicate of a view under a new name. It's a new view, so it doesn't keep
40
+ * the original's id.
41
+ */
42
+ export declare function viewDuplicate({ id: _id, ...view }: View, name: string): Omit<SavedView, "id">;
43
+ /**
44
+ * Whether a view can be renamed, deleted, or saved over. Static views can't,
45
+ * and neither can a view that isn't saved yet, since updates are matched by id.
46
+ */
47
+ export declare function isViewEditable(view: View, savedViews: SavedView[]): boolean;
48
+ /**
49
+ * Whether the table's filters, sort, or visible columns differ from a view.
50
+ * Filters match by name, operator, scope, and value, in any order; labels are
51
+ * display-only. Sort and visible columns count only when both the view and the
52
+ * table have them. Column names match as given, in any order, so resolve them
53
+ * against the table's columns first to ignore ones that are gone.
54
+ */
55
+ export declare function isViewModified(view: View, { activeFilters, sort, visibleColumnNames }: Omit<View, "id" | "name">): boolean;
56
+ //# sourceMappingURL=views.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"views.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/views.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAGjD,8BAA8B;AAC9B,MAAM,WAAW,IAAI;IACnB,0EAA0E;IAC1E,aAAa,EAAE,YAAY,EAAE,CAAA;IAC7B;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,6DAA6D;IAC7D,IAAI,CAAC,EAAE,IAAI,CAAA;IACX;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAA;CAC9B;AAED,mDAAmD;AACnD,MAAM,MAAM,SAAS,GAAG,IAAI,CAAA;AAE5B,uCAAuC;AACvC,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG;IAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAA;AAEvD;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,UAIzB,CAAA;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,IAAI,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAQxD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,EAAE,IAAI,EAC1B,IAAI,EAAE,MAAM,GACX,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAEvB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,WAEjE;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,IAAI,EACV,EAAE,aAAa,EAAE,IAAI,EAAE,kBAAkB,EAAE,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAAC,WAoBvE"}
@@ -25,28 +25,29 @@ function withoutSearch(view) {
25
25
  * A duplicate of a view under a new name. It's a new view, so it doesn't keep
26
26
  * the original's id.
27
27
  */
28
- function savedViewDuplicate({ id: _id, ...view }, name) {
28
+ function viewDuplicate({ id: _id, ...view }, name) {
29
29
  return { ...view, name };
30
30
  }
31
31
  /**
32
32
  * Whether a view can be renamed, deleted, or saved over. Static views can't,
33
33
  * and neither can a view that isn't saved yet, since updates are matched by id.
34
34
  */
35
- function isSavedViewEditable(view, savedViews) {
35
+ function isViewEditable(view, savedViews) {
36
36
  return view.id !== undefined && savedViews.includes(view);
37
37
  }
38
38
  /**
39
- * Whether the table's filters, sort, or hidden columns differ from a view.
39
+ * Whether the table's filters, sort, or visible columns differ from a view.
40
40
  * Filters match by name, operator, scope, and value, in any order; labels are
41
- * display-only. Sort and hidden columns count only when both the view and the
42
- * table have them.
41
+ * display-only. Sort and visible columns count only when both the view and the
42
+ * table have them. Column names match as given, in any order, so resolve them
43
+ * against the table's columns first to ignore ones that are gone.
43
44
  */
44
- function isSavedViewModified(view, { activeFilters, hiddenColumnNames, sort }) {
45
+ function isViewModified(view, { activeFilters, sort, visibleColumnNames }) {
45
46
  if (view.sort && sort && !isSameSort(view.sort, sort))
46
47
  return true;
47
- if (view.hiddenColumnNames &&
48
- hiddenColumnNames &&
49
- !isSameNames(view.hiddenColumnNames, hiddenColumnNames))
48
+ if (view.visibleColumnNames &&
49
+ visibleColumnNames &&
50
+ !isSameNames(view.visibleColumnNames, visibleColumnNames))
50
51
  return true;
51
52
  // Each saved filter matches one current filter, so repeats count.
52
53
  const unmatched = [...view.activeFilters];
@@ -79,5 +80,5 @@ function isSameNames(a, b) {
79
80
  return a.length === b.length && a.every((name) => b.includes(name));
80
81
  }
81
82
 
82
- export { initialView, isSavedViewEditable, isSavedViewModified, savedViewDuplicate, withoutSearch };
83
- //# sourceMappingURL=savedViews.js.map
83
+ export { initialView, isViewEditable, isViewModified, viewDuplicate, withoutSearch };
84
+ //# sourceMappingURL=views.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"views.js","sources":["../../../src/components/DataTable/views.ts"],"sourcesContent":["import type { Sort } from \"./DataTable\"\nimport type { ActiveFilter } from \"./FilterTypes\"\nimport { isSearchFilter } from \"./useSearchFilter\"\n\n/** A static or saved view. */\nexport interface View {\n /** A search (`q`) filter is ignored; applying a view keeps the search. */\n activeFilters: ActiveFilter[]\n /**\n * Required on a static view. A saved view gets one from the consumer once\n * it's saved.\n */\n id?: number | string\n name: string\n /** Omit to leave the current sort unchanged when applied. */\n sort?: Sort\n /**\n * The columns the view shows. A hideable column it doesn't name is hidden,\n * so a column added later stays out of the view until it's saved with it.\n * Omit to leave the current column visibility unchanged when applied.\n */\n visibleColumnNames?: string[]\n}\n\n/** A user-created view, stored by the consumer. */\nexport type SavedView = View\n\n/** An app-provided view. Read-only. */\nexport type StaticView = View & { id: number | string }\n\n/**\n * Always listed, so there's a view to fall back to. Added before the static\n * views unless one of them uses its id, which replaces it.\n */\nexport const initialView: StaticView = {\n activeFilters: [],\n id: \"initial\",\n name: \"All\",\n}\n\n/**\n * A view from the app, without any search. Search isn't part of a view, so\n * views enter the table without it. A view without one is returned as is.\n */\nexport function withoutSearch<T extends View>(view: T): T {\n if (!view.activeFilters.some(isSearchFilter)) return view\n return {\n ...view,\n activeFilters: view.activeFilters.filter(\n (filter) => !isSearchFilter(filter)\n ),\n }\n}\n\n/**\n * A duplicate of a view under a new name. It's a new view, so it doesn't keep\n * the original's id.\n */\nexport function viewDuplicate(\n { id: _id, ...view }: View,\n name: string\n): Omit<SavedView, \"id\"> {\n return { ...view, name }\n}\n\n/**\n * Whether a view can be renamed, deleted, or saved over. Static views can't,\n * and neither can a view that isn't saved yet, since updates are matched by id.\n */\nexport function isViewEditable(view: View, savedViews: SavedView[]) {\n return view.id !== undefined && savedViews.includes(view)\n}\n\n/**\n * Whether the table's filters, sort, or visible columns differ from a view.\n * Filters match by name, operator, scope, and value, in any order; labels are\n * display-only. Sort and visible columns count only when both the view and the\n * table have them. Column names match as given, in any order, so resolve them\n * against the table's columns first to ignore ones that are gone.\n */\nexport function isViewModified(\n view: View,\n { activeFilters, sort, visibleColumnNames }: Omit<View, \"id\" | \"name\">\n) {\n if (view.sort && sort && !isSameSort(view.sort, sort)) return true\n if (\n view.visibleColumnNames &&\n visibleColumnNames &&\n !isSameNames(view.visibleColumnNames, visibleColumnNames)\n )\n return true\n // Each saved filter matches one current filter, so repeats count.\n const unmatched = [...view.activeFilters]\n return (\n activeFilters.length !== unmatched.length ||\n !activeFilters.every((filter) => {\n const index = unmatched.findIndex((saved) => isSameFilter(saved, filter))\n if (index === -1) return false\n unmatched.splice(index, 1)\n return true\n })\n )\n}\n\nfunction isSameFilter(a: ActiveFilter, b: ActiveFilter) {\n return (\n a.name === b.name &&\n a.operator === b.operator &&\n a.scope === b.scope &&\n isSameValue(a.value, b.value)\n )\n}\n\n// Filter values are primitives or flat arrays, such as ranges. Arrays match\n// only in the same order.\nfunction isSameValue(a: unknown, b: unknown) {\n if (!Array.isArray(a) || !Array.isArray(b)) return a === b\n return a.length === b.length && a.every((item, index) => item === b[index])\n}\n\nfunction isSameSort(a: Sort, b: Sort) {\n return a.column === b.column && a.direction === b.direction\n}\n\nfunction isSameNames(a: string[], b: string[]) {\n return a.length === b.length && a.every((name) => b.includes(name))\n}\n"],"names":[],"mappings":";;AA8BA;;;AAGG;AACI,MAAM,WAAW,GAAe;AACrC,IAAA,aAAa,EAAE,EAAE;AACjB,IAAA,EAAE,EAAE,SAAS;AACb,IAAA,IAAI,EAAE,KAAK;;AAGb;;;AAGG;AACG,SAAU,aAAa,CAAiB,IAAO,EAAA;IACnD,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,cAAc,CAAC;AAAE,QAAA,OAAO,IAAI;IACzD,OAAO;AACL,QAAA,GAAG,IAAI;AACP,QAAA,aAAa,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM,CACtC,CAAC,MAAM,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CACpC;KACF;AACH;AAEA;;;AAGG;AACG,SAAU,aAAa,CAC3B,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI,EAAQ,EAC1B,IA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AAQ;AACzB,QAAA,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK;QACnB,WAAW,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC;AAEjC;AAEA;AACA;AACA,SAAS,WAAW,CAAC,CAAU,EAAE,CAAU,EAAA;AACzC,IAAA,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,KAAK,CAAC;IAC1D,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,KAAK,IAAI,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;AAC7E;AAEA,SAAS,UAAU,CAAC,CAAO,EAAE,CAAO,EAAA;AAClC,IAAA,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,SAAS,KAAK,CAAC,CAAC,SAAS;AAC7D;AAEA,SAAS,WAAW,CAAC,CAAW,EAAE,CAAW,EAAA;IAC3C,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACrE;;;;"}
@@ -39,7 +39,7 @@ export type ActionsDropdownIconButtonProps = Omit<IconButtonBaseProps, "aria-lab
39
39
  size?: Exclude<ComponentSize, "xs">;
40
40
  /** Not supported — no caret, and nothing else in the suffix slot. */
41
41
  suffix?: never;
42
- /** Text shown on hover and focus. Without `aria-label`, it is also used as the `aria-label`. With `aria-label`, start the `aria-label` with the same text (e.g. tooltip `"Delete"`, aria-label `"Delete, 3 selected"`). The tooltip itself is hidden from screen readers. Ignores `aria-labelledby`. */
42
+ /** Text shown on hover and focus. Without `aria-label`, it is also used as the `aria-label`. With `aria-label`, start the `aria-label` with the same text (e.g. tooltip `"Delete"`, aria-label `"Delete, 3 selected"`). The tooltip itself is hidden from screen readers. Ignores `aria-labelledby`. Never opens on hover while `disabled`, and opens on keyboard focus only with `focusableWhenDisabled`, so don't rely on it to explain why the button is disabled. */
43
43
  tooltip?: string;
44
44
  /** Where the tooltip renders relative to the button. Default `"bottom"`. Has no effect without `tooltip`. */
45
45
  tooltipPlacement?: TooltipPlacement;
@@ -87,7 +87,7 @@ export declare const ActionsDropdownIconButton: React.ForwardRefExoticComponent<
87
87
  size?: Exclude<ComponentSize, "xs">;
88
88
  /** Not supported — no caret, and nothing else in the suffix slot. */
89
89
  suffix?: never;
90
- /** Text shown on hover and focus. Without `aria-label`, it is also used as the `aria-label`. With `aria-label`, start the `aria-label` with the same text (e.g. tooltip `"Delete"`, aria-label `"Delete, 3 selected"`). The tooltip itself is hidden from screen readers. Ignores `aria-labelledby`. */
90
+ /** Text shown on hover and focus. Without `aria-label`, it is also used as the `aria-label`. With `aria-label`, start the `aria-label` with the same text (e.g. tooltip `"Delete"`, aria-label `"Delete, 3 selected"`). The tooltip itself is hidden from screen readers. Ignores `aria-labelledby`. Never opens on hover while `disabled`, and opens on keyboard focus only with `focusableWhenDisabled`, so don't rely on it to explain why the button is disabled. */
91
91
  tooltip?: string;
92
92
  /** Where the tooltip renders relative to the button. Default `"bottom"`. Has no effect without `tooltip`. */
93
93
  tooltipPlacement?: TooltipPlacement;
@@ -1 +1 @@
1
- {"version":3,"file":"ActionsDropdownIconButton.d.ts","sourceRoot":"","sources":["../../../src/components/button/ActionsDropdownIconButton.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAG3D,OAAO,KAAiC,MAAM,OAAO,CAAA;AAErD,OAAO,EAAc,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAE9D,MAAM,MAAM,8BAA8B,GAAG,IAAI,CAC/C,mBAAmB,EACnB,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CACpD,GAAG;IACF;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;OAGG;IACH,SAAS,CAAC,EAAE,KAAK,CAAA;IACjB,yEAAyE;IACzE,IAAI,CAAC,EAAE,KAAK,CAAA;IACZ;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC1B;;;OAGG;IACH,OAAO,CAAC,EAAE,KAAK,CAAA;IACf;;;OAGG;IACH,MAAM,CAAC,EAAE,KAAK,CAAA;IACd;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC,aAAa,EAAE,IAAI,CAAC,CAAA;IACnC,qEAAqE;IACrE,MAAM,CAAC,EAAE,KAAK,CAAA;IACd,wSAAwS;IACxS,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,6GAA6G;IAC7G,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;CACpC,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB;IAhDpC;;;;OAIG;mBACY,MAAM;IACrB;;;OAGG;gBACS,KAAK;IACjB,yEAAyE;WAClE,KAAK;IACZ;;;OAGG;WACI,OAAO,GAAG,SAAS;IAC1B;;;OAGG;cACO,KAAK;IACf;;;OAGG;aACM,KAAK;IACd;;;;OAIG;WACI,OAAO,CAAC,aAAa,EAAE,IAAI,CAAC;IACnC,qEAAqE;aAC5D,KAAK;IACd,wSAAwS;cAC9R,MAAM;IAChB,6GAA6G;uBAC1F,gBAAgB;2CAiDpC,CAAA"}
1
+ {"version":3,"file":"ActionsDropdownIconButton.d.ts","sourceRoot":"","sources":["../../../src/components/button/ActionsDropdownIconButton.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAG3D,OAAO,KAAiC,MAAM,OAAO,CAAA;AAErD,OAAO,EAAc,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAE9D,MAAM,MAAM,8BAA8B,GAAG,IAAI,CAC/C,mBAAmB,EACnB,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CACpD,GAAG;IACF;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;OAGG;IACH,SAAS,CAAC,EAAE,KAAK,CAAA;IACjB,yEAAyE;IACzE,IAAI,CAAC,EAAE,KAAK,CAAA;IACZ;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC1B;;;OAGG;IACH,OAAO,CAAC,EAAE,KAAK,CAAA;IACf;;;OAGG;IACH,MAAM,CAAC,EAAE,KAAK,CAAA;IACd;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC,aAAa,EAAE,IAAI,CAAC,CAAA;IACnC,qEAAqE;IACrE,MAAM,CAAC,EAAE,KAAK,CAAA;IACd,ycAAyc;IACzc,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,6GAA6G;IAC7G,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;CACpC,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB;IAhDpC;;;;OAIG;mBACY,MAAM;IACrB;;;OAGG;gBACS,KAAK;IACjB,yEAAyE;WAClE,KAAK;IACZ;;;OAGG;WACI,OAAO,GAAG,SAAS;IAC1B;;;OAGG;cACO,KAAK;IACf;;;OAGG;aACM,KAAK;IACd;;;;OAIG;WACI,OAAO,CAAC,aAAa,EAAE,IAAI,CAAC;IACnC,qEAAqE;aAC5D,KAAK;IACd,ycAAyc;cAC/b,MAAM;IAChB,6GAA6G;uBAC1F,gBAAgB;2CAiDpC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"ActionsDropdownIconButton.js","sources":["../../../src/components/button/ActionsDropdownIconButton.tsx"],"sourcesContent":["import { DropdownTriggerContext } from \"@components/dropdown/DropdownTriggerContext\"\nimport { type TooltipPlacement } from \"@components/internal/tooltip\"\nimport { ComponentSize } from \"@utilities/buttonLinkShared\"\nimport Icon from \"@utilities/Icon\"\nimport classNames from \"classnames\"\nimport React, { forwardRef, useContext } from \"react\"\n\nimport { IconButton, IconButtonBaseProps } from \"./IconButton\"\n\nexport type ActionsDropdownIconButtonProps = Omit<\n IconButtonBaseProps,\n \"aria-label\" | \"icon\" | \"kind\" | \"loading\" | \"size\"\n> & {\n /**\n * Accessible name. Defaults to `\"Actions\"` when `tooltip` is not set.\n * Override when a page has several actions menus that need\n * distinguishing (e.g. `\"Actions for Jane Doe\"`).\n */\n \"aria-label\"?: string\n /**\n * Not supported — an actions trigger is a fixed-size icon button and\n * shouldn't stretch to fill a container. Always rendered as `false`.\n */\n fullWidth?: never\n /** Not supported — the vertical ellipsis is the component's identity. */\n icon?: never\n /**\n * Only `\"ghost\"` and `\"neutral\"` are supported treatments for an actions\n * trigger. Defaults to `\"ghost\"`.\n */\n kind?: \"ghost\" | \"neutral\"\n /**\n * Not supported — `.tds-btn--loading` hides every non-spinner child, so a\n * loading actions button would render a bare spinner with no glyph.\n */\n loading?: never\n /**\n * Not supported — same reasoning as `suffix`: total control over the\n * button's contents, and no slot besides the fixed ellipsis icon.\n */\n prefix?: never\n /**\n * `xs` is excluded — at 20px effective height it falls below the WCAG 2.2\n * AA 24×24 minimum target size, and an icon-only button has no text\n * content to widen it past the minimum.\n */\n size?: Exclude<ComponentSize, \"xs\">\n /** Not supported — no caret, and nothing else in the suffix slot. */\n suffix?: never\n /** Text shown on hover and focus. Without `aria-label`, it is also used as the `aria-label`. With `aria-label`, start the `aria-label` with the same text (e.g. tooltip `\"Delete\"`, aria-label `\"Delete, 3 selected\"`). The tooltip itself is hidden from screen readers. Ignores `aria-labelledby`. */\n tooltip?: string\n /** Where the tooltip renders relative to the button. Default `\"bottom\"`. Has no effect without `tooltip`. */\n tooltipPlacement?: TooltipPlacement\n}\n\n/**\n * An icon-only dropdown trigger with a vertical-ellipsis glyph and no\n * caret, for action menus where a caret is visually redundant.\n *\n * @component\n */\nexport const ActionsDropdownIconButton = forwardRef<\n HTMLButtonElement,\n ActionsDropdownIconButtonProps\n>(\n (\n {\n \"aria-label\": ariaLabel,\n className,\n kind = \"ghost\",\n tooltip,\n ...restProps\n }: ActionsDropdownIconButtonProps,\n ref\n ) => {\n const contextProps = useContext(DropdownTriggerContext)\n const nameProps = tooltip\n ? { \"aria-label\": ariaLabel, tooltip }\n : { \"aria-label\": ariaLabel ?? \"Actions\" }\n return (\n <IconButton\n ref={ref}\n {...restProps}\n {...contextProps}\n {...nameProps}\n className={classNames(className, \"tds-btn--actions-dropdown\")}\n fullWidth={false}\n icon={\n <Icon\n className=\"actions-icon\"\n symbol=\"general#three-dots\"\n aria-hidden\n />\n }\n kind={kind}\n loading={undefined}\n prefix={undefined}\n suffix={undefined}\n />\n )\n }\n)\n\nActionsDropdownIconButton.displayName = \"ActionsDropdownIconButton\"\n"],"names":[],"mappings":";;;;;;AAuDA;;;;;AAKG;AACI,MAAM,yBAAyB,GAAG,UAAU,CAIjD,CACE,EACE,YAAY,EAAE,SAAS,EACvB,SAAS,EACT,IAAI,GAAG,OAAO,EACd,OAAO,EACP,GAAG,SAAS,EACmB,EACjC,GAAG,KACD;AACF,IAAA,MAAM,YAAY,GAAG,UAAU,CAAC,sBAAsB,CAAC;IACvD,MAAM,SAAS,GAAG;AAChB,UAAE,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO;UAClC,EAAE,YAAY,EAAE,SAAS,IAAI,SAAS,EAAE;IAC5C,QACE,KAAA,CAAA,aAAA,CAAC,UAAU,EAAA,EACT,GAAG,EAAE,GAAG,EAAA,GACJ,SAAS,EAAA,GACT,YAAY,EAAA,GACZ,SAAS,EACb,SAAS,EAAE,UAAU,CAAC,SAAS,EAAE,2BAA2B,CAAC,EAC7D,SAAS,EAAE,KAAK,EAChB,IAAI,EACF,oBAAC,IAAI,EAAA,EACH,SAAS,EAAC,cAAc,EACxB,MAAM,EAAC,oBAAoB,EAAA,aAAA,EAAA,IAAA,EAAA,CAE3B,EAEJ,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,SAAS,EAClB,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,SAAS,EAAA,CACjB;AAEN,CAAC;AAGH,yBAAyB,CAAC,WAAW,GAAG,2BAA2B;;;;"}
1
+ {"version":3,"file":"ActionsDropdownIconButton.js","sources":["../../../src/components/button/ActionsDropdownIconButton.tsx"],"sourcesContent":["import { DropdownTriggerContext } from \"@components/dropdown/DropdownTriggerContext\"\nimport { type TooltipPlacement } from \"@components/internal/tooltip\"\nimport { ComponentSize } from \"@utilities/buttonLinkShared\"\nimport Icon from \"@utilities/Icon\"\nimport classNames from \"classnames\"\nimport React, { forwardRef, useContext } from \"react\"\n\nimport { IconButton, IconButtonBaseProps } from \"./IconButton\"\n\nexport type ActionsDropdownIconButtonProps = Omit<\n IconButtonBaseProps,\n \"aria-label\" | \"icon\" | \"kind\" | \"loading\" | \"size\"\n> & {\n /**\n * Accessible name. Defaults to `\"Actions\"` when `tooltip` is not set.\n * Override when a page has several actions menus that need\n * distinguishing (e.g. `\"Actions for Jane Doe\"`).\n */\n \"aria-label\"?: string\n /**\n * Not supported — an actions trigger is a fixed-size icon button and\n * shouldn't stretch to fill a container. Always rendered as `false`.\n */\n fullWidth?: never\n /** Not supported — the vertical ellipsis is the component's identity. */\n icon?: never\n /**\n * Only `\"ghost\"` and `\"neutral\"` are supported treatments for an actions\n * trigger. Defaults to `\"ghost\"`.\n */\n kind?: \"ghost\" | \"neutral\"\n /**\n * Not supported — `.tds-btn--loading` hides every non-spinner child, so a\n * loading actions button would render a bare spinner with no glyph.\n */\n loading?: never\n /**\n * Not supported — same reasoning as `suffix`: total control over the\n * button's contents, and no slot besides the fixed ellipsis icon.\n */\n prefix?: never\n /**\n * `xs` is excluded — at 20px effective height it falls below the WCAG 2.2\n * AA 24×24 minimum target size, and an icon-only button has no text\n * content to widen it past the minimum.\n */\n size?: Exclude<ComponentSize, \"xs\">\n /** Not supported — no caret, and nothing else in the suffix slot. */\n suffix?: never\n /** Text shown on hover and focus. Without `aria-label`, it is also used as the `aria-label`. With `aria-label`, start the `aria-label` with the same text (e.g. tooltip `\"Delete\"`, aria-label `\"Delete, 3 selected\"`). The tooltip itself is hidden from screen readers. Ignores `aria-labelledby`. Never opens on hover while `disabled`, and opens on keyboard focus only with `focusableWhenDisabled`, so don't rely on it to explain why the button is disabled. */\n tooltip?: string\n /** Where the tooltip renders relative to the button. Default `\"bottom\"`. Has no effect without `tooltip`. */\n tooltipPlacement?: TooltipPlacement\n}\n\n/**\n * An icon-only dropdown trigger with a vertical-ellipsis glyph and no\n * caret, for action menus where a caret is visually redundant.\n *\n * @component\n */\nexport const ActionsDropdownIconButton = forwardRef<\n HTMLButtonElement,\n ActionsDropdownIconButtonProps\n>(\n (\n {\n \"aria-label\": ariaLabel,\n className,\n kind = \"ghost\",\n tooltip,\n ...restProps\n }: ActionsDropdownIconButtonProps,\n ref\n ) => {\n const contextProps = useContext(DropdownTriggerContext)\n const nameProps = tooltip\n ? { \"aria-label\": ariaLabel, tooltip }\n : { \"aria-label\": ariaLabel ?? \"Actions\" }\n return (\n <IconButton\n ref={ref}\n {...restProps}\n {...contextProps}\n {...nameProps}\n className={classNames(className, \"tds-btn--actions-dropdown\")}\n fullWidth={false}\n icon={\n <Icon\n className=\"actions-icon\"\n symbol=\"general#three-dots\"\n aria-hidden\n />\n }\n kind={kind}\n loading={undefined}\n prefix={undefined}\n suffix={undefined}\n />\n )\n }\n)\n\nActionsDropdownIconButton.displayName = \"ActionsDropdownIconButton\"\n"],"names":[],"mappings":";;;;;;AAuDA;;;;;AAKG;AACI,MAAM,yBAAyB,GAAG,UAAU,CAIjD,CACE,EACE,YAAY,EAAE,SAAS,EACvB,SAAS,EACT,IAAI,GAAG,OAAO,EACd,OAAO,EACP,GAAG,SAAS,EACmB,EACjC,GAAG,KACD;AACF,IAAA,MAAM,YAAY,GAAG,UAAU,CAAC,sBAAsB,CAAC;IACvD,MAAM,SAAS,GAAG;AAChB,UAAE,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO;UAClC,EAAE,YAAY,EAAE,SAAS,IAAI,SAAS,EAAE;IAC5C,QACE,KAAA,CAAA,aAAA,CAAC,UAAU,EAAA,EACT,GAAG,EAAE,GAAG,EAAA,GACJ,SAAS,EAAA,GACT,YAAY,EAAA,GACZ,SAAS,EACb,SAAS,EAAE,UAAU,CAAC,SAAS,EAAE,2BAA2B,CAAC,EAC7D,SAAS,EAAE,KAAK,EAChB,IAAI,EACF,oBAAC,IAAI,EAAA,EACH,SAAS,EAAC,cAAc,EACxB,MAAM,EAAC,oBAAoB,EAAA,aAAA,EAAA,IAAA,EAAA,CAE3B,EAEJ,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,SAAS,EAClB,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,SAAS,EAAA,CACjB;AAEN,CAAC;AAGH,yBAAyB,CAAC,WAAW,GAAG,2BAA2B;;;;"}
@@ -13,13 +13,13 @@ export type IconButtonBaseProps = IconButtonSharedProps & {
13
13
  type IconButtonTooltipProps = {
14
14
  /** Accessible label. Required for icon-only buttons to provide context about the button's purpose. Not required when `tooltip` is set. When both are set, this is the name and the tooltip is visual only. */
15
15
  "aria-label"?: string;
16
- /** Text shown on hover and focus. Without `aria-label`, it is also used as the `aria-label`. With `aria-label`, start the `aria-label` with the same text (e.g. tooltip `"Delete"`, aria-label `"Delete, 3 selected"`). The tooltip itself is hidden from screen readers. Ignores `aria-labelledby`. */
16
+ /** Text shown on hover and focus. Without `aria-label`, it is also used as the `aria-label`. With `aria-label`, start the `aria-label` with the same text (e.g. tooltip `"Delete"`, aria-label `"Delete, 3 selected"`). The tooltip itself is hidden from screen readers. Ignores `aria-labelledby`. Never opens on hover while `disabled` or `loading`, and opens on keyboard focus only with `focusableWhenDisabled`, so don't rely on it to explain why the button is disabled. */
17
17
  tooltip: string;
18
18
  };
19
19
  type IconButtonAriaLabelProps = {
20
20
  /** Accessible label. Required for icon-only buttons to provide context about the button's purpose. Not required when `tooltip` is set. When both are set, this is the name and the tooltip is visual only. */
21
21
  "aria-label": string;
22
- /** Text shown on hover and focus. Without `aria-label`, it is also used as the `aria-label`. With `aria-label`, start the `aria-label` with the same text (e.g. tooltip `"Delete"`, aria-label `"Delete, 3 selected"`). The tooltip itself is hidden from screen readers. Ignores `aria-labelledby`. */
22
+ /** Text shown on hover and focus. Without `aria-label`, it is also used as the `aria-label`. With `aria-label`, start the `aria-label` with the same text (e.g. tooltip `"Delete"`, aria-label `"Delete, 3 selected"`). The tooltip itself is hidden from screen readers. Ignores `aria-labelledby`. Never opens on hover while `disabled` or `loading`, and opens on keyboard focus only with `focusableWhenDisabled`, so don't rely on it to explain why the button is disabled. */
23
23
  tooltip?: string;
24
24
  };
25
25
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"IconButton.d.ts","sourceRoot":"","sources":["../../../src/components/button/IconButton.tsx"],"names":[],"mappings":"AAAA,OAAO,WAAW,CAAA;AAElB,OAAO,EAAW,KAAK,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAE7E,OAAO,KAAqB,MAAM,OAAO,CAAA;AAEzC,OAAO,EAAc,sBAAsB,EAAE,MAAM,cAAc,CAAA;AAEjE,KAAK,qBAAqB,GAAG,IAAI,CAAC,sBAAsB,EAAE,OAAO,CAAC,GAAG;IACnE,sFAAsF;IACtF,IAAI,EAAE,KAAK,CAAC,SAAS,CAAA;CACtB,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG,qBAAqB,GAAG;IACxD,sGAAsG;IACtG,YAAY,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,KAAK,sBAAsB,GAAG;IAC5B,8MAA8M;IAC9M,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,wSAAwS;IACxS,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,KAAK,wBAA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AAe,GAAG,qBAAqB,GACjD,mBAAmB,GAAG;IACpB,6GAA6G;IAC7G,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;CACpC,CAAA;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,2FA0CtB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"IconButton.js","sources":["../../../src/components/button/IconButton.tsx"],"sourcesContent":["import \"./btn.css\"\n\nimport { Tooltip, type TooltipPlacement } from \"@components/internal/tooltip\"\nimport classNames from \"classnames\"\nimport React, { forwardRef } from \"react\"\n\nimport { BaseButton, BaseButtonElementProps } from \"./BaseButton\"\n\ntype IconButtonSharedProps = Omit<BaseButtonElementProps, \"label\"> & {\n /** The icon to display in the button. Set via story args for non-primitive values. */\n icon: React.ReactNode\n}\n\nexport type IconButtonBaseProps = IconButtonSharedProps & {\n /** Accessible label. Required for icon-only buttons to provide context about the button's purpose. */\n \"aria-label\": string\n}\n\ntype IconButtonTooltipProps = {\n /** Accessible label. Required for icon-only buttons to provide context about the button's purpose. Not required when `tooltip` is set. When both are set, this is the name and the tooltip is visual only. */\n \"aria-label\"?: string\n /** Text shown on hover and focus. Without `aria-label`, it is also used as the `aria-label`. With `aria-label`, start the `aria-label` with the same text (e.g. tooltip `\"Delete\"`, aria-label `\"Delete, 3 selected\"`). The tooltip itself is hidden from screen readers. Ignores `aria-labelledby`. */\n tooltip: string\n}\n\ntype IconButtonAriaLabelProps = {\n /** Accessible label. Required for icon-only buttons to provide context about the button's purpose. Not required when `tooltip` is set. When both are set, this is the name and the tooltip is visual only. */\n \"aria-label\": string\n /** Text shown on hover and focus. Without `aria-label`, it is also used as the `aria-label`. With `aria-label`, start the `aria-label` with the same text (e.g. tooltip `\"Delete\"`, aria-label `\"Delete, 3 selected\"`). The tooltip itself is hidden from screen readers. Ignores `aria-labelledby`. */\n tooltip?: string\n}\n\n/**\n * An icon-only button needs a name: `aria-label`, `tooltip`, or both.\n * `IconButtonAriaLabelProps` is declared last so that a missing name\n * reports \"aria-label is missing\", not \"tooltip is missing\".\n */\ntype IconButtonNameProps = IconButtonAriaLabelProps | IconButtonTooltipProps\n\nexport type IconButtonProps = IconButtonSharedProps &\n IconButtonNameProps & {\n /** Where the tooltip renders relative to the button. Default `\"bottom\"`. Has no effect without `tooltip`. */\n tooltipPlacement?: TooltipPlacement\n }\n\n/**\n * An icon-only button component that renders as a button element.\n * Requires an icon, and an aria-label or tooltip for accessibility.\n *\n * @component\n * @see {@link https://planningcenter.github.io/tapestry/?path=/docs/buttons-icon-button--docs | Storybook Documentation}\n * @see {@link https://github.com/planningcenter/tapestry/tree/main/packages/tapestry-migration-cli | Migration CLI: Available}\n */\nexport const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(\n (\n {\n className,\n icon,\n tooltip,\n tooltipPlacement = \"bottom\",\n ...restProps\n }: IconButtonProps,\n ref\n ) => {\n const iconOnlyClassName = classNames(\"tds-btn--icononly\", className)\n\n if (tooltip) {\n const {\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n ...buttonProps\n } = restProps\n\n return (\n <Tooltip content={tooltip} placement={tooltipPlacement} visualOnly>\n <BaseButton\n {...buttonProps}\n aria-label={ariaLabel || tooltip}\n label={icon}\n className={iconOnlyClassName}\n ref={ref}\n />\n </Tooltip>\n )\n }\n\n return (\n <BaseButton\n {...restProps}\n label={icon}\n className={iconOnlyClassName}\n ref={ref}\n />\n )\n }\n)\n\nIconButton.displayName = \"IconButton\"\n"],"names":[],"mappings":";;;;;AA6CA;;;;;;;AAOG;AACI,MAAM,UAAU,GAAG,UAAU,CAClC,CACE,EACE,SAAS,EACT,IAAI,EACJ,OAAO,EACP,gBAAgB,GAAG,QAAQ,EAC3B,GAAG,SAAS,EACI,EAClB,GAAG,KACD;IACF,MAAM,iBAAiB,GAAG,UAAU,CAAC,mBAAmB,EAAE,SAAS,CAAC;IAEpE,IAAI,OAAO,EAAE;AACX,QAAA,MAAM,EACJ,YAAY,EAAE,SAAS,EACvB,iBAAiB,EAAE,cAAc,EACjC,GAAG,WAAW,EACf,GAAG,SAAS;AAEb,QAAA,QACE,KAAA,CAAA,aAAA,CAAC,OAAO,EAAA,EAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,UAAU,EAAA,IAAA,EAAA;YAChE,KAAA,CAAA,aAAA,CAAC,UAAU,OACL,WAAW,EAAA,YAAA,EACH,SAAS,IAAI,OAAO,EAChC,KAAK,EAAE,IAAI,EACX,SAAS,EAAE,iBAAiB,EAC5B,GAAG,EAAE,GAAG,EAAA,CACR,CACM;IAEd;AAEA,IAAA,QACE,KAAA,CAAA,aAAA,CAAC,UAAU,OACL,SAAS,EACb,KAAK,EAAE,IAAI,EACX,SAAS,EAAE,iBAAiB,EAC5B,GAAG,EAAE,GAAG,EAAA,CACR;AAEN,CAAC;AAGH,UAAU,CAAC,WAAW,GAAG,YAAY;;;;"}
1
+ {"version":3,"file":"IconButton.js","sources":["../../../src/components/button/IconButton.tsx"],"sourcesContent":["import \"./btn.css\"\n\nimport { Tooltip, type TooltipPlacement } from \"@components/internal/tooltip\"\nimport classNames from \"classnames\"\nimport React, { forwardRef } from \"react\"\n\nimport { BaseButton, BaseButtonElementProps } from \"./BaseButton\"\n\ntype IconButtonSharedProps = Omit<BaseButtonElementProps, \"label\"> & {\n /** The icon to display in the button. Set via story args for non-primitive values. */\n icon: React.ReactNode\n}\n\nexport type IconButtonBaseProps = IconButtonSharedProps & {\n /** Accessible label. Required for icon-only buttons to provide context about the button's purpose. */\n \"aria-label\": string\n}\n\ntype IconButtonTooltipProps = {\n /** Accessible label. Required for icon-only buttons to provide context about the button's purpose. Not required when `tooltip` is set. When both are set, this is the name and the tooltip is visual only. */\n \"aria-label\"?: string\n /** Text shown on hover and focus. Without `aria-label`, it is also used as the `aria-label`. With `aria-label`, start the `aria-label` with the same text (e.g. tooltip `\"Delete\"`, aria-label `\"Delete, 3 selected\"`). The tooltip itself is hidden from screen readers. Ignores `aria-labelledby`. Never opens on hover while `disabled` or `loading`, and opens on keyboard focus only with `focusableWhenDisabled`, so don't rely on it to explain why the button is disabled. */\n tooltip: string\n}\n\ntype IconButtonAriaLabelProps = {\n /** Accessible label. Required for icon-only buttons to provide context about the button's purpose. Not required when `tooltip` is set. When both are set, this is the name and the tooltip is visual only. */\n \"aria-label\": string\n /** Text shown on hover and focus. Without `aria-label`, it is also used as the `aria-label`. With `aria-label`, start the `aria-label` with the same text (e.g. tooltip `\"Delete\"`, aria-label `\"Delete, 3 selected\"`). The tooltip itself is hidden from screen readers. Ignores `aria-labelledby`. Never opens on hover while `disabled` or `loading`, and opens on keyboard focus only with `focusableWhenDisabled`, so don't rely on it to explain why the button is disabled. */\n tooltip?: string\n}\n\n/**\n * An icon-only button needs a name: `aria-label`, `tooltip`, or both.\n * `IconButtonAriaLabelProps` is declared last so that a missing name\n * reports \"aria-label is missing\", not \"tooltip is missing\".\n */\ntype IconButtonNameProps = IconButtonAriaLabelProps | IconButtonTooltipProps\n\nexport type IconButtonProps = IconButtonSharedProps &\n IconButtonNameProps & {\n /** Where the tooltip renders relative to the button. Default `\"bottom\"`. Has no effect without `tooltip`. */\n tooltipPlacement?: TooltipPlacement\n }\n\n/**\n * An icon-only button component that renders as a button element.\n * Requires an icon, and an aria-label or tooltip for accessibility.\n *\n * @component\n * @see {@link https://planningcenter.github.io/tapestry/?path=/docs/buttons-icon-button--docs | Storybook Documentation}\n * @see {@link https://github.com/planningcenter/tapestry/tree/main/packages/tapestry-migration-cli | Migration CLI: Available}\n */\nexport const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(\n (\n {\n className,\n icon,\n tooltip,\n tooltipPlacement = \"bottom\",\n ...restProps\n }: IconButtonProps,\n ref\n ) => {\n const iconOnlyClassName = classNames(\"tds-btn--icononly\", className)\n\n if (tooltip) {\n const {\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n ...buttonProps\n } = restProps\n\n return (\n <Tooltip content={tooltip} placement={tooltipPlacement} visualOnly>\n <BaseButton\n {...buttonProps}\n aria-label={ariaLabel || tooltip}\n label={icon}\n className={iconOnlyClassName}\n ref={ref}\n />\n </Tooltip>\n )\n }\n\n return (\n <BaseButton\n {...restProps}\n label={icon}\n className={iconOnlyClassName}\n ref={ref}\n />\n )\n }\n)\n\nIconButton.displayName = \"IconButton\"\n"],"names":[],"mappings":";;;;;AA6CA;;;;;;;AAOG;AACI,MAAM,UAAU,GAAG,UAAU,CAClC,CACE,EACE,SAAS,EACT,IAAI,EACJ,OAAO,EACP,gBAAgB,GAAG,QAAQ,EAC3B,GAAG,SAAS,EACI,EAClB,GAAG,KACD;IACF,MAAM,iBAAiB,GAAG,UAAU,CAAC,mBAAmB,EAAE,SAAS,CAAC;IAEpE,IAAI,OAAO,EAAE;AACX,QAAA,MAAM,EACJ,YAAY,EAAE,SAAS,EACvB,iBAAiB,EAAE,cAAc,EACjC,GAAG,WAAW,EACf,GAAG,SAAS;AAEb,QAAA,QACE,KAAA,CAAA,aAAA,CAAC,OAAO,EAAA,EAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,UAAU,EAAA,IAAA,EAAA;YAChE,KAAA,CAAA,aAAA,CAAC,UAAU,OACL,WAAW,EAAA,YAAA,EACH,SAAS,IAAI,OAAO,EAChC,KAAK,EAAE,IAAI,EACX,SAAS,EAAE,iBAAiB,EAC5B,GAAG,EAAE,GAAG,EAAA,CACR,CACM;IAEd;AAEA,IAAA,QACE,KAAA,CAAA,aAAA,CAAC,UAAU,OACL,SAAS,EACb,KAAK,EAAE,IAAI,EACX,SAAS,EAAE,iBAAiB,EAC5B,GAAG,EAAE,GAAG,EAAA,CACR;AAEN,CAAC;AAGH,UAAU,CAAC,WAAW,GAAG,YAAY;;;;"}
@@ -4,6 +4,8 @@ export type CheckboxGroupSize = "md" | "sm";
4
4
  export interface CheckboxGroupProps {
5
5
  /** Optional description or error message rendered below the legend. */
6
6
  description?: React.ReactNode;
7
+ /** If true, visually hides the legend while keeping it available to assistive technology. */
8
+ hideLabel?: boolean;
7
9
  /** If true, adds aria-invalid and styles the description as an error. */
8
10
  invalid?: boolean;
9
11
  /** The group label. Renders as <legend>. Required. */
@@ -19,5 +21,5 @@ export type CheckboxGroupElementProps = Omit<FieldsetHTMLAttributes<HTMLFieldSet
19
21
  * @component
20
22
  * @see {@link https://planningcenter.github.io/tapestry/?path=/docs/forms-checkbox-group--docs | Storybook Documentation}
21
23
  */
22
- export declare function CheckboxGroup({ children, className, description, invalid, label, size, ...restProps }: CheckboxGroupElementProps): React.JSX.Element;
24
+ export declare function CheckboxGroup({ children, className, description, hideLabel, invalid, label, size, ...restProps }: CheckboxGroupElementProps): React.JSX.Element;
23
25
  //# sourceMappingURL=CheckboxGroup.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CheckboxGroup.d.ts","sourceRoot":"","sources":["../../../src/components/checkbox-group/CheckboxGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAKpB,OAAO,KAAK,EAAE,EAAE,sBAAsB,EAAE,MAAM,OAAO,CAAA;AAErD,MAAM,MAAM,iBAAiB,GAAG,IAAI,GAAG,IAAI,CAAA;AAE3C,MAAM,WAAW,kBAAkB;IACjC,uEAAuE;IACvE,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC7B,yEAAyE;IACzE,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,sDAAsD;IACtD,KAAK,EAAE,MAAM,CAAA;IACb,qDAAqD;IACrD,IAAI,CAAC,EAAE,iBAAiB,CAAA;CACzB;AAED,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAC1C,sBAAsB,CAAC,mBAAmB,CAAC,EAC3C,MAAM,kBAAkB,CACzB,GACC,kBAAkB,CAAA;AAEpB;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,SAAS,EACT,WAAW,EACX,OAAO,EACP,KAAK,EACL,IAAW,EACX,GAAG,SAAS,EACb,EAAE,yBAAyB,qBAiC3B"}
1
+ {"version":3,"file":"CheckboxGroup.d.ts","sourceRoot":"","sources":["../../../src/components/checkbox-group/CheckboxGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAKpB,OAAO,KAAK,EAAE,EAAE,sBAAsB,EAAE,MAAM,OAAO,CAAA;AAErD,MAAM,MAAM,iBAAiB,GAAG,IAAI,GAAG,IAAI,CAAA;AAE3C,MAAM,WAAW,kBAAkB;IACjC,uEAAuE;IACvE,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC7B,6FAA6F;IAC7F,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,yEAAyE;IACzE,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,sDAAsD;IACtD,KAAK,EAAE,MAAM,CAAA;IACb,qDAAqD;IACrD,IAAI,CAAC,EAAE,iBAAiB,CAAA;CACzB;AAED,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAC1C,sBAAsB,CAAC,mBAAmB,CAAC,EAC3C,MAAM,kBAAkB,CACzB,GACC,kBAAkB,CAAA;AAEpB;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,SAAS,EACT,WAAW,EACX,SAAiB,EACjB,OAAO,EACP,KAAK,EACL,IAAW,EACX,GAAG,SAAS,EACb,EAAE,yBAAyB,qBAqC3B"}