@arbor-education/design-system.components 0.3.5 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/components/banner/Banner.d.ts +19 -0
- package/dist/components/banner/Banner.d.ts.map +1 -0
- package/dist/components/banner/Banner.js +33 -0
- package/dist/components/banner/Banner.js.map +1 -0
- package/dist/components/banner/Banner.stories.d.ts +72 -0
- package/dist/components/banner/Banner.stories.d.ts.map +1 -0
- package/dist/components/banner/Banner.stories.js +84 -0
- package/dist/components/banner/Banner.stories.js.map +1 -0
- package/dist/components/banner/Banner.test.d.ts +2 -0
- package/dist/components/banner/Banner.test.d.ts.map +1 -0
- package/dist/components/banner/Banner.test.js +72 -0
- package/dist/components/banner/Banner.test.js.map +1 -0
- package/dist/components/editableText/EditableText.d.ts +10 -0
- package/dist/components/editableText/EditableText.d.ts.map +1 -0
- package/dist/components/editableText/EditableText.js +36 -0
- package/dist/components/editableText/EditableText.js.map +1 -0
- package/dist/components/editableText/EditableText.stories.d.ts +44 -0
- package/dist/components/editableText/EditableText.stories.d.ts.map +1 -0
- package/dist/components/editableText/EditableText.stories.js +94 -0
- package/dist/components/editableText/EditableText.stories.js.map +1 -0
- package/dist/components/editableText/EditableText.test.d.ts +2 -0
- package/dist/components/editableText/EditableText.test.d.ts.map +1 -0
- package/dist/components/editableText/EditableText.test.js +187 -0
- package/dist/components/editableText/EditableText.test.js.map +1 -0
- package/dist/components/heading/Heading.stories.d.ts +26 -0
- package/dist/components/heading/Heading.stories.d.ts.map +1 -1
- package/dist/components/heading/Heading.stories.js +35 -0
- package/dist/components/heading/Heading.stories.js.map +1 -1
- package/dist/components/progress/Progress.d.ts +6 -0
- package/dist/components/progress/Progress.d.ts.map +1 -0
- package/dist/components/progress/Progress.js +9 -0
- package/dist/components/progress/Progress.js.map +1 -0
- package/dist/components/progress/Progress.stories.d.ts +324 -0
- package/dist/components/progress/Progress.stories.d.ts.map +1 -0
- package/dist/components/progress/Progress.stories.js +77 -0
- package/dist/components/progress/Progress.stories.js.map +1 -0
- package/dist/components/progress/Progress.test.d.ts +2 -0
- package/dist/components/progress/Progress.test.d.ts.map +1 -0
- package/dist/components/progress/Progress.test.js +77 -0
- package/dist/components/progress/Progress.test.js.map +1 -0
- package/dist/components/toast/Toast.d.ts +10 -0
- package/dist/components/toast/Toast.d.ts.map +1 -0
- package/dist/components/toast/Toast.js +20 -0
- package/dist/components/toast/Toast.js.map +1 -0
- package/dist/components/toast/Toast.stories.d.ts +12 -0
- package/dist/components/toast/Toast.stories.d.ts.map +1 -0
- package/dist/components/toast/Toast.stories.js +73 -0
- package/dist/components/toast/Toast.stories.js.map +1 -0
- package/dist/components/toast/Toast.test.d.ts +2 -0
- package/dist/components/toast/Toast.test.d.ts.map +1 -0
- package/dist/components/toast/Toast.test.js +87 -0
- package/dist/components/toast/Toast.test.js.map +1 -0
- package/dist/components/toast/ToastViewport.d.ts +3 -0
- package/dist/components/toast/ToastViewport.d.ts.map +1 -0
- package/dist/components/toast/ToastViewport.js +5 -0
- package/dist/components/toast/ToastViewport.js.map +1 -0
- package/dist/index.css +202 -56
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/setupTestRuntime.ts +7 -0
- package/src/components/banner/Banner.stories.tsx +96 -0
- package/src/components/banner/Banner.test.tsx +86 -0
- package/src/components/banner/Banner.tsx +81 -0
- package/src/components/banner/banner.scss +67 -0
- package/src/components/button/button.scss +1 -5
- package/src/components/card/card.scss +0 -3
- package/src/components/dropdown/dropdown.scss +0 -3
- package/src/components/editableText/EditableText.stories.tsx +136 -0
- package/src/components/editableText/EditableText.test.tsx +242 -0
- package/src/components/editableText/EditableText.tsx +73 -0
- package/src/components/editableText/editableText.scss +54 -0
- package/src/components/formField/fieldset/fieldset.scss +0 -2
- package/src/components/formField/formField.scss +0 -2
- package/src/components/formField/inputs/checkbox/checkboxInput.scss +0 -2
- package/src/components/formField/inputs/input.scss +0 -3
- package/src/components/formField/inputs/radio/radioButtonInput.scss +0 -2
- package/src/components/formField/inputs/selectDropdown/selectDropdown.scss +0 -1
- package/src/components/formField/label/label.scss +0 -2
- package/src/components/heading/Heading.stories.tsx +58 -0
- package/src/components/heading/heading.scss +4 -4
- package/src/components/modal/modal.scss +0 -3
- package/src/components/pill/pill.scss +0 -3
- package/src/components/progress/Progress.stories.tsx +90 -0
- package/src/components/progress/Progress.test.tsx +88 -0
- package/src/components/progress/Progress.tsx +16 -0
- package/src/components/progress/progress.scss +13 -0
- package/src/components/searchBar/searchBar.scss +0 -3
- package/src/components/table/columnFilters/columnFilters.scss +0 -6
- package/src/components/table/pagination/pagination.scss +0 -4
- package/src/components/tabs/tabs.scss +0 -2
- package/src/components/tag/tag.scss +0 -3
- package/src/components/toast/Toast.stories.tsx +113 -0
- package/src/components/toast/Toast.test.tsx +126 -0
- package/src/components/toast/Toast.tsx +35 -0
- package/src/components/toast/ToastViewport.tsx +6 -0
- package/src/components/toast/toast.scss +79 -0
- package/src/components/tooltip/tooltip.scss +0 -3
- package/src/global.scss +9 -1
- package/src/index.scss +4 -0
- package/src/index.ts +4 -0
- package/src/tokens.scss +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#124](https://github.com/arbor-education/design-system.components/pull/124) [`202615f`](https://github.com/arbor-education/design-system.components/commit/202615f09a42e564dd418b7bd1b9c6a3de38b33f) Thanks [@angusmglfraser](https://github.com/angusmglfraser)! - MIS-66715 add banner component
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#125](https://github.com/arbor-education/design-system.components/pull/125) [`f01b121`](https://github.com/arbor-education/design-system.components/commit/f01b1216f60898647910fd64af9262e59d7e3060) Thanks [@angusmglfraser](https://github.com/angusmglfraser)! - MIS-67797 added global default styles for DS components
|
|
12
|
+
|
|
13
|
+
## 0.3.6
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#122](https://github.com/arbor-education/design-system.components/pull/122) [`8f25e54`](https://github.com/arbor-education/design-system.components/commit/8f25e54a2c20ec2ef52c486749d46e7d9731d49f) Thanks [@AmeeMorris](https://github.com/AmeeMorris)! - MIS-66424 Toast component
|
|
18
|
+
|
|
19
|
+
- [#123](https://github.com/arbor-education/design-system.components/pull/123) [`dbac185`](https://github.com/arbor-education/design-system.components/commit/dbac18524c61d15e788f92ec8cee25cf20c1332c) Thanks [@AmeeMorris](https://github.com/AmeeMorris)! - MIS-66708 Progress component
|
|
20
|
+
|
|
21
|
+
- [#121](https://github.com/arbor-education/design-system.components/pull/121) [`e93e5c8`](https://github.com/arbor-education/design-system.components/commit/e93e5c8625a63ffb6282fc246168cd69696d5a32) Thanks [@AmeeMorris](https://github.com/AmeeMorris)! - MIS-68210 Editable text component
|
|
22
|
+
|
|
3
23
|
## 0.3.5
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { IconName } from '../icon/allowedIcons';
|
|
2
|
+
export declare enum BANNER_LEVEL {
|
|
3
|
+
INFO = "info",
|
|
4
|
+
NEUTRAL = "neutral",
|
|
5
|
+
WARNING = "warning",
|
|
6
|
+
DESTRUCTIVE = "destructive"
|
|
7
|
+
}
|
|
8
|
+
export type BannerProps = {
|
|
9
|
+
className?: string;
|
|
10
|
+
level?: BANNER_LEVEL;
|
|
11
|
+
icon?: IconName;
|
|
12
|
+
title?: string;
|
|
13
|
+
buttonText?: string;
|
|
14
|
+
buttonOnClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
15
|
+
text?: string;
|
|
16
|
+
hideIcon?: boolean;
|
|
17
|
+
};
|
|
18
|
+
export declare const Banner: (props: BannerProps) => import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
//# sourceMappingURL=Banner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Banner.d.ts","sourceRoot":"","sources":["../../../src/components/banner/Banner.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAG7D,oBAAY,YAAY;IACtB,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,WAAW,gBAAgB;CAC5B;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IACjE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAoBF,eAAO,MAAM,MAAM,GAAI,OAAO,WAAW,4CAsCxC,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cva } from 'class-variance-authority';
|
|
3
|
+
import { Button } from '../button/Button';
|
|
4
|
+
import { Icon } from '../icon/Icon';
|
|
5
|
+
export var BANNER_LEVEL;
|
|
6
|
+
(function (BANNER_LEVEL) {
|
|
7
|
+
BANNER_LEVEL["INFO"] = "info";
|
|
8
|
+
BANNER_LEVEL["NEUTRAL"] = "neutral";
|
|
9
|
+
BANNER_LEVEL["WARNING"] = "warning";
|
|
10
|
+
BANNER_LEVEL["DESTRUCTIVE"] = "destructive";
|
|
11
|
+
})(BANNER_LEVEL || (BANNER_LEVEL = {}));
|
|
12
|
+
const bannerClassName = cva(['ds-banner'], {
|
|
13
|
+
variants: {
|
|
14
|
+
level: {
|
|
15
|
+
[BANNER_LEVEL.INFO]: 'ds-banner--info',
|
|
16
|
+
[BANNER_LEVEL.NEUTRAL]: 'ds-banner--neutral',
|
|
17
|
+
[BANNER_LEVEL.WARNING]: 'ds-banner--warning',
|
|
18
|
+
[BANNER_LEVEL.DESTRUCTIVE]: 'ds-banner--destructive',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
const DEFAULT_ICON_MAP = {
|
|
23
|
+
[BANNER_LEVEL.INFO]: 'info',
|
|
24
|
+
[BANNER_LEVEL.NEUTRAL]: 'info',
|
|
25
|
+
[BANNER_LEVEL.WARNING]: 'triangle-alert',
|
|
26
|
+
[BANNER_LEVEL.DESTRUCTIVE]: 'circle-alert',
|
|
27
|
+
};
|
|
28
|
+
export const Banner = (props) => {
|
|
29
|
+
const { className, level = BANNER_LEVEL.NEUTRAL, icon: rawIcon, hideIcon = false, title, buttonText, buttonOnClick, text, } = props;
|
|
30
|
+
const icon = hideIcon ? null : rawIcon ?? DEFAULT_ICON_MAP[level];
|
|
31
|
+
return (_jsxs("div", { className: bannerClassName({ level, className }), children: [icon && _jsx(Icon, { size: 24, name: icon }), _jsxs("div", { className: "ds-banner__central-container", children: [title && (_jsx("h3", { className: "ds-banner__title", children: title })), text && _jsx("span", { children: text })] }), buttonText && (_jsx(Button, { onClick: buttonOnClick, className: "ds-banner__button", variant: "text-link", children: buttonText }))] }));
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=Banner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Banner.js","sourceRoot":"","sources":["../../../src/components/banner/Banner.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,MAAM,EAA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SAAS,EAAE,CAAC,aAE/C,IAAI,IAAI,KAAC,IAAI,IAAC,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,GAAI,EACvC,eAAK,SAAS,EAAC,8BAA8B,aAC1C,KAAK,IAAI,CACR,aAAI,SAAS,EAAC,kBAAkB,YAC7B,KAAK,GACH,CACN,EACA,IAAI,IAAI,yBAAO,IAAI,GAAQ,IACxB,EACL,UAAU,IAAI,CACb,KAAC,MAAM,IACL,OAAO,EAAE,aAAa,EACtB,SAAS,EAAC,mBAAmB,EAC7B,OAAO,EAAC,WAAW,YAElB,UAAU,GACJ,CACV,IACG,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { Meta } from '@storybook/react-vite';
|
|
2
|
+
import { Banner, BANNER_LEVEL } from './Banner';
|
|
3
|
+
declare const meta: Meta<typeof Banner>;
|
|
4
|
+
export declare const Neutral: {
|
|
5
|
+
args: {
|
|
6
|
+
text: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export declare const Info: {
|
|
10
|
+
args: {
|
|
11
|
+
level: BANNER_LEVEL;
|
|
12
|
+
text: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export declare const Warning: {
|
|
16
|
+
args: {
|
|
17
|
+
level: BANNER_LEVEL;
|
|
18
|
+
text: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export declare const Destructive: {
|
|
22
|
+
args: {
|
|
23
|
+
level: BANNER_LEVEL;
|
|
24
|
+
text: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export declare const WithTitle: {
|
|
28
|
+
args: {
|
|
29
|
+
level: BANNER_LEVEL;
|
|
30
|
+
title: string;
|
|
31
|
+
text: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export declare const WithButton: {
|
|
35
|
+
args: {
|
|
36
|
+
level: BANNER_LEVEL;
|
|
37
|
+
text: string;
|
|
38
|
+
buttonText: string;
|
|
39
|
+
buttonOnClick: () => void;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
export declare const WithTitleAndButton: {
|
|
43
|
+
args: {
|
|
44
|
+
level: BANNER_LEVEL;
|
|
45
|
+
title: string;
|
|
46
|
+
text: string;
|
|
47
|
+
buttonText: string;
|
|
48
|
+
buttonOnClick: () => void;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export declare const TitleOnly: {
|
|
52
|
+
args: {
|
|
53
|
+
level: BANNER_LEVEL;
|
|
54
|
+
title: string;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
export declare const CustomIcon: {
|
|
58
|
+
args: {
|
|
59
|
+
level: BANNER_LEVEL;
|
|
60
|
+
icon: string;
|
|
61
|
+
text: string;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
export declare const HideIcon: {
|
|
65
|
+
args: {
|
|
66
|
+
level: BANNER_LEVEL;
|
|
67
|
+
hideIcon: boolean;
|
|
68
|
+
text: string;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
export default meta;
|
|
72
|
+
//# sourceMappingURL=Banner.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Banner.stories.d.ts","sourceRoot":"","sources":["../../../src/components/banner/Banner.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAEhD,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,MAAM,CAa7B,CAAC;AAEF,eAAO,MAAM,OAAO;;;;CAInB,CAAC;AAEF,eAAO,MAAM,IAAI;;;;;CAKhB,CAAC;AAEF,eAAO,MAAM,OAAO;;;;;CAKnB,CAAC;AAEF,eAAO,MAAM,WAAW;;;;;CAKvB,CAAC;AAEF,eAAO,MAAM,SAAS;;;;;;CAMrB,CAAC;AAEF,eAAO,MAAM,UAAU;;;;;;;CAOtB,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;;;;;;CAQ9B,CAAC;AAEF,eAAO,MAAM,SAAS;;;;;CAKrB,CAAC;AAEF,eAAO,MAAM,UAAU;;;;;;CAMtB,CAAC;AAEF,eAAO,MAAM,QAAQ;;;;;;CAMpB,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Banner, BANNER_LEVEL } from './Banner';
|
|
2
|
+
const meta = {
|
|
3
|
+
tags: ['autodocs'],
|
|
4
|
+
title: 'Components/Banner',
|
|
5
|
+
component: Banner,
|
|
6
|
+
argTypes: {
|
|
7
|
+
level: {
|
|
8
|
+
control: { type: 'select' },
|
|
9
|
+
options: Object.values(BANNER_LEVEL),
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
args: {
|
|
13
|
+
buttonOnClick: () => { console.log('click!'); },
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
export const Neutral = {
|
|
17
|
+
args: {
|
|
18
|
+
text: 'This is a neutral banner message with some useful information for the user.',
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
export const Info = {
|
|
22
|
+
args: {
|
|
23
|
+
level: BANNER_LEVEL.INFO,
|
|
24
|
+
text: 'Your session will expire in 10 minutes. Save your work to avoid losing changes.',
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
export const Warning = {
|
|
28
|
+
args: {
|
|
29
|
+
level: BANNER_LEVEL.WARNING,
|
|
30
|
+
text: 'This action may affect student records. Please review before proceeding.',
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
export const Destructive = {
|
|
34
|
+
args: {
|
|
35
|
+
level: BANNER_LEVEL.DESTRUCTIVE,
|
|
36
|
+
text: 'Something went wrong. Please contact your system administrator.',
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
export const WithTitle = {
|
|
40
|
+
args: {
|
|
41
|
+
level: BANNER_LEVEL.INFO,
|
|
42
|
+
title: 'Important Update',
|
|
43
|
+
text: 'A new version of the system is available. Refresh the page to apply updates.',
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
export const WithButton = {
|
|
47
|
+
args: {
|
|
48
|
+
level: BANNER_LEVEL.WARNING,
|
|
49
|
+
text: 'You have unsaved changes that will be lost.',
|
|
50
|
+
buttonText: 'Undo changes',
|
|
51
|
+
buttonOnClick: () => { console.log('Banner button clicked'); },
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
export const WithTitleAndButton = {
|
|
55
|
+
args: {
|
|
56
|
+
level: BANNER_LEVEL.INFO,
|
|
57
|
+
title: 'Scheduled Maintenance',
|
|
58
|
+
text: 'The system will be unavailable on Saturday 1st March between 2am–4am.',
|
|
59
|
+
buttonText: 'Learn more',
|
|
60
|
+
buttonOnClick: () => { console.log('Banner button clicked'); },
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
export const TitleOnly = {
|
|
64
|
+
args: {
|
|
65
|
+
level: BANNER_LEVEL.NEUTRAL,
|
|
66
|
+
title: 'No results found for the selected filters.',
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
export const CustomIcon = {
|
|
70
|
+
args: {
|
|
71
|
+
level: BANNER_LEVEL.INFO,
|
|
72
|
+
icon: 'circle-check',
|
|
73
|
+
text: 'Your changes have been saved successfully.',
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
export const HideIcon = {
|
|
77
|
+
args: {
|
|
78
|
+
level: BANNER_LEVEL.WARNING,
|
|
79
|
+
hideIcon: true,
|
|
80
|
+
text: 'This banner has its icon hidden.',
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
export default meta;
|
|
84
|
+
//# sourceMappingURL=Banner.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Banner.stories.js","sourceRoot":"","sources":["../../../src/components/banner/Banner.stories.tsx"],"names":[],"mappings":"AACA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AU,EAAE,cAAc;QAC1B,aAAa,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC;KAC/D;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE;QACJ,KAAK,EAAE,YAAY,CAAC,IAAI;QACxB,KAAK,EAAE,uBAAuB;QAC9B,IAAI,EAAE,uEAAuE;QAC7E,UAAU,EAAE,YAAY;QACxB,aAAa,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC;KAC/D;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,IAAI,EAAE;QACJ,KAAK,EAAE,YAAY,CAAC,OAAO;QAC3B,KAAK,EAAE,4CAA4C;KACpD;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,IAAI,EAAE;QACJ,KAAK,EAAE,YAAY,CAAC,IAAI;QACxB,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,4CAA4C;KACnD;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE;QACJ,KAAK,EAAE,YAAY,CAAC,OAAO;QAC3B,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE,kCAAkC;KACzC;CACF,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Banner.test.d.ts","sourceRoot":"","sources":["../../../src/components/banner/Banner.test.tsx"],"names":[],"mappings":"AAEA,OAAO,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { describe, expect, test, vi } from 'vitest';
|
|
3
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
4
|
+
import '@testing-library/jest-dom/vitest';
|
|
5
|
+
import { Banner, BANNER_LEVEL } from './Banner';
|
|
6
|
+
describe('Banner', () => {
|
|
7
|
+
describe('text', () => {
|
|
8
|
+
test('renders text content', () => {
|
|
9
|
+
render(_jsx(Banner, { text: "Something important happened." }));
|
|
10
|
+
expect(screen.getByText('Something important happened.')).toBeInTheDocument();
|
|
11
|
+
});
|
|
12
|
+
test('renders title', () => {
|
|
13
|
+
render(_jsx(Banner, { title: "Scheduled Maintenance" }));
|
|
14
|
+
expect(screen.getByRole('heading', { name: 'Scheduled Maintenance' })).toBeInTheDocument();
|
|
15
|
+
});
|
|
16
|
+
test('does not render a heading when title is not provided', () => {
|
|
17
|
+
render(_jsx(Banner, { text: "No title here." }));
|
|
18
|
+
expect(screen.queryByRole('heading')).not.toBeInTheDocument();
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
describe('level', () => {
|
|
22
|
+
test('applies neutral class by default', () => {
|
|
23
|
+
const { container } = render(_jsx(Banner, {}));
|
|
24
|
+
expect(container.firstChild).toHaveClass('ds-banner--neutral');
|
|
25
|
+
});
|
|
26
|
+
test.each(Object.values(BANNER_LEVEL))('applies correct class for level %s', (level) => {
|
|
27
|
+
const { container } = render(_jsx(Banner, { level: level }));
|
|
28
|
+
expect(container.firstChild).toHaveClass(`ds-banner--${level.toLowerCase()}`);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
describe('icon', () => {
|
|
32
|
+
test('renders the default icon based on level', () => {
|
|
33
|
+
const { container } = render(_jsx(Banner, {}));
|
|
34
|
+
expect(container.querySelector('svg')).toBeInTheDocument();
|
|
35
|
+
});
|
|
36
|
+
test('renders a custom icon when icon prop is provided', () => {
|
|
37
|
+
const { container } = render(_jsx(Banner, { icon: "circle-check" }));
|
|
38
|
+
expect(container.querySelector('svg')).toBeInTheDocument();
|
|
39
|
+
});
|
|
40
|
+
test('does not render an icon when hideIcon is true', () => {
|
|
41
|
+
const { container } = render(_jsx(Banner, { hideIcon: true }));
|
|
42
|
+
expect(container.querySelector('svg')).not.toBeInTheDocument();
|
|
43
|
+
});
|
|
44
|
+
test('does not render an icon when hideIcon is true even if icon prop is provided', () => {
|
|
45
|
+
const { container } = render(_jsx(Banner, { icon: "info", hideIcon: true }));
|
|
46
|
+
expect(container.querySelector('svg')).not.toBeInTheDocument();
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
describe('button', () => {
|
|
50
|
+
test('renders a button when buttonText is provided', () => {
|
|
51
|
+
render(_jsx(Banner, { buttonText: "Learn more" }));
|
|
52
|
+
expect(screen.getByRole('button')).toBeInTheDocument();
|
|
53
|
+
});
|
|
54
|
+
test('does not render a button when buttonText is not provided', () => {
|
|
55
|
+
render(_jsx(Banner, { text: "No button here." }));
|
|
56
|
+
expect(screen.queryByRole('button')).not.toBeInTheDocument();
|
|
57
|
+
});
|
|
58
|
+
test('calls buttonOnClick when button is clicked', () => {
|
|
59
|
+
const handleClick = vi.fn();
|
|
60
|
+
render(_jsx(Banner, { buttonText: "Learn more", buttonOnClick: handleClick }));
|
|
61
|
+
fireEvent.click(screen.getByRole('button'));
|
|
62
|
+
expect(handleClick).toHaveBeenCalledTimes(1);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
describe('className', () => {
|
|
66
|
+
test('applies custom className', () => {
|
|
67
|
+
const { container } = render(_jsx(Banner, { className: "my-custom-class" }));
|
|
68
|
+
expect(container.firstChild).toHaveClass('my-custom-class');
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
//# sourceMappingURL=Banner.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Banner.test.js","sourceRoot":"","sources":["../../../src/components/banner/Banner.test.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,k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SAAS,EAAE,GAAG,MAAM,CAAC,KAAC,MAAM,IAAC,SAAS,EAAC,iBAAiB,GAAG,CAAC,CAAC;YACrE,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;QAC9D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type EditableTextProps = {
|
|
2
|
+
text: string;
|
|
3
|
+
className?: string;
|
|
4
|
+
onEditSave: (newText: string) => void;
|
|
5
|
+
isEditing?: boolean;
|
|
6
|
+
multiline?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare const EditableText: ({ text: textProp, className, onEditSave, isEditing: isEditingProp, multiline }: EditableTextProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=EditableText.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditableText.d.ts","sourceRoot":"","sources":["../../../src/components/editableText/EditableText.tsx"],"names":[],"mappings":"AAMA,KAAK,iBAAiB,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,gFAAqG,iBAAiB,4CA0DlJ,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { TextInput } from '../formField/inputs/text/TextInput';
|
|
4
|
+
import { TextArea } from '../formField/inputs/textArea/TextArea';
|
|
5
|
+
import { Icon } from '../icon/Icon';
|
|
6
|
+
import { useEffect, useRef, useState } from 'react';
|
|
7
|
+
export const EditableText = ({ text: textProp, className = '', onEditSave, isEditing: isEditingProp = false, multiline = false }) => {
|
|
8
|
+
const [isEditing, setIsEditing] = useState(false);
|
|
9
|
+
const [text, setText] = useState(textProp);
|
|
10
|
+
const preEditText = useRef(textProp);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
setText(textProp);
|
|
13
|
+
}, [textProp]);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
setIsEditing(isEditingProp);
|
|
16
|
+
}, [isEditingProp]);
|
|
17
|
+
const handleEditSave = () => {
|
|
18
|
+
onEditSave(text);
|
|
19
|
+
preEditText.current = text;
|
|
20
|
+
setIsEditing(false);
|
|
21
|
+
};
|
|
22
|
+
const handleKeyDown = (e) => {
|
|
23
|
+
if (e.key === 'Enter' && !multiline) {
|
|
24
|
+
handleEditSave();
|
|
25
|
+
}
|
|
26
|
+
if (e.key === 'Escape') {
|
|
27
|
+
setText(preEditText.current);
|
|
28
|
+
setIsEditing(false);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const InputComponent = multiline ? TextArea : TextInput;
|
|
32
|
+
return (_jsx("span", { className: classNames('ds-editable-text', className), children: isEditing
|
|
33
|
+
? (_jsx(InputComponent, { name: "editable-text", "aria-label": "Text", className: "ds-editable-text__input", value: text, onChange: e => setText(e.target.value), onBlur: handleEditSave, onKeyDown: handleKeyDown, autoFocus: true }))
|
|
34
|
+
: (_jsxs("button", { className: "ds-editable-text__button", "aria-label": "Edit text", onClick: () => setIsEditing(true), children: [text, _jsx(Icon, { name: "pencil", size: 16, className: "ds-editable-text__button-icon" })] })) }));
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=EditableText.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditableText.js","sourceRoot":"","sources":["../../../src/components/editableText/EditableText.tsx"],"names":[],"mappings":";AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO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;YACvB,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;YAC7B,YAAY,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,cAAc,GAAG,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;IAExD,OAAO,CACL,eAAM,SAAS,EAAE,UAAU,CAAC,kBAAkB,EAAE,SAAS,CAAC,YACvD,SAAS;YACR,CAAC,CAAC,CACE,KAAC,cAAc,IACb,IAAI,EAAC,eAAe,gBACT,MAAM,EACjB,SAAS,EAAC,yBAAyB,EACnC,KAAK,EAAE,IAAI,EACX,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EACtC,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,aAAa,EACxB,SAAS,SACT,CACH;YACH,CAAC,CAAC,CACE,kBACE,SAAS,EAAC,0BAA0B,gBACzB,WAAW,EACtB,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,aAEhC,IAAI,EACL,KAAC,IAAI,IAAC,IAAI,EAAC,QAAQ,EAAC,IAAI,EAAE,EAAE,EAAE,SAAS,EAAC,+BAA+B,GAAG,IACnE,CACV,GACA,CACR,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { StoryObj } from '@storybook/react-vite';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: ({ text: textProp, className, onEditSave, isEditing: isEditingProp, multiline }: {
|
|
5
|
+
text: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
onEditSave: (newText: string) => void;
|
|
8
|
+
isEditing?: boolean;
|
|
9
|
+
multiline?: boolean;
|
|
10
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
parameters: {
|
|
12
|
+
layout: string;
|
|
13
|
+
};
|
|
14
|
+
tags: string[];
|
|
15
|
+
argTypes: {
|
|
16
|
+
text: {
|
|
17
|
+
control: "text";
|
|
18
|
+
description: string;
|
|
19
|
+
};
|
|
20
|
+
className: {
|
|
21
|
+
control: "text";
|
|
22
|
+
description: string;
|
|
23
|
+
};
|
|
24
|
+
onEditSave: {
|
|
25
|
+
action: string;
|
|
26
|
+
description: string;
|
|
27
|
+
};
|
|
28
|
+
isEditing: {
|
|
29
|
+
control: "boolean";
|
|
30
|
+
description: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export default meta;
|
|
35
|
+
type Story = StoryObj<typeof meta>;
|
|
36
|
+
export declare const Default: Story;
|
|
37
|
+
export declare const InH1: Story;
|
|
38
|
+
export declare const InH2: Story;
|
|
39
|
+
export declare const InH3: Story;
|
|
40
|
+
export declare const InH4: Story;
|
|
41
|
+
export declare const InParagraph: Story;
|
|
42
|
+
export declare const InCustomStyledDiv: Story;
|
|
43
|
+
export declare const LongText: Story;
|
|
44
|
+
//# sourceMappingURL=EditableText.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditableText.stories.d.ts","sourceRoot":"","sources":["../../../src/components/editableText/EditableText.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAG5D,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyB2B,CAAC;AAEtC,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAGnC,eAAO,MAAM,OAAO,EAAE,KAUrB,CAAC;AAGF,eAAO,MAAM,IAAI,EAAE,KAUlB,CAAC;AAGF,eAAO,MAAM,IAAI,EAAE,KAUlB,CAAC;AAGF,eAAO,MAAM,IAAI,EAAE,KAUlB,CAAC;AAGF,eAAO,MAAM,IAAI,EAAE,KAUlB,CAAC;AAGF,eAAO,MAAM,WAAW,EAAE,KAUzB,CAAC;AAGF,eAAO,MAAM,iBAAiB,EAAE,KAU/B,CAAC;AAGF,eAAO,MAAM,QAAQ,EAAE,KAUtB,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { EditableText } from './EditableText';
|
|
3
|
+
const meta = {
|
|
4
|
+
title: 'Components/EditableText',
|
|
5
|
+
component: EditableText,
|
|
6
|
+
parameters: {
|
|
7
|
+
layout: 'padded',
|
|
8
|
+
},
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
argTypes: {
|
|
11
|
+
text: {
|
|
12
|
+
control: 'text',
|
|
13
|
+
description: 'The text to display',
|
|
14
|
+
},
|
|
15
|
+
className: {
|
|
16
|
+
control: 'text',
|
|
17
|
+
description: 'Optional CSS class name',
|
|
18
|
+
},
|
|
19
|
+
onEditSave: {
|
|
20
|
+
action: 'edit saved',
|
|
21
|
+
description: 'Callback fired when the text is edited',
|
|
22
|
+
},
|
|
23
|
+
isEditing: {
|
|
24
|
+
control: 'boolean',
|
|
25
|
+
description: 'Control whether the text is in edit mode',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
export default meta;
|
|
30
|
+
// Default (inherits parent styles)
|
|
31
|
+
export const Default = {
|
|
32
|
+
render: args => (_jsx("div", { style: { width: '100%' }, children: _jsx(EditableText, { ...args }) })),
|
|
33
|
+
args: {
|
|
34
|
+
text: 'Editable Text',
|
|
35
|
+
onEditSave: () => { },
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
// Inside H1 heading
|
|
39
|
+
export const InH1 = {
|
|
40
|
+
render: args => (_jsx("h1", { children: _jsx(EditableText, { ...args }) })),
|
|
41
|
+
args: {
|
|
42
|
+
text: 'Editable Heading Level 1',
|
|
43
|
+
onEditSave: () => { },
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
// Inside H2 heading
|
|
47
|
+
export const InH2 = {
|
|
48
|
+
render: args => (_jsx("h2", { children: _jsx(EditableText, { ...args }) })),
|
|
49
|
+
args: {
|
|
50
|
+
text: 'Editable Heading Level 2',
|
|
51
|
+
onEditSave: () => { },
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
// Inside H3 heading
|
|
55
|
+
export const InH3 = {
|
|
56
|
+
render: args => (_jsx("h3", { children: _jsx(EditableText, { ...args }) })),
|
|
57
|
+
args: {
|
|
58
|
+
text: 'Editable Heading Level 3',
|
|
59
|
+
onEditSave: () => { },
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
// Inside H4 heading
|
|
63
|
+
export const InH4 = {
|
|
64
|
+
render: args => (_jsx("h4", { children: _jsx(EditableText, { ...args }) })),
|
|
65
|
+
args: {
|
|
66
|
+
text: 'Editable Heading Level 4',
|
|
67
|
+
onEditSave: () => { },
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
// Inside paragraph
|
|
71
|
+
export const InParagraph = {
|
|
72
|
+
render: args => (_jsx("p", { children: _jsx(EditableText, { ...args }) })),
|
|
73
|
+
args: {
|
|
74
|
+
text: 'Editable paragraph text',
|
|
75
|
+
onEditSave: () => { },
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
// Inside custom styled div
|
|
79
|
+
export const InCustomStyledDiv = {
|
|
80
|
+
render: args => (_jsx("div", { style: { fontSize: '24px', fontWeight: 'bold', color: '#0066cc' }, children: _jsx(EditableText, { ...args }) })),
|
|
81
|
+
args: {
|
|
82
|
+
text: 'Custom styled editable text',
|
|
83
|
+
onEditSave: () => { },
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
// Long text example
|
|
87
|
+
export const LongText = {
|
|
88
|
+
render: args => (_jsx("h2", { children: _jsx(EditableText, { ...args }) })),
|
|
89
|
+
args: {
|
|
90
|
+
text: 'This is a much longer text that demonstrates how the component handles extended content',
|
|
91
|
+
onEditSave: () => { },
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=EditableText.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditableText.stories.js","sourceRoot":"","sources":["../../../src/components/editableText/EditableText.stories.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,IAAI,GAAG;IACX,KAAK,EAAE,yBAAyB;IAChC,SAAS,EAAE,YAAY;IACvB,UAAU,EAAE;QACV,MAAM,EAAE,QAAQ;KACjB;IACD,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,QAAQ,EAAE;QACR,IAAI,EAAE;YACJ,OAAO,EAAE,MAAM;YACf,WAAW,EAAE,qBAAqB;SACnC;QACD,SAAS,EAAE;YACT,OAAO,EAAE,MAAM;YACf,WAAW,EAAE,yBAAyB;SACvC;QACD,UAAU,EAAE;YACV,MAAM,EAAE,YAAY;YACpB,WAAW,EAAE,wCAAwC;SACtD;QACD,SAAS,EAAE;YACT,OAAO,EAAE,SAAS;YAClB,WAAW,EAAE,0CAA0C;SACxD;KACF;CACkC,CAAC;AAEtC,eAAe,IAAI,CAAC;AAGpB,mCAAmC;AACnC,MAAM,CAAC,MAAM,OAAO,GAAU;IAC5B,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,CACd,cAAK,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,YAC3B,KAAC,YAAY,OAAK,IAAI,GAAI,GACtB,CACP;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,eAAe;QACrB,UAAU,EAAE,GAAG,EAAE,GAAE,CAAC;KACrB;CACF,CAAC;AAEF,oBAAoB;AACpB,MAAM,CAAC,MAAM,IAAI,GAAU;IACzB,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,CACd,uBACE,KAAC,YAAY,OAAK,IAAI,GAAI,GACvB,CACN;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,0BAA0B;QAChC,UAAU,EAAE,GAAG,EAAE,GAAE,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,IAAI,GAAI,GACtB,CACP;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,6BAA6B;QACnC,UAAU,EAAE,GAAG,EAAE,GAAE,CAAC;KACrB;CACF,CAAC;AAEF,oBAAoB;AACpB,MAAM,CAAC,MAAM,QAAQ,GAAU;IAC7B,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,CACd,uBACE,KAAC,YAAY,OAAK,IAAI,GAAI,GACvB,CACN;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,yFAAyF;QAC/F,UAAU,EAAE,GAAG,EAAE,GAAE,CAAC;KACrB;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditableText.test.d.ts","sourceRoot":"","sources":["../../../src/components/editableText/EditableText.test.tsx"],"names":[],"mappings":"AAGA,OAAO,kCAAkC,CAAC"}
|