@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.
Files changed (158) hide show
  1. package/.eslintrc +119 -0
  2. package/.github/actions/setup/action.yml +42 -0
  3. package/.github/workflows/ci.yml +105 -0
  4. package/.github/workflows/publish.yml +41 -0
  5. package/.github/workflows/release.yml +44 -0
  6. package/.husky/pre-commit +1 -0
  7. package/.prettierrc +8 -0
  8. package/.storybook/main.js +23 -0
  9. package/.storybook/manager.js +10 -0
  10. package/.storybook/preview-head.html +29 -0
  11. package/.storybook/preview.js +44 -0
  12. package/LICENSE +21 -0
  13. package/README.md +20 -0
  14. package/babel.config.js +7 -0
  15. package/dist/index.cjs.js +360 -0
  16. package/dist/index.d.ts +397 -0
  17. package/dist/index.esm.js +314 -0
  18. package/jest.config.js +33 -0
  19. package/jest.setup.js +2 -0
  20. package/package.json +110 -0
  21. package/renovate.json +4 -0
  22. package/rollup.config.mjs +47 -0
  23. package/src/Boolean/Boolean.tsx +24 -0
  24. package/src/Boolean/index.ts +1 -0
  25. package/src/Button/Button.tsx +49 -0
  26. package/src/Button/index.ts +1 -0
  27. package/src/Checkbox/Checkbox.tsx +16 -0
  28. package/src/Checkbox/index.ts +1 -0
  29. package/src/Code/Code.tsx +21 -0
  30. package/src/Code/index.ts +1 -0
  31. package/src/Container/Container.tsx +111 -0
  32. package/src/Container/index.ts +1 -0
  33. package/src/CssVarImage/CssVarImage.tsx +38 -0
  34. package/src/CssVarImage/index.ts +1 -0
  35. package/src/Divider/Divider.tsx +33 -0
  36. package/src/Divider/index.ts +1 -0
  37. package/src/EmailField/EmailField.tsx +20 -0
  38. package/src/EmailField/index.ts +1 -0
  39. package/src/Image/Image.tsx +32 -0
  40. package/src/Image/index.ts +1 -0
  41. package/src/Input/Input.tsx +27 -0
  42. package/src/Input/index.ts +1 -0
  43. package/src/Link/Link.tsx +33 -0
  44. package/src/Link/index.ts +1 -0
  45. package/src/Loader/Loader.tsx +40 -0
  46. package/src/Loader/index.ts +1 -0
  47. package/src/Logo/Logo.tsx +27 -0
  48. package/src/Logo/index.ts +1 -0
  49. package/src/NewPassword/NewPassword.tsx +25 -0
  50. package/src/NewPassword/index.ts +1 -0
  51. package/src/NumberField/NumberField.tsx +20 -0
  52. package/src/NumberField/index.ts +1 -0
  53. package/src/Password/Password.tsx +20 -0
  54. package/src/Password/index.ts +1 -0
  55. package/src/Phone/Phone.tsx +22 -0
  56. package/src/Phone/index.ts +1 -0
  57. package/src/Select/Select.tsx +29 -0
  58. package/src/Select/index.ts +1 -0
  59. package/src/Switch/Switch.tsx +21 -0
  60. package/src/Switch/index.ts +1 -0
  61. package/src/TOTPImage/TOTPImage.tsx +18 -0
  62. package/src/TOTPImage/index.ts +1 -0
  63. package/src/TOTPLink/TOTPLink.tsx +16 -0
  64. package/src/TOTPLink/index.ts +1 -0
  65. package/src/Text/Text.tsx +36 -0
  66. package/src/Text/index.ts +1 -0
  67. package/src/TextField/TextField.tsx +20 -0
  68. package/src/TextField/index.ts +1 -0
  69. package/src/Textarea/Textarea.tsx +20 -0
  70. package/src/Textarea/index.ts +1 -0
  71. package/src/icons/apple.tsx +14 -0
  72. package/src/icons/discord.tsx +14 -0
  73. package/src/icons/facebook.tsx +14 -0
  74. package/src/icons/fingerprint.tsx +14 -0
  75. package/src/icons/github.tsx +14 -0
  76. package/src/icons/gitlab.tsx +41 -0
  77. package/src/icons/google.tsx +29 -0
  78. package/src/icons/index.ts +11 -0
  79. package/src/icons/input-hidden.tsx +17 -0
  80. package/src/icons/input-visible.tsx +17 -0
  81. package/src/icons/linkedin.tsx +18 -0
  82. package/src/icons/microsoft.tsx +41 -0
  83. package/src/icons/passkey.tsx +16 -0
  84. package/src/icons/sso.tsx +14 -0
  85. package/src/index.ts +29 -0
  86. package/src/inputHelpers.ts +41 -0
  87. package/src/themeToCssVars/constants.ts +13 -0
  88. package/src/themeToCssVars/index.ts +153 -0
  89. package/src/themeToCssVars/types.ts +56 -0
  90. package/src/types.ts +52 -0
  91. package/src/utils.tsx +69 -0
  92. package/stories/Boolean.stories.jsx +37 -0
  93. package/stories/Button.stories.jsx +71 -0
  94. package/stories/Checkbox.stories.jsx +29 -0
  95. package/stories/Code.stories.jsx +60 -0
  96. package/stories/Container.stories.jsx +53 -0
  97. package/stories/Divider.stories.jsx +23 -0
  98. package/stories/EmailField.stories.jsx +36 -0
  99. package/stories/Image.stories.jsx +16 -0
  100. package/stories/Input.stories.jsx +63 -0
  101. package/stories/Link.stories.jsx +21 -0
  102. package/stories/Loader.stories.jsx +34 -0
  103. package/stories/Logo.stories.jsx +14 -0
  104. package/stories/NewPassword.stories.jsx +52 -0
  105. package/stories/NumberField.stories.jsx +35 -0
  106. package/stories/Password.stories.jsx +37 -0
  107. package/stories/Phone.stories.jsx +61 -0
  108. package/stories/Switch.stories.jsx +29 -0
  109. package/stories/TOTPImage.stories.jsx +22 -0
  110. package/stories/TOTPLink.stories.jsx +20 -0
  111. package/stories/Text.stories.jsx +35 -0
  112. package/stories/TextField.stories.jsx +39 -0
  113. package/stories/Textarea.stories.jsx +25 -0
  114. package/storybook-static/favicon.ico +0 -0
  115. package/test/__snapshots__/boolean.test.tsx.snap +47 -0
  116. package/test/__snapshots__/buttons.test.tsx.snap +843 -0
  117. package/test/__snapshots__/checkbox.test.tsx.snap +51 -0
  118. package/test/__snapshots__/code.test.tsx.snap +1184 -0
  119. package/test/__snapshots__/container.test.tsx.snap +218 -0
  120. package/test/__snapshots__/divider.test.tsx.snap +73 -0
  121. package/test/__snapshots__/image.test.tsx.snap +62 -0
  122. package/test/__snapshots__/input.test.tsx.snap +80 -0
  123. package/test/__snapshots__/link.test.tsx.snap +120 -0
  124. package/test/__snapshots__/loader.test.tsx.snap +53 -0
  125. package/test/__snapshots__/logo.test.tsx.snap +10 -0
  126. package/test/__snapshots__/newPassword.test.tsx.snap +69 -0
  127. package/test/__snapshots__/numeric-input.test.tsx.snap +21 -0
  128. package/test/__snapshots__/password.test.tsx.snap +26 -0
  129. package/test/__snapshots__/phone.test.tsx.snap +504 -0
  130. package/test/__snapshots__/switch.test.tsx.snap +51 -0
  131. package/test/__snapshots__/text.test.tsx.snap +89 -0
  132. package/test/__snapshots__/textarea.test.tsx.snap +73 -0
  133. package/test/__snapshots__/themeToCssVars.test.ts.snap +45 -0
  134. package/test/__snapshots__/totpImage.test.tsx.snap +10 -0
  135. package/test/__snapshots__/totpLink.test.tsx.snap +13 -0
  136. package/test/boolean.test.tsx +28 -0
  137. package/test/buttons.test.tsx +66 -0
  138. package/test/checkbox.test.tsx +67 -0
  139. package/test/code.test.tsx +182 -0
  140. package/test/container.test.tsx +91 -0
  141. package/test/divider.test.tsx +50 -0
  142. package/test/image.test.tsx +40 -0
  143. package/test/input.test.tsx +82 -0
  144. package/test/inputHelpers.test.tsx +58 -0
  145. package/test/link.test.tsx +71 -0
  146. package/test/loader.test.tsx +25 -0
  147. package/test/logo.test.tsx +10 -0
  148. package/test/newPassword.test.tsx +132 -0
  149. package/test/numeric-input.test.tsx +114 -0
  150. package/test/password.test.tsx +55 -0
  151. package/test/phone.test.tsx +158 -0
  152. package/test/switch.test.tsx +67 -0
  153. package/test/text.test.tsx +60 -0
  154. package/test/textarea.test.tsx +64 -0
  155. package/test/themeToCssVars.test.ts +82 -0
  156. package/test/totpImage.test.tsx +10 -0
  157. package/test/totpLink.test.tsx +10 -0
  158. 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
+ };