@limetech/lime-elements 38.23.5 → 38.24.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/CHANGELOG.md +9 -0
- package/dist/cjs/lime-elements.cjs.js +1 -1
- package/dist/cjs/limel-action-bar_2.cjs.entry.js +1 -1
- package/dist/cjs/limel-ai-avatar.cjs.entry.js +1 -1
- package/dist/cjs/limel-badge.cjs.entry.js +42 -0
- package/dist/cjs/limel-badge.cjs.entry.js.map +1 -0
- package/dist/cjs/limel-callout.cjs.entry.js +1 -1
- package/dist/cjs/limel-chart.cjs.entry.js +1 -1
- package/dist/cjs/limel-chip_2.cjs.entry.js +1 -1
- package/dist/cjs/limel-collapsible-section.cjs.entry.js +1 -1
- package/dist/cjs/limel-file-viewer.cjs.entry.js +1 -1
- package/dist/cjs/limel-file.cjs.entry.js +1 -1
- package/dist/cjs/limel-flatpickr-adapter.cjs.entry.js +1 -1
- package/dist/cjs/limel-linear-progress.cjs.entry.js +1 -1
- package/dist/cjs/{limel-portal_2.cjs.entry.js → limel-portal_3.cjs.entry.js} +107 -11
- package/dist/cjs/limel-portal_3.cjs.entry.js.map +1 -0
- package/dist/cjs/limel-profile-picture.cjs.entry.js +536 -0
- package/dist/cjs/limel-profile-picture.cjs.entry.js.map +1 -0
- package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js +1 -1
- package/dist/cjs/limel-snackbar.cjs.entry.js +1 -1
- package/dist/cjs/limel-table.cjs.entry.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{translations-2746c4c6.js → translations-7499f391.js} +25 -1
- package/dist/cjs/translations-7499f391.js.map +1 -0
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/profile-picture/profile-picture.css +255 -0
- package/dist/collection/components/profile-picture/profile-picture.js +554 -0
- package/dist/collection/components/profile-picture/profile-picture.js.map +1 -0
- package/dist/collection/translations/da.js +3 -0
- package/dist/collection/translations/da.js.map +1 -1
- package/dist/collection/translations/de.js +3 -0
- package/dist/collection/translations/de.js.map +1 -1
- package/dist/collection/translations/en.js +3 -0
- package/dist/collection/translations/en.js.map +1 -1
- package/dist/collection/translations/fi.js +3 -0
- package/dist/collection/translations/fi.js.map +1 -1
- package/dist/collection/translations/fr.js +3 -0
- package/dist/collection/translations/fr.js.map +1 -1
- package/dist/collection/translations/nl.js +3 -0
- package/dist/collection/translations/nl.js.map +1 -1
- package/dist/collection/translations/no.js +3 -0
- package/dist/collection/translations/no.js.map +1 -1
- package/dist/collection/translations/sv.js +3 -0
- package/dist/collection/translations/sv.js.map +1 -1
- package/dist/collection/util/image-resize.js +305 -0
- package/dist/collection/util/image-resize.js.map +1 -0
- package/dist/esm/lime-elements.js +1 -1
- package/dist/esm/limel-action-bar_2.entry.js +1 -1
- package/dist/esm/limel-ai-avatar.entry.js +1 -1
- package/dist/esm/limel-badge.entry.js +38 -0
- package/dist/esm/limel-badge.entry.js.map +1 -0
- package/dist/esm/limel-callout.entry.js +1 -1
- package/dist/esm/limel-chart.entry.js +1 -1
- package/dist/esm/limel-chip_2.entry.js +1 -1
- package/dist/esm/limel-collapsible-section.entry.js +1 -1
- package/dist/esm/limel-file-viewer.entry.js +1 -1
- package/dist/esm/limel-file.entry.js +1 -1
- package/dist/esm/limel-flatpickr-adapter.entry.js +1 -1
- package/dist/esm/limel-linear-progress.entry.js +1 -1
- package/dist/esm/{limel-portal_2.entry.js → limel-portal_3.entry.js} +107 -12
- package/dist/esm/limel-portal_3.entry.js.map +1 -0
- package/dist/esm/limel-profile-picture.entry.js +532 -0
- package/dist/esm/limel-profile-picture.entry.js.map +1 -0
- package/dist/esm/limel-prosemirror-adapter.entry.js +1 -1
- package/dist/esm/limel-snackbar.entry.js +1 -1
- package/dist/esm/limel-table.entry.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{translations-0c3c0779.js → translations-1d617679.js} +25 -1
- package/dist/esm/translations-1d617679.js.map +1 -0
- package/dist/lime-elements/lime-elements.esm.js +1 -1
- package/dist/lime-elements/lime-elements.esm.js.map +1 -1
- package/dist/lime-elements/{p-6edfe426.entry.js → p-011f5d81.entry.js} +2 -2
- package/dist/lime-elements/p-18a3c28a.entry.js +2 -0
- package/dist/lime-elements/p-18a3c28a.entry.js.map +1 -0
- package/dist/lime-elements/{p-8a7bc823.entry.js → p-20d1913a.entry.js} +2 -2
- package/dist/lime-elements/{p-244e13f5.entry.js → p-3f698d18.entry.js} +2 -2
- package/dist/lime-elements/{p-9abbe61a.entry.js → p-441c1eab.entry.js} +2 -2
- package/dist/lime-elements/{p-b957a3ca.entry.js → p-4558a60e.entry.js} +2 -2
- package/dist/lime-elements/p-58777116.js +2 -0
- package/dist/lime-elements/p-58777116.js.map +1 -0
- package/dist/lime-elements/{p-d7e93894.entry.js → p-597e6f79.entry.js} +2 -2
- package/dist/lime-elements/{p-208f87d2.entry.js → p-78abbc50.entry.js} +2 -2
- package/dist/lime-elements/p-7e3a4f49.entry.js +2 -0
- package/dist/lime-elements/p-7e3a4f49.entry.js.map +1 -0
- package/dist/lime-elements/{p-e4d64dd2.entry.js → p-8ae75f4a.entry.js} +2 -2
- package/dist/lime-elements/{p-5018673b.entry.js → p-99de518a.entry.js} +2 -2
- package/dist/lime-elements/p-b5a96409.entry.js +2 -0
- package/dist/lime-elements/p-b5a96409.entry.js.map +1 -0
- package/dist/lime-elements/{p-2173d6d5.entry.js → p-bd619d56.entry.js} +2 -2
- package/dist/lime-elements/{p-65d5d2fb.entry.js → p-bd6878ee.entry.js} +2 -2
- package/dist/lime-elements/{p-5bf57c21.entry.js → p-ce29c097.entry.js} +2 -2
- package/dist/lime-elements/{p-00aee6b6.entry.js → p-e7201ebd.entry.js} +2 -2
- package/dist/types/components/profile-picture/profile-picture.d.ts +126 -0
- package/dist/types/components.d.ts +203 -0
- package/dist/types/translations/da.d.ts +3 -0
- package/dist/types/translations/de.d.ts +3 -0
- package/dist/types/translations/en.d.ts +3 -0
- package/dist/types/translations/fi.d.ts +3 -0
- package/dist/types/translations/fr.d.ts +3 -0
- package/dist/types/translations/nl.d.ts +3 -0
- package/dist/types/translations/no.d.ts +3 -0
- package/dist/types/translations/sv.d.ts +3 -0
- package/dist/types/util/image-resize.d.ts +138 -0
- package/package.json +1 -1
- package/dist/cjs/limel-badge_2.cjs.entry.js +0 -138
- package/dist/cjs/limel-badge_2.cjs.entry.js.map +0 -1
- package/dist/cjs/limel-portal_2.cjs.entry.js.map +0 -1
- package/dist/cjs/translations-2746c4c6.js.map +0 -1
- package/dist/esm/limel-badge_2.entry.js +0 -133
- package/dist/esm/limel-badge_2.entry.js.map +0 -1
- package/dist/esm/limel-portal_2.entry.js.map +0 -1
- package/dist/esm/translations-0c3c0779.js.map +0 -1
- package/dist/lime-elements/p-29b1f083.entry.js +0 -2
- package/dist/lime-elements/p-29b1f083.entry.js.map +0 -1
- package/dist/lime-elements/p-c8825e88.js +0 -2
- package/dist/lime-elements/p-c8825e88.js.map +0 -1
- package/dist/lime-elements/p-fe7243c1.entry.js +0 -2
- package/dist/lime-elements/p-fe7243c1.entry.js.map +0 -1
- /package/dist/lime-elements/{p-6edfe426.entry.js.map → p-011f5d81.entry.js.map} +0 -0
- /package/dist/lime-elements/{p-8a7bc823.entry.js.map → p-20d1913a.entry.js.map} +0 -0
- /package/dist/lime-elements/{p-244e13f5.entry.js.map → p-3f698d18.entry.js.map} +0 -0
- /package/dist/lime-elements/{p-9abbe61a.entry.js.map → p-441c1eab.entry.js.map} +0 -0
- /package/dist/lime-elements/{p-b957a3ca.entry.js.map → p-4558a60e.entry.js.map} +0 -0
- /package/dist/lime-elements/{p-d7e93894.entry.js.map → p-597e6f79.entry.js.map} +0 -0
- /package/dist/lime-elements/{p-208f87d2.entry.js.map → p-78abbc50.entry.js.map} +0 -0
- /package/dist/lime-elements/{p-e4d64dd2.entry.js.map → p-8ae75f4a.entry.js.map} +0 -0
- /package/dist/lime-elements/{p-5018673b.entry.js.map → p-99de518a.entry.js.map} +0 -0
- /package/dist/lime-elements/{p-2173d6d5.entry.js.map → p-bd619d56.entry.js.map} +0 -0
- /package/dist/lime-elements/{p-65d5d2fb.entry.js.map → p-bd6878ee.entry.js.map} +0 -0
- /package/dist/lime-elements/{p-5bf57c21.entry.js.map → p-ce29c097.entry.js.map} +0 -0
- /package/dist/lime-elements/{p-00aee6b6.entry.js.map → p-e7201ebd.entry.js.map} +0 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Image resize utilities
|
|
3
|
+
*
|
|
4
|
+
* Overview
|
|
5
|
+
* --------
|
|
6
|
+
* This module provides a small, dependency-free utility to resize images on the client
|
|
7
|
+
* (in the browser) before uploading. It works by decoding an input `File` to an
|
|
8
|
+
* `ImageBitmap` (or falling back to an `HTMLImageElement`), drawing it onto a
|
|
9
|
+
* `Canvas`/`OffscreenCanvas` with the requested strategy (cover/contain), and
|
|
10
|
+
* then exporting the result to a new `File` with your preferred MIME type and
|
|
11
|
+
* quality.
|
|
12
|
+
*
|
|
13
|
+
* Why resize client-side?
|
|
14
|
+
* - Faster perceived uploads and lower bandwidth usage
|
|
15
|
+
* - Consistent avatar sizes and formats (e.g., JPEG 400x400)
|
|
16
|
+
* - No server-side transformation required for common cases
|
|
17
|
+
*
|
|
18
|
+
* Fit strategies
|
|
19
|
+
* - `cover` (default): The image is scaled to cover the target rectangle, and
|
|
20
|
+
* the excess parts are center-cropped. Good for avatars.
|
|
21
|
+
* - `contain`: The image is scaled to fit entirely within the target rectangle
|
|
22
|
+
* without cropping, letterboxing if needed. Good when you must preserve the
|
|
23
|
+
* entire image.
|
|
24
|
+
*
|
|
25
|
+
* Decoding & EXIF orientation
|
|
26
|
+
* EXIF orientation is a piece of metadata stored inside image files
|
|
27
|
+
* (usually JPEGs) that tells image renderer software how the image should be displayed
|
|
28
|
+
* i.e., whether it should be rotated or flipped. This meta data is normally added
|
|
29
|
+
* to photos by digital cameras and phones.
|
|
30
|
+
* - When available, `createImageBitmap(file, { imageOrientation: 'from-image' })`
|
|
31
|
+
* is used to automatically respect EXIF orientation.
|
|
32
|
+
* - If not available or it fails (e.g., unsupported format), we fall back to
|
|
33
|
+
* decoding via an `HTMLImageElement`.
|
|
34
|
+
*
|
|
35
|
+
* OffscreenCanvas
|
|
36
|
+
* - If the environment supports `OffscreenCanvas`, it will be used for the draw
|
|
37
|
+
* and encode operations for better performance in some cases. Otherwise, a
|
|
38
|
+
* regular `HTMLCanvasElement` is used.
|
|
39
|
+
*
|
|
40
|
+
* HEIC/HEIF notes
|
|
41
|
+
* - All major browsers except Safari lack native HEIC/HEIF decoding.
|
|
42
|
+
* In such cases the `resizeImage` function will throw when decoding fails.
|
|
43
|
+
* The caller should catch and fall back
|
|
44
|
+
* to using the original file or handle conversion on the server.
|
|
45
|
+
* - If we need guaranteed client-side HEIC->JPEG conversion, we must add a small
|
|
46
|
+
* library or WASM module; this utility intentionally avoids extra dependencies.
|
|
47
|
+
*
|
|
48
|
+
* Output type & quality
|
|
49
|
+
* - Default output is `image/jpeg` with `quality=0.85`, which is typically
|
|
50
|
+
* appropriate for avatars. You can switch to `image/png` to preserve
|
|
51
|
+
* transparency.
|
|
52
|
+
* - The output filename extension is adjusted to match the chosen MIME type by
|
|
53
|
+
* default (e.g., `.jpg` or `.png`). You can override naming via the `rename`
|
|
54
|
+
* option.
|
|
55
|
+
*
|
|
56
|
+
* Error handling
|
|
57
|
+
* - Throws if canvas/context cannot be created or if canvas->blob conversion fails.
|
|
58
|
+
* - Decoding failures (unsupported type) will throw; caller can try/catch and
|
|
59
|
+
* fall back to the original file.
|
|
60
|
+
*
|
|
61
|
+
* Performance tips
|
|
62
|
+
* - Keep target sizes reasonable (e.g., 256–1024 px) to avoid long processing
|
|
63
|
+
* times on modest devices.
|
|
64
|
+
* - JPEG with quality 0.8–0.9 often strikes a good balance between size and
|
|
65
|
+
* perceived quality for photos/avatars.
|
|
66
|
+
*
|
|
67
|
+
* Usage examples
|
|
68
|
+
* --------------
|
|
69
|
+
* Basic usage:
|
|
70
|
+
* ```ts
|
|
71
|
+
* import { resizeImage } from '@limetech/lime-elements/util/image-resize';
|
|
72
|
+
*
|
|
73
|
+
* const processed = await resizeImage(file, {
|
|
74
|
+
* width: 400,
|
|
75
|
+
* height: 400,
|
|
76
|
+
* fit: 'cover', // default; center-crops
|
|
77
|
+
* type: 'image/jpeg', // default
|
|
78
|
+
* quality: 0.85, // default
|
|
79
|
+
* });
|
|
80
|
+
* // Upload `processed` instead of the original file
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* With custom naming:
|
|
84
|
+
* ```ts
|
|
85
|
+
* const processed = await resizeImage(file, {
|
|
86
|
+
* width: 800,
|
|
87
|
+
* height: 800,
|
|
88
|
+
* fit: 'contain',
|
|
89
|
+
* type: 'image/png',
|
|
90
|
+
* rename: (name) => name.replace(/\.[^.]+$/, '') + '_resized.png',
|
|
91
|
+
* });
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* In a Stencil component (simplified):
|
|
95
|
+
* ```tsx
|
|
96
|
+
* private async handleFilesSelected(file: File) {
|
|
97
|
+
* try {
|
|
98
|
+
* const resized = await resizeImage(file, { width: 400, height: 400 });
|
|
99
|
+
* // build your FileInfo and emit
|
|
100
|
+
* } catch {
|
|
101
|
+
* // fall back to original
|
|
102
|
+
* }
|
|
103
|
+
* }
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
/**
|
|
107
|
+
* Options for client-side image resizing.
|
|
108
|
+
* @beta
|
|
109
|
+
*/
|
|
110
|
+
export type ResizeOptions = {
|
|
111
|
+
/** Target width in CSS pixels. */
|
|
112
|
+
width: number;
|
|
113
|
+
/** Target height in CSS pixels. */
|
|
114
|
+
height: number;
|
|
115
|
+
/** Fit strategy; defaults to 'cover'. */
|
|
116
|
+
fit?: 'cover' | 'contain';
|
|
117
|
+
/** Output MIME type; 'image/jpeg' by default. */
|
|
118
|
+
type?: 'image/jpeg' | 'image/png';
|
|
119
|
+
/** JPEG quality (0..1); used only for 'image/jpeg'. Defaults to 0.85. */
|
|
120
|
+
quality?: number;
|
|
121
|
+
/** Optional renaming function. Defaults to changing extension to match MIME. */
|
|
122
|
+
rename?: (originalName: string) => string;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Resize an image file on the client using Canvas/OffscreenCanvas.
|
|
126
|
+
* Returns a new File with the requested format and dimensions.
|
|
127
|
+
*
|
|
128
|
+
* Contract
|
|
129
|
+
* - Input: image `File`
|
|
130
|
+
* - Output: resized image as a new `File` with updated `type`, name, and size
|
|
131
|
+
* - Errors: may throw on decode failure or canvas export failure
|
|
132
|
+
*
|
|
133
|
+
* @beta
|
|
134
|
+
* @param file - The image file to resize.
|
|
135
|
+
* @param options - Configuration for the resize operation.
|
|
136
|
+
*/
|
|
137
|
+
export declare function resizeImage(file: File, options: ResizeOptions): Promise<File>;
|
|
138
|
+
//# sourceMappingURL=image-resize.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const index = require('./index-174a078a.js');
|
|
6
|
-
const format = require('./format-c8759d02.js');
|
|
7
|
-
const randomString = require('./random-string-27fb6c74.js');
|
|
8
|
-
require('./_commonjsHelpers-a5111d61.js');
|
|
9
|
-
|
|
10
|
-
const badgeCss = "@charset \"UTF-8\";:host([hidden]){display:none}:host(limel-badge){--limel-min-badge-size:1rem;display:inline-flex;justify-content:center;align-items:center;flex-shrink:0;min-height:var(--limel-min-badge-size);min-width:var(--limel-min-badge-size)}span{cursor:default;box-sizing:border-box;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;text-align:center;font-size:0.6875rem;line-height:var(--limel-min-badge-size);color:var(--badge-text-color, rgb(var(--contrast-1200)));border-radius:var(--limel-min-badge-size);max-height:var(--limel-min-badge-size);min-width:0.5rem;min-height:0.5rem;background-color:var(--badge-background-color, rgb(var(--contrast-500)))}span:not(:empty){min-width:var(--limel-min-badge-size);max-width:var(--badge-max-width, 2.75rem);padding:0 0.28125rem}:host(.has-large-label) span{cursor:help}";
|
|
11
|
-
|
|
12
|
-
const Badge = class {
|
|
13
|
-
constructor(hostRef) {
|
|
14
|
-
index.registerInstance(this, hostRef);
|
|
15
|
-
this.label = undefined;
|
|
16
|
-
}
|
|
17
|
-
render() {
|
|
18
|
-
return (index.h(index.Host, { title: this.labelIsLarge() ? this.label : '', class: {
|
|
19
|
-
'has-large-label': this.labelIsLarge(),
|
|
20
|
-
} }, index.h("span", null, this.renderLabel())));
|
|
21
|
-
}
|
|
22
|
-
renderLabel() {
|
|
23
|
-
if (typeof this.label === 'number') {
|
|
24
|
-
return format.abbreviate(this.label);
|
|
25
|
-
}
|
|
26
|
-
return this.label;
|
|
27
|
-
}
|
|
28
|
-
labelIsLarge() {
|
|
29
|
-
const largeNumericLabel = 999;
|
|
30
|
-
const largeStringLabel = 6;
|
|
31
|
-
if ((typeof this.label === 'number' &&
|
|
32
|
-
this.label > largeNumericLabel) ||
|
|
33
|
-
(typeof this.label === 'string' &&
|
|
34
|
-
this.label.length > largeStringLabel)) {
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
Badge.style = badgeCss;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
*
|
|
43
|
-
* @param id
|
|
44
|
-
* @param startingPoint
|
|
45
|
-
*/
|
|
46
|
-
function getOwnerElement(id, startingPoint) {
|
|
47
|
-
let element = startingPoint;
|
|
48
|
-
do {
|
|
49
|
-
element = element.parentNode;
|
|
50
|
-
} while (element &&
|
|
51
|
-
element.nodeType !== Node.DOCUMENT_FRAGMENT_NODE &&
|
|
52
|
-
element.nodeType !== Node.DOCUMENT_NODE);
|
|
53
|
-
return element === null || element === void 0 ? void 0 : element.getElementById(id);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const DEFAULT_DELAY_FOR_SHOWING = 500;
|
|
57
|
-
class TooltipTimer {
|
|
58
|
-
constructor(showCallback, hideCallback, delayForShowing = DEFAULT_DELAY_FOR_SHOWING) {
|
|
59
|
-
this.timerHandle = null;
|
|
60
|
-
this.showCallback = showCallback;
|
|
61
|
-
this.hideCallback = hideCallback;
|
|
62
|
-
this.delayForShowing = delayForShowing;
|
|
63
|
-
}
|
|
64
|
-
showAfterDelay() {
|
|
65
|
-
if (!this.timerHandle) {
|
|
66
|
-
this.timerHandle = setTimeout(this.showCallback, this.delayForShowing);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
hide() {
|
|
70
|
-
clearTimeout(this.timerHandle);
|
|
71
|
-
this.timerHandle = null;
|
|
72
|
-
this.hideCallback();
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const tooltipCss = ":host(limel-tooltip){position:absolute;pointer-events:none}";
|
|
77
|
-
|
|
78
|
-
const DEFAULT_MAX_LENGTH = 50;
|
|
79
|
-
const Tooltip = class {
|
|
80
|
-
constructor(hostRef) {
|
|
81
|
-
index.registerInstance(this, hostRef);
|
|
82
|
-
this.showTooltip = () => {
|
|
83
|
-
this.tooltipTimer.showAfterDelay();
|
|
84
|
-
};
|
|
85
|
-
this.hideTooltip = () => {
|
|
86
|
-
this.tooltipTimer.hide();
|
|
87
|
-
};
|
|
88
|
-
this.elementId = undefined;
|
|
89
|
-
this.label = undefined;
|
|
90
|
-
this.helperLabel = undefined;
|
|
91
|
-
this.maxlength = DEFAULT_MAX_LENGTH;
|
|
92
|
-
this.openDirection = 'top';
|
|
93
|
-
this.open = undefined;
|
|
94
|
-
this.portalId = randomString.createRandomString();
|
|
95
|
-
this.tooltipId = randomString.createRandomString();
|
|
96
|
-
this.tooltipTimer = new TooltipTimer(() => (this.open = true), () => (this.open = false));
|
|
97
|
-
}
|
|
98
|
-
connectedCallback() {
|
|
99
|
-
this.ownerElement = getOwnerElement(this.elementId, this.host);
|
|
100
|
-
this.setOwnerAriaLabel();
|
|
101
|
-
this.addListeners();
|
|
102
|
-
}
|
|
103
|
-
disconnectedCallback() {
|
|
104
|
-
this.removeListeners();
|
|
105
|
-
}
|
|
106
|
-
render() {
|
|
107
|
-
const tooltipZIndex = getComputedStyle(this.host).getPropertyValue('--tooltip-z-index');
|
|
108
|
-
return (index.h("div", { class: "trigger-anchor" }, index.h("limel-portal", { openDirection: this.openDirection, visible: this.open, containerId: this.portalId, containerStyle: {
|
|
109
|
-
'z-index': tooltipZIndex,
|
|
110
|
-
'pointer-events': 'none',
|
|
111
|
-
}, anchor: this.ownerElement }, index.h("limel-tooltip-content", { label: this.label, helperLabel: this.helperLabel, maxlength: this.maxlength, role: "tooltip", "aria-hidden": !this.open, id: this.tooltipId }))));
|
|
112
|
-
}
|
|
113
|
-
setOwnerAriaLabel() {
|
|
114
|
-
var _a;
|
|
115
|
-
(_a = this.ownerElement) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-describedby', this.tooltipId);
|
|
116
|
-
}
|
|
117
|
-
addListeners() {
|
|
118
|
-
var _a, _b, _c, _d;
|
|
119
|
-
(_a = this.ownerElement) === null || _a === void 0 ? void 0 : _a.addEventListener('mouseover', this.showTooltip);
|
|
120
|
-
(_b = this.ownerElement) === null || _b === void 0 ? void 0 : _b.addEventListener('mouseout', this.hideTooltip);
|
|
121
|
-
(_c = this.ownerElement) === null || _c === void 0 ? void 0 : _c.addEventListener('focus', this.showTooltip);
|
|
122
|
-
(_d = this.ownerElement) === null || _d === void 0 ? void 0 : _d.addEventListener('blur', this.hideTooltip);
|
|
123
|
-
}
|
|
124
|
-
removeListeners() {
|
|
125
|
-
var _a, _b, _c, _d;
|
|
126
|
-
(_a = this.ownerElement) === null || _a === void 0 ? void 0 : _a.removeEventListener('mouseover', this.showTooltip);
|
|
127
|
-
(_b = this.ownerElement) === null || _b === void 0 ? void 0 : _b.removeEventListener('mouseout', this.hideTooltip);
|
|
128
|
-
(_c = this.ownerElement) === null || _c === void 0 ? void 0 : _c.removeEventListener('focus', this.showTooltip);
|
|
129
|
-
(_d = this.ownerElement) === null || _d === void 0 ? void 0 : _d.removeEventListener('blur', this.hideTooltip);
|
|
130
|
-
}
|
|
131
|
-
get host() { return index.getElement(this); }
|
|
132
|
-
};
|
|
133
|
-
Tooltip.style = tooltipCss;
|
|
134
|
-
|
|
135
|
-
exports.limel_badge = Badge;
|
|
136
|
-
exports.limel_tooltip = Tooltip;
|
|
137
|
-
|
|
138
|
-
//# sourceMappingURL=limel-badge_2.cjs.entry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"file":"limel-badge.limel-tooltip.entry.cjs.js","mappings":";;;;;;;;;AAAA,MAAM,QAAQ,GAAG,i0BAAi0B;;MCgBr0B,KAAK;;;;;EAUP,MAAM;IACT,QACIA,QAACC,UAAI,IACD,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,GAAG,IAAI,CAAC,KAAK,GAAG,EAAE,EAC5C,KAAK,EAAE;QACH,iBAAiB,EAAE,IAAI,CAAC,YAAY,EAAE;OACzC,IAEDD,sBAAO,IAAI,CAAC,WAAW,EAAE,CAAQ,CAC9B,EACT;GACL;EAEO,WAAW;IACf,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAE;MAChC,OAAOE,iBAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KACjC;IAED,OAAO,IAAI,CAAC,KAAK,CAAC;GACrB;EAEO,YAAY;IAChB,MAAM,iBAAiB,GAAG,GAAG,CAAC;IAC9B,MAAM,gBAAgB,GAAG,CAAC,CAAC;IAC3B,IACI,CAAC,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ;MAC3B,IAAI,CAAC,KAAK,GAAG,iBAAiB;OACjC,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ;QAC3B,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,gBAAgB,CAAC,EAC3C;MACE,OAAO,IAAI,CAAC;KACf;GACJ;;;;AC1DL;;;;;SAKgB,eAAe,CAC3B,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,MAAA,IAAI,CAAC,YAAY,0CAAE,gBAAgB,CAAC,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IACnE,MAAA,IAAI,CAAC,YAAY,0CAAE,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAClE,MAAA,IAAI,CAAC,YAAY,0CAAE,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAC/D,MAAA,IAAI,CAAC,YAAY,0CAAE,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;GACjE;EAEO,eAAe;;IACnB,MAAA,IAAI,CAAC,YAAY,0CAAE,mBAAmB,CAAC,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IACtE,MAAA,IAAI,CAAC,YAAY,0CAAE,mBAAmB,CAAC,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IACrE,MAAA,IAAI,CAAC,YAAY,0CAAE,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAClE,MAAA,IAAI,CAAC,YAAY,0CAAE,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;GACpE;;;;;;;;","names":["h","Host","abbreviate","createRandomString"],"sources":["./src/components/badge/badge.scss?tag=limel-badge&encapsulation=shadow","./src/components/badge/badge.tsx","./src/components/tooltip/get-owner-element.tsx","./src/components/tooltip/tooltip-timer.ts","./src/components/tooltip/tooltip.scss?tag=limel-tooltip&encapsulation=shadow","./src/components/tooltip/tooltip.tsx"],"sourcesContent":["@use '../../style/functions';\n@use '../../style/mixins';\n\n/**\n * @prop --badge-background-color: badge background color\n * @prop --badge-text-color: badge text color\n * @prop --badge-max-width: maximum width of the badge, before its text gets truncated\n */\n\n:host([hidden]) {\n display: none;\n}\n\n:host(limel-badge) {\n --limel-min-badge-size: 1rem;\n display: inline-flex;\n justify-content: center;\n align-items: center;\n flex-shrink: 0;\n min-height: var(--limel-min-badge-size);\n min-width: var(--limel-min-badge-size);\n}\n\nspan {\n cursor: default;\n box-sizing: border-box;\n\n @include mixins.truncate-text;\n text-align: center;\n font-size: functions.pxToRem(11);\n line-height: var(--limel-min-badge-size);\n\n color: var(--badge-text-color, rgb(var(--contrast-1200)));\n\n border-radius: var(--limel-min-badge-size);\n max-height: var(--limel-min-badge-size);\n min-width: 0.5rem;\n min-height: 0.5rem;\n\n background-color: var(--badge-background-color, rgb(var(--contrast-500)));\n\n &:not(:empty) {\n min-width: var(\n --limel-min-badge-size\n ); // ensures that a badge with only one character rendered as perfect circle\n max-width: var(--badge-max-width, 2.75rem);\n padding: 0 functions.pxToRem(4.5);\n }\n}\n\n:host(.has-large-label) {\n span {\n cursor: help;\n }\n}\n","import { Component, Prop, h, Host } from '@stencil/core';\nimport { abbreviate } from './format';\n\n/**\n * The Badge component can be used to display a notification badge,\n * optionally with a number or a text label.\n *\n * @exampleComponent limel-example-badge\n * @exampleComponent limel-example-badge-number\n * @exampleComponent limel-example-badge-string\n */\n@Component({\n tag: 'limel-badge',\n styleUrl: 'badge.scss',\n shadow: true,\n})\nexport class Badge {\n /**\n * Label to display in the badge.\n * Numeric labels larger than 999 will be rounded and abbreviated.\n * String labels get truncated if their length is longer than\n * six characters.\n */\n @Prop({ reflect: true })\n public label?: number | string;\n\n public render() {\n return (\n <Host\n title={this.labelIsLarge() ? this.label : ''}\n class={{\n 'has-large-label': this.labelIsLarge(),\n }}\n >\n <span>{this.renderLabel()}</span>\n </Host>\n );\n }\n\n private renderLabel() {\n if (typeof this.label === 'number') {\n return abbreviate(this.label);\n }\n\n return this.label;\n }\n\n private labelIsLarge() {\n const largeNumericLabel = 999;\n const largeStringLabel = 6;\n if (\n (typeof this.label === 'number' &&\n this.label > largeNumericLabel) ||\n (typeof this.label === 'string' &&\n this.label.length > largeStringLabel)\n ) {\n return true;\n }\n }\n}\n","/**\n *\n * @param id\n * @param startingPoint\n */\nexport function getOwnerElement(\n id: string,\n startingPoint: Node\n): HTMLElement | undefined {\n let element: Node = startingPoint;\n\n do {\n element = element.parentNode;\n } while (\n element &&\n element.nodeType !== Node.DOCUMENT_FRAGMENT_NODE &&\n element.nodeType !== Node.DOCUMENT_NODE\n );\n\n return (element as ShadowRoot)?.getElementById(id);\n}\n","const DEFAULT_DELAY_FOR_SHOWING = 500;\n\nexport class TooltipTimer {\n private timerHandle: number | null = null;\n private showCallback: Function;\n private hideCallback: Function;\n private delayForShowing: number;\n\n constructor(\n showCallback: Function,\n hideCallback: Function,\n delayForShowing: number = DEFAULT_DELAY_FOR_SHOWING\n ) {\n this.showCallback = showCallback;\n this.hideCallback = hideCallback;\n this.delayForShowing = delayForShowing;\n }\n\n showAfterDelay(): void {\n if (!this.timerHandle) {\n this.timerHandle = setTimeout(\n this.showCallback,\n this.delayForShowing\n );\n }\n }\n\n hide(): void {\n clearTimeout(this.timerHandle);\n this.timerHandle = null;\n this.hideCallback();\n }\n}\n","/**\n * @prop --tooltip-z-index: z-index of the tooltip.\n */\n\n:host(limel-tooltip) {\n // Absolutely positioning ensures that this invisible element\n // does not occupy visible space in the UI.\n // Without this, `limel-tooltip` could in many cases\n // mess up the layout, where it is used.\n // For example, inside a `grid` or `flex` section,\n // every instance of the tooltip would take some space,\n // creating gaps and empty holes.\n position: absolute;\n pointer-events: none;\n}\n","import { Component, h, Prop, Element, State } from '@stencil/core';\nimport { JSX } from 'react';\nimport { createRandomString } from '../../util/random-string';\nimport { OpenDirection } from '../menu/menu.types';\nimport { getOwnerElement } from './get-owner-element';\nimport { TooltipTimer } from './tooltip-timer';\n\nconst DEFAULT_MAX_LENGTH = 50;\n\n/**\n * A tooltip can be used to display a descriptive text for any element.\n * The displayed content must be a brief and supplemental string of text,\n * identifying the element or describing its function for the user,\n * helping them better understand unfamiliar objects that aren't described\n * directly in the UI.\n *\n * ## Interaction\n * The tooltip appears after a slight delay, when the element is hovered;\n * and disappears as soon as the cursor leaves the element.\n * Therefore, users cannot interact with the tip, but if the trigger element\n * itself is interactive, it will remain interactible even with a tooltip bound\n * to it.\n *\n * :::note\n * In order to display the tooltip, the tooltip element and its trigger element\n * must be within the same document or document fragment (the same shadowRoot).\n * Often, it's easiest to just place them next to each other like in the example\n * below, but if you need to, you can place them differently.\n *\n * ```html\n * <limel-button icon=\"search\" id=\"tooltip-example\" />\n * <limel-tooltip label=\"Search\" elementId=\"tooltip-example\" />\n * ```\n * :::\n *\n * ## Usage\n * - Keep in mind that tooltips can be distracting, and can be perceived as an interruption.\n * Use them only when they add significant value.\n * - A good tip is concise, helpful, and informative.\n * Don't explain the obvious or simply repeat what is already on the screen.\n * When used correctly, supplemental info of a tooltip helps to [declutter the UI](/#/DesignGuidelines/decluttering.md/).\n * - If the tip is essential to the primary tasks that the user is performing,\n * such as warnings or important notes, include the information directly in the\n * interface instead.\n * - When a component offers a helper text (e.g. [Input field](/#/component/limel-input-field/)),\n * use that, not a tooltip.\n * - Make sure to use the tooltip on an element that users naturally and\n * effortlessly recognize can be hovered.\n *\n * @exampleComponent limel-example-tooltip-basic\n * @exampleComponent limel-example-tooltip-max-character\n * @exampleComponent limel-example-tooltip-composite\n */\n@Component({\n tag: 'limel-tooltip',\n shadow: true,\n styleUrl: 'tooltip.scss',\n})\nexport class Tooltip {\n /**\n * ID of the owner element that the tooltip should describe.\n * Must be a child within the same document fragment as the tooltip element\n * itself.\n */\n @Prop({ reflect: true })\n public elementId!: string;\n\n /**\n * Short descriptive text of the owner element.\n */\n @Prop({ reflect: true })\n public label!: string;\n\n /**\n * Additional helper text for the element.\n * Example usage can be a keyboard shortcut to activate the function of the\n * owner element.\n */\n @Prop({ reflect: true })\n public helperLabel?: string;\n\n /**\n * The maximum amount of characters before rendering 'label' and\n * 'helperLabel' in two rows.\n */\n @Prop({ reflect: true })\n public maxlength?: number = DEFAULT_MAX_LENGTH;\n\n /**\n * Decides the tooltip's location in relation to its trigger.\n */\n @Prop({ reflect: true })\n public openDirection: OpenDirection = 'top';\n\n @Element()\n private host: HTMLLimelTooltipElement;\n\n @State()\n private open: boolean;\n\n private portalId: string;\n private tooltipId: string;\n private ownerElement: HTMLElement;\n private tooltipTimer: TooltipTimer;\n\n public constructor() {\n this.portalId = createRandomString();\n this.tooltipId = createRandomString();\n this.tooltipTimer = new TooltipTimer(\n () => (this.open = true),\n () => (this.open = false)\n );\n }\n\n public connectedCallback() {\n this.ownerElement = getOwnerElement(this.elementId, this.host);\n this.setOwnerAriaLabel();\n this.addListeners();\n }\n\n public disconnectedCallback() {\n this.removeListeners();\n }\n\n public render(): JSX.Element {\n const tooltipZIndex = getComputedStyle(this.host).getPropertyValue(\n '--tooltip-z-index'\n );\n\n return (\n <div class=\"trigger-anchor\">\n <limel-portal\n openDirection={this.openDirection}\n visible={this.open}\n containerId={this.portalId}\n containerStyle={{\n 'z-index': tooltipZIndex,\n 'pointer-events': 'none',\n }}\n anchor={this.ownerElement}\n >\n <limel-tooltip-content\n label={this.label}\n helperLabel={this.helperLabel}\n maxlength={this.maxlength}\n role=\"tooltip\"\n aria-hidden={!this.open}\n id={this.tooltipId}\n />\n </limel-portal>\n </div>\n );\n }\n\n private setOwnerAriaLabel() {\n this.ownerElement?.setAttribute('aria-describedby', this.tooltipId);\n }\n\n private addListeners() {\n this.ownerElement?.addEventListener('mouseover', this.showTooltip);\n this.ownerElement?.addEventListener('mouseout', this.hideTooltip);\n this.ownerElement?.addEventListener('focus', this.showTooltip);\n this.ownerElement?.addEventListener('blur', this.hideTooltip);\n }\n\n private removeListeners() {\n this.ownerElement?.removeEventListener('mouseover', this.showTooltip);\n this.ownerElement?.removeEventListener('mouseout', this.hideTooltip);\n this.ownerElement?.removeEventListener('focus', this.showTooltip);\n this.ownerElement?.removeEventListener('blur', this.hideTooltip);\n }\n\n private showTooltip = () => {\n this.tooltipTimer.showAfterDelay();\n };\n\n private hideTooltip = () => {\n this.tooltipTimer.hide();\n };\n}\n"],"version":3}
|