@record-evolution/widget-filter-calendar 1.0.1
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/LICENSE +21 -0
- package/README.md +148 -0
- package/dist/widget-filter-calendar.js +718 -0
- package/dist/widget-filter-calendar.js.map +1 -0
- package/package.json +56 -0
- package/src/default-data.json +6 -0
- package/src/definition-schema.d.ts +28 -0
- package/src/definition-schema.json +33 -0
- package/src/widget-filter-calendar.ts +238 -0
- package/thumbnail.png +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 widget-linechart
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# \<widget-filter-calendar>
|
|
2
|
+
|
|
3
|
+
A filter dropdown widget using Material Design components for IronFlock dashboards.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm i @record-evolution/widget-filter-calendar
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### Import Map Requirement
|
|
16
|
+
|
|
17
|
+
This widget uses Material Web components as external dependencies. You **must** provide an import map in your consuming application to resolve `@material/web` imports.
|
|
18
|
+
|
|
19
|
+
**Option 1: Load from CDN**
|
|
20
|
+
|
|
21
|
+
```html
|
|
22
|
+
<script type="importmap">
|
|
23
|
+
{
|
|
24
|
+
"imports": {
|
|
25
|
+
"@material/web/": "https://cdn.jsdelivr.net/npm/@material/web@2.4.0/"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
</script>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Option 2: Load from local node_modules** (if you have `@material/web` installed)
|
|
32
|
+
|
|
33
|
+
```html
|
|
34
|
+
<script type="importmap">
|
|
35
|
+
{
|
|
36
|
+
"imports": {
|
|
37
|
+
"@material/web/": "/node_modules/@material/web/"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
</script>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Important:** If your consuming application also uses Material Web components and bundles them with Vite, you must externalize `@material/web` in your Vite config:
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
// vite.config.ts
|
|
47
|
+
export default defineConfig({
|
|
48
|
+
build: {
|
|
49
|
+
rollupOptions: {
|
|
50
|
+
external: [/^@material\/web/]
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Loading the Widget
|
|
57
|
+
|
|
58
|
+
```html
|
|
59
|
+
<!-- Define import map first -->
|
|
60
|
+
<script type="importmap">
|
|
61
|
+
{
|
|
62
|
+
"imports": {
|
|
63
|
+
"@material/web/": "https://cdn.jsdelivr.net/npm/@material/web@2.4.0/"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
<!-- Then load the widget -->
|
|
69
|
+
<script type="module">
|
|
70
|
+
import 'https://cdn.jsdelivr.net/npm/@record-evolution/widget-filter-calendar@1.0.0/dist/widget-filter-calendar.js'
|
|
71
|
+
</script>
|
|
72
|
+
|
|
73
|
+
<widget-filter-calendar-1.0.0></widget-filter-calendar-1.0.0>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Expected Data Format
|
|
77
|
+
|
|
78
|
+
The widget accepts configuration matching the `definition-schema.json`:
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"label": "Select Device Type",
|
|
83
|
+
"parameterKey": "deviceType",
|
|
84
|
+
"data": [
|
|
85
|
+
{
|
|
86
|
+
"label": "Temperature Sensor",
|
|
87
|
+
"value": "temp_sensor"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"label": "Humidity Sensor",
|
|
91
|
+
"value": "humidity_sensor"
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Properties
|
|
98
|
+
|
|
99
|
+
- **label** (string): Display label shown above the dropdown
|
|
100
|
+
- **parameterKey** (string): Key used to identify this filter parameter in events
|
|
101
|
+
- **data** (array): List of dropdown options
|
|
102
|
+
- **label** (string): Display text for the option
|
|
103
|
+
- **value** (string): Value sent in the filter-change event
|
|
104
|
+
|
|
105
|
+
### Events
|
|
106
|
+
|
|
107
|
+
The widget dispatches a `filter-change` event when a selection is made:
|
|
108
|
+
|
|
109
|
+
```javascript
|
|
110
|
+
{
|
|
111
|
+
detail: {
|
|
112
|
+
parameterKey: "deviceType",
|
|
113
|
+
value: "temp_sensor"
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Development
|
|
119
|
+
|
|
120
|
+
### Local Development
|
|
121
|
+
|
|
122
|
+
To develop the widget locally:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
npm start
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
This starts a development server at `localhost:8000/demo/` serving `demo/index.html`.
|
|
129
|
+
|
|
130
|
+
### Building
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
npm run build
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Releasing
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
npm run release
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
This automatically bumps the patch version, builds, and pushes to GitHub. The GitHub Action will publish to npm.
|
|
143
|
+
|
|
144
|
+
## Tooling configs
|
|
145
|
+
|
|
146
|
+
For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project.
|
|
147
|
+
|
|
148
|
+
If you customize the configuration a lot, you can consider moving them to individual files.
|