├── .gitattributes
├── .github
├── FUNDING.yml
├── actions
│ └── rust_toolchain
│ │ └── action.yml
├── dependabot.yml
└── workflows
│ ├── cd.yml
│ ├── ci.yml
│ └── tests.yml
├── .gitignore
├── .idea
├── .gitignore
├── dataSources.xml
├── leptos-struct-table.iml
├── modules.xml
└── vcs.xml
├── CHANGELOG.md
├── Cargo.toml
├── LICENSE-APACHE
├── LICENSE-MIT
├── README.md
├── examples
├── bootstrap
│ ├── Cargo.toml
│ ├── README.md
│ ├── index.html
│ ├── src
│ │ └── main.rs
│ └── style.css
├── custom_renderers_svg
│ ├── Cargo.toml
│ ├── README.md
│ ├── index.html
│ └── src
│ │ ├── main.rs
│ │ └── renderers.rs
├── custom_row_renderer
│ ├── Cargo.toml
│ ├── README.md
│ ├── index.html
│ └── src
│ │ └── main.rs
├── custom_type
│ ├── Cargo.toml
│ ├── README.md
│ ├── index.html
│ └── src
│ │ └── main.rs
├── editable
│ ├── Cargo.toml
│ ├── README.md
│ ├── index.html
│ ├── input.css
│ ├── src
│ │ ├── main.rs
│ │ ├── renderer.rs
│ │ └── tailwind.rs
│ ├── style
│ │ └── output.css
│ └── tailwind.config.js
├── generic
│ ├── Cargo.toml
│ ├── README.md
│ ├── index.html
│ └── src
│ │ └── main.rs
├── getter
│ ├── Cargo.toml
│ ├── README.md
│ ├── index.html
│ └── src
│ │ └── main.rs
├── i18n
│ ├── Cargo.toml
│ ├── README.md
│ ├── index.html
│ ├── locales
│ │ ├── de.json
│ │ └── en.json
│ └── src
│ │ └── main.rs
├── paginated_rest_datasource
│ ├── Cargo.toml
│ ├── README.md
│ ├── index.html
│ ├── src
│ │ ├── data_provider.rs
│ │ ├── main.rs
│ │ ├── models.rs
│ │ └── renderer.rs
│ └── style.css
├── pagination
│ ├── Cargo.toml
│ ├── README.md
│ ├── index.html
│ ├── input.css
│ ├── src
│ │ ├── data_provider.rs
│ │ ├── main.rs
│ │ ├── models.rs
│ │ └── tailwind.rs
│ ├── style
│ │ └── output.css
│ └── tailwind.config.js
├── selectable
│ ├── Cargo.toml
│ ├── README.md
│ ├── index.html
│ ├── input.css
│ ├── src
│ │ ├── main.rs
│ │ └── tailwind.rs
│ ├── style
│ │ └── output.css
│ └── tailwind.config.js
├── serverfn_sqlx
│ ├── .gitignore
│ ├── Cargo.toml
│ ├── README.md
│ ├── db.sqlite3
│ ├── input.css
│ ├── public
│ │ └── favicon.ico
│ ├── src
│ │ ├── app.rs
│ │ ├── classes.rs
│ │ ├── data_provider.rs
│ │ ├── database.rs
│ │ ├── handlers.rs
│ │ ├── lib.rs
│ │ └── main.rs
│ ├── style
│ │ └── output.css
│ └── tailwind.config.js
├── simple
│ ├── Cargo.toml
│ ├── README.md
│ ├── index.html
│ └── src
│ │ └── main.rs
└── tailwind
│ ├── Cargo.toml
│ ├── README.md
│ ├── index.html
│ ├── input.css
│ ├── src
│ ├── main.rs
│ └── tailwind.rs
│ ├── style
│ └── output.css
│ └── tailwind.config.js
├── hero.afdesign
├── hero.webp
└── src
├── cell_value.rs
├── chrono.rs
├── class_providers
├── bootstrap.rs
├── mod.rs
└── tailwind.rs
├── components
├── cell.rs
├── mod.rs
├── renderer_fn.rs
├── row.rs
├── table_content.rs
├── tbody.rs
└── thead.rs
├── data_provider.rs
├── display_strategy.rs
├── events.rs
├── lib.rs
├── loaded_rows.rs
├── reload_controller.rs
├── row_reader.rs
├── rust_decimal.rs
├── selection.rs
├── sorting.rs
├── table_row.rs
├── time.rs
└── uuid.rs
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.sqlite3 filter=lfs diff=lfs merge=lfs -text
2 | *.sqlite3-wal filter=lfs diff=lfs merge=lfs -text
3 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: [Synphonyte]# Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4 | patreon: # Replace with a single Patreon username
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: # Replace with a single Ko-fi username
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: # Replace with a single Liberapay username
10 | issuehunt: # Replace with a single IssueHunt username
11 | otechie: # Replace with a single Otechie username
12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
13 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
14 |
--------------------------------------------------------------------------------
/.github/actions/rust_toolchain/action.yml:
--------------------------------------------------------------------------------
1 | name: Rust Toolchain
2 |
3 | runs:
4 | using: "composite"
5 | steps:
6 | - uses: actions-rs/toolchain@v1
7 | with:
8 | toolchain: stable
9 | profile: minimal
10 | override: true
11 | components: rustfmt
12 |
13 | - name: Cache
14 | uses: Swatinem/rust-cache@v2
15 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: cargo
4 | directory: /
5 | schedule:
6 | interval: daily
7 | - package-ecosystem: github-actions
8 | directory: /
9 | schedule:
10 | interval: weekly
--------------------------------------------------------------------------------
/.github/workflows/cd.yml:
--------------------------------------------------------------------------------
1 | name: CD
2 |
3 | on:
4 | push:
5 | # Pattern matched against refs/tags
6 | tags:
7 | - '*' # Push events to every tag not containing /
8 | workflow_dispatch:
9 |
10 | jobs:
11 | cargo_checks:
12 | name: Cargo Checks
13 | runs-on: ubuntu-latest
14 | steps:
15 | - uses: actions/checkout@v4
16 | - uses: ./.github/actions/rust_toolchain/
17 | - name: Check formatting
18 | run: cargo fmt --check
19 | - name: Clippy
20 | run: cargo clippy --tests -- -D warnings
21 | - name: Check if the README is up to date.
22 | run: |
23 | cargo install cargo-rdme
24 | cargo rdme --check
25 | - name: Run tests
26 | run: cargo test --features chrono,uuid,rust_decimal,time
27 |
28 | test_examples:
29 | name: Test Examples
30 | runs-on: ubuntu-latest
31 | strategy:
32 | fail-fast: false
33 | matrix:
34 | example:
35 | - bootstrap
36 | - custom_renderers_svg
37 | - custom_row_renderer
38 | - editable
39 | - generic
40 | - getter
41 | - i18n
42 | - paginated_rest_datasource
43 | - pagination
44 | - selectable
45 | - serverfn_sqlx
46 | - simple
47 | - tailwind
48 | steps:
49 | - uses: actions/checkout@v4
50 | - uses: ./.github/actions/rust_toolchain/
51 | - name: Build example ${{ matrix.example }}
52 | run: |
53 | cd ${{ github.workspace }}/examples/${{ matrix.example }}/
54 | cargo build
55 | shell: bash
56 |
57 | publish:
58 | name: Publish
59 | runs-on: ubuntu-latest
60 | needs: [ cargo_checks, test_examples ]
61 | steps:
62 | - uses: actions/checkout@v4
63 | - uses: ./.github/actions/rust_toolchain/
64 | - name: Publish crate leptos-struct-table
65 | uses: katyo/publish-crates@v2
66 | with:
67 | registry-token: ${{ secrets.CRATES_TOKEN }}
68 |
69 | - uses: CSchoel/release-notes-from-changelog@v1
70 | - name: Create Release using GitHub CLI
71 | env:
72 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73 | run: >
74 | gh release create
75 | -d
76 | -F RELEASE.md
77 | -t "Version $RELEASE_VERSION"
78 | ${GITHUB_REF#refs/*/}
79 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: Continuous Integration
2 |
3 | on:
4 | pull_request:
5 | branches:
6 | - main
7 | paths:
8 | - "**"
9 | - "!/*.md"
10 | - "!/**.md"
11 |
12 | concurrency:
13 | group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
14 | cancel-in-progress: true
15 |
16 | jobs:
17 | integrity:
18 | name: Integrity Checks on Rust ${{ matrix.toolchain }}
19 | runs-on: ubuntu-latest
20 | timeout-minutes: 15
21 | strategy:
22 | matrix:
23 | toolchain:
24 | - stable
25 | - nightly
26 |
27 | steps:
28 | - name: Checkout
29 | uses: actions/checkout@v4
30 |
31 | - name: Setup Rust
32 | uses: dtolnay/rust-toolchain@master
33 | with:
34 | toolchain: ${{ matrix.toolchain }}
35 | targets: wasm32-unknown-unknown
36 | components: clippy, rustfmt
37 |
38 | - name: Setup Rust Cache
39 | uses: Swatinem/rust-cache@v2
40 |
41 | - name: Build
42 | run: cargo build
43 |
44 | - name: Format
45 | run: cargo fmt --check
46 |
47 | - name: Clippy
48 | run: cargo clippy -- -D warnings
49 |
--------------------------------------------------------------------------------
/.github/workflows/tests.yml:
--------------------------------------------------------------------------------
1 | on:
2 | pull_request:
3 | branches:
4 | - main
5 | paths:
6 | - "**"
7 | - "!/*.md"
8 | - "!/**.md"
9 | workflow_dispatch:
10 |
11 | name: Tests
12 |
13 | permissions: write-all
14 |
15 | jobs:
16 | tests:
17 | name: Tests
18 | runs-on: ubuntu-latest
19 | steps:
20 | - uses: actions/checkout@v4
21 | - uses: actions-rs/toolchain@v1
22 | with:
23 | toolchain: nightly
24 | profile: minimal
25 | override: true
26 | components: rustfmt, clippy, rust-src
27 | - name: Cache
28 | uses: Swatinem/rust-cache@v2
29 |
30 | - name: Run tests (general)
31 | run: cargo test --features chrono,uuid,rust_decimal,time
32 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | target
2 | dist
3 | Cargo.lock
4 | node_modules
5 | package*.json
6 | .DS_Store
7 | *.sqlite3-wal
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Editor-based HTTP Client requests
5 | /httpRequests/
6 | # Datasource local storage ignored files
7 | /dataSources/
8 | /dataSources.local.xml
9 |
--------------------------------------------------------------------------------
/.idea/dataSources.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | sqlite.xerial
6 | true
7 | org.sqlite.JDBC
8 | jdbc:sqlite:$PROJECT_DIR$/examples/serverfn_sqlx/db.sqlite3
9 | $ProjectFileDir$
10 |
11 |
12 | file://$APPLICATION_CONFIG_DIR$/jdbc-drivers/Xerial SQLiteJDBC/3.40.1/org/xerial/sqlite-jdbc/3.40.1.0/sqlite-jdbc-3.40.1.0.jar
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/.idea/leptos-struct-table.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## [0.14.0-beta3] - 2025-03-17
4 |
5 | ### Fix 🐛
6 |
7 | - Fixed keeping track of the query params so the frontend doesn't crash (thanks to @holg).
8 |
9 | ### Changes 🔥
10 |
11 | - Made compatibility table much more prominent (thanks to @cramhead).
12 | - Adapted to allow --cfg erase_components usage (thanks to @Zagitta).
13 |
14 | ### Special thanks to our sponsor
15 | - @spencewenski
16 |
17 |
18 | ## [0.14.0-beta2] - 2025-01-05
19 |
20 | ### Breaking Changes 🛠️
21 |
22 | - row and cell renderers now take a `RwSignal` which also makes it possible to edit the data much more easily.
23 |
24 | ### Fix 🐛
25 |
26 | - Fixed broken API in examples `paginated_rest_datasource` and `pagination`
27 |
28 | ### Special thanks to our sponsor
29 | - @spencewenski
30 |
31 | ## [0.14.0-beta1] - 2025-01-03
32 |
33 | ### Breaking Changes 🛠️
34 |
35 | - Updated dependencies leptos-use to version 0.15 and leptos 0.7
36 | - The prop `scroll_container` of `` is now required. If you don't care about scrolling you can use `scroll_container="html"`.
37 | - Some smaller stuff that the compiler should tell you about. Please also refer to the updated examples.
38 |
39 | ### Known Issues
40 |
41 | - The virtualized scrolling is not perfectly smooth yet.
42 | - Editing doesn't work quite yet.
43 | - The examples `paginated_rest_datasource` and `pagination` are not working yet because the previously used external REST API changed.
44 |
45 | ### Thanks to contributor
46 |
47 | Thanks to @kstep for his many contributions to this release.
48 |
49 | ### Special thanks to our sponsor
50 | - @spencewenski
51 |
52 | ## [0.13.1] - 2024-10-31
53 |
54 | ### Fixes 🐛
55 |
56 | - Fixed edge case loading data ranges that are smaller than the chunk size (thanks to @mcbernie).
57 |
58 | ## [0.13.0] - 2024-09-05
59 |
60 | ### Breaking Change 🛠️
61 |
62 | - Updated dependency leptos-use to version 0.13 which fixes some unsatisfied trait bounds.
63 |
64 | ## [0.12.1] - 2024-09-01
65 |
66 | ### Features 🚀
67 |
68 | - Added support for generics in struct field types (thanks to @frnsys)
69 | - Added macro options for much more flexibility with leptos-i18n (thanks to @Baptistemontan)
70 | - Added hint to readmes of examples how to run them (thanks to @luckynumberke7in)
71 |
72 | ## [0.12.0] - 2024-08-14
73 |
74 | ### Breaking Change 🛠️
75 |
76 | - Updated dependency leptos-use to version 0.12 which supports web-sys 0.3.70 which introduced breaking changes. (thanks
77 | to @frnsys)
78 |
79 | ## [0.11.0] - 2024-08-05
80 |
81 | ### Features 🚀
82 |
83 | - Changed leptos-use to version 0.11
84 | - Added i18n support via the `"i18n"` feature which uses `leptos-i18n`. See the `i18n` example for usage.
85 | - Added row reader to `TableComponent`
86 | - Added `default_th_sorting_style` to make it easier to write a custom thead cell render component.
87 |
88 | ## [0.10.2] - 2024-06-07
89 |
90 | ### Fixes 🐛
91 |
92 | - Fixed race condition with loading row count and sorting update.
93 | - Fixed console errors/warnings for signals accessed in async blocks after component was disposed of.
94 |
95 | ## [0.10.1] - 2024-06-05
96 |
97 | ### Change 🔥
98 |
99 | - `CellValue` is now implemented for `leptos::View`. This makes `FieldGetter...` to produce valid HTML. This fixes SSR rendering issues.
154 |
155 | ### Other Changes
156 |
157 | - Added an example for how to use server functions and sqlx together with this crate.
158 |
159 | ## [0.8.3] - 2024-02-20
160 |
161 | ### Fix 🐛
162 |
163 | - When not limiting a scroll container this could lead to a runaway row loading. This is now limited to max 500 rows.
164 |
165 | ## [0.8.2] - 2024-02-18
166 |
167 | ### Feature 🚀
168 |
169 | - Added method `TableDataProvider::track` to easily specify reactive dependencies of data loading
170 |
171 | ## [0.8.1] - 2024-02-17
172 |
173 | ### Fix 🐛
174 |
175 | - Removed debug log
176 |
177 | ## [0.8.0] - 2024-02-17
178 |
179 | ### Feature 🚀
180 |
181 | - Added `loading_row_display_limit` prop to `TableContent` to make it possible to load smaller row counts nicely
182 |
183 | ### Breaking Changes 🛠️
184 |
185 | - Added `row_index` and `col_index` to `TableClassesProvider::loading_cell`
186 | - Added `col_index` to `TableClassesProvider::loading_cell_inner`
187 | - Changed the type of prop `loading_row_renderer` of the component `TableContent`
188 |
189 | ### Fix 🐛
190 |
191 | - Data loading for small data sets
192 |
193 | ## [0.7.1] - 2024-02-14
194 |
195 | ### Changes
196 |
197 | - Added generic error type to `TableDataProvider`
198 | - Fixed sorting for tables with skipped fields
199 |
200 | ## [0.7.0] - 2024-02-08
201 |
202 | ### Features 🚀
203 |
204 | - Virtualization — Only elements that are visible are rendered (with some extra for smooth scrolling).
205 | - Other display acceleration strategies like infinite scroll and pagination are implemented as well.
206 | - Caching — Only rows that are visible are requested from the data source and then cached.
207 | - Error handling — If an error occurs while loading data, it is displayed in a table row instead of the failed data.
208 | - Easy reloading — The data can be reloaded through the `ReloadController`.
209 |
210 | ### Breaking Changes 🛠️
211 |
212 | Everything? - sorry. This release is like half a rewrite with much less macro magic.
213 | Please check the docs and examples.
214 |
215 | ## [0.6.0] - 2023-11-02
216 |
217 | ### New Feature 🎉
218 |
219 | - Support for generic structs
220 |
221 | ### Fix 🐛
222 |
223 | - Fixed `#[table(skip_sort)]` on fields
224 |
225 | ## [0.5.0] - 2023-10-20
226 |
227 | ### Breaking Changes 🛠️
228 |
229 | - Added `on_change` events to support editable data (see new editable example)
230 |
231 | ### Fixes 🐛
232 |
233 | - Fixed selection with `key`s that are not `Copy`
234 |
235 | ### Other Changes
236 |
237 | - Modified REST example to include sorting
238 |
239 | ## [0.4.0] - 2023-10-02
240 |
241 | - Updated to leptos 0.5
242 |
243 | ## [0.3.0]
244 |
245 | - Updated to leptos 0.4
246 |
247 | ## [0.2.0]
248 |
249 | - Updated to leptos 0.3
250 | - Deactivated `default-features` of leptos
251 | - New class provider `BootstrapClassesPreset`
252 | - New example `bootstrap`
253 | - Added `thead` and `tbody` with customizable renderers
254 | - Added `getter` and `FieldGetter` with new example
--------------------------------------------------------------------------------
/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "leptos-struct-table"
3 | version = "0.14.0-beta3"
4 | edition = "2021"
5 | authors = ["Marc-Stefan Cassola"]
6 | categories = ["gui", "web-programming", "wasm"]
7 | description = "Generate a complete batteries included leptos data table component from a struct definition."
8 | exclude = ["examples/", "tests/"]
9 | keywords = ["leptos", "table", "data-sheet", "data-grid"]
10 | license = "MIT OR Apache-2.0"
11 | readme = "README.md"
12 | repository = "https://github.com/Synphonyte/leptos-struct-table"
13 |
14 | [dependencies]
15 | leptos = { version = "0.7.0" }
16 | leptos-struct-table-macro = { version = "0.13.0-beta2" }
17 | leptos-use = { version = "0.15.2" }
18 | rust_decimal = { version = "1.35", optional = true }
19 | chrono = { version = "0.4", optional = true }
20 | send_wrapper = "0.6"
21 | serde = "1"
22 | time = { version = "0.3", optional = true, features = ["formatting"] }
23 | uuid = { version = "1", optional = true, features = [] }
24 | thiserror = "1"
25 | web-sys = "0.3.67"
26 | wasm-bindgen = "0.2"
27 |
28 | [features]
29 | chrono = ["dep:chrono"]
30 | uuid = ["dep:uuid"]
31 | rust_decimal = ["dep:rust_decimal"]
32 | time = ["dep:time"]
33 | i18n = ["leptos-struct-table-macro/i18n"]
34 |
35 | [package.metadata."docs.rs"]
36 | all-features = true
37 |
--------------------------------------------------------------------------------
/LICENSE-APACHE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
--------------------------------------------------------------------------------
/LICENSE-MIT:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Synphonyte
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/examples/bootstrap/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "bootstrap"
3 | version = "0.1.0"
4 | edition = "2021"
5 |
6 | [dependencies]
7 | leptos = { version = "0.7", features = ["csr"]}
8 | leptos-struct-table = { path = "../..", features = ["chrono"] }
9 | chrono = { version = "0.4" }
10 | console_error_panic_hook = "0.1"
11 | console_log = "1"
12 | log = "0.4"
13 |
14 | [dev-dependencies]
15 | wasm-bindgen = "0.2"
16 | wasm-bindgen-test = "0.3.0"
17 | web-sys = "0.3"
--------------------------------------------------------------------------------
/examples/bootstrap/README.md:
--------------------------------------------------------------------------------
1 | ### A simple table example with just local data stored as `Vec` Uses the Bootstrap class provider.
2 |
3 | To make this example work, you must download / fork the whole repo because this is in the Cargo.toml: `leptos-struct-table = { path = "../.." }`.
4 |
5 | If you don't have it installed already, install [Trunk](https://trunkrs.dev/)
6 | as well as the wasm32-unknown-unknown target:
7 |
8 | ```bash
9 | cargo install trunk
10 | rustup target add wasm32-unknown-unknown
11 | ```
12 |
13 | Then, to run this example, execute in a terminal:
14 |
15 | ```bash
16 | trunk serve --open
17 | ```
--------------------------------------------------------------------------------
/examples/bootstrap/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/examples/bootstrap/src/main.rs:
--------------------------------------------------------------------------------
1 | use ::chrono::NaiveDate;
2 | use leptos::prelude::*;
3 | use leptos_struct_table::*;
4 |
5 | // This generates the component BookTable
6 | #[derive(TableRow, Clone)]
7 | #[table(
8 | sortable,
9 | classes_provider = "BootstrapClassesPreset",
10 | impl_vec_data_provider
11 | )]
12 | pub struct Book {
13 | pub id: u32,
14 | pub title: String,
15 | pub author: String,
16 | pub publish_date: NaiveDate,
17 | }
18 |
19 | fn main() {
20 | _ = console_log::init_with_level(log::Level::Debug);
21 | console_error_panic_hook::set_once();
22 |
23 | mount_to_body(|| {
24 | let rows = vec![
25 | Book {
26 | id: 1,
27 | title: "The Great Gatsby".to_string(),
28 | author: "F. Scott Fitzgerald".to_string(),
29 | publish_date: NaiveDate::from_ymd_opt(1925, 4, 10).unwrap(),
30 | },
31 | Book {
32 | id: 2,
33 | title: "The Grapes of Wrath".to_string(),
34 | author: "John Steinbeck".to_string(),
35 | publish_date: NaiveDate::from_ymd_opt(1939, 4, 14).unwrap(),
36 | },
37 | Book {
38 | id: 3,
39 | title: "Nineteen Eighty-Four".to_string(),
40 | author: "George Orwell".to_string(),
41 | publish_date: NaiveDate::from_ymd_opt(1949, 6, 8).unwrap(),
42 | },
43 | Book {
44 | id: 4,
45 | title: "Ulysses".to_string(),
46 | author: "James Joyce".to_string(),
47 | publish_date: NaiveDate::from_ymd_opt(1922, 2, 2).unwrap(),
48 | },
49 | ];
50 |
51 | view! {
52 |