@transferwise/components 0.0.0-experimental-a8f3db2 → 0.0.0-experimental-8abc58f
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/build/main.css +11 -15
- package/build/styles/main.css +11 -15
- package/build/styles/switch/Switch.css +22 -41
- package/build/styles/switchOption/SwitchOption.css +4 -0
- package/build/switch/Switch.js +7 -18
- package/build/switch/Switch.js.map +1 -1
- package/build/switch/Switch.mjs +8 -19
- package/build/switch/Switch.mjs.map +1 -1
- package/build/switchOption/SwitchOption.js +1 -0
- package/build/switchOption/SwitchOption.js.map +1 -1
- package/build/switchOption/SwitchOption.mjs +1 -0
- package/build/switchOption/SwitchOption.mjs.map +1 -1
- package/build/types/switch/Switch.d.ts.map +1 -1
- package/build/types/switchOption/SwitchOption.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/accordion/Accordion.story.tsx +31 -21
- package/src/avatarView/AvatarView.story.tsx +1 -6
- package/src/carousel/Carousel.story.tsx +1 -0
- package/src/common/bottomSheet/BottomSheet.story.tsx +5 -4
- package/src/common/circle/Circle.story.tsx +1 -0
- package/src/dateLookup/DateLookup.story.tsx +1 -0
- package/src/decision/Decision.story.tsx +1 -0
- package/src/definitionList/DefinitionList.story.tsx +1 -0
- package/src/dimmer/Dimmer.story.tsx +1 -0
- package/src/display/Display.story.tsx +1 -0
- package/src/drawer/Drawer.story.tsx +1 -0
- package/src/dropFade/DropFade.story.tsx +1 -0
- package/src/flowNavigation/FlowNavigation.story.tsx +1 -0
- package/src/header/Header.story.tsx +1 -0
- package/src/iconButton/IconButton.story.tsx +1 -0
- package/src/image/Image.story.tsx +1 -0
- package/src/info/Info.story.tsx +1 -0
- package/src/inlineAlert/InlineAlert.story.tsx +1 -0
- package/src/inputWithDisplayFormat/InputWithDisplayFormat.story.tsx +1 -0
- package/src/inputs/InputGroup.story.tsx +1 -0
- package/src/inputs/SearchInput.story.tsx +1 -0
- package/src/legacylistItem/LegacyListItem.tests.story.tsx +1 -0
- package/src/link/Link.story.tsx +1 -0
- package/src/main.css +11 -15
- package/src/main.less +1 -0
- package/src/modal/Modal.story.tsx +11 -6
- package/src/money/Money.story.tsx +1 -0
- package/src/navigationOptionsList/NavigationOptionsList.story.tsx +1 -0
- package/src/nudge/Nudge.story.tsx +1 -0
- package/src/overlayHeader/OverlayHeader.story.tsx +1 -0
- package/src/progress/Progress.story.tsx +1 -0
- package/src/provider/Provider.story.tsx +1 -0
- package/src/radio/Radio.story.tsx +1 -0
- package/src/radioGroup/RadioGroup.story.tsx +1 -0
- package/src/radioOption/RadioOption.story.tsx +1 -0
- package/src/section/Section.story.tsx +1 -0
- package/src/segmentedControl/SegmentedControl.story.tsx +1 -0
- package/src/select/Select.story.tsx +1 -0
- package/src/slidingPanel/SlidingPanel.story.tsx +1 -0
- package/src/snackbar/Snackbar.story.tsx +1 -0
- package/src/summary/Summary.story.tsx +1 -0
- package/src/switch/Switch.css +22 -41
- package/src/switch/Switch.less +6 -12
- package/src/switch/Switch.spec.tsx +11 -9
- package/src/switch/Switch.story.tsx +158 -33
- package/src/switch/Switch.tsx +6 -15
- package/src/switchOption/SwitchOption.css +4 -0
- package/src/switchOption/SwitchOption.less +8 -0
- package/src/switchOption/SwitchOption.spec.tsx +4 -5
- package/src/switchOption/SwitchOption.story.tsx +42 -38
- package/src/switchOption/SwitchOption.tsx +1 -0
- package/src/textareaWithDisplayFormat/TextareaWithDisplayFormat.story.tsx +1 -0
- package/src/tile/Tile.story.tsx +1 -0
- package/src/title/Title.story.tsx +1 -0
- package/src/typeahead/Typeahead.story.tsx +1 -0
- package/src/switch/__snapshots__/Switch.spec.tsx.snap +0 -44
package/build/main.css
CHANGED
|
@@ -5149,6 +5149,8 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
5149
5149
|
margin-top: var(--size-24);
|
|
5150
5150
|
}
|
|
5151
5151
|
.np-switch {
|
|
5152
|
+
all: unset;
|
|
5153
|
+
box-sizing: border-box;
|
|
5152
5154
|
display: inline-flex;
|
|
5153
5155
|
overflow: hidden;
|
|
5154
5156
|
width: 50px;
|
|
@@ -5157,6 +5159,7 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
5157
5159
|
-webkit-user-select: none;
|
|
5158
5160
|
-moz-user-select: none;
|
|
5159
5161
|
user-select: none;
|
|
5162
|
+
cursor: pointer;
|
|
5160
5163
|
}
|
|
5161
5164
|
.np-switch:focus {
|
|
5162
5165
|
outline: none;
|
|
@@ -5189,21 +5192,10 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
5189
5192
|
[dir="rtl"] .np-switch--checked .np-switch--thumb {
|
|
5190
5193
|
transform: translateX(-20px) ;
|
|
5191
5194
|
}
|
|
5192
|
-
.np-switch
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
width: 0;
|
|
5197
|
-
height: 0;
|
|
5198
|
-
opacity: 0;
|
|
5199
|
-
}
|
|
5200
|
-
[dir="rtl"] .np-switch input {
|
|
5201
|
-
right: -100%;
|
|
5202
|
-
left: auto;
|
|
5203
|
-
left: initial;
|
|
5204
|
-
}
|
|
5205
|
-
.np-switch:not([aria-disabled]) {
|
|
5206
|
-
cursor: pointer;
|
|
5195
|
+
.np-switch.disabled {
|
|
5196
|
+
filter: grayscale(1);
|
|
5197
|
+
opacity: 0.45;
|
|
5198
|
+
cursor: not-allowed !important;
|
|
5207
5199
|
}
|
|
5208
5200
|
.np-theme-personal .np-switch {
|
|
5209
5201
|
padding: 1px 2px;
|
|
@@ -5219,6 +5211,10 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
5219
5211
|
background-color: #ffffff;
|
|
5220
5212
|
background-color: var(--color-background-screen);
|
|
5221
5213
|
}
|
|
5214
|
+
.np-switch-option.disabled .np-switch {
|
|
5215
|
+
filter: none;
|
|
5216
|
+
opacity: 1;
|
|
5217
|
+
}
|
|
5222
5218
|
.tabs {
|
|
5223
5219
|
position: relative;
|
|
5224
5220
|
}
|
package/build/styles/main.css
CHANGED
|
@@ -5149,6 +5149,8 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
5149
5149
|
margin-top: var(--size-24);
|
|
5150
5150
|
}
|
|
5151
5151
|
.np-switch {
|
|
5152
|
+
all: unset;
|
|
5153
|
+
box-sizing: border-box;
|
|
5152
5154
|
display: inline-flex;
|
|
5153
5155
|
overflow: hidden;
|
|
5154
5156
|
width: 50px;
|
|
@@ -5157,6 +5159,7 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
5157
5159
|
-webkit-user-select: none;
|
|
5158
5160
|
-moz-user-select: none;
|
|
5159
5161
|
user-select: none;
|
|
5162
|
+
cursor: pointer;
|
|
5160
5163
|
}
|
|
5161
5164
|
.np-switch:focus {
|
|
5162
5165
|
outline: none;
|
|
@@ -5189,21 +5192,10 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
5189
5192
|
[dir="rtl"] .np-switch--checked .np-switch--thumb {
|
|
5190
5193
|
transform: translateX(-20px) ;
|
|
5191
5194
|
}
|
|
5192
|
-
.np-switch
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
width: 0;
|
|
5197
|
-
height: 0;
|
|
5198
|
-
opacity: 0;
|
|
5199
|
-
}
|
|
5200
|
-
[dir="rtl"] .np-switch input {
|
|
5201
|
-
right: -100%;
|
|
5202
|
-
left: auto;
|
|
5203
|
-
left: initial;
|
|
5204
|
-
}
|
|
5205
|
-
.np-switch:not([aria-disabled]) {
|
|
5206
|
-
cursor: pointer;
|
|
5195
|
+
.np-switch.disabled {
|
|
5196
|
+
filter: grayscale(1);
|
|
5197
|
+
opacity: 0.45;
|
|
5198
|
+
cursor: not-allowed !important;
|
|
5207
5199
|
}
|
|
5208
5200
|
.np-theme-personal .np-switch {
|
|
5209
5201
|
padding: 1px 2px;
|
|
@@ -5219,6 +5211,10 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
5219
5211
|
background-color: #ffffff;
|
|
5220
5212
|
background-color: var(--color-background-screen);
|
|
5221
5213
|
}
|
|
5214
|
+
.np-switch-option.disabled .np-switch {
|
|
5215
|
+
filter: none;
|
|
5216
|
+
opacity: 1;
|
|
5217
|
+
}
|
|
5222
5218
|
.tabs {
|
|
5223
5219
|
position: relative;
|
|
5224
5220
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
@media (min-width: 768px) {
|
|
2
|
+
}@media (min-width: 768px) {
|
|
3
|
+
}.np-switch {
|
|
4
|
+
all: unset;
|
|
5
|
+
box-sizing: border-box;
|
|
2
6
|
display: inline-flex;
|
|
3
7
|
overflow: hidden;
|
|
4
8
|
width: 50px;
|
|
@@ -7,61 +11,38 @@
|
|
|
7
11
|
-webkit-user-select: none;
|
|
8
12
|
-moz-user-select: none;
|
|
9
13
|
user-select: none;
|
|
10
|
-
|
|
11
|
-
.np-switch:focus {
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
}.np-switch:focus {
|
|
12
16
|
outline: none;
|
|
13
|
-
}
|
|
14
|
-
.np-switch:focus-visible {
|
|
17
|
+
}.np-switch:focus-visible {
|
|
15
18
|
outline: var(--ring-outline-color) solid var(--ring-outline-width);
|
|
16
19
|
outline-offset: var(--ring-outline-offset);
|
|
17
|
-
}
|
|
18
|
-
.np-switch--thumb {
|
|
20
|
+
}.np-switch--thumb {
|
|
19
21
|
display: flex;
|
|
20
22
|
transition: transform cubic-bezier(0, 0.94, 0.62, 1) 350ms;
|
|
21
|
-
}
|
|
22
|
-
.np-switch--thumb .tw-icon {
|
|
23
|
+
}.np-switch--thumb .tw-icon {
|
|
23
24
|
color: #fff;
|
|
24
|
-
}
|
|
25
|
-
.np-switch--unchecked {
|
|
25
|
+
}.np-switch--unchecked {
|
|
26
26
|
background: #c9cbce;
|
|
27
27
|
background: var(--color-interactive-secondary);
|
|
28
|
-
}
|
|
29
|
-
.np-switch--unchecked .switch--thumb {
|
|
28
|
+
}.np-switch--unchecked .switch--thumb {
|
|
30
29
|
transform: translateX(0);
|
|
31
|
-
}
|
|
32
|
-
.np-switch--checked {
|
|
30
|
+
}.np-switch--checked {
|
|
33
31
|
background: #00a2dd;
|
|
34
32
|
background: var(--color-interactive-accent);
|
|
35
|
-
}
|
|
36
|
-
.np-switch--checked .np-switch--thumb {
|
|
33
|
+
}.np-switch--checked .np-switch--thumb {
|
|
37
34
|
transform: translateX(20px) ;
|
|
38
|
-
}
|
|
39
|
-
[dir="rtl"] .np-switch--checked .np-switch--thumb {
|
|
35
|
+
}[dir="rtl"] .np-switch--checked .np-switch--thumb {
|
|
40
36
|
transform: translateX(-20px) ;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
width: 0;
|
|
47
|
-
height: 0;
|
|
48
|
-
opacity: 0;
|
|
49
|
-
}
|
|
50
|
-
[dir="rtl"] .np-switch input {
|
|
51
|
-
right: -100%;
|
|
52
|
-
left: auto;
|
|
53
|
-
left: initial;
|
|
54
|
-
}
|
|
55
|
-
.np-switch:not([aria-disabled]) {
|
|
56
|
-
cursor: pointer;
|
|
57
|
-
}
|
|
58
|
-
.np-theme-personal .np-switch {
|
|
37
|
+
}.np-switch.disabled {
|
|
38
|
+
filter: grayscale(1);
|
|
39
|
+
opacity: 0.45;
|
|
40
|
+
cursor: not-allowed !important;
|
|
41
|
+
}.np-theme-personal .np-switch {
|
|
59
42
|
padding: 1px 2px;
|
|
60
|
-
}
|
|
61
|
-
.np-theme-personal .np-switch--checked {
|
|
43
|
+
}.np-theme-personal .np-switch--checked {
|
|
62
44
|
background: var(--color-interactive-primary);
|
|
63
|
-
}
|
|
64
|
-
.np-theme-personal .np-switch--thumb {
|
|
45
|
+
}.np-theme-personal .np-switch--thumb {
|
|
65
46
|
width: 20px;
|
|
66
47
|
height: 20px;
|
|
67
48
|
margin: 3px;
|
package/build/switch/Switch.js
CHANGED
|
@@ -19,36 +19,25 @@ const Switch = props => {
|
|
|
19
19
|
onClick,
|
|
20
20
|
disabled
|
|
21
21
|
} = props;
|
|
22
|
-
const handleKeyDown = event => {
|
|
23
|
-
if (event.key === ' ') {
|
|
24
|
-
event.preventDefault();
|
|
25
|
-
onClick();
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
22
|
const ariaLabelledby = (ariaLabel ? undefined : ariaLabelledbyProp) ?? inputAttributes['aria-labelledby'];
|
|
29
|
-
return /*#__PURE__*/jsxRuntime.
|
|
23
|
+
return /*#__PURE__*/jsxRuntime.jsx("button", {
|
|
30
24
|
className: clsx.clsx('np-switch', {
|
|
31
25
|
'np-switch--unchecked': !checked,
|
|
32
26
|
'np-switch--checked': checked,
|
|
33
27
|
disabled
|
|
34
28
|
}, className),
|
|
35
|
-
|
|
29
|
+
type: "button",
|
|
36
30
|
role: "switch",
|
|
31
|
+
...inputAttributes,
|
|
32
|
+
id: id,
|
|
37
33
|
"aria-checked": checked,
|
|
38
34
|
"aria-label": ariaLabel,
|
|
39
|
-
...inputAttributes,
|
|
40
35
|
"aria-labelledby": ariaLabelledby,
|
|
41
|
-
|
|
42
|
-
"aria-disabled": disabled,
|
|
36
|
+
disabled: disabled,
|
|
43
37
|
onClick: !disabled ? onClick : undefined,
|
|
44
|
-
|
|
45
|
-
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
38
|
+
children: /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
46
39
|
className: "np-switch--thumb"
|
|
47
|
-
})
|
|
48
|
-
type: "checkbox",
|
|
49
|
-
checked: checked,
|
|
50
|
-
readOnly: true
|
|
51
|
-
})]
|
|
40
|
+
})
|
|
52
41
|
});
|
|
53
42
|
};
|
|
54
43
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Switch.js","sources":["../../src/switch/Switch.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport type { KeyboardEventHandler, MouseEvent } from 'react';\n\nimport type { CommonProps } from '../common';\nimport { useInputAttributes } from '../inputs/contexts';\n\nexport type SwitchProps = CommonProps & {\n /**\n * Used to describe the purpose of the switch. To be used if there is no external label (i.e. aria-labelledby is null)\n * @deprecated Use `Field` wrapper or the `aria-labelledby` attribute instead.\n */\n 'aria-label'?: string;\n /** A reference to a label that describes the purpose of the switch. Ignored if aria-label is provided */\n 'aria-labelledby'?: string;\n /** Whether the switch is checked or not */\n checked?: boolean;\n disabled?: boolean;\n /** ID to apply to the switch container */\n id?: string;\n /** Function called when the switch is toggled */\n onClick: (event?: MouseEvent<HTMLSpanElement>) => void;\n};\n\nconst Switch = (props: SwitchProps) => {\n const inputAttributes = useInputAttributes({ nonLabelable: true });\n\n const {\n checked,\n className,\n id = inputAttributes.id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledbyProp,\n onClick,\n disabled,\n } = props;\n\n const
|
|
1
|
+
{"version":3,"file":"Switch.js","sources":["../../src/switch/Switch.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport type { KeyboardEventHandler, MouseEvent } from 'react';\n\nimport type { CommonProps } from '../common';\nimport { useInputAttributes } from '../inputs/contexts';\n\nexport type SwitchProps = CommonProps & {\n /**\n * Used to describe the purpose of the switch. To be used if there is no external label (i.e. aria-labelledby is null)\n * @deprecated Use `Field` wrapper or the `aria-labelledby` attribute instead.\n */\n 'aria-label'?: string;\n /** A reference to a label that describes the purpose of the switch. Ignored if aria-label is provided */\n 'aria-labelledby'?: string;\n /** Whether the switch is checked or not */\n checked?: boolean;\n disabled?: boolean;\n /** ID to apply to the switch container */\n id?: string;\n /** Function called when the switch is toggled */\n onClick: (event?: MouseEvent<HTMLSpanElement>) => void;\n};\n\nconst Switch = (props: SwitchProps) => {\n const inputAttributes = useInputAttributes({ nonLabelable: true });\n\n const {\n checked,\n className,\n id = inputAttributes.id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledbyProp,\n onClick,\n disabled,\n } = props;\n\n const ariaLabelledby =\n (ariaLabel ? undefined : ariaLabelledbyProp) ?? inputAttributes['aria-labelledby'];\n\n return (\n <button\n className={clsx(\n 'np-switch',\n {\n 'np-switch--unchecked': !checked,\n 'np-switch--checked': checked,\n disabled,\n },\n className,\n )}\n type=\"button\"\n role=\"switch\"\n {...inputAttributes}\n id={id}\n aria-checked={checked}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n disabled={disabled}\n onClick={!disabled ? onClick : undefined}\n >\n <span className=\"np-switch--thumb\" />\n </button>\n );\n};\n\nexport default Switch;\n"],"names":["Switch","props","inputAttributes","useInputAttributes","nonLabelable","checked","className","id","ariaLabel","ariaLabelledbyProp","onClick","disabled","ariaLabelledby","undefined","_jsx","clsx","type","role","children"],"mappings":";;;;;;;;AAuBMA,MAAAA,MAAM,GAAIC,KAAkB,IAAI;EACpC,MAAMC,eAAe,GAAGC,2BAAkB,CAAC;AAAEC,IAAAA,YAAY,EAAE;AAAM,GAAA,CAAC;EAElE,MAAM;IACJC,OAAO;IACPC,SAAS;IACTC,EAAE,GAAGL,eAAe,CAACK,EAAE;AACvB,IAAA,YAAY,EAAEC,SAAS;AACvB,IAAA,iBAAiB,EAAEC,kBAAkB;IACrCC,OAAO;AACPC,IAAAA;AAAQ,GACT,GAAGV,KAAK;AAET,EAAA,MAAMW,cAAc,GAClB,CAACJ,SAAS,GAAGK,SAAS,GAAGJ,kBAAkB,KAAKP,eAAe,CAAC,iBAAiB,CAAC;AAEpF,EAAA,oBACEY,cAAA,CAAA,QAAA,EAAA;AACER,IAAAA,SAAS,EAAES,SAAI,CACb,WAAW,EACX;MACE,sBAAsB,EAAE,CAACV,OAAO;AAChC,MAAA,oBAAoB,EAAEA,OAAO;AAC7BM,MAAAA;KACD,EACDL,SAAS,CACT;AACFU,IAAAA,IAAI,EAAC,QAAQ;AACbC,IAAAA,IAAI,EAAC,QAAQ;AAAA,IAAA,GACTf,eAAe;AACnBK,IAAAA,EAAE,EAAEA,EAAG;AACP,IAAA,cAAA,EAAcF,OAAQ;AACtB,IAAA,YAAA,EAAYG,SAAU;AACtB,IAAA,iBAAA,EAAiBI,cAAe;AAChCD,IAAAA,QAAQ,EAAEA,QAAS;AACnBD,IAAAA,OAAO,EAAE,CAACC,QAAQ,GAAGD,OAAO,GAAGG,SAAU;AAAAK,IAAAA,QAAA,eAEzCJ,cAAA,CAAA,MAAA,EAAA;AAAMR,MAAAA,SAAS,EAAC;KAClB;AAAA,GAAQ,CAAC;AAEb;;;;"}
|
package/build/switch/Switch.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { clsx } from 'clsx';
|
|
2
2
|
import { useInputAttributes } from '../inputs/contexts.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
4
|
|
|
5
5
|
const Switch = props => {
|
|
6
6
|
const inputAttributes = useInputAttributes({
|
|
@@ -15,36 +15,25 @@ const Switch = props => {
|
|
|
15
15
|
onClick,
|
|
16
16
|
disabled
|
|
17
17
|
} = props;
|
|
18
|
-
const handleKeyDown = event => {
|
|
19
|
-
if (event.key === ' ') {
|
|
20
|
-
event.preventDefault();
|
|
21
|
-
onClick();
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
18
|
const ariaLabelledby = (ariaLabel ? undefined : ariaLabelledbyProp) ?? inputAttributes['aria-labelledby'];
|
|
25
|
-
return /*#__PURE__*/
|
|
19
|
+
return /*#__PURE__*/jsx("button", {
|
|
26
20
|
className: clsx('np-switch', {
|
|
27
21
|
'np-switch--unchecked': !checked,
|
|
28
22
|
'np-switch--checked': checked,
|
|
29
23
|
disabled
|
|
30
24
|
}, className),
|
|
31
|
-
|
|
25
|
+
type: "button",
|
|
32
26
|
role: "switch",
|
|
27
|
+
...inputAttributes,
|
|
28
|
+
id: id,
|
|
33
29
|
"aria-checked": checked,
|
|
34
30
|
"aria-label": ariaLabel,
|
|
35
|
-
...inputAttributes,
|
|
36
31
|
"aria-labelledby": ariaLabelledby,
|
|
37
|
-
|
|
38
|
-
"aria-disabled": disabled,
|
|
32
|
+
disabled: disabled,
|
|
39
33
|
onClick: !disabled ? onClick : undefined,
|
|
40
|
-
|
|
41
|
-
children: [/*#__PURE__*/jsx("span", {
|
|
34
|
+
children: /*#__PURE__*/jsx("span", {
|
|
42
35
|
className: "np-switch--thumb"
|
|
43
|
-
})
|
|
44
|
-
type: "checkbox",
|
|
45
|
-
checked: checked,
|
|
46
|
-
readOnly: true
|
|
47
|
-
})]
|
|
36
|
+
})
|
|
48
37
|
});
|
|
49
38
|
};
|
|
50
39
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Switch.mjs","sources":["../../src/switch/Switch.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport type { KeyboardEventHandler, MouseEvent } from 'react';\n\nimport type { CommonProps } from '../common';\nimport { useInputAttributes } from '../inputs/contexts';\n\nexport type SwitchProps = CommonProps & {\n /**\n * Used to describe the purpose of the switch. To be used if there is no external label (i.e. aria-labelledby is null)\n * @deprecated Use `Field` wrapper or the `aria-labelledby` attribute instead.\n */\n 'aria-label'?: string;\n /** A reference to a label that describes the purpose of the switch. Ignored if aria-label is provided */\n 'aria-labelledby'?: string;\n /** Whether the switch is checked or not */\n checked?: boolean;\n disabled?: boolean;\n /** ID to apply to the switch container */\n id?: string;\n /** Function called when the switch is toggled */\n onClick: (event?: MouseEvent<HTMLSpanElement>) => void;\n};\n\nconst Switch = (props: SwitchProps) => {\n const inputAttributes = useInputAttributes({ nonLabelable: true });\n\n const {\n checked,\n className,\n id = inputAttributes.id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledbyProp,\n onClick,\n disabled,\n } = props;\n\n const
|
|
1
|
+
{"version":3,"file":"Switch.mjs","sources":["../../src/switch/Switch.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport type { KeyboardEventHandler, MouseEvent } from 'react';\n\nimport type { CommonProps } from '../common';\nimport { useInputAttributes } from '../inputs/contexts';\n\nexport type SwitchProps = CommonProps & {\n /**\n * Used to describe the purpose of the switch. To be used if there is no external label (i.e. aria-labelledby is null)\n * @deprecated Use `Field` wrapper or the `aria-labelledby` attribute instead.\n */\n 'aria-label'?: string;\n /** A reference to a label that describes the purpose of the switch. Ignored if aria-label is provided */\n 'aria-labelledby'?: string;\n /** Whether the switch is checked or not */\n checked?: boolean;\n disabled?: boolean;\n /** ID to apply to the switch container */\n id?: string;\n /** Function called when the switch is toggled */\n onClick: (event?: MouseEvent<HTMLSpanElement>) => void;\n};\n\nconst Switch = (props: SwitchProps) => {\n const inputAttributes = useInputAttributes({ nonLabelable: true });\n\n const {\n checked,\n className,\n id = inputAttributes.id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledbyProp,\n onClick,\n disabled,\n } = props;\n\n const ariaLabelledby =\n (ariaLabel ? undefined : ariaLabelledbyProp) ?? inputAttributes['aria-labelledby'];\n\n return (\n <button\n className={clsx(\n 'np-switch',\n {\n 'np-switch--unchecked': !checked,\n 'np-switch--checked': checked,\n disabled,\n },\n className,\n )}\n type=\"button\"\n role=\"switch\"\n {...inputAttributes}\n id={id}\n aria-checked={checked}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n disabled={disabled}\n onClick={!disabled ? onClick : undefined}\n >\n <span className=\"np-switch--thumb\" />\n </button>\n );\n};\n\nexport default Switch;\n"],"names":["Switch","props","inputAttributes","useInputAttributes","nonLabelable","checked","className","id","ariaLabel","ariaLabelledbyProp","onClick","disabled","ariaLabelledby","undefined","_jsx","clsx","type","role","children"],"mappings":";;;;AAuBMA,MAAAA,MAAM,GAAIC,KAAkB,IAAI;EACpC,MAAMC,eAAe,GAAGC,kBAAkB,CAAC;AAAEC,IAAAA,YAAY,EAAE;AAAM,GAAA,CAAC;EAElE,MAAM;IACJC,OAAO;IACPC,SAAS;IACTC,EAAE,GAAGL,eAAe,CAACK,EAAE;AACvB,IAAA,YAAY,EAAEC,SAAS;AACvB,IAAA,iBAAiB,EAAEC,kBAAkB;IACrCC,OAAO;AACPC,IAAAA;AAAQ,GACT,GAAGV,KAAK;AAET,EAAA,MAAMW,cAAc,GAClB,CAACJ,SAAS,GAAGK,SAAS,GAAGJ,kBAAkB,KAAKP,eAAe,CAAC,iBAAiB,CAAC;AAEpF,EAAA,oBACEY,GAAA,CAAA,QAAA,EAAA;AACER,IAAAA,SAAS,EAAES,IAAI,CACb,WAAW,EACX;MACE,sBAAsB,EAAE,CAACV,OAAO;AAChC,MAAA,oBAAoB,EAAEA,OAAO;AAC7BM,MAAAA;KACD,EACDL,SAAS,CACT;AACFU,IAAAA,IAAI,EAAC,QAAQ;AACbC,IAAAA,IAAI,EAAC,QAAQ;AAAA,IAAA,GACTf,eAAe;AACnBK,IAAAA,EAAE,EAAEA,EAAG;AACP,IAAA,cAAA,EAAcF,OAAQ;AACtB,IAAA,YAAA,EAAYG,SAAU;AACtB,IAAA,iBAAA,EAAiBI,cAAe;AAChCD,IAAAA,QAAQ,EAAEA,QAAS;AACnBD,IAAAA,OAAO,EAAE,CAACC,QAAQ,GAAGD,OAAO,GAAGG,SAAU;AAAAK,IAAAA,QAAA,eAEzCJ,GAAA,CAAA,MAAA,EAAA;AAAMR,MAAAA,SAAS,EAAC;KAClB;AAAA,GAAQ,CAAC;AAEb;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SwitchOption.js","sources":["../../src/switchOption/SwitchOption.tsx"],"sourcesContent":["import { MouseEvent } from 'react';\n\nimport Option from '../common/Option';\nimport Switch from '../switch';\n\nexport type SwitchOptionProps = {\n checked?: boolean;\n complex?: boolean;\n content?: React.ReactNode;\n disabled?: boolean;\n showMediaCircle?: boolean;\n showMediaAtAllSizes?: boolean;\n isContainerAligned?: boolean;\n id?: string;\n media?: React.ReactNode;\n onChange: (newValue: boolean) => void;\n title: React.ReactNode;\n 'aria-label': string;\n};\n\nconst stopPropagation = (event?: MouseEvent<HTMLSpanElement>) => {\n if (event) {\n event.stopPropagation();\n event.preventDefault();\n event.nativeEvent?.stopImmediatePropagation?.();\n }\n};\n\nconst SwitchOption = ({\n checked,\n complex,\n content,\n disabled,\n id,\n media,\n onChange,\n title,\n showMediaCircle,\n showMediaAtAllSizes,\n isContainerAligned,\n 'aria-label': ariaLabel,\n}: SwitchOptionProps) => {\n const sharedProps = {\n media,\n title,\n content,\n complex,\n disabled,\n showMediaCircle,\n showMediaAtAllSizes,\n isContainerAligned,\n };\n const toggle = (event?: MouseEvent<HTMLSpanElement>) => {\n stopPropagation(event);\n if (disabled) {\n return;\n }\n\n onChange(!checked);\n };\n\n return (\n <Option\n {...sharedProps}\n button={\n <Switch\n id={id}\n checked={checked}\n disabled={disabled}\n aria-label={ariaLabel}\n onClick={toggle}\n />\n }\n onClick={toggle}\n />\n );\n};\n\nexport default SwitchOption;\n"],"names":["stopPropagation","event","preventDefault","nativeEvent","stopImmediatePropagation","SwitchOption","checked","complex","content","disabled","id","media","onChange","title","showMediaCircle","showMediaAtAllSizes","isContainerAligned","ariaLabel","sharedProps","toggle","_jsx","Option","button","Switch","onClick"],"mappings":";;;;;;;;AAoBA,MAAMA,eAAe,GAAIC,KAAmC,IAAI;AAC9D,EAAA,IAAIA,KAAK,EAAE;IACTA,KAAK,CAACD,eAAe,EAAE;IACvBC,KAAK,CAACC,cAAc,EAAE;AACtBD,IAAAA,KAAK,CAACE,WAAW,EAAEC,wBAAwB,IAAI;AACjD;AACF,CAAC;AAEKC,MAAAA,YAAY,GAAGA,CAAC;EACpBC,OAAO;EACPC,OAAO;EACPC,OAAO;EACPC,QAAQ;EACRC,EAAE;EACFC,KAAK;EACLC,QAAQ;EACRC,KAAK;EACLC,eAAe;EACfC,mBAAmB;EACnBC,kBAAkB;AAClB,EAAA,YAAY,EAAEC;AAAS,CACL,KAAI;AACtB,EAAA,MAAMC,WAAW,GAAG;IAClBP,KAAK;IACLE,KAAK;IACLL,OAAO;IACPD,OAAO;IACPE,QAAQ;IACRK,eAAe;IACfC,mBAAmB;AACnBC,IAAAA;GACD;EACD,MAAMG,MAAM,GAAIlB,KAAmC,IAAI;IACrDD,eAAe,CAACC,KAAK,CAAC;AACtB,IAAA,IAAIQ,QAAQ,EAAE;AACZ,MAAA;AACF;IAEAG,QAAQ,CAAC,CAACN,OAAO,CAAC;GACnB;EAED,oBACEc,cAAA,CAACC,cAAM,EAAA;AAAA,IAAA,GACDH,WAAW;
|
|
1
|
+
{"version":3,"file":"SwitchOption.js","sources":["../../src/switchOption/SwitchOption.tsx"],"sourcesContent":["import { MouseEvent } from 'react';\n\nimport Option from '../common/Option';\nimport Switch from '../switch';\n\nexport type SwitchOptionProps = {\n checked?: boolean;\n complex?: boolean;\n content?: React.ReactNode;\n disabled?: boolean;\n showMediaCircle?: boolean;\n showMediaAtAllSizes?: boolean;\n isContainerAligned?: boolean;\n id?: string;\n media?: React.ReactNode;\n onChange: (newValue: boolean) => void;\n title: React.ReactNode;\n 'aria-label': string;\n};\n\nconst stopPropagation = (event?: MouseEvent<HTMLSpanElement>) => {\n if (event) {\n event.stopPropagation();\n event.preventDefault();\n event.nativeEvent?.stopImmediatePropagation?.();\n }\n};\n\nconst SwitchOption = ({\n checked,\n complex,\n content,\n disabled,\n id,\n media,\n onChange,\n title,\n showMediaCircle,\n showMediaAtAllSizes,\n isContainerAligned,\n 'aria-label': ariaLabel,\n}: SwitchOptionProps) => {\n const sharedProps = {\n media,\n title,\n content,\n complex,\n disabled,\n showMediaCircle,\n showMediaAtAllSizes,\n isContainerAligned,\n };\n const toggle = (event?: MouseEvent<HTMLSpanElement>) => {\n stopPropagation(event);\n if (disabled) {\n return;\n }\n\n onChange(!checked);\n };\n\n return (\n <Option\n {...sharedProps}\n className=\"np-switch-option\"\n button={\n <Switch\n id={id}\n checked={checked}\n disabled={disabled}\n aria-label={ariaLabel}\n onClick={toggle}\n />\n }\n onClick={toggle}\n />\n );\n};\n\nexport default SwitchOption;\n"],"names":["stopPropagation","event","preventDefault","nativeEvent","stopImmediatePropagation","SwitchOption","checked","complex","content","disabled","id","media","onChange","title","showMediaCircle","showMediaAtAllSizes","isContainerAligned","ariaLabel","sharedProps","toggle","_jsx","Option","className","button","Switch","onClick"],"mappings":";;;;;;;;AAoBA,MAAMA,eAAe,GAAIC,KAAmC,IAAI;AAC9D,EAAA,IAAIA,KAAK,EAAE;IACTA,KAAK,CAACD,eAAe,EAAE;IACvBC,KAAK,CAACC,cAAc,EAAE;AACtBD,IAAAA,KAAK,CAACE,WAAW,EAAEC,wBAAwB,IAAI;AACjD;AACF,CAAC;AAEKC,MAAAA,YAAY,GAAGA,CAAC;EACpBC,OAAO;EACPC,OAAO;EACPC,OAAO;EACPC,QAAQ;EACRC,EAAE;EACFC,KAAK;EACLC,QAAQ;EACRC,KAAK;EACLC,eAAe;EACfC,mBAAmB;EACnBC,kBAAkB;AAClB,EAAA,YAAY,EAAEC;AAAS,CACL,KAAI;AACtB,EAAA,MAAMC,WAAW,GAAG;IAClBP,KAAK;IACLE,KAAK;IACLL,OAAO;IACPD,OAAO;IACPE,QAAQ;IACRK,eAAe;IACfC,mBAAmB;AACnBC,IAAAA;GACD;EACD,MAAMG,MAAM,GAAIlB,KAAmC,IAAI;IACrDD,eAAe,CAACC,KAAK,CAAC;AACtB,IAAA,IAAIQ,QAAQ,EAAE;AACZ,MAAA;AACF;IAEAG,QAAQ,CAAC,CAACN,OAAO,CAAC;GACnB;EAED,oBACEc,cAAA,CAACC,cAAM,EAAA;AAAA,IAAA,GACDH,WAAW;AACfI,IAAAA,SAAS,EAAC,kBAAkB;IAC5BC,MAAM,eACJH,cAAA,CAACI,cAAM,EAAA;AACLd,MAAAA,EAAE,EAAEA,EAAG;AACPJ,MAAAA,OAAO,EAAEA,OAAQ;AACjBG,MAAAA,QAAQ,EAAEA,QAAS;AACnB,MAAA,YAAA,EAAYQ,SAAU;AACtBQ,MAAAA,OAAO,EAAEN;AAAO,KAEpB,CAAC;AACDM,IAAAA,OAAO,EAAEN;AAAO,GAChB,CAAA;AAEN;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SwitchOption.mjs","sources":["../../src/switchOption/SwitchOption.tsx"],"sourcesContent":["import { MouseEvent } from 'react';\n\nimport Option from '../common/Option';\nimport Switch from '../switch';\n\nexport type SwitchOptionProps = {\n checked?: boolean;\n complex?: boolean;\n content?: React.ReactNode;\n disabled?: boolean;\n showMediaCircle?: boolean;\n showMediaAtAllSizes?: boolean;\n isContainerAligned?: boolean;\n id?: string;\n media?: React.ReactNode;\n onChange: (newValue: boolean) => void;\n title: React.ReactNode;\n 'aria-label': string;\n};\n\nconst stopPropagation = (event?: MouseEvent<HTMLSpanElement>) => {\n if (event) {\n event.stopPropagation();\n event.preventDefault();\n event.nativeEvent?.stopImmediatePropagation?.();\n }\n};\n\nconst SwitchOption = ({\n checked,\n complex,\n content,\n disabled,\n id,\n media,\n onChange,\n title,\n showMediaCircle,\n showMediaAtAllSizes,\n isContainerAligned,\n 'aria-label': ariaLabel,\n}: SwitchOptionProps) => {\n const sharedProps = {\n media,\n title,\n content,\n complex,\n disabled,\n showMediaCircle,\n showMediaAtAllSizes,\n isContainerAligned,\n };\n const toggle = (event?: MouseEvent<HTMLSpanElement>) => {\n stopPropagation(event);\n if (disabled) {\n return;\n }\n\n onChange(!checked);\n };\n\n return (\n <Option\n {...sharedProps}\n button={\n <Switch\n id={id}\n checked={checked}\n disabled={disabled}\n aria-label={ariaLabel}\n onClick={toggle}\n />\n }\n onClick={toggle}\n />\n );\n};\n\nexport default SwitchOption;\n"],"names":["stopPropagation","event","preventDefault","nativeEvent","stopImmediatePropagation","SwitchOption","checked","complex","content","disabled","id","media","onChange","title","showMediaCircle","showMediaAtAllSizes","isContainerAligned","ariaLabel","sharedProps","toggle","_jsx","Option","button","Switch","onClick"],"mappings":";;;;AAoBA,MAAMA,eAAe,GAAIC,KAAmC,IAAI;AAC9D,EAAA,IAAIA,KAAK,EAAE;IACTA,KAAK,CAACD,eAAe,EAAE;IACvBC,KAAK,CAACC,cAAc,EAAE;AACtBD,IAAAA,KAAK,CAACE,WAAW,EAAEC,wBAAwB,IAAI;AACjD;AACF,CAAC;AAEKC,MAAAA,YAAY,GAAGA,CAAC;EACpBC,OAAO;EACPC,OAAO;EACPC,OAAO;EACPC,QAAQ;EACRC,EAAE;EACFC,KAAK;EACLC,QAAQ;EACRC,KAAK;EACLC,eAAe;EACfC,mBAAmB;EACnBC,kBAAkB;AAClB,EAAA,YAAY,EAAEC;AAAS,CACL,KAAI;AACtB,EAAA,MAAMC,WAAW,GAAG;IAClBP,KAAK;IACLE,KAAK;IACLL,OAAO;IACPD,OAAO;IACPE,QAAQ;IACRK,eAAe;IACfC,mBAAmB;AACnBC,IAAAA;GACD;EACD,MAAMG,MAAM,GAAIlB,KAAmC,IAAI;IACrDD,eAAe,CAACC,KAAK,CAAC;AACtB,IAAA,IAAIQ,QAAQ,EAAE;AACZ,MAAA;AACF;IAEAG,QAAQ,CAAC,CAACN,OAAO,CAAC;GACnB;EAED,oBACEc,GAAA,CAACC,MAAM,EAAA;AAAA,IAAA,GACDH,WAAW;
|
|
1
|
+
{"version":3,"file":"SwitchOption.mjs","sources":["../../src/switchOption/SwitchOption.tsx"],"sourcesContent":["import { MouseEvent } from 'react';\n\nimport Option from '../common/Option';\nimport Switch from '../switch';\n\nexport type SwitchOptionProps = {\n checked?: boolean;\n complex?: boolean;\n content?: React.ReactNode;\n disabled?: boolean;\n showMediaCircle?: boolean;\n showMediaAtAllSizes?: boolean;\n isContainerAligned?: boolean;\n id?: string;\n media?: React.ReactNode;\n onChange: (newValue: boolean) => void;\n title: React.ReactNode;\n 'aria-label': string;\n};\n\nconst stopPropagation = (event?: MouseEvent<HTMLSpanElement>) => {\n if (event) {\n event.stopPropagation();\n event.preventDefault();\n event.nativeEvent?.stopImmediatePropagation?.();\n }\n};\n\nconst SwitchOption = ({\n checked,\n complex,\n content,\n disabled,\n id,\n media,\n onChange,\n title,\n showMediaCircle,\n showMediaAtAllSizes,\n isContainerAligned,\n 'aria-label': ariaLabel,\n}: SwitchOptionProps) => {\n const sharedProps = {\n media,\n title,\n content,\n complex,\n disabled,\n showMediaCircle,\n showMediaAtAllSizes,\n isContainerAligned,\n };\n const toggle = (event?: MouseEvent<HTMLSpanElement>) => {\n stopPropagation(event);\n if (disabled) {\n return;\n }\n\n onChange(!checked);\n };\n\n return (\n <Option\n {...sharedProps}\n className=\"np-switch-option\"\n button={\n <Switch\n id={id}\n checked={checked}\n disabled={disabled}\n aria-label={ariaLabel}\n onClick={toggle}\n />\n }\n onClick={toggle}\n />\n );\n};\n\nexport default SwitchOption;\n"],"names":["stopPropagation","event","preventDefault","nativeEvent","stopImmediatePropagation","SwitchOption","checked","complex","content","disabled","id","media","onChange","title","showMediaCircle","showMediaAtAllSizes","isContainerAligned","ariaLabel","sharedProps","toggle","_jsx","Option","className","button","Switch","onClick"],"mappings":";;;;AAoBA,MAAMA,eAAe,GAAIC,KAAmC,IAAI;AAC9D,EAAA,IAAIA,KAAK,EAAE;IACTA,KAAK,CAACD,eAAe,EAAE;IACvBC,KAAK,CAACC,cAAc,EAAE;AACtBD,IAAAA,KAAK,CAACE,WAAW,EAAEC,wBAAwB,IAAI;AACjD;AACF,CAAC;AAEKC,MAAAA,YAAY,GAAGA,CAAC;EACpBC,OAAO;EACPC,OAAO;EACPC,OAAO;EACPC,QAAQ;EACRC,EAAE;EACFC,KAAK;EACLC,QAAQ;EACRC,KAAK;EACLC,eAAe;EACfC,mBAAmB;EACnBC,kBAAkB;AAClB,EAAA,YAAY,EAAEC;AAAS,CACL,KAAI;AACtB,EAAA,MAAMC,WAAW,GAAG;IAClBP,KAAK;IACLE,KAAK;IACLL,OAAO;IACPD,OAAO;IACPE,QAAQ;IACRK,eAAe;IACfC,mBAAmB;AACnBC,IAAAA;GACD;EACD,MAAMG,MAAM,GAAIlB,KAAmC,IAAI;IACrDD,eAAe,CAACC,KAAK,CAAC;AACtB,IAAA,IAAIQ,QAAQ,EAAE;AACZ,MAAA;AACF;IAEAG,QAAQ,CAAC,CAACN,OAAO,CAAC;GACnB;EAED,oBACEc,GAAA,CAACC,MAAM,EAAA;AAAA,IAAA,GACDH,WAAW;AACfI,IAAAA,SAAS,EAAC,kBAAkB;IAC5BC,MAAM,eACJH,GAAA,CAACI,MAAM,EAAA;AACLd,MAAAA,EAAE,EAAEA,EAAG;AACPJ,MAAAA,OAAO,EAAEA,OAAQ;AACjBG,MAAAA,QAAQ,EAAEA,QAAS;AACnB,MAAA,YAAA,EAAYQ,SAAU;AACtBQ,MAAAA,OAAO,EAAEN;AAAO,KAEpB,CAAC;AACDM,IAAAA,OAAO,EAAEN;AAAO,GAChB,CAAA;AAEN;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../../../src/switch/Switch.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAwB,UAAU,EAAE,MAAM,OAAO,CAAC;AAE9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAG7C,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG;IACtC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,yGAAyG;IACzG,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,2CAA2C;IAC3C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,0CAA0C;IAC1C,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,iDAAiD;IACjD,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,eAAe,CAAC,KAAK,IAAI,CAAC;CACxD,CAAC;AAEF,QAAA,MAAM,MAAM,GAAI,OAAO,WAAW,
|
|
1
|
+
{"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../../../src/switch/Switch.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAwB,UAAU,EAAE,MAAM,OAAO,CAAC;AAE9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAG7C,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG;IACtC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,yGAAyG;IACzG,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,2CAA2C;IAC3C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,0CAA0C;IAC1C,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,iDAAiD;IACjD,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,eAAe,CAAC,KAAK,IAAI,CAAC;CACxD,CAAC;AAEF,QAAA,MAAM,MAAM,GAAI,OAAO,WAAW,gCAwCjC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SwitchOption.d.ts","sourceRoot":"","sources":["../../../src/switchOption/SwitchOption.tsx"],"names":[],"mappings":"AAKA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,QAAQ,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAUF,QAAA,MAAM,YAAY,GAAI,yJAanB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"SwitchOption.d.ts","sourceRoot":"","sources":["../../../src/switchOption/SwitchOption.tsx"],"names":[],"mappings":"AAKA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,QAAQ,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAUF,QAAA,MAAM,YAAY,GAAI,yJAanB,iBAAiB,gCAoCnB,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
1
2
|
import { Meta, StoryObj } from '@storybook/react';
|
|
2
3
|
import { FastFlag as FastFlagIcon, CardWise as CardWiseIcon } from '@transferwise/icons';
|
|
3
4
|
|
|
@@ -6,6 +7,7 @@ import Modal from '../modal';
|
|
|
6
7
|
import { lorem10, lorem40 } from '../test-utils';
|
|
7
8
|
|
|
8
9
|
import Accordion from './Accordion';
|
|
10
|
+
import Button from '../button/Button';
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* Metadata for the Accordion component story.
|
|
@@ -20,8 +22,8 @@ const meta: Meta<typeof Accordion> = {
|
|
|
20
22
|
'A simple accordion component that displays a list of items that can be expanded or collapsed.',
|
|
21
23
|
},
|
|
22
24
|
},
|
|
23
|
-
tags: ['autodocs'],
|
|
24
25
|
},
|
|
26
|
+
tags: ['autodocs'],
|
|
25
27
|
args: {
|
|
26
28
|
items: [
|
|
27
29
|
{
|
|
@@ -133,28 +135,36 @@ export const WithinModal: Story = {
|
|
|
133
135
|
delay: 1000,
|
|
134
136
|
},
|
|
135
137
|
},
|
|
136
|
-
render: (args) => {
|
|
138
|
+
render: (args, { viewMode }) => {
|
|
139
|
+
// Modal is open by default unless in docs view
|
|
140
|
+
const [open, setOpen] = useState(viewMode !== 'docs');
|
|
137
141
|
const { items } = args;
|
|
142
|
+
|
|
138
143
|
return (
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
<
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
144
|
+
<>
|
|
145
|
+
<Button v2 onClick={() => setOpen(true)}>
|
|
146
|
+
Open Modal
|
|
147
|
+
</Button>
|
|
148
|
+
<Modal
|
|
149
|
+
body={
|
|
150
|
+
<div className="p-a-1">
|
|
151
|
+
<h3 className="m-t-2 m-b-4 text-xs-center">Large transfer tips</h3>
|
|
152
|
+
<Accordion {...args} items={[items[0]]} />
|
|
153
|
+
<Accordion {...args} items={[items[0]]} indexOpen={0} />
|
|
154
|
+
<Accordion {...args} items={items} />
|
|
155
|
+
</div>
|
|
156
|
+
}
|
|
157
|
+
scroll={Scroll.CONTENT}
|
|
158
|
+
size={Size.LARGE}
|
|
159
|
+
open={open}
|
|
160
|
+
footer={
|
|
161
|
+
<div className="p-a-3 text-xs-center">
|
|
162
|
+
<a href="/large-amounts">Learn more</a>
|
|
163
|
+
</div>
|
|
164
|
+
}
|
|
165
|
+
onClose={() => setOpen(false)}
|
|
166
|
+
/>
|
|
167
|
+
</>
|
|
158
168
|
);
|
|
159
169
|
},
|
|
160
170
|
};
|
|
@@ -26,6 +26,7 @@ import Body from '../body';
|
|
|
26
26
|
|
|
27
27
|
export default {
|
|
28
28
|
title: 'Content/AvatarView',
|
|
29
|
+
tags: ['autodocs'],
|
|
29
30
|
} satisfies Meta<typeof AvatarView>;
|
|
30
31
|
|
|
31
32
|
type Story = StoryObj<typeof AvatarView>;
|
|
@@ -35,7 +36,6 @@ const profileName2 = 'Tyler Durden';
|
|
|
35
36
|
const sizes: AvatarViewProps['size'][] = [16, 24, 32, 40, 48, 56, 72];
|
|
36
37
|
|
|
37
38
|
export const Selected: Story = {
|
|
38
|
-
tags: ['autodocs'],
|
|
39
39
|
render: () => {
|
|
40
40
|
return (
|
|
41
41
|
<div
|
|
@@ -69,7 +69,6 @@ export const Selected: Story = {
|
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
export const Notification: Story = {
|
|
72
|
-
tags: ['autodocs'],
|
|
73
72
|
render: () => (
|
|
74
73
|
<div
|
|
75
74
|
style={{
|
|
@@ -106,7 +105,6 @@ export const Notification: Story = {
|
|
|
106
105
|
};
|
|
107
106
|
|
|
108
107
|
export const Badge: Story = {
|
|
109
|
-
tags: ['autodocs'],
|
|
110
108
|
render: () => {
|
|
111
109
|
const currencies = ['USD', 'EUR', 'GBP', 'AUD', 'CAD', 'JPY', 'CNY'];
|
|
112
110
|
const icons = [
|
|
@@ -250,7 +248,6 @@ export const Badge: Story = {
|
|
|
250
248
|
};
|
|
251
249
|
|
|
252
250
|
export const Images: Story = {
|
|
253
|
-
tags: ['autodocs'],
|
|
254
251
|
render: () => {
|
|
255
252
|
return (
|
|
256
253
|
<div
|
|
@@ -305,7 +302,6 @@ export const Images: Story = {
|
|
|
305
302
|
};
|
|
306
303
|
|
|
307
304
|
export const Profiles: Story = {
|
|
308
|
-
tags: ['autodocs'],
|
|
309
305
|
render: () => {
|
|
310
306
|
return (
|
|
311
307
|
<div
|
|
@@ -388,7 +384,6 @@ export const ProfileBrokenImageFallback: Story = {
|
|
|
388
384
|
};
|
|
389
385
|
|
|
390
386
|
export const EdgeInstaces: Story = {
|
|
391
|
-
tags: ['autodocs'],
|
|
392
387
|
render: () => {
|
|
393
388
|
const css = `.custom-variant {
|
|
394
389
|
border: 1px dashed var(--color-border-neutral);
|
|
@@ -16,13 +16,14 @@ export default {
|
|
|
16
16
|
component: BottomSheet,
|
|
17
17
|
title: 'Dialogs/BottomSheet',
|
|
18
18
|
args: {
|
|
19
|
-
open:
|
|
19
|
+
open: false,
|
|
20
20
|
},
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
tags: ['autodocs'],
|
|
22
|
+
render: (args, { viewMode }) => {
|
|
23
|
+
const [open, setOpen] = useState(viewMode !== 'docs');
|
|
23
24
|
|
|
24
25
|
return (
|
|
25
|
-
<div
|
|
26
|
+
<div>
|
|
26
27
|
<Button onClick={() => setOpen(true)}>Open BottomSheet</Button>
|
|
27
28
|
<BottomSheet
|
|
28
29
|
{...args}
|