@knowark/componarkjs 1.10.2 → 1.11.0

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.
@@ -201,6 +201,32 @@ describe('Component', () => {
201
201
  expect(component.data.value).toEqual('E')
202
202
  })
203
203
 
204
+ it('binds multiple handlers to the same event', async () => {
205
+ container.innerHTML = `
206
+ <mock-component>
207
+ <input type="text"
208
+ listen
209
+ on-input="{{ data.value = data }}"
210
+ on-input-1="{{ data.value1 = data }}"
211
+ on-input-2="{{ data.value2 = data }}"
212
+ on-input-3="{{ data.value3 = data }}"
213
+ ></input>
214
+ </mock-component>
215
+ `
216
+
217
+ const component = container.querySelector('mock-component')
218
+ const input = component.select('input')
219
+
220
+ input.dispatchEvent(
221
+ new globalThis.InputEvent('input', { bubbles: true, data: 'E' })
222
+ )
223
+
224
+ expect(component.data.value).toEqual('E')
225
+ expect(component.data.value1).toEqual('E')
226
+ expect(component.data.value2).toEqual('E')
227
+ expect(component.data.value3).toEqual('E')
228
+ })
229
+
204
230
  it('binds to the target.value event property by default', async () => {
205
231
  container.innerHTML = `
206
232
  <mock-component>
@@ -2,7 +2,9 @@ const userActions = ['-hover', '-active']
2
2
 
3
3
  const formActions = ['-focus-within', '-valid', '-invalid', '-checked']
4
4
 
5
- const actions = ['', ...userActions, ...formActions]
5
+ const attributes = ['[disabled]', '[open]', '[required]', '[readonly]']
6
+
7
+ const actions = ['', ...userActions, ...formActions, ...attributes]
6
8
 
7
9
  const sides = ['', '-top', '-right', '-bottom', '-left']
8
10
 
@@ -13,6 +15,8 @@ const mutableProperties = [
13
15
  const effects = [
14
16
  'animation', 'filter', 'mix-blend-mode', 'transition', 'transform']
15
17
 
18
+ const tie = (action) => action.replace('[', '-').replace(']', '')
19
+
16
20
  const css = String.raw; export default css`
17
21
  * {
18
22
  margin: 0;
@@ -90,13 +94,13 @@ html {
90
94
  /* COLORS */
91
95
 
92
96
  ${actions.map(action => css`
93
- [style*='--color${action}:']${action.replace('-', ':')} {
94
- color: var(--color${action});
97
+ [style*='--color${tie(action)}:']${action.replace('-', ':')} {
98
+ color: var(--color${tie(action)});
95
99
  }
96
100
  `.trim()).join('\n')}
97
101
  ${actions.map(action => css`
98
- [style*='--background${action}:']${action.replace('-', ':')} {
99
- background: var(--background${action});
102
+ [style*='--background${tie(action)}:']${action.replace('-', ':')} {
103
+ background: var(--background${tie(action)});
100
104
  }
101
105
  `.trim()).join('\n')}
102
106
 
@@ -239,34 +243,34 @@ ${sides.filter(Boolean).map(side => css`
239
243
  /* BORDERS */
240
244
 
241
245
  ${actions.map(action => css`
242
- [style*='--border-style${action}:']${action.replace('-', ':')} {
243
- border-style: var(--border-style${action});
246
+ [style*='--border-style${tie(action)}:']${action.replace('-', ':')} {
247
+ border-style: var(--border-style${tie(action)});
244
248
  }
245
- [style*='--border-width${action}:']${action.replace('-', ':')} {
246
- border-width: var(--border-width${action});
249
+ [style*='--border-width${tie(action)}:']${action.replace('-', ':')} {
250
+ border-width: var(--border-width${tie(action)});
247
251
  }
248
- [style*='--border-color${action}:']${action.replace('-', ':')} {
249
- border-color: var(--border-color${action});
252
+ [style*='--border-color${tie(action)}:']${action.replace('-', ':')} {
253
+ border-color: var(--border-color${tie(action)});
250
254
  }
251
- [style*='--border-radius${action}:']${action.replace('-', ':')} {
252
- border-radius: var(--border-radius${action});
255
+ [style*='--border-radius${tie(action)}:']${action.replace('-', ':')} {
256
+ border-radius: var(--border-radius${tie(action)});
253
257
  }
254
258
  `.trim()).join('\n')}
255
259
 
256
260
  ${actions.map(action => css`
257
- [style*='--outline${action}:']${action.replace('-', ':')} {
258
- outline: var(--outline${action});
261
+ [style*='--outline${tie(action)}:']${action.replace('-', ':')} {
262
+ outline: var(--outline${tie(action)});
259
263
  }
260
264
  `.trim()).join('\n')}
261
265
 
262
266
  /* SHADOWS */
263
267
 
264
268
  ${actions.map(action => css`
265
- [style*='--box-shadow${action}:']${action.replace('-', ':')} {
269
+ [style*='--box-shadow${tie(action)}:']${action.replace('-', ':')} {
266
270
  box-shadow: 0
267
- calc(var(--box-shadow-offset-step) * var(--box-shadow${action}))
268
- calc(var(--box-shadow-blur-step) * var(--box-shadow${action}))
269
- calc(var(--box-shadow-spread-step) * var(--box-shadow${action}))
271
+ calc(var(--box-shadow-offset-step) * var(--box-shadow${tie(action)}))
272
+ calc(var(--box-shadow-blur-step) * var(--box-shadow${tie(action)}))
273
+ calc(var(--box-shadow-spread-step) * var(--box-shadow${tie(action)}))
270
274
  var(--box-shadow-color);
271
275
  }
272
276
  `.trim()).join('\n')}
@@ -274,8 +278,8 @@ ${actions.map(action => css`
274
278
  /* EFFECTS */
275
279
 
276
280
  ${effects.map(effect => actions.map(action => css`
277
- [style*='--${effect}${action}:']${action.replace('-', ':')} {
278
- ${effect}: var(--${effect}${action});
281
+ [style*='--${effect}${tie(action)}:']${action.replace('-', ':')} {
282
+ ${effect}: var(--${effect}${tie(action)});
279
283
  }
280
284
  `.trim())).flat().join('\n')}
281
285
 
@@ -283,22 +287,22 @@ ${effects.map(effect => actions.map(action => css`
283
287
 
284
288
  ${[...mutableProperties, ...effects].map(
285
289
  effect => actions.map(action => css`
286
- *${action.replace('-', ':')} > [style*='--${effect}-parent${action}:'] {
287
- ${effect}: var(--${effect}-parent${action});
290
+ *${action.replace('-', ':')} > [style*='--${effect}-parent${tie(action)}:'] {
291
+ ${effect}: var(--${effect}-parent${tie(action)});
288
292
  }
289
293
  `.trim())).flat().join('\n')}
290
294
 
291
295
  ${[...mutableProperties, ...effects].map(
292
296
  effect => actions.map(action => css`
293
- *${action.replace('-', ':')} + [style*='--${effect}-sibling${action}:'] {
294
- ${effect}: var(--${effect}-sibling${action});
297
+ *${action.replace('-', ':')} + [style*='--${effect}-sibling${tie(action)}:'] {
298
+ ${effect}: var(--${effect}-sibling${tie(action)});
295
299
  }
296
300
  `.trim())).flat().join('\n')}
297
301
 
298
302
  ${[...mutableProperties, ...effects].map(
299
303
  effect => actions.map(action => css`
300
- *${action.replace('-', ':')} ~ [style*='--${effect}-antecessor${action}:'] {
301
- ${effect}: var(--${effect}-antecessor${action});
304
+ *${action.replace('-',':')} ~ [style*='--${effect}-antecessor${tie(action)}:'] {
305
+ ${effect}: var(--${effect}-antecessor${tie(action)});
302
306
  }
303
307
  `.trim())).flat().join('\n')}
304
308
 
@@ -50,7 +50,8 @@ export function listen (self) {
50
50
  }
51
51
  }
52
52
 
53
- const eventName = attribute.name.replace('on-', '').trim()
53
+ const eventName = (
54
+ attribute.name.replace('on-', '').replace(/-\d+$/, '').trim())
54
55
  element.addEventListener(eventName, catchingHandler.bind(self))
55
56
  element.removeAttribute(binding)
56
57
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowark/componarkjs",
3
- "version": "1.10.2",
3
+ "version": "1.11.0",
4
4
  "author": "Knowark",
5
5
  "description": "Knowark's Web Components Library",
6
6
  "license": "ISC",