@ornery/ui-grid-vanilla 1.0.6 → 1.0.7
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.
- package/README.md +75 -11
- package/dist/browser/ui-grid-element.js +9586 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +18 -0
- package/dist/index.mjs +20 -0
- package/package.json +9 -2
- package/src/browser.test.ts +9 -0
- package/src/browser.ts +8 -0
- package/src/grid-controller.ts +24 -0
- package/src/index.integration.test.ts +32 -6
- package/tsup.config.ts +22 -7
package/README.md
CHANGED
|
@@ -45,6 +45,7 @@ class MyComponent extends HTMLElement {
|
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
The `.html` template uses ES6 template literal syntax:
|
|
48
|
+
|
|
48
49
|
```html
|
|
49
50
|
<div class="my-class">${this.myProp}</div>
|
|
50
51
|
```
|
|
@@ -60,10 +61,10 @@ Templates are compiled at build time by `@ornery/web-components/vite` (or `/webp
|
|
|
60
61
|
|
|
61
62
|
Cell and row slot templates support dual binding syntax:
|
|
62
63
|
|
|
63
|
-
| Syntax
|
|
64
|
-
|
|
65
|
-
| `{{ }}` | `{{value}}`
|
|
66
|
-
| `${ }`
|
|
64
|
+
| Syntax | Example | Description |
|
|
65
|
+
| ------- | --------------- | ----------------------------------------------------- |
|
|
66
|
+
| `{{ }}` | `{{value}}` | Mustache-style, original grid syntax |
|
|
67
|
+
| `${ }` | `${this.value}` | ES6 template literal, `@ornery/web-components` native |
|
|
67
68
|
|
|
68
69
|
Both resolve against the same context: `{ $implicit, value, valueText, row, column, rowIndex }`.
|
|
69
70
|
|
|
@@ -75,6 +76,53 @@ npm install @ornery/ui-grid-vanilla @ornery/ui-grid-core
|
|
|
75
76
|
|
|
76
77
|
## Usage
|
|
77
78
|
|
|
79
|
+
### No-Bundler Browser Usage
|
|
80
|
+
|
|
81
|
+
Use the browser bundle when a static HTML host needs to consume the grid without Vite, Webpack, tsup, or another package-aware build step. The bundle includes `@ornery/ui-grid-core` and registers `<ui-grid-element>` when the module loads.
|
|
82
|
+
|
|
83
|
+
After `npm run build:vanilla` from the repo root, the browser-ready file is written to `projects/ui-grid-vanilla/dist/browser/ui-grid-element.js`.
|
|
84
|
+
|
|
85
|
+
```html
|
|
86
|
+
<!doctype html>
|
|
87
|
+
<html lang="en">
|
|
88
|
+
<head>
|
|
89
|
+
<meta charset="utf-8" />
|
|
90
|
+
<title>UI Grid Browser Bundle</title>
|
|
91
|
+
<script type="module" src="./ui-grid-element.js"></script>
|
|
92
|
+
</head>
|
|
93
|
+
<body>
|
|
94
|
+
<ui-grid-element
|
|
95
|
+
grid-id="static-grid"
|
|
96
|
+
enable-sorting
|
|
97
|
+
enable-filtering
|
|
98
|
+
column-defs='[{"name":"name"},{"name":"role"},{"name":"salary","type":"number","align":"end"}]'
|
|
99
|
+
data='[{"name":"Alice","role":"Engineer","salary":120000},{"name":"Bob","role":"Designer","salary":95000}]'
|
|
100
|
+
>
|
|
101
|
+
</ui-grid-element>
|
|
102
|
+
</body>
|
|
103
|
+
</html>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
For imperative setup in the same no-bundler environment, import from that same file:
|
|
107
|
+
|
|
108
|
+
```html
|
|
109
|
+
<div id="grid"></div>
|
|
110
|
+
|
|
111
|
+
<script type="module">
|
|
112
|
+
import { mountVanillaUiGrid } from './ui-grid-element.js';
|
|
113
|
+
|
|
114
|
+
await mountVanillaUiGrid(document.querySelector('#grid'), {
|
|
115
|
+
id: 'static-mounted-grid',
|
|
116
|
+
columnDefs: [{ name: 'name' }, { name: 'role' }],
|
|
117
|
+
data: [{ name: 'Alice', role: 'Engineer' }],
|
|
118
|
+
enableSorting: true,
|
|
119
|
+
enableFiltering: true,
|
|
120
|
+
});
|
|
121
|
+
</script>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
The package `dist/index.js` file is CommonJS for Node/package consumers, and `dist/index.mjs` is package ESM for bundlers or import-map setups. Use `dist/browser/ui-grid-element.js` for direct browser loading.
|
|
125
|
+
|
|
78
126
|
### Imperative (JavaScript)
|
|
79
127
|
|
|
80
128
|
```js
|
|
@@ -103,7 +151,8 @@ const grid = await mountVanillaUiGrid(document.getElementById('grid'), {
|
|
|
103
151
|
enable-sorting
|
|
104
152
|
enable-filtering
|
|
105
153
|
column-defs='[{"name":"name","field":"name"},{"name":"age","field":"age","align":"end"}]'
|
|
106
|
-
data='[{"name":"Alice","age":30},{"name":"Bob","age":25}]'
|
|
154
|
+
data='[{"name":"Alice","age":30},{"name":"Bob","age":25}]'
|
|
155
|
+
>
|
|
107
156
|
</ui-grid-element>
|
|
108
157
|
```
|
|
109
158
|
|
|
@@ -131,10 +180,21 @@ Define reusable components from HTML alone with `<template is="ui-grid-template"
|
|
|
131
180
|
<!-- Define a badge component -->
|
|
132
181
|
<template is="ui-grid-template" name="ui-status-badge" status="unknown">
|
|
133
182
|
<style>
|
|
134
|
-
:host {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
.badge
|
|
183
|
+
:host {
|
|
184
|
+
display: inline-block;
|
|
185
|
+
}
|
|
186
|
+
.badge {
|
|
187
|
+
padding: 2px 8px;
|
|
188
|
+
border-radius: 4px;
|
|
189
|
+
}
|
|
190
|
+
.badge-active {
|
|
191
|
+
background: #d1fae5;
|
|
192
|
+
color: #065f46;
|
|
193
|
+
}
|
|
194
|
+
.badge-inactive {
|
|
195
|
+
background: #fee2e2;
|
|
196
|
+
color: #991b1b;
|
|
197
|
+
}
|
|
138
198
|
</style>
|
|
139
199
|
<span class="badge badge-${this.status}">${this.status}</span>
|
|
140
200
|
</template>
|
|
@@ -156,7 +216,7 @@ import { defineConfig } from 'vite';
|
|
|
156
216
|
import webComponents from '@ornery/web-components/vite';
|
|
157
217
|
|
|
158
218
|
export default defineConfig({
|
|
159
|
-
plugins: [webComponents()]
|
|
219
|
+
plugins: [webComponents()],
|
|
160
220
|
});
|
|
161
221
|
```
|
|
162
222
|
|
|
@@ -166,7 +226,7 @@ export default defineConfig({
|
|
|
166
226
|
import webComponents from '@ornery/web-components/webpack';
|
|
167
227
|
|
|
168
228
|
export default {
|
|
169
|
-
plugins: [webComponents()]
|
|
229
|
+
plugins: [webComponents()],
|
|
170
230
|
};
|
|
171
231
|
```
|
|
172
232
|
|
|
@@ -184,13 +244,17 @@ export default defineConfig({
|
|
|
184
244
|
## API
|
|
185
245
|
|
|
186
246
|
### `mountVanillaUiGrid(target, options, rustModule?, tagName?)`
|
|
247
|
+
|
|
187
248
|
Mount a grid into a target element. Returns the grid element.
|
|
188
249
|
|
|
189
250
|
### `defineStandaloneUiGridElement(tagName?)`
|
|
251
|
+
|
|
190
252
|
Register the `<ui-grid-element>` custom element (and all sub-components).
|
|
191
253
|
|
|
192
254
|
### `UIGridTemplate`
|
|
255
|
+
|
|
193
256
|
Exported class for the `<template is="ui-grid-template">` element. Auto-registered when the grid is defined.
|
|
194
257
|
|
|
195
258
|
### Grid Element Properties
|
|
259
|
+
|
|
196
260
|
See `VanillaUiGridElement` type — all `GridOptions` fields are available as both HTML attributes and JS properties.
|