@descope/flow-components 2.0.38
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/.eslintrc +119 -0
- package/.github/actions/setup/action.yml +42 -0
- package/.github/workflows/ci.yml +105 -0
- package/.github/workflows/publish.yml +41 -0
- package/.github/workflows/release.yml +44 -0
- package/.husky/pre-commit +1 -0
- package/.prettierrc +8 -0
- package/.storybook/main.js +23 -0
- package/.storybook/manager.js +10 -0
- package/.storybook/preview-head.html +29 -0
- package/.storybook/preview.js +44 -0
- package/LICENSE +21 -0
- package/README.md +20 -0
- package/babel.config.js +7 -0
- package/dist/index.cjs.js +360 -0
- package/dist/index.d.ts +397 -0
- package/dist/index.esm.js +314 -0
- package/jest.config.js +33 -0
- package/jest.setup.js +2 -0
- package/package.json +110 -0
- package/renovate.json +4 -0
- package/rollup.config.mjs +47 -0
- package/src/Boolean/Boolean.tsx +24 -0
- package/src/Boolean/index.ts +1 -0
- package/src/Button/Button.tsx +49 -0
- package/src/Button/index.ts +1 -0
- package/src/Checkbox/Checkbox.tsx +16 -0
- package/src/Checkbox/index.ts +1 -0
- package/src/Code/Code.tsx +21 -0
- package/src/Code/index.ts +1 -0
- package/src/Container/Container.tsx +111 -0
- package/src/Container/index.ts +1 -0
- package/src/CssVarImage/CssVarImage.tsx +38 -0
- package/src/CssVarImage/index.ts +1 -0
- package/src/Divider/Divider.tsx +33 -0
- package/src/Divider/index.ts +1 -0
- package/src/EmailField/EmailField.tsx +20 -0
- package/src/EmailField/index.ts +1 -0
- package/src/Image/Image.tsx +32 -0
- package/src/Image/index.ts +1 -0
- package/src/Input/Input.tsx +27 -0
- package/src/Input/index.ts +1 -0
- package/src/Link/Link.tsx +33 -0
- package/src/Link/index.ts +1 -0
- package/src/Loader/Loader.tsx +40 -0
- package/src/Loader/index.ts +1 -0
- package/src/Logo/Logo.tsx +27 -0
- package/src/Logo/index.ts +1 -0
- package/src/NewPassword/NewPassword.tsx +25 -0
- package/src/NewPassword/index.ts +1 -0
- package/src/NumberField/NumberField.tsx +20 -0
- package/src/NumberField/index.ts +1 -0
- package/src/Password/Password.tsx +20 -0
- package/src/Password/index.ts +1 -0
- package/src/Phone/Phone.tsx +22 -0
- package/src/Phone/index.ts +1 -0
- package/src/Select/Select.tsx +29 -0
- package/src/Select/index.ts +1 -0
- package/src/Switch/Switch.tsx +21 -0
- package/src/Switch/index.ts +1 -0
- package/src/TOTPImage/TOTPImage.tsx +18 -0
- package/src/TOTPImage/index.ts +1 -0
- package/src/TOTPLink/TOTPLink.tsx +16 -0
- package/src/TOTPLink/index.ts +1 -0
- package/src/Text/Text.tsx +36 -0
- package/src/Text/index.ts +1 -0
- package/src/TextField/TextField.tsx +20 -0
- package/src/TextField/index.ts +1 -0
- package/src/Textarea/Textarea.tsx +20 -0
- package/src/Textarea/index.ts +1 -0
- package/src/icons/apple.tsx +14 -0
- package/src/icons/discord.tsx +14 -0
- package/src/icons/facebook.tsx +14 -0
- package/src/icons/fingerprint.tsx +14 -0
- package/src/icons/github.tsx +14 -0
- package/src/icons/gitlab.tsx +41 -0
- package/src/icons/google.tsx +29 -0
- package/src/icons/index.ts +11 -0
- package/src/icons/input-hidden.tsx +17 -0
- package/src/icons/input-visible.tsx +17 -0
- package/src/icons/linkedin.tsx +18 -0
- package/src/icons/microsoft.tsx +41 -0
- package/src/icons/passkey.tsx +16 -0
- package/src/icons/sso.tsx +14 -0
- package/src/index.ts +29 -0
- package/src/inputHelpers.ts +41 -0
- package/src/themeToCssVars/constants.ts +13 -0
- package/src/themeToCssVars/index.ts +153 -0
- package/src/themeToCssVars/types.ts +56 -0
- package/src/types.ts +52 -0
- package/src/utils.tsx +69 -0
- package/stories/Boolean.stories.jsx +37 -0
- package/stories/Button.stories.jsx +71 -0
- package/stories/Checkbox.stories.jsx +29 -0
- package/stories/Code.stories.jsx +60 -0
- package/stories/Container.stories.jsx +53 -0
- package/stories/Divider.stories.jsx +23 -0
- package/stories/EmailField.stories.jsx +36 -0
- package/stories/Image.stories.jsx +16 -0
- package/stories/Input.stories.jsx +63 -0
- package/stories/Link.stories.jsx +21 -0
- package/stories/Loader.stories.jsx +34 -0
- package/stories/Logo.stories.jsx +14 -0
- package/stories/NewPassword.stories.jsx +52 -0
- package/stories/NumberField.stories.jsx +35 -0
- package/stories/Password.stories.jsx +37 -0
- package/stories/Phone.stories.jsx +61 -0
- package/stories/Switch.stories.jsx +29 -0
- package/stories/TOTPImage.stories.jsx +22 -0
- package/stories/TOTPLink.stories.jsx +20 -0
- package/stories/Text.stories.jsx +35 -0
- package/stories/TextField.stories.jsx +39 -0
- package/stories/Textarea.stories.jsx +25 -0
- package/storybook-static/favicon.ico +0 -0
- package/test/__snapshots__/boolean.test.tsx.snap +47 -0
- package/test/__snapshots__/buttons.test.tsx.snap +843 -0
- package/test/__snapshots__/checkbox.test.tsx.snap +51 -0
- package/test/__snapshots__/code.test.tsx.snap +1184 -0
- package/test/__snapshots__/container.test.tsx.snap +218 -0
- package/test/__snapshots__/divider.test.tsx.snap +73 -0
- package/test/__snapshots__/image.test.tsx.snap +62 -0
- package/test/__snapshots__/input.test.tsx.snap +80 -0
- package/test/__snapshots__/link.test.tsx.snap +120 -0
- package/test/__snapshots__/loader.test.tsx.snap +53 -0
- package/test/__snapshots__/logo.test.tsx.snap +10 -0
- package/test/__snapshots__/newPassword.test.tsx.snap +69 -0
- package/test/__snapshots__/numeric-input.test.tsx.snap +21 -0
- package/test/__snapshots__/password.test.tsx.snap +26 -0
- package/test/__snapshots__/phone.test.tsx.snap +504 -0
- package/test/__snapshots__/switch.test.tsx.snap +51 -0
- package/test/__snapshots__/text.test.tsx.snap +89 -0
- package/test/__snapshots__/textarea.test.tsx.snap +73 -0
- package/test/__snapshots__/themeToCssVars.test.ts.snap +45 -0
- package/test/__snapshots__/totpImage.test.tsx.snap +10 -0
- package/test/__snapshots__/totpLink.test.tsx.snap +13 -0
- package/test/boolean.test.tsx +28 -0
- package/test/buttons.test.tsx +66 -0
- package/test/checkbox.test.tsx +67 -0
- package/test/code.test.tsx +182 -0
- package/test/container.test.tsx +91 -0
- package/test/divider.test.tsx +50 -0
- package/test/image.test.tsx +40 -0
- package/test/input.test.tsx +82 -0
- package/test/inputHelpers.test.tsx +58 -0
- package/test/link.test.tsx +71 -0
- package/test/loader.test.tsx +25 -0
- package/test/logo.test.tsx +10 -0
- package/test/newPassword.test.tsx +132 -0
- package/test/numeric-input.test.tsx +114 -0
- package/test/password.test.tsx +55 -0
- package/test/phone.test.tsx +158 -0
- package/test/switch.test.tsx +67 -0
- package/test/text.test.tsx +60 -0
- package/test/textarea.test.tsx +64 -0
- package/test/themeToCssVars.test.ts +82 -0
- package/test/totpImage.test.tsx +10 -0
- package/test/totpLink.test.tsx +10 -0
- package/tsconfig.json +20 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
type KebabCase<S extends string> = S extends `${infer First}${infer Rest}`
|
|
2
|
+
? Rest extends Uncapitalize<Rest>
|
|
3
|
+
? `${Uncapitalize<First>}${KebabCase<Rest>}`
|
|
4
|
+
: `${Uncapitalize<First>}-${KebabCase<Rest>}`
|
|
5
|
+
: S;
|
|
6
|
+
|
|
7
|
+
export type ExcludeMatchingProperties<F, S extends Partial<F>> = Pick<
|
|
8
|
+
F,
|
|
9
|
+
{ [K in keyof F]: S[K] extends F[K] ? never : K }[keyof F]
|
|
10
|
+
>;
|
|
11
|
+
|
|
12
|
+
export type CustomInputEvent = InputEvent & {
|
|
13
|
+
target: HTMLSelectElement;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type ComponentSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
17
|
+
|
|
18
|
+
export type InputType = 'number' | 'email' | 'text' | 'password';
|
|
19
|
+
|
|
20
|
+
export type TextAlign = 'left' | 'right' | 'center';
|
|
21
|
+
|
|
22
|
+
export type FlexAlignment = 'start' | 'center' | 'end';
|
|
23
|
+
|
|
24
|
+
export type HTMLInputAttrs = Omit<JSX.IntrinsicElements['input'], 'size'>;
|
|
25
|
+
|
|
26
|
+
export type DescopeInputExtraProps = {
|
|
27
|
+
'full-width'?: boolean;
|
|
28
|
+
bordered?: boolean;
|
|
29
|
+
label?: string;
|
|
30
|
+
placeholder?: string;
|
|
31
|
+
size?: ComponentSize;
|
|
32
|
+
'helper-text'?: string;
|
|
33
|
+
'data-errormessage-pattern-mismatch'?: string;
|
|
34
|
+
'data-errormessage-value-missing'?: string;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type DescopeInputProps = HTMLInputAttrs & DescopeInputExtraProps;
|
|
38
|
+
|
|
39
|
+
export type PropsToAttrs<R extends Record<string, any>> = {
|
|
40
|
+
[K in keyof R as KebabCase<K & string>]: R[K];
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type TypographyVariants =
|
|
44
|
+
| 'h1'
|
|
45
|
+
| 'h2'
|
|
46
|
+
| 'h3'
|
|
47
|
+
| 'subtitle1'
|
|
48
|
+
| 'subtitle2'
|
|
49
|
+
| 'body1'
|
|
50
|
+
| 'body2';
|
|
51
|
+
|
|
52
|
+
export type Mode = 'primary' | 'secondary' | 'error' | 'success';
|
package/src/utils.tsx
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React, { useCallback, useImperativeHandle, useRef } from 'react';
|
|
2
|
+
import { ExcludeMatchingProperties } from './types';
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line import/exports-last
|
|
5
|
+
export const withFixedProps = <P extends {}, F extends Partial<P>>(
|
|
6
|
+
Component: React.ComponentType<P>,
|
|
7
|
+
fixedProps: F
|
|
8
|
+
) =>
|
|
9
|
+
React.forwardRef<HTMLElement, ExcludeMatchingProperties<P, F>>(
|
|
10
|
+
(props, ref) => {
|
|
11
|
+
const allProps = { ...props, ...fixedProps } as unknown as P;
|
|
12
|
+
return <Component {...allProps} ref={ref} />;
|
|
13
|
+
}
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
const getFnBodyStr = (fn: Function) =>
|
|
17
|
+
fn.toString().match(/[^{]+\{([\s\S]*)\}$/)[1];
|
|
18
|
+
|
|
19
|
+
type CustomScriptFn = () => void;
|
|
20
|
+
|
|
21
|
+
const hash = (s: string) =>
|
|
22
|
+
// eslint-disable-next-line no-return-assign, no-bitwise, no-param-reassign
|
|
23
|
+
s.split('').reduce((a, b) => (a = (a << 5) - a + b.charCodeAt(0)) & a, 0);
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* This HOC allows us to bind a script (in vanilla JS) to the component and consume it in 2 different ways
|
|
27
|
+
* 1. By rendering the component using React
|
|
28
|
+
* 2. By adding a script tag next to the dom element that is later parsed and run by the web-component
|
|
29
|
+
*/
|
|
30
|
+
export const withCustomScripts = <T extends {}>(
|
|
31
|
+
Component: React.ComponentType<T>,
|
|
32
|
+
...nonArrowFns: CustomScriptFn[]
|
|
33
|
+
) =>
|
|
34
|
+
React.forwardRef<HTMLElement, T>((props, ref) => {
|
|
35
|
+
const internalRef = useRef<HTMLElement>();
|
|
36
|
+
|
|
37
|
+
const refFn = useCallback((recRef: HTMLElement) => {
|
|
38
|
+
if (!recRef) return;
|
|
39
|
+
|
|
40
|
+
internalRef.current = recRef;
|
|
41
|
+
// when in React, the context is taken from the root node,
|
|
42
|
+
// when in web-component, the context is injected to the function
|
|
43
|
+
nonArrowFns.forEach((fn) =>
|
|
44
|
+
fn.bind(recRef, (recRef?.getRootNode() as any)?.context)()
|
|
45
|
+
);
|
|
46
|
+
}, []);
|
|
47
|
+
|
|
48
|
+
useImperativeHandle(ref, () => internalRef.current);
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<>
|
|
52
|
+
<Component {...props} ref={refFn} />
|
|
53
|
+
{global?.process?.env?.SSR &&
|
|
54
|
+
nonArrowFns.map((fn, i) => {
|
|
55
|
+
const fnStr = getFnBodyStr(fn);
|
|
56
|
+
return (
|
|
57
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
58
|
+
<script
|
|
59
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
60
|
+
key={i}
|
|
61
|
+
data-id={hash(fnStr)}
|
|
62
|
+
// eslint-disable-next-line react/no-danger
|
|
63
|
+
dangerouslySetInnerHTML={{ __html: fnStr }}
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
66
|
+
})}
|
|
67
|
+
</>
|
|
68
|
+
);
|
|
69
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Boolean as Bool } from '../src';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'WCUI/Boolean',
|
|
6
|
+
component: Bool,
|
|
7
|
+
argTypes: {
|
|
8
|
+
type: {
|
|
9
|
+
options: ['checkbox', 'switch'],
|
|
10
|
+
control: { type: 'radio' }
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const BooleanTemplate = (args) => (
|
|
16
|
+
<form
|
|
17
|
+
onSubmit={(e) => {
|
|
18
|
+
e.preventDefault();
|
|
19
|
+
}}
|
|
20
|
+
style={{ display: 'flex', flexWrap: 'wrap' }}
|
|
21
|
+
>
|
|
22
|
+
<Bool {...args} />
|
|
23
|
+
|
|
24
|
+
<div>
|
|
25
|
+
<button type="submit">Submit</button>
|
|
26
|
+
</div>
|
|
27
|
+
</form>
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
export const Boolean = BooleanTemplate.bind({});
|
|
31
|
+
Boolean.args = {
|
|
32
|
+
label: 'Boolean Input Label',
|
|
33
|
+
size: 'md',
|
|
34
|
+
'full-width': false,
|
|
35
|
+
required: true,
|
|
36
|
+
type: 'checkbox'
|
|
37
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button } from '../src';
|
|
3
|
+
import * as icons from '../src/icons';
|
|
4
|
+
export default {
|
|
5
|
+
title: 'WCUI/Button',
|
|
6
|
+
component: Button,
|
|
7
|
+
parameters: {
|
|
8
|
+
controls: { expanded: true }
|
|
9
|
+
},
|
|
10
|
+
argTypes: {
|
|
11
|
+
variant: {
|
|
12
|
+
options: ['contained', 'outline', 'link'],
|
|
13
|
+
control: { type: 'radio' }
|
|
14
|
+
},
|
|
15
|
+
color: {
|
|
16
|
+
options: ['primary', 'secondary', 'success', 'error'],
|
|
17
|
+
control: { type: 'radio' }
|
|
18
|
+
},
|
|
19
|
+
size: {
|
|
20
|
+
options: ['xs', 'sm', 'md', 'lg', 'xl'],
|
|
21
|
+
control: { type: 'radio' }
|
|
22
|
+
},
|
|
23
|
+
startIcon: {
|
|
24
|
+
options: Object.keys(icons),
|
|
25
|
+
control: { type: 'select' }
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const StandardTemplate = (args) => <Button {...args} />;
|
|
31
|
+
export const Standard = StandardTemplate.bind({});
|
|
32
|
+
Standard.args = {
|
|
33
|
+
variant: 'contained',
|
|
34
|
+
children: 'Button',
|
|
35
|
+
color: 'primary',
|
|
36
|
+
loading: false,
|
|
37
|
+
size: 'md',
|
|
38
|
+
'full-width': false,
|
|
39
|
+
startIconColorText: true
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const ProvidersTemplate = (args) => (
|
|
43
|
+
<div className="flex">
|
|
44
|
+
<div
|
|
45
|
+
className="flex"
|
|
46
|
+
style={{ gap: '0.5rem', display: 'flex', flexWrap: 'wrap' }}
|
|
47
|
+
>
|
|
48
|
+
<Button {...args} startIcon="facebook" />
|
|
49
|
+
<Button {...args} startIcon="google" />
|
|
50
|
+
<Button {...args} startIcon="microsoft" />
|
|
51
|
+
<Button {...args} startIcon="github" />
|
|
52
|
+
<Button {...args} startIcon="gitlab" />
|
|
53
|
+
<Button {...args} startIcon="apple" />
|
|
54
|
+
<Button {...args} startIcon="discord" />
|
|
55
|
+
<Button {...args} startIcon="linkedin" />
|
|
56
|
+
<Button {...args} startIcon="sso" />
|
|
57
|
+
<Button {...args} startIcon="fingerprint" />
|
|
58
|
+
<Button {...args} startIcon="passkey" />
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
);
|
|
62
|
+
export const Providers = ProvidersTemplate.bind({});
|
|
63
|
+
Providers.args = {
|
|
64
|
+
variant: 'contained',
|
|
65
|
+
children: '',
|
|
66
|
+
color: 'primary',
|
|
67
|
+
loading: false,
|
|
68
|
+
size: 'md',
|
|
69
|
+
'full-width': false,
|
|
70
|
+
startIconColorText: true
|
|
71
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Checkbox } from '../src';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'WCUI/Checkbox',
|
|
6
|
+
component: Checkbox
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const CheckboxTemplate = (args) => (
|
|
10
|
+
<form
|
|
11
|
+
onSubmit={(e) => {
|
|
12
|
+
e.preventDefault();
|
|
13
|
+
}}
|
|
14
|
+
style={{ display: 'flex', flexWrap: 'wrap', gap: '0.5rem' }}
|
|
15
|
+
>
|
|
16
|
+
<Checkbox {...args} />
|
|
17
|
+
<div>
|
|
18
|
+
<button type="submit">Submit</button>
|
|
19
|
+
</div>
|
|
20
|
+
</form>
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export const Check = CheckboxTemplate.bind({});
|
|
24
|
+
Check.args = {
|
|
25
|
+
label: 'Checkbox Label',
|
|
26
|
+
size: 'sm',
|
|
27
|
+
'full-width': false,
|
|
28
|
+
required: true
|
|
29
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/* eslint-disable import/exports-last */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Code } from '../src';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'WCUI/Code',
|
|
7
|
+
component: Code,
|
|
8
|
+
parameters: {
|
|
9
|
+
controls: { expanded: true }
|
|
10
|
+
},
|
|
11
|
+
argTypes: {
|
|
12
|
+
color: {
|
|
13
|
+
options: [
|
|
14
|
+
'',
|
|
15
|
+
'primary',
|
|
16
|
+
'secondary',
|
|
17
|
+
'accent',
|
|
18
|
+
'ghost',
|
|
19
|
+
'info',
|
|
20
|
+
'success',
|
|
21
|
+
'warning',
|
|
22
|
+
'error'
|
|
23
|
+
],
|
|
24
|
+
control: { type: 'select' }
|
|
25
|
+
},
|
|
26
|
+
'data-errormessage-pattern-mismatch': {
|
|
27
|
+
control: { type: 'text' }
|
|
28
|
+
},
|
|
29
|
+
'data-errormessage-value-missing': {
|
|
30
|
+
control: { type: 'text' }
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const defaults = {
|
|
36
|
+
label: 'Label',
|
|
37
|
+
disabled: false,
|
|
38
|
+
digits: 6,
|
|
39
|
+
bordered: true,
|
|
40
|
+
size: 'md',
|
|
41
|
+
color: '',
|
|
42
|
+
'full-width': false,
|
|
43
|
+
required: false
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const StandardTemplate = (args) => (
|
|
47
|
+
<form
|
|
48
|
+
onSubmit={(e) => {
|
|
49
|
+
e.preventDefault();
|
|
50
|
+
}}
|
|
51
|
+
>
|
|
52
|
+
<Code {...args} />
|
|
53
|
+
<br />
|
|
54
|
+
<button type="submit">submit</button>
|
|
55
|
+
</form>
|
|
56
|
+
);
|
|
57
|
+
export const Standard = StandardTemplate.bind({});
|
|
58
|
+
Standard.args = {
|
|
59
|
+
...defaults
|
|
60
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Container } from '../src';
|
|
3
|
+
|
|
4
|
+
const StandardTemplate = (args) => (
|
|
5
|
+
<Container {...args}>
|
|
6
|
+
<button type="button">Click</button>
|
|
7
|
+
<button type="button">click</button>
|
|
8
|
+
</Container>
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
const OldProps = StandardTemplate.bind({});
|
|
12
|
+
OldProps.args = {
|
|
13
|
+
shadow: '2xl',
|
|
14
|
+
'border-radius': 'lg',
|
|
15
|
+
paddingX: '20px',
|
|
16
|
+
paddingY: '20px',
|
|
17
|
+
align: 'center',
|
|
18
|
+
background: '200',
|
|
19
|
+
direction: 'row',
|
|
20
|
+
width: '100%'
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const NewProps = StandardTemplate.bind({});
|
|
24
|
+
NewProps.args = {
|
|
25
|
+
shadow: '2xl',
|
|
26
|
+
'border-radius': 'lg',
|
|
27
|
+
paddingX: '20px',
|
|
28
|
+
paddingY: '20px',
|
|
29
|
+
'vertical-alignment': 'center',
|
|
30
|
+
'horizontal-alignment': 'center',
|
|
31
|
+
'space-between': '10px',
|
|
32
|
+
background: '200',
|
|
33
|
+
direction: 'row',
|
|
34
|
+
width: '100%'
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default {
|
|
38
|
+
title: 'WCUI/Container',
|
|
39
|
+
component: Container,
|
|
40
|
+
parameters: {
|
|
41
|
+
controls: { expanded: true }
|
|
42
|
+
},
|
|
43
|
+
argTypes: {
|
|
44
|
+
'border-radius': {
|
|
45
|
+
control: { type: 'radio' }
|
|
46
|
+
},
|
|
47
|
+
justify: {
|
|
48
|
+
control: { type: 'radio' }
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export { OldProps, NewProps };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Divider } from '../src';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'WCUI/Divider',
|
|
6
|
+
component: Divider,
|
|
7
|
+
parameters: {
|
|
8
|
+
controls: { expanded: true }
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const StandardTemplate = (args) => (
|
|
13
|
+
<div style={{ width: '400px' }}>
|
|
14
|
+
<Divider {...args} />
|
|
15
|
+
</div>
|
|
16
|
+
);
|
|
17
|
+
export const Standard = StandardTemplate.bind({});
|
|
18
|
+
Standard.args = {
|
|
19
|
+
children: 'label',
|
|
20
|
+
italic: false,
|
|
21
|
+
vertical: false,
|
|
22
|
+
variant: 'h3'
|
|
23
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { EmailField } from '../src/EmailField';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'WCUI/EmailField',
|
|
6
|
+
component: EmailField,
|
|
7
|
+
parameters: {
|
|
8
|
+
controls: { expanded: true }
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const defaults = {
|
|
13
|
+
label: 'Email Input',
|
|
14
|
+
placeholder: 'Enter your email',
|
|
15
|
+
disabled: false,
|
|
16
|
+
bordered: true,
|
|
17
|
+
'full-width': true,
|
|
18
|
+
required: false,
|
|
19
|
+
size: 'md',
|
|
20
|
+
'error-message': 'Enter a valid e-mail address'
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const StandardTemplate = (args) => (
|
|
24
|
+
<form
|
|
25
|
+
onSubmit={(e) => {
|
|
26
|
+
e.preventDefault();
|
|
27
|
+
}}
|
|
28
|
+
>
|
|
29
|
+
<EmailField {...args} />
|
|
30
|
+
<button type="submit">Submit</button>
|
|
31
|
+
</form>
|
|
32
|
+
);
|
|
33
|
+
export const Standard = StandardTemplate.bind({});
|
|
34
|
+
Standard.args = {
|
|
35
|
+
...defaults
|
|
36
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Image } from '../src';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'WCUI/Image',
|
|
6
|
+
component: Image,
|
|
7
|
+
parameters: {
|
|
8
|
+
controls: { expanded: true }
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const StandardTemplate = (args) => <Image {...args} />;
|
|
13
|
+
export const Standard = StandardTemplate.bind({});
|
|
14
|
+
Standard.args = {
|
|
15
|
+
src: 'https://joomisp.de/images/blog/joomisp-demo.jpg'
|
|
16
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Input } from '../src';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'WCUI/Input',
|
|
6
|
+
component: Input,
|
|
7
|
+
parameters: {
|
|
8
|
+
controls: { expanded: true }
|
|
9
|
+
},
|
|
10
|
+
argTypes: {}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const defaults = {
|
|
14
|
+
placeholder: 'Placeholder',
|
|
15
|
+
label: 'Label',
|
|
16
|
+
bordered: true,
|
|
17
|
+
size: 'md',
|
|
18
|
+
'full-width': false,
|
|
19
|
+
required: true,
|
|
20
|
+
'data-errormessage-value-missing': 'Required'
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const StandardTemplate = (args) => (
|
|
24
|
+
<form
|
|
25
|
+
onSubmit={(e) => {
|
|
26
|
+
e.preventDefault();
|
|
27
|
+
}}
|
|
28
|
+
>
|
|
29
|
+
<Input {...args} />
|
|
30
|
+
<button type="submit">Submit</button>
|
|
31
|
+
</form>
|
|
32
|
+
);
|
|
33
|
+
export const Text = StandardTemplate.bind({});
|
|
34
|
+
Text.args = {
|
|
35
|
+
...defaults
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const Email = StandardTemplate.bind({});
|
|
39
|
+
Email.args = {
|
|
40
|
+
...defaults,
|
|
41
|
+
placeholder: 'Enter your email',
|
|
42
|
+
label: 'Email',
|
|
43
|
+
type: 'email',
|
|
44
|
+
'data-errormessage-pattern-mismatch': 'Enter a valid e-mail address'
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const Password = StandardTemplate.bind({});
|
|
48
|
+
Password.args = {
|
|
49
|
+
...defaults,
|
|
50
|
+
placeholder: 'Enter your password',
|
|
51
|
+
label: 'Password',
|
|
52
|
+
type: 'password'
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const Numeric = StandardTemplate.bind({});
|
|
56
|
+
Numeric.args = {
|
|
57
|
+
...defaults,
|
|
58
|
+
placeholder: 'Enter number value',
|
|
59
|
+
label: 'Number Value',
|
|
60
|
+
type: 'number',
|
|
61
|
+
step: 'any',
|
|
62
|
+
'data-errormessage-pattern-mismatch': 'Must be a number'
|
|
63
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Link } from '../src';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'WCUI/Link',
|
|
6
|
+
component: Link,
|
|
7
|
+
parameters: {
|
|
8
|
+
controls: { expanded: true }
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const StandardTemplate = (args) => <Link {...args} />;
|
|
13
|
+
export const Standard = StandardTemplate.bind({});
|
|
14
|
+
Standard.args = {
|
|
15
|
+
children: 'Hello World',
|
|
16
|
+
italic: true,
|
|
17
|
+
variant: 'h3',
|
|
18
|
+
mode: 'primary',
|
|
19
|
+
'text-align': 'center',
|
|
20
|
+
'full-width': true
|
|
21
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/* eslint-disable import/exports-last */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Loader } from '../src';
|
|
4
|
+
|
|
5
|
+
const StandardTemplate = (args) => <Loader {...args} />;
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: 'WCUI/Loader',
|
|
9
|
+
component: Loader,
|
|
10
|
+
parameters: {
|
|
11
|
+
controls: { expanded: true }
|
|
12
|
+
},
|
|
13
|
+
argTypes: {
|
|
14
|
+
variant: {
|
|
15
|
+
options: ['linear', 'radial'],
|
|
16
|
+
control: { type: 'select' }
|
|
17
|
+
},
|
|
18
|
+
size: {
|
|
19
|
+
options: ['xs', 'sm', 'md', 'lg'],
|
|
20
|
+
control: { type: 'select' }
|
|
21
|
+
},
|
|
22
|
+
color: {
|
|
23
|
+
options: ['primary', 'secondary'],
|
|
24
|
+
control: { type: 'select' }
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const Standard = StandardTemplate.bind({});
|
|
30
|
+
Standard.args = {
|
|
31
|
+
variant: 'radial',
|
|
32
|
+
size: 'md',
|
|
33
|
+
color: 'primary'
|
|
34
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Logo } from '../src';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'WCUI/Logo',
|
|
6
|
+
component: Logo,
|
|
7
|
+
parameters: {
|
|
8
|
+
controls: { expanded: true }
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const StandardTemplate = (args) => <Logo {...args} />;
|
|
13
|
+
export const Standard = StandardTemplate.bind({});
|
|
14
|
+
Standard.args = {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { NewPassword } from '../src';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'WCUI/NewPassword',
|
|
6
|
+
component: NewPassword,
|
|
7
|
+
parameters: {
|
|
8
|
+
controls: { expanded: true }
|
|
9
|
+
},
|
|
10
|
+
argTypes: {
|
|
11
|
+
'data-errormessage-pattern-mismatch': {
|
|
12
|
+
control: { type: 'text' }
|
|
13
|
+
},
|
|
14
|
+
'data-errormessage-value-missing': {
|
|
15
|
+
control: { type: 'text' }
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const defaults = {
|
|
21
|
+
disabled: false,
|
|
22
|
+
bordered: true,
|
|
23
|
+
size: 'md',
|
|
24
|
+
'full-width': true,
|
|
25
|
+
name: 'standard',
|
|
26
|
+
isConfirm: true,
|
|
27
|
+
required: true,
|
|
28
|
+
passwordInputProps: {
|
|
29
|
+
label: 'Password',
|
|
30
|
+
placeholder: 'Password'
|
|
31
|
+
},
|
|
32
|
+
confirmInputProps: {
|
|
33
|
+
label: 'Confirm password',
|
|
34
|
+
placeholder: 'Confirm password'
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const StandardTemplate = (args) => (
|
|
39
|
+
<form
|
|
40
|
+
onSubmit={(e) => {
|
|
41
|
+
e.preventDefault();
|
|
42
|
+
}}
|
|
43
|
+
>
|
|
44
|
+
<NewPassword {...args} />
|
|
45
|
+
<button type="submit">submit</button>
|
|
46
|
+
</form>
|
|
47
|
+
);
|
|
48
|
+
export const Standard = StandardTemplate.bind({});
|
|
49
|
+
|
|
50
|
+
Standard.args = {
|
|
51
|
+
...defaults
|
|
52
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { NumberField } from '../src/NumberField';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'WCUI/NumberField',
|
|
6
|
+
component: NumberField,
|
|
7
|
+
parameters: {
|
|
8
|
+
controls: { expanded: true }
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const defaults = {
|
|
13
|
+
label: 'Label',
|
|
14
|
+
placeholder: 'Enter number value',
|
|
15
|
+
disabled: false,
|
|
16
|
+
bordered: true,
|
|
17
|
+
'full-width': false,
|
|
18
|
+
size: 'md',
|
|
19
|
+
required: false
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const StandardTemplate = (args) => (
|
|
23
|
+
<form
|
|
24
|
+
onSubmit={(e) => {
|
|
25
|
+
e.preventDefault();
|
|
26
|
+
}}
|
|
27
|
+
>
|
|
28
|
+
<NumberField {...args} />
|
|
29
|
+
<button type="submit">Submit</button>
|
|
30
|
+
</form>
|
|
31
|
+
);
|
|
32
|
+
export const Standard = StandardTemplate.bind({});
|
|
33
|
+
Standard.args = {
|
|
34
|
+
...defaults
|
|
35
|
+
};
|