@economic/taco 2.46.0 → 2.46.2

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.
@@ -1361,3 +1361,10 @@ table[data-taco^='table'] tr[data-row-id^='temp-'] [data-row-move-indicator] {
1361
1361
  table[data-taco^='table'] tr:not([data-row-id^='temp-']) [data-row-move-indicator] {
1362
1362
  @apply top-full rounded-b-md;
1363
1363
  }
1364
+
1365
+ table[data-taco^='table'][data-table-row-height='short'] tr[data-row-create] td,
1366
+ table[data-taco^='table'][data-table-row-height='medium'] tr[data-row-create] td,
1367
+ table[data-taco^='table'][data-table-row-height='tall'] tr[data-row-create] td,
1368
+ table[data-taco^='table'][data-table-row-height='extra-tall'] tr[data-row-create] td {
1369
+ @apply !min-h-[41px] !pt-[10px];
1370
+ }
@@ -26,19 +26,22 @@ function useTable3(props, ref) {
26
26
  data,
27
27
  enableRowActions: editing.isEditing ? true : props.enableRowActions,
28
28
  // Display EditingActionMenu instead of row actions while editing
29
- rowActions: editing.isEditing ? [(_, rowId, table) => (/*#__PURE__*/React__default.createElement(EditingActionMenu, {
30
- hasChanges: editing.hasChanges(rowId),
31
- hasErrors: editing.hasRowErrors(rowId),
32
- onDiscard: () => editing.discardChanges(rowId, table),
33
- onEditingSave: function () {
34
- try {
35
- return Promise.resolve(editing.saveChanges(table, rowId)).then(function () {});
36
- } catch (e) {
37
- return Promise.reject(e);
38
- }
39
- },
40
- isLastRow: !creationEnabled && table.meta.rowActive.rowActiveIndex === table.meta.length - 1
41
- }))] : props.rowActions
29
+ rowActions: editing.isEditing ? [(_, rowId, table) => {
30
+ const tableMeta = table.options.meta;
31
+ return /*#__PURE__*/React__default.createElement(EditingActionMenu, {
32
+ hasChanges: editing.hasChanges(rowId),
33
+ hasErrors: editing.hasRowErrors(rowId),
34
+ onDiscard: () => editing.discardChanges(rowId, table),
35
+ onEditingSave: function () {
36
+ try {
37
+ return Promise.resolve(editing.saveChanges(table, rowId)).then(function () {});
38
+ } catch (e) {
39
+ return Promise.reject(e);
40
+ }
41
+ },
42
+ isLastRow: !creationEnabled && tableMeta.rowActive.rowActiveIndex === tableMeta.length - 1
43
+ });
44
+ }] : props.rowActions
42
45
  };
43
46
  const meta = {
44
47
  editing
@@ -1 +1 @@
1
- {"version":3,"file":"useTable3.js","sources":["../../../../../../../src/components/Table3/useTable3.tsx"],"sourcesContent":["import React from 'react';\nimport { RowData } from '@tanstack/react-table';\nimport { useTable } from '../../primitives/Table/Core/useTable';\nimport { useTableEditingListener } from './listeners/useTableEditingListener';\nimport { useTableEditing } from './features/useTableEditing';\nimport { Table3Props, Table3Ref } from './types';\nimport { TableRowActionRenderer } from '../../primitives/Table/types';\nimport { Cell } from './components/Columns/Cell/Cell';\nimport { EditingActionMenu } from './components/Columns/Internal/EditingActionsMenu';\nimport { Row } from './components/Row/Row';\nimport { useTableRenderOptions } from '../../primitives/Table/Core/types';\n\nexport const RENDERERS = {\n row: Row,\n cell: Cell,\n};\n\ndeclare module '@tanstack/table-core' {\n interface TableMeta<TData extends RowData> {\n editing: ReturnType<typeof useTableEditing>;\n }\n}\n\ntype Table3Meta = {\n editing: ReturnType<typeof useTableEditing>;\n};\n\nexport function useTable3<TType>(props: Table3Props<TType>, ref: React.Ref<Table3Ref>) {\n const editing = useTableEditing(\n props.enableEditing,\n props.onEditingSave,\n props.onEditingChange,\n props.rowIdentityAccessor,\n props.validator\n );\n const creationEnabled = editing.isEnabled && !!props.onEditingCreate;\n\n // this gives me the performance heeby jeebies, but can't think of a better way to internalise the state\n const data: TType[] = React.useMemo(() => {\n if (editing.temporaryRows.length) {\n return (props.data ?? []).concat(editing.temporaryRows as TType[]);\n }\n\n return props.data;\n }, [JSON.stringify(props.data), editing.temporaryRows.length]);\n\n const extendedProps: Table3Props<TType> = {\n ...props,\n data,\n enableRowActions: editing.isEditing ? true : props.enableRowActions,\n // Display EditingActionMenu instead of row actions while editing\n rowActions: editing.isEditing\n ? ([\n (_, rowId, table) => (\n <EditingActionMenu\n hasChanges={editing.hasChanges(rowId)}\n hasErrors={editing.hasRowErrors(rowId)}\n onDiscard={() => editing.discardChanges(rowId, table)}\n onEditingSave={async () => {\n await editing.saveChanges(table, rowId);\n }}\n isLastRow={!creationEnabled && table.meta.rowActive.rowActiveIndex === table.meta.length - 1}\n />\n ),\n ] as TableRowActionRenderer<TType>[])\n : props.rowActions,\n };\n const meta = { editing };\n\n const options: useTableRenderOptions = {\n virtualiserPaddingEndOffset:\n props.enableEditing && props.onEditingCreate ? (editing.hasTemporaryRowErrors() ? 1.4 : 1) : 0,\n };\n\n const table = useTable<TType, Table3Meta>(extendedProps, ref, RENDERERS, meta, options);\n\n // listeners\n useTableEditingListener<TType>(table.instance, table.ref, table.renderer.scrollToIndex);\n\n React.useEffect(() => {\n if (table.ref.current) {\n (table.ref.current as Table3Ref).instance.toggleEditing = (enabled: boolean | undefined) =>\n table.meta.editing.toggleEditing(enabled ?? (editing => !editing), table.instance, table.renderer.scrollToIndex);\n }\n }, [table.ref.current]);\n\n return table;\n}\n"],"names":["RENDERERS","row","Row","cell","Cell","useTable3","props","ref","editing","useTableEditing","enableEditing","onEditingSave","onEditingChange","rowIdentityAccessor","validator","creationEnabled","isEnabled","onEditingCreate","data","React","useMemo","temporaryRows","length","_props$data","concat","JSON","stringify","extendedProps","enableRowActions","isEditing","rowActions","_","rowId","table","EditingActionMenu","hasChanges","hasErrors","hasRowErrors","onDiscard","discardChanges","saveChanges","then","e","Promise","reject","isLastRow","meta","rowActive","rowActiveIndex","options","virtualiserPaddingEndOffset","hasTemporaryRowErrors","useTable","useTableEditingListener","instance","renderer","scrollToIndex","useEffect","current","toggleEditing","enabled"],"mappings":";;;;;;;;MAYaA,SAAS,GAAG;EACrBC,GAAG,EAAEC,GAAG;EACRC,IAAI,EAAEC;;SAaMC,SAASA,CAAQC,KAAyB,EAAEC,GAAyB;EACjF,MAAMC,OAAO,GAAGC,eAAe,CAC3BH,KAAK,CAACI,aAAa,EACnBJ,KAAK,C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AAe,IAAIkB,KAAK,CAACa,IAAI,CAACC,SAAS,CAACC,cAAc,KAAKf,KAAK,CAACa,IAAI,CAACxB,MAAM,GAAG;MAC7F,CACL,CACgC,GACrChB,KAAK,CAACwB;GACf;EACD,MAAMgB,IAAI,GAAG;IAAEtC;GAAS;EAExB,MAAMyC,OAAO,GAA0B;IACnCC,2BAA2B,EACvB5C,KAAK,CAACI,aAAa,IAAIJ,KAAK,CAACW,eAAe,GAAIT,OAAO,CAAC2C,qBAAqB,EAAE,GAAG,GAAG,GAAG,CAAC,GAAI;GACpG;EAED,MAAMlB,KAAK,GAAGmB,QAAQ,CAAoBzB,aAAa,EAAEpB,GAAG,EAAEP,SAAS,EAAE8C,IAAI,EAAEG,OAAO,CAAC;;EAGvFI,uBAAuB,CAAQpB,KAAK,CAACqB,QAAQ,EAAErB,KAAK,CAAC1B,GAAG,EAAE0B,KAAK,CAACsB,QAAQ,CAACC,aAAa,CAAC;EAEvFrC,cAAK,CAACsC,SAAS,CAAC;IACZ,IAAIxB,KAAK,CAAC1B,GAAG,CAACmD,OAAO,EAAE;MAClBzB,KAAK,CAAC1B,GAAG,CAACmD,OAAqB,CAACJ,QAAQ,CAACK,aAAa,GAAIC,OAA4B,IACnF3B,KAAK,CAACa,IAAI,CAACtC,OAAO,CAACmD,aAAa,CAACC,OAAO,aAAPA,OAAO,cAAPA,OAAO,GAAKpD,OAAO,IAAI,CAACA,OAAO,EAAGyB,KAAK,CAACqB,QAAQ,EAAErB,KAAK,CAACsB,QAAQ,CAACC,aAAa,CAAC;;GAE3H,EAAE,CAACvB,KAAK,CAAC1B,GAAG,CAACmD,OAAO,CAAC,CAAC;EAEvB,OAAOzB,KAAK;AAChB;;;;"}
1
+ {"version":3,"file":"useTable3.js","sources":["../../../../../../../src/components/Table3/useTable3.tsx"],"sourcesContent":["import React from 'react';\nimport { RowData, Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { useTable } from '../../primitives/Table/Core/useTable';\nimport { useTableEditingListener } from './listeners/useTableEditingListener';\nimport { useTableEditing } from './features/useTableEditing';\nimport { Table3Props, Table3Ref } from './types';\nimport { TableRowActionRenderer } from '../../primitives/Table/types';\nimport { Cell } from './components/Columns/Cell/Cell';\nimport { EditingActionMenu } from './components/Columns/Internal/EditingActionsMenu';\nimport { Row } from './components/Row/Row';\nimport { useTableRenderOptions } from '../../primitives/Table/Core/types';\n\nexport const RENDERERS = {\n row: Row,\n cell: Cell,\n};\n\ndeclare module '@tanstack/table-core' {\n interface TableMeta<TData extends RowData> {\n editing: ReturnType<typeof useTableEditing>;\n }\n}\n\ntype Table3Meta = {\n editing: ReturnType<typeof useTableEditing>;\n};\n\nexport function useTable3<TType>(props: Table3Props<TType>, ref: React.Ref<Table3Ref>) {\n const editing = useTableEditing(\n props.enableEditing,\n props.onEditingSave,\n props.onEditingChange,\n props.rowIdentityAccessor,\n props.validator\n );\n const creationEnabled = editing.isEnabled && !!props.onEditingCreate;\n\n // this gives me the performance heeby jeebies, but can't think of a better way to internalise the state\n const data: TType[] = React.useMemo(() => {\n if (editing.temporaryRows.length) {\n return (props.data ?? []).concat(editing.temporaryRows as TType[]);\n }\n\n return props.data;\n }, [JSON.stringify(props.data), editing.temporaryRows.length]);\n\n const extendedProps: Table3Props<TType> = {\n ...props,\n data,\n enableRowActions: editing.isEditing ? true : props.enableRowActions,\n // Display EditingActionMenu instead of row actions while editing\n rowActions: editing.isEditing\n ? ([\n (_, rowId, table: ReactTable<TType>) => {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n return (\n <EditingActionMenu\n hasChanges={editing.hasChanges(rowId)}\n hasErrors={editing.hasRowErrors(rowId)}\n onDiscard={() => editing.discardChanges(rowId, table)}\n onEditingSave={async () => {\n await editing.saveChanges(table, rowId);\n }}\n isLastRow={!creationEnabled && tableMeta.rowActive.rowActiveIndex === tableMeta.length - 1}\n />\n );\n },\n ] as TableRowActionRenderer<TType>[])\n : props.rowActions,\n };\n const meta = { editing };\n\n const options: useTableRenderOptions = {\n virtualiserPaddingEndOffset:\n props.enableEditing && props.onEditingCreate ? (editing.hasTemporaryRowErrors() ? 1.4 : 1) : 0,\n };\n\n const table = useTable<TType, Table3Meta>(extendedProps, ref, RENDERERS, meta, options);\n\n // listeners\n useTableEditingListener<TType>(table.instance, table.ref, table.renderer.scrollToIndex);\n\n React.useEffect(() => {\n if (table.ref.current) {\n (table.ref.current as Table3Ref).instance.toggleEditing = (enabled: boolean | undefined) =>\n table.meta.editing.toggleEditing(enabled ?? (editing => !editing), table.instance, table.renderer.scrollToIndex);\n }\n }, [table.ref.current]);\n\n return table;\n}\n"],"names":["RENDERERS","row","Row","cell","Cell","useTable3","props","ref","editing","useTableEditing","enableEditing","onEditingSave","onEditingChange","rowIdentityAccessor","validator","creationEnabled","isEnabled","onEditingCreate","data","React","useMemo","temporaryRows","length","_props$data","concat","JSON","stringify","extendedProps","enableRowActions","isEditing","rowActions","_","rowId","table","tableMeta","options","meta","EditingActionMenu","hasChanges","hasErrors","hasRowErrors","onDiscard","discardChanges","saveChanges","then","e","Promise","reject","isLastRow","rowActive","rowActiveIndex","virtualiserPaddingEndOffset","hasTemporaryRowErrors","useTable","useTableEditingListener","instance","renderer","scrollToIndex","useEffect","current","toggleEditing","enabled"],"mappings":";;;;;;;;MAYaA,SAAS,GAAG;EACrBC,GAAG,EAAEC,GAAG;EACRC,IAAI,EAAEC;;SAaMC,SAASA,CAAQC,KAAyB,EAAEC,GAAyB;EACjF,MAAMC,OAAO,GAAGC,eAAe,CAC3BH,KAAK,CAACI,aAAa,EACnBJ,KAAK,CAACK,aAAa,EACnBL,KAAK,CAACM,eAAe,EACrBN,KAAK,CAACO,mBAAmB,EACzBP,KAAK,CAACQ,SAAS,CAClB;EACD,MAAMC,eAAe,GAAGP,OAAO,CAACQ,SAAS,IAAI,CAAC,CAACV,KAAK,CAACW,eAAe;;EAGpE,MAAMC,IAAI,GAAYC,cAAK,CAACC,OAAO,CAAC;IAChC,IAAIZ,OAAO,CAACa,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gB,2BAA2B,EACvB7C,KAAK,CAACI,aAAa,IAAIJ,KAAK,CAACW,eAAe,GAAIT,OAAO,CAAC4C,qBAAqB,EAAE,GAAG,GAAG,GAAG,CAAC,GAAI;GACpG;EAED,MAAMnB,KAAK,GAAGoB,QAAQ,CAAoB1B,aAAa,EAAEpB,GAAG,EAAEP,SAAS,EAAEoC,IAAI,EAAED,OAAO,CAAC;;EAGvFmB,uBAAuB,CAAQrB,KAAK,CAACsB,QAAQ,EAAEtB,KAAK,CAAC1B,GAAG,EAAE0B,KAAK,CAACuB,QAAQ,CAACC,aAAa,CAAC;EAEvFtC,cAAK,CAACuC,SAAS,CAAC;IACZ,IAAIzB,KAAK,CAAC1B,GAAG,CAACoD,OAAO,EAAE;MAClB1B,KAAK,CAAC1B,GAAG,CAACoD,OAAqB,CAACJ,QAAQ,CAACK,aAAa,GAAIC,OAA4B,IACnF5B,KAAK,CAACG,IAAI,CAAC5B,OAAO,CAACoD,aAAa,CAACC,OAAO,aAAPA,OAAO,cAAPA,OAAO,GAAKrD,OAAO,IAAI,CAACA,OAAO,EAAGyB,KAAK,CAACsB,QAAQ,EAAEtB,KAAK,CAACuB,QAAQ,CAACC,aAAa,CAAC;;GAE3H,EAAE,CAACxB,KAAK,CAAC1B,GAAG,CAACoD,OAAO,CAAC,CAAC;EAEvB,OAAO1B,KAAK;AAChB;;;;"}
package/dist/index.css CHANGED
@@ -1361,3 +1361,10 @@ table[data-taco^='table'] tr[data-row-id^='temp-'] [data-row-move-indicator] {
1361
1361
  table[data-taco^='table'] tr:not([data-row-id^='temp-']) [data-row-move-indicator] {
1362
1362
  @apply top-full rounded-b-md;
1363
1363
  }
1364
+
1365
+ table[data-taco^='table'][data-table-row-height='short'] tr[data-row-create] td,
1366
+ table[data-taco^='table'][data-table-row-height='medium'] tr[data-row-create] td,
1367
+ table[data-taco^='table'][data-table-row-height='tall'] tr[data-row-create] td,
1368
+ table[data-taco^='table'][data-table-row-height='extra-tall'] tr[data-row-create] td {
1369
+ @apply !min-h-[41px] !pt-[10px];
1370
+ }
@@ -19764,19 +19764,22 @@ function useTable3(props, ref) {
19764
19764
  data,
19765
19765
  enableRowActions: editing.isEditing ? true : props.enableRowActions,
19766
19766
  // Display EditingActionMenu instead of row actions while editing
19767
- rowActions: editing.isEditing ? [(_, rowId, table) => (/*#__PURE__*/React__default.createElement(EditingActionMenu, {
19768
- hasChanges: editing.hasChanges(rowId),
19769
- hasErrors: editing.hasRowErrors(rowId),
19770
- onDiscard: () => editing.discardChanges(rowId, table),
19771
- onEditingSave: function () {
19772
- try {
19773
- return Promise.resolve(editing.saveChanges(table, rowId)).then(function () {});
19774
- } catch (e) {
19775
- return Promise.reject(e);
19776
- }
19777
- },
19778
- isLastRow: !creationEnabled && table.meta.rowActive.rowActiveIndex === table.meta.length - 1
19779
- }))] : props.rowActions
19767
+ rowActions: editing.isEditing ? [(_, rowId, table) => {
19768
+ const tableMeta = table.options.meta;
19769
+ return /*#__PURE__*/React__default.createElement(EditingActionMenu, {
19770
+ hasChanges: editing.hasChanges(rowId),
19771
+ hasErrors: editing.hasRowErrors(rowId),
19772
+ onDiscard: () => editing.discardChanges(rowId, table),
19773
+ onEditingSave: function () {
19774
+ try {
19775
+ return Promise.resolve(editing.saveChanges(table, rowId)).then(function () {});
19776
+ } catch (e) {
19777
+ return Promise.reject(e);
19778
+ }
19779
+ },
19780
+ isLastRow: !creationEnabled && tableMeta.rowActive.rowActiveIndex === tableMeta.length - 1
19781
+ });
19782
+ }] : props.rowActions
19780
19783
  };
19781
19784
  const meta = {
19782
19785
  editing