@maggioli-design-system/mds-input-tip 1.2.2 → 1.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.
- package/dist/cjs/{index-442db91d.js → index-66d8bb25.js} +143 -58
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/mds-input-tip.cjs.entry.js +8 -2
- package/dist/cjs/mds-input-tip.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/common/floating-controller.js +180 -0
- package/dist/collection/common/slot.js +28 -0
- package/dist/collection/common/string.js +30 -0
- package/dist/collection/components/mds-input-tip/mds-input-tip.css +123 -0
- package/dist/collection/components/mds-input-tip/mds-input-tip.js +10 -0
- package/dist/collection/dictionary/animation.js +5 -0
- package/dist/collection/dictionary/file-extensions.js +6 -59
- package/dist/collection/dictionary/keyboard.js +84 -0
- package/dist/collection/dictionary/tree.js +13 -0
- package/dist/collection/fixtures/filenames.js +62 -1
- package/dist/collection/type/animation.js +1 -0
- package/dist/collection/type/keyboard.js +1 -0
- package/dist/collection/type/tree.js +1 -0
- package/dist/collection/type/variant-file-format.js +5 -0
- package/dist/components/mds-input-tip.js +7 -1
- package/dist/documentation.d.ts +8 -0
- package/dist/documentation.json +15 -5
- package/dist/esm/{index-8fed469d.js → index-4e431d49.js} +143 -58
- package/dist/esm/loader.js +2 -2
- package/dist/esm/mds-input-tip.entry.js +8 -2
- package/dist/esm/mds-input-tip.js +3 -3
- package/dist/esm-es5/index-4e431d49.js +1 -0
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/mds-input-tip.entry.js +1 -1
- package/dist/esm-es5/mds-input-tip.js +1 -1
- package/dist/mds-input-tip/mds-input-tip.esm.js +1 -1
- package/dist/mds-input-tip/mds-input-tip.js +1 -1
- package/dist/mds-input-tip/p-27388d25.entry.js +1 -0
- package/dist/mds-input-tip/p-7eeec96b.system.js +2 -0
- package/dist/mds-input-tip/p-b8376582.js +2 -0
- package/dist/mds-input-tip/{p-c915dfb3.system.js → p-c7ede63a.system.js} +1 -1
- package/dist/mds-input-tip/p-d876075e.system.entry.js +1 -0
- package/dist/stats.json +74 -37
- package/dist/types/common/floating-controller.d.ts +46 -0
- package/dist/types/common/slot.d.ts +4 -0
- package/dist/types/common/string.d.ts +4 -0
- package/dist/types/dictionary/animation.d.ts +2 -0
- package/dist/types/dictionary/keyboard.d.ts +2 -0
- package/dist/types/dictionary/tree.d.ts +4 -0
- package/dist/types/fixtures/filenames.d.ts +62 -1
- package/dist/types/type/animation.d.ts +1 -0
- package/dist/types/type/file-types.d.ts +1 -1
- package/dist/types/type/keyboard.d.ts +12 -0
- package/dist/types/type/tree.d.ts +3 -0
- package/dist/types/type/variant-file-format.d.ts +1 -1
- package/documentation.json +76 -16
- package/package.json +4 -4
- package/readme.md +7 -0
- package/src/common/floating-controller.ts +263 -0
- package/src/common/slot.ts +35 -0
- package/src/common/string.ts +42 -0
- package/src/components/mds-input-tip/mds-input-tip.css +5 -0
- package/src/components/mds-input-tip/readme.md +7 -0
- package/src/dictionary/animation.ts +8 -0
- package/src/dictionary/file-extensions.ts +6 -60
- package/src/dictionary/keyboard.ts +87 -0
- package/src/dictionary/tree.ts +21 -0
- package/src/fixtures/filenames.ts +63 -0
- package/src/fixtures/icons.json +39 -1
- package/src/fixtures/iconsauce.json +6 -0
- package/src/meta/file-format/locale.el.json +26 -21
- package/src/meta/file-format/locale.en.json +26 -21
- package/src/meta/file-format/locale.es.json +26 -21
- package/src/meta/file-format/locale.it.json +26 -21
- package/src/meta/keyboard/keys.json +83 -0
- package/src/tailwind/components.css +11 -0
- package/src/tailwind/fouc.css +118 -0
- package/src/type/animation.ts +3 -0
- package/src/type/file-types.ts +6 -0
- package/src/type/keyboard.ts +93 -0
- package/src/type/tree.ts +12 -0
- package/src/type/variant-file-format.ts +6 -0
- package/www/build/mds-input-tip.esm.js +1 -1
- package/www/build/mds-input-tip.js +1 -1
- package/www/build/p-27388d25.entry.js +1 -0
- package/www/build/p-7eeec96b.system.js +2 -0
- package/www/build/p-b8376582.js +2 -0
- package/www/build/{p-c915dfb3.system.js → p-c7ede63a.system.js} +1 -1
- package/www/build/p-d876075e.system.entry.js +1 -0
- package/dist/esm-es5/index-8fed469d.js +0 -1
- package/dist/mds-input-tip/p-37c61f56.system.js +0 -2
- package/dist/mds-input-tip/p-3e967425.js +0 -2
- package/dist/mds-input-tip/p-4486a5e4.entry.js +0 -1
- package/dist/mds-input-tip/p-fadf816e.system.entry.js +0 -1
- package/www/build/p-37c61f56.system.js +0 -2
- package/www/build/p-3e967425.js +0 -2
- package/www/build/p-4486a5e4.entry.js +0 -1
- package/www/build/p-fadf816e.system.entry.js +0 -1
package/documentation.json
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
{
|
2
|
-
"timestamp": "
|
2
|
+
"timestamp": "2025-02-25T13:09:05",
|
3
3
|
"compiler": {
|
4
4
|
"name": "@stencil/core",
|
5
|
-
"version": "4.
|
5
|
+
"version": "4.25.1",
|
6
6
|
"typescriptVersion": "5.5.4"
|
7
7
|
},
|
8
8
|
"components": [
|
@@ -38,7 +38,9 @@
|
|
38
38
|
}
|
39
39
|
],
|
40
40
|
"optional": true,
|
41
|
-
"required": false
|
41
|
+
"required": false,
|
42
|
+
"getter": false,
|
43
|
+
"setter": false
|
42
44
|
},
|
43
45
|
{
|
44
46
|
"name": "position",
|
@@ -74,13 +76,21 @@
|
|
74
76
|
}
|
75
77
|
],
|
76
78
|
"optional": true,
|
77
|
-
"required": false
|
79
|
+
"required": false,
|
80
|
+
"getter": false,
|
81
|
+
"setter": false
|
78
82
|
}
|
79
83
|
],
|
80
84
|
"methods": [],
|
81
85
|
"events": [],
|
82
86
|
"listeners": [],
|
83
|
-
"styles": [
|
87
|
+
"styles": [
|
88
|
+
{
|
89
|
+
"name": "--mds-input-tip-active-translate",
|
90
|
+
"annotation": "prop",
|
91
|
+
"docs": "Set the translate of the tip when it is active."
|
92
|
+
}
|
93
|
+
],
|
84
94
|
"slots": [],
|
85
95
|
"parts": [],
|
86
96
|
"dependents": [
|
@@ -219,6 +229,11 @@
|
|
219
229
|
"docstring": "",
|
220
230
|
"path": "src/type/button.ts"
|
221
231
|
},
|
232
|
+
"src/type/text.ts::TypographyTruncateType": {
|
233
|
+
"declaration": "export type TypographyTruncateType =\n | 'all'\n | 'none'\n | 'word'",
|
234
|
+
"docstring": "",
|
235
|
+
"path": "src/type/text.ts"
|
236
|
+
},
|
222
237
|
"src/type/variant.ts::ChipVariantType": {
|
223
238
|
"declaration": "export type ChipVariantType =\n | 'primary'\n | 'secondary'\n | 'dark'\n | 'error'\n | 'info'\n | 'success'\n | 'warning'",
|
224
239
|
"docstring": "",
|
@@ -250,7 +265,7 @@
|
|
250
265
|
"path": "src/components/mds-dropdown/meta/event-detail.ts"
|
251
266
|
},
|
252
267
|
"src/type/file-types.ts::ExtensionSuffixType": {
|
253
|
-
"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'",
|
268
|
+
"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'",
|
254
269
|
"docstring": "",
|
255
270
|
"path": "src/type/file-types.ts"
|
256
271
|
},
|
@@ -259,11 +274,6 @@
|
|
259
274
|
"docstring": "",
|
260
275
|
"path": "src/components/mds-file/meta/event-detail.ts"
|
261
276
|
},
|
262
|
-
"src/type/text.ts::TypographyTruncateType": {
|
263
|
-
"declaration": "export type TypographyTruncateType =\n | 'all'\n | 'none'\n | 'word'",
|
264
|
-
"docstring": "",
|
265
|
-
"path": "src/type/text.ts"
|
266
|
-
},
|
267
277
|
"src/components/mds-file-preview/meta/event-detail.ts::MdsFilePreviewEventDetail": {
|
268
278
|
"declaration": "export interface MdsFilePreviewEventDetail {\n extension: string\n filename: string\n target: HTMLMdsFilePreviewElement\n}",
|
269
279
|
"docstring": "",
|
@@ -294,6 +304,11 @@
|
|
294
304
|
"docstring": "",
|
295
305
|
"path": "src/components/mds-header/meta/event-detail.ts"
|
296
306
|
},
|
307
|
+
"src/components/mds-header/meta/event-detail.ts::MdsHeaderVisibilityEventDetail": {
|
308
|
+
"declaration": "export interface MdsHeaderVisibilityEventDetail {\n visibility: boolean\n}",
|
309
|
+
"docstring": "",
|
310
|
+
"path": "src/components/mds-header/meta/event-detail.ts"
|
311
|
+
},
|
297
312
|
"src/components/mds-horizontal-scroll/meta/types.ts::ViewportType": {
|
298
313
|
"declaration": "export type ViewportType =\n | 'all'\n | 'tv'\n | 'xlarge'\n | 'large'\n | 'wide'\n | 'desktop'\n | 'tablet'\n | 'none'",
|
299
314
|
"docstring": "",
|
@@ -409,6 +424,16 @@
|
|
409
424
|
"docstring": "",
|
410
425
|
"path": "src/components/mds-input-upload/meta/types.ts"
|
411
426
|
},
|
427
|
+
"src/components/mds-keyboard/meta/type.ts::KeyboardTest": {
|
428
|
+
"declaration": "export type KeyboardTest =\n | 'pass'\n | 'fail'",
|
429
|
+
"docstring": "",
|
430
|
+
"path": "src/components/mds-keyboard/meta/type.ts"
|
431
|
+
},
|
432
|
+
"src/type/keyboard.ts::KeyboardKeyName": {
|
433
|
+
"declaration": "export type KeyboardKeyName =\n | '0'\n | '1'\n | '2'\n | '3'\n | '4'\n | '5'\n | '6'\n | '7'\n | '8'\n | '9'\n | 'a'\n | 'alt'\n | 'altleft'\n | 'altright'\n | 'arrowdown'\n | 'arrowleft'\n | 'arrowright'\n | 'arrowup'\n | 'b'\n | 'backspace'\n | 'c'\n | 'capslock'\n | 'command'\n | 'commandleft'\n | 'commandright'\n | 'control'\n | 'controlleft'\n | 'controlright'\n | 'd'\n | 'delete'\n | 'e'\n | 'end'\n | 'enter'\n | 'escape'\n | 'f'\n | 'f1'\n | 'f10'\n | 'f11'\n | 'f12'\n | 'f2'\n | 'f3'\n | 'f4'\n | 'f5'\n | 'f6'\n | 'f7'\n | 'f8'\n | 'f9'\n | 'g'\n | 'h'\n | 'home'\n | 'i'\n | 'j'\n | 'k'\n | 'l'\n | 'm'\n | 'n'\n | 'o'\n | 'option'\n | 'optionleft'\n | 'optionright'\n | 'p'\n | 'pagedown'\n | 'pageup'\n | 'q'\n | 'r'\n | 's'\n | 'shift'\n | 'shiftleft'\n | 'shiftright'\n | 'space'\n | 't'\n | 'tab'\n | 'u'\n | 'v'\n | 'w'\n | 'windows'\n | 'windowsleft'\n | 'windowsright'\n | 'x'\n | 'y'\n | 'z'",
|
434
|
+
"docstring": "",
|
435
|
+
"path": "src/type/keyboard.ts"
|
436
|
+
},
|
412
437
|
"src/type/typography.ts::TypographyType": {
|
413
438
|
"declaration": "export type TypographyType =\n | 'action'\n | 'caption'\n | 'snippet'\n | 'detail'\n | 'h1'\n | 'h2'\n | 'h3'\n | 'h4'\n | 'h5'\n | 'h6'\n | 'hack'\n | 'label'\n | 'option'\n | 'paragraph'\n | 'tip'",
|
414
439
|
"docstring": "",
|
@@ -429,6 +454,11 @@
|
|
429
454
|
"docstring": "",
|
430
455
|
"path": "src/components/mds-modal/meta/types.ts"
|
431
456
|
},
|
457
|
+
"src/components/mds-modal/meta/types.ts::ModalOverflowType": {
|
458
|
+
"declaration": "export type ModalOverflowType =\n | 'auto'\n | 'manual'",
|
459
|
+
"docstring": "",
|
460
|
+
"path": "src/components/mds-modal/meta/types.ts"
|
461
|
+
},
|
432
462
|
"src/type/variant.ts::LabelVariantType": {
|
433
463
|
"declaration": "export type LabelVariantType =\n | 'amaranth'\n | 'aqua'\n | 'blue'\n | 'green'\n | 'lime'\n | 'orange'\n | 'orchid'\n | 'sky'\n | 'violet'\n | 'yellow'",
|
434
464
|
"docstring": "",
|
@@ -489,11 +519,6 @@
|
|
489
519
|
"docstring": "",
|
490
520
|
"path": "src/components/mds-progress/meta/types.ts"
|
491
521
|
},
|
492
|
-
"src/type/date.ts::ISO8601Date": {
|
493
|
-
"declaration": "type ISO8601Date = ISO8601DateFormat<string, 'ISO8601Date'>",
|
494
|
-
"docstring": "",
|
495
|
-
"path": "src/type/date.ts"
|
496
|
-
},
|
497
522
|
"src/components/mds-push-notification/meta/types.ts::NotificationDateFormatType": {
|
498
523
|
"declaration": "string",
|
499
524
|
"docstring": "",
|
@@ -524,6 +549,11 @@
|
|
524
549
|
"docstring": "",
|
525
550
|
"path": "src/components/mds-stepper-bar-item/meta/event-detail.ts"
|
526
551
|
},
|
552
|
+
"src/type/animation.ts::HorizontalActionsAnimationType": {
|
553
|
+
"declaration": "export type HorizontalActionsAnimationType =\n | 'fade'\n | 'slide'",
|
554
|
+
"docstring": "",
|
555
|
+
"path": "src/type/animation.ts"
|
556
|
+
},
|
527
557
|
"src/components/mds-tab/meta/event-detail.ts::MdsTabEventDetail": {
|
528
558
|
"declaration": "export interface MdsTabEventDetail {\n id: number\n value?: string\n}",
|
529
559
|
"docstring": "",
|
@@ -544,6 +574,16 @@
|
|
544
574
|
"docstring": "",
|
545
575
|
"path": "src/components/mds-tab-item/meta/event-detail.ts"
|
546
576
|
},
|
577
|
+
"src/components/mds-table/meta/event-detail.ts::MdsTableSelectionEventDetail": {
|
578
|
+
"declaration": "export interface MdsTableSelectionEventDetail {\n rows: MdsTableRowSelection[]\n}",
|
579
|
+
"docstring": "",
|
580
|
+
"path": "src/components/mds-table/meta/event-detail.ts"
|
581
|
+
},
|
582
|
+
"src/components/mds-table/meta/type.ts::MdsTableRowSelection": {
|
583
|
+
"declaration": "{\n index: number\n value?: string | number\n}",
|
584
|
+
"docstring": "",
|
585
|
+
"path": "src/components/mds-table/meta/type.ts"
|
586
|
+
},
|
547
587
|
"src/components/mds-table-header-cell/meta/types.ts::SortDirectionType": {
|
548
588
|
"declaration": "export type SortDirectionType =\n | 'ascending'\n | 'descending'\n | 'none'",
|
549
589
|
"docstring": "",
|
@@ -574,6 +614,26 @@
|
|
574
614
|
"docstring": "",
|
575
615
|
"path": "src/type/typography.ts"
|
576
616
|
},
|
617
|
+
"src/type/tree.ts::TreeAppearance": {
|
618
|
+
"declaration": "export type TreeAppearance =\n | 'none'\n | 'depth'",
|
619
|
+
"docstring": "",
|
620
|
+
"path": "src/type/tree.ts"
|
621
|
+
},
|
622
|
+
"src/type/tree.ts::TreeIcon": {
|
623
|
+
"declaration": "export type TreeIcon =\n | 'folder'\n | 'chevron'",
|
624
|
+
"docstring": "",
|
625
|
+
"path": "src/type/tree.ts"
|
626
|
+
},
|
627
|
+
"src/type/tree.ts::TreeActions": {
|
628
|
+
"declaration": "export type TreeActions =\n | 'auto'\n | 'visible'",
|
629
|
+
"docstring": "",
|
630
|
+
"path": "src/type/tree.ts"
|
631
|
+
},
|
632
|
+
"src/components/mds-tree-item/meta/event-detail.ts::MdsTreeItemEventDetail": {
|
633
|
+
"declaration": "export interface MdsTreeItemEventDetail {\n element: HTMLMdsTreeItemElement\n}",
|
634
|
+
"docstring": "",
|
635
|
+
"path": "src/components/mds-tree-item/meta/event-detail.ts"
|
636
|
+
},
|
577
637
|
"src/components/mds-usage/meta/types.ts::UsageType": {
|
578
638
|
"declaration": "export type UsageType =\n | 'do'\n | 'dont'\n | 'info'\n | 'warn'",
|
579
639
|
"docstring": "",
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@maggioli-design-system/mds-input-tip",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.3.0",
|
4
4
|
"description": "mds-input-tip 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/mds-input-tip-item": "1.
|
28
|
-
"@maggioli-design-system/styles": "15.
|
29
|
-
"@stencil/core": "4.
|
27
|
+
"@maggioli-design-system/mds-input-tip-item": "1.3.0",
|
28
|
+
"@maggioli-design-system/styles": "15.8.0",
|
29
|
+
"@stencil/core": "4.25.1"
|
30
30
|
},
|
31
31
|
"license": "MIT",
|
32
32
|
"author": {
|
package/readme.md
CHANGED
@@ -13,6 +13,13 @@
|
|
13
13
|
| `position` | `position` | Specifies the position of the element relative to its container | `"bottom" \| "top" \| undefined` | `'top'` |
|
14
14
|
|
15
15
|
|
16
|
+
## CSS Custom Properties
|
17
|
+
|
18
|
+
| Name | Description |
|
19
|
+
| ---------------------------------- | ----------------------------------------------- |
|
20
|
+
| `--mds-input-tip-active-translate` | Set the translate of the tip when it is active. |
|
21
|
+
|
22
|
+
|
16
23
|
## Dependencies
|
17
24
|
|
18
25
|
### Used by
|
@@ -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 = 'magma-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: string
|
222
|
+
private readonly cssBackdropZIndex: string
|
223
|
+
private readonly cssBackdropDuration: string
|
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, 4000)`
|
231
|
+
this.cssBackdropDuration = `var(--${this.backdropId}-animation-duration, 300ms)`
|
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,35 @@
|
|
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
|
+
const hasSlotted = (el: HTMLElement, name?: string): boolean => {
|
22
|
+
const query = name ? `slot[name="${name}"]` : 'slot:not([name])'
|
23
|
+
|
24
|
+
const slot: HTMLSlotElement = el.shadowRoot?.querySelector(query) as HTMLSlotElement
|
25
|
+
if (slot) {
|
26
|
+
return slot.assignedNodes().length > 0 || slot.assignedElements().length > 0
|
27
|
+
}
|
28
|
+
return false
|
29
|
+
}
|
30
|
+
|
31
|
+
export {
|
32
|
+
hasSlottedElements,
|
33
|
+
hasSlottedNodes,
|
34
|
+
hasSlotted,
|
35
|
+
}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
const levenshteinDistance = (a: string, b: string): number => {
|
2
|
+
const dp: number[][] = Array.from({ length: a.length + 1 }, (_, i) =>
|
3
|
+
// eslint-disable-next-line no-nested-ternary
|
4
|
+
Array.from({ length: b.length + 1 }, (_, j) => (i === 0 ? j : j === 0 ? i : 0)),
|
5
|
+
)
|
6
|
+
|
7
|
+
for (let i = 1; i <= a.length; i++) {
|
8
|
+
for (let j = 1; j <= b.length; j++) {
|
9
|
+
if (a[i - 1] === b[j - 1]) {
|
10
|
+
dp[i][j] = dp[i - 1][j - 1]
|
11
|
+
} else {
|
12
|
+
dp[i][j] = 1 + Math.min(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1])
|
13
|
+
}
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
return dp[a.length][b.length]
|
18
|
+
}
|
19
|
+
|
20
|
+
|
21
|
+
const closest = (input: string, validCodes: string[]): string => {
|
22
|
+
let [closest] = validCodes
|
23
|
+
let minDistance = levenshteinDistance(input, closest)
|
24
|
+
|
25
|
+
for (const code of validCodes) {
|
26
|
+
const distance = levenshteinDistance(input, code)
|
27
|
+
if (distance < minDistance) {
|
28
|
+
minDistance = distance
|
29
|
+
closest = code
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
return closest
|
34
|
+
}
|
35
|
+
|
36
|
+
const firstLetterUppercase = (str: string): string => str.charAt(0).toUpperCase() + str.slice(1)
|
37
|
+
|
38
|
+
export {
|
39
|
+
closest,
|
40
|
+
firstLetterUppercase,
|
41
|
+
levenshteinDistance,
|
42
|
+
}
|
@@ -1,5 +1,9 @@
|
|
1
1
|
@tailwind utilities;
|
2
2
|
|
3
|
+
/**
|
4
|
+
* @prop --mds-input-tip-active-translate: Set the translate of the tip when it is active.
|
5
|
+
*/
|
6
|
+
|
3
7
|
:host {
|
4
8
|
|
5
9
|
--mds-input-tip-active-translate: translate(0, 0);
|
@@ -52,3 +56,4 @@
|
|
52
56
|
}
|
53
57
|
|
54
58
|
@import './css/mds-input-tip-pref-animation.css';
|
59
|
+
@import '../../tailwind/fouc.css';
|
@@ -13,6 +13,13 @@
|
|
13
13
|
| `position` | `position` | Specifies the position of the element relative to its container | `"bottom" \| "top" \| undefined` | `'top'` |
|
14
14
|
|
15
15
|
|
16
|
+
## CSS Custom Properties
|
17
|
+
|
18
|
+
| Name | Description |
|
19
|
+
| ---------------------------------- | ----------------------------------------------- |
|
20
|
+
| `--mds-input-tip-active-translate` | Set the translate of the tip when it is active. |
|
21
|
+
|
22
|
+
|
16
23
|
----------------------------------------------
|
17
24
|
|
18
25
|
Built with love @ [Gruppo Maggioli](https://www.maggioli.com) from [R&D Department](https://www.maggioli.com/it-it/chi-siamo/ricerca-sviluppo)
|