diff --git a/packages/bbui/package.json b/packages/bbui/package.json index 7d34c5c6d7..67277ac2f0 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -43,6 +43,14 @@ "dist" ], "dependencies": { + "@spectrum-css/actionbutton": "^1.0.1", + "@spectrum-css/button": "^3.0.1", + "@spectrum-css/checkbox": "^3.0.1", + "@spectrum-css/icon": "^3.0.1", + "@spectrum-css/label": "^2.0.9", + "@spectrum-css/table": "^3.0.1", + "@spectrum-css/vars": "^3.0.1", + "dayjs": "^1.10.4", "markdown-it": "^12.0.4", "quill": "^1.3.7", "sirv-cli": "^0.4.6", diff --git a/packages/bbui/src/Table/AttachmentRenderer.svelte b/packages/bbui/src/Table/AttachmentRenderer.svelte new file mode 100644 index 0000000000..45bd97a849 --- /dev/null +++ b/packages/bbui/src/Table/AttachmentRenderer.svelte @@ -0,0 +1,39 @@ + + +{#each attachments as attachment} + {#if attachment.type.startsWith('image')} + {attachment.extension} + {:else} +
{attachment.extension}
+ {/if} +{/each} +{#if leftover} +
+{leftover} more
+{/if} + + diff --git a/packages/bbui/src/Table/BooleanRenderer.svelte b/packages/bbui/src/Table/BooleanRenderer.svelte new file mode 100644 index 0000000000..a71e28cb91 --- /dev/null +++ b/packages/bbui/src/Table/BooleanRenderer.svelte @@ -0,0 +1,38 @@ + + + + + diff --git a/packages/bbui/src/Table/CellRenderer.svelte b/packages/bbui/src/Table/CellRenderer.svelte new file mode 100644 index 0000000000..0c14ec2aa5 --- /dev/null +++ b/packages/bbui/src/Table/CellRenderer.svelte @@ -0,0 +1,27 @@ + + +{#if value != null && value !== ''} + {#if plainTypes.includes(type)} + + {:else if type === 'boolean'} + + {:else if type === 'datetime'} + + {:else if type === 'link'} + + {:else if type === 'attachment'} + + {/if} +{/if} diff --git a/packages/bbui/src/Table/DateTimeRenderer.svelte b/packages/bbui/src/Table/DateTimeRenderer.svelte new file mode 100644 index 0000000000..169adab163 --- /dev/null +++ b/packages/bbui/src/Table/DateTimeRenderer.svelte @@ -0,0 +1,13 @@ + + +
{dayjs(value).format('MMMM D YYYY, HH:mm')}
+ + diff --git a/packages/bbui/src/Table/RelationshipRenderer.svelte b/packages/bbui/src/Table/RelationshipRenderer.svelte new file mode 100644 index 0000000000..6c04000fa7 --- /dev/null +++ b/packages/bbui/src/Table/RelationshipRenderer.svelte @@ -0,0 +1,20 @@ + + +{#each relationships as relationship} + {#if relationship?.primaryDisplay} + + {relationship.primaryDisplay} + + {/if} +{/each} +{#if leftover} +
+{leftover} more
+{/if} diff --git a/packages/bbui/src/Table/SelectEditRenderer.svelte b/packages/bbui/src/Table/SelectEditRenderer.svelte new file mode 100644 index 0000000000..89a97f3866 --- /dev/null +++ b/packages/bbui/src/Table/SelectEditRenderer.svelte @@ -0,0 +1,48 @@ + + +{#if allowSelectRows} + +{/if} +{#if allowEditRows} + +{/if} + + diff --git a/packages/bbui/src/Table/StringRenderer.svelte b/packages/bbui/src/Table/StringRenderer.svelte new file mode 100644 index 0000000000..2756839616 --- /dev/null +++ b/packages/bbui/src/Table/StringRenderer.svelte @@ -0,0 +1,13 @@ + + +
{value}
+ + diff --git a/packages/bbui/src/Table/Table.svelte b/packages/bbui/src/Table/Table.svelte new file mode 100644 index 0000000000..475c1e2a09 --- /dev/null +++ b/packages/bbui/src/Table/Table.svelte @@ -0,0 +1,356 @@ + + +{#if !loaded} +
+{:else} +
+
+ + + + {#if customColumnRenderer} + + {/if} + {#each fields as field} + + {/each} + + + + {#each sortedRows as row, idx} + toggleSelectRow(row)} + class="spectrum-Table-row" + class:hidden={idx < firstVisibleRow || idx > lastVisibleRow}> + {#if idx >= firstVisibleRow && idx <= lastVisibleRow} + {#if customColumnRenderer} + + {/if} + {#each fields as field} + + {/each} + {/if} + + {/each} + +
+
+ {customColumnTitle || ''} +
+
sortBy(field)}> +
+
+ {schema[field]?.displayName || schema[field]?.name} +
+ {#if schema[field]?.autocolumn} + + + + {/if} + {#if sortColumn === field} + + {/if} + {#if allowEditColumns} + editColumn(e, field)}> + + + {/if} +
+
+
+ toggleSelectRow(row)} + onEdit={e => editRow(e, row)} + {allowSelectRows} + {allowEditRows} /> +
+
+
+ +
+
+
+
+{/if} + + diff --git a/packages/bbui/src/Table/index.js b/packages/bbui/src/Table/index.js new file mode 100644 index 0000000000..16b81c6eb6 --- /dev/null +++ b/packages/bbui/src/Table/index.js @@ -0,0 +1 @@ +export { default as Table } from "./Table.svelte" diff --git a/packages/bbui/src/index.js b/packages/bbui/src/index.js index 1a156697c9..d21260ecf8 100644 --- a/packages/bbui/src/index.js +++ b/packages/bbui/src/index.js @@ -30,6 +30,7 @@ export { default as DatePicker } from "./DatePicker/DatePicker.svelte" export { default as Multiselect } from "./Form/Multiselect.svelte" export { default as Slider } from "./Form/Slider.svelte" export { default as Context } from "./context" +export { default as Table } from "./Table/Table.svelte" // Actions export { default as autoResizeTextArea } from "./Actions/autoresize_textarea" diff --git a/packages/bbui/yarn.lock b/packages/bbui/yarn.lock index e444c1fb18..6b2a232b14 100644 --- a/packages/bbui/yarn.lock +++ b/packages/bbui/yarn.lock @@ -410,6 +410,41 @@ lodash "^4.17.4" read-pkg-up "^7.0.0" +"@spectrum-css/actionbutton@^1.0.1": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@spectrum-css/actionbutton/-/actionbutton-1.0.1.tgz#9c75da37ea6915919fb574c74bd60dacc03b6577" + integrity sha512-AUqtyNabHF451Aj9i3xz82TxS5Z6k1dttA68/1hMeU9kbPCSS4P6Viw3vaRGs9CSspuR8xnnhDgrq+F+zMy2Hw== + +"@spectrum-css/button@^3.0.1": + version "3.0.1" + resolved "https://registry.yarnpkg.com/@spectrum-css/button/-/button-3.0.1.tgz#6db8c3e851baecd0f1c2d88fef37d49d01c6e643" + integrity sha512-YXrBtjIYisk4Vaxnp0RiE4gdElQX04P2mc4Pi2GlQ27dJKlHmufYcF+kAqGdtiyK5yjdN/vKRcC8y13aA4rusA== + +"@spectrum-css/checkbox@^3.0.1": + version "3.0.1" + resolved "https://registry.yarnpkg.com/@spectrum-css/checkbox/-/checkbox-3.0.1.tgz#6f36377d8bd556989ddd1dec2506dc295c5fcda8" + integrity sha512-fI0q2Cp6yU4ORyE6JWUSMYNgEtGf6AjYViZ2Weg3UPTYBQuWdQd8J0ZTcH38pDMyARFPRdiXgQ3KnyX5Hk5huw== + +"@spectrum-css/icon@^3.0.1": + version "3.0.1" + resolved "https://registry.yarnpkg.com/@spectrum-css/icon/-/icon-3.0.1.tgz#e300a6fc353c85c6b5d6e7a364408a940c31b177" + integrity sha512-cGFtIrcQ/7tthdkHK1npuEFiCdYVHLqwmLxghUYQw8Tb8KgJaw3OBO1tpjgsUizexNgu26BjVRIbGxNWuBXIHQ== + +"@spectrum-css/label@^2.0.9": + version "2.0.9" + resolved "https://registry.yarnpkg.com/@spectrum-css/label/-/label-2.0.9.tgz#792f34b906ba81118f4d0edcc81a18da1ecd57cb" + integrity sha512-0vXhWIZoQDTg+I6MyMpwmeJ+yQHtxkZ7lLcEqxhJ2y7JXP2ftblz2sO4+9jB11ljepeVlV+B6LF1drU8mMu82A== + +"@spectrum-css/table@^3.0.1": + version "3.0.1" + resolved "https://registry.yarnpkg.com/@spectrum-css/table/-/table-3.0.1.tgz#753e0e2498082c0c36b9600828516aff3ac338cd" + integrity sha512-XQ+srMTv9hK1H0nctWUtqyzitmvyb5TNR+7mjAmKRdkBRSTQQSipDhenxZp72ekzMtMoSYZVZ77kgo0Iw3Fpug== + +"@spectrum-css/vars@^3.0.1": + version "3.0.1" + resolved "https://registry.yarnpkg.com/@spectrum-css/vars/-/vars-3.0.1.tgz#561fd69098f896a647242dd8d6108af603bfa31e" + integrity sha512-l4oRcCOqInChYXZN6OQhpe3isk6l4OE6Ys8cgdlsiKp53suNoQxyyd9p/eGRbCjZgH3xQ8nK0t4DHa7QYC0S6w== + "@sveltejs/vite-plugin-svelte@^1.0.0-next.5": version "1.0.0-next.5" resolved "https://registry.yarnpkg.com/@sveltejs/vite-plugin-svelte/-/vite-plugin-svelte-1.0.0-next.5.tgz#8cf608f7a3c33dfa5b648397aae1ba90e6a4883f" @@ -1638,6 +1673,11 @@ dateformat@^3.0.0: resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-3.0.3.tgz#a6e37499a4d9a9cf85ef5872044d62901c9889ae" integrity sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q== +dayjs@^1.10.4: + version "1.10.4" + resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.10.4.tgz#8e544a9b8683f61783f570980a8a80eaf54ab1e2" + integrity sha512-RI/Hh4kqRc1UKLOAf/T5zdMMX5DQIlDxwUe3wSyMMnEbGunnpENCdbUgM+dW7kXidZqCttBrmw7BhN4TMddkCw== + debug@2.6.9: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" diff --git a/packages/builder/src/components/backend/DataTable/Table.svelte b/packages/builder/src/components/backend/DataTable/Table.svelte index 059fe1e123..fa15f3f886 100644 --- a/packages/builder/src/components/backend/DataTable/Table.svelte +++ b/packages/builder/src/components/backend/DataTable/Table.svelte @@ -1,19 +1,15 @@
@@ -163,17 +92,24 @@ {/if}
-
- {#key columnDefs.length} - (selectedRows = detail)} /> - {/key} -
+{#key tableId} + editColumn(e.detail)} + on:editrow={e => editRow(e.detail)} /> +{/key} + + + + + + +