@maggioli-design-system/mds-input-range 2.0.1 → 2.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.
Files changed (91) hide show
  1. package/dist/cjs/{index-f984e289.js → index-27635fed.js} +171 -73
  2. package/dist/cjs/loader.cjs.js +2 -2
  3. package/dist/cjs/mds-input-range.cjs.entry.js +30 -8
  4. package/dist/cjs/mds-input-range.cjs.js +3 -3
  5. package/dist/collection/collection-manifest.json +1 -1
  6. package/dist/collection/common/floating-controller.js +180 -0
  7. package/dist/collection/common/slot.js +19 -0
  8. package/dist/collection/components/mds-input-range/mds-input-range.css +22 -2
  9. package/dist/collection/components/mds-input-range/mds-input-range.js +57 -6
  10. package/dist/collection/components/mds-input-range/test/mds-input-range.stories.js +8 -0
  11. package/dist/collection/dictionary/animation.js +5 -0
  12. package/dist/collection/dictionary/file-extensions.js +6 -59
  13. package/dist/collection/dictionary/tree.js +13 -0
  14. package/dist/collection/fixtures/filenames.js +62 -1
  15. package/dist/collection/type/animation.js +1 -0
  16. package/dist/collection/type/tree.js +1 -0
  17. package/dist/collection/type/variant-file-format.js +5 -0
  18. package/dist/components/mds-input-range.js +31 -7
  19. package/dist/documentation.d.ts +8 -0
  20. package/dist/documentation.json +40 -6
  21. package/dist/esm/{index-e0ac0a55.js → index-c0c11860.js} +171 -73
  22. package/dist/esm/loader.js +3 -3
  23. package/dist/esm/mds-input-range.entry.js +30 -8
  24. package/dist/esm/mds-input-range.js +4 -4
  25. package/dist/esm-es5/index-c0c11860.js +1 -0
  26. package/dist/esm-es5/loader.js +1 -1
  27. package/dist/esm-es5/mds-input-range.entry.js +1 -1
  28. package/dist/esm-es5/mds-input-range.js +1 -1
  29. package/dist/mds-input-range/mds-input-range.esm.js +1 -1
  30. package/dist/mds-input-range/mds-input-range.js +1 -1
  31. package/dist/mds-input-range/p-16118dde.system.entry.js +1 -0
  32. package/dist/mds-input-range/p-71d27af5.system.js +2 -0
  33. package/dist/mds-input-range/p-7a612415.system.js +1 -0
  34. package/dist/mds-input-range/p-8951c4d3.entry.js +1 -0
  35. package/dist/mds-input-range/p-dd7b28fc.js +2 -0
  36. package/dist/stats.json +120 -41
  37. package/dist/types/common/floating-controller.d.ts +46 -0
  38. package/dist/types/common/slot.d.ts +3 -0
  39. package/dist/types/components/mds-input-range/mds-input-range.d.ts +6 -0
  40. package/dist/types/components/mds-input-range/test/mds-input-range.stories.d.ts +7 -0
  41. package/dist/types/components.d.ts +8 -0
  42. package/dist/types/dictionary/animation.d.ts +2 -0
  43. package/dist/types/dictionary/tree.d.ts +4 -0
  44. package/dist/types/fixtures/filenames.d.ts +62 -1
  45. package/dist/types/type/animation.d.ts +1 -0
  46. package/dist/types/type/file-types.d.ts +1 -1
  47. package/dist/types/type/tree.d.ts +3 -0
  48. package/dist/types/type/variant-file-format.d.ts +1 -1
  49. package/documentation.json +81 -17
  50. package/package.json +4 -4
  51. package/readme.md +7 -6
  52. package/src/common/floating-controller.ts +263 -0
  53. package/src/common/slot.ts +24 -0
  54. package/src/components/mds-input-range/css/mds-input-range-disabled.css +9 -0
  55. package/src/components/mds-input-range/mds-input-range.css +12 -2
  56. package/src/components/mds-input-range/mds-input-range.tsx +23 -0
  57. package/src/components/mds-input-range/readme.md +7 -6
  58. package/src/components/mds-input-range/test/mds-input-range.stories.tsx +9 -0
  59. package/src/components.d.ts +8 -0
  60. package/src/dictionary/animation.ts +8 -0
  61. package/src/dictionary/file-extensions.ts +6 -60
  62. package/src/dictionary/tree.ts +21 -0
  63. package/src/fixtures/filenames.ts +63 -0
  64. package/src/fixtures/icons.json +21 -0
  65. package/src/fixtures/iconsauce.json +6 -0
  66. package/src/meta/file-format/locale.el.json +26 -21
  67. package/src/meta/file-format/locale.en.json +26 -21
  68. package/src/meta/file-format/locale.es.json +26 -21
  69. package/src/meta/file-format/locale.it.json +26 -21
  70. package/src/type/animation.ts +3 -0
  71. package/src/type/file-types.ts +6 -0
  72. package/src/type/tree.ts +12 -0
  73. package/src/type/variant-file-format.ts +6 -0
  74. package/www/build/mds-input-range.esm.js +1 -1
  75. package/www/build/mds-input-range.js +1 -1
  76. package/www/build/p-16118dde.system.entry.js +1 -0
  77. package/www/build/p-71d27af5.system.js +2 -0
  78. package/www/build/p-7a612415.system.js +1 -0
  79. package/www/build/p-8951c4d3.entry.js +1 -0
  80. package/www/build/p-dd7b28fc.js +2 -0
  81. package/dist/esm-es5/index-e0ac0a55.js +0 -1
  82. package/dist/mds-input-range/p-48fdc5db.system.entry.js +0 -1
  83. package/dist/mds-input-range/p-4e0b934e.system.js +0 -2
  84. package/dist/mds-input-range/p-76412b19.system.js +0 -1
  85. package/dist/mds-input-range/p-d697edb0.entry.js +0 -1
  86. package/dist/mds-input-range/p-f6cc8c2e.js +0 -2
  87. package/www/build/p-48fdc5db.system.entry.js +0 -1
  88. package/www/build/p-4e0b934e.system.js +0 -2
  89. package/www/build/p-76412b19.system.js +0 -1
  90. package/www/build/p-d697edb0.entry.js +0 -1
  91. package/www/build/p-f6cc8c2e.js +0 -2
@@ -1,8 +1,8 @@
1
1
  {
2
- "timestamp": "2024-12-04T15:30:05",
2
+ "timestamp": "2025-02-06T07:52:44",
3
3
  "compiler": {
4
4
  "name": "@stencil/core",
5
- "version": "4.22.2",
5
+ "version": "4.25.1",
6
6
  "typescriptVersion": "5.5.4"
7
7
  },
8
8
  "components": [
@@ -20,6 +20,32 @@
20
20
  ],
21
21
  "usage": {},
22
22
  "props": [
23
+ {
24
+ "name": "disabled",
25
+ "type": "boolean | undefined",
26
+ "complexType": {
27
+ "original": "boolean",
28
+ "resolved": "boolean | undefined",
29
+ "references": {}
30
+ },
31
+ "mutable": true,
32
+ "attr": "disabled",
33
+ "reflectToAttr": true,
34
+ "docs": "Sets if the component is disabled",
35
+ "docsTags": [],
36
+ "values": [
37
+ {
38
+ "type": "boolean"
39
+ },
40
+ {
41
+ "type": "undefined"
42
+ }
43
+ ],
44
+ "optional": true,
45
+ "required": false,
46
+ "getter": false,
47
+ "setter": false
48
+ },
23
49
  {
24
50
  "name": "max",
25
51
  "type": "number",
@@ -40,7 +66,9 @@
40
66
  }
41
67
  ],
42
68
  "optional": false,
43
- "required": false
69
+ "required": false,
70
+ "getter": false,
71
+ "setter": false
44
72
  },
45
73
  {
46
74
  "name": "min",
@@ -62,7 +90,9 @@
62
90
  }
63
91
  ],
64
92
  "optional": false,
65
- "required": false
93
+ "required": false,
94
+ "getter": false,
95
+ "setter": false
66
96
  },
67
97
  {
68
98
  "name": "step",
@@ -84,7 +114,9 @@
84
114
  }
85
115
  ],
86
116
  "optional": false,
87
- "required": false
117
+ "required": false,
118
+ "getter": false,
119
+ "setter": false
88
120
  },
89
121
  {
90
122
  "name": "value",
@@ -105,7 +137,9 @@
105
137
  }
106
138
  ],
107
139
  "optional": false,
108
- "required": false
140
+ "required": false,
141
+ "getter": false,
142
+ "setter": false
109
143
  }
110
144
  ],
111
145
  "methods": [],
@@ -292,6 +326,11 @@
292
326
  "docstring": "",
293
327
  "path": "src/type/button.ts"
294
328
  },
329
+ "src/type/text.ts::TypographyTruncateType": {
330
+ "declaration": "export type TypographyTruncateType =\n | 'all'\n | 'none'\n | 'word'",
331
+ "docstring": "",
332
+ "path": "src/type/text.ts"
333
+ },
295
334
  "src/type/variant.ts::ChipVariantType": {
296
335
  "declaration": "export type ChipVariantType =\n | 'primary'\n | 'secondary'\n | 'dark'\n | 'error'\n | 'info'\n | 'success'\n | 'warning'",
297
336
  "docstring": "",
@@ -323,7 +362,7 @@
323
362
  "path": "src/components/mds-dropdown/meta/event-detail.ts"
324
363
  },
325
364
  "src/type/file-types.ts::ExtensionSuffixType": {
326
- "declaration": "export type ExtensionSuffixType =\n | '7z'\n | 'ace'\n | 'ai'\n | 'db'\n | 'default'\n | 'dmg'\n | 'doc'\n | 'docm'\n | 'docx'\n | 'eml'\n | 'eps'\n | 'exe'\n | 'flac'\n | 'gif'\n | 'heic'\n | 'htm'\n | 'html'\n | 'jpe'\n | 'jpeg'\n | 'jpg'\n | 'js'\n | 'json'\n | 'jsx'\n | 'm2v'\n | 'mp2'\n | 'mp3'\n | 'mp4'\n | 'mp4v'\n | 'mpeg'\n | 'mpg'\n | 'mpg4'\n | 'mpga'\n | 'odp'\n | 'ods'\n | 'odt'\n | 'pdf'\n | 'php'\n | 'png'\n | 'ppt'\n | 'rar'\n | 'rtf'\n | 'sass'\n | 'shtml'\n | 'svg'\n | 'tar'\n | 'tiff'\n | 'ts'\n | 'txt'\n | 'wav'\n | 'webp'\n | 'xar'\n | 'xls'\n | 'xlsx'\n | 'zip'",
365
+ "declaration": "export type ExtensionSuffixType =\n | '7z'\n | 'ace'\n | 'ai'\n | 'db'\n | 'default'\n | 'dmg'\n | 'doc'\n | 'docm'\n | 'docx'\n | 'eml'\n | 'eps'\n | 'exe'\n | 'flac'\n | 'gif'\n | 'heic'\n | 'htm'\n | 'html'\n | 'jpe'\n | 'jpeg'\n | 'jpg'\n | 'js'\n | 'json'\n | 'jsx'\n | 'm2v'\n | 'mp2'\n | 'mp3'\n | 'mp4'\n | 'mp4v'\n | 'mpeg'\n | 'mpg'\n | 'mpg4'\n | 'mpga'\n | 'odf'\n | 'odp'\n | 'ods'\n | 'odt'\n | 'odt'\n | 'ole'\n | 'p7m'\n | 'pdf'\n | 'php'\n | 'png'\n | 'ppt'\n | 'rar'\n | 'rtf'\n | 'sass'\n | 'shtml'\n | 'svg'\n | 'tar'\n | 'tiff'\n | 'ts'\n | 'tsd'\n | 'txt'\n | 'wav'\n | 'webp'\n | 'xar'\n | 'xls'\n | 'xlsx'\n | 'xml'\n | 'zip'",
327
366
  "docstring": "",
328
367
  "path": "src/type/file-types.ts"
329
368
  },
@@ -332,11 +371,6 @@
332
371
  "docstring": "",
333
372
  "path": "src/components/mds-file/meta/event-detail.ts"
334
373
  },
335
- "src/type/text.ts::TypographyTruncateType": {
336
- "declaration": "export type TypographyTruncateType =\n | 'all'\n | 'none'\n | 'word'",
337
- "docstring": "",
338
- "path": "src/type/text.ts"
339
- },
340
374
  "src/components/mds-file-preview/meta/event-detail.ts::MdsFilePreviewEventDetail": {
341
375
  "declaration": "export interface MdsFilePreviewEventDetail {\n extension: string\n filename: string\n target: HTMLMdsFilePreviewElement\n}",
342
376
  "docstring": "",
@@ -562,11 +596,6 @@
562
596
  "docstring": "",
563
597
  "path": "src/components/mds-progress/meta/types.ts"
564
598
  },
565
- "src/type/date.ts::ISO8601Date": {
566
- "declaration": "type ISO8601Date = ISO8601DateFormat<string, 'ISO8601Date'>",
567
- "docstring": "",
568
- "path": "src/type/date.ts"
569
- },
570
599
  "src/components/mds-push-notification/meta/types.ts::NotificationDateFormatType": {
571
600
  "declaration": "string",
572
601
  "docstring": "",
@@ -597,6 +626,11 @@
597
626
  "docstring": "",
598
627
  "path": "src/components/mds-stepper-bar-item/meta/event-detail.ts"
599
628
  },
629
+ "src/type/animation.ts::HorizontalActionsAnimationType": {
630
+ "declaration": "export type HorizontalActionsAnimationType =\n | 'fade'\n | 'slide'",
631
+ "docstring": "",
632
+ "path": "src/type/animation.ts"
633
+ },
600
634
  "src/components/mds-tab/meta/event-detail.ts::MdsTabEventDetail": {
601
635
  "declaration": "export interface MdsTabEventDetail {\n id: number\n value?: string\n}",
602
636
  "docstring": "",
@@ -617,6 +651,16 @@
617
651
  "docstring": "",
618
652
  "path": "src/components/mds-tab-item/meta/event-detail.ts"
619
653
  },
654
+ "src/components/mds-table/meta/event-detail.ts::MdsTableSelectionEventDetail": {
655
+ "declaration": "export interface MdsTableSelectionEventDetail {\n rows: MdsTableRowSelection[]\n}",
656
+ "docstring": "",
657
+ "path": "src/components/mds-table/meta/event-detail.ts"
658
+ },
659
+ "src/components/mds-table/meta/type.ts::MdsTableRowSelection": {
660
+ "declaration": "{\n index: number\n value?: string | number\n}",
661
+ "docstring": "",
662
+ "path": "src/components/mds-table/meta/type.ts"
663
+ },
620
664
  "src/components/mds-table-header-cell/meta/types.ts::SortDirectionType": {
621
665
  "declaration": "export type SortDirectionType =\n | 'ascending'\n | 'descending'\n | 'none'",
622
666
  "docstring": "",
@@ -647,6 +691,26 @@
647
691
  "docstring": "",
648
692
  "path": "src/type/typography.ts"
649
693
  },
694
+ "src/type/tree.ts::TreeAppearance": {
695
+ "declaration": "export type TreeAppearance =\n | 'none'\n | 'depth'",
696
+ "docstring": "",
697
+ "path": "src/type/tree.ts"
698
+ },
699
+ "src/type/tree.ts::TreeIcon": {
700
+ "declaration": "export type TreeIcon =\n | 'folder'\n | 'chevron'",
701
+ "docstring": "",
702
+ "path": "src/type/tree.ts"
703
+ },
704
+ "src/type/tree.ts::TreeActions": {
705
+ "declaration": "export type TreeActions =\n | 'auto'\n | 'visible'",
706
+ "docstring": "",
707
+ "path": "src/type/tree.ts"
708
+ },
709
+ "src/components/mds-tree-item/meta/event-detail.ts::MdsTreeItemEventDetail": {
710
+ "declaration": "export interface MdsTreeItemEventDetail {\n element: HTMLMdsTreeItemElement\n}",
711
+ "docstring": "",
712
+ "path": "src/components/mds-tree-item/meta/event-detail.ts"
713
+ },
650
714
  "src/components/mds-usage/meta/types.ts::UsageType": {
651
715
  "declaration": "export type UsageType =\n | 'do'\n | 'dont'\n | 'info'\n | 'warn'",
652
716
  "docstring": "",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maggioli-design-system/mds-input-range",
3
- "version": "2.0.1",
3
+ "version": "2.1.1",
4
4
  "description": "mds-input-range is a web-component from Magma Design System, built with StencilJS, TypeScript, Storybook. It's based on the web-component standard and it's designed to be agnostic from the JavaScript framework you are using.",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.js",
@@ -24,9 +24,9 @@
24
24
  "test": "stencil test --spec --e2e"
25
25
  },
26
26
  "dependencies": {
27
- "@maggioli-design-system/styles": "15.5.0",
28
- "@maggioli-design-system/mds-text": "4.5.2",
29
- "@stencil/core": "4.22.2"
27
+ "@maggioli-design-system/styles": "15.7.0",
28
+ "@maggioli-design-system/mds-text": "4.5.3",
29
+ "@stencil/core": "4.25.1"
30
30
  },
31
31
  "license": "MIT",
32
32
  "author": {
package/readme.md CHANGED
@@ -9,12 +9,13 @@ This is a web-component from Maggioli Design System [Magma](https://magma.maggio
9
9
 
10
10
  ## Properties
11
11
 
12
- | Property | Attribute | Description | Type | Default |
13
- | -------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | -------- | ----------- |
14
- | `max` | `max` | The greatest value in the range of permitted values | `number` | `100` |
15
- | `min` | `min` | The lowest value in the range of permitted values | `number` | `0` |
16
- | `step` | `step` | The step attribute is a number that specifies the granularity that the value must adhere to, or the special value any, which is described below. | `number` | `1` |
17
- | `value` | `value` | The value attribute contains a number which contains a representation of the selected number. | `number` | `undefined` |
12
+ | Property | Attribute | Description | Type | Default |
13
+ | ---------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------- | ----------- |
14
+ | `disabled` | `disabled` | Sets if the component is disabled | `boolean \| undefined` | `undefined` |
15
+ | `max` | `max` | The greatest value in the range of permitted values | `number` | `100` |
16
+ | `min` | `min` | The lowest value in the range of permitted values | `number` | `0` |
17
+ | `step` | `step` | The step attribute is a number that specifies the granularity that the value must adhere to, or the special value any, which is described below. | `number` | `1` |
18
+ | `value` | `value` | The value attribute contains a number which contains a representation of the selected number. | `number` | `undefined` |
18
19
 
19
20
 
20
21
  ## Events
@@ -0,0 +1,263 @@
1
+ import {
2
+ arrow,
3
+ autoPlacement,
4
+ autoUpdate,
5
+ computePosition,
6
+ flip,
7
+ Middleware,
8
+ MiddlewareData,
9
+ offset,
10
+ shift,
11
+ } from '@floating-ui/dom'
12
+ import { FloatingUIPlacement, FloatingUIStrategy } from '@type/floating-ui'
13
+ import { cssDurationToMilliseconds } from './unit'
14
+ import { setAttributeIfEmpty } from './aria'
15
+ import { HTMLStencilElement } from '@stencil/core/internal'
16
+
17
+ export interface FloatingElement extends PositionOptions {
18
+ host: HTMLFloatingElement,
19
+ }
20
+
21
+ export interface HTMLFloatingElement extends HTMLStencilElement, PositionOptions {
22
+ visible: boolean,
23
+ }
24
+
25
+ export interface PositionOptions {
26
+ arrow: boolean;
27
+ arrowPadding: number;
28
+ autoPlacement: boolean;
29
+ flip: boolean;
30
+ offset: number;
31
+ placement: FloatingUIPlacement;
32
+ shift: boolean;
33
+ shiftPadding: number;
34
+ strategy: FloatingUIStrategy;
35
+ }
36
+
37
+ export class FloatingController {
38
+ private _caller: HTMLElement
39
+ private readonly _host: HTMLFloatingElement
40
+ arrowEl: HTMLElement | undefined
41
+
42
+ private cleanupAutoUpdate: () => void
43
+
44
+ constructor (host: HTMLFloatingElement, arrowEl?: HTMLElement) {
45
+ this._host = host
46
+ this.arrowEl = arrowEl
47
+ }
48
+
49
+ updateCaller (target: string): HTMLElement {
50
+ // search caller in document or rootNode of host (if target is in shadowDOM)
51
+ const caller = (this._host.parentElement?.shadowRoot?.querySelector(target) as HTMLElement) ??
52
+ ((this._host.getRootNode() as HTMLElement).querySelector(target) as HTMLElement)
53
+
54
+ if (!caller) {
55
+ throw Error(`Target not found: ${target}`)
56
+ }
57
+
58
+ this._caller = caller
59
+
60
+ setAttributeIfEmpty(this._caller, 'aria-haspopup', 'true')
61
+ setAttributeIfEmpty(this._caller, 'aria-controls', target)
62
+ setAttributeIfEmpty(this._host, 'role', 'menu')
63
+ setAttributeIfEmpty(this._host, 'aria-labelledby', target)
64
+ return caller
65
+ }
66
+
67
+ private readonly arrowInset = (
68
+ middleware: MiddlewareData,
69
+ arrowPosition: string,
70
+ ): { bottom?: string; left?: string; right?: string; top?: string } => {
71
+ const { arrow } = middleware
72
+ const inset = { bottom: '', left: '', right: '', top: '' }
73
+
74
+ if (arrow === undefined) {
75
+ return {}
76
+ }
77
+
78
+ switch (arrowPosition) {
79
+ case 'bottom':
80
+ inset.left = arrow.x !== null ? `${arrow.x}px` : ''
81
+ inset.top = '100%'
82
+ break
83
+ case 'left':
84
+ inset.right = '100%'
85
+ inset.top = arrow.y !== null ? `${arrow.y}px` : ''
86
+ break
87
+ case 'right':
88
+ inset.left = '100%'
89
+ inset.top = arrow.y !== null ? `${arrow.y}px` : ''
90
+ break
91
+ case 'top':
92
+ inset.left = arrow.x !== null ? `${arrow.x}px` : ''
93
+ inset.top = ''
94
+ break
95
+ default:
96
+ break
97
+ }
98
+ return inset
99
+ }
100
+
101
+ private readonly arrowTransform = (
102
+ arrowPosition: string,
103
+ ): { transform: string } => {
104
+ let transformProps = this._host.arrow && this._host.visible ? 'scale(1)' : 'scale(0)'
105
+ switch (arrowPosition) {
106
+ case 'bottom':
107
+ transformProps = `rotate(180deg) ${transformProps} translate(0, -100%)`
108
+ break
109
+ case 'left':
110
+ transformProps = `rotate(-90deg) ${transformProps} translate(50%, -50%)`
111
+ break
112
+ case 'right':
113
+ transformProps = `rotate(90deg) ${transformProps} translate(-50%, -50%)`
114
+ break
115
+ case 'top':
116
+ transformProps = `rotate(0deg) ${transformProps} translate(0, 0)`
117
+ break
118
+ default:
119
+ break
120
+ }
121
+ return { transform: transformProps }
122
+ }
123
+
124
+ private readonly arrowTransformOrigin = (
125
+ arrowPosition: string,
126
+ ): { transformOrigin: string } => {
127
+ switch (arrowPosition) {
128
+ case 'bottom':
129
+ return { transformOrigin: 'center top' }
130
+ case 'left':
131
+ return { transformOrigin: 'right center' }
132
+ case 'right':
133
+ return { transformOrigin: 'left center' }
134
+ case 'top':
135
+ return { transformOrigin: 'center bottom' }
136
+ default:
137
+ return { transformOrigin: 'center top' }
138
+ }
139
+ }
140
+
141
+ private readonly calculatePosition = (): void => {
142
+ if (!this._caller) return
143
+
144
+ const middleware: Middleware[] = new Array<Middleware>()
145
+ const config: { padding?: number } = {}
146
+
147
+ if (this._host.shiftPadding) {
148
+ config.padding = this._host.shiftPadding
149
+ }
150
+
151
+ if (this._host.autoPlacement) {
152
+ middleware.push(autoPlacement())
153
+ }
154
+
155
+ if (this._host.offset) {
156
+ middleware.push(offset(this._host.offset))
157
+ }
158
+
159
+ if (!this._host.autoPlacement && this._host.flip) {
160
+ middleware.push(flip(config))
161
+ }
162
+
163
+ if (this._host.shift) {
164
+ middleware.push(shift(config))
165
+ }
166
+
167
+ if (this.arrowEl && this._host.arrow) {
168
+ middleware.push(
169
+ arrow({
170
+ element: this.arrowEl,
171
+ padding: this._host.arrowPadding,
172
+ }),
173
+ )
174
+ }
175
+
176
+ computePosition(this._caller, this._host, {
177
+ middleware,
178
+ placement: this._host.placement,
179
+ strategy: this._host.strategy,
180
+ }).then(({ x, y, placement, middlewareData }) => {
181
+ Object.assign(this._host.style, {
182
+ left: `${x}px`,
183
+ top: `${y}px`,
184
+ })
185
+
186
+ const arrowStyle = {}
187
+ const arrowPosition = {
188
+ top: 'bottom',
189
+ right: 'left',
190
+ bottom: 'top',
191
+ left: 'right',
192
+ }[placement.split('-')[0]]
193
+
194
+ if (arrowPosition && this.arrowEl) {
195
+ Object.assign(arrowStyle, this.arrowTransform(arrowPosition))
196
+ Object.assign(
197
+ arrowStyle,
198
+ this.arrowInset(middlewareData, arrowPosition),
199
+ )
200
+ Object.assign(arrowStyle, this.arrowTransformOrigin(arrowPosition))
201
+ Object.assign(this.arrowEl.style, arrowStyle)
202
+ }
203
+ })
204
+ }
205
+
206
+ updatePosition (): void {
207
+ if (this.cleanupAutoUpdate) this.cleanupAutoUpdate()
208
+ this.cleanupAutoUpdate = autoUpdate(this._caller, this._host, this.calculatePosition)
209
+ }
210
+
211
+ dismiss (): void {
212
+ this.cleanupAutoUpdate()
213
+ }
214
+ }
215
+
216
+ export class Backdrop {
217
+ private readonly defaultBackdropId = 'mds-backdrop'
218
+ private readonly backdropBackgroundVisible = 'rgba(var(--magma-backdrop-color, 0 0 0) / var(--magma-backdrop-opacity, 0.1))'
219
+ private readonly backdropBackgroundHidden = 'rgba(var(--magma-backdrop-color, 0 0 0) / 0)'
220
+
221
+ private readonly backdropId
222
+ private readonly cssBackdropZIndex
223
+ private readonly cssBackdropDuration
224
+
225
+ private backdropEl: HTMLElement
226
+ private backdropTimer: NodeJS.Timeout
227
+
228
+ constructor (backdropId?: string) {
229
+ this.backdropId = backdropId ?? this.defaultBackdropId
230
+ this.cssBackdropZIndex = `var(--${this.backdropId}-z-index)`
231
+ this.cssBackdropDuration = `var(--${this.backdropId}-duration)`
232
+ }
233
+
234
+ attachBackdrop (): void {
235
+ if (!this.backdropEl) {
236
+ this.backdropEl = document.createElement('div')
237
+ this.backdropEl.className = this.backdropId
238
+ this.backdropEl.style.inset = '0'
239
+ this.backdropEl.style.pointerEvents = 'none'
240
+ this.backdropEl.style.position = 'fixed'
241
+ this.backdropEl.style.transition = `background-color ${this.cssBackdropDuration} ease-out`
242
+ this.backdropEl.style.zIndex = this.cssBackdropZIndex
243
+ }
244
+ this.backdropEl.style.backgroundColor = this.backdropBackgroundHidden
245
+ document.body.appendChild(this.backdropEl)
246
+
247
+ clearTimeout(this.backdropTimer)
248
+ this.backdropTimer = setTimeout(() => {
249
+ this.backdropEl.style.backgroundColor = this.backdropBackgroundVisible
250
+ }, 1)
251
+ }
252
+
253
+ detachBackdrop (): void {
254
+ if (!this.backdropEl) {
255
+ return
256
+ }
257
+ this.backdropEl.style.backgroundColor = 'transparent'
258
+ clearTimeout(this.backdropTimer)
259
+ this.backdropTimer = setTimeout(() => {
260
+ this.backdropEl.remove()
261
+ }, cssDurationToMilliseconds(this.cssBackdropDuration))
262
+ }
263
+ }
@@ -0,0 +1,24 @@
1
+ const hasSlottedElements = (el: HTMLElement, name?: string): boolean => {
2
+ const query = name ? `slot[name="${name}"]` : 'slot:not([name])'
3
+
4
+ const slot: HTMLSlotElement = el.shadowRoot?.querySelector(query) as HTMLSlotElement
5
+ if (slot) {
6
+ return slot.assignedElements({ flatten: true }).length > 0
7
+ }
8
+ return false
9
+ }
10
+
11
+ const hasSlottedNodes = (el: HTMLElement, name?: string): boolean => {
12
+ const query = name ? `slot[name="${name}"]` : 'slot:not([name])'
13
+
14
+ const slot: HTMLSlotElement = el.shadowRoot?.querySelector(query) as HTMLSlotElement
15
+ if (slot) {
16
+ return slot.assignedNodes().length > 0
17
+ }
18
+ return false
19
+ }
20
+
21
+ export {
22
+ hasSlottedElements,
23
+ hasSlottedNodes,
24
+ }
@@ -0,0 +1,9 @@
1
+ :host([disabled]:not([disabled="false"])) {
2
+ --mds-input-range-thumb-background: var(--mds-input-range-thumb-background-disabled);
3
+ --mds-input-range-track-background: var(--mds-input-range-track-background-disabled);
4
+ --mds-input-range-track-progress-background: var(--mds-input-range-track-progress-background-disabled);
5
+ }
6
+
7
+ :host([disabled]:not([disabled="false"])) .field::-webkit-slider-thumb {
8
+ cursor: not-allowed;
9
+ }
@@ -17,12 +17,16 @@
17
17
  --mds-input-range-thumb-size: theme('spacing.400');
18
18
  --mds-input-range-thumb-background: theme('colors.variant-primary-04');
19
19
  --mds-input-range-thumb-shadow: 0 0 0 2px theme('colors.tone-neutral');
20
- --mds-input-range-track-background: theme('colors.tone-neutral-09');
20
+ --mds-input-range-track-background: theme('colors.tone-neutral-08');
21
21
  --mds-input-range-track-size: theme('spacing.200');
22
22
  --mds-input-range-track-progress-background: theme('colors.variant-primary-03');
23
+ --mds-input-range-thumb-background-disabled: theme('colors.tone-neutral-06');
24
+ --mds-input-range-track-background-disabled: theme('colors.tone-neutral-08');
25
+ --mds-input-range-track-progress-background-disabled: theme('colors.tone-neutral-06');
23
26
 
24
27
  @apply
25
- duration-200
28
+ duration-300
29
+ ease-in-out
26
30
  gap-100;
27
31
 
28
32
  display: grid;
@@ -80,6 +84,10 @@
80
84
  }
81
85
 
82
86
  .field::-webkit-slider-thumb {
87
+ @apply
88
+ ease-in-out
89
+ duration-300;
90
+
83
91
  appearance: none;
84
92
  background-color: var(--mds-input-range-thumb-background);
85
93
  border: 0;
@@ -89,6 +97,7 @@
89
97
  height: var(--mds-input-range-thumb-size);
90
98
  line-height: 0;
91
99
  transform: translate(0, -50%);
100
+ transition-property: background-color, box-shadow;
92
101
  width: var(--mds-input-range-thumb-size);
93
102
  }
94
103
 
@@ -131,6 +140,7 @@
131
140
  border-radius: var(--mds-input-range-track-size);
132
141
  }
133
142
 
143
+ @import './css/mds-input-range-disabled.css';
134
144
  @import './css/mds-input-range-pref-animation.css';
135
145
  @import './css/mds-input-range-pref-theme.css';
136
146
  @import './css/mds-input-range-pref-contrast.css';
@@ -34,6 +34,11 @@ export class MdsInputRange {
34
34
  */
35
35
  @Prop() readonly step: number = 1
36
36
 
37
+ /**
38
+ * Sets if the component is disabled
39
+ */
40
+ @Prop({ mutable: true, reflect: true }) disabled?: boolean
41
+
37
42
  /**
38
43
  * The value attribute contains a number which contains a representation of the selected number.
39
44
  */
@@ -62,6 +67,19 @@ export class MdsInputRange {
62
67
  // trigger valueChanged that update progress and emit event
63
68
  this.value = parseInt(this.inputElement.value)
64
69
  }
70
+
71
+ @Watch('disabled')
72
+ protected disabledChanged (newValue: boolean):void {
73
+ /**
74
+ * This is related to ALL disabled attributes set on Magma input components
75
+ * if solved, please check mds-button, mds-input, mds-input-*
76
+ * https://github.com/ionic-team/stencil/issues/5461
77
+ */
78
+ if (newValue) {
79
+ this.internals.setFormValue(null)
80
+ }
81
+ }
82
+
65
83
  @Watch('value')
66
84
  valueChanged (): void {
67
85
  this.inputElement.value = this.value.toString()
@@ -85,6 +103,10 @@ export class MdsInputRange {
85
103
  this.calculateProgress()
86
104
  }
87
105
 
106
+ formResetCallback (): void {
107
+ this.internals.setFormValue('')
108
+ }
109
+
88
110
  componentDidLoad (): void {
89
111
  this.label = this.element.textContent ?? ''
90
112
  this.inputElement = this.element.shadowRoot?.querySelector('.field') as HTMLInputElement
@@ -109,6 +131,7 @@ export class MdsInputRange {
109
131
  <input
110
132
  class="field"
111
133
  aria-label={this.label}
134
+ disabled={this.disabled}
112
135
  max={this.max}
113
136
  min={this.min}
114
137
  onInput={this.onInput}
@@ -7,12 +7,13 @@
7
7
 
8
8
  ## Properties
9
9
 
10
- | Property | Attribute | Description | Type | Default |
11
- | -------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | -------- | ----------- |
12
- | `max` | `max` | The greatest value in the range of permitted values | `number` | `100` |
13
- | `min` | `min` | The lowest value in the range of permitted values | `number` | `0` |
14
- | `step` | `step` | The step attribute is a number that specifies the granularity that the value must adhere to, or the special value any, which is described below. | `number` | `1` |
15
- | `value` | `value` | The value attribute contains a number which contains a representation of the selected number. | `number` | `undefined` |
10
+ | Property | Attribute | Description | Type | Default |
11
+ | ---------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------- | ----------- |
12
+ | `disabled` | `disabled` | Sets if the component is disabled | `boolean \| undefined` | `undefined` |
13
+ | `max` | `max` | The greatest value in the range of permitted values | `number` | `100` |
14
+ | `min` | `min` | The lowest value in the range of permitted values | `number` | `0` |
15
+ | `step` | `step` | The step attribute is a number that specifies the granularity that the value must adhere to, or the special value any, which is described below. | `number` | `1` |
16
+ | `value` | `value` | The value attribute contains a number which contains a representation of the selected number. | `number` | `undefined` |
16
17
 
17
18
 
18
19
  ## Events
@@ -3,6 +3,10 @@ import { h } from '@stencil/core'
3
3
  export default {
4
4
  title: 'Form / Range',
5
5
  argTypes: {
6
+ disabled: {
7
+ type: { name: 'boolean' },
8
+ description: 'Sets if the component is disabled',
9
+ },
6
10
  min: {
7
11
  type: { name: 'number' },
8
12
  description: 'The lowest value in the range of permitted values',
@@ -44,6 +48,11 @@ const HideHeaderTemplate = args =>
44
48
 
45
49
  export const Default = Template.bind({})
46
50
 
51
+ export const Disabled = Template.bind({})
52
+ Disabled.args = {
53
+ disabled: true,
54
+ }
55
+
47
56
  export const Min = Template.bind({})
48
57
  Min.args = {
49
58
  min: -100,