@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
package/README.md
CHANGED
|
@@ -14,64 +14,253 @@ start by reviewing the [contributing guidelines](CONTRIBUTING.md).
|
|
|
14
14
|
|
|
15
15
|
### Installation
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
Warp custom elements are supplied by the Eik CDN.
|
|
18
|
+
In addition, you can install the `@warp-ds/elements` package to get intellisense
|
|
19
|
+
in your editor.
|
|
18
20
|
|
|
19
|
-
####
|
|
21
|
+
#### Step 1.
|
|
22
|
+
|
|
23
|
+
Add the following script and style to the very top of your document head to ensure performant loading
|
|
24
|
+
|
|
25
|
+
```html
|
|
26
|
+
<link rel="stylesheet" href="https://assets.finn.no/pkg/@warp-ds/elements/2.2.0-next.13/styles.css" crossorigin />
|
|
27
|
+
<script src="https://assets.finn.no/pkg/@warp-ds/elements/2.2.0-next.13/index.js" type="module"></script>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
#### Step 2.
|
|
31
|
+
|
|
32
|
+
Be sure to preload whichever brand fonts you need for a page and load the correct font file:
|
|
33
|
+
|
|
34
|
+
```html
|
|
35
|
+
<!-- Finn example -->
|
|
36
|
+
<link rel="preload" href="https://assets.finn.no/pkg/@warp-ds/fonts/v1/FINNTypeAlleTegn-Light.woff2" as="font" type="font/woff2" crossorigin>
|
|
37
|
+
<link rel="preload" href="https://assets.finn.no/pkg/@warp-ds/fonts/v1/FINNTypeAlleTegn-Medium.woff2" as="font" type="font/woff2" crossorigin>
|
|
38
|
+
<link rel="stylesheet" href="https://assets.finn.no/pkg/@warp-ds/fonts/v1/finn-no.css" crossorigin>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
```html
|
|
42
|
+
<!-- Tori example -->
|
|
43
|
+
<link rel="preload" href="https://assets.finn.no/pkg/@warp-ds/fonts/v1/ToriSans-Regular.woff2" as="font" type="font/woff2" crossorigin>
|
|
44
|
+
<link rel="preload" href="https://assets.finn.no/pkg/@warp-ds/fonts/v1/ToriSans-Bold.woff2" as="font" type="font/woff2" crossorigin>
|
|
45
|
+
<link rel="preload" href="https://assets.finn.no/pkg/@warp-ds/fonts/v1/ToriSans-Italic.woff2" as="font" type="font/woff2" crossorigin>
|
|
46
|
+
<link rel="stylesheet" href="https://assets.finn.no/pkg/@warp-ds/fonts/v1/tori-fi.css" crossorigin>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
```html
|
|
50
|
+
<!-- DBA example -->
|
|
51
|
+
<link rel="preload" href="https://assets.finn.no/pkg/@warp-ds/fonts/v1/ProximaNova-Regular.woff2" as="font" type="font/woff2" crossorigin>
|
|
52
|
+
<link rel="preload" href="https://assets.finn.no/pkg/@warp-ds/fonts/v1/ProximaNova-Bold.woff2" as="font" type="font/woff2" crossorigin>
|
|
53
|
+
<link rel="stylesheet" href="https://assets.finn.no/pkg/@warp-ds/fonts/v1/dba-dk.css" crossorigin>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
```html
|
|
57
|
+
<!-- Blocket example -->
|
|
58
|
+
<link rel="preload" href="https://assets.finn.no/pkg/@warp-ds/fonts/v1/BlocketSans-Regular.woff2" as="font" type="font/woff2" crossorigin>
|
|
59
|
+
<link rel="preload" href="https://assets.finn.no/pkg/@warp-ds/fonts/v1/BlocketSans-Bold.woff2" as="font" type="font/woff2" crossorigin>
|
|
60
|
+
<link rel="preload" href="https://assets.finn.no/pkg/@warp-ds/fonts/v1/BlocketSans-Medium.woff2" as="font" type="font/woff2" crossorigin>
|
|
61
|
+
<link rel="stylesheet" href="https://assets.finn.no/pkg/@warp-ds/fonts/v1/blocket-se.css" crossorigin>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
#### Step 3.
|
|
65
|
+
|
|
66
|
+
You'll also want to load Warp tokens and resets CSS files to ensure consistent and correct styling for the brand.
|
|
67
|
+
|
|
68
|
+
```html
|
|
69
|
+
<!-- Finn example -->
|
|
70
|
+
<link rel="stylesheet" href="https://assets.finn.no/pkg/@warp-ds/css/v2/tokens/finn-no.css" crossorigin>
|
|
71
|
+
<link rel="stylesheet" href="https://assets.finn.no/pkg/@warp-ds/css/v2/resets.css" crossorigin>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
```html
|
|
75
|
+
<!-- Tori example -->
|
|
76
|
+
<link rel="stylesheet" href="https://assets.finn.no/pkg/@warp-ds/css/v2/tokens/tori-fi.css" crossorigin>
|
|
77
|
+
<link rel="stylesheet" href="https://assets.finn.no/pkg/@warp-ds/css/v2/resets.css" crossorigin>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
```html
|
|
81
|
+
<!-- DBA example -->
|
|
82
|
+
<link rel="stylesheet" href="https://assets.finn.no/pkg/@warp-ds/css/v2/tokens/dba-dk.css" crossorigin>
|
|
83
|
+
<link rel="stylesheet" href="https://assets.finn.no/pkg/@warp-ds/css/v2/resets.css" crossorigin>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
```html
|
|
87
|
+
<!-- Blocket example -->
|
|
88
|
+
<link rel="stylesheet" href="https://assets.finn.no/pkg/@warp-ds/css/v2/tokens/blocket-se.css" crossorigin>
|
|
89
|
+
<link rel="stylesheet" href="https://assets.finn.no/pkg/@warp-ds/css/v2/resets.css" crossorigin>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
#### Step 4.
|
|
93
|
+
|
|
94
|
+
Next, to add intellisense to your editor install `@warp-ds/elements` by using npm/pnpm. See the Editor integration below.
|
|
95
|
+
|
|
96
|
+
##### Install using npm
|
|
20
97
|
|
|
21
98
|
```sh
|
|
22
99
|
npm install @warp-ds/elements
|
|
23
100
|
```
|
|
24
101
|
|
|
25
|
-
|
|
102
|
+
##### Install using pnpm
|
|
26
103
|
|
|
27
104
|
```sh
|
|
28
105
|
pnpm add @warp-ds/elements
|
|
29
106
|
```
|
|
30
107
|
|
|
31
|
-
|
|
108
|
+
And then head on down to the editor configuration section below to complete setup.
|
|
109
|
+
|
|
110
|
+
### Using Warp elements with Borealis
|
|
111
|
+
|
|
112
|
+
If you are using Borealis modules from the Web Platform Team (and you should be) and keeping your app dependencies up to date (and you should be), then steps 2 and 3 are already taken care of for you, you just need to do steps 1 and 4.
|
|
113
|
+
|
|
114
|
+
### Documentation
|
|
115
|
+
|
|
116
|
+
For information on the components available in the package and how to use them,
|
|
117
|
+
see the [Warp Design System documentation](https://warp-ds.github.io/tech-docs/).
|
|
118
|
+
|
|
119
|
+
### Editor integration
|
|
120
|
+
|
|
121
|
+
#### Typescript
|
|
122
|
+
|
|
123
|
+
Install the `@warp-ds/elements` package
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
npm install @warp-ds/elements
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Add `@warp-ds/elements` to tsconfig types in compilerOptions.
|
|
130
|
+
|
|
131
|
+
```json
|
|
132
|
+
{
|
|
133
|
+
"compilerOptions": {
|
|
134
|
+
"types": ["react", "react-dom", "@warp-ds/elements"]
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
#### Visual Studio Code
|
|
140
|
+
|
|
141
|
+
Install the [Web Components Language Server](https://wc-toolkit.com/integrations/web-components-language-server/) extension. The extension automatically picks up the [Custom Element Manifest](https://wc-toolkit.com/getting-started/) that we ship with `@warp-ds/elements`.
|
|
142
|
+
|
|
143
|
+
##### Using Warp Elements in a plain HTML page
|
|
144
|
+
|
|
145
|
+
Install Warp Elements locally using npm:
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
npm install @warp-ds/elements
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Install the [Web Components Language Server](https://wc-toolkit.com/integrations/web-components-language-server/) extension.
|
|
152
|
+
|
|
153
|
+
Now, inside any `.html` files, you will get IntelliSense when using Warp Elements:
|
|
32
154
|
|
|
33
155
|
```html
|
|
34
|
-
<
|
|
156
|
+
<w-button variant=""><w-button>
|
|
35
157
|
```
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
158
|
+
|
|
159
|
+
##### Using Warp Elements in JavaScript template literals
|
|
160
|
+
|
|
161
|
+
IntelliSense in JavaScript strings is not supported without additional plugins and syntax, such as comment hints (`/* html */`) or a tagged template literal similar to Lit.
|
|
162
|
+
|
|
163
|
+
##### Using Warp Elements in Lit html tagged template literals
|
|
164
|
+
|
|
165
|
+
Install Warp Elements locally using npm:
|
|
166
|
+
|
|
40
167
|
```
|
|
41
|
-
|
|
42
|
-
```js
|
|
43
|
-
import '@warp-ds/elements/components/toast';
|
|
168
|
+
npm install @warp-ds/elements
|
|
44
169
|
```
|
|
45
170
|
|
|
46
|
-
|
|
171
|
+
Install the [Web Components Language Server](https://wc-toolkit.com/integrations/web-components-language-server/) extension.
|
|
47
172
|
|
|
48
|
-
|
|
49
|
-
see the [Warp Design System documentation](https://warp-ds.github.io/tech-docs/).
|
|
173
|
+
Install the [lit-plugin](https://marketplace.visualstudio.com/items?itemName=runem.lit-plugin) extension.
|
|
50
174
|
|
|
51
|
-
|
|
175
|
+
Now, inside any html`` tagged template literals, you will get intellisense when using Warp Elements.
|
|
52
176
|
|
|
53
|
-
|
|
54
|
-
|
|
177
|
+
```html
|
|
178
|
+
<w-button variant=""><w-button>
|
|
179
|
+
```
|
|
55
180
|
|
|
56
|
-
|
|
181
|
+
##### Using Warp Elements in a React app, v19 or later
|
|
57
182
|
|
|
58
|
-
|
|
183
|
+
```
|
|
184
|
+
npm install @warp-ds/elements
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Now, inside your react components, you will get intellisense when using Warp Elements.
|
|
188
|
+
|
|
189
|
+
```html
|
|
190
|
+
<w-button variant=""><w-button>
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
##### Using Warp Elements in a React app, v18 or earlier
|
|
194
|
+
|
|
195
|
+
React 18 and earlier do not support custom elements.
|
|
196
|
+
|
|
197
|
+
If you are on React 18 or early, we strongly urge you to please consider upgrading to React v19.
|
|
198
|
+
|
|
199
|
+
If you cannot upgrade right away, Warp supplies custom element wrappers to add backwards compatibility. Use them like so:
|
|
59
200
|
|
|
60
|
-
|
|
201
|
+
```
|
|
202
|
+
npm install @warp-ds/elements
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Wherever you need to use a component in your app, import the appropriate element from the React namespace
|
|
61
206
|
|
|
62
|
-
|
|
207
|
+
```js
|
|
208
|
+
import { Button } from "@warp-ds/elements/react/button";
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
and use the component
|
|
63
212
|
|
|
64
213
|
```js
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
214
|
+
<Button variant="primary"></Button>
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
you should get intellisense when using Warp Elements.
|
|
218
|
+
|
|
219
|
+
#### CustomData fallback
|
|
220
|
+
|
|
221
|
+
`@warp-ds/elements` also includes [Custom HTML and CSS data for Visual Studio Code](https://code.visualstudio.com/blogs/2020/02/24/custom-data-format).
|
|
222
|
+
|
|
223
|
+
If you can't get the Web Components Language Server to work, add the following snippet to `.vscode/settings.json`, then restart VS Code.
|
|
224
|
+
|
|
225
|
+
```json
|
|
226
|
+
{
|
|
227
|
+
"html.customData": [
|
|
228
|
+
"./node_modules/@warp-ds/elements/dist/vscode.html-custom-data.json"
|
|
229
|
+
],
|
|
230
|
+
"css.customData": [
|
|
231
|
+
"./node_modules/@warp-ds/elements/dist/vscode.css-custom-data.json"
|
|
69
232
|
]
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
#### JetBrains products
|
|
237
|
+
|
|
238
|
+
We ship `web-types.json` which should get picked up automatically by JetBrains IDEA and similar products.
|
|
239
|
+
|
|
240
|
+
You should see code completions and inline docs for Warp elements when writing HTML.
|
|
241
|
+
|
|
242
|
+
### Ensure elements are ready (and avoid CLS and FOUCE)
|
|
243
|
+
|
|
244
|
+
To avoid issues like CLS (cumulative layout shift) and FOUCE (flash of unstyled custom elements), its important that Warp Elements is loaded before the page is rendered. For this reason, elements should not be bundled into the rest of your client side application and code and should be loaded in the document head, as early as possible (see installation above). When this is done correctly, elements will be loaded and ready about the same time as the rest of the page styles and wont cause delays in page load times. However, due to the way browsers work, a page render will occur without the components and an immediate re-render will occur with the components. This causes things to jump around on the page which in turn impacts lighthouse and other performance scores. Warp elements ships with a tool to prevent the initial render without components and only do the second, with components, render. This tool is called Warp Cloak and its usage is described below.
|
|
245
|
+
|
|
246
|
+
#### The Warp cloaking device
|
|
247
|
+
|
|
248
|
+
To use the Warp cloaking device to avoid CLS and FOUCE, simply add the warp-cloak class to your pages body, html or a wrapper div that contains all the pages visible elements (including the header and footer)
|
|
249
|
+
|
|
250
|
+
```html
|
|
251
|
+
<body class="warp-cloak">
|
|
70
252
|
```
|
|
71
253
|
|
|
72
|
-
|
|
254
|
+
That's it, your components should render just 1x, fully ready with no CLS and FOUCE.
|
|
73
255
|
|
|
74
|
-
|
|
256
|
+
## Releases
|
|
257
|
+
|
|
258
|
+
This project is continuously published to [NPM](https://www.npmjs.com/package/@warp-ds/elements) and [Eik](https://assets.finn.no/pkg/@warp-ds/elements) using a `next` tag (e.g. `2.2.0-next.13`).
|
|
259
|
+
Anyone needing to use the latest changes of this package can point to the `next` version while waiting for the stable release.
|
|
260
|
+
|
|
261
|
+
## Changelog
|
|
262
|
+
|
|
263
|
+
Detailed changes for each release can be found in the [CHANGELOG](CHANGELOG.md) file.
|
|
75
264
|
|
|
76
265
|
## License
|
|
77
266
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Massages storybook args before being spread to HTML attributes.
|
|
3
|
+
*
|
|
4
|
+
* - Empty strings are treated as not set.
|
|
5
|
+
* - Boolean false don't get set.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { html } from 'lit';
|
|
10
|
+
* import { spread } from '@open-wc/lit-helpers';
|
|
11
|
+
* import { prespread } from '../../.storybook/utilities.js';
|
|
12
|
+
*
|
|
13
|
+
* type Args = {
|
|
14
|
+
* required: boolean;
|
|
15
|
+
* };
|
|
16
|
+
*
|
|
17
|
+
* const meta: Meta<Args> = {
|
|
18
|
+
* component: 'w-component',
|
|
19
|
+
* render(args) {
|
|
20
|
+
* return html`<w-component ${spread(prespread(args))}></w-component>`;
|
|
21
|
+
* },
|
|
22
|
+
* argTypes: {
|
|
23
|
+
* required: { type: 'boolean' },
|
|
24
|
+
* },
|
|
25
|
+
* };
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function prespread(args: Record<string, unknown>): Record<string, unknown>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Massages storybook args before being spread to HTML attributes.
|
|
3
|
+
*
|
|
4
|
+
* - Empty strings are treated as not set.
|
|
5
|
+
* - Boolean false don't get set.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { html } from 'lit';
|
|
10
|
+
* import { spread } from '@open-wc/lit-helpers';
|
|
11
|
+
* import { prespread } from '../../.storybook/utilities.js';
|
|
12
|
+
*
|
|
13
|
+
* type Args = {
|
|
14
|
+
* required: boolean;
|
|
15
|
+
* };
|
|
16
|
+
*
|
|
17
|
+
* const meta: Meta<Args> = {
|
|
18
|
+
* component: 'w-component',
|
|
19
|
+
* render(args) {
|
|
20
|
+
* return html`<w-component ${spread(prespread(args))}></w-component>`;
|
|
21
|
+
* },
|
|
22
|
+
* argTypes: {
|
|
23
|
+
* required: { type: 'boolean' },
|
|
24
|
+
* },
|
|
25
|
+
* };
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export function prespread(args) {
|
|
29
|
+
const newArgs = {
|
|
30
|
+
...args,
|
|
31
|
+
};
|
|
32
|
+
for (const field of Object.keys(newArgs)) {
|
|
33
|
+
const value = args[field];
|
|
34
|
+
// Add Lit syntax for boolean attributes
|
|
35
|
+
if (typeof value === 'boolean') {
|
|
36
|
+
newArgs[`?${field}`] = value;
|
|
37
|
+
delete newArgs[field];
|
|
38
|
+
}
|
|
39
|
+
// Add Lit syntax for complex properties
|
|
40
|
+
if (typeof value === 'object') {
|
|
41
|
+
newArgs[`.${field}`] = value;
|
|
42
|
+
delete newArgs[field];
|
|
43
|
+
}
|
|
44
|
+
// The manifest has a bunch of default empty strings (which we should probably investigate)
|
|
45
|
+
// that turn on features that should be off in Storybook canvases.
|
|
46
|
+
// Remove the empty strings.
|
|
47
|
+
if (newArgs[field] === '') {
|
|
48
|
+
delete newArgs[field];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return newArgs;
|
|
52
|
+
}
|
package/dist/api.js
CHANGED
|
@@ -1,50 +1,2 @@
|
|
|
1
|
-
var
|
|
2
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __spreadValues = (a, b) => {
|
|
7
|
-
for (var prop in b || (b = {}))
|
|
8
|
-
if (__hasOwnProp.call(b, prop))
|
|
9
|
-
__defNormalProp(a, prop, b[prop]);
|
|
10
|
-
if (__getOwnPropSymbols)
|
|
11
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
-
if (__propIsEnum.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
}
|
|
15
|
-
return a;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
// packages/utils/window-exists.js
|
|
19
|
-
var windowExists = typeof window !== "undefined";
|
|
20
|
-
|
|
21
|
-
// packages/toast/api.js
|
|
22
|
-
function toast(message, options) {
|
|
23
|
-
if (!windowExists) return;
|
|
24
|
-
const toast2 = customElements.get("w-toast-container").init();
|
|
25
|
-
const data = __spreadValues({
|
|
26
|
-
id: Date.now().toString(36) + Math.random().toString(36).slice(2, 5),
|
|
27
|
-
text: message,
|
|
28
|
-
duration: 5e3,
|
|
29
|
-
type: "success"
|
|
30
|
-
}, options);
|
|
31
|
-
toast2.set(data);
|
|
32
|
-
return data;
|
|
33
|
-
}
|
|
34
|
-
function removeToast(id) {
|
|
35
|
-
if (!windowExists) return;
|
|
36
|
-
const toast2 = customElements.get("w-toast-container").init();
|
|
37
|
-
return toast2.del(id);
|
|
38
|
-
}
|
|
39
|
-
function updateToast(id, options) {
|
|
40
|
-
if (!windowExists) return;
|
|
41
|
-
const toast2 = customElements.get("w-toast-container").init();
|
|
42
|
-
toast2.set(__spreadValues(__spreadValues({}, toast2.get(id)), options));
|
|
43
|
-
return toast2.get(id);
|
|
44
|
-
}
|
|
45
|
-
export {
|
|
46
|
-
removeToast,
|
|
47
|
-
toast,
|
|
48
|
-
updateToast
|
|
49
|
-
};
|
|
1
|
+
var e=typeof window!="undefined";function r(){return customElements.get("w-toast-container")}function p(t,o){if(!e)return;let n=r().init(),s={id:Date.now().toString(36)+Math.random().toString(36).slice(2,5),text:t,duration:5e3,type:"success",...o};return n.set(s),s}function u(t){return e?r().init().del(t):void 0}function c(t,o){if(!e)return;let n=r().init();return n.set({...n.get(t),...o}),n.get(t)}export{u as removeToast,p as toast,c as updateToast};
|
|
50
2
|
//# sourceMappingURL=api.js.map
|
package/dist/api.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../packages/utils/window-exists.js", "../packages/toast/api.
|
|
4
|
-
"sourcesContent": ["export const windowExists = typeof window !== 'undefined';\n", "import { windowExists } from '../utils/window-exists';\n\
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["toast"]
|
|
3
|
+
"sources": ["../packages/utils/window-exists.js", "../packages/toast/api.ts"],
|
|
4
|
+
"sourcesContent": ["export const windowExists = typeof window !== 'undefined';\n", "import { windowExists } from '../utils/window-exists';\n\nimport { WarpToastContainer } from './toast-container';\nimport type { ToastInternal, ToastOptions } from './types';\n\nfunction getToastContainer() {\n const container = customElements.get('w-toast-container');\n return container as typeof WarpToastContainer;\n}\n\n/**\n * Creates a new toast\n */\nexport function toast(message: string, options?: ToastOptions) {\n if (!windowExists) return;\n\n const toast = getToastContainer().init() as WarpToastContainer;\n\n const data: ToastOptions = {\n id: Date.now().toString(36) + Math.random().toString(36).slice(2, 5),\n text: message,\n duration: 5000,\n type: 'success',\n ...options,\n };\n\n toast.set(data);\n return data;\n}\n\n/**\n * Remove an existing toast\n */\nexport function removeToast(id: string | number): Promise<boolean> | undefined {\n if (!windowExists) return;\n\n const toast = getToastContainer().init() as WarpToastContainer;\n return toast.del(id);\n}\n\n/**\n * Update an existing toast\n */\nexport function updateToast(id: string | number, options?: ToastOptions): ToastInternal | undefined {\n if (!windowExists) return;\n\n const toast = getToastContainer().init() as WarpToastContainer;\n toast.set({ ...toast.get(id), ...options });\n return toast.get(id);\n}\n"],
|
|
5
|
+
"mappings": "AAAO,IAAMA,EAAe,OAAO,QAAW,YCK9C,SAASC,GAAoB,CAE3B,OADkB,eAAe,IAAI,mBAAmB,CAE1D,CAKO,SAASC,EAAMC,EAAiBC,EAAwB,CAC7D,GAAI,CAACC,EAAc,OAEnB,IAAMH,EAAQD,EAAkB,EAAE,KAAK,EAEjCK,EAAqB,CACzB,GAAI,KAAK,IAAI,EAAE,SAAS,EAAE,EAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,EAAG,CAAC,EACnE,KAAMH,EACN,SAAU,IACV,KAAM,UACN,GAAGC,CACL,EAEA,OAAAF,EAAM,IAAII,CAAI,EACPA,CACT,CAKO,SAASC,EAAYC,EAAmD,CAC7E,OAAKH,EAESJ,EAAkB,EAAE,KAAK,EAC1B,IAAIO,CAAE,EAHA,MAIrB,CAKO,SAASC,EAAYD,EAAqBJ,EAAmD,CAClG,GAAI,CAACC,EAAc,OAEnB,IAAMH,EAAQD,EAAkB,EAAE,KAAK,EACvC,OAAAC,EAAM,IAAI,CAAE,GAAGA,EAAM,IAAIM,CAAE,EAAG,GAAGJ,CAAQ,CAAC,EACnCF,EAAM,IAAIM,CAAE,CACrB",
|
|
6
|
+
"names": ["windowExists", "getToastContainer", "toast", "message", "options", "windowExists", "data", "removeToast", "id", "updateToast"]
|
|
7
7
|
}
|