@bosonprotocol/react-kit 0.31.1 → 0.32.0-alpha.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.
Files changed (136) hide show
  1. package/dist/cjs/components/buttons/BaseButton.d.ts +27 -0
  2. package/dist/cjs/components/buttons/BaseButton.d.ts.map +1 -0
  3. package/dist/cjs/components/buttons/BaseButton.js +154 -0
  4. package/dist/cjs/components/buttons/BaseButton.js.map +1 -0
  5. package/dist/cjs/components/form/BaseInput.d.ts +17 -0
  6. package/dist/cjs/components/form/BaseInput.d.ts.map +1 -0
  7. package/dist/cjs/components/form/BaseInput.js +88 -0
  8. package/dist/cjs/components/form/BaseInput.js.map +1 -0
  9. package/dist/cjs/components/form/BaseTagsInput.d.ts +8 -0
  10. package/dist/cjs/components/form/BaseTagsInput.d.ts.map +1 -0
  11. package/dist/cjs/components/form/{TagsInput.js → BaseTagsInput.js} +24 -16
  12. package/dist/cjs/components/form/BaseTagsInput.js.map +1 -0
  13. package/dist/cjs/components/form/ClearButton.d.ts +14 -0
  14. package/dist/cjs/components/form/ClearButton.d.ts.map +1 -0
  15. package/dist/cjs/components/form/ClearButton.js +28 -0
  16. package/dist/cjs/components/form/ClearButton.js.map +1 -0
  17. package/dist/cjs/components/form/Field.styles.d.ts +45 -7
  18. package/dist/cjs/components/form/Field.styles.d.ts.map +1 -1
  19. package/dist/cjs/components/form/Field.styles.js +44 -36
  20. package/dist/cjs/components/form/Field.styles.js.map +1 -1
  21. package/dist/cjs/components/form/Input.d.ts +3 -2
  22. package/dist/cjs/components/form/Input.d.ts.map +1 -1
  23. package/dist/cjs/components/form/Input.js +37 -24
  24. package/dist/cjs/components/form/Input.js.map +1 -1
  25. package/dist/cjs/components/form/Phone.js +1 -1
  26. package/dist/cjs/components/form/Phone.js.map +1 -1
  27. package/dist/cjs/components/form/index.d.ts +3 -2
  28. package/dist/cjs/components/form/index.d.ts.map +1 -1
  29. package/dist/cjs/components/form/index.js +17 -3
  30. package/dist/cjs/components/form/index.js.map +1 -1
  31. package/dist/cjs/components/form/styles/{TagsInput.styles.d.ts → BaseTagsInput.styles.d.ts} +6 -2
  32. package/dist/cjs/components/form/styles/BaseTagsInput.styles.d.ts.map +1 -0
  33. package/dist/cjs/components/form/styles/BaseTagsInput.styles.js +76 -0
  34. package/dist/cjs/components/form/styles/BaseTagsInput.styles.js.map +1 -0
  35. package/dist/cjs/components/styles/GlobalStyle.d.ts +1 -14
  36. package/dist/cjs/components/styles/GlobalStyle.d.ts.map +1 -1
  37. package/dist/cjs/components/styles/GlobalStyle.js +14 -41
  38. package/dist/cjs/components/styles/GlobalStyle.js.map +1 -1
  39. package/dist/cjs/components/ui/ThemedButton.d.ts.map +1 -1
  40. package/dist/cjs/components/ui/ThemedButton.js +3 -97
  41. package/dist/cjs/components/ui/ThemedButton.js.map +1 -1
  42. package/dist/cjs/components/ui/styles.d.ts.map +1 -1
  43. package/dist/cjs/components/ui/styles.js +5 -2
  44. package/dist/cjs/components/ui/styles.js.map +1 -1
  45. package/dist/cjs/hooks/useCurrentSellers.js.map +1 -1
  46. package/dist/cjs/index.d.ts +2 -0
  47. package/dist/cjs/index.d.ts.map +1 -1
  48. package/dist/cjs/index.js +2 -0
  49. package/dist/cjs/index.js.map +1 -1
  50. package/dist/esm/components/buttons/BaseButton.d.ts +27 -0
  51. package/dist/esm/components/buttons/BaseButton.d.ts.map +1 -0
  52. package/dist/esm/components/buttons/BaseButton.js +107 -0
  53. package/dist/esm/components/buttons/BaseButton.js.map +1 -0
  54. package/dist/esm/components/form/BaseInput.d.ts +17 -0
  55. package/dist/esm/components/form/BaseInput.d.ts.map +1 -0
  56. package/dist/esm/components/form/BaseInput.js +47 -0
  57. package/dist/esm/components/form/BaseInput.js.map +1 -0
  58. package/dist/esm/components/form/BaseTagsInput.d.ts +8 -0
  59. package/dist/esm/components/form/BaseTagsInput.d.ts.map +1 -0
  60. package/dist/esm/components/form/{TagsInput.js → BaseTagsInput.js} +22 -17
  61. package/dist/esm/components/form/BaseTagsInput.js.map +1 -0
  62. package/dist/esm/components/form/ClearButton.d.ts +14 -0
  63. package/dist/esm/components/form/ClearButton.d.ts.map +1 -0
  64. package/dist/esm/components/form/ClearButton.js +22 -0
  65. package/dist/esm/components/form/ClearButton.js.map +1 -0
  66. package/dist/esm/components/form/Field.styles.d.ts +45 -7
  67. package/dist/esm/components/form/Field.styles.d.ts.map +1 -1
  68. package/dist/esm/components/form/Field.styles.js +44 -36
  69. package/dist/esm/components/form/Field.styles.js.map +1 -1
  70. package/dist/esm/components/form/Input.d.ts +3 -2
  71. package/dist/esm/components/form/Input.d.ts.map +1 -1
  72. package/dist/esm/components/form/Input.js +37 -12
  73. package/dist/esm/components/form/Input.js.map +1 -1
  74. package/dist/esm/components/form/Phone.js +1 -1
  75. package/dist/esm/components/form/Phone.js.map +1 -1
  76. package/dist/esm/components/form/index.d.ts +3 -2
  77. package/dist/esm/components/form/index.d.ts.map +1 -1
  78. package/dist/esm/components/form/index.js +2 -1
  79. package/dist/esm/components/form/index.js.map +1 -1
  80. package/dist/esm/components/form/styles/{TagsInput.styles.d.ts → BaseTagsInput.styles.d.ts} +6 -2
  81. package/dist/esm/components/form/styles/BaseTagsInput.styles.d.ts.map +1 -0
  82. package/dist/esm/components/form/styles/{TagsInput.styles.js → BaseTagsInput.styles.js} +14 -4
  83. package/dist/esm/components/form/styles/BaseTagsInput.styles.js.map +1 -0
  84. package/dist/esm/components/styles/GlobalStyle.d.ts +1 -14
  85. package/dist/esm/components/styles/GlobalStyle.d.ts.map +1 -1
  86. package/dist/esm/components/styles/GlobalStyle.js +14 -41
  87. package/dist/esm/components/styles/GlobalStyle.js.map +1 -1
  88. package/dist/esm/components/ui/ThemedButton.d.ts.map +1 -1
  89. package/dist/esm/components/ui/ThemedButton.js +4 -98
  90. package/dist/esm/components/ui/ThemedButton.js.map +1 -1
  91. package/dist/esm/components/ui/styles.d.ts.map +1 -1
  92. package/dist/esm/components/ui/styles.js +5 -2
  93. package/dist/esm/components/ui/styles.js.map +1 -1
  94. package/dist/esm/hooks/useCurrentSellers.js.map +1 -1
  95. package/dist/esm/index.d.ts +2 -0
  96. package/dist/esm/index.d.ts.map +1 -1
  97. package/dist/esm/index.js +2 -0
  98. package/dist/esm/index.js.map +1 -1
  99. package/package.json +2 -2
  100. package/src/components/buttons/BaseButton.tsx +181 -0
  101. package/src/components/form/BaseInput.tsx +88 -0
  102. package/src/components/form/{TagsInput.tsx → BaseTagsInput.tsx} +46 -24
  103. package/src/components/form/ClearButton.tsx +39 -0
  104. package/src/components/form/Field.styles.ts +83 -40
  105. package/src/components/form/Input.tsx +42 -21
  106. package/src/components/form/Phone.tsx +1 -1
  107. package/src/components/form/index.ts +3 -2
  108. package/src/components/form/styles/{TagsInput.styles.ts → BaseTagsInput.styles.ts} +18 -4
  109. package/src/components/styles/GlobalStyle.tsx +15 -71
  110. package/src/components/ui/ThemedButton.tsx +8 -145
  111. package/src/components/ui/styles.ts +5 -2
  112. package/src/hooks/useCurrentSellers.ts +8 -8
  113. package/src/index.tsx +2 -0
  114. package/src/stories/buttons/button.stories.tsx +84 -62
  115. package/src/stories/form/Input.stories.tsx +67 -0
  116. package/src/stories/ui/ThemedButton.stories.tsx +79 -52
  117. package/dist/cjs/components/form/TagsInput.d.ts +0 -4
  118. package/dist/cjs/components/form/TagsInput.d.ts.map +0 -1
  119. package/dist/cjs/components/form/TagsInput.js.map +0 -1
  120. package/dist/cjs/components/form/styles/TagsInput.styles.d.ts.map +0 -1
  121. package/dist/cjs/components/form/styles/TagsInput.styles.js +0 -46
  122. package/dist/cjs/components/form/styles/TagsInput.styles.js.map +0 -1
  123. package/dist/cjs/global.d.ts +0 -5
  124. package/dist/cjs/global.d.ts.map +0 -1
  125. package/dist/cjs/global.js +0 -44
  126. package/dist/cjs/global.js.map +0 -1
  127. package/dist/esm/components/form/TagsInput.d.ts +0 -4
  128. package/dist/esm/components/form/TagsInput.d.ts.map +0 -1
  129. package/dist/esm/components/form/TagsInput.js.map +0 -1
  130. package/dist/esm/components/form/styles/TagsInput.styles.d.ts.map +0 -1
  131. package/dist/esm/components/form/styles/TagsInput.styles.js.map +0 -1
  132. package/dist/esm/global.d.ts +0 -5
  133. package/dist/esm/global.d.ts.map +0 -1
  134. package/dist/esm/global.js +0 -41
  135. package/dist/esm/global.js.map +0 -1
  136. package/src/global.ts +0 -42
@@ -1,104 +1,11 @@
1
- import React, { ButtonHTMLAttributes, forwardRef, Fragment } from "react";
2
- import styled, { css, ThemeProvider } from "styled-components";
1
+ import React, { ButtonHTMLAttributes, forwardRef } from "react";
3
2
 
4
- import { zIndex } from "./zIndex";
5
- import { Tooltip } from "../tooltip/Tooltip";
6
- import * as Styles from "./styles";
7
- import { Typography } from "./Typography";
8
3
  import { theme } from "../../theme";
9
- import { Loading } from "../Loading";
4
+ import { BaseButton } from "../buttons/BaseButton";
10
5
  import { ButtonSize } from "./buttonSize";
11
6
 
12
7
  const colors = theme.colors.light;
13
8
 
14
- const BaseButton = styled.button<{
15
- size: IButton["size"];
16
- fill: IButton["fill"];
17
- }>`
18
- ${() => Styles.button};
19
- ${(props) => Styles[props.size as keyof typeof Styles]}
20
- border-style: solid;
21
- border-color: ${(props) => props.theme.borderColor || "transparent"};
22
- border-width: ${(props) => props.theme.borderWidth || 0}px;
23
- color: ${(props) => props.theme.color || "#000000"};
24
- background-color: ${(props) => props.theme.background || "transparent"};
25
- svg {
26
- stroke: ${(props) => props.theme.color || "#000000"};
27
- }
28
- ${(props) =>
29
- props.fill
30
- ? css`
31
- width: 100%;
32
- `
33
- : ""};
34
- ${(props) =>
35
- props.theme.hover &&
36
- css`
37
- &:hover:not(:disabled) {
38
- background-color: ${props.theme.hover.background};
39
- ${props.theme.hover.color &&
40
- css`
41
- color: ${props.theme.hover.color} !important;
42
- svg {
43
- fill: ${props.theme.hover.color} !important;
44
- line {
45
- stroke: ${props.theme.hover.color} !important;
46
- }
47
- polyline {
48
- stroke: ${props.theme.hover.color} !important;
49
- }
50
- path {
51
- stroke: ${props.theme.hover.color} !important;
52
- }
53
- }
54
- `};
55
- ${props.theme.hover.borderColor &&
56
- css`
57
- border-color: ${props.theme.hover.borderColor};
58
- `};
59
- }
60
- `}
61
- ${(props) =>
62
- props.theme.padding
63
- ? css`
64
- padding: ${props.theme.padding} !important;
65
- `
66
- : ""}
67
-
68
- ${(props) =>
69
- props.theme.disabled
70
- ? css`
71
- &:disabled {
72
- background-color: ${props.theme.disabled.background ||
73
- "transparent"};
74
- color: ${props.theme.disabled.color || colors.darkGrey};
75
- border-color: transparent;
76
- cursor: not-allowed;
77
- opacity: 0.5;
78
- }
79
- `
80
- : css`
81
- &:disabled {
82
- background-color: ${colors.lightGrey};
83
- color: ${colors.darkGrey};
84
- border-color: transparent;
85
- cursor: not-allowed;
86
- opacity: 0.5;
87
- }
88
- `};
89
- `;
90
-
91
- const ChildWrapperButton = styled.div`
92
- display: flex;
93
- align-items: center;
94
- justify-content: center;
95
- gap: 12px;
96
- position: relative;
97
- z-index: ${zIndex.Button};
98
-
99
- ${() => Styles.buttonText};
100
- `;
101
-
102
9
  const allThemes = ({ withBosonStyle }: { withBosonStyle?: boolean }) => {
103
10
  return {
104
11
  primary: {
@@ -325,57 +232,13 @@ export type IButton = ButtonHTMLAttributes<HTMLButtonElement> & {
325
232
  };
326
233
 
327
234
  const ThemedButton = forwardRef<HTMLButtonElement, IButton>(
328
- (
329
- {
330
- children,
331
- onClick,
332
- size = "regular",
333
- themeVal = "primary",
334
- type = "button",
335
- step = 0,
336
- fill = false,
337
- isLoading = false,
338
- tooltip = "",
339
- withBosonStyle = false,
340
- ...rest
341
- },
342
- ref
343
- ) => {
344
- const Wrapper = tooltip !== "" && rest?.disabled ? Tooltip : Fragment;
345
- const wrapperParams =
346
- tooltip !== "" && rest?.disabled ? { wrap: false, content: tooltip } : {};
235
+ ({ themeVal = "primary", withBosonStyle = false, ...rest }, ref) => {
347
236
  return (
348
- <>
349
- {/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}
350
- {/* @ts-ignore */}
351
- <ThemeProvider theme={allThemes({ withBosonStyle })[themeVal]}>
352
- {/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}
353
- {/* @ts-ignore */}
354
- <Wrapper {...wrapperParams}>
355
- <BaseButton
356
- onClick={onClick}
357
- type={type}
358
- size={size}
359
- fill={fill ? fill : undefined}
360
- {...rest}
361
- ref={ref}
362
- >
363
- {isLoading ? (
364
- <Loading />
365
- ) : (
366
- <ChildWrapperButton data-child-wrapper-button>
367
- {children}
368
- {step !== 0 && (
369
- <Typography>
370
- <small>Step {step}</small>
371
- </Typography>
372
- )}
373
- </ChildWrapperButton>
374
- )}
375
- </BaseButton>
376
- </Wrapper>
377
- </ThemeProvider>
378
- </>
237
+ <BaseButton
238
+ {...rest}
239
+ ref={ref}
240
+ theme={allThemes({ withBosonStyle })[themeVal]}
241
+ />
379
242
  );
380
243
  }
381
244
  );
@@ -33,8 +33,11 @@ export const clamp = css`
33
33
  -webkit-box-orient: vertical;
34
34
  `;
35
35
  export const boxShadow = css`
36
- box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.05), 0px 0px 8px rgba(0, 0, 0, 0.05),
37
- 0px 0px 16px rgba(0, 0, 0, 0.05), 0px 0px 32px rgba(0, 0, 0, 0.05);
36
+ box-shadow:
37
+ 0px 0px 4px rgba(0, 0, 0, 0.05),
38
+ 0px 0px 8px rgba(0, 0, 0, 0.05),
39
+ 0px 0px 16px rgba(0, 0, 0, 0.05),
40
+ 0px 0px 32px rgba(0, 0, 0, 0.05);
38
41
  `;
39
42
 
40
43
  export const text = css`
@@ -259,15 +259,15 @@ export function useCurrentSellers(
259
259
  const sellerType: string[] | string[][] = resultById?.data
260
260
  ? resultById.data.map((d) => Object.keys(d))
261
261
  : resultByLensId?.data
262
- ? Object.keys(resultByLensId.data)
263
- : resultByAddress?.data?.sellerType || [];
262
+ ? Object.keys(resultByLensId.data)
263
+ : resultByAddress?.data?.sellerType || [];
264
264
 
265
265
  const sellerIdsToQuery: string[] =
266
266
  sellerAddressType === "SELLER_IDS"
267
267
  ? (sellerAddress as string[])
268
268
  : sellerAddressType === "LENS_TOKEN_ID" && resultByLensId?.data?.sellerId
269
- ? [resultByLensId?.data.sellerId]
270
- : [];
269
+ ? [resultByLensId?.data.sellerId]
270
+ : [];
271
271
  const enableSellerById = !!sellerIdsToQuery?.length;
272
272
  const { data: sellers2, refetch: refetchFetchSellers } = fetchSellers(
273
273
  sellerIdsToQuery,
@@ -360,10 +360,10 @@ export function useCurrentSellers(
360
360
  resultByAddress.data
361
361
  ? resultByAddress.data.sellers.map((seller) => seller.id)
362
362
  : sellerAddressType === "SELLER_IDS"
363
- ? Array.isArray(sellerAddress)
364
- ? sellerAddress
365
- : [sellerAddress]
366
- : []
363
+ ? Array.isArray(sellerAddress)
364
+ ? sellerAddress
365
+ : [sellerAddress]
366
+ : []
367
367
  ).filter((sellerId) => !!sellerId) as string[];
368
368
  }, [resultByAddress.data, sellerAddress, sellerAddressType]);
369
369
  return {
package/src/index.tsx CHANGED
@@ -6,6 +6,7 @@ export { default as ThemedButton, IButton } from "./components/ui/ThemedButton";
6
6
  export * from "./components/ui/zIndex";
7
7
  export * from "./components/ui/buttonSize";
8
8
  export * from "./components/buttons/Button";
9
+ export * from "./components/buttons/BaseButton";
9
10
  export * from "./components/buttons/CommitButtonView";
10
11
  export * from "./components/cta/exchange/BatchCompleteButton";
11
12
  export * from "./components/cta/exchange/CancelButton";
@@ -58,6 +59,7 @@ export * from "./components/ui/Grid";
58
59
  export * from "./components/ui/GridContainer";
59
60
  export * from "./components/ui/Typography";
60
61
  export * from "./components/ui/MuteButton";
62
+ export * from "./components/form";
61
63
  export * from "./lib/magicLink/logout";
62
64
  export * from "./lib/magicLink/provider";
63
65
  export * from "./lib/const/networks";
@@ -1,88 +1,110 @@
1
- import React from "react";
2
- import { ComponentStory, ComponentMeta } from "@storybook/react";
3
-
1
+ import { fn } from "@storybook/test";
4
2
  import { Button } from "../../components/buttons/Button";
3
+ import React from "react";
4
+ import { Meta } from "@storybook/react";
5
5
 
6
6
  // More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
7
7
  export default {
8
8
  title: "Visual Components/Buttons/Button",
9
- component: Button
10
- } as ComponentMeta<typeof Button>;
9
+ component: Button,
10
+ parameters: {
11
+ // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
12
+ layout: "centered"
13
+ },
14
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
15
+ tags: ["autodocs"],
16
+ args: { onClick: fn() },
17
+ argTypes: {
18
+ disabled: { control: "boolean" },
19
+ size: {
20
+ control: "select",
21
+ options: ["small", "regular", "large"]
22
+ },
23
+ children: { control: "text" },
24
+ tooltip: { control: "text" }
25
+ },
26
+ decorators: [
27
+ (Story) => {
28
+ return <Story />;
29
+ }
30
+ ]
31
+ } satisfies Meta<typeof Button>;
11
32
 
12
33
  const BASE_ARGS = {
13
34
  children: "Button Text",
14
- // eslint-disable-next-line @typescript-eslint/no-empty-function
15
- onClick: () => {},
16
- size: "regular"
35
+ size: "regular",
36
+ tooltip: "tooltip shown when disabled only"
17
37
  } as const;
18
- // More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
19
- const Template: ComponentStory<typeof Button> = (args) => (
20
- <Button {...BASE_ARGS} {...args} />
21
- );
22
-
23
- export const PrimaryFill: ComponentStory<typeof Button> = Template.bind({});
24
-
25
- export const PrimaryInverted: ComponentStory<typeof Button> = Template.bind({});
26
-
27
- export const SecondaryFill: ComponentStory<typeof Button> = Template.bind({});
28
-
29
- export const SecondaryInverted: ComponentStory<typeof Button> = Template.bind(
30
- {}
31
- );
32
-
33
- export const AccentFill: ComponentStory<typeof Button> = Template.bind({});
34
-
35
- export const AccentInverted: ComponentStory<typeof Button> = Template.bind({});
36
-
37
- export const Disabled: ComponentStory<typeof Button> = Template.bind({});
38
-
39
- export const Loading: ComponentStory<typeof Button> = Template.bind({});
40
38
 
41
39
  // More on args: https://storybook.js.org/docs/react/writing-stories/args
42
- PrimaryFill.args = {
43
- disabled: false,
44
- loading: false,
45
- variant: "primaryFill"
40
+ export const PrimaryFill = {
41
+ args: {
42
+ ...BASE_ARGS,
43
+ disabled: false,
44
+ loading: false,
45
+ variant: "primaryFill"
46
+ }
46
47
  };
47
48
 
48
- PrimaryInverted.args = {
49
- disabled: false,
50
- loading: false,
51
- variant: "primaryInverted"
49
+ export const PrimaryInverted = {
50
+ args: {
51
+ ...BASE_ARGS,
52
+ disabled: false,
53
+ loading: false,
54
+ variant: "primaryInverted"
55
+ }
52
56
  };
53
57
 
54
- SecondaryFill.args = {
55
- disabled: false,
56
- loading: false,
57
- variant: "secondaryFill"
58
+ export const SecondaryFill = {
59
+ args: {
60
+ ...BASE_ARGS,
61
+ disabled: false,
62
+ loading: false,
63
+ variant: "secondaryFill"
64
+ }
58
65
  };
59
66
 
60
- SecondaryInverted.args = {
61
- disabled: false,
62
- loading: false,
63
- variant: "secondaryInverted"
67
+ export const SecondaryInverted = {
68
+ args: {
69
+ ...BASE_ARGS,
70
+ disabled: false,
71
+ loading: false,
72
+ variant: "secondaryInverted"
73
+ }
64
74
  };
65
75
 
66
- AccentFill.args = {
67
- disabled: false,
68
- loading: false,
69
- variant: "accentFill"
76
+ export const AccentFill = {
77
+ args: {
78
+ ...BASE_ARGS,
79
+ disabled: false,
80
+ loading: false,
81
+ variant: "accentFill"
82
+ }
70
83
  };
71
84
 
72
- AccentInverted.args = {
73
- disabled: false,
74
- loading: false,
75
- variant: "accentInverted"
85
+ export const AccentInverted = {
86
+ args: {
87
+ ...BASE_ARGS,
88
+ disabled: false,
89
+ loading: false,
90
+ variant: "accentInverted"
91
+ }
76
92
  };
77
93
 
78
- Disabled.args = {
79
- disabled: true,
80
- loading: false,
81
- variant: "primaryFill"
94
+ export const Disabled = {
95
+ args: {
96
+ ...BASE_ARGS,
97
+ disabled: true,
98
+ loading: false,
99
+ variant: "primaryFill"
100
+ }
82
101
  };
83
102
 
84
- Loading.args = {
85
- disabled: false,
86
- loading: true,
87
- variant: "primaryFill"
103
+ export const Loading = {
104
+ args: {
105
+ ...BASE_ARGS,
106
+ disabled: false,
107
+ loading: true,
108
+ variant: "primaryFill"
109
+ }
88
110
  };
@@ -0,0 +1,67 @@
1
+ import React from "react";
2
+ import { Input } from "../../components/form";
3
+ import { Formik } from "formik";
4
+ import type { Meta } from "@storybook/react";
5
+ import { fn } from "@storybook/test";
6
+ const inputWithErrors = "With error";
7
+ const defaultHeightSize = "regular";
8
+ const inputName = "test";
9
+ // More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
10
+ export default {
11
+ title: "Visual Components/Inputs/Input",
12
+ component: Input,
13
+ parameters: {
14
+ // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
15
+ layout: "centered"
16
+ },
17
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
18
+ tags: ["autodocs"],
19
+ // More on argTypes: https://storybook.js.org/docs/api/argtypes
20
+ argTypes: {
21
+ disabled: { control: "boolean" },
22
+ heightSize: {
23
+ control: "select",
24
+ options: ["small", "regular", "large"]
25
+ },
26
+ isClearable: { control: "boolean" }
27
+ },
28
+ // Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
29
+ args: { onClick: fn() },
30
+ decorators: [
31
+ (Story, { name }) => {
32
+ return (
33
+ <Formik<{ [inputName]: unknown }>
34
+ onSubmit={() => {
35
+ //
36
+ }}
37
+ initialErrors={
38
+ name === inputWithErrors
39
+ ? { [inputName]: "Input error before typing!" }
40
+ : {}
41
+ }
42
+ initialValues={{ [inputName]: "" }}
43
+ initialTouched={{ [inputName]: true }}
44
+ >
45
+ <Story />
46
+ </Formik>
47
+ );
48
+ }
49
+ ] satisfies Meta<typeof Input>["decorators"]
50
+ } satisfies Meta<typeof Input>;
51
+
52
+ export const Simple = {
53
+ args: {
54
+ name: inputName,
55
+ placeholder: "this is a placeholder",
56
+ heightSize: defaultHeightSize
57
+ }
58
+ };
59
+
60
+ export const InputWithError = {
61
+ name: "With error",
62
+ args: {
63
+ name: inputName,
64
+ placeholder: "this is a placeholder",
65
+ heightSize: defaultHeightSize
66
+ }
67
+ };
@@ -1,75 +1,102 @@
1
- import { ComponentStory, ComponentMeta } from "@storybook/react";
1
+ import { Meta } from "@storybook/react";
2
2
 
3
- import ThemedButton, { IButton } from "../../components/ui/ThemedButton";
4
- import React from "react";
3
+ import { fn } from "@storybook/test";
5
4
  import { CaretDown } from "phosphor-react";
5
+ import React from "react";
6
+ import ThemedButton from "../../components/ui/ThemedButton";
6
7
 
7
8
  // More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
8
9
  export default {
9
- title: "Visual Components/UI/ThemedButton",
10
- component: ThemedButton
11
- } as ComponentMeta<typeof ThemedButton>;
10
+ title: "Visual Components/Buttons/ThemedButton",
11
+ component: ThemedButton,
12
+ parameters: {
13
+ // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
14
+ layout: "centered"
15
+ },
16
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
17
+ tags: ["autodocs"],
18
+ args: { onClick: fn() },
19
+ argTypes: {
20
+ disabled: { control: "boolean" },
21
+ size: {
22
+ control: "select",
23
+ options: ["small", "regular", "large"]
24
+ },
25
+ children: {
26
+ table: {
27
+ disable: true
28
+ }
29
+ },
30
+ onClick: {
31
+ table: {
32
+ disable: true
33
+ }
34
+ },
35
+ tooltip: { control: "text" }
36
+ },
37
+ decorators: [
38
+ (Story) => {
39
+ return <Story />;
40
+ }
41
+ ]
42
+ } satisfies Meta<typeof ThemedButton>;
12
43
 
13
- const BASE_ARGS: Pick<IButton, "onClick" | "size" | "children"> = {
44
+ const BASE_ARGS = {
14
45
  children: (
15
46
  <>
16
47
  Button Text <CaretDown size={16} />
17
48
  </>
18
49
  ),
19
- // eslint-disable-next-line @typescript-eslint/no-empty-function
20
- onClick: () => {},
21
50
  size: "regular"
22
- };
23
- // More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
24
- const Template: ComponentStory<typeof ThemedButton> = (args) => (
25
- <ThemedButton {...BASE_ARGS} {...args} />
26
- );
27
-
28
- export const Primary: ComponentStory<typeof ThemedButton> = Template.bind({});
29
-
30
- export const BosonPrimary: ComponentStory<typeof ThemedButton> = Template.bind(
31
- {}
32
- );
33
-
34
- export const Secondary: ComponentStory<typeof ThemedButton> = Template.bind({});
35
- export const BosonSecondary: ComponentStory<typeof ThemedButton> =
36
- Template.bind({});
37
- export const AccentFiil: ComponentStory<typeof ThemedButton> = Template.bind(
38
- {}
39
- );
51
+ } as const;
40
52
 
41
53
  // More on args: https://storybook.js.org/docs/react/writing-stories/args
42
- Primary.args = {
43
- disabled: false,
44
- isLoading: false,
45
- theme: "primary",
46
- withBosonStyle: false
54
+ export const Primary = {
55
+ args: {
56
+ ...BASE_ARGS,
57
+ disabled: false,
58
+ isLoading: false,
59
+ themeVal: "primary",
60
+ withBosonStyle: false
61
+ }
47
62
  };
48
63
 
49
- BosonPrimary.args = {
50
- disabled: false,
51
- isLoading: false,
52
- theme: "bosonPrimary",
53
- withBosonStyle: true
64
+ export const BosonPrimary = {
65
+ args: {
66
+ ...BASE_ARGS,
67
+ disabled: false,
68
+ isLoading: false,
69
+ themeVal: "bosonPrimary",
70
+ withBosonStyle: true
71
+ }
54
72
  };
55
73
 
56
- Secondary.args = {
57
- disabled: false,
58
- isLoading: false,
59
- theme: "secondary",
60
- withBosonStyle: false
74
+ export const Secondary = {
75
+ args: {
76
+ ...BASE_ARGS,
77
+ disabled: false,
78
+ isLoading: false,
79
+ themeVal: "secondary",
80
+ withBosonStyle: false
81
+ }
61
82
  };
62
83
 
63
- BosonSecondary.args = {
64
- disabled: false,
65
- isLoading: false,
66
- theme: "secondary",
67
- withBosonStyle: true
84
+ export const BosonSecondary = {
85
+ args: {
86
+ ...BASE_ARGS,
87
+ disabled: false,
88
+ isLoading: false,
89
+ themeVal: "secondary",
90
+ withBosonStyle: true
91
+ }
68
92
  };
69
93
 
70
- AccentFiil.args = {
71
- disabled: false,
72
- isLoading: false,
73
- theme: "accentFill",
74
- withBosonStyle: true
94
+ export const AccentFiil = {
95
+ args: {
96
+ ...BASE_ARGS,
97
+ disabled: false,
98
+ isLoading: false,
99
+ themeVal: "accentFill",
100
+ withBosonStyle: true
101
+ }
75
102
  };
@@ -1,4 +0,0 @@
1
- import { TagsProps } from "./types";
2
- declare const TagsInput: ({ name, placeholder, onAddTag, onRemoveTag, compareTags, transform, label }: TagsProps) => JSX.Element;
3
- export default TagsInput;
4
- //# sourceMappingURL=TagsInput.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TagsInput.d.ts","sourceRoot":"","sources":["../../../../src/components/form/TagsInput.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,QAAA,MAAM,SAAS,gFASZ,SAAS,gBA6EX,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"TagsInput.js","sourceRoot":"","sources":["../../../../src/components/form/TagsInput.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAAuD;AACvD,mCAAoD;AACpD,mDAA2C;AAC3C,+CAAyC;AAEzC,qCAAkC;AAClC,iDAA8C;AAC9C,oDAA4B;AAC5B,iDAA4C;AAC5C,gEAKmC;AAGnC,MAAM,SAAS,GAAG,CAAC,EACjB,IAAI,EACJ,WAAW,EACX,QAAQ,EACR,WAAW,EACX,WAAW,GAAG,CAAC,IAAY,EAAE,IAAY,EAAE,EAAE,CAC3C,IAAI,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,WAAW,EAAE,EAC3C,SAAS,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,EAChC,KAAK,EACK,EAAE,EAAE;IACd,MAAM,EAAE,YAAY,EAA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E;YACA,IAAI,CAAC,GAAG,CAAC,CAAC,GAAW,EAAE,KAAa,EAAE,EAAE,CAAC,CACxC,8BAAC,6BAAU,IAAC,GAAG,EAAE,gBAAgB,GAAG,EAAE;gBACpC,wCAAM,SAAS,EAAC,MAAM,IAAE,GAAG,CAAQ;gBACnC,8BAAC,wBAAK,IAAC,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,aAAiB,CAC5C,CACd,CAAC,CACW;QACf,8BAAC,eAAK,IAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,GAAI;QAAC,GAAG,CAC1D,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"TagsInput.styles.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/styles/TagsInput.styles.ts"],"names":[],"mappings":";AAKA,eAAO,MAAM,YAAY,gNAQxB,CAAC;AAEF,eAAO,MAAM,MAAM,gNAWlB,CAAC;AACF,eAAO,MAAM,UAAU,gNAItB,CAAC;AAEF,eAAO,MAAM,KAAK,kNASjB,CAAC"}