@sula-tech/webcomponents 0.14.0 → 0.15.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/loader.cjs.js +1 -1
- package/dist/cjs/{sula-avatar_21.cjs.entry.js → sula-avatar_22.cjs.entry.js} +1932 -19
- package/dist/{esm/sula-avatar_21.entry.js.map → cjs/sula-avatar_22.cjs.entry.js.map} +1 -1
- package/dist/cjs/webcomponents.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +2 -1
- package/dist/collection/components/sula-avatar/sula-avatar.css +1 -1
- package/dist/collection/components/sula-dropdown/sula-dropdown.js +39 -17
- package/dist/collection/components/sula-dropdown/sula-dropdown.js.map +1 -1
- package/dist/collection/components/sula-dropdown/sula-dropdown.stories.js +16 -1
- package/dist/collection/components/sula-dropdown/sula-dropdown.stories.js.map +1 -1
- package/dist/collection/components/sula-icon/sula-icon.css +1 -1
- package/dist/collection/components/sula-tooltip/model/sula-tooltip.model.js +13 -0
- package/dist/collection/components/sula-tooltip/model/sula-tooltip.model.js.map +1 -0
- package/dist/collection/components/sula-tooltip/sula-tooltip.css +1 -0
- package/dist/collection/components/sula-tooltip/sula-tooltip.js +218 -0
- package/dist/collection/components/sula-tooltip/sula-tooltip.js.map +1 -0
- package/dist/collection/components/sula-tooltip/sula-tooltip.stories.js +179 -0
- package/dist/collection/components/sula-tooltip/sula-tooltip.stories.js.map +1 -0
- package/dist/components/{p-tr2oA4pB.js → p-BESq0oqe.js} +3 -3
- package/dist/components/{p-tr2oA4pB.js.map → p-BESq0oqe.js.map} +1 -1
- package/dist/components/{p-BlyFOqde.js → p-BznR9x_k.js} +3 -3
- package/dist/components/{p-BlyFOqde.js.map → p-BznR9x_k.js.map} +1 -1
- package/dist/components/sula-avatar.js +2 -2
- package/dist/components/sula-badge.js +1 -1
- package/dist/components/sula-breadcrumb.js +1 -1
- package/dist/components/sula-button.js +1 -1
- package/dist/components/sula-checkbox.js +1 -1
- package/dist/components/sula-chip.js +1 -1
- package/dist/components/sula-dropdown.js +21 -18
- package/dist/components/sula-dropdown.js.map +1 -1
- package/dist/components/sula-icon.js +1 -1
- package/dist/components/sula-modal.js +2 -2
- package/dist/components/sula-progress-bar.js +1 -1
- package/dist/components/sula-search-bar.js +1 -1
- package/dist/components/sula-segmented-control.js +1 -1
- package/dist/components/sula-tag.js +1 -1
- package/dist/components/sula-textfield.js +1 -1
- package/dist/components/sula-tiles.js +1 -1
- package/dist/components/sula-timeline-list.js +1 -1
- package/dist/components/sula-tooltip.d.ts +11 -0
- package/dist/components/sula-tooltip.js +1946 -0
- package/dist/components/sula-tooltip.js.map +1 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{sula-avatar_21.entry.js → sula-avatar_22.entry.js} +1932 -20
- package/dist/esm/sula-avatar_22.entry.js.map +1 -0
- package/dist/esm/webcomponents.js +1 -1
- package/dist/types/components/sula-dropdown/sula-dropdown.d.ts +5 -2
- package/dist/types/components/sula-dropdown/sula-dropdown.stories.d.ts +8 -0
- package/dist/types/components/sula-tooltip/model/sula-tooltip.model.d.ts +10 -0
- package/dist/types/components/sula-tooltip/sula-tooltip.d.ts +40 -0
- package/dist/types/components/sula-tooltip/sula-tooltip.stories.d.ts +105 -0
- package/dist/types/components.d.ts +63 -0
- package/dist/webcomponents/{p-01cb6887.entry.js → p-6dc2ae91.entry.js} +1906 -186
- package/dist/webcomponents/p-6dc2ae91.entry.js.map +1 -0
- package/dist/webcomponents/webcomponents.esm.js +9 -3
- package/package.json +2 -1
- package/dist/cjs/sula-avatar_21.cjs.entry.js.map +0 -1
- package/dist/webcomponents/p-01cb6887.entry.js.map +0 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export var SulaTooltipPosition;
|
|
2
|
+
(function (SulaTooltipPosition) {
|
|
3
|
+
SulaTooltipPosition["Top"] = "top";
|
|
4
|
+
SulaTooltipPosition["Bottom"] = "bottom";
|
|
5
|
+
SulaTooltipPosition["Left"] = "left";
|
|
6
|
+
SulaTooltipPosition["Right"] = "right";
|
|
7
|
+
})(SulaTooltipPosition || (SulaTooltipPosition = {}));
|
|
8
|
+
export var SulaTooltipTrigger;
|
|
9
|
+
(function (SulaTooltipTrigger) {
|
|
10
|
+
SulaTooltipTrigger["Icon"] = "icon";
|
|
11
|
+
SulaTooltipTrigger["Parent"] = "parent";
|
|
12
|
+
})(SulaTooltipTrigger || (SulaTooltipTrigger = {}));
|
|
13
|
+
//# sourceMappingURL=sula-tooltip.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sula-tooltip.model.js","sourceRoot":"","sources":["../../../../src/components/sula-tooltip/model/sula-tooltip.model.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,mBAKX;AALD,WAAY,mBAAmB;IAC7B,kCAAW,CAAA;IACX,wCAAiB,CAAA;IACjB,oCAAa,CAAA;IACb,sCAAe,CAAA;AACjB,CAAC,EALW,mBAAmB,KAAnB,mBAAmB,QAK9B;AAED,MAAM,CAAN,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,mCAAa,CAAA;IACb,uCAAiB,CAAA;AACnB,CAAC,EAHW,kBAAkB,KAAlB,kBAAkB,QAG7B","sourcesContent":["export enum SulaTooltipPosition {\n Top = 'top',\n Bottom = 'bottom',\n Left = 'left',\n Right = 'right',\n}\n\nexport enum SulaTooltipTrigger {\n Icon = 'icon',\n Parent = 'parent',\n}\n\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
*,:after,:before{--tw-ring-color:rgba(59,130,246,.5);--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(147,197,253,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: ;border:0 solid #e5e7eb;box-sizing:border-box}::backdrop{--tw-ring-color:rgba(59,130,246,.5);--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(147,197,253,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.17 | MIT License | https://tailwindcss.com*/:after,:before{--tw-content:""}:host,html{-webkit-text-size-adjust:100%;font-feature-settings:normal;-webkit-tap-highlight-color:transparent;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-variation-settings:normal;line-height:1.5;-moz-tab-size:4;tab-size:4}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-feature-settings:normal;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{font-feature-settings:inherit;color:inherit;font-family:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,fieldset,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]:where(:not([hidden=until-found])){display:none}.visible{visibility:visible}.absolute{position:absolute}.hidden{display:none}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.tooltip-arrow,.tooltip-arrow:before{height:8px;position:absolute;width:8px}.tooltip-arrow{visibility:hidden}.tooltip-arrow:before{background:var(--color-neutral-neutral-8);content:"";transform:rotate(45deg);visibility:visible}.hint-bubble[data-popper-placement^=top]>.tooltip-arrow{bottom:-4px}.hint-bubble[data-popper-placement^=bottom]>.tooltip-arrow{top:-4px}.hint-bubble[data-popper-placement^=left]>.tooltip-arrow{right:-4px}.hint-bubble[data-popper-placement^=right]>.tooltip-arrow{left:-4px}:root{--color-green-50:#f1f9f4;--color-green-100:#e6f4ed;--color-green-200:#cae7d8;--color-green-300:#a0d4b8;--color-green-400:#68bb8e;--color-green-500:#04843f;--color-green-600:#037236;--color-green-700:#03632f;--color-green-800:#035428;--color-green-900:#024521;--color-green-950:#012b15;--color-red-50:#fef6f6;--color-red-100:#fde8e8;--color-red-200:#fad1d1;--color-red-300:#f7abab;--color-red-400:#f17474;--color-red-500:#c80505;--color-red-600:#b30404;--color-red-700:#9f0404;--color-red-800:#860303;--color-red-900:#6d0303;--color-red-950:#330d00;--color-yellow-50:#fdf4e7;--color-yellow-100:#fcedd9;--color-yellow-200:#fae0bd;--color-yellow-300:#f6c788;--color-yellow-400:#f3b159;--color-yellow-500:#ef9928;--color-yellow-600:#e49226;--color-yellow-700:#d17e10;--color-yellow-800:#b46d0e;--color-yellow-900:#93590b;--color-yellow-950:#402705;--color-orange-50:#fef4f1;--color-orange-100:#fde8e2;--color-orange-200:#fbd2c6;--color-orange-300:#f8b4a0;--color-orange-400:#f58e70;--color-orange-500:#f05223;--color-orange-600:#ea4210;--color-orange-700:#d23b0e;--color-orange-800:#b5330c;--color-orange-900:#942a0a;--color-orange-950:#401204;--color-blue-50:#ecf0f9;--color-blue-100:#dde3f4;--color-blue-200:#b2c2e5;--color-blue-300:#7994d2;--color-blue-400:#4066bf;--color-blue-500:#001e64;--color-blue-600:#001c5c;--color-blue-700:#00174c;--color-blue-800:#00123d;--color-blue-900:#000f33;--color-blue-950:#000d2b;--color-ambar-50:#fff6eb;--color-ambar-100:#ffefdc;--color-ambar-200:#fedfb9;--color-ambar-300:#fdca8b;--color-ambar-400:#fdb359;--color-ambar-500:#fc9c26;--color-ambar-600:#ec8403;--color-ambar-700:#d87803;--color-ambar-800:#ba6803;--color-ambar-900:#975402;--color-ambar-950:#402301;--color-gray-50:#fff;--color-gray-100:#f3f4f4;--color-gray-200:#e5e6e6;--color-gray-300:#bfc0c0;--color-gray-400:#acaeae;--color-gray-500:#949595;--color-gray-600:#737575;--color-gray-700:#6c6e6e;--color-gray-800:#313333;--color-gray-900:#272929;--color-gray-950:#191d1d;--color-white-opacity-50:#ffffff0d;--color-white-opacity-100:#ffffff1a;--color-white-opacity-200:#ffffff26;--color-white-opacity-300:#ffffff45;--color-white-opacity-400:#ffffff5c;--color-white-opacity-500:#ffffff80;--color-white-opacity-600:#ffffff8c;--color-white-opacity-700:#ffffffa3;--color-white-opacity-800:#ffffffba;--color-white-opacity-900:#fffc;--color-white-opacity-950:#ffffffe8;--color-ciano-50:#f1f6fe;--color-ciano-100:#dfeafc;--color-ciano-200:#c3d9f9;--color-ciano-300:#90b9f4;--color-ciano-400:#5d98ee;--color-ciano-500:#1769e0;--color-ciano-600:#155fcb;--color-ciano-700:#1355b4;--color-ciano-800:#104899;--color-ciano-900:#0d3b7d;--color-ciano-950:#071e40;--color-extra-color-blue-light:#e7f0f4;--color-extra-color-blue-dark:#162931;--color-black-opacity-50:rgba(25,29,29,.02);--color-black-opacity-100:rgba(25,29,29,.05);--color-black-opacity-200:rgba(25,29,29,.11);--color-black-opacity-300:rgba(25,29,29,.28);--color-black-opacity-400:rgba(25,29,29,.36);--color-black-opacity-500:rgba(25,29,29,.44);--color-black-opacity-600:rgba(25,29,29,.62);--color-black-opacity-700:rgba(25,29,29,.64);--color-black-opacity-800:rgba(25,29,29,.72);--color-black-opacity-900:rgba(25,29,29,.8);--color-black-opacity-950:rgba(25,29,29,.96);--color-shadow-opacity-50:rgba(0,0,0,.04);--color-shadow-opacity-100:rgba(0,0,0,.06);--color-shadow-opacity-200:rgba(0,0,0,.12);--color-shadow-opacity-300:rgba(0,0,0,.2);--color-shadow-opacity-400:rgba(0,0,0,.32);--color-shadow-opacity-500:rgba(0,0,0,.5);--color-shadow-opacity-600:rgba(0,0,0,.55);--color-shadow-opacity-700:rgba(0,0,0,.64);--color-shadow-opacity-800:rgba(0,0,0,.73);--color-shadow-opacity-900:rgba(0,0,0,.8);--color-shadow-opacity-950:rgba(0,0,0,.91);--color-feedback-success:#04843f;--color-feedback-error:#c80505;--color-feedback-informational:#1355b4;--color-feedback-alert:#ef9928;--color-brand-primary:#f05223;--color-brand-secondary:#001c5c;--color-brand-tertiary-1:#1769e0;--color-brand-tertiary-2:#fc9c26;--color-surface-body:#fff;--color-surface-on-body:#f3f4f4;--color-surface-on-body-blue:#e7f0f4;--color-surface-on-body-brand:#fff6eb;--color-surface-on-body-feedback-success:#e6f4ed;--color-surface-on-body-feedback-error:#fde8e8;--color-surface-on-body-feedback-alert:#fdf4e7;--color-surface-on-body-feedback-info:#dfeafc;--color-text-brand:#f05223;--color-text-primary:#313333;--color-text-secondary:#6c6e6e;--color-text-disabled:#949595;--color-text-link:#1355b4;--color-states-empty-bg-hover:rgba(25,29,29,.05);--color-states-empty-bg-pressed:rgba(25,29,29,.11);--color-states-bg-disabled:rgba(25,29,29,.02);--color-states-bg-focus:#1355b4;--color-states-primary-hover:#ea4210;--color-states-primary-pressed:#d23b0e;--color-states-danger-hover:#b30404;--color-states-danger-pressed:#9f0404;--color-states-negative-hover:#e5e6e6;--color-states-negative-pressed:#bfc0c0;--color-icon-primary:#6c6e6e;--color-icon-secondary:#fff;--color-icon-tertiary:#b30404;--color-icon-disabled:#acaeae;--color-neutral-neutral-1:#fff;--color-neutral-neutral-2:#f3f4f4;--color-neutral-neutral-3:#acaeae;--color-neutral-neutral-4:#949595;--color-neutral-neutral-5:#737575;--color-neutral-neutral-6:#6c6e6e;--color-neutral-neutral-7:#313333;--color-neutral-neutral-8:#272929;--color-negative-negative-1:#fff;--color-negative-negative-2:#313333;--color-opacity-body:#fffc;--color-opacity-on-body:rgba(25,29,29,.02);--color-opacity-overlay:rgba(25,29,29,.62);--color-opacity-on-overlay:#ffffff1a;--color-line-input:#949595;--color-line-general-strong:#bfc0c0;--color-line-general:#e5e6e6;--color-line-hair:rgba(25,29,29,.05);--color-box-shadow-body:#fff;--color-box-shadow-shadow-color-1:rgba(0,0,0,.04);--color-box-shadow-shadow-color-2:rgba(0,0,0,.06)}.pointer-events-none{pointer-events:none}.invisible{visibility:hidden}.static{position:static}.fixed{position:fixed}.relative{position:relative}.inset-0{inset:0}.z-50{z-index:50}.box-border{box-sizing:border-box}.inline-block{display:inline-block}.flex{display:flex}.h-\[22px\]{height:22px}.h-full{height:100%}.w-\[22px\]{width:22px}.w-full{width:100%}.max-w-\[200px\]{max-width:200px}.cursor-pointer{cursor:pointer}.items-center{align-items:center}.justify-center{justify-content:center}.overflow-visible{overflow:visible}.break-words{overflow-wrap:break-word}.rounded{border-radius:.25rem}.rounded-full{border-radius:9999px}.border{border-width:1px}.border-solid{border-style:solid}.border-feedback-informational{border-color:var(--color-feedback-informational)}.border-transparent{border-color:transparent}.bg-neutral-neutral-8{background-color:var(--color-neutral-neutral-8)}.bg-transparent{background-color:transparent}.px-12{padding-left:.75rem;padding-right:.75rem}.py-8{padding-bottom:.5rem;padding-top:.5rem}.text-\[18px\]{font-size:18px}.text-sm{font-size:.875rem;line-height:1.25rem}.leading-\[0\]{line-height:0}.leading-none{line-height:1}.leading-normal{line-height:1.5}.text-icon-primary{color:var(--color-icon-primary)}.text-neutral-neutral-1{color:var(--color-neutral-neutral-1)}.opacity-0{opacity:0}.opacity-100{opacity:1}.shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.shadow,.shadow-\[0_4px_16px_rgba\(0\2c 0\2c 0\2c 0\.24\)\]{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-\[0_4px_16px_rgba\(0\2c 0\2c 0\2c 0\.24\)\]{--tw-shadow:0 4px 16px rgba(0,0,0,.24);--tw-shadow-colored:0 4px 16px var(--tw-shadow-color)}.ring{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.transition-opacity{transition-duration:.15s;transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1)}.duration-200{transition-duration:.2s}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { Host, h } from "@stencil/core";
|
|
2
|
+
import { createPopper } from "@popperjs/core";
|
|
3
|
+
import { SulaTooltipPosition, SulaTooltipTrigger } from "./model/sula-tooltip.model";
|
|
4
|
+
const MAX_TEXT_LENGTH = 300;
|
|
5
|
+
export class SulaTooltip {
|
|
6
|
+
constructor() {
|
|
7
|
+
/**
|
|
8
|
+
* Tooltip position relative to trigger
|
|
9
|
+
*/
|
|
10
|
+
this.position = SulaTooltipPosition.Top;
|
|
11
|
+
this.icon = 'ph ph-info';
|
|
12
|
+
/**
|
|
13
|
+
* When true, renders a focus ring (21.5×21.5px, 1px border) around the icon.
|
|
14
|
+
*/
|
|
15
|
+
this.focused = false;
|
|
16
|
+
/**
|
|
17
|
+
* Trigger mode.
|
|
18
|
+
* - `'icon'` (default): the built-in info icon is the hover target.
|
|
19
|
+
* - `'parent'`: the icon is hidden; the component stretches to fill the
|
|
20
|
+
* parent element (which **must** have `position: relative`) and the hint
|
|
21
|
+
* appears on hover of that parent.
|
|
22
|
+
*/
|
|
23
|
+
this.trigger = SulaTooltipTrigger.Icon;
|
|
24
|
+
this.isVisible = false;
|
|
25
|
+
this.parentEl = null;
|
|
26
|
+
this.hintEl = null;
|
|
27
|
+
this.triggerEl = null;
|
|
28
|
+
this.arrowEl = null;
|
|
29
|
+
this.popperInstance = null;
|
|
30
|
+
this.handleMouseEnter = () => {
|
|
31
|
+
var _a;
|
|
32
|
+
this.isVisible = true;
|
|
33
|
+
(_a = this.popperInstance) === null || _a === void 0 ? void 0 : _a.update();
|
|
34
|
+
};
|
|
35
|
+
this.handleMouseLeave = () => {
|
|
36
|
+
this.isVisible = false;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
componentDidLoad() {
|
|
40
|
+
if (this.trigger === SulaTooltipTrigger.Parent) {
|
|
41
|
+
this.parentEl = this.el.parentElement;
|
|
42
|
+
if (this.parentEl) {
|
|
43
|
+
this.parentEl.addEventListener('mouseenter', this.handleMouseEnter);
|
|
44
|
+
this.parentEl.addEventListener('mouseleave', this.handleMouseLeave);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
this.initPopper();
|
|
48
|
+
}
|
|
49
|
+
disconnectedCallback() {
|
|
50
|
+
if (this.parentEl) {
|
|
51
|
+
this.parentEl.removeEventListener('mouseenter', this.handleMouseEnter);
|
|
52
|
+
this.parentEl.removeEventListener('mouseleave', this.handleMouseLeave);
|
|
53
|
+
this.parentEl = null;
|
|
54
|
+
}
|
|
55
|
+
if (this.popperInstance) {
|
|
56
|
+
this.popperInstance.destroy();
|
|
57
|
+
this.popperInstance = null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
initPopper() {
|
|
61
|
+
const reference = this.trigger === SulaTooltipTrigger.Parent ? this.el.parentElement : this.triggerEl;
|
|
62
|
+
if (!reference || !this.hintEl)
|
|
63
|
+
return;
|
|
64
|
+
if (this.popperInstance) {
|
|
65
|
+
this.popperInstance.destroy();
|
|
66
|
+
}
|
|
67
|
+
this.popperInstance = createPopper(reference, this.hintEl, {
|
|
68
|
+
placement: this.position,
|
|
69
|
+
strategy: 'fixed',
|
|
70
|
+
modifiers: [
|
|
71
|
+
{ name: 'offset', options: { offset: [0, 8] } },
|
|
72
|
+
{ name: 'arrow', options: { element: this.arrowEl } },
|
|
73
|
+
{ name: 'preventOverflow', options: { padding: 8 } },
|
|
74
|
+
{ name: 'flip' },
|
|
75
|
+
],
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
get displayText() {
|
|
79
|
+
if (!this.text)
|
|
80
|
+
return '';
|
|
81
|
+
return this.text.length > MAX_TEXT_LENGTH
|
|
82
|
+
? this.text.slice(0, MAX_TEXT_LENGTH)
|
|
83
|
+
: this.text;
|
|
84
|
+
}
|
|
85
|
+
getIconClasses() {
|
|
86
|
+
const baseClasses = 'relative w-[22px] h-[22px] box-border flex items-center justify-center rounded-full cursor-pointer transition-all opacity-100 border border-solid bg-transparent';
|
|
87
|
+
const borderColor = this.focused
|
|
88
|
+
? 'border-feedback-informational'
|
|
89
|
+
: 'border-transparent';
|
|
90
|
+
return `${baseClasses} ${borderColor}`;
|
|
91
|
+
}
|
|
92
|
+
getHintClasses() {
|
|
93
|
+
const baseClasses = 'hint-bubble fixed z-50 px-12 py-8 bg-neutral-neutral-8 text-neutral-neutral-1 text-sm rounded pointer-events-none leading-normal shadow-[0_4px_16px_rgba(0,0,0,0.24)] max-w-[200px] break-words';
|
|
94
|
+
const visibilityClasses = this.isVisible ? 'opacity-100 visible' : 'opacity-0 invisible';
|
|
95
|
+
return `${baseClasses} ${visibilityClasses} transition-opacity duration-200`;
|
|
96
|
+
}
|
|
97
|
+
render() {
|
|
98
|
+
const isParentMode = this.trigger === SulaTooltipTrigger.Parent;
|
|
99
|
+
const hostClass = isParentMode
|
|
100
|
+
? 'absolute inset-0 pointer-events-none overflow-visible'
|
|
101
|
+
: 'inline-block relative';
|
|
102
|
+
return (h(Host, { key: '24bf98cfe6268747b1c8a9b641a1ba2949878eb0', class: hostClass }, !isParentMode && (h("div", { key: '0f53fc5dfd2ffcaf787be059146cf60b6b752340', class: this.getIconClasses(), onMouseEnter: this.handleMouseEnter, onMouseLeave: this.handleMouseLeave, role: "button", "aria-label": "Tooltip trigger", ref: (el) => (this.triggerEl = el) }, h("sula-icon", { key: '5636e2af603eca17a6450d2c3bdfdb75c3d827d8', class: "flex items-center justify-center w-full h-full leading-[0]", icon: this.icon, customClass: "text-icon-primary text-[18px] leading-none" }))), this.displayText && (h("div", { key: '8a800e9e77323adfda8e11ddbc041bde55f33369', class: this.getHintClasses(), role: "tooltip", ref: (el) => (this.hintEl = el) }, this.displayText, h("div", { key: '073f4ed7af8bb575b55afd13db6595b88a36f227', class: "tooltip-arrow", "data-popper-arrow": true, ref: (el) => (this.arrowEl = el) })))));
|
|
103
|
+
}
|
|
104
|
+
static get is() { return "sula-tooltip"; }
|
|
105
|
+
static get encapsulation() { return "shadow"; }
|
|
106
|
+
static get originalStyleUrls() {
|
|
107
|
+
return {
|
|
108
|
+
"$": ["sula-tooltip.scss"]
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
static get styleUrls() {
|
|
112
|
+
return {
|
|
113
|
+
"$": ["sula-tooltip.css"]
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
static get properties() {
|
|
117
|
+
return {
|
|
118
|
+
"text": {
|
|
119
|
+
"type": "string",
|
|
120
|
+
"attribute": "text",
|
|
121
|
+
"mutable": false,
|
|
122
|
+
"complexType": {
|
|
123
|
+
"original": "string",
|
|
124
|
+
"resolved": "string",
|
|
125
|
+
"references": {}
|
|
126
|
+
},
|
|
127
|
+
"required": false,
|
|
128
|
+
"optional": false,
|
|
129
|
+
"docs": {
|
|
130
|
+
"tags": [],
|
|
131
|
+
"text": "Tooltip hint text \u2014 max 300 characters"
|
|
132
|
+
},
|
|
133
|
+
"getter": false,
|
|
134
|
+
"setter": false,
|
|
135
|
+
"reflect": false
|
|
136
|
+
},
|
|
137
|
+
"position": {
|
|
138
|
+
"type": "string",
|
|
139
|
+
"attribute": "position",
|
|
140
|
+
"mutable": false,
|
|
141
|
+
"complexType": {
|
|
142
|
+
"original": "SulaTooltipPosition",
|
|
143
|
+
"resolved": "SulaTooltipPosition.Bottom | SulaTooltipPosition.Left | SulaTooltipPosition.Right | SulaTooltipPosition.Top",
|
|
144
|
+
"references": {
|
|
145
|
+
"SulaTooltipPosition": {
|
|
146
|
+
"location": "import",
|
|
147
|
+
"path": "./model/sula-tooltip.model",
|
|
148
|
+
"id": "src/components/sula-tooltip/model/sula-tooltip.model.ts::SulaTooltipPosition"
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
"required": false,
|
|
153
|
+
"optional": false,
|
|
154
|
+
"docs": {
|
|
155
|
+
"tags": [],
|
|
156
|
+
"text": "Tooltip position relative to trigger"
|
|
157
|
+
},
|
|
158
|
+
"getter": false,
|
|
159
|
+
"setter": false,
|
|
160
|
+
"reflect": false,
|
|
161
|
+
"defaultValue": "SulaTooltipPosition.Top"
|
|
162
|
+
},
|
|
163
|
+
"focused": {
|
|
164
|
+
"type": "boolean",
|
|
165
|
+
"attribute": "focused",
|
|
166
|
+
"mutable": false,
|
|
167
|
+
"complexType": {
|
|
168
|
+
"original": "boolean",
|
|
169
|
+
"resolved": "boolean",
|
|
170
|
+
"references": {}
|
|
171
|
+
},
|
|
172
|
+
"required": false,
|
|
173
|
+
"optional": false,
|
|
174
|
+
"docs": {
|
|
175
|
+
"tags": [],
|
|
176
|
+
"text": "When true, renders a focus ring (21.5\u00D721.5px, 1px border) around the icon."
|
|
177
|
+
},
|
|
178
|
+
"getter": false,
|
|
179
|
+
"setter": false,
|
|
180
|
+
"reflect": false,
|
|
181
|
+
"defaultValue": "false"
|
|
182
|
+
},
|
|
183
|
+
"trigger": {
|
|
184
|
+
"type": "string",
|
|
185
|
+
"attribute": "trigger",
|
|
186
|
+
"mutable": false,
|
|
187
|
+
"complexType": {
|
|
188
|
+
"original": "SulaTooltipTrigger",
|
|
189
|
+
"resolved": "SulaTooltipTrigger.Icon | SulaTooltipTrigger.Parent",
|
|
190
|
+
"references": {
|
|
191
|
+
"SulaTooltipTrigger": {
|
|
192
|
+
"location": "import",
|
|
193
|
+
"path": "./model/sula-tooltip.model",
|
|
194
|
+
"id": "src/components/sula-tooltip/model/sula-tooltip.model.ts::SulaTooltipTrigger"
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
"required": false,
|
|
199
|
+
"optional": false,
|
|
200
|
+
"docs": {
|
|
201
|
+
"tags": [],
|
|
202
|
+
"text": "Trigger mode.\n- `'icon'` (default): the built-in info icon is the hover target.\n- `'parent'`: the icon is hidden; the component stretches to fill the\n parent element (which **must** have `position: relative`) and the hint\n appears on hover of that parent."
|
|
203
|
+
},
|
|
204
|
+
"getter": false,
|
|
205
|
+
"setter": false,
|
|
206
|
+
"reflect": false,
|
|
207
|
+
"defaultValue": "SulaTooltipTrigger.Icon"
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
static get states() {
|
|
212
|
+
return {
|
|
213
|
+
"isVisible": {}
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
static get elementRef() { return "el"; }
|
|
217
|
+
}
|
|
218
|
+
//# sourceMappingURL=sula-tooltip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sula-tooltip.js","sourceRoot":"","sources":["../../../src/components/sula-tooltip/sula-tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAErF,MAAM,eAAe,GAAG,GAAG,CAAC;AAO5B,MAAM,OAAO,WAAW;IALxB;QAaE;;WAEG;QACK,aAAQ,GAAwB,mBAAmB,CAAC,GAAG,CAAC;QAE/C,SAAI,GAAW,YAAY,CAAC;QAE7C;;WAEG;QACK,YAAO,GAAY,KAAK,CAAC;QAEjC;;;;;;WAMG;QACK,YAAO,GAAuB,kBAAkB,CAAC,IAAI,CAAC;QAErD,cAAS,GAAY,KAAK,CAAC;QAE5B,aAAQ,GAAuB,IAAI,CAAC;QACpC,WAAM,GAAuB,IAAI,CAAC;QAClC,cAAS,GAAuB,IAAI,CAAC;QACrC,YAAO,GAAuB,IAAI,CAAC;QACnC,mBAAc,GAA0B,IAAI,CAAC;QAqE7C,qBAAgB,GAAG,GAAG,EAAE;;YAC9B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YACtB,MAAA,IAAI,CAAC,cAAc,0CAAE,MAAM,EAAE,CAAC;QAChC,CAAC,CAAC;QAEM,qBAAgB,GAAG,GAAG,EAAE;YAC9B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACzB,CAAC,CAAC;KAgCH;IA1GC,gBAAgB;QACd,IAAI,IAAI,CAAC,OAAO,KAAK,kBAAkB,CAAC,MAAM,EAAE,CAAC;YAC/C,IAAI,CAAC,QAAQ,G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YAC5B,CAAC,CAAC,uDAAuD;YACzD,CAAC,CAAC,uBAAuB,CAAC;QAE5B,OAAO,CACL,EAAC,IAAI,qDAAC,KAAK,EAAE,SAAS;YACnB,CAAC,YAAY,IAAI,CAChB,4DACE,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,EAC5B,YAAY,EAAE,IAAI,CAAC,gBAAgB,EACnC,YAAY,EAAE,IAAI,CAAC,gBAAgB,EACnC,IAAI,EAAC,QAAQ,gBACF,iBAAiB,EAC5B,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,GAAG,EAAiB,CAAC;gBAEjD,kEAAW,KAAK,EAAC,4DAA4D,EAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,WAAW,EAAC,4CAA4C,GAAa,CAChK,CACP;YAEA,IAAI,CAAC,WAAW,IAAI,CACnB,4DAAK,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,EAAE,IAAI,EAAC,SAAS,EAAC,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,EAAiB,CAAC;gBAC7F,IAAI,CAAC,WAAW;gBACjB,4DAAK,KAAK,EAAC,eAAe,6BAAmB,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,GAAG,EAAiB,CAAC,GAAQ,CAChG,CACP,CACI,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Host, Prop, h, State } from '@stencil/core';\nimport { createPopper } from '@popperjs/core';\nimport type { Instance as PopperInstance } from '@popperjs/core';\nimport { SulaTooltipPosition, SulaTooltipTrigger } from './model/sula-tooltip.model';\n\nconst MAX_TEXT_LENGTH = 300;\n\n@Component({\n tag: 'sula-tooltip',\n styleUrl: 'sula-tooltip.scss',\n shadow: true,\n})\nexport class SulaTooltip {\n @Element() el: HTMLElement;\n\n /**\n * Tooltip hint text — max 300 characters\n */\n @Prop() text: string;\n\n /**\n * Tooltip position relative to trigger\n */\n @Prop() position: SulaTooltipPosition = SulaTooltipPosition.Top;\n\n private readonly icon: string = 'ph ph-info';\n\n /**\n * When true, renders a focus ring (21.5×21.5px, 1px border) around the icon.\n */\n @Prop() focused: boolean = false;\n\n /**\n * Trigger mode.\n * - `'icon'` (default): the built-in info icon is the hover target.\n * - `'parent'`: the icon is hidden; the component stretches to fill the\n * parent element (which **must** have `position: relative`) and the hint\n * appears on hover of that parent.\n */\n @Prop() trigger: SulaTooltipTrigger = SulaTooltipTrigger.Icon;\n\n @State() isVisible: boolean = false;\n\n private parentEl: HTMLElement | null = null;\n private hintEl: HTMLElement | null = null;\n private triggerEl: HTMLElement | null = null;\n private arrowEl: HTMLElement | null = null;\n private popperInstance: PopperInstance | null = null;\n\n componentDidLoad() {\n if (this.trigger === SulaTooltipTrigger.Parent) {\n this.parentEl = this.el.parentElement;\n if (this.parentEl) {\n this.parentEl.addEventListener('mouseenter', this.handleMouseEnter);\n this.parentEl.addEventListener('mouseleave', this.handleMouseLeave);\n }\n }\n this.initPopper();\n }\n\n disconnectedCallback() {\n if (this.parentEl) {\n this.parentEl.removeEventListener('mouseenter', this.handleMouseEnter);\n this.parentEl.removeEventListener('mouseleave', this.handleMouseLeave);\n this.parentEl = null;\n }\n if (this.popperInstance) {\n this.popperInstance.destroy();\n this.popperInstance = null;\n }\n }\n\n private initPopper() {\n const reference =\n this.trigger === SulaTooltipTrigger.Parent ? this.el.parentElement : this.triggerEl;\n if (!reference || !this.hintEl) return;\n\n if (this.popperInstance) {\n this.popperInstance.destroy();\n }\n\n this.popperInstance = createPopper(reference, this.hintEl, {\n placement: this.position as any,\n strategy: 'fixed',\n modifiers: [\n { name: 'offset', options: { offset: [0, 8] } },\n { name: 'arrow', options: { element: this.arrowEl } },\n { name: 'preventOverflow', options: { padding: 8 } },\n { name: 'flip' },\n ],\n });\n }\n\n private get displayText(): string {\n if (!this.text) return '';\n return this.text.length > MAX_TEXT_LENGTH\n ? this.text.slice(0, MAX_TEXT_LENGTH)\n : this.text;\n }\n\n private getIconClasses() {\n const baseClasses = 'relative w-[22px] h-[22px] box-border flex items-center justify-center rounded-full cursor-pointer transition-all opacity-100 border border-solid bg-transparent';\n const borderColor = this.focused\n ? 'border-feedback-informational'\n : 'border-transparent';\n\n return `${baseClasses} ${borderColor}`;\n }\n\n private getHintClasses() {\n const baseClasses =\n 'hint-bubble fixed z-50 px-12 py-8 bg-neutral-neutral-8 text-neutral-neutral-1 text-sm rounded pointer-events-none leading-normal shadow-[0_4px_16px_rgba(0,0,0,0.24)] max-w-[200px] break-words';\n const visibilityClasses = this.isVisible ? 'opacity-100 visible' : 'opacity-0 invisible';\n return `${baseClasses} ${visibilityClasses} transition-opacity duration-200`;\n }\n\n private handleMouseEnter = () => {\n this.isVisible = true;\n this.popperInstance?.update();\n };\n\n private handleMouseLeave = () => {\n this.isVisible = false;\n };\n\n render() {\n const isParentMode = this.trigger === SulaTooltipTrigger.Parent;\n const hostClass = isParentMode\n ? 'absolute inset-0 pointer-events-none overflow-visible'\n : 'inline-block relative';\n\n return (\n <Host class={hostClass}>\n {!isParentMode && (\n <div\n class={this.getIconClasses()}\n onMouseEnter={this.handleMouseEnter}\n onMouseLeave={this.handleMouseLeave}\n role=\"button\"\n aria-label=\"Tooltip trigger\"\n ref={(el) => (this.triggerEl = el as HTMLElement)}\n >\n <sula-icon class=\"flex items-center justify-center w-full h-full leading-[0]\" icon={this.icon} customClass=\"text-icon-primary text-[18px] leading-none\"></sula-icon>\n </div>\n )}\n\n {this.displayText && (\n <div class={this.getHintClasses()} role=\"tooltip\" ref={(el) => (this.hintEl = el as HTMLElement)}>\n {this.displayText}\n <div class=\"tooltip-arrow\" data-popper-arrow ref={(el) => (this.arrowEl = el as HTMLElement)}></div>\n </div>\n )}\n </Host>\n );\n }\n}\n"]}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { SulaTooltipPosition, SulaTooltipTrigger } from "./model/sula-tooltip.model";
|
|
2
|
+
export default {
|
|
3
|
+
title: 'Components/sula-tooltip',
|
|
4
|
+
tags: ['autodocs'],
|
|
5
|
+
argTypes: {
|
|
6
|
+
text: {
|
|
7
|
+
control: 'text',
|
|
8
|
+
description: 'Texto exibido no tooltip (máx. 300 caracteres)',
|
|
9
|
+
table: {
|
|
10
|
+
type: { summary: 'string' },
|
|
11
|
+
defaultValue: { summary: 'undefined' },
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
position: {
|
|
15
|
+
control: { type: 'select' },
|
|
16
|
+
options: Object.values(SulaTooltipPosition),
|
|
17
|
+
description: 'Posição do tooltip em relação ao gatilho',
|
|
18
|
+
table: {
|
|
19
|
+
type: { summary: 'SulaTooltipPosition' },
|
|
20
|
+
defaultValue: { summary: 'SulaTooltipPosition.Top' },
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
icon: {
|
|
24
|
+
control: 'text',
|
|
25
|
+
description: 'Classe do ícone (Phosphor Icons)',
|
|
26
|
+
table: {
|
|
27
|
+
type: { summary: 'string' },
|
|
28
|
+
defaultValue: { summary: 'ph ph-info' },
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
focused: {
|
|
32
|
+
control: 'boolean',
|
|
33
|
+
description: 'Exibe o focus ring ao redor do ícone',
|
|
34
|
+
table: {
|
|
35
|
+
type: { summary: 'boolean' },
|
|
36
|
+
defaultValue: { summary: 'false' },
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
trigger: {
|
|
40
|
+
control: { type: 'select' },
|
|
41
|
+
options: Object.values(SulaTooltipTrigger),
|
|
42
|
+
description: 'Modo de disparo: ícone (padrão) ou elemento pai',
|
|
43
|
+
table: {
|
|
44
|
+
type: { summary: 'SulaTooltipTrigger' },
|
|
45
|
+
defaultValue: { summary: 'SulaTooltipTrigger.Icon' },
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
parameters: {
|
|
50
|
+
docs: {
|
|
51
|
+
description: {
|
|
52
|
+
component: `
|
|
53
|
+
O componente **Sula Tooltip** exibe um hint informativo ao passar o mouse sobre um ícone ou elemento pai.
|
|
54
|
+
|
|
55
|
+
### Características principais:
|
|
56
|
+
- Posicionamento em 4 direções (top, bottom, left, right)
|
|
57
|
+
- Adaptação automática ao tema via Tailwind
|
|
58
|
+
- Suporte a focus ring
|
|
59
|
+
- Modo trigger por ícone ou por elemento pai
|
|
60
|
+
- Texto com até 300 caracteres
|
|
61
|
+
`,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
const Template = args => {
|
|
67
|
+
const container = document.createElement('div');
|
|
68
|
+
container.style.margin = '100px';
|
|
69
|
+
container.style.display = 'flex';
|
|
70
|
+
container.style.justifyContent = 'center';
|
|
71
|
+
container.style.alignItems = 'center';
|
|
72
|
+
const el = document.createElement('sula-tooltip');
|
|
73
|
+
el.setAttribute('text', args.text);
|
|
74
|
+
el.setAttribute('position', args.position);
|
|
75
|
+
el.setAttribute('icon', args.icon || 'ph ph-info');
|
|
76
|
+
el.setAttribute('focused', args.focused ? 'true' : 'false');
|
|
77
|
+
el.setAttribute('trigger', args.trigger || 'icon');
|
|
78
|
+
container.appendChild(el);
|
|
79
|
+
return container;
|
|
80
|
+
};
|
|
81
|
+
export const Playground = Template.bind({});
|
|
82
|
+
Playground.args = {
|
|
83
|
+
text: 'Este é um tooltip padrão',
|
|
84
|
+
position: SulaTooltipPosition.Top,
|
|
85
|
+
icon: 'ph ph-info',
|
|
86
|
+
focused: false,
|
|
87
|
+
trigger: SulaTooltipTrigger.Icon,
|
|
88
|
+
};
|
|
89
|
+
export const Positions = () => {
|
|
90
|
+
const container = document.createElement('div');
|
|
91
|
+
container.style.display = 'flex';
|
|
92
|
+
container.style.gap = '64px';
|
|
93
|
+
container.style.alignItems = 'center';
|
|
94
|
+
container.style.justifyContent = 'center';
|
|
95
|
+
container.style.padding = '100px 20px';
|
|
96
|
+
Object.values(SulaTooltipPosition).forEach(pos => {
|
|
97
|
+
const wrapper = document.createElement('div');
|
|
98
|
+
wrapper.style.display = 'flex';
|
|
99
|
+
wrapper.style.alignItems = 'center';
|
|
100
|
+
wrapper.style.gap = '8px';
|
|
101
|
+
const label = document.createElement('span');
|
|
102
|
+
label.style.fontSize = '14px';
|
|
103
|
+
label.textContent = pos.charAt(0).toUpperCase() + pos.slice(1) + ':';
|
|
104
|
+
const el = document.createElement('sula-tooltip');
|
|
105
|
+
el.setAttribute('text', `Tooltip posicionado em ${pos}`);
|
|
106
|
+
el.setAttribute('position', pos);
|
|
107
|
+
wrapper.appendChild(label);
|
|
108
|
+
wrapper.appendChild(el);
|
|
109
|
+
container.appendChild(wrapper);
|
|
110
|
+
});
|
|
111
|
+
return container;
|
|
112
|
+
};
|
|
113
|
+
Positions.parameters = {
|
|
114
|
+
docs: { description: { story: 'Todas as posições disponíveis do tooltip.' } },
|
|
115
|
+
};
|
|
116
|
+
export const FocusRing = Template.bind({});
|
|
117
|
+
FocusRing.args = {
|
|
118
|
+
text: 'Tooltip com focus ring',
|
|
119
|
+
position: SulaTooltipPosition.Top,
|
|
120
|
+
focused: true,
|
|
121
|
+
};
|
|
122
|
+
FocusRing.parameters = {
|
|
123
|
+
docs: { description: { story: 'Tooltip com focus ring visível ao redor do ícone.' } },
|
|
124
|
+
};
|
|
125
|
+
export const CustomIcon = Template.bind({});
|
|
126
|
+
CustomIcon.args = {
|
|
127
|
+
text: 'Tooltip com ícone customizado',
|
|
128
|
+
position: SulaTooltipPosition.Top,
|
|
129
|
+
icon: 'ph ph-question',
|
|
130
|
+
};
|
|
131
|
+
CustomIcon.parameters = {
|
|
132
|
+
docs: { description: { story: 'Tooltip com ícone de pergunta.' } },
|
|
133
|
+
};
|
|
134
|
+
export const LongText = Template.bind({});
|
|
135
|
+
LongText.args = {
|
|
136
|
+
text: 'Este é um texto longo para demonstrar que o tooltip suporta quebra de linha e até 300 caracteres de conteúdo informativo para o usuário.',
|
|
137
|
+
position: SulaTooltipPosition.Right,
|
|
138
|
+
};
|
|
139
|
+
LongText.parameters = {
|
|
140
|
+
docs: { description: { story: 'Tooltip com texto longo demonstrando o suporte a múltiplas linhas.' } },
|
|
141
|
+
};
|
|
142
|
+
export const ParentTrigger = () => {
|
|
143
|
+
const container = document.createElement('div');
|
|
144
|
+
container.style.display = 'flex';
|
|
145
|
+
container.style.gap = '16px';
|
|
146
|
+
container.style.padding = '100px 20px';
|
|
147
|
+
container.style.justifyContent = 'center';
|
|
148
|
+
const card = document.createElement('div');
|
|
149
|
+
card.style.position = 'relative';
|
|
150
|
+
card.style.padding = '16px 20px';
|
|
151
|
+
card.style.borderRadius = '8px';
|
|
152
|
+
card.style.border = '1px solid #e0e0e0';
|
|
153
|
+
card.style.background = '#fff';
|
|
154
|
+
card.style.cursor = 'default';
|
|
155
|
+
card.style.width = '180px';
|
|
156
|
+
const label = document.createElement('p');
|
|
157
|
+
label.style.fontSize = '12px';
|
|
158
|
+
label.style.color = '#6c6e6e';
|
|
159
|
+
label.style.margin = '0 0 4px';
|
|
160
|
+
label.textContent = 'Total investido';
|
|
161
|
+
const value = document.createElement('p');
|
|
162
|
+
value.style.fontSize = '20px';
|
|
163
|
+
value.style.fontWeight = 'bold';
|
|
164
|
+
value.style.margin = '0';
|
|
165
|
+
value.textContent = 'R$ 4.820';
|
|
166
|
+
const tooltip = document.createElement('sula-tooltip');
|
|
167
|
+
tooltip.setAttribute('text', 'Passe o mouse sobre o card para ver o tooltip.');
|
|
168
|
+
tooltip.setAttribute('trigger', SulaTooltipTrigger.Parent);
|
|
169
|
+
tooltip.setAttribute('position', SulaTooltipPosition.Top);
|
|
170
|
+
card.appendChild(label);
|
|
171
|
+
card.appendChild(value);
|
|
172
|
+
card.appendChild(tooltip);
|
|
173
|
+
container.appendChild(card);
|
|
174
|
+
return container;
|
|
175
|
+
};
|
|
176
|
+
ParentTrigger.parameters = {
|
|
177
|
+
docs: { description: { story: 'Tooltip disparado pelo hover no elemento pai (ícone oculto).' } },
|
|
178
|
+
};
|
|
179
|
+
//# sourceMappingURL=sula-tooltip.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sula-tooltip.stories.js","sourceRoot":"","sources":["../../../src/components/sula-tooltip/sula-tooltip.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAErF,eAAe;IACb,KAAK,EAAE,yBAAyB;IAChC,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,QAAQ,EAAE;QACR,IAAI,EAAE;YACJ,OAAO,EAAE,MAAM;YACf,WAAW,EAAE,gDAAgD;YAC7D,KAAK,EAAE;gBACL,IAAI,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE;gBAC3B,YAAY,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE;aACvC;SACF;QACD,QAAQ,EAAE;YACR,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC3B,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC;YAC3C,WAAW,EAAE,0CAA0C;YACvD,KAAK,EAAE;gBACL,IAAI,EAAE,EAAE,OAAO,EAAE,qBAAqB,EAAE;gBACxC,YAAY,EAAE,EAAE,OAAO,EAAE,yBAAyB,EAAE;aACrD;SACF;QACD,IAAI,EAAE;YACJ,OAAO,EAAE,MAAM;YACf,WAAW,EAAE,kCAAkC;YAC/C,KAAK,EAAE;gBACL,IAAI,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE;gBAC3B,YAAY,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE;aACxC;SACF;QACD,OAAO,EAAE;YACP,OAAO,EAAE,SAAS;YAClB,WAAW,EAAE,sCAAsC;YACnD,KAAK,EAAE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CACjG,CAAC","sourcesContent":["import { SulaTooltipPosition, SulaTooltipTrigger } from './model/sula-tooltip.model';\n\nexport default {\n title: 'Components/sula-tooltip',\n tags: ['autodocs'],\n argTypes: {\n text: {\n control: 'text',\n description: 'Texto exibido no tooltip (máx. 300 caracteres)',\n table: {\n type: { summary: 'string' },\n defaultValue: { summary: 'undefined' },\n },\n },\n position: {\n control: { type: 'select' },\n options: Object.values(SulaTooltipPosition),\n description: 'Posição do tooltip em relação ao gatilho',\n table: {\n type: { summary: 'SulaTooltipPosition' },\n defaultValue: { summary: 'SulaTooltipPosition.Top' },\n },\n },\n icon: {\n control: 'text',\n description: 'Classe do ícone (Phosphor Icons)',\n table: {\n type: { summary: 'string' },\n defaultValue: { summary: 'ph ph-info' },\n },\n },\n focused: {\n control: 'boolean',\n description: 'Exibe o focus ring ao redor do ícone',\n table: {\n type: { summary: 'boolean' },\n defaultValue: { summary: 'false' },\n },\n },\n trigger: {\n control: { type: 'select' },\n options: Object.values(SulaTooltipTrigger),\n description: 'Modo de disparo: ícone (padrão) ou elemento pai',\n table: {\n type: { summary: 'SulaTooltipTrigger' },\n defaultValue: { summary: 'SulaTooltipTrigger.Icon' },\n },\n },\n },\n parameters: {\n docs: {\n description: {\n component: `\nO componente **Sula Tooltip** exibe um hint informativo ao passar o mouse sobre um ícone ou elemento pai.\n\n### Características principais:\n- Posicionamento em 4 direções (top, bottom, left, right)\n- Adaptação automática ao tema via Tailwind\n- Suporte a focus ring\n- Modo trigger por ícone ou por elemento pai\n- Texto com até 300 caracteres\n `,\n },\n },\n },\n};\n\nconst Template = args => {\n const container = document.createElement('div');\n container.style.margin = '100px';\n container.style.display = 'flex';\n container.style.justifyContent = 'center';\n container.style.alignItems = 'center';\n\n const el = document.createElement('sula-tooltip');\n\n el.setAttribute('text', args.text);\n el.setAttribute('position', args.position);\n el.setAttribute('icon', args.icon || 'ph ph-info');\n el.setAttribute('focused', args.focused ? 'true' : 'false');\n el.setAttribute('trigger', args.trigger || 'icon');\n\n container.appendChild(el);\n\n return container;\n};\n\nexport const Playground = Template.bind({});\nPlayground.args = {\n text: 'Este é um tooltip padrão',\n position: SulaTooltipPosition.Top,\n icon: 'ph ph-info',\n focused: false,\n trigger: SulaTooltipTrigger.Icon,\n};\n\nexport const Positions = () => {\n const container = document.createElement('div');\n container.style.display = 'flex';\n container.style.gap = '64px';\n container.style.alignItems = 'center';\n container.style.justifyContent = 'center';\n container.style.padding = '100px 20px';\n\n Object.values(SulaTooltipPosition).forEach(pos => {\n const wrapper = document.createElement('div');\n wrapper.style.display = 'flex';\n wrapper.style.alignItems = 'center';\n wrapper.style.gap = '8px';\n\n const label = document.createElement('span');\n label.style.fontSize = '14px';\n label.textContent = pos.charAt(0).toUpperCase() + pos.slice(1) + ':';\n\n const el = document.createElement('sula-tooltip');\n el.setAttribute('text', `Tooltip posicionado em ${pos}`);\n el.setAttribute('position', pos);\n\n wrapper.appendChild(label);\n wrapper.appendChild(el);\n container.appendChild(wrapper);\n });\n\n return container;\n};\nPositions.parameters = {\n docs: { description: { story: 'Todas as posições disponíveis do tooltip.' } },\n};\n\nexport const FocusRing = Template.bind({});\nFocusRing.args = {\n text: 'Tooltip com focus ring',\n position: SulaTooltipPosition.Top,\n focused: true,\n};\nFocusRing.parameters = {\n docs: { description: { story: 'Tooltip com focus ring visível ao redor do ícone.' } },\n};\n\nexport const CustomIcon = Template.bind({});\nCustomIcon.args = {\n text: 'Tooltip com ícone customizado',\n position: SulaTooltipPosition.Top,\n icon: 'ph ph-question',\n};\nCustomIcon.parameters = {\n docs: { description: { story: 'Tooltip com ícone de pergunta.' } },\n};\n\nexport const LongText = Template.bind({});\nLongText.args = {\n text: 'Este é um texto longo para demonstrar que o tooltip suporta quebra de linha e até 300 caracteres de conteúdo informativo para o usuário.',\n position: SulaTooltipPosition.Right,\n};\nLongText.parameters = {\n docs: { description: { story: 'Tooltip com texto longo demonstrando o suporte a múltiplas linhas.' } },\n};\n\nexport const ParentTrigger = () => {\n const container = document.createElement('div');\n container.style.display = 'flex';\n container.style.gap = '16px';\n container.style.padding = '100px 20px';\n container.style.justifyContent = 'center';\n\n const card = document.createElement('div');\n card.style.position = 'relative';\n card.style.padding = '16px 20px';\n card.style.borderRadius = '8px';\n card.style.border = '1px solid #e0e0e0';\n card.style.background = '#fff';\n card.style.cursor = 'default';\n card.style.width = '180px';\n\n const label = document.createElement('p');\n label.style.fontSize = '12px';\n label.style.color = '#6c6e6e';\n label.style.margin = '0 0 4px';\n label.textContent = 'Total investido';\n\n const value = document.createElement('p');\n value.style.fontSize = '20px';\n value.style.fontWeight = 'bold';\n value.style.margin = '0';\n value.textContent = 'R$ 4.820';\n\n const tooltip = document.createElement('sula-tooltip');\n tooltip.setAttribute('text', 'Passe o mouse sobre o card para ver o tooltip.');\n tooltip.setAttribute('trigger', SulaTooltipTrigger.Parent);\n tooltip.setAttribute('position', SulaTooltipPosition.Top);\n\n card.appendChild(label);\n card.appendChild(value);\n card.appendChild(tooltip);\n container.appendChild(card);\n\n return container;\n};\nParentTrigger.parameters = {\n docs: { description: { story: 'Tooltip disparado pelo hover no elemento pai (ícone oculto).' } },\n};\n"]}
|