@decidables/decidables-elements 0.0.3 → 0.1.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/CHANGELOG.md +33 -0
- package/LICENSE.md +641 -750
- package/README.md +279 -203
- package/lib/decidablesElements.esm.js +2034 -2235
- package/lib/decidablesElements.esm.js.map +1 -1
- package/lib/decidablesElements.esm.min.js +758 -3
- package/lib/decidablesElements.esm.min.js.map +1 -1
- package/lib/decidablesElements.umd.js +2035 -2236
- package/lib/decidablesElements.umd.js.map +1 -1
- package/lib/decidablesElements.umd.min.js +758 -3
- package/lib/decidablesElements.umd.min.js.map +1 -1
- package/package.json +10 -7
package/README.md
CHANGED
|
@@ -1,204 +1,279 @@
|
|
|
1
1
|
<!--lint ignore first-heading-level-->
|
|
2
2
|
|
|
3
|
-
# decidables-elements
|
|
3
|
+
# **`@decidables/decidables-elements`**<br>Web Components for Basic UI in [**decidables**](https://decidables.github.io)
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@decidables/decidables-elements)
|
|
6
|
+
[](https://github.com/decidables/decidables/blob/main/LICENSE.md)
|
|
7
|
+
|
|
8
|
+
This package provides basic user interface web components for use in all of the explorables. This
|
|
9
|
+
facilitates a consistent look and feel. They try to use the native inputs when possible, but build
|
|
10
|
+
on them for new elements like a switch, and composite elements like a slider with a linked spinner.
|
|
4
11
|
|
|
5
12
|
## Usage
|
|
6
13
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
### Install
|
|
15
|
+
|
|
16
|
+
```shell
|
|
17
|
+
yarn add @decidables/decidables-elements
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Use
|
|
21
|
+
|
|
22
|
+
```javascript
|
|
23
|
+
import '@decidables/decidables-elements';
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
A bare import is used to register the elements in the custom registry, so they are then available
|
|
27
|
+
for use in HTML.
|
|
17
28
|
|
|
18
29
|
## Contents
|
|
19
30
|
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
31
|
+
### Components
|
|
32
|
+
|
|
33
|
+
#### `DecidablesButton` / `<decidables-button>`
|
|
34
|
+
|
|
35
|
+
Button for taking actions
|
|
36
|
+
|
|
37
|
+
##### Slots
|
|
38
|
+
|
|
39
|
+
- *unnamed*
|
|
40
|
+
- Inline content as label
|
|
41
|
+
|
|
42
|
+
##### Attributes
|
|
43
|
+
|
|
44
|
+
- `disabled: boolean = false`
|
|
45
|
+
- In disabled state user can't interact
|
|
46
|
+
|
|
47
|
+
##### Example
|
|
48
|
+
|
|
49
|
+
```html
|
|
50
|
+
<decidables-button disabled>
|
|
51
|
+
Click me
|
|
52
|
+
</decidables-button>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
#### `DecidablesSlider` / `<decidables-slider>`
|
|
56
|
+
|
|
57
|
+
Slider w/spinner for selecting a numeric value from a range
|
|
58
|
+
|
|
59
|
+
##### Slots
|
|
60
|
+
|
|
61
|
+
- *unnamed*
|
|
62
|
+
- Inline content as label
|
|
63
|
+
|
|
64
|
+
##### Attributes
|
|
65
|
+
|
|
66
|
+
- `disabled: boolean = false`
|
|
67
|
+
- In disabled state user can't interact
|
|
68
|
+
- `max: number = undefined`
|
|
69
|
+
- Maximum value the slider can take
|
|
70
|
+
- `min: number = undefined`
|
|
71
|
+
- Minimum value the slider can take
|
|
72
|
+
- `step: number = undefined`
|
|
73
|
+
- Amount that value increments with smallest movement of the slider
|
|
74
|
+
- `value: number = undefined`
|
|
75
|
+
- Initial value of the slider
|
|
76
|
+
|
|
77
|
+
##### Example
|
|
78
|
+
|
|
79
|
+
```html
|
|
80
|
+
<decidables-slider disabled max="0" min="100" step="2" value="50">
|
|
81
|
+
Move me
|
|
82
|
+
</decidables-slider>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
#### `DecidablesSpinner` / `<decidables-spinner>`
|
|
86
|
+
|
|
87
|
+
Text field w/spinner arrows for selecting a continuous numeric value
|
|
88
|
+
|
|
89
|
+
##### Slots
|
|
90
|
+
|
|
91
|
+
- *unnamed*
|
|
92
|
+
- Inline content as label
|
|
93
|
+
|
|
94
|
+
##### Attributes
|
|
95
|
+
|
|
96
|
+
- `disabled: boolean = false`
|
|
97
|
+
- In disabled state user can't interact
|
|
98
|
+
- `max: number = undefined`
|
|
99
|
+
- Maximum value the slider can take
|
|
100
|
+
- `min: number = undefined`
|
|
101
|
+
- Minimum value the slider can take
|
|
102
|
+
- `step: number = undefined`
|
|
103
|
+
- Amount that value increments with smallest movement of the slider
|
|
104
|
+
- `value: number = undefined`
|
|
105
|
+
- Initial value of the slider
|
|
106
|
+
|
|
107
|
+
##### Example
|
|
108
|
+
|
|
109
|
+
```html
|
|
110
|
+
<decidables-spinner disabled max="0" min="100" step="2" value="50">
|
|
111
|
+
Change me
|
|
112
|
+
</decidables-spinner>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
#### `DecidablesSwitch` / `<decidables-switch>`
|
|
116
|
+
|
|
117
|
+
Switch for turning an option on or off
|
|
118
|
+
|
|
119
|
+
##### Slots
|
|
120
|
+
|
|
121
|
+
- *unnamed*
|
|
122
|
+
- Inline content as label for **on** state
|
|
123
|
+
- `off-label`
|
|
124
|
+
- Inline content as label for **off** state
|
|
125
|
+
|
|
126
|
+
##### Attributes
|
|
127
|
+
|
|
128
|
+
- `disabled: boolean = false`
|
|
129
|
+
- In disabled state user can't interact
|
|
130
|
+
- `checked: number = false`
|
|
131
|
+
- Whether the switch is **on** (`true`) or **off** (`false`)
|
|
132
|
+
|
|
133
|
+
##### Example
|
|
134
|
+
|
|
135
|
+
```html
|
|
136
|
+
<decidables-switch disabled checked>
|
|
137
|
+
<span>On</span>
|
|
138
|
+
<span slot="off-label">Off</span>
|
|
139
|
+
</decidables-switch>
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
#### `DecidablesToggleOption` / `<decidables-toggle-option>`
|
|
143
|
+
|
|
144
|
+
One option in a toggle set
|
|
145
|
+
|
|
146
|
+
##### Slots
|
|
147
|
+
|
|
148
|
+
- *unnamed*
|
|
149
|
+
- Inline content as label for option
|
|
150
|
+
|
|
151
|
+
##### Attributes
|
|
152
|
+
|
|
153
|
+
- `disabled: boolean = false`
|
|
154
|
+
- In disabled state user can't interact
|
|
155
|
+
- `checked: number = false`
|
|
156
|
+
- Whether the option is selected (`true`) or not ('false`)
|
|
157
|
+
- `name: string = undefined`
|
|
158
|
+
- An identifier to be shared by all options in a mutually exclusive group
|
|
159
|
+
- `value: string = undefined`
|
|
160
|
+
- An identifier specific to this option to uniquely identify it in the group
|
|
161
|
+
|
|
162
|
+
##### Example
|
|
163
|
+
|
|
164
|
+
```html
|
|
165
|
+
<decidables-toggle-option disabled name="flavors" value="chocolate" checked>
|
|
166
|
+
Chocolate
|
|
167
|
+
</decidables-toggle-option>
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
#### `DecidablesToggle` / `<decidables-toggle>`
|
|
171
|
+
|
|
172
|
+
Toggle for selecting one option from a set
|
|
173
|
+
|
|
174
|
+
##### Slots
|
|
175
|
+
|
|
176
|
+
- *unnamed*
|
|
177
|
+
- Inline content as label for set
|
|
178
|
+
- `label`
|
|
179
|
+
- Inline content as legend for options
|
|
180
|
+
|
|
181
|
+
##### Attributes
|
|
182
|
+
|
|
183
|
+
- `disabled: boolean = false`
|
|
184
|
+
- In disabled state user can't interact
|
|
185
|
+
|
|
186
|
+
##### Example
|
|
187
|
+
|
|
188
|
+
```html
|
|
189
|
+
<decidables-toggle disabled>
|
|
190
|
+
<span>Pick one</span>
|
|
191
|
+
<span slot="label">Flavors</span>
|
|
192
|
+
<decidables-toggle-option disabled name="flavors" value="chocolate">
|
|
193
|
+
Chocolate
|
|
194
|
+
</decidables-toggle-option>
|
|
195
|
+
<decidables-toggle-option disabled name="flavors" value="strawberry">
|
|
196
|
+
Strawberry
|
|
197
|
+
</decidables-toggle-option>
|
|
198
|
+
<decidables-toggle-option disabled name="flavors" value="vanilla" checked>
|
|
199
|
+
Vanilla
|
|
200
|
+
</decidables-toggle-option>
|
|
201
|
+
</decidables-toggle>
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Base class
|
|
205
|
+
|
|
206
|
+
#### `DecidablesElement`
|
|
207
|
+
|
|
208
|
+
Base class for all *decidables* web components
|
|
209
|
+
|
|
210
|
+
To define a new element:
|
|
211
|
+
|
|
212
|
+
```javascript
|
|
213
|
+
export default class DecidablesSomething extends DecidablesElement {
|
|
214
|
+
...
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
This library is built on `Lit`, so the resulting `DecidableElement` is also a `LitElement`
|
|
219
|
+
|
|
220
|
+
### Utilities
|
|
221
|
+
|
|
222
|
+
#### `DecidablesConverterArray`
|
|
223
|
+
|
|
224
|
+
Utility for attributes that can take an array of values
|
|
225
|
+
|
|
226
|
+
If you are defining a `DecidablesElement` with an attribute that can take an array of numbers,
|
|
227
|
+
then you can use this to automatically convert between a space-separated list as the attribute
|
|
228
|
+
and an `Array` of numbers as the property:
|
|
229
|
+
|
|
230
|
+
```javascript
|
|
231
|
+
static get properties() {
|
|
232
|
+
return {
|
|
233
|
+
stuff: {
|
|
234
|
+
attribute: 'values',
|
|
235
|
+
converter: DecidablesConverterArray,
|
|
236
|
+
reflect: true,
|
|
237
|
+
},
|
|
238
|
+
};
|
|
239
|
+
};
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
```html
|
|
243
|
+
<decidables-something values="1.23 3.56 -2.97"></decidables-something>
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
And `this.values` will be the `Array`: `[1.23 3.56 -2.97]`
|
|
247
|
+
|
|
248
|
+
#### `DecidablesConverterSet`
|
|
249
|
+
|
|
250
|
+
Utility for attributes that can take a set of values
|
|
251
|
+
|
|
252
|
+
If you are defining a `DecidablesElement` with an attribute that can take a set of string
|
|
253
|
+
values, then you can use this to automatically convert between a space-separated list as the
|
|
254
|
+
attribute and a `Set` of strings as the property:
|
|
255
|
+
|
|
256
|
+
```javascript
|
|
257
|
+
static get properties() {
|
|
258
|
+
return {
|
|
259
|
+
stuff: {
|
|
260
|
+
attribute: 'stuff',
|
|
261
|
+
converter: DecidablesConverterSet,
|
|
262
|
+
reflect: true,
|
|
263
|
+
},
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
```html
|
|
269
|
+
<decidables-something stuff="this that other"></decidables-something>
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
And `this.stuff` will be a `Set` with members: `'this'`, `'that'`, and `'other'`
|
|
273
|
+
|
|
274
|
+
## Development
|
|
275
|
+
|
|
276
|
+
### Features/Bugs/Notes
|
|
202
277
|
|
|
203
278
|
- Custom spinner that looks better than User Agent spinners?
|
|
204
279
|
- Edge/IE11 - slider shadow is clipped
|
|
@@ -206,11 +281,7 @@
|
|
|
206
281
|
- Firefox - spinner arrows look ugly and asymmetrical
|
|
207
282
|
- IE11 - No CSS variables outside custom elements (and not patched by ShadyCSS!)
|
|
208
283
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
## Development Tooling
|
|
212
|
-
|
|
213
|
-
### Local Scripts
|
|
284
|
+
### Package Scripts
|
|
214
285
|
|
|
215
286
|
- `yarn lint`
|
|
216
287
|
- Lints markdown, scripts and styles
|
|
@@ -223,9 +294,7 @@
|
|
|
223
294
|
- `yarn build`
|
|
224
295
|
- Builds bundles from `src/` to `lib/`
|
|
225
296
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
## File Organization
|
|
297
|
+
### File Organization
|
|
229
298
|
|
|
230
299
|
- `decidables-elements/`
|
|
231
300
|
- `lib/` (Bundles created from `src/` by `build`) **\[autogenerated\]**
|
|
@@ -233,6 +302,13 @@
|
|
|
233
302
|
- `test/` (Testing files)
|
|
234
303
|
- `coverage/` (Code coverage results) **\[autogenerated\]**
|
|
235
304
|
- `CHANGELOG.md` (Based on conventional commits) **\[autogenerated\]**
|
|
236
|
-
- `gulpfile.js` (
|
|
237
|
-
- `package.json` (
|
|
305
|
+
- `gulpfile.js` (Tasks for *gulp*)
|
|
306
|
+
- `package.json` (Package config for *yarn* and *npm*)
|
|
238
307
|
- `README.md` (This file)
|
|
308
|
+
|
|
309
|
+
## [License](https://github.com/decidables/decidables/blob/main/LICENSE.md)
|
|
310
|
+
|
|
311
|
+
The content of this project is licensed under [Creative Commons Attribution-ShareAlike 4.0
|
|
312
|
+
International License (CC-BY-SA-4.0)](https://creativecommons.org/licenses/by-sa/4.0/) and the
|
|
313
|
+
source code of this project is licensed under [GNU General Public License v3.0 or any later version
|
|
314
|
+
(GPL-3.0-or-later)](https://www.gnu.org/licenses/gpl-3.0.html).
|