@warp-ds/elements 2.2.0-next.3 → 2.2.0-next.30
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/README.md +217 -28
- package/dist/.storybook/utilities.d.ts +28 -0
- package/dist/.storybook/utilities.js +52 -0
- package/dist/api.js +1 -49
- package/dist/api.js.map +4 -4
- package/dist/custom-elements.json +3059 -0
- package/dist/index.d.ts +942 -18
- package/dist/packages/affix/affix.react.stories.d.ts +9 -0
- package/dist/packages/affix/affix.react.stories.js +10 -0
- package/dist/packages/affix/affix.stories.d.ts +10 -0
- package/dist/packages/affix/affix.stories.js +25 -0
- package/dist/packages/affix/affix.test.d.ts +1 -0
- package/dist/packages/affix/affix.test.js +9 -0
- package/dist/packages/affix/index.d.ts +47 -24
- package/dist/packages/affix/index.js +2448 -2240
- package/dist/packages/affix/index.js.map +4 -4
- package/dist/packages/affix/react.d.ts +2 -0
- package/dist/packages/affix/react.js +15 -0
- package/dist/packages/affix/styles.d.ts +1 -0
- package/dist/packages/affix/styles.js +2 -0
- package/dist/packages/alert/alert.react.stories.d.ts +13 -0
- package/dist/packages/alert/alert.react.stories.js +44 -0
- package/dist/packages/alert/alert.stories.d.ts +15 -0
- package/dist/packages/alert/alert.stories.js +68 -0
- package/dist/packages/alert/alert.test.d.ts +1 -0
- package/dist/packages/alert/alert.test.js +18 -0
- package/dist/packages/alert/index.d.ts +23 -17
- package/dist/packages/alert/index.js +2452 -2446
- package/dist/packages/alert/index.js.map +4 -4
- package/dist/packages/alert/react.d.ts +2 -0
- package/dist/packages/alert/react.js +11 -0
- package/dist/packages/alert/styles.d.ts +1 -0
- package/dist/packages/alert/styles.js +2 -0
- package/dist/packages/attention/attention.react.stories.d.ts +15 -0
- package/dist/packages/attention/attention.react.stories.js +92 -0
- package/dist/packages/attention/attention.stories.d.ts +16 -0
- package/dist/packages/attention/attention.stories.js +180 -0
- package/dist/packages/attention/attention.test.d.ts +1 -0
- package/dist/packages/attention/attention.test.js +11 -0
- package/dist/packages/attention/index.d.ts +61 -89
- package/dist/packages/attention/index.js +3530 -3924
- package/dist/packages/attention/index.js.map +4 -4
- package/dist/packages/attention/layout-styles.d.ts +1 -0
- package/dist/packages/attention/layout-styles.js +905 -0
- package/dist/packages/attention/locales/da/messages.mjs +1 -0
- package/dist/packages/attention/locales/en/messages.mjs +1 -0
- package/dist/packages/attention/locales/fi/messages.mjs +1 -0
- package/dist/packages/attention/locales/nb/messages.mjs +1 -0
- package/dist/packages/attention/locales/sv/messages.mjs +1 -0
- package/dist/packages/attention/react.d.ts +15 -0
- package/dist/packages/attention/react.js +17 -0
- package/dist/packages/attention/styles.d.ts +1 -0
- package/dist/packages/attention/styles.js +2 -0
- package/dist/packages/badge/badge.react.stories.d.ts +18 -0
- package/dist/packages/badge/badge.react.stories.js +60 -0
- package/dist/packages/badge/badge.stories.d.ts +17 -0
- package/dist/packages/badge/badge.stories.js +68 -0
- package/dist/packages/badge/badge.test.d.ts +1 -0
- package/dist/packages/badge/badge.test.js +9 -0
- package/dist/packages/badge/index.d.ts +12 -12
- package/dist/packages/badge/index.js +2441 -300
- package/dist/packages/badge/index.js.map +4 -4
- package/dist/packages/badge/react.d.ts +2 -0
- package/dist/packages/badge/react.js +11 -0
- package/dist/packages/badge/styles.d.ts +1 -0
- package/dist/packages/badge/styles.js +2 -0
- package/dist/packages/box/box.react.stories.d.ts +15 -0
- package/dist/packages/box/box.react.stories.js +45 -0
- package/dist/packages/box/box.stories.d.ts +14 -0
- package/dist/packages/box/box.stories.js +59 -0
- package/dist/packages/box/box.test.d.ts +1 -0
- package/dist/packages/box/box.test.js +9 -0
- package/dist/packages/box/index.d.ts +16 -21
- package/dist/packages/box/index.js +2443 -299
- package/dist/packages/box/index.js.map +4 -4
- package/dist/packages/box/react.d.ts +2 -0
- package/dist/packages/box/react.js +11 -0
- package/dist/packages/box/slot.test.d.ts +1 -0
- package/dist/packages/box/slot.test.js +9 -0
- package/dist/packages/box/styles.d.ts +1 -0
- package/dist/packages/box/styles.js +2 -0
- package/dist/packages/breadcrumbs/breadcrumbs.react.stories.d.ts +13 -0
- package/dist/packages/breadcrumbs/breadcrumbs.react.stories.js +40 -0
- package/dist/packages/breadcrumbs/breadcrumbs.stories.d.ts +12 -0
- package/dist/packages/breadcrumbs/breadcrumbs.stories.js +60 -0
- package/dist/packages/breadcrumbs/breadcrumbs.test.d.ts +1 -0
- package/dist/packages/breadcrumbs/breadcrumbs.test.js +16 -0
- package/dist/packages/breadcrumbs/index.d.ts +19 -16
- package/dist/packages/breadcrumbs/index.js +2402 -2051
- package/dist/packages/breadcrumbs/index.js.map +4 -4
- package/dist/packages/breadcrumbs/locales/da/messages.mjs +1 -0
- package/dist/packages/breadcrumbs/locales/en/messages.mjs +1 -0
- package/dist/packages/breadcrumbs/locales/fi/messages.mjs +1 -0
- package/dist/packages/breadcrumbs/locales/nb/messages.mjs +1 -0
- package/dist/packages/breadcrumbs/locales/sv/messages.mjs +1 -0
- package/dist/packages/breadcrumbs/react.d.ts +2 -0
- package/dist/packages/breadcrumbs/react.js +11 -0
- package/dist/packages/breadcrumbs/styles.d.ts +1 -0
- package/dist/packages/breadcrumbs/styles.js +2 -0
- package/dist/packages/button/button.react.stories.d.ts +22 -0
- package/dist/packages/button/button.react.stories.js +102 -0
- package/dist/packages/button/button.stories.d.ts +25 -0
- package/dist/packages/button/button.stories.js +151 -0
- package/dist/packages/button/button.test.d.ts +1 -1
- package/dist/packages/button/button.test.js +25 -0
- package/dist/packages/button/index.d.ts +83 -9
- package/dist/packages/button/index.js +2614 -2422
- package/dist/packages/button/index.js.map +4 -4
- package/dist/packages/button/locales/da/messages.mjs +1 -0
- package/dist/packages/button/locales/en/messages.mjs +1 -0
- package/dist/packages/button/locales/fi/messages.mjs +1 -0
- package/dist/packages/button/locales/nb/messages.mjs +1 -0
- package/dist/packages/button/locales/sv/messages.mjs +1 -0
- package/dist/packages/button/react.d.ts +2 -0
- package/dist/packages/button/react.js +11 -0
- package/dist/packages/button/styles.d.ts +1 -0
- package/dist/packages/button/styles.js +2 -0
- package/dist/packages/card/card.react.stories.d.ts +16 -0
- package/dist/packages/card/card.react.stories.js +63 -0
- package/dist/packages/card/card.stories.d.ts +15 -0
- package/dist/packages/card/card.stories.js +82 -0
- package/dist/packages/card/card.test.d.ts +1 -0
- package/dist/packages/card/card.test.js +9 -0
- package/dist/packages/card/index.d.ts +27 -16
- package/dist/packages/card/index.js +2403 -2067
- package/dist/packages/card/index.js.map +4 -4
- package/dist/packages/card/locales/da/messages.mjs +1 -0
- package/dist/packages/card/locales/en/messages.mjs +1 -0
- package/dist/packages/card/locales/fi/messages.mjs +1 -0
- package/dist/packages/card/locales/nb/messages.mjs +1 -0
- package/dist/packages/card/locales/sv/messages.mjs +1 -0
- package/dist/packages/card/react.d.ts +2 -0
- package/dist/packages/card/react.js +11 -0
- package/dist/packages/card/styles.d.ts +1 -0
- package/dist/packages/card/styles.js +2 -0
- package/dist/packages/expandable/expandable.react.stories.d.ts +18 -0
- package/dist/packages/expandable/expandable.react.stories.js +103 -0
- package/dist/packages/expandable/expandable.stories.d.ts +19 -0
- package/dist/packages/expandable/expandable.stories.js +132 -0
- package/dist/packages/expandable/expandable.test.d.ts +1 -0
- package/dist/packages/expandable/expandable.test.js +24 -0
- package/dist/packages/expandable/index.d.ts +52 -50
- package/dist/packages/expandable/index.js +2424 -2286
- package/dist/packages/expandable/index.js.map +4 -4
- package/dist/packages/expandable/react.d.ts +2 -0
- package/dist/packages/expandable/react.js +11 -0
- package/dist/packages/expandable/styles.d.ts +1 -0
- package/dist/packages/expandable/styles.js +2 -0
- package/dist/packages/i18n.js +45 -0
- package/dist/packages/link/index.d.ts +34 -0
- package/dist/packages/link/index.js +99 -0
- package/dist/packages/link/styles.d.ts +1 -0
- package/dist/packages/link/styles.js +200 -0
- package/dist/packages/modal/index.d.ts +5 -6
- package/dist/packages/modal/index.js +5 -2611
- package/dist/packages/modal/locales/da/messages.mjs +1 -0
- package/dist/packages/modal/locales/en/messages.mjs +1 -0
- package/dist/packages/modal/locales/fi/messages.mjs +1 -0
- package/dist/packages/modal/locales/nb/messages.mjs +1 -0
- package/dist/packages/modal/locales/sv/messages.mjs +1 -0
- package/dist/packages/modal/modal-footer.d.ts +12 -10
- package/dist/packages/modal/modal-footer.js +2460 -0
- package/dist/packages/modal/modal-footer.js.map +7 -0
- package/dist/packages/modal/modal-header.d.ts +15 -13
- package/dist/packages/modal/modal-header.js +2567 -0
- package/dist/packages/modal/modal-header.js.map +7 -0
- package/dist/packages/modal/modal-main.d.ts +14 -8
- package/dist/packages/modal/modal-main.js +2572 -0
- package/dist/packages/modal/modal-main.js.map +7 -0
- package/dist/packages/modal/modal.react.stories.d.ts +14 -0
- package/dist/packages/modal/modal.react.stories.js +27 -0
- package/dist/packages/modal/modal.stories.d.ts +19 -0
- package/dist/packages/modal/modal.stories.js +254 -0
- package/dist/packages/modal/react.d.ts +12 -0
- package/dist/packages/modal/react.js +31 -0
- package/dist/packages/modal/util.d.ts +7 -17
- package/dist/packages/modal/util.js +21 -0
- package/dist/packages/pill/index.d.ts +39 -23
- package/dist/packages/pill/index.js +2408 -2175
- package/dist/packages/pill/index.js.map +4 -4
- package/dist/packages/pill/locales/da/messages.mjs +1 -0
- package/dist/packages/pill/locales/en/messages.mjs +1 -0
- package/dist/packages/pill/locales/fi/messages.mjs +1 -0
- package/dist/packages/pill/locales/nb/messages.mjs +1 -0
- package/dist/packages/pill/locales/sv/messages.mjs +1 -0
- package/dist/packages/pill/pill.react.stories.d.ts +23 -0
- package/dist/packages/pill/pill.react.stories.js +22 -0
- package/dist/packages/pill/pill.stories.d.ts +12 -0
- package/dist/packages/pill/pill.stories.js +33 -0
- package/dist/packages/pill/pill.test.d.ts +1 -0
- package/dist/packages/pill/pill.test.js +25 -0
- package/dist/packages/pill/react.d.ts +7 -0
- package/dist/packages/pill/react.js +17 -0
- package/dist/packages/pill/styles.d.ts +1 -0
- package/dist/packages/pill/styles.js +2 -0
- package/dist/packages/select/index.d.ts +56 -60
- package/dist/packages/select/index.js +2428 -2533
- package/dist/packages/select/index.js.map +4 -4
- package/dist/packages/select/locales/da/messages.mjs +1 -0
- package/dist/packages/select/locales/en/messages.mjs +1 -0
- package/dist/packages/select/locales/fi/messages.mjs +1 -0
- package/dist/packages/select/locales/nb/messages.mjs +1 -0
- package/dist/packages/select/locales/sv/messages.mjs +1 -0
- package/dist/packages/select/react.d.ts +6 -0
- package/dist/packages/select/react.js +20 -0
- package/dist/packages/select/select.react.stories.d.ts +18 -0
- package/dist/packages/select/select.react.stories.js +28 -0
- package/dist/packages/select/select.stories.d.ts +17 -0
- package/dist/packages/select/select.stories.js +100 -0
- package/dist/packages/select/select.test.d.ts +1 -0
- package/dist/packages/select/select.test.js +31 -0
- package/dist/packages/select/styles.d.ts +1 -0
- package/dist/packages/select/styles.js +2 -0
- package/dist/packages/styles.js +2442 -0
- package/dist/packages/textfield/index.d.ts +78 -74
- package/dist/packages/textfield/index.js +2522 -707
- package/dist/packages/textfield/index.js.map +4 -4
- package/dist/packages/textfield/react.d.ts +11 -0
- package/dist/packages/textfield/react.js +21 -0
- package/dist/packages/textfield/styles/w-textfield.styles.d.ts +1 -0
- package/dist/packages/textfield/styles/w-textfield.styles.js +55 -0
- package/dist/packages/textfield/styles.d.ts +1 -0
- package/dist/packages/textfield/styles.js +2 -0
- package/dist/packages/textfield/textfield.react.stories.d.ts +37 -0
- package/dist/packages/textfield/textfield.react.stories.js +88 -0
- package/dist/packages/textfield/textfield.stories.d.ts +18 -0
- package/dist/packages/textfield/textfield.stories.js +105 -0
- package/dist/packages/textfield/textfield.test.d.ts +2 -0
- package/dist/packages/textfield/textfield.test.js +68 -0
- package/dist/packages/toast/api.d.ts +4 -45
- package/dist/packages/toast/api.js +41 -0
- package/dist/packages/toast/index.d.ts +3 -3
- package/dist/packages/toast/index.js +3 -2804
- package/dist/packages/toast/locales/da/messages.mjs +1 -0
- package/dist/packages/toast/locales/en/messages.mjs +1 -0
- package/dist/packages/toast/locales/fi/messages.mjs +1 -0
- package/dist/packages/toast/locales/nb/messages.mjs +1 -0
- package/dist/packages/toast/locales/sv/messages.mjs +1 -0
- package/dist/packages/toast/styles.d.ts +1 -0
- package/dist/packages/toast/styles.js +2 -0
- package/dist/packages/toast/toast-container.d.ts +13 -63
- package/dist/packages/toast/toast-container.js +2458 -0
- package/dist/packages/toast/toast-container.js.map +7 -0
- package/dist/packages/toast/toast.d.ts +36 -29
- package/dist/packages/toast/toast.js +2466 -0
- package/dist/packages/toast/toast.js.map +7 -0
- package/dist/packages/toast/toast.stories.d.ts +12 -0
- package/dist/packages/toast/toast.stories.js +50 -0
- package/dist/packages/toast/types.d.ts +15 -0
- package/dist/packages/toast/types.js +1 -0
- package/dist/packages/utils/expand-transition.d.ts +3 -3
- package/dist/packages/utils/expand-transition.js +59 -0
- package/dist/packages/utils/index.d.ts +1 -1
- package/dist/packages/utils/index.js +37 -0
- package/dist/packages/utils/unstyled-heading.d.ts +3 -4
- package/dist/packages/utils/unstyled-heading.js +22 -0
- package/dist/packages/utils/window-exists.js +1 -0
- package/dist/setup-tests.d.ts +1 -0
- package/dist/setup-tests.js +1 -0
- package/dist/vscode.css-custom-data.json +6 -0
- package/dist/vscode.html-custom-data.json +296 -0
- package/dist/web-types.json +661 -0
- package/package.json +89 -36
- package/dist/index.js +0 -9820
- package/dist/index.js.map +0 -7
- package/dist/packages/modal/index.js.map +0 -7
- package/dist/packages/toast/index.js.map +0 -7
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import { createComponent } from '@lit/react';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
// decouple from CDN by providing a dummy class
|
|
5
|
+
class Component extends LitElement {
|
|
6
|
+
}
|
|
7
|
+
export const Alert = createComponent({
|
|
8
|
+
tagName: 'w-alert',
|
|
9
|
+
elementClass: Component,
|
|
10
|
+
react: React,
|
|
11
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const styles: import("lit").CSSResult;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export const styles = css `*,:before,:after{--w-rotate:0;--w-rotate-x:0;--w-rotate-y:0;--w-rotate-z:0;--w-scale-x:1;--w-scale-y:1;--w-scale-z:1;--w-skew-x:0;--w-skew-y:0;--w-translate-x:0;--w-translate-y:0;--w-translate-z:0}.will-change-height{will-change:height}.border{border-width:1px}.border-l-4{border-left-width:4px}.rounded-4{border-radius:4px}.block{display:block}.inline{display:inline}.flex{display:flex}.static{position:static}.s-bg-info-subtle{background-color:var(--w-s-color-background-info-subtle)}.s-bg-negative-subtle{background-color:var(--w-s-color-background-negative-subtle)}.s-bg-positive-subtle{background-color:var(--w-s-color-background-positive-subtle)}.s-bg-warning-subtle{background-color:var(--w-s-color-background-warning-subtle)}.s-text{color:var(--w-s-color-text)}.s-icon-info{color:var(--w-s-color-icon-info)}.s-icon-negative{color:var(--w-s-color-icon-negative)}.s-icon-positive{color:var(--w-s-color-icon-positive)}.s-icon-warning{color:var(--w-s-color-icon-warning)}.s-border-info-subtle{border-color:var(--w-s-color-border-info-subtle)}.s-border-l-info{border-left-color:var(--w-s-color-border-info)}.s-border-l-negative{border-left-color:var(--w-s-color-border-negative)}.s-border-l-positive{border-left-color:var(--w-s-color-border-positive)}.s-border-l-warning{border-left-color:var(--w-s-color-border-warning)}.s-border-negative-subtle{border-color:var(--w-s-color-border-negative-subtle)}.s-border-positive-subtle{border-color:var(--w-s-color-border-positive-subtle)}.s-border-warning-subtle{border-color:var(--w-s-color-border-warning-subtle)}.min-w-16{min-width:1.6rem}.w-16{width:1.6rem}.last-child\\:mb-0>:last-child{margin-bottom:0}.mr-8{margin-right:.8rem}.p-16{padding:1.6rem}.text-s{font-size:var(--w-font-size-s);line-height:var(--w-line-height-s)}`;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StoryObj } from '@storybook/react';
|
|
3
|
+
import { Attention } from './react';
|
|
4
|
+
declare const _default: {
|
|
5
|
+
title: string;
|
|
6
|
+
component: React.FC<import("./react").AttentionProps>;
|
|
7
|
+
};
|
|
8
|
+
export default _default;
|
|
9
|
+
export type Story = StoryObj<typeof Attention>;
|
|
10
|
+
export declare const Default: Story;
|
|
11
|
+
export declare const ToolTip: Story;
|
|
12
|
+
export declare const Callout: Story;
|
|
13
|
+
export declare const Highlight: Story;
|
|
14
|
+
export declare const DismissibleHighlight: Story;
|
|
15
|
+
export declare const AccessibleTooltip: Story;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Button } from '../button/react';
|
|
3
|
+
import { Attention } from './react';
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Overlays/Attention',
|
|
6
|
+
component: Attention,
|
|
7
|
+
};
|
|
8
|
+
export const Default = {
|
|
9
|
+
args: {
|
|
10
|
+
placement: 'bottom',
|
|
11
|
+
popover: true,
|
|
12
|
+
flip: true,
|
|
13
|
+
},
|
|
14
|
+
render: (args) => {
|
|
15
|
+
const [show, setShow] = useState(false);
|
|
16
|
+
return (React.createElement(Attention, { ...args, show: show },
|
|
17
|
+
React.createElement(Button, { onClick: () => setShow(!show), slot: "target" }, "Click to toggle a popover"),
|
|
18
|
+
React.createElement("span", { slot: "message" }, "I'm a popover")));
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
export const ToolTip = {
|
|
22
|
+
args: {
|
|
23
|
+
placement: 'right',
|
|
24
|
+
id: 'tooltip-element',
|
|
25
|
+
tooltip: true,
|
|
26
|
+
flip: true,
|
|
27
|
+
},
|
|
28
|
+
render: (args) => {
|
|
29
|
+
const [show, setShow] = useState(false);
|
|
30
|
+
return (React.createElement(Attention, { ...args, show: show },
|
|
31
|
+
React.createElement(Button, { slot: "target", onMouseEnter: () => {
|
|
32
|
+
setShow(true);
|
|
33
|
+
}, onMouseLeave: () => setShow(false), onFocus: () => setShow(true), onBlur: () => setShow(false) }, "hover me"),
|
|
34
|
+
React.createElement("span", { slot: "message" }, "Tooltip content")));
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
export const Callout = {
|
|
38
|
+
args: {
|
|
39
|
+
placement: 'right',
|
|
40
|
+
callout: false,
|
|
41
|
+
show: true,
|
|
42
|
+
className: 'flex items-center gap-8',
|
|
43
|
+
},
|
|
44
|
+
render: (args) => {
|
|
45
|
+
return (React.createElement(Attention, { ...args },
|
|
46
|
+
React.createElement(Button, { slot: "target" }, "I need a callout"),
|
|
47
|
+
React.createElement("span", { slot: "message" }, "Callout")));
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
export const Highlight = {
|
|
51
|
+
args: {
|
|
52
|
+
placement: 'right',
|
|
53
|
+
highlight: true,
|
|
54
|
+
flip: true,
|
|
55
|
+
},
|
|
56
|
+
render: (args) => {
|
|
57
|
+
const [show, setShow] = useState(false);
|
|
58
|
+
return (React.createElement(Attention, { ...args, show: show },
|
|
59
|
+
React.createElement(Button, { onClick: () => setShow(!show), slot: "target" }, "I'm highlighted"),
|
|
60
|
+
React.createElement("span", { slot: "message" }, "Highlighted content")));
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
export const DismissibleHighlight = {
|
|
64
|
+
args: {
|
|
65
|
+
className: 'flex items-center gap-8',
|
|
66
|
+
placement: 'right',
|
|
67
|
+
canClose: true,
|
|
68
|
+
crossAxis: true,
|
|
69
|
+
highlight: true,
|
|
70
|
+
flip: true,
|
|
71
|
+
},
|
|
72
|
+
render: (args) => {
|
|
73
|
+
const [show, setShow] = useState(false);
|
|
74
|
+
return (React.createElement(Attention, { ...args, show: show, onClose: () => setShow(false) },
|
|
75
|
+
React.createElement(Button, { onClick: () => setShow(!show), slot: "target" }, "click me"),
|
|
76
|
+
React.createElement("span", { slot: "message" }, "Dismissible highlight content")));
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
export const AccessibleTooltip = {
|
|
80
|
+
args: {
|
|
81
|
+
placement: 'right',
|
|
82
|
+
popover: true,
|
|
83
|
+
},
|
|
84
|
+
render: (args) => {
|
|
85
|
+
const [show, setShow] = useState(false);
|
|
86
|
+
return (React.createElement(Attention, { ...args, show: show },
|
|
87
|
+
React.createElement("div", { slot: "message" },
|
|
88
|
+
React.createElement("p", { id: "aria-content", role: "tooltip" }, "I'm a popover with ARIA \"tooltip\" role"),
|
|
89
|
+
React.createElement("p", null, "(this text is less relevant)")),
|
|
90
|
+
React.createElement("button", { onClick: () => setShow(!show), "aria-details": "aria-content", id: "accessible-target", className: "group block relative break-words last-child:mb-0 p-16 rounded-8 s-bg-subtle", slot: "target" }, "Click to toggle a popover")));
|
|
91
|
+
},
|
|
92
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/web-components-vite';
|
|
2
|
+
import type { WarpAttention } from './index.js';
|
|
3
|
+
import './index.js';
|
|
4
|
+
import '../button/index.js';
|
|
5
|
+
declare const args: Partial<WarpAttention> & {
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
};
|
|
8
|
+
declare const meta: Meta<typeof args>;
|
|
9
|
+
export default meta;
|
|
10
|
+
type Story = StoryObj<typeof args>;
|
|
11
|
+
export declare const Default: Story;
|
|
12
|
+
export declare const ToolTip: Story;
|
|
13
|
+
export declare const Callout: Story;
|
|
14
|
+
export declare const Highlight: Story;
|
|
15
|
+
export declare const DismissibleHighlight: Story;
|
|
16
|
+
export declare const AccessibleTooltip: Story;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { spread } from '@open-wc/lit-helpers';
|
|
2
|
+
import { getStorybookHelpers } from '@wc-toolkit/storybook-helpers';
|
|
3
|
+
import { html } from 'lit';
|
|
4
|
+
import { prespread } from '../../.storybook/utilities.js';
|
|
5
|
+
import './index.js';
|
|
6
|
+
import '../button/index.js';
|
|
7
|
+
const { events, args, argTypes } = getStorybookHelpers('w-attention');
|
|
8
|
+
const meta = {
|
|
9
|
+
title: 'Overlays/Attention',
|
|
10
|
+
render(args) {
|
|
11
|
+
return html `
|
|
12
|
+
<w-attention ${spread(prespread(args))}>
|
|
13
|
+
<w-button
|
|
14
|
+
${spread({ id: args.buttonId })}
|
|
15
|
+
variant="secondary"
|
|
16
|
+
slot="target">
|
|
17
|
+
${args.buttonText}
|
|
18
|
+
</w-button>
|
|
19
|
+
<span slot="message">I'm a message</span>
|
|
20
|
+
</w-attention>
|
|
21
|
+
`;
|
|
22
|
+
},
|
|
23
|
+
args,
|
|
24
|
+
argTypes,
|
|
25
|
+
parameters: {
|
|
26
|
+
actions: {
|
|
27
|
+
handles: events,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
export default meta;
|
|
32
|
+
export const Default = {
|
|
33
|
+
args: {
|
|
34
|
+
placement: 'bottom',
|
|
35
|
+
popover: true,
|
|
36
|
+
flip: true,
|
|
37
|
+
},
|
|
38
|
+
render(args) {
|
|
39
|
+
return html `
|
|
40
|
+
<w-attention ${spread(prespread(args))}>
|
|
41
|
+
<w-button
|
|
42
|
+
id="popoverTarget"
|
|
43
|
+
slot="target"
|
|
44
|
+
variant="secondary"
|
|
45
|
+
@click=${(e) => { const attention = e.currentTarget.closest('w-attention'); attention.show = !attention.show; }}>
|
|
46
|
+
Click to toggle a popover
|
|
47
|
+
</w-button>
|
|
48
|
+
<span slot="message">I'm a popover</span>
|
|
49
|
+
</w-attention>
|
|
50
|
+
`;
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
export const ToolTip = {
|
|
54
|
+
args: {
|
|
55
|
+
placement: 'right',
|
|
56
|
+
buttonText: 'hover me',
|
|
57
|
+
id: 'tooltip-element',
|
|
58
|
+
tooltip: true,
|
|
59
|
+
flip: true,
|
|
60
|
+
buttonId: 'tooltip-target',
|
|
61
|
+
},
|
|
62
|
+
decorators: [
|
|
63
|
+
(story) => html `
|
|
64
|
+
${story()}
|
|
65
|
+
<script>
|
|
66
|
+
(() => {
|
|
67
|
+
const button = document.getElementById('tooltip-target');
|
|
68
|
+
const tooltip = document.getElementById('tooltip-element');
|
|
69
|
+
button.addEventListener('mouseenter', () => {
|
|
70
|
+
tooltip.show = true;
|
|
71
|
+
});
|
|
72
|
+
button.addEventListener('mouseleave', () => {
|
|
73
|
+
tooltip.show = false;
|
|
74
|
+
});
|
|
75
|
+
button.addEventListener('focus', () => {
|
|
76
|
+
tooltip.show = true;
|
|
77
|
+
});
|
|
78
|
+
button.addEventListener('blur', () => {
|
|
79
|
+
tooltip.show = false;
|
|
80
|
+
});
|
|
81
|
+
})();
|
|
82
|
+
</script>
|
|
83
|
+
`,
|
|
84
|
+
],
|
|
85
|
+
};
|
|
86
|
+
export const Callout = {
|
|
87
|
+
args: {
|
|
88
|
+
buttonText: 'i need a callout',
|
|
89
|
+
class: 'flex items-center gap-8',
|
|
90
|
+
placement: 'right',
|
|
91
|
+
callout: true,
|
|
92
|
+
show: true,
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
export const Highlight = {
|
|
96
|
+
args: {
|
|
97
|
+
buttonId: 'highlight-target1',
|
|
98
|
+
id: 'highlight-message',
|
|
99
|
+
buttonText: `I'm highlighted`,
|
|
100
|
+
placement: 'right',
|
|
101
|
+
highlight: true,
|
|
102
|
+
flip: true,
|
|
103
|
+
},
|
|
104
|
+
decorators: [
|
|
105
|
+
(story) => html `
|
|
106
|
+
${story()}
|
|
107
|
+
<script>
|
|
108
|
+
(() => {
|
|
109
|
+
const button = document.getElementById('highlight-target1');
|
|
110
|
+
const highlight = document.getElementById('highlight-message');
|
|
111
|
+
button.addEventListener('click', () => {
|
|
112
|
+
highlight.show = !highlight.show;
|
|
113
|
+
});
|
|
114
|
+
})();
|
|
115
|
+
</script>
|
|
116
|
+
`,
|
|
117
|
+
],
|
|
118
|
+
};
|
|
119
|
+
export const DismissibleHighlight = {
|
|
120
|
+
args: {
|
|
121
|
+
class: 'flex items-center gap-8',
|
|
122
|
+
placement: 'right',
|
|
123
|
+
buttonId: 'highlight-target2',
|
|
124
|
+
buttonText: 'click me',
|
|
125
|
+
id: 'dismissible-highlight-message',
|
|
126
|
+
['can-close']: true,
|
|
127
|
+
['cross-axis']: true,
|
|
128
|
+
highlight: true,
|
|
129
|
+
flip: true,
|
|
130
|
+
},
|
|
131
|
+
decorators: [
|
|
132
|
+
(story) => html `
|
|
133
|
+
${story()}
|
|
134
|
+
<script>
|
|
135
|
+
(() => {
|
|
136
|
+
const button = document.getElementById('highlight-target2');
|
|
137
|
+
const highlight = document.getElementById('dismissible-highlight-message');
|
|
138
|
+
button.addEventListener('click', () => {
|
|
139
|
+
highlight.show = true;
|
|
140
|
+
});
|
|
141
|
+
highlight.addEventListener('close', () => {
|
|
142
|
+
highlight.show = false;
|
|
143
|
+
});
|
|
144
|
+
})();
|
|
145
|
+
</script>
|
|
146
|
+
`,
|
|
147
|
+
],
|
|
148
|
+
};
|
|
149
|
+
export const AccessibleTooltip = {
|
|
150
|
+
args: {},
|
|
151
|
+
render() {
|
|
152
|
+
return html `
|
|
153
|
+
<w-attention id="accessible-attention" placement="right" popover>
|
|
154
|
+
<div slot="message">
|
|
155
|
+
<p id="aria-content" role="tooltip">I'm a popover with ARIA "tooltip" role</p>
|
|
156
|
+
<p>(this text is less relevant)</p>
|
|
157
|
+
</div>
|
|
158
|
+
<w-button
|
|
159
|
+
aria-details="aria-content"
|
|
160
|
+
id="accessible-target"
|
|
161
|
+
slot="target"
|
|
162
|
+
variant="secondary">
|
|
163
|
+
Click to toggle a popover
|
|
164
|
+
</w-button>
|
|
165
|
+
</w-attention>
|
|
166
|
+
`;
|
|
167
|
+
},
|
|
168
|
+
decorators: [
|
|
169
|
+
(story) => html ` ${story()}
|
|
170
|
+
<script>
|
|
171
|
+
(() => {
|
|
172
|
+
const button = document.getElementById('accessible-target');
|
|
173
|
+
const accessibleAttention = document.getElementById('accessible-attention');
|
|
174
|
+
button.addEventListener('click', () => {
|
|
175
|
+
accessibleAttention.show = !accessibleAttention.show;
|
|
176
|
+
});
|
|
177
|
+
})();
|
|
178
|
+
</script>`,
|
|
179
|
+
],
|
|
180
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './index.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { page } from '@vitest/browser/context';
|
|
2
|
+
import { html } from 'lit';
|
|
3
|
+
import { expect, test } from 'vitest';
|
|
4
|
+
import './index.js';
|
|
5
|
+
test('renders an info', async () => {
|
|
6
|
+
const screen = await page.render(html `<w-attention show data-testid="attentionTarget" placement="bottom" popover flip>
|
|
7
|
+
<button id="target" slot="target" onclick="toggleShow()">Click to toggle a popover</button>
|
|
8
|
+
<span slot="message">I'm a popover</span>
|
|
9
|
+
</w-attention>`);
|
|
10
|
+
await expect.element(screen.getByTestId('attentionTarget')).toBeVisible();
|
|
11
|
+
});
|
|
@@ -1,69 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { Directions } from '@warp-ds/core/attention';
|
|
2
|
+
import { LitElement } from 'lit';
|
|
3
|
+
import '@warp-ds/icons/elements/close-16';
|
|
4
|
+
import '../button/index';
|
|
5
|
+
export declare const ccAttention: {
|
|
6
|
+
base: string;
|
|
7
|
+
tooltip: string;
|
|
8
|
+
callout: string;
|
|
9
|
+
highlight: string;
|
|
10
|
+
popover: string;
|
|
11
|
+
arrowBase: string;
|
|
12
|
+
arrowDirectionLeftStart: string;
|
|
13
|
+
arrowDirectionLeft: string;
|
|
14
|
+
arrowDirectionLeftEnd: string;
|
|
15
|
+
arrowDirectionRightStart: string;
|
|
16
|
+
arrowDirectionRight: string;
|
|
17
|
+
arrowDirectionRightEnd: string;
|
|
18
|
+
arrowDirectionBottomStart: string;
|
|
19
|
+
arrowDirectionBottom: string;
|
|
20
|
+
arrowDirectionBottomEnd: string;
|
|
21
|
+
arrowDirectionTopStart: string;
|
|
22
|
+
arrowDirectionTop: string;
|
|
23
|
+
arrowDirectionTopEnd: string;
|
|
24
|
+
arrowTooltip: string;
|
|
25
|
+
arrowCallout: string;
|
|
26
|
+
arrowPopover: string;
|
|
27
|
+
arrowHighlight: string;
|
|
28
|
+
content: string;
|
|
29
|
+
notCallout: string;
|
|
7
30
|
};
|
|
8
|
-
|
|
9
|
-
static properties: {
|
|
10
|
-
show: {
|
|
11
|
-
type: BooleanConstructor;
|
|
12
|
-
reflect: boolean;
|
|
13
|
-
};
|
|
14
|
-
placement: {
|
|
15
|
-
type: StringConstructor;
|
|
16
|
-
reflect: boolean;
|
|
17
|
-
};
|
|
18
|
-
tooltip: {
|
|
19
|
-
type: BooleanConstructor;
|
|
20
|
-
reflect: boolean;
|
|
21
|
-
};
|
|
22
|
-
callout: {
|
|
23
|
-
type: BooleanConstructor;
|
|
24
|
-
reflect: boolean;
|
|
25
|
-
};
|
|
26
|
-
popover: {
|
|
27
|
-
type: BooleanConstructor;
|
|
28
|
-
reflect: boolean;
|
|
29
|
-
};
|
|
30
|
-
highlight: {
|
|
31
|
-
type: BooleanConstructor;
|
|
32
|
-
reflect: boolean;
|
|
33
|
-
};
|
|
34
|
-
canClose: {
|
|
35
|
-
type: BooleanConstructor;
|
|
36
|
-
reflect: boolean;
|
|
37
|
-
};
|
|
38
|
-
noArrow: {
|
|
39
|
-
type: BooleanConstructor;
|
|
40
|
-
reflect: boolean;
|
|
41
|
-
};
|
|
42
|
-
distance: {
|
|
43
|
-
type: NumberConstructor;
|
|
44
|
-
reflect: boolean;
|
|
45
|
-
};
|
|
46
|
-
skidding: {
|
|
47
|
-
type: NumberConstructor;
|
|
48
|
-
reflect: boolean;
|
|
49
|
-
};
|
|
50
|
-
flip: {
|
|
51
|
-
type: BooleanConstructor;
|
|
52
|
-
reflect: boolean;
|
|
53
|
-
};
|
|
54
|
-
crossAxis: {
|
|
55
|
-
type: BooleanConstructor;
|
|
56
|
-
reflect: boolean;
|
|
57
|
-
};
|
|
58
|
-
fallbackPlacements: {
|
|
59
|
-
type: ArrayConstructor;
|
|
60
|
-
reflect: boolean;
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
static styles: (import("lit").CSSResult | (import("lit").CSSResult | CSSStyleSheet | import("lit").CSSResultArray)[])[];
|
|
64
|
-
handleDone(): void;
|
|
31
|
+
declare class WarpAttention extends LitElement {
|
|
65
32
|
show: boolean;
|
|
66
|
-
placement:
|
|
33
|
+
placement: Directions;
|
|
67
34
|
tooltip: boolean;
|
|
68
35
|
callout: boolean;
|
|
69
36
|
popover: boolean;
|
|
@@ -74,48 +41,53 @@ export class WarpAttention extends WarpAttention_base {
|
|
|
74
41
|
skidding: number;
|
|
75
42
|
flip: boolean;
|
|
76
43
|
crossAxis: boolean;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
44
|
+
fallbackPlacements: Directions[];
|
|
45
|
+
/** @internal */
|
|
46
|
+
attentionState: any;
|
|
47
|
+
/** @internal */
|
|
48
|
+
_initialPlacement: Directions;
|
|
49
|
+
static styles: import("lit").CSSResult[];
|
|
50
|
+
constructor();
|
|
80
51
|
connectedCallback(): void;
|
|
81
52
|
disconnectedCallback(): void;
|
|
82
|
-
|
|
83
|
-
|
|
53
|
+
handleDone(): void;
|
|
54
|
+
/** @internal */
|
|
55
|
+
get _actualDirection(): Directions;
|
|
56
|
+
/** @internal */
|
|
57
|
+
set _actualDirection(v: Directions);
|
|
58
|
+
/** @internal */
|
|
59
|
+
get _arrowEl(): Element;
|
|
60
|
+
/** @internal */
|
|
61
|
+
get _arrowDirection(): Directions;
|
|
62
|
+
/** @internal */
|
|
84
63
|
get _arrowClasses(): string;
|
|
64
|
+
/** @internal */
|
|
85
65
|
get _arrowHtml(): import("lit").TemplateResult<1> | "";
|
|
66
|
+
/** @internal */
|
|
86
67
|
get _activeVariantClasses(): {
|
|
87
68
|
wrapper: any;
|
|
88
69
|
arrow: any;
|
|
89
70
|
};
|
|
90
|
-
|
|
91
|
-
get
|
|
92
|
-
|
|
71
|
+
/** @internal */
|
|
72
|
+
get _attentionEl(): HTMLDivElement;
|
|
73
|
+
/** @internal */
|
|
74
|
+
get _targetEl(): Element | null;
|
|
75
|
+
/** @internal */
|
|
76
|
+
get _messageEl(): Element | null;
|
|
77
|
+
/** @internal */
|
|
93
78
|
get _wrapperClasses(): string;
|
|
79
|
+
/** @internal */
|
|
94
80
|
get _ariaClose(): string;
|
|
81
|
+
/** @internal */
|
|
95
82
|
get _closeBtnHtml(): import("lit").TemplateResult<1>;
|
|
96
83
|
updated(): void;
|
|
97
|
-
attentionState: {
|
|
98
|
-
isShowing: boolean;
|
|
99
|
-
isCallout: boolean;
|
|
100
|
-
actualDirection: string;
|
|
101
|
-
directionName: string;
|
|
102
|
-
arrowEl: any;
|
|
103
|
-
attentionEl: any;
|
|
104
|
-
targetEl: any;
|
|
105
|
-
noArrow: boolean;
|
|
106
|
-
distance: number;
|
|
107
|
-
skidding: number;
|
|
108
|
-
flip: boolean;
|
|
109
|
-
crossAxis: boolean;
|
|
110
|
-
fallbackPlacements: any;
|
|
111
|
-
};
|
|
112
84
|
pointingAtDirection(): string;
|
|
113
85
|
activeAttentionType(): string;
|
|
114
86
|
defaultAriaLabel(): string;
|
|
115
87
|
setAriaLabels(): void;
|
|
116
88
|
firstUpdated(): void;
|
|
117
89
|
close(): void;
|
|
118
|
-
keypressed(e:
|
|
90
|
+
keypressed(e: KeyboardEvent): void;
|
|
119
91
|
render(): import("lit").TemplateResult<1>;
|
|
120
92
|
}
|
|
121
|
-
export {};
|
|
93
|
+
export { WarpAttention };
|