@flipdish/ui-library 0.67.0 → 0.68.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 (171) hide show
  1. package/README.md +31 -31
  2. package/dist/components/atoms/PhoneInput/hooks/usePhoneEntry.cjs +13 -30
  3. package/dist/components/atoms/PhoneInput/hooks/usePhoneEntry.cjs.map +1 -1
  4. package/dist/components/atoms/PhoneInput/hooks/usePhoneEntry.d.ts.map +1 -1
  5. package/dist/components/atoms/PhoneInput/hooks/usePhoneEntry.js +10 -27
  6. package/dist/components/atoms/PhoneInput/hooks/usePhoneEntry.js.map +1 -1
  7. package/dist/components/atoms/PhoneInput/utilities/phoneEntry.utils.cjs +55 -0
  8. package/dist/components/atoms/PhoneInput/utilities/phoneEntry.utils.cjs.map +1 -0
  9. package/dist/components/atoms/PhoneInput/utilities/phoneEntry.utils.d.ts +56 -0
  10. package/dist/components/atoms/PhoneInput/utilities/phoneEntry.utils.d.ts.map +1 -0
  11. package/dist/components/atoms/PhoneInput/utilities/phoneEntry.utils.js +52 -0
  12. package/dist/components/atoms/PhoneInput/utilities/phoneEntry.utils.js.map +1 -0
  13. package/dist/components/molecules/EmptyState/index.cjs +4 -2
  14. package/dist/components/molecules/EmptyState/index.cjs.map +1 -1
  15. package/dist/components/molecules/EmptyState/index.d.ts.map +1 -1
  16. package/dist/components/molecules/EmptyState/index.js +4 -2
  17. package/dist/components/molecules/EmptyState/index.js.map +1 -1
  18. package/dist/components/molecules/Pagination/index.d.ts +1 -1
  19. package/dist/components/molecules/Pagination/index.d.ts.map +1 -1
  20. package/dist/components/molecules/Paginations/Pagination/Pagination.cjs +21 -5
  21. package/dist/components/molecules/Paginations/Pagination/Pagination.cjs.map +1 -1
  22. package/dist/components/molecules/Paginations/Pagination/Pagination.d.ts +7 -1
  23. package/dist/components/molecules/Paginations/Pagination/Pagination.d.ts.map +1 -1
  24. package/dist/components/molecules/Paginations/Pagination/Pagination.js +22 -6
  25. package/dist/components/molecules/Paginations/Pagination/Pagination.js.map +1 -1
  26. package/dist/components/molecules/Paginations/components/PaginationBase.cjs +2 -2
  27. package/dist/components/molecules/Paginations/components/PaginationBase.cjs.map +1 -1
  28. package/dist/components/molecules/Paginations/components/PaginationBase.d.ts +4 -2
  29. package/dist/components/molecules/Paginations/components/PaginationBase.d.ts.map +1 -1
  30. package/dist/components/molecules/Paginations/components/PaginationBase.js +2 -2
  31. package/dist/components/molecules/Paginations/components/PaginationBase.js.map +1 -1
  32. package/dist/components/molecules/Paginations/utilities/paginationScroll.utils.cjs +125 -0
  33. package/dist/components/molecules/Paginations/utilities/paginationScroll.utils.cjs.map +1 -0
  34. package/dist/components/molecules/Paginations/utilities/paginationScroll.utils.d.ts +42 -0
  35. package/dist/components/molecules/Paginations/utilities/paginationScroll.utils.d.ts.map +1 -0
  36. package/dist/components/molecules/Paginations/utilities/paginationScroll.utils.js +118 -0
  37. package/dist/components/molecules/Paginations/utilities/paginationScroll.utils.js.map +1 -0
  38. package/dist/components/organisms/FilterBar/index.cjs +3 -1
  39. package/dist/components/organisms/FilterBar/index.cjs.map +1 -1
  40. package/dist/components/organisms/FilterBar/index.d.ts.map +1 -1
  41. package/dist/components/organisms/FilterBar/index.js +3 -1
  42. package/dist/components/organisms/FilterBar/index.js.map +1 -1
  43. package/dist/components/organisms/Table/components/TableCardList.cjs +27 -0
  44. package/dist/components/organisms/Table/components/TableCardList.cjs.map +1 -0
  45. package/dist/components/organisms/Table/components/TableCardList.d.ts +4 -0
  46. package/dist/components/organisms/Table/components/TableCardList.d.ts.map +1 -0
  47. package/dist/components/organisms/Table/components/TableCardList.js +25 -0
  48. package/dist/components/organisms/Table/components/TableCardList.js.map +1 -0
  49. package/dist/components/organisms/Table/components/TableCardRow.cjs +80 -0
  50. package/dist/components/organisms/Table/components/TableCardRow.cjs.map +1 -0
  51. package/dist/components/organisms/Table/components/TableCardRow.d.ts +4 -0
  52. package/dist/components/organisms/Table/components/TableCardRow.d.ts.map +1 -0
  53. package/dist/components/organisms/Table/components/TableCardRow.js +78 -0
  54. package/dist/components/organisms/Table/components/TableCardRow.js.map +1 -0
  55. package/dist/components/organisms/Table/components/TableCardsSelectAll.cjs +24 -0
  56. package/dist/components/organisms/Table/components/TableCardsSelectAll.cjs.map +1 -0
  57. package/dist/components/organisms/Table/components/TableCardsSelectAll.d.ts +13 -0
  58. package/dist/components/organisms/Table/components/TableCardsSelectAll.d.ts.map +1 -0
  59. package/dist/components/organisms/Table/components/TableCardsSelectAll.js +22 -0
  60. package/dist/components/organisms/Table/components/TableCardsSelectAll.js.map +1 -0
  61. package/dist/components/organisms/Table/components/TableFallbackCard.cjs +12 -0
  62. package/dist/components/organisms/Table/components/TableFallbackCard.cjs.map +1 -0
  63. package/dist/components/organisms/Table/components/TableFallbackCard.d.ts +6 -0
  64. package/dist/components/organisms/Table/components/TableFallbackCard.d.ts.map +1 -0
  65. package/dist/components/organisms/Table/components/TableFallbackCard.js +10 -0
  66. package/dist/components/organisms/Table/components/TableFallbackCard.js.map +1 -0
  67. package/dist/components/organisms/Table/components/TableFocusGuard.cjs +23 -0
  68. package/dist/components/organisms/Table/components/TableFocusGuard.cjs.map +1 -0
  69. package/dist/components/organisms/Table/components/TableFocusGuard.d.ts +2 -0
  70. package/dist/components/organisms/Table/components/TableFocusGuard.d.ts.map +1 -0
  71. package/dist/components/organisms/Table/components/TableFocusGuard.js +21 -0
  72. package/dist/components/organisms/Table/components/TableFocusGuard.js.map +1 -0
  73. package/dist/components/organisms/Table/components/TableLayoutToggle.cjs +27 -0
  74. package/dist/components/organisms/Table/components/TableLayoutToggle.cjs.map +1 -0
  75. package/dist/components/organisms/Table/components/TableLayoutToggle.d.ts +17 -0
  76. package/dist/components/organisms/Table/components/TableLayoutToggle.d.ts.map +1 -0
  77. package/dist/components/organisms/Table/components/TableLayoutToggle.js +25 -0
  78. package/dist/components/organisms/Table/components/TableLayoutToggle.js.map +1 -0
  79. package/dist/components/organisms/Table/components/TableRowCard.cjs +79 -0
  80. package/dist/components/organisms/Table/components/TableRowCard.cjs.map +1 -0
  81. package/dist/components/organisms/Table/components/TableRowCard.d.ts +71 -0
  82. package/dist/components/organisms/Table/components/TableRowCard.d.ts.map +1 -0
  83. package/dist/components/organisms/Table/components/TableRowCard.js +72 -0
  84. package/dist/components/organisms/Table/components/TableRowCard.js.map +1 -0
  85. package/dist/components/organisms/Table/components/TableSortMenu.cjs +48 -0
  86. package/dist/components/organisms/Table/components/TableSortMenu.cjs.map +1 -0
  87. package/dist/components/organisms/Table/components/TableSortMenu.d.ts +35 -0
  88. package/dist/components/organisms/Table/components/TableSortMenu.d.ts.map +1 -0
  89. package/dist/components/organisms/Table/components/TableSortMenu.js +46 -0
  90. package/dist/components/organisms/Table/components/TableSortMenu.js.map +1 -0
  91. package/dist/components/organisms/Table/hooks/useFirstSortDirection.cjs +25 -0
  92. package/dist/components/organisms/Table/hooks/useFirstSortDirection.cjs.map +1 -0
  93. package/dist/components/organisms/Table/hooks/useFirstSortDirection.d.ts +12 -0
  94. package/dist/components/organisms/Table/hooks/useFirstSortDirection.d.ts.map +1 -0
  95. package/dist/components/organisms/Table/hooks/useFirstSortDirection.js +23 -0
  96. package/dist/components/organisms/Table/hooks/useFirstSortDirection.js.map +1 -0
  97. package/dist/components/organisms/Table/hooks/useIsAtLeastMd.cjs +21 -0
  98. package/dist/components/organisms/Table/hooks/useIsAtLeastMd.cjs.map +1 -0
  99. package/dist/components/organisms/Table/hooks/useIsAtLeastMd.d.ts +9 -0
  100. package/dist/components/organisms/Table/hooks/useIsAtLeastMd.d.ts.map +1 -0
  101. package/dist/components/organisms/Table/hooks/useIsAtLeastMd.js +19 -0
  102. package/dist/components/organisms/Table/hooks/useIsAtLeastMd.js.map +1 -0
  103. package/dist/components/organisms/Table/hooks/usePlaceholderRows.cjs +43 -0
  104. package/dist/components/organisms/Table/hooks/usePlaceholderRows.cjs.map +1 -0
  105. package/dist/components/organisms/Table/hooks/usePlaceholderRows.d.ts +23 -0
  106. package/dist/components/organisms/Table/hooks/usePlaceholderRows.d.ts.map +1 -0
  107. package/dist/components/organisms/Table/hooks/usePlaceholderRows.js +40 -0
  108. package/dist/components/organisms/Table/hooks/usePlaceholderRows.js.map +1 -0
  109. package/dist/components/organisms/Table/hooks/useSelectableRowRegistry.cjs +20 -2
  110. package/dist/components/organisms/Table/hooks/useSelectableRowRegistry.cjs.map +1 -1
  111. package/dist/components/organisms/Table/hooks/useSelectableRowRegistry.d.ts +8 -4
  112. package/dist/components/organisms/Table/hooks/useSelectableRowRegistry.d.ts.map +1 -1
  113. package/dist/components/organisms/Table/hooks/useSelectableRowRegistry.js +21 -3
  114. package/dist/components/organisms/Table/hooks/useSelectableRowRegistry.js.map +1 -1
  115. package/dist/components/organisms/Table/hooks/useTableSelection.cjs +47 -0
  116. package/dist/components/organisms/Table/hooks/useTableSelection.cjs.map +1 -0
  117. package/dist/components/organisms/Table/hooks/useTableSelection.d.ts +31 -0
  118. package/dist/components/organisms/Table/hooks/useTableSelection.d.ts.map +1 -0
  119. package/dist/components/organisms/Table/hooks/useTableSelection.js +45 -0
  120. package/dist/components/organisms/Table/hooks/useTableSelection.js.map +1 -0
  121. package/dist/components/organisms/Table/index.cjs +169 -38
  122. package/dist/components/organisms/Table/index.cjs.map +1 -1
  123. package/dist/components/organisms/Table/index.d.ts +57 -20
  124. package/dist/components/organisms/Table/index.d.ts.map +1 -1
  125. package/dist/components/organisms/Table/index.js +162 -33
  126. package/dist/components/organisms/Table/index.js.map +1 -1
  127. package/dist/components/organisms/Table/providers/Table.context.cjs +19 -0
  128. package/dist/components/organisms/Table/providers/Table.context.cjs.map +1 -0
  129. package/dist/components/organisms/Table/providers/Table.context.d.ts +44 -0
  130. package/dist/components/organisms/Table/providers/Table.context.d.ts.map +1 -0
  131. package/dist/components/organisms/Table/providers/Table.context.js +13 -0
  132. package/dist/components/organisms/Table/providers/Table.context.js.map +1 -0
  133. package/dist/components/organisms/Table/table.types.d.ts +35 -0
  134. package/dist/components/organisms/Table/table.types.d.ts.map +1 -0
  135. package/dist/components/organisms/Table/utilities/tableCard.utils.cjs +197 -0
  136. package/dist/components/organisms/Table/utilities/tableCard.utils.cjs.map +1 -0
  137. package/dist/components/organisms/Table/utilities/tableCard.utils.d.ts +161 -0
  138. package/dist/components/organisms/Table/utilities/tableCard.utils.d.ts.map +1 -0
  139. package/dist/components/organisms/Table/utilities/tableCard.utils.js +180 -0
  140. package/dist/components/organisms/Table/utilities/tableCard.utils.js.map +1 -0
  141. package/dist/components/organisms/Table/utilities/tableChildren.utils.cjs +47 -0
  142. package/dist/components/organisms/Table/utilities/tableChildren.utils.cjs.map +1 -0
  143. package/dist/components/organisms/Table/utilities/tableChildren.utils.d.ts +39 -0
  144. package/dist/components/organisms/Table/utilities/tableChildren.utils.d.ts.map +1 -0
  145. package/dist/components/organisms/Table/utilities/tableChildren.utils.js +43 -0
  146. package/dist/components/organisms/Table/utilities/tableChildren.utils.js.map +1 -0
  147. package/dist/components/organisms/Table/utilities/tableSelection.utils.cjs +106 -0
  148. package/dist/components/organisms/Table/utilities/tableSelection.utils.cjs.map +1 -0
  149. package/dist/components/organisms/Table/utilities/tableSelection.utils.d.ts +82 -0
  150. package/dist/components/organisms/Table/utilities/tableSelection.utils.d.ts.map +1 -0
  151. package/dist/components/organisms/Table/utilities/tableSelection.utils.js +98 -0
  152. package/dist/components/organisms/Table/utilities/tableSelection.utils.js.map +1 -0
  153. package/dist/components/organisms/Table/utilities/tableSort.utils.cjs +87 -0
  154. package/dist/components/organisms/Table/utilities/tableSort.utils.cjs.map +1 -0
  155. package/dist/components/organisms/Table/utilities/tableSort.utils.d.ts +67 -0
  156. package/dist/components/organisms/Table/utilities/tableSort.utils.d.ts.map +1 -0
  157. package/dist/components/organisms/Table/utilities/tableSort.utils.js +79 -0
  158. package/dist/components/organisms/Table/utilities/tableSort.utils.js.map +1 -0
  159. package/dist/utilities/searchParamsUtils/index.cjs +2 -9
  160. package/dist/utilities/searchParamsUtils/index.cjs.map +1 -1
  161. package/dist/utilities/searchParamsUtils/index.d.ts +5 -3
  162. package/dist/utilities/searchParamsUtils/index.d.ts.map +1 -1
  163. package/dist/utilities/searchParamsUtils/index.js +2 -9
  164. package/dist/utilities/searchParamsUtils/index.js.map +1 -1
  165. package/package.json +1 -1
  166. package/dist/components/organisms/Table/table.utils.cjs +0 -61
  167. package/dist/components/organisms/Table/table.utils.cjs.map +0 -1
  168. package/dist/components/organisms/Table/table.utils.d.ts +0 -48
  169. package/dist/components/organisms/Table/table.utils.d.ts.map +0 -1
  170. package/dist/components/organisms/Table/table.utils.js +0 -55
  171. package/dist/components/organisms/Table/table.utils.js.map +0 -1
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Tells whether two sorts order a list the same way, for showing that a table is not at its resting order.
3
+ * @param current - The table's `sortDescriptor`; `undefined` when nothing is sorted.
4
+ * @param other - The sort to compare it with, such as the page's resting sort; `undefined` for no sort.
5
+ * @returns `true` when both sort the same column in the same direction, or neither sorts anything.
6
+ */
7
+ const isSameSort = (current, other) => current?.column === other?.column && current?.direction === other?.direction;
8
+ /**
9
+ * Keeps track of the direction the sorted column first landed on, as the table's sort changes. A sort at the resting sort is
10
+ * always the start of its column's cycle, so a column opened elsewhere, as from a link, comes back round once a clear lands it there.
11
+ * @param previous - What was tracked before; `undefined` while nothing was sorted.
12
+ * @param sortDescriptor - The table's sort now; `undefined` when nothing is sorted.
13
+ * @param resting - The page's resting sort; `undefined` when the list rests unsorted.
14
+ * @returns The column and its direction when another column becomes sorted, as on mount, or when the sort is the resting one;
15
+ * `previous` while the same column stays sorted elsewhere, whatever its direction now; `undefined` when nothing is sorted.
16
+ */
17
+ const firstSortOf = (previous, sortDescriptor, resting) => {
18
+ if (!sortDescriptor)
19
+ return undefined;
20
+ const isSameColumn = previous?.column === sortDescriptor.column;
21
+ if (isSameColumn && !isSameSort(sortDescriptor, resting))
22
+ return previous;
23
+ // The same object while nothing changed, so the hook holding it settles instead of storing a copy on every render.
24
+ if (isSameColumn && previous?.direction === sortDescriptor.direction)
25
+ return previous;
26
+ return { column: sortDescriptor.column, direction: sortDescriptor.direction };
27
+ };
28
+ /**
29
+ * Decides what a press on a sortable column header does. A column's cycle is its first direction, the other direction, then
30
+ * cleared: react-aria only toggles the sorted column, so the press that would toggle it back to its first direction clears it
31
+ * instead. An explicit `sort(direction)` on the sorted column asking for the other direction reaches the table as a press
32
+ * does, so on its second direction it clears too; one asking for the direction already shown is a change.
33
+ * @param current - The table's `sortDescriptor`; `undefined` when nothing is sorted.
34
+ * @param next - What react-aria asks for: ascending for a column that is not sorted, the other direction for the one that is.
35
+ * @param firstDirection - The direction the sorted column first landed on; `current`'s own direction when unknown.
36
+ * @returns `'clear'` for a press on the sorted column once it is on its second direction; `'change'` otherwise.
37
+ */
38
+ const sortStepOf = (current, next, firstDirection) => {
39
+ if (!current || current.column !== next.column)
40
+ return 'change';
41
+ // A press always asks for the other direction, so this is an explicit request for the one shown, which keeps it.
42
+ if (next.direction === current.direction)
43
+ return 'change';
44
+ return current.direction === (firstDirection ?? current.direction) ? 'change' : 'clear';
45
+ };
46
+ /**
47
+ * Picks the sort a column chosen in the sort menu applies.
48
+ * @param current - The table's `sortDescriptor`; `undefined` when nothing is sorted.
49
+ * @param column - The chosen column's id.
50
+ * @returns That column in the current direction, or ascending when nothing is sorted.
51
+ */
52
+ const sortOfColumnChoice = (current, column) => ({
53
+ column,
54
+ direction: current?.direction ?? 'ascending',
55
+ });
56
+ /**
57
+ * Picks the sort a direction chosen in the sort menu applies.
58
+ * @param current - The table's `sortDescriptor`; `undefined` when nothing is sorted.
59
+ * @param direction - The chosen direction.
60
+ * @returns The current column in that direction, or `undefined` when nothing is sorted, as there is no column to apply it to.
61
+ */
62
+ const sortOfDirectionChoice = (current, direction) => current && { column: current.column, direction };
63
+ /**
64
+ * Keys a column's item in the sort menu, apart from the direction and "Clear sort" items and from every other column's.
65
+ * @param id - The column's id, as its `Table.Head` has it.
66
+ * @returns `col-<id>` for a string id and `colnum-<id>` for a number, so `'1'` and `1` stay apart; the item's test id
67
+ * derives from it too.
68
+ */
69
+ const sortMenuColumnKeyOf = (id) => (typeof id === 'number' ? `colnum-${id}` : `col-${id}`);
70
+ /**
71
+ * Finds the column a sort-menu item stands for.
72
+ * @param columns - The menu's columns.
73
+ * @param key - The chosen item's key; `undefined` when nothing is chosen.
74
+ * @returns The column whose item that is, or `undefined` for any other key.
75
+ */
76
+ const columnOfSortMenuKey = (columns, key) => key === undefined ? undefined : columns.find((column) => sortMenuColumnKeyOf(column.id) === key);
77
+
78
+ export { columnOfSortMenuKey, firstSortOf, isSameSort, sortMenuColumnKeyOf, sortOfColumnChoice, sortOfDirectionChoice, sortStepOf };
79
+ //# sourceMappingURL=tableSort.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tableSort.utils.js","sources":["../../../../../src/components/organisms/Table/utilities/tableSort.utils.ts"],"sourcesContent":[null],"names":[],"mappings":"AAEA;;;;;AAKG;AACI,MAAM,UAAU,GAAG,CAAC,OAAmC,EAAE,KAAiC,KAC/F,OAAO,EAAE,MAAM,KAAK,KAAK,EAAE,MAAM,IAAI,OAAO,EAAE,SAAS,KAAK,KAAK,EAAE;AAUrE;;;;;;;;AAQG;AACI,MAAM,WAAW,GAAG,CACzB,QAA+B,EAC/B,cAA0C,EAC1C,OAAwB,KACC;AACzB,IAAA,IAAI,CAAC,cAAc;AAAE,QAAA,OAAO,SAAS;IACrC,MAAM,YAAY,GAAG,QAAQ,EAAE,MAAM,KAAK,cAAc,CAAC,MAAM;IAC/D,IAAI,YAAY,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE,OAAO,CAAC;AAAE,QAAA,OAAO,QAAQ;;IAEzE,IAAI,YAAY,IAAI,QAAQ,EAAE,SAAS,KAAK,cAAc,CAAC,SAAS;AAAE,QAAA,OAAO,QAAQ;AACrF,IAAA,OAAO,EAAE,MAAM,EAAE,cAAc,CAAC,MAAM,EAAE,SAAS,EAAE,cAAc,CAAC,SAAS,EAAE;AAC/E;AAEA;;;;;;;;;AASG;AACI,MAAM,UAAU,GAAG,CAAC,OAAmC,EAAE,IAAoB,EAAE,cAA8B,KAAwB;IAC1I,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM;AAAE,QAAA,OAAO,QAAQ;;AAE/D,IAAA,IAAI,IAAI,CAAC,SAAS,KAAK,OAAO,CAAC,SAAS;AAAE,QAAA,OAAO,QAAQ;AACzD,IAAA,OAAO,OAAO,CAAC,SAAS,MAAM,cAAc,IAAI,OAAO,CAAC,SAAS,CAAC,GAAG,QAAQ,GAAG,OAAO;AACzF;AAEA;;;;;AAKG;AACI,MAAM,kBAAkB,GAAG,CAAC,OAAmC,EAAE,MAAW,MAAsB;IACvG,MAAM;AACN,IAAA,SAAS,EAAE,OAAO,EAAE,SAAS,IAAI,WAAW;AAC7C,CAAA;AAED;;;;;AAKG;MACU,qBAAqB,GAAG,CAAC,OAAmC,EAAE,SAAwB,KACjG,OAAO,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,SAAS;AAEhD;;;;;AAKG;AACI,MAAM,mBAAmB,GAAG,CAAC,EAAO,MAAc,OAAO,EAAE,KAAK,QAAQ,GAAG,CAAA,OAAA,EAAU,EAAE,CAAA,CAAE,GAAG,CAAA,IAAA,EAAO,EAAE,CAAA,CAAE;AAE9G;;;;;AAKG;AACI,MAAM,mBAAmB,GAAG,CAAwB,OAAqB,EAAE,GAAoB,KACpG,GAAG,KAAK,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,GAAG;;"}
@@ -34,20 +34,13 @@ const parsePageSizeParam = (value, allowed, fallback) => {
34
34
  const size = Number(value);
35
35
  return value !== null && allowed.includes(size) ? size : fallback;
36
36
  };
37
- /**
38
- * Reads a table sort out of a search param written by `sortToParam`: the column id, with a leading `-` for descending.
39
- * @param value - The param's value, `null` when it is absent.
40
- * @param columns - The columns that can be sorted.
41
- * @param fallback - The sort to use when the value is absent or names a column that cannot be sorted.
42
- * @returns The sort the value describes, or `fallback`.
43
- */
44
- const parseSortParam = (value, columns, fallback) => {
37
+ function parseSortParam(value, columns, fallback) {
45
38
  if (!value)
46
39
  return fallback;
47
40
  const descending = value.startsWith('-');
48
41
  const column = parseEnumParam(descending ? value.slice(1) : value, columns, null);
49
42
  return column === null ? fallback : { column, direction: descending ? 'descending' : 'ascending' };
50
- };
43
+ }
51
44
  /**
52
45
  * Writes a table sort as a search param value: the column id, with a leading `-` for descending, e.g. `-name`.
53
46
  * @param sort - The table's sort; any `{ column, direction }`, such as react-aria's `SortDescriptor`.
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../src/utilities/searchParamsUtils/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;AAGG;AACI,MAAM,WAAW,GAAG;AACzB,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,MAAM,EAAE,GAAG;AACX,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,QAAQ,EAAE,UAAU;;SAkBN,cAAc,CAAmB,KAAoB,EAAE,OAAqB,EAAE,QAAkB,EAAA;AAC9G,IAAA,OAAO,KAAK,KAAK,IAAI,IAAK,OAA6B,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAI,KAAW,GAAG,QAAQ;AACnG;AAEA;;;;AAIG;AACI,MAAM,cAAc,GAAG,CAAC,KAAoB,KAAY;AAC7D,IAAA,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC;AAC1B,IAAA,OAAO,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC;AACtD;AAEA;;;;;;AAMG;AACI,MAAM,kBAAkB,GAAG,CAAC,KAAoB,EAAE,OAA0B,EAAE,QAAgB,KAAY;AAC/G,IAAA,MAAM,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AC9I,IAAA,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS;AAAE,QAAA,OAAO,IAAI;AAC1C,IAAA,IAAI,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM,IAAI,IAAI,CAAC,SAAS,KAAK,QAAQ,CAAC,SAAS;AAAE,QAAA,OAAO,IAAI;IACrG,OAAO,CAAA,EAAG,IAAI,CAAC,SAAS,KAAK,YAAY,GAAG,GAAG,GAAG,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA,CAAE;AAC9E;;;;;;;"}
@@ -41,10 +41,12 @@ export declare const parsePageSizeParam: (value: string | null, allowed: readonl
41
41
  * Reads a table sort out of a search param written by `sortToParam`: the column id, with a leading `-` for descending.
42
42
  * @param value - The param's value, `null` when it is absent.
43
43
  * @param columns - The columns that can be sorted.
44
- * @param fallback - The sort to use when the value is absent or names a column that cannot be sorted.
45
- * @returns The sort the value describes, or `fallback`.
44
+ * @param fallback - The sort to use when the value is absent, empty or names a column that cannot be sorted; omitted or
45
+ * `undefined` for a page whose list rests unsorted.
46
+ * @returns The sort the value describes, or `fallback`, which is `undefined` when there is none.
46
47
  */
47
- export declare const parseSortParam: <Column extends string>(value: string | null, columns: readonly Column[], fallback: SortParam<Column>) => SortParam<Column>;
48
+ export declare function parseSortParam<Column extends string>(value: string | null, columns: readonly Column[], fallback: SortParam<Column>): SortParam<Column>;
49
+ export declare function parseSortParam<Column extends string>(value: string | null, columns: readonly Column[], fallback?: SortParam<Column>): SortParam<Column> | undefined;
48
50
  /**
49
51
  * Writes a table sort as a search param value: the column id, with a leading `-` for descending, e.g. `-name`.
50
52
  * @param sort - The table's sort; any `{ column, direction }`, such as react-aria's `SortDescriptor`.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utilities/searchParamsUtils/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,WAAW;;;;;;CAMd,CAA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;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,MAAM;IAAE,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,WAAW;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,KAAG,MAAM,GAAG,IAIxI,CAAC"}
@@ -32,20 +32,13 @@ const parsePageSizeParam = (value, allowed, fallback) => {
32
32
  const size = Number(value);
33
33
  return value !== null && allowed.includes(size) ? size : fallback;
34
34
  };
35
- /**
36
- * Reads a table sort out of a search param written by `sortToParam`: the column id, with a leading `-` for descending.
37
- * @param value - The param's value, `null` when it is absent.
38
- * @param columns - The columns that can be sorted.
39
- * @param fallback - The sort to use when the value is absent or names a column that cannot be sorted.
40
- * @returns The sort the value describes, or `fallback`.
41
- */
42
- const parseSortParam = (value, columns, fallback) => {
35
+ function parseSortParam(value, columns, fallback) {
43
36
  if (!value)
44
37
  return fallback;
45
38
  const descending = value.startsWith('-');
46
39
  const column = parseEnumParam(descending ? value.slice(1) : value, columns, null);
47
40
  return column === null ? fallback : { column, direction: descending ? 'descending' : 'ascending' };
48
- };
41
+ }
49
42
  /**
50
43
  * Writes a table sort as a search param value: the column id, with a leading `-` for descending, e.g. `-name`.
51
44
  * @param sort - The table's sort; any `{ column, direction }`, such as react-aria's `SortDescriptor`.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/utilities/searchParamsUtils/index.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;AAGG;AACI,MAAM,WAAW,GAAG;AACzB,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,MAAM,EAAE,GAAG;AACX,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,QAAQ,EAAE,UAAU;;SAkBN,cAAc,CAAmB,KAAoB,EAAE,OAAqB,EAAE,QAAkB,EAAA;AAC9G,IAAA,OAAO,KAAK,KAAK,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AAAE,QAAA,OAAO,QAAQ;IAC3B,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC;IACxC,MAAM,MAAM,GAAG,cAAc,CAAC,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC;IACjF,OAAO,MAAM,KAAK,IAAI,GAAG,QAAQ,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,GAAG,YAAY,GAAG,WAAW,EAAE;AACpG;AAEA;;;;;AAKG;MACU,WAAW,GAAG,CAAC,IAA8C,EAAE,QAAiD,KAAmB;AAC9I,IAAA,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS;AAAE,QAAA,OAAO,IAAI;AAC1C,IAAA,IAAI,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM,IAAI,IAAI,CAAC,SAAS,KAAK,QAAQ,CAAC,SAAS;AAAE,QAAA,OAAO,IAAI;IACrG,OAAO,CAAA,EAAG,IAAI,CAAC,SAAS,KAAK,YAAY,GAAG,GAAG,GAAG,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA,CAAE;AAC9E;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flipdish/ui-library",
3
- "version": "0.67.0",
3
+ "version": "0.68.0",
4
4
  "description": "Flipdish Design System — atomic-design component library (Tailwind v4 + UntitledUI + React Aria).",
5
5
  "type": "module",
6
6
  "imports": {
@@ -1,61 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * Turns a single selected key into the selection react-aria expects.
5
- * @param key - The selected row's id, or `null` for none.
6
- * @returns A selection holding that one key, or an empty one.
7
- */
8
- const selectionOfKey = (key) => new Set(key === null ? [] : [key]);
9
- /**
10
- * Reads the one selected key out of a selection, for a single-select table.
11
- * @param selection - What react-aria reports; a single-select table never reports `'all'`.
12
- * @returns The selected row's id, or `null` when nothing is selected, as after a second click on the selected row.
13
- */
14
- const keyOfSelection = (selection) => {
15
- if (selection === 'all')
16
- return null;
17
- const [first] = selection;
18
- return first ?? null;
19
- };
20
- /**
21
- * Lists the selected keys of a multiple-select table, resolving "select all" into the rows it covers.
22
- * @param selection - What react-aria reports, `'all'` after the header checkbox.
23
- * @param rowKeys - Every rendered row's id, in the order the rows mounted, which is the display order until rows are reordered in place.
24
- * @param disabledKeys - Rows that cannot be selected, which "select all" leaves out.
25
- * @returns The selected rows' ids.
26
- */
27
- const keysOfSelection = (selection, rowKeys, disabledKeys = []) => {
28
- if (selection !== 'all')
29
- return [...selection];
30
- const disabled = new Set(disabledKeys);
31
- return [...rowKeys].filter((key) => !disabled.has(key));
32
- };
33
- /**
34
- * Reports whether the table should replace react-aria's selection handler.
35
- * Passing a handler when nobody is listening would override react-aria's own bookkeeping.
36
- *
37
- * @param listeners The three selection callbacks a table may be given.
38
- * @returns `true` when at least one listener is set.
39
- */
40
- const hasSelectionListener = (listeners) => listeners.onSelectionChange !== undefined || listeners.onSelectedKeyChange !== undefined || listeners.onSelectedKeysChange !== undefined;
41
- /**
42
- * Forwards one selection change to every listener the consumer passed, in that order.
43
- *
44
- * @param selection What react-aria reports, including `'all'` after the header checkbox.
45
- * @param rowKeys Mounted selectable row ids, in mount order, used to expand `'all'`.
46
- * @param disabledKeys Rows "select all" leaves out. Omitted when the table disables none.
47
- * @param listeners The callbacks to notify. Each runs only when the consumer passed it.
48
- * @returns Nothing. Each provided listener is called.
49
- */
50
- const reportSelectionChange = (selection, rowKeys, disabledKeys, listeners) => {
51
- listeners.onSelectionChange?.(selection);
52
- listeners.onSelectedKeyChange?.(keyOfSelection(selection));
53
- listeners.onSelectedKeysChange?.(keysOfSelection(selection, rowKeys, disabledKeys));
54
- };
55
-
56
- exports.hasSelectionListener = hasSelectionListener;
57
- exports.keyOfSelection = keyOfSelection;
58
- exports.keysOfSelection = keysOfSelection;
59
- exports.reportSelectionChange = reportSelectionChange;
60
- exports.selectionOfKey = selectionOfKey;
61
- //# sourceMappingURL=table.utils.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"table.utils.cjs","sources":["../../../../src/components/organisms/Table/table.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA;;;;AAIG;AACI,MAAM,cAAc,GAAG,CAAC,GAAe,KAAgB,IAAI,GAAG,CAAC,GAAG,KAAK,IAAI,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC;AAE/F;;;;AAIG;AACI,MAAM,cAAc,GAAG,CAAC,SAAoB,KAAgB;IACjE,IAAI,SAAS,KAAK,KAAK;AAAE,QAAA,OAAO,IAAI;AACpC,IAAA,MAAM,CAAC,KAAK,CAAC,GAAG,SAAS;IACzB,OAAO,KAAK,IAAI,IAAI;AACtB;AAEA;;;;;;AAMG;AACI,MAAM,eAAe,GAAG,CAAC,SAAoB,EAAE,OAAsB,EAAE,YAAA,GAA8B,EAAE,KAAW;IACvH,IAAI,SAAS,KAAK,KAAK;AAAE,QAAA,OAAO,CAAC,GAAG,SAAS,CAAC;AAC9C,IAAA,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC;IACtC,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACzD;AAWA;;;;;;AAMG;AACI,MAAM,oBAAoB,GAAG,CAAC,SAAmC,KACtE,SAAS,CAAC,iBAAiB,KAAK,SAAS,IAAI,SAAS,CAAC,mBAAmB,KAAK,SAAS,IAAI,SAAS,CAAC,oBAAoB,KAAK;AAEjI;;;;;;;;AAQG;AACI,MAAM,qBAAqB,GAAG,CACnC,SAAoB,EACpB,OAAsB,EACtB,YAAuC,EACvC,SAAmC,KAC3B;AACR,IAAA,SAAS,CAAC,iBAAiB,GAAG,SAAS,CAAC;IACxC,SAAS,CAAC,mBAAmB,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;AAC1D,IAAA,SAAS,CAAC,oBAAoB,GAAG,eAAe,CAAC,SAAS,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;AACrF;;;;;;"}
@@ -1,48 +0,0 @@
1
- import type { Key, Selection } from 'react-aria-components';
2
- /**
3
- * Turns a single selected key into the selection react-aria expects.
4
- * @param key - The selected row's id, or `null` for none.
5
- * @returns A selection holding that one key, or an empty one.
6
- */
7
- export declare const selectionOfKey: (key: Key | null) => Selection;
8
- /**
9
- * Reads the one selected key out of a selection, for a single-select table.
10
- * @param selection - What react-aria reports; a single-select table never reports `'all'`.
11
- * @returns The selected row's id, or `null` when nothing is selected, as after a second click on the selected row.
12
- */
13
- export declare const keyOfSelection: (selection: Selection) => Key | null;
14
- /**
15
- * Lists the selected keys of a multiple-select table, resolving "select all" into the rows it covers.
16
- * @param selection - What react-aria reports, `'all'` after the header checkbox.
17
- * @param rowKeys - Every rendered row's id, in the order the rows mounted, which is the display order until rows are reordered in place.
18
- * @param disabledKeys - Rows that cannot be selected, which "select all" leaves out.
19
- * @returns The selected rows' ids.
20
- */
21
- export declare const keysOfSelection: (selection: Selection, rowKeys: Iterable<Key>, disabledKeys?: Iterable<Key>) => Key[];
22
- export interface SelectionChangeListeners {
23
- /** React Aria's own selection callback, forwarded unchanged. */
24
- onSelectionChange?: (selection: Selection) => void;
25
- /** Single-select callback. Receives the one key, or `null` when the selection is empty or `'all'`. */
26
- onSelectedKeyChange?: (key: Key | null) => void;
27
- /** Multi-select callback. Receives row ids, with `'all'` expanded to the mounted selectable rows. */
28
- onSelectedKeysChange?: (keys: Key[]) => void;
29
- }
30
- /**
31
- * Reports whether the table should replace react-aria's selection handler.
32
- * Passing a handler when nobody is listening would override react-aria's own bookkeeping.
33
- *
34
- * @param listeners The three selection callbacks a table may be given.
35
- * @returns `true` when at least one listener is set.
36
- */
37
- export declare const hasSelectionListener: (listeners: SelectionChangeListeners) => boolean;
38
- /**
39
- * Forwards one selection change to every listener the consumer passed, in that order.
40
- *
41
- * @param selection What react-aria reports, including `'all'` after the header checkbox.
42
- * @param rowKeys Mounted selectable row ids, in mount order, used to expand `'all'`.
43
- * @param disabledKeys Rows "select all" leaves out. Omitted when the table disables none.
44
- * @param listeners The callbacks to notify. Each runs only when the consumer passed it.
45
- * @returns Nothing. Each provided listener is called.
46
- */
47
- export declare const reportSelectionChange: (selection: Selection, rowKeys: Iterable<Key>, disabledKeys: Iterable<Key> | undefined, listeners: SelectionChangeListeners) => void;
48
- //# sourceMappingURL=table.utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"table.utils.d.ts","sourceRoot":"","sources":["../../../../src/components/organisms/Table/table.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAE5D;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,KAAK,GAAG,GAAG,IAAI,KAAG,SAA+C,CAAC;AAEjG;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,WAAW,SAAS,KAAG,GAAG,GAAG,IAI3D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAAI,WAAW,SAAS,EAAE,SAAS,QAAQ,CAAC,GAAG,CAAC,EAAE,eAAc,QAAQ,CAAC,GAAG,CAAM,KAAG,GAAG,EAInH,CAAC;AAEF,MAAM,WAAW,wBAAwB;IACvC,gEAAgE;IAChE,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,CAAC;IACnD,sGAAsG;IACtG,mBAAmB,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,KAAK,IAAI,CAAC;IAChD,qGAAqG;IACrG,oBAAoB,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;CAC9C;AAED;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAAI,WAAW,wBAAwB,KAAG,OAC+D,CAAC;AAE3I;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,GAChC,WAAW,SAAS,EACpB,SAAS,QAAQ,CAAC,GAAG,CAAC,EACtB,cAAc,QAAQ,CAAC,GAAG,CAAC,GAAG,SAAS,EACvC,WAAW,wBAAwB,KAClC,IAIF,CAAC"}
@@ -1,55 +0,0 @@
1
- /**
2
- * Turns a single selected key into the selection react-aria expects.
3
- * @param key - The selected row's id, or `null` for none.
4
- * @returns A selection holding that one key, or an empty one.
5
- */
6
- const selectionOfKey = (key) => new Set(key === null ? [] : [key]);
7
- /**
8
- * Reads the one selected key out of a selection, for a single-select table.
9
- * @param selection - What react-aria reports; a single-select table never reports `'all'`.
10
- * @returns The selected row's id, or `null` when nothing is selected, as after a second click on the selected row.
11
- */
12
- const keyOfSelection = (selection) => {
13
- if (selection === 'all')
14
- return null;
15
- const [first] = selection;
16
- return first ?? null;
17
- };
18
- /**
19
- * Lists the selected keys of a multiple-select table, resolving "select all" into the rows it covers.
20
- * @param selection - What react-aria reports, `'all'` after the header checkbox.
21
- * @param rowKeys - Every rendered row's id, in the order the rows mounted, which is the display order until rows are reordered in place.
22
- * @param disabledKeys - Rows that cannot be selected, which "select all" leaves out.
23
- * @returns The selected rows' ids.
24
- */
25
- const keysOfSelection = (selection, rowKeys, disabledKeys = []) => {
26
- if (selection !== 'all')
27
- return [...selection];
28
- const disabled = new Set(disabledKeys);
29
- return [...rowKeys].filter((key) => !disabled.has(key));
30
- };
31
- /**
32
- * Reports whether the table should replace react-aria's selection handler.
33
- * Passing a handler when nobody is listening would override react-aria's own bookkeeping.
34
- *
35
- * @param listeners The three selection callbacks a table may be given.
36
- * @returns `true` when at least one listener is set.
37
- */
38
- const hasSelectionListener = (listeners) => listeners.onSelectionChange !== undefined || listeners.onSelectedKeyChange !== undefined || listeners.onSelectedKeysChange !== undefined;
39
- /**
40
- * Forwards one selection change to every listener the consumer passed, in that order.
41
- *
42
- * @param selection What react-aria reports, including `'all'` after the header checkbox.
43
- * @param rowKeys Mounted selectable row ids, in mount order, used to expand `'all'`.
44
- * @param disabledKeys Rows "select all" leaves out. Omitted when the table disables none.
45
- * @param listeners The callbacks to notify. Each runs only when the consumer passed it.
46
- * @returns Nothing. Each provided listener is called.
47
- */
48
- const reportSelectionChange = (selection, rowKeys, disabledKeys, listeners) => {
49
- listeners.onSelectionChange?.(selection);
50
- listeners.onSelectedKeyChange?.(keyOfSelection(selection));
51
- listeners.onSelectedKeysChange?.(keysOfSelection(selection, rowKeys, disabledKeys));
52
- };
53
-
54
- export { hasSelectionListener, keyOfSelection, keysOfSelection, reportSelectionChange, selectionOfKey };
55
- //# sourceMappingURL=table.utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"table.utils.js","sources":["../../../../src/components/organisms/Table/table.utils.ts"],"sourcesContent":[null],"names":[],"mappings":"AAEA;;;;AAIG;AACI,MAAM,cAAc,GAAG,CAAC,GAAe,KAAgB,IAAI,GAAG,CAAC,GAAG,KAAK,IAAI,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC;AAE/F;;;;AAIG;AACI,MAAM,cAAc,GAAG,CAAC,SAAoB,KAAgB;IACjE,IAAI,SAAS,KAAK,KAAK;AAAE,QAAA,OAAO,IAAI;AACpC,IAAA,MAAM,CAAC,KAAK,CAAC,GAAG,SAAS;IACzB,OAAO,KAAK,IAAI,IAAI;AACtB;AAEA;;;;;;AAMG;AACI,MAAM,eAAe,GAAG,CAAC,SAAoB,EAAE,OAAsB,EAAE,YAAA,GAA8B,EAAE,KAAW;IACvH,IAAI,SAAS,KAAK,KAAK;AAAE,QAAA,OAAO,CAAC,GAAG,SAAS,CAAC;AAC9C,IAAA,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC;IACtC,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACzD;AAWA;;;;;;AAMG;AACI,MAAM,oBAAoB,GAAG,CAAC,SAAm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