@maggioli-design-system/mds-modal 3.1.0 → 3.3.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.
Files changed (68) hide show
  1. package/dist/cjs/{index-90939077.js → index-6de6438b.js} +251 -198
  2. package/dist/cjs/loader.cjs.js +3 -2
  3. package/dist/cjs/mds-modal.cjs.entry.js +34 -7
  4. package/dist/cjs/mds-modal.cjs.js +6 -2
  5. package/dist/collection/collection-manifest.json +2 -2
  6. package/dist/collection/common/aria.js +19 -0
  7. package/dist/collection/components/mds-modal/mds-modal.css +37 -67
  8. package/dist/collection/components/mds-modal/mds-modal.js +33 -6
  9. package/dist/collection/components/mds-modal/test/mds-modal.stories.js +8 -0
  10. package/dist/collection/dictionary/typography.js +3 -3
  11. package/dist/components/index.d.ts +9 -0
  12. package/dist/components/index.js +1 -1
  13. package/dist/components/mds-modal.js +33 -6
  14. package/dist/esm/{index-5dfae565.js → index-640a40d3.js} +251 -199
  15. package/dist/esm/loader.js +3 -2
  16. package/dist/esm/mds-modal.entry.js +34 -7
  17. package/dist/esm/mds-modal.js +3 -2
  18. package/dist/esm/polyfills/css-shim.js +1 -1
  19. package/dist/esm-es5/index-640a40d3.js +2 -0
  20. package/dist/esm-es5/loader.js +1 -1
  21. package/dist/esm-es5/mds-modal.entry.js +1 -1
  22. package/dist/esm-es5/mds-modal.js +1 -1
  23. package/dist/mds-modal/mds-modal.esm.js +1 -1
  24. package/dist/mds-modal/mds-modal.js +1 -1
  25. package/dist/mds-modal/p-0f3e1d2d.system.js +2 -0
  26. package/dist/mds-modal/{p-4288d1a7.system.entry.js → p-2c61dab9.system.entry.js} +1 -1
  27. package/dist/mds-modal/p-6fde22cf.js +2 -0
  28. package/dist/mds-modal/p-ba28961b.entry.js +1 -0
  29. package/dist/mds-modal/p-bea21063.system.js +1 -0
  30. package/dist/stats.json +36 -32
  31. package/dist/types/common/aria.d.ts +4 -0
  32. package/dist/types/components/mds-modal/meta/types.d.ts +2 -2
  33. package/dist/types/components/mds-modal/test/mds-modal.stories.d.ts +1 -0
  34. package/dist/types/stencil-public-runtime.d.ts +68 -7
  35. package/dist/types/types/autocomplete.d.ts +2 -2
  36. package/dist/types/types/button.d.ts +4 -4
  37. package/dist/types/types/floating-ui.d.ts +2 -2
  38. package/dist/types/types/form-rel.d.ts +1 -1
  39. package/dist/types/types/input-text-type.d.ts +1 -1
  40. package/dist/types/types/input-value-type.d.ts +1 -1
  41. package/dist/types/types/loading.d.ts +1 -1
  42. package/dist/types/types/typography.d.ts +8 -8
  43. package/dist/types/types/variant.d.ts +10 -10
  44. package/loader/index.d.ts +9 -0
  45. package/package.json +4 -4
  46. package/src/common/aria.ts +27 -0
  47. package/src/components/mds-modal/mds-modal.tsx +39 -4
  48. package/src/components/mds-modal/test/mds-modal.e2e.ts +4 -5
  49. package/src/components/mds-modal/test/mds-modal.stories.tsx +20 -0
  50. package/src/dictionary/typography.ts +3 -3
  51. package/src/fixtures/icons.json +5 -2
  52. package/src/types/typography.ts +3 -3
  53. package/www/build/mds-modal.esm.js +1 -1
  54. package/www/build/mds-modal.js +1 -1
  55. package/www/build/p-0f3e1d2d.system.js +2 -0
  56. package/www/build/{p-4288d1a7.system.entry.js → p-2c61dab9.system.entry.js} +1 -1
  57. package/www/build/p-6fde22cf.js +2 -0
  58. package/www/build/p-ba28961b.entry.js +1 -0
  59. package/www/build/p-bea21063.system.js +1 -0
  60. package/dist/esm-es5/index-5dfae565.js +0 -2
  61. package/dist/mds-modal/p-19fa0f59.js +0 -2
  62. package/dist/mds-modal/p-5935b9a5.system.js +0 -1
  63. package/dist/mds-modal/p-9c47a964.system.js +0 -2
  64. package/dist/mds-modal/p-f1135a2e.entry.js +0 -1
  65. package/www/build/p-19fa0f59.js +0 -2
  66. package/www/build/p-5935b9a5.system.js +0 -1
  67. package/www/build/p-9c47a964.system.js +0 -2
  68. package/www/build/p-f1135a2e.entry.js +0 -1
package/dist/stats.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "timestamp": "2022-09-27T10:53:55",
2
+ "timestamp": "2023-01-20T18:23:55",
3
3
  "compiler": {
4
4
  "name": "node",
5
5
  "version": "18.3.0"
@@ -9,12 +9,13 @@
9
9
  "fsNamespace": "mds-modal",
10
10
  "components": 1,
11
11
  "entries": 1,
12
- "bundles": 65,
12
+ "bundles": 66,
13
13
  "outputs": [
14
14
  {
15
15
  "name": "dist-collection",
16
- "files": 24,
16
+ "files": 25,
17
17
  "generatedFiles": [
18
+ "./dist/collection/common/aria.js",
18
19
  "./dist/collection/components/mds-modal/mds-modal.js",
19
20
  "./dist/collection/components/mds-modal/meta/dictionary.js",
20
21
  "./dist/collection/components/mds-modal/meta/types.js",
@@ -55,17 +56,17 @@
55
56
  "name": "dist-lazy",
56
57
  "files": 35,
57
58
  "generatedFiles": [
58
- "./dist/cjs/index-90939077.js",
59
+ "./dist/cjs/index-6de6438b.js",
59
60
  "./dist/cjs/index.cjs.js",
60
61
  "./dist/cjs/loader.cjs.js",
61
62
  "./dist/cjs/mds-modal.cjs.entry.js",
62
63
  "./dist/cjs/mds-modal.cjs.js",
63
- "./dist/esm-es5/index-5dfae565.js",
64
+ "./dist/esm-es5/index-640a40d3.js",
64
65
  "./dist/esm-es5/index.js",
65
66
  "./dist/esm-es5/loader.js",
66
67
  "./dist/esm-es5/mds-modal.entry.js",
67
68
  "./dist/esm-es5/mds-modal.js",
68
- "./dist/esm/index-5dfae565.js",
69
+ "./dist/esm/index-640a40d3.js",
69
70
  "./dist/esm/index.js",
70
71
  "./dist/esm/loader.js",
71
72
  "./dist/esm/mds-modal.entry.js",
@@ -75,21 +76,21 @@
75
76
  "./dist/mds-modal/index.esm.js",
76
77
  "./dist/mds-modal/mds-modal.esm.js",
77
78
  "./dist/mds-modal/mds-modal.js",
78
- "./dist/mds-modal/p-19fa0f59.js",
79
- "./dist/mds-modal/p-4288d1a7.system.entry.js",
79
+ "./dist/mds-modal/p-0f3e1d2d.system.js",
80
+ "./dist/mds-modal/p-2c61dab9.system.entry.js",
80
81
  "./dist/mds-modal/p-50ea2036.system.js",
81
- "./dist/mds-modal/p-5935b9a5.system.js",
82
- "./dist/mds-modal/p-9c47a964.system.js",
83
- "./dist/mds-modal/p-f1135a2e.entry.js",
82
+ "./dist/mds-modal/p-6fde22cf.js",
83
+ "./dist/mds-modal/p-ba28961b.entry.js",
84
+ "./dist/mds-modal/p-bea21063.system.js",
84
85
  "./www/build/index.esm.js",
85
86
  "./www/build/mds-modal.esm.js",
86
87
  "./www/build/mds-modal.js",
87
- "./www/build/p-19fa0f59.js",
88
- "./www/build/p-4288d1a7.system.entry.js",
88
+ "./www/build/p-0f3e1d2d.system.js",
89
+ "./www/build/p-2c61dab9.system.entry.js",
89
90
  "./www/build/p-50ea2036.system.js",
90
- "./www/build/p-5935b9a5.system.js",
91
- "./www/build/p-9c47a964.system.js",
92
- "./www/build/p-f1135a2e.entry.js"
91
+ "./www/build/p-6fde22cf.js",
92
+ "./www/build/p-ba28961b.entry.js",
93
+ "./www/build/p-bea21063.system.js"
93
94
  ]
94
95
  },
95
96
  {
@@ -122,12 +123,12 @@
122
123
  "components": [
123
124
  "mds-modal"
124
125
  ],
125
- "bundleId": "p-f1135a2e",
126
- "fileName": "p-f1135a2e.entry.js",
126
+ "bundleId": "p-ba28961b",
127
+ "fileName": "p-ba28961b.entry.js",
127
128
  "imports": [
128
- "p-19fa0f59.js"
129
+ "p-6fde22cf.js"
129
130
  ],
130
- "originalByteSize": 18965
131
+ "originalByteSize": 19835
131
132
  }
132
133
  ],
133
134
  "esm": [
@@ -139,9 +140,9 @@
139
140
  "bundleId": "mds-modal",
140
141
  "fileName": "mds-modal.entry.js",
141
142
  "imports": [
142
- "index-5dfae565.js"
143
+ "index-640a40d3.js"
143
144
  ],
144
- "originalByteSize": 18969
145
+ "originalByteSize": 19839
145
146
  }
146
147
  ],
147
148
  "es5": [
@@ -153,9 +154,9 @@
153
154
  "bundleId": "mds-modal",
154
155
  "fileName": "mds-modal.entry.js",
155
156
  "imports": [
156
- "index-5dfae565.js"
157
+ "index-640a40d3.js"
157
158
  ],
158
- "originalByteSize": 18969
159
+ "originalByteSize": 19839
159
160
  }
160
161
  ],
161
162
  "system": [
@@ -164,12 +165,12 @@
164
165
  "components": [
165
166
  "mds-modal"
166
167
  ],
167
- "bundleId": "p-4288d1a7.system",
168
- "fileName": "p-4288d1a7.system.entry.js",
168
+ "bundleId": "p-2c61dab9.system",
169
+ "fileName": "p-2c61dab9.system.entry.js",
169
170
  "imports": [
170
- "p-9c47a964.system.js"
171
+ "p-0f3e1d2d.system.js"
171
172
  ],
172
- "originalByteSize": 19710
173
+ "originalByteSize": 20742
173
174
  }
174
175
  ],
175
176
  "commonjs": [
@@ -181,9 +182,9 @@
181
182
  "bundleId": "mds-modal.cjs",
182
183
  "fileName": "mds-modal.cjs.entry.js",
183
184
  "imports": [
184
- "index-90939077.js"
185
+ "index-6de6438b.js"
185
186
  ],
186
- "originalByteSize": 19046
187
+ "originalByteSize": 19916
187
188
  }
188
189
  ]
189
190
  },
@@ -431,7 +432,7 @@
431
432
  "hasComponentDidRenderFn": true,
432
433
  "hasComponentDidUnloadFn": false,
433
434
  "hasConnectedCallbackFn": false,
434
- "hasDisconnectedCallbackFn": false,
435
+ "hasDisconnectedCallbackFn": true,
435
436
  "hasElement": false,
436
437
  "hasEvent": true,
437
438
  "hasLifecycle": true,
@@ -468,9 +469,11 @@
468
469
  "hasWatchCallback": true,
469
470
  "isPlain": false,
470
471
  "htmlAttrNames": [
472
+ "aria-modal",
471
473
  "class",
472
474
  "onClick",
473
475
  "name",
476
+ "role",
474
477
  "innerHTML"
475
478
  ],
476
479
  "htmlTagNames": [
@@ -492,10 +495,11 @@
492
495
  ],
493
496
  "componentGraph": {
494
497
  "sc-mds-modal": [
495
- "p-19fa0f59.js"
498
+ "p-6fde22cf.js"
496
499
  ]
497
500
  },
498
501
  "sourceGraph": {
502
+ "./src/common/aria.ts": [],
499
503
  "./src/components/mds-modal/mds-modal.tsx": [],
500
504
  "./src/components/mds-modal/meta/dictionary.ts": [],
501
505
  "./src/components/mds-modal/meta/types.ts": [],
@@ -0,0 +1,4 @@
1
+ declare const unslugName: (name: string) => string;
2
+ declare const setAttributeIfEmpty: (element: HTMLElement, attribute: string, value: string) => string;
3
+ declare const hashValue: (value: string) => string;
4
+ export { unslugName, setAttributeIfEmpty, hashValue, };
@@ -1,2 +1,2 @@
1
- export declare type ModalPositionType = 'bottom' | 'center' | 'left' | 'right' | 'top';
2
- export declare type ModalAnimationStateType = 'intro' | 'outro';
1
+ export type ModalPositionType = 'bottom' | 'center' | 'left' | 'right' | 'top';
2
+ export type ModalAnimationStateType = 'intro' | 'outro';
@@ -24,3 +24,4 @@ declare const _default: {
24
24
  export default _default;
25
25
  export declare const Default: any;
26
26
  export declare const CustomWindow: any;
27
+ export declare const ARIATest: any;
@@ -133,7 +133,7 @@ export interface ListenOptions {
133
133
  */
134
134
  passive?: boolean;
135
135
  }
136
- export declare type ListenTargetOptions = 'body' | 'document' | 'window';
136
+ export type ListenTargetOptions = 'body' | 'document' | 'window';
137
137
  export interface StateDecorator {
138
138
  (): PropertyDecorator;
139
139
  }
@@ -214,14 +214,16 @@ export declare const State: StateDecorator;
214
214
  * https://stenciljs.com/docs/reactive-data#watch-decorator
215
215
  */
216
216
  export declare const Watch: WatchDecorator;
217
- export declare type ResolutionHandler = (elm: HTMLElement) => string | undefined | null;
218
- export declare type ErrorHandler = (err: any, element?: HTMLElement) => void;
217
+ export type ResolutionHandler = (elm: HTMLElement) => string | undefined | null;
218
+ export type ErrorHandler = (err: any, element?: HTMLElement) => void;
219
219
  /**
220
220
  * `setMode()` is used for libraries which provide multiple "modes" for styles.
221
221
  */
222
222
  export declare const setMode: (handler: ResolutionHandler) => void;
223
223
  /**
224
- * getMode
224
+ * `getMode()` is used for libraries which provide multiple "modes" for styles.
225
+ * @param ref a reference to the node to get styles for
226
+ * @returns the current mode or undefined, if not found
225
227
  */
226
228
  export declare function getMode<T = string | undefined>(ref: any): T;
227
229
  export declare function setPlatformHelpers(helpers: {
@@ -234,6 +236,9 @@ export declare function setPlatformHelpers(helpers: {
234
236
  /**
235
237
  * Get the base path to where the assets can be found. Use `setAssetPath(path)`
236
238
  * if the path needs to be customized.
239
+ * @param path the path to use in calculating the asset path. this value will be
240
+ * used in conjunction with the base asset path
241
+ * @returns the base path
237
242
  */
238
243
  export declare function getAssetPath(path: string): string;
239
244
  /**
@@ -246,22 +251,38 @@ export declare function getAssetPath(path: string): string;
246
251
  * `setAssetPath(document.currentScript.src)`, or using a bundler's replace plugin to
247
252
  * dynamically set the path at build time, such as `setAssetPath(process.env.ASSET_PATH)`.
248
253
  * But do note that this configuration depends on how your script is bundled, or lack of
249
- * bunding, and where your assets can be loaded from. Additionally custom bundling
254
+ * bundling, and where your assets can be loaded from. Additionally custom bundling
250
255
  * will have to ensure the static assets are copied to its build directory.
256
+ * @param path the asset path to set
257
+ * @returns the set path
251
258
  */
252
259
  export declare function setAssetPath(path: string): string;
253
260
  /**
254
- * getElement
261
+ * Used to specify a nonce value that corresponds with an application's
262
+ * [Content Security Policy (CSP)](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP).
263
+ * When set, the nonce will be added to all dynamically created script and style tags at runtime.
264
+ * Alternatively, the nonce value can be set on a `meta` tag in the DOM head
265
+ * (<meta name="csp-nonce" content="{ nonce value here }" />) and will result in the same behavior.
266
+ * @param nonce The value to be used for the nonce attribute.
267
+ */
268
+ export declare function setNonce(nonce: string): void;
269
+ /**
270
+ * Retrieve a Stencil element for a given reference
271
+ * @param ref the ref to get the Stencil element for
272
+ * @returns a reference to the element
255
273
  */
256
274
  export declare function getElement(ref: any): HTMLStencilElement;
257
275
  /**
258
276
  * Schedules a new render of the given instance or element even if no state changed.
259
277
  *
260
- * Notice `forceUpdate()` is not syncronous and might perform the DOM render in the next frame.
278
+ * Notice `forceUpdate()` is not synchronous and might perform the DOM render in the next frame.
279
+ *
280
+ * @param ref the node/element to force the re-render of
261
281
  */
262
282
  export declare function forceUpdate(ref: any): void;
263
283
  /**
264
284
  * getRenderingRef
285
+ * @returns the rendering ref
265
286
  */
266
287
  export declare function getRenderingRef(): any;
267
288
  export interface HTMLStencilElement extends HTMLElement {
@@ -272,6 +293,8 @@ export interface HTMLStencilElement extends HTMLElement {
272
293
  * in the best moment to perform DOM mutation without causing layout thrashing.
273
294
  *
274
295
  * For further information: https://developers.google.com/web/fundamentals/performance/rendering/avoid-large-complex-layouts-and-layout-thrashing
296
+ *
297
+ * @param task the DOM-write to schedule
275
298
  */
276
299
  export declare function writeTask(task: RafCallback): void;
277
300
  /**
@@ -279,6 +302,8 @@ export declare function writeTask(task: RafCallback): void;
279
302
  * in the best moment to perform DOM reads without causing layout thrashing.
280
303
  *
281
304
  * For further information: https://developers.google.com/web/fundamentals/performance/rendering/avoid-large-complex-layouts-and-layout-thrashing
305
+ *
306
+ * @param task the DOM-read to schedule
282
307
  */
283
308
  export declare function readTask(task: RafCallback): void;
284
309
  /**
@@ -417,8 +442,44 @@ interface HostAttributes {
417
442
  ref?: (el: HTMLElement | null) => void;
418
443
  [prop: string]: any;
419
444
  }
445
+ /**
446
+ * Utilities for working with functional Stencil components. An object
447
+ * conforming to this interface is passed by the Stencil runtime as the third
448
+ * argument to a functional component, allowing component authors to work with
449
+ * features like children.
450
+ *
451
+ * The children of a functional component will be passed as the second
452
+ * argument, so a functional component which uses these utils to transform its
453
+ * children might look like the following:
454
+ *
455
+ * ```ts
456
+ * export const AddClass: FunctionalComponent = (_, children, utils) => (
457
+ * utils.map(children, child => ({
458
+ * ...child,
459
+ * vattrs: {
460
+ * ...child.vattrs,
461
+ * class: `${child.vattrs.class} add-class`
462
+ * }
463
+ * }))
464
+ * );
465
+ * ```
466
+ *
467
+ * For more see the Stencil documentation, here:
468
+ * https://stenciljs.com/docs/functional-components
469
+ */
420
470
  export interface FunctionalUtilities {
471
+ /**
472
+ * Utility for reading the children of a functional component at runtime.
473
+ * Since the Stencil runtime uses a different interface for children it is
474
+ * not recommendeded to read the children directly, and is preferable to use
475
+ * this utility to, for instance, perform a side effect for each child.
476
+ */
421
477
  forEach: (children: VNode[], cb: (vnode: ChildNode, index: number, array: ChildNode[]) => void) => void;
478
+ /**
479
+ * Utility for transforming the children of a functional component. Given an
480
+ * array of children and a callback this will return a list of the results of
481
+ * passing each child to the supplied callback.
482
+ */
422
483
  map: (children: VNode[], cb: (vnode: ChildNode, index: number, array: ChildNode[]) => ChildNode) => VNode[];
423
484
  }
424
485
  export interface FunctionalComponent<T = {}> {
@@ -1,2 +1,2 @@
1
- export declare type AutocompleteType = 'additional-name' | 'address' | 'address-level1' | 'address-level2' | 'address-level3' | 'address-level4' | 'address-line1' | 'address-line2' | 'address-line3' | 'bday' | 'bday-day' | 'bday-month' | 'bday-year' | 'cc-additional-name' | 'cc-csc' | 'cc-exp' | 'cc-exp-month' | 'cc-exp-year' | 'cc-family-name' | 'cc-family-name' | 'cc-given-name' | 'cc-name' | 'cc-number' | 'cc-type' | 'country' | 'country-name' | 'current-password' | 'email' | 'family-name' | 'given-name' | 'honorific-prefix' | 'honorific-suffix' | 'impp' | 'language' | 'name' | 'new-password' | 'nickname' | 'off' | 'on' | 'one-time-code' | 'organization' | 'organization-title' | 'photo' | 'postal-code' | 'sex' | 'street-address' | 'tel' | 'tel-area-code' | 'tel-country-code' | 'tel-extension' | 'tel-local' | 'tel-national' | 'transaction-amount' | 'transaction-currency' | 'url' | 'username';
2
- export declare type InputTextType = 'date' | 'email' | 'number' | 'password' | 'search' | 'tel' | 'text' | 'textarea' | 'time' | 'url';
1
+ export type AutocompleteType = 'additional-name' | 'address' | 'address-level1' | 'address-level2' | 'address-level3' | 'address-level4' | 'address-line1' | 'address-line2' | 'address-line3' | 'bday' | 'bday-day' | 'bday-month' | 'bday-year' | 'cc-additional-name' | 'cc-csc' | 'cc-exp' | 'cc-exp-month' | 'cc-exp-year' | 'cc-family-name' | 'cc-family-name' | 'cc-given-name' | 'cc-name' | 'cc-number' | 'cc-type' | 'country' | 'country-name' | 'current-password' | 'email' | 'family-name' | 'given-name' | 'honorific-prefix' | 'honorific-suffix' | 'impp' | 'language' | 'name' | 'new-password' | 'nickname' | 'off' | 'on' | 'one-time-code' | 'organization' | 'organization-title' | 'photo' | 'postal-code' | 'sex' | 'street-address' | 'tel' | 'tel-area-code' | 'tel-country-code' | 'tel-extension' | 'tel-local' | 'tel-national' | 'transaction-amount' | 'transaction-currency' | 'url' | 'username';
2
+ export type InputTextType = 'date' | 'email' | 'number' | 'password' | 'search' | 'tel' | 'text' | 'textarea' | 'time' | 'url';
@@ -1,4 +1,4 @@
1
- export declare type ButtonType = 'a' | 'button' | 'reset' | 'submit';
2
- export declare type ButtonSizeType = 'sm' | 'md' | 'lg' | 'xl';
3
- export declare type ButtonIconPositionType = 'left' | 'right';
4
- export declare type ButtonVariantType = 'primary' | 'dark' | 'light' | 'error' | 'info' | 'success' | 'warning';
1
+ export type ButtonType = 'a' | 'button' | 'reset' | 'submit';
2
+ export type ButtonSizeType = 'sm' | 'md' | 'lg' | 'xl';
3
+ export type ButtonIconPositionType = 'left' | 'right';
4
+ export type ButtonVariantType = 'primary' | 'dark' | 'light' | 'error' | 'info' | 'success' | 'warning';
@@ -1,2 +1,2 @@
1
- export declare type FloatingUIPlacement = 'bottom' | 'bottom-end' | 'bottom-start' | 'left' | 'left-end' | 'left-start' | 'right' | 'right-end' | 'right-start' | 'top' | 'top-end' | 'top-start';
2
- export declare type FloatingUIStrategy = 'absolute' | 'fixed';
1
+ export type FloatingUIPlacement = 'bottom' | 'bottom-end' | 'bottom-start' | 'left' | 'left-end' | 'left-start' | 'right' | 'right-end' | 'right-start' | 'top' | 'top-end' | 'top-start';
2
+ export type FloatingUIStrategy = 'absolute' | 'fixed';
@@ -1 +1 @@
1
- export declare type FormRelType = 'external' | 'help' | 'license' | 'next' | 'nofollow' | 'noopener' | 'noreferrer' | 'opener' | 'prev' | 'search';
1
+ export type FormRelType = 'external' | 'help' | 'license' | 'next' | 'nofollow' | 'noopener' | 'noreferrer' | 'opener' | 'prev' | 'search';
@@ -1 +1 @@
1
- export declare type InputTextType = 'date' | 'email' | 'number' | 'password' | 'search' | 'tel' | 'text' | 'textarea' | 'time' | 'url';
1
+ export type InputTextType = 'date' | 'email' | 'number' | 'password' | 'search' | 'tel' | 'text' | 'textarea' | 'time' | 'url';
@@ -1 +1 @@
1
- export declare type InputValueType = null | number | string | undefined;
1
+ export type InputValueType = null | number | string | undefined;
@@ -1 +1 @@
1
- export declare type LoadingType = 'eager' | 'lazy';
1
+ export type LoadingType = 'eager' | 'lazy';
@@ -1,8 +1,8 @@
1
- export declare type TypographyType = 'action' | 'caption' | 'code' | 'detail' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'hack' | 'label' | 'option' | 'paragraph' | 'tip';
2
- export declare type TypographyVariants = 'title' | 'info' | 'read' | 'mono';
3
- export declare type TypographyTitleType = 'action' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
4
- export declare type TypographyInfoType = 'caption' | 'detail' | 'label' | 'option' | 'paragraph' | 'tip';
5
- export declare type TypographyReadType = 'caption' | 'detail' | 'paragraph';
6
- export declare type TypographySmallerType = 'tip' | 'option';
7
- export declare type TypographyMonoType = 'code' | 'hack';
8
- export declare type TypographyTooltipType = 'caption' | 'detail' | 'tip';
1
+ export type TypographyType = 'action' | 'caption' | 'snippet' | 'detail' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'hack' | 'label' | 'option' | 'paragraph' | 'tip';
2
+ export type TypographyVariants = 'title' | 'info' | 'read' | 'code';
3
+ export type TypographyTitleType = 'action' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
4
+ export type TypographyInfoType = 'caption' | 'detail' | 'label' | 'option' | 'paragraph' | 'tip';
5
+ export type TypographyReadType = 'caption' | 'detail' | 'paragraph';
6
+ export type TypographySmallerType = 'tip' | 'option';
7
+ export type TypographyMonoType = 'snippet' | 'hack';
8
+ export type TypographyTooltipType = 'caption' | 'detail' | 'tip';
@@ -1,10 +1,10 @@
1
- export declare type ThemeStatusVariantType = 'error' | 'info' | 'success' | 'warning';
2
- export declare type ThemeVariantType = 'dark' | 'error' | 'info' | 'light' | 'primary' | 'success' | 'warning';
3
- export declare type ThemeFullVariantType = 'amaranth' | 'aqua' | 'blue' | 'dark' | 'error' | 'green' | 'info' | 'light' | 'lime' | 'orange' | 'orchid' | 'sky' | 'success' | 'violet' | 'warning' | 'yellow';
4
- export declare type ThemeLuminanceVariantType = 'dark' | 'light';
5
- export declare type LabelVariantType = 'amaranth' | 'aqua' | 'blue' | 'green' | 'lime' | 'orange' | 'orchid' | 'sky' | 'violet' | 'yellow';
6
- export declare type ActionVariantType = 'primary' | 'dark' | 'light';
7
- export declare type StateVariantType = 'disabled' | 'focused' | 'readonly';
8
- export declare type ToneVariantType = 'strong' | 'weak' | 'ghost' | 'quiet';
9
- export declare type ToneSimpleVariantType = 'strong' | 'weak' | 'quiet';
10
- export declare type ToneMinimalVariantType = 'strong' | 'weak';
1
+ export type ThemeStatusVariantType = 'error' | 'info' | 'success' | 'warning';
2
+ export type ThemeVariantType = 'dark' | 'error' | 'info' | 'light' | 'primary' | 'success' | 'warning';
3
+ export type ThemeFullVariantType = 'amaranth' | 'aqua' | 'blue' | 'dark' | 'error' | 'green' | 'info' | 'light' | 'lime' | 'orange' | 'orchid' | 'sky' | 'success' | 'violet' | 'warning' | 'yellow';
4
+ export type ThemeLuminanceVariantType = 'dark' | 'light';
5
+ export type LabelVariantType = 'amaranth' | 'aqua' | 'blue' | 'green' | 'lime' | 'orange' | 'orchid' | 'sky' | 'violet' | 'yellow';
6
+ export type ActionVariantType = 'primary' | 'dark' | 'light';
7
+ export type StateVariantType = 'disabled' | 'focused' | 'readonly';
8
+ export type ToneVariantType = 'strong' | 'weak' | 'ghost' | 'quiet';
9
+ export type ToneSimpleVariantType = 'strong' | 'weak' | 'quiet';
10
+ export type ToneMinimalVariantType = 'strong' | 'weak';
package/loader/index.d.ts CHANGED
@@ -10,3 +10,12 @@ export interface CustomElementsDefineOptions {
10
10
  }
11
11
  export declare function defineCustomElements(win?: Window, opts?: CustomElementsDefineOptions): Promise<void>;
12
12
  export declare function applyPolyfills(): Promise<void>;
13
+
14
+ /**
15
+ * Used to specify a nonce value that corresponds with an application's CSP.
16
+ * When set, the nonce will be added to all dynamically created script and style tags at runtime.
17
+ * Alternatively, the nonce value can be set on a meta tag in the DOM head
18
+ * (<meta name="csp-nonce" content="{ nonce value here }" />) which
19
+ * will result in the same behavior.
20
+ */
21
+ export declare function setNonce(nonce: string): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maggioli-design-system/mds-modal",
3
- "version": "3.1.0",
3
+ "version": "3.3.0",
4
4
  "description": "mds-modal is a web-component from Maggioli Design System Magma, built with StencilJS, TypeScript, Storybook. It's based on the web-component standard and it's designed to be agnostic from the JavaScirpt framework you are using.",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.js",
@@ -23,15 +23,15 @@
23
23
  "test": "stencil test --spec --e2e"
24
24
  },
25
25
  "dependencies": {
26
- "@maggioli-design-system/styles": "^8.2.0",
27
- "@stencil/core": "^2.18.0",
26
+ "@maggioli-design-system/styles": "^10.0.1",
27
+ "@stencil/core": "^2.22.1",
28
28
  "clsx": "^1.2.1"
29
29
  },
30
30
  "license": "MIT",
31
31
  "author": {
32
32
  "name": "Vittorio Vittori",
33
33
  "email": "vittorio.vittori@maggioli.it",
34
- "url": "http://vit.to"
34
+ "url": "https://vitto.github.io/vit.to/"
35
35
  },
36
36
  "contributors": [
37
37
  {
@@ -0,0 +1,27 @@
1
+ const hash = (s: string): string => {
2
+ let i: number, h: number
3
+ for (i = 0, h = 0; i < s.length; i ++) {
4
+ h = Math.imul(31, h) + s.charCodeAt(i) | 0
5
+ }
6
+ return h.toString()
7
+ }
8
+
9
+ const unslugName = (name: string): string => {
10
+ return name.split('/').slice(-1).pop().replace(/-/g, ' ')
11
+ }
12
+
13
+ const setAttributeIfEmpty = (element: HTMLElement, attribute: string, value: string): string => {
14
+ if (element.hasAttribute(attribute)) {
15
+ return element.getAttribute(attribute)
16
+ }
17
+ element.setAttribute(attribute, value)
18
+ return value
19
+ }
20
+
21
+ const hashValue = (value: string): string => `${value}-${hash(value)}`
22
+
23
+ export {
24
+ unslugName,
25
+ setAttributeIfEmpty,
26
+ hashValue,
27
+ }
@@ -41,6 +41,11 @@ export class MdsModal {
41
41
  if (this.position === null) {
42
42
  this.position = 'right'
43
43
  }
44
+
45
+ if (this.window) {
46
+ const modal = this.hostElement.querySelector('[slot="window"]')
47
+ modal.setAttribute('role', 'modal')
48
+ }
44
49
  }
45
50
 
46
51
  componentWillRender (): void {
@@ -55,6 +60,17 @@ export class MdsModal {
55
60
  this.hostElement.classList.add(this.animationName(this.animationState))
56
61
  window.clearTimeout(this.animationDeelay)
57
62
  }, 500)
63
+
64
+ if (this.opened) {
65
+ this.addKeyboardEscapeListener()
66
+ return
67
+ }
68
+
69
+ this.removeKeyboardEscapeListener()
70
+ }
71
+
72
+ disconnectedCallback (): void {
73
+ this.removeKeyboardEscapeListener()
58
74
  }
59
75
 
60
76
  private animationName = (customState: string = null, customPosition: string = null): string => {
@@ -69,10 +85,31 @@ export class MdsModal {
69
85
  this.hostElement.classList.remove(this.animationName('outro', oldValue))
70
86
  }
71
87
 
88
+ private checkKeyboardEscape = (event: KeyboardEvent): void => {
89
+ if (event.code === 'Escape') {
90
+ this.close.emit()
91
+ }
92
+ }
93
+
94
+ private addKeyboardEscapeListener (): void {
95
+ window.addEventListener('keydown', this.checkKeyboardEscape.bind(this))
96
+ }
97
+
98
+ private removeKeyboardEscapeListener (): void {
99
+ window.removeEventListener('keydown', this.checkKeyboardEscape.bind(this))
100
+ }
101
+
72
102
  @Watch('opened')
73
103
  openedChange (newValue: boolean): void {
74
104
  this.stateOpened = newValue
75
105
  window.clearTimeout(this.animationDeelay)
106
+
107
+ if (newValue) {
108
+ this.addKeyboardEscapeListener()
109
+ return
110
+ }
111
+
112
+ this.removeKeyboardEscapeListener()
76
113
  }
77
114
 
78
115
  /**
@@ -97,14 +134,12 @@ export class MdsModal {
97
134
 
98
135
  render () {
99
136
  return (
100
- <Host class={clsx(
101
- this.stateOpened && this.animationName('opened'),
102
- )} onClick={(e: Event) => { this.closeModal(e) }}>
137
+ <Host aria-modal={clsx(this.opened ? 'true' : 'false' )} class={clsx(this.stateOpened && this.animationName('opened'))} onClick={(e: Event) => { this.closeModal(e) }}>
103
138
  { this.window
104
139
  ?
105
140
  <slot name="window"/>
106
141
  :
107
- <div class={clsx('window', (this.top || this.bottom) && `window-${this.top ? '-top' : ''}${this.bottom ? '-bottom' : ''}`)}>
142
+ <div class={clsx('window', (this.top || this.bottom) && `window-${this.top ? '-top' : ''}${this.bottom ? '-bottom' : ''}`)} role="dialog">
108
143
  { this.top &&
109
144
  <slot name="top"/>
110
145
  }
@@ -9,9 +9,8 @@ describe('mds-modal', () => {
9
9
 
10
10
  // La riga seguente non è valida perché `animate-right-intro` viene impostato in `componentDidRender`
11
11
  // e quindi appena instanziato non è presente come classe
12
- // expect(element).toHaveClasses(['animate-right', 'hydrated', 'animate-right-intro'])
13
- expect(element).toHaveClasses(['animate-right', 'hydrated'])
14
-
12
+ expect(element).toHaveClass('animate-right')
13
+ expect(element).toHaveAttribute('hydrated')
15
14
  expect(element).toHaveAttribute('position')
16
15
 
17
16
  expect(element.getAttribute('position')).toBe('right')
@@ -19,7 +18,7 @@ describe('mds-modal', () => {
19
18
  expect(element).not.toHaveAttribute('opened')
20
19
 
21
20
  expect(element.shadowRoot).toEqualHtml(`
22
- <div class="window">
21
+ <div class="window" role="dialog">
23
22
  <slot></slot>
24
23
  </div>
25
24
  <i class="close svg">
@@ -39,7 +38,7 @@ describe('mds-modal', () => {
39
38
  expect(element.getAttribute('opened')).not.toBe('false')
40
39
 
41
40
  expect(element.shadowRoot).toEqualHtml(`
42
- <div class="window">
41
+ <div class="window" role="dialog">
43
42
  <slot></slot>
44
43
  </div>
45
44
  <i class="close svg">
@@ -1,5 +1,6 @@
1
1
 
2
2
  import { h } from '@stencil/core'
3
+ import { useState } from 'react'
3
4
  import { modalPositionDictionary } from '../meta/dictionary'
4
5
 
5
6
  export default {
@@ -58,5 +59,24 @@ const CustomTemplate = args =>
58
59
  </mds-banner>
59
60
  </mds-modal>
60
61
 
62
+ const AriaTemplate = () => {
63
+ // Click not working with reader
64
+ const [opened, setOpened] = useState(false)
65
+ window.addEventListener('close', () => { setOpened(false) })
66
+ return <div>
67
+ <mds-button onClick={() => setOpened(true) }>Apri modale</mds-button>
68
+ <mds-modal opened={opened} onClose={() => setOpened(false)}>
69
+ <mds-banner slot="window" class="max-w-xl mx-6" deletable headline="Action required">
70
+ <mds-text typography="detail">
71
+ As a multi-brand design system, our components need to be flexible enough for any one of our brands to use them for multiple use cases. To achieve this, we ensure that all of the brands are involved in the specification stage, giving us more confidence that we’re future-proofing our components as more brands adopt NewsKit.
72
+ </mds-text>
73
+ <mds-button slot="actions" variant="dark" tone="quiet" onClick={() => setOpened(false) }>Cancel</mds-button>
74
+ <mds-button slot="actions" variant="primary">Confirm</mds-button>
75
+ </mds-banner>
76
+ </mds-modal>
77
+ </div>
78
+ }
79
+
61
80
  export const Default = Template.bind({})
62
81
  export const CustomWindow = CustomTemplate.bind({})
82
+ export const ARIATest = AriaTemplate.bind({})