Browse Source

Fix storybook

Fix the controls for each story in the storybook.
master
TheoryOfNekomata 1 year ago
parent
commit
94707e1a6b
33 changed files with 656 additions and 49 deletions
  1. +1
    -1
      categories/web/action/react/src/components/ActionButton/ActionButton.stories.tsx
  2. +1
    -1
      categories/web/blob/react/src/components/FileSelectBox/FileSelectBox.stories.tsx
  3. +19
    -1
      categories/web/choice/react/src/components/ComboBox/ComboBox.stories.tsx
  4. +19
    -0
      categories/web/choice/react/src/components/DropdownSelect/DropdownSelect.stories.tsx
  5. +19
    -0
      categories/web/choice/react/src/components/MenuSelect/MenuSelect.stories.tsx
  6. +31
    -3
      categories/web/choice/react/src/components/RadioButton/RadioButton.stories.tsx
  7. +4
    -2
      categories/web/choice/react/src/components/RadioButton/index.tsx
  8. +17
    -3
      categories/web/choice/react/src/components/RadioTickBox/RadioTickBox.stories.tsx
  9. +25
    -0
      categories/web/formatted/react/src/components/EmailInput/EmailInput.stories.tsx
  10. +34
    -0
      categories/web/formatted/react/src/components/PatternTextInput/PatternTextInput.stories.tsx
  11. +25
    -0
      categories/web/formatted/react/src/components/PhoneNumberInput/PhoneNumberInput.stories.tsx
  12. +25
    -0
      categories/web/formatted/react/src/components/UrlInput/UrlInput.stories.tsx
  13. +30
    -0
      categories/web/freeform/react/src/components/MaskedTextInput/MaskedTextInput.stories.tsx
  14. +25
    -0
      categories/web/freeform/react/src/components/MultilineTextInput/MultilineTextInput.stories.tsx
  15. +42
    -0
      categories/web/freeform/react/src/components/TextInput/TextInput.stories.tsx
  16. +7
    -1
      categories/web/information/react/src/components/Badge/Badge.stories.tsx
  17. +1
    -1
      categories/web/information/react/src/components/Badge/index.tsx
  18. +32
    -2
      categories/web/multichoice/react/src/components/MenuMultiSelect/MenuMultiSelect.stories.tsx
  19. +37
    -1
      categories/web/multichoice/react/src/components/TagInput/TagInput.stories.tsx
  20. +3
    -1
      categories/web/multichoice/react/src/components/TagInput/index.tsx
  21. +33
    -3
      categories/web/multichoice/react/src/components/ToggleButton/ToggleButton.stories.tsx
  22. +4
    -2
      categories/web/multichoice/react/src/components/ToggleButton/index.tsx
  23. +29
    -3
      categories/web/multichoice/react/src/components/ToggleSwitch/ToggleSwitch.stories.tsx
  24. +1
    -1
      categories/web/multichoice/react/src/components/ToggleSwitch/index.tsx
  25. +21
    -3
      categories/web/multichoice/react/src/components/ToggleTickBox/ToggleTickBox.stories.tsx
  26. +18
    -7
      categories/web/navigation/react/src/components/LinkButton/LinkButton.stories.tsx
  27. +23
    -0
      categories/web/number/react/src/components/NumberSpinner/NumberSpinner.stories.tsx
  28. +8
    -7
      categories/web/number/react/src/components/NumberSpinner/index.tsx
  29. +35
    -3
      categories/web/number/react/src/components/Slider/Slider.stories.tsx
  30. +4
    -2
      categories/web/number/react/src/components/Slider/index.tsx
  31. +23
    -0
      categories/web/temporal/react/src/components/DateDropdown/DateDropdown.stories.tsx
  32. +20
    -0
      categories/web/temporal/react/src/components/TimeSpinner/TimeSpinner.stories.tsx
  33. +40
    -1
      storybook/react/tailwind.config.ts

+ 1
- 1
categories/web/action/react/src/components/ActionButton/ActionButton.stories.tsx View File

@@ -41,7 +41,7 @@ const meta: Meta<typeof Component> = {
...(Component.defaultProps ?? {}), ...(Component.defaultProps ?? {}),
subtext: 'Subtext', subtext: 'Subtext',
badge: '1', badge: '1',
children: 'Button',
children: Component.displayName,
}, },
}; };




+ 1
- 1
categories/web/blob/react/src/components/FileSelectBox/FileSelectBox.stories.tsx View File

@@ -25,7 +25,7 @@ const meta: Meta<typeof Component> = {
}, },
args: { args: {
...(Component.defaultProps ?? {}), ...(Component.defaultProps ?? {}),
label: 'ファイル選択',
label: Component.displayName,
hint: 'ファイルを選択してください。', hint: 'ファイルを選択してください。',
}, },
}; };


+ 19
- 1
categories/web/choice/react/src/components/ComboBox/ComboBox.stories.tsx View File

@@ -1,5 +1,6 @@
import * as React from 'react'; import * as React from 'react';
import type { Meta } from '@storybook/react'; import type { Meta } from '@storybook/react';
import { TextControl } from '@tesseract-design/web-base';
import { ComboBox as Component, ComboBoxProps as Props } from '.'; import { ComboBox as Component, ComboBoxProps as Props } from '.';


const meta: Meta<typeof Component> = { const meta: Meta<typeof Component> = {
@@ -11,6 +12,18 @@ const meta: Meta<typeof Component> = {
hint: { hint: {
control: { type: 'text' }, control: { type: 'text' },
}, },
variant: {
control: {
type: 'select',
},
options: TextControl.AVAILABLE_VARIANTS,
},
size: {
control: {
type: 'select',
},
options: TextControl.AVAILABLE_SIZES,
},
indicator: { indicator: {
control: { type: 'text' }, control: { type: 'text' },
}, },
@@ -29,7 +42,12 @@ const meta: Meta<typeof Component> = {
}, },
args: { args: {
...(Component.defaultProps ?? {}), ...(Component.defaultProps ?? {}),
label: 'ComboBox',
label: Component.displayName,
children: `Chocolate
Vanilla
Mango
Strawberry
`,
}, },
}; };




+ 19
- 0
categories/web/choice/react/src/components/DropdownSelect/DropdownSelect.stories.tsx View File

@@ -1,5 +1,6 @@
import * as React from 'react'; import * as React from 'react';
import type { Meta } from '@storybook/react'; import type { Meta } from '@storybook/react';
import { TextControl } from '@tesseract-design/web-base';
import { DropdownSelect as Component, DropdownSelectProps as Props } from '.'; import { DropdownSelect as Component, DropdownSelectProps as Props } from '.';


const meta: Meta<typeof Component> = { const meta: Meta<typeof Component> = {
@@ -14,6 +15,18 @@ const meta: Meta<typeof Component> = {
children: { children: {
control: { type: 'text' }, control: { type: 'text' },
}, },
variant: {
control: {
type: 'select',
},
options: TextControl.AVAILABLE_VARIANTS,
},
size: {
control: {
type: 'select',
},
options: TextControl.AVAILABLE_SIZES,
},
onChange: { onChange: {
table: { table: {
disable: true, disable: true,
@@ -23,6 +36,12 @@ const meta: Meta<typeof Component> = {
}, },
args: { args: {
...(Component.defaultProps ?? {}), ...(Component.defaultProps ?? {}),
label: Component.displayName,
children: `Chocolate
Vanilla
Mango
Strawberry
`,
}, },
}; };




+ 19
- 0
categories/web/choice/react/src/components/MenuSelect/MenuSelect.stories.tsx View File

@@ -1,5 +1,6 @@
import * as React from 'react'; import * as React from 'react';
import type {Meta} from '@storybook/react'; import type {Meta} from '@storybook/react';
import {TextControl} from '@tesseract-design/web-base';
import {MenuSelect as Component, MenuSelectProps as Props} from '.'; import {MenuSelect as Component, MenuSelectProps as Props} from '.';


const meta: Meta<typeof Component> = { const meta: Meta<typeof Component> = {
@@ -11,6 +12,18 @@ const meta: Meta<typeof Component> = {
hint: { hint: {
control: { type: 'text' }, control: { type: 'text' },
}, },
variant: {
control: {
type: 'select',
},
options: TextControl.AVAILABLE_VARIANTS,
},
size: {
control: {
type: 'select',
},
options: TextControl.AVAILABLE_SIZES,
},
indicator: { indicator: {
control: { type: 'text' }, control: { type: 'text' },
}, },
@@ -26,6 +39,12 @@ const meta: Meta<typeof Component> = {
}, },
args: { args: {
...(Component.defaultProps ?? {}), ...(Component.defaultProps ?? {}),
label: Component.displayName,
children: `Chocolate
Vanilla
Mango
Strawberry
`,
}, },
}; };




+ 31
- 3
categories/web/choice/react/src/components/RadioButton/RadioButton.stories.tsx View File

@@ -1,10 +1,29 @@
import * as React from 'react'; import * as React from 'react';
import type { Meta } from '@storybook/react'; import type { Meta } from '@storybook/react';
import { Button } from '@tesseract-design/web-base';
import { RadioButton as Component, RadioButtonProps as Props } from '.'; import { RadioButton as Component, RadioButtonProps as Props } from '.';


const LENGTH = 3 as const;

const meta: Meta<typeof Component> = { const meta: Meta<typeof Component> = {
component: Component, component: Component,
argTypes: { argTypes: {
badge: {
control: {
type: 'text',
},
},
variant: {
control: { type: 'select' },
options: Button.AVAILABLE_VARIANTS,
},
size: {
control: { type: 'select' },
options: Button.AVAILABLE_SIZES,
},
subtext: {
control: { type: 'text' },
},
onChange: { onChange: {
table: { table: {
disable: true, disable: true,
@@ -18,9 +37,18 @@ const meta: Meta<typeof Component> = {
}; };


export const RadioButton = (args: Omit<Props, 'ref'>) => ( export const RadioButton = (args: Omit<Props, 'ref'>) => (
<Component
{...args}
/>
<>
{Array.from({ length: LENGTH }).map((_, i) => (
<Component
{...args}
key={i}
name={Component.displayName}
value={i + 1}
>
{Component.displayName} {i + 1}
</Component>
))}
</>
); );


export default meta; export default meta;

+ 4
- 2
categories/web/choice/react/src/components/RadioButton/index.tsx View File

@@ -76,7 +76,9 @@ export const RadioButton = React.forwardRef<RadioButtonDerivedElement, RadioButt
const id = useFallbackId(idProp); const id = useFallbackId(idProp);


return ( return (
<>
<span
className="contents"
>
<input <input
{...etcProps} {...etcProps}
ref={forwardedRef} ref={forwardedRef}
@@ -181,7 +183,7 @@ export const RadioButton = React.forwardRef<RadioButtonDerivedElement, RadioButt
)} )}
</span> </span>
</label> </label>
</>
</span>
); );
}); });




+ 17
- 3
categories/web/choice/react/src/components/RadioTickBox/RadioTickBox.stories.tsx View File

@@ -2,9 +2,14 @@ import * as React from 'react';
import type { Meta } from '@storybook/react'; import type { Meta } from '@storybook/react';
import { RadioTickBox as Component, RadioTickBoxProps as Props } from '.'; import { RadioTickBox as Component, RadioTickBoxProps as Props } from '.';


const LENGTH = 3 as const;

const meta: Meta<typeof Component> = { const meta: Meta<typeof Component> = {
component: Component, component: Component,
argTypes: { argTypes: {
subtext: {
control: { type: 'text' },
},
onChange: { onChange: {
table: { table: {
disable: true, disable: true,
@@ -18,9 +23,18 @@ const meta: Meta<typeof Component> = {
}; };


export const RadioTickBox = (args: Omit<Props, 'ref'>) => ( export const RadioTickBox = (args: Omit<Props, 'ref'>) => (
<Component
{...args}
/>
<>
{Array.from({ length: LENGTH }).map((_, i) => (
<Component
{...args}
key={i}
name={Component.displayName}
value={i + 1}
>
{Component.displayName} {i + 1}
</Component>
))}
</>
); );


export default meta; export default meta;

+ 25
- 0
categories/web/formatted/react/src/components/EmailInput/EmailInput.stories.tsx View File

@@ -1,10 +1,34 @@
import * as React from 'react'; import * as React from 'react';
import type { Meta } from '@storybook/react'; import type { Meta } from '@storybook/react';
import { TextControl } from '@tesseract-design/web-base';
import { EmailInput as Component, EmailInputProps as Props } from '.'; import { EmailInput as Component, EmailInputProps as Props } from '.';


const meta: Meta<typeof Component> = { const meta: Meta<typeof Component> = {
component: Component, component: Component,
argTypes: { argTypes: {
label: {
control: { type: 'text' },
},
hint: {
control: { type: 'text' },
},
variant: {
control: {
type: 'select',
},
options: TextControl.AVAILABLE_VARIANTS,
},
size: {
control: {
type: 'select',
},
options: TextControl.AVAILABLE_SIZES,
},
length: {
control: {
type: 'number',
},
},
onChange: { onChange: {
table: { table: {
disable: true, disable: true,
@@ -14,6 +38,7 @@ const meta: Meta<typeof Component> = {
}, },
args: { args: {
...(Component.defaultProps ?? {}), ...(Component.defaultProps ?? {}),
label: Component.displayName,
}, },
}; };




+ 34
- 0
categories/web/formatted/react/src/components/PatternTextInput/PatternTextInput.stories.tsx View File

@@ -1,10 +1,43 @@
import * as React from 'react'; import * as React from 'react';
import type { Meta } from '@storybook/react'; import type { Meta } from '@storybook/react';
import { TextControl } from '@tesseract-design/web-base';
import { PatternTextInput as Component, PatternTextInputProps as Props } from '.'; import { PatternTextInput as Component, PatternTextInputProps as Props } from '.';


const meta: Meta<typeof Component> = { const meta: Meta<typeof Component> = {
component: Component, component: Component,
argTypes: { argTypes: {
label: {
control: { type: 'text' },
},
hint: {
control: { type: 'text' },
},
indicator: {
control: { type: 'text' },
},
variant: {
control: {
type: 'select',
},
options: TextControl.AVAILABLE_VARIANTS,
},
size: {
control: {
type: 'select',
},
options: TextControl.AVAILABLE_SIZES,
},
inputMode: {
control: {
type: 'select',
},
options: TextControl.AVAILABLE_INPUT_MODES,
},
length: {
control: {
type: 'number',
},
},
onChange: { onChange: {
table: { table: {
disable: true, disable: true,
@@ -14,6 +47,7 @@ const meta: Meta<typeof Component> = {
}, },
args: { args: {
...(Component.defaultProps ?? {}), ...(Component.defaultProps ?? {}),
label: Component.displayName,
}, },
}; };




+ 25
- 0
categories/web/formatted/react/src/components/PhoneNumberInput/PhoneNumberInput.stories.tsx View File

@@ -1,19 +1,44 @@
import * as React from 'react'; import * as React from 'react';
import type { Meta } from '@storybook/react'; import type { Meta } from '@storybook/react';
import { TextControl } from '@tesseract-design/web-base';
import { PhoneNumberInput as Component, PhoneNumberInputProps as Props } from '.'; import { PhoneNumberInput as Component, PhoneNumberInputProps as Props } from '.';


const meta: Meta<typeof Component> = { const meta: Meta<typeof Component> = {
component: Component, component: Component,
argTypes: { argTypes: {
label: {
control: { type: 'text' },
},
hint: {
control: { type: 'text' },
},
variant: {
control: {
type: 'select',
},
options: TextControl.AVAILABLE_VARIANTS,
},
size: {
control: {
type: 'select',
},
options: TextControl.AVAILABLE_SIZES,
},
onChange: { onChange: {
table: { table: {
disable: true, disable: true,
}, },
action: 'changed', action: 'changed',
}, },
length: {
control: {
type: 'number',
},
},
}, },
args: { args: {
...(Component.defaultProps ?? {}), ...(Component.defaultProps ?? {}),
label: Component.displayName,
}, },
}; };




+ 25
- 0
categories/web/formatted/react/src/components/UrlInput/UrlInput.stories.tsx View File

@@ -1,10 +1,34 @@
import * as React from 'react'; import * as React from 'react';
import type { Meta } from '@storybook/react'; import type { Meta } from '@storybook/react';
import { TextControl } from '@tesseract-design/web-base';
import { UrlInput as Component, UrlInputProps as Props } from '.'; import { UrlInput as Component, UrlInputProps as Props } from '.';


const meta: Meta<typeof Component> = { const meta: Meta<typeof Component> = {
component: Component, component: Component,
argTypes: { argTypes: {
label: {
control: { type: 'text' },
},
hint: {
control: { type: 'text' },
},
variant: {
control: {
type: 'select',
},
options: TextControl.AVAILABLE_VARIANTS,
},
size: {
control: {
type: 'select',
},
options: TextControl.AVAILABLE_SIZES,
},
length: {
control: {
type: 'number',
},
},
onChange: { onChange: {
table: { table: {
disable: true, disable: true,
@@ -14,6 +38,7 @@ const meta: Meta<typeof Component> = {
}, },
args: { args: {
...(Component.defaultProps ?? {}), ...(Component.defaultProps ?? {}),
label: Component.displayName,
}, },
}; };




+ 30
- 0
categories/web/freeform/react/src/components/MaskedTextInput/MaskedTextInput.stories.tsx View File

@@ -1,10 +1,39 @@
import * as React from 'react'; import * as React from 'react';
import type { Meta } from '@storybook/react'; import type { Meta } from '@storybook/react';
import { TextControl } from '@tesseract-design/web-base';
import { MaskedTextInput as Component, MaskedTextInputProps as Props } from '.'; import { MaskedTextInput as Component, MaskedTextInputProps as Props } from '.';


const meta: Meta<typeof Component> = { const meta: Meta<typeof Component> = {
component: Component, component: Component,
argTypes: { argTypes: {
label: {
control: { type: 'text' },
},
hint: {
control: { type: 'text' },
},
variant: {
control: {
type: 'select',
},
options: TextControl.AVAILABLE_VARIANTS,
},
size: {
control: {
type: 'select',
},
options: TextControl.AVAILABLE_SIZES,
},
autoComplete: {
table: {
disable: true,
},
},
length: {
control: {
type: 'number',
},
},
onChange: { onChange: {
table: { table: {
disable: true, disable: true,
@@ -14,6 +43,7 @@ const meta: Meta<typeof Component> = {
}, },
args: { args: {
...(Component.defaultProps ?? {}), ...(Component.defaultProps ?? {}),
label: Component.displayName,
}, },
}; };




+ 25
- 0
categories/web/freeform/react/src/components/MultilineTextInput/MultilineTextInput.stories.tsx View File

@@ -1,10 +1,34 @@
import * as React from 'react'; import * as React from 'react';
import type { Meta } from '@storybook/react'; import type { Meta } from '@storybook/react';
import { TextControl } from '@tesseract-design/web-base';
import { MultilineTextInput as Component, MultilineTextInputProps as Props } from '.'; import { MultilineTextInput as Component, MultilineTextInputProps as Props } from '.';


const meta: Meta<typeof Component> = { const meta: Meta<typeof Component> = {
component: Component, component: Component,
argTypes: { argTypes: {
label: {
control: { type: 'text' },
},
hint: {
control: { type: 'text' },
},
indicator: {
control: {
type: 'text',
},
},
variant: {
control: {
type: 'select',
},
options: TextControl.AVAILABLE_VARIANTS,
},
size: {
control: {
type: 'select',
},
options: TextControl.AVAILABLE_SIZES,
},
onChange: { onChange: {
table: { table: {
disable: true, disable: true,
@@ -14,6 +38,7 @@ const meta: Meta<typeof Component> = {
}, },
args: { args: {
...(Component.defaultProps ?? {}), ...(Component.defaultProps ?? {}),
label: Component.displayName,
}, },
}; };




+ 42
- 0
categories/web/freeform/react/src/components/TextInput/TextInput.stories.tsx View File

@@ -1,10 +1,51 @@
import * as React from 'react'; import * as React from 'react';
import type { Meta } from '@storybook/react'; import type { Meta } from '@storybook/react';
import { TextControl } from '@tesseract-design/web-base';
import { TextInput as Component, TextInputProps as Props } from '.'; import { TextInput as Component, TextInputProps as Props } from '.';


const meta: Meta<typeof Component> = { const meta: Meta<typeof Component> = {
component: Component, component: Component,
argTypes: { argTypes: {
label: {
control: { type: 'text' },
},
hint: {
control: { type: 'text' },
},
indicator: {
control: {
type: 'text',
},
},
variant: {
control: {
type: 'select',
},
options: TextControl.AVAILABLE_VARIANTS,
},
size: {
control: {
type: 'select',
},
options: TextControl.AVAILABLE_SIZES,
},
inputMode: {
control: {
type: 'select',
},
options: TextControl.AVAILABLE_INPUT_MODES,
},
type: {
control: {
type: 'select',
},
options: TextControl.AVAILABLE_INPUT_TYPES,
},
length: {
control: {
type: 'number',
},
},
onChange: { onChange: {
table: { table: {
disable: true, disable: true,
@@ -14,6 +55,7 @@ const meta: Meta<typeof Component> = {
}, },
args: { args: {
...(Component.defaultProps ?? {}), ...(Component.defaultProps ?? {}),
label: Component.displayName,
}, },
}; };




+ 7
- 1
categories/web/information/react/src/components/Badge/Badge.stories.tsx View File

@@ -4,7 +4,13 @@ import { Badge as Component, BadgeProps as Props } from '.';


const meta: Meta<typeof Component> = { const meta: Meta<typeof Component> = {
component: Component, component: Component,
argTypes: {},
argTypes: {
children: {
control: {
type: 'text',
},
},
},
args: { args: {
...(Component.defaultProps ?? {}), ...(Component.defaultProps ?? {}),
}, },


+ 1
- 1
categories/web/information/react/src/components/Badge/index.tsx View File

@@ -33,7 +33,7 @@ export const Badge = React.forwardRef<BadgeDerivedElement, BadgeProps>((
{...etcProps} {...etcProps}
ref={forwardedRef} ref={forwardedRef}
className={clsx( className={clsx(
'relative h-6 min-w-6 flex items-center justify-center text-xs font-bold overflow-hidden font-semi-expanded',
'relative h-6 min-w-6 inline-flex align-middle items-center justify-center text-xs font-bold overflow-hidden font-semi-expanded',
'before:absolute before:top-0 before:left-0 before:w-full before:h-full before:bg-current before:opacity-25', 'before:absolute before:top-0 before:left-0 before:w-full before:h-full before:bg-current before:opacity-25',
{ {
'rounded-full px-2': rounded, 'rounded-full px-2': rounded,


+ 32
- 2
categories/web/multichoice/react/src/components/MenuMultiSelect/MenuMultiSelect.stories.tsx View File

@@ -5,6 +5,18 @@ import { MenuMultiSelect as Component, MenuMultiSelectProps as Props } from '.';
const meta: Meta<typeof Component> = { const meta: Meta<typeof Component> = {
component: Component, component: Component,
argTypes: { argTypes: {
label: {
control: { type: 'text' },
},
hint: {
control: { type: 'text' },
},
indicator: {
control: { type: 'text' },
},
children: {
control: { type: 'text' },
},
onChange: { onChange: {
table: { table: {
disable: true, disable: true,
@@ -14,13 +26,31 @@ const meta: Meta<typeof Component> = {
}, },
args: { args: {
...(Component.defaultProps ?? {}), ...(Component.defaultProps ?? {}),
label: Component.displayName,
children: `Chocolate
Vanilla
Mango
Strawberry
`,
}, },
}; };


export const MenuMultiSelect = (args: Omit<Props, 'ref'>) => (
export const MenuMultiSelect = ({ children = '', ...args }: Omit<Props, 'ref'>) => (
<Component <Component
{...args} {...args}
/>
>
{(children ? children.toString() : '').split('\n').filter(s => s.length > 0).map((s, i) => {
const [label, value = label] = s.split(':').map(s => s.trim()) as string[];
return (
<option
key={`${s}:${i}`}
value={value}
>
{label}
</option>
);
})}
</Component>
); );


export default meta; export default meta;

+ 37
- 1
categories/web/multichoice/react/src/components/TagInput/TagInput.stories.tsx View File

@@ -1,10 +1,45 @@
import * as React from 'react'; import * as React from 'react';
import type { Meta } from '@storybook/react'; import type { Meta } from '@storybook/react';
import { TagInput as Component, TagInputProps as Props } from '.';
import { TextControl } from '@tesseract-design/web-base';
import { TagInput as Component, TagInputProps as Props, AVAILABLE_TAG_INPUT_SEPARATORS } from '.';


const meta: Meta<typeof Component> = { const meta: Meta<typeof Component> = {
component: Component, component: Component,
argTypes: { argTypes: {
label: {
control: { type: 'text' },
},
hint: {
control: { type: 'text' },
},
indicator: {
control: {
type: 'text',
},
},
variant: {
control: {
type: 'select',
},
options: TextControl.AVAILABLE_VARIANTS,
},
size: {
control: {
type: 'select',
},
options: TextControl.AVAILABLE_SIZES,
},
fallbackElement: {
table: {
disable: true,
},
},
valueSeparator: {
control: {
type: 'select',
},
options: AVAILABLE_TAG_INPUT_SEPARATORS,
},
onChange: { onChange: {
table: { table: {
disable: true, disable: true,
@@ -14,6 +49,7 @@ const meta: Meta<typeof Component> = {
}, },
args: { args: {
...(Component.defaultProps ?? {}), ...(Component.defaultProps ?? {}),
label: Component.displayName,
}, },
}; };




+ 3
- 1
categories/web/multichoice/react/src/components/TagInput/index.tsx View File

@@ -5,10 +5,12 @@ import { useClientSide, useFallbackId, useProxyInput } from '@modal-sh/react-uti
import { TextControl } from '@tesseract-design/web-base'; import { TextControl } from '@tesseract-design/web-base';
import plugin from 'tailwindcss/plugin'; import plugin from 'tailwindcss/plugin';


export const AVAILABLE_TAG_INPUT_SEPARATORS = ['comma', 'newline', 'semicolon'] as const;

/** /**
* Separator for splitting the input value into multiple tags. * Separator for splitting the input value into multiple tags.
*/ */
export type TagInputSeparator = 'comma' | 'newline' | 'semicolon';
export type TagInputSeparator = typeof AVAILABLE_TAG_INPUT_SEPARATORS[number];


const TAG_INPUT_SEPARATOR_MAP: Record<TagInputSeparator, string> = { const TAG_INPUT_SEPARATOR_MAP: Record<TagInputSeparator, string> = {
'comma': ',', 'comma': ',',


+ 33
- 3
categories/web/multichoice/react/src/components/ToggleButton/ToggleButton.stories.tsx View File

@@ -1,10 +1,30 @@
import * as React from 'react'; import * as React from 'react';
import type { Meta } from '@storybook/react'; import type { Meta } from '@storybook/react';
import { Button } from '@tesseract-design/web-base';
import { ToggleButton as Component, ToggleButtonProps as Props } from '.'; import { ToggleButton as Component, ToggleButtonProps as Props } from '.';


const LENGTH = 3 as const;

const meta: Meta<typeof Component> = { const meta: Meta<typeof Component> = {
component: Component, component: Component,
argTypes: { argTypes: {
children: {
control: { type: 'text' },
},
badge: {
control: { type: 'text' },
},
variant: {
control: { type: 'select' },
options: Button.AVAILABLE_VARIANTS,
},
size: {
control: { type: 'select' },
options: Button.AVAILABLE_SIZES,
},
subtext: {
control: { type: 'text' },
},
onChange: { onChange: {
table: { table: {
disable: true, disable: true,
@@ -14,13 +34,23 @@ const meta: Meta<typeof Component> = {
}, },
args: { args: {
...(Component.defaultProps ?? {}), ...(Component.defaultProps ?? {}),
children: Component.displayName,
}, },
}; };


export const ToggleButton = (args: Omit<Props, 'ref'>) => ( export const ToggleButton = (args: Omit<Props, 'ref'>) => (
<Component
{...args}
/>
<>
{Array.from({ length: LENGTH }).map((_, i) => (
<Component
{...args}
key={i}
name={Component.displayName}
value={i + 1}
>
{Component.displayName} {i + 1}
</Component>
))}
</>
); );


export default meta; export default meta;

+ 4
- 2
categories/web/multichoice/react/src/components/ToggleButton/index.tsx View File

@@ -98,7 +98,9 @@ export const ToggleButton = React.forwardRef<ToggleButtonDerivedElement, ToggleB
}, [indeterminate, defaultRef, ref]); }, [indeterminate, defaultRef, ref]);


return ( return (
<>
<span
className="contents"
>
<input <input
{...etcProps} {...etcProps}
ref={typeof ref === 'function' ? defaultRef : ref} ref={typeof ref === 'function' ? defaultRef : ref}
@@ -225,7 +227,7 @@ export const ToggleButton = React.forwardRef<ToggleButtonDerivedElement, ToggleB
)} )}
</span> </span>
</label> </label>
</>
</span>
); );
}); });




+ 29
- 3
categories/web/multichoice/react/src/components/ToggleSwitch/ToggleSwitch.stories.tsx View File

@@ -2,9 +2,26 @@ import * as React from 'react';
import type { Meta } from '@storybook/react'; import type { Meta } from '@storybook/react';
import { ToggleSwitch as Component, ToggleSwitchProps as Props } from '.'; import { ToggleSwitch as Component, ToggleSwitchProps as Props } from '.';


const LENGTH = 3 as const;

const meta: Meta<typeof Component> = { const meta: Meta<typeof Component> = {
component: Component, component: Component,
argTypes: { argTypes: {
checkedLabel: {
control: {
type: 'text',
},
},
subtext: {
control: {
type: 'text',
},
},
uncheckedLabel: {
control: {
type: 'text',
},
},
onChange: { onChange: {
table: { table: {
disable: true, disable: true,
@@ -14,13 +31,22 @@ const meta: Meta<typeof Component> = {
}, },
args: { args: {
...(Component.defaultProps ?? {}), ...(Component.defaultProps ?? {}),
checkedLabel: Component.displayName,
}, },
}; };


export const ToggleSwitch = (args: Omit<Props, 'ref'>) => ( export const ToggleSwitch = (args: Omit<Props, 'ref'>) => (
<Component
{...args}
/>
<>
{Array.from({ length: LENGTH }).map((_, i) => (
<Component
{...args}
key={i}
name={Component.displayName}
value={i + 1}
checkedLabel={`${Component.displayName} ${i + 1}`}
/>
))}
</>
); );


export default meta; export default meta;

+ 1
- 1
categories/web/multichoice/react/src/components/ToggleSwitch/index.tsx View File

@@ -11,7 +11,7 @@ export type ToggleSwitchDerivedElement = HTMLInputElement;
/** /**
* Props of the {@link ToggleSwitch} component. * Props of the {@link ToggleSwitch} component.
*/ */
export interface ToggleSwitchProps extends Omit<React.InputHTMLAttributes<ToggleSwitchDerivedElement>, 'type' | 'size'> {
export interface ToggleSwitchProps extends Omit<React.InputHTMLAttributes<ToggleSwitchDerivedElement>, 'type' | 'size' | 'children'> {
/** /**
* Should the component occupy the whole width of its parent? * Should the component occupy the whole width of its parent?
*/ */


+ 21
- 3
categories/web/multichoice/react/src/components/ToggleTickBox/ToggleTickBox.stories.tsx View File

@@ -2,9 +2,17 @@ import * as React from 'react';
import type { Meta } from '@storybook/react'; import type { Meta } from '@storybook/react';
import { ToggleTickBox as Component, ToggleTickBoxProps as Props } from '.'; import { ToggleTickBox as Component, ToggleTickBoxProps as Props } from '.';


const LENGTH = 3 as const;

const meta: Meta<typeof Component> = { const meta: Meta<typeof Component> = {
component: Component, component: Component,
argTypes: { argTypes: {
children: {
control: { type: 'text' },
},
subtext: {
control: { type: 'text' },
},
onChange: { onChange: {
table: { table: {
disable: true, disable: true,
@@ -14,13 +22,23 @@ const meta: Meta<typeof Component> = {
}, },
args: { args: {
...(Component.defaultProps ?? {}), ...(Component.defaultProps ?? {}),
children: Component.displayName,
}, },
}; };


export const ToggleTickBox = (args: Omit<Props, 'ref'>) => ( export const ToggleTickBox = (args: Omit<Props, 'ref'>) => (
<Component
{...args}
/>
<>
{Array.from({ length: LENGTH }).map((_, i) => (
<Component
{...args}
key={i}
name={Component.displayName}
value={i + 1}
>
{Component.displayName} {i + 1}
</Component>
))}
</>
); );


export default meta; export default meta;

+ 18
- 7
categories/web/navigation/react/src/components/LinkButton/LinkButton.stories.tsx View File

@@ -6,10 +6,6 @@ import { Button } from '@tesseract-design/web-base';
const meta: Meta<typeof Component> = { const meta: Meta<typeof Component> = {
component: Component, component: Component,
argTypes: { argTypes: {
type: {
control: { type: 'select' },
options: Button.AVAILABLE_TYPES,
},
variant: { variant: {
control: { type: 'select' }, control: { type: 'select' },
options: Button.AVAILABLE_VARIANTS, options: Button.AVAILABLE_VARIANTS,
@@ -31,7 +27,14 @@ const meta: Meta<typeof Component> = {
control: { type: 'text' }, control: { type: 'text' },
}, },
href: { href: {
control: { type: 'text' },
table: {
disable: true,
},
},
component: {
table: {
disable: true,
},
}, },
onClick: { onClick: {
table: { table: {
@@ -40,12 +43,20 @@ const meta: Meta<typeof Component> = {
action: 'clicked', action: 'clicked',
}, },
}, },
args: Component.defaultProps ?? {},
args: {
...(Component.defaultProps ?? {}),
children: Component.displayName,
},
}; };


export const LinkButton = (args: Omit<LinkButtonProps, 'ref'>) => (
export const LinkButton = ({ onClick, ...args }: Omit<LinkButtonProps, 'ref'>) => (
<Component <Component
{...args} {...args}
href="#"
onClick={(e) => {
e.preventDefault();
onClick?.(e);
}}
/> />
); );




+ 23
- 0
categories/web/number/react/src/components/NumberSpinner/NumberSpinner.stories.tsx View File

@@ -1,10 +1,32 @@
import * as React from 'react'; import * as React from 'react';
import type { Meta } from '@storybook/react'; import type { Meta } from '@storybook/react';
import { TextControl } from '@tesseract-design/web-base';
import { NumberSpinner as Component, NumberSpinnerProps as Props } from '.'; import { NumberSpinner as Component, NumberSpinnerProps as Props } from '.';


const meta: Meta<typeof Component> = { const meta: Meta<typeof Component> = {
component: Component, component: Component,
argTypes: { argTypes: {
label: {
control: { type: 'text' },
},
hint: {
control: { type: 'text' },
},
length: {
control: { type: 'number' },
},
variant: {
control: {
type: 'select',
},
options: TextControl.AVAILABLE_VARIANTS,
},
size: {
control: {
type: 'select',
},
options: TextControl.AVAILABLE_SIZES,
},
onChange: { onChange: {
table: { table: {
disable: true, disable: true,
@@ -14,6 +36,7 @@ const meta: Meta<typeof Component> = {
}, },
args: { args: {
...(Component.defaultProps ?? {}), ...(Component.defaultProps ?? {}),
label: Component.displayName,
}, },
}; };




+ 8
- 7
categories/web/number/react/src/components/NumberSpinner/index.tsx View File

@@ -117,7 +117,7 @@ export const NumberSpinner = React.forwardRef<NumberSpinnerDerivedElement, Numbe
const spinEventSource = React.useRef<'mouse' | 'keyboard'>(); const spinEventSource = React.useRef<'mouse' | 'keyboard'>();
const [displayStep, setDisplayStep] = React.useState<boolean>(); const [displayStep, setDisplayStep] = React.useState<boolean>();


const performStepMouse = (
const performStep = (
input: NumberSpinnerDerivedElement, input: NumberSpinnerDerivedElement,
theStepUpMode?: boolean, theStepUpMode?: boolean,
) => { ) => {
@@ -132,6 +132,7 @@ export const NumberSpinner = React.forwardRef<NumberSpinnerDerivedElement, Numbe
} else { } else {
current.stepDown(); current.stepDown();
} }
current.dispatchEvent(new Event('change', { bubbles: true }));
current.step = theStep; current.step = theStep;
current.focus(); current.focus();
}; };
@@ -168,15 +169,15 @@ export const NumberSpinner = React.forwardRef<NumberSpinnerDerivedElement, Numbe
clearInterval(intervalRef.current); clearInterval(intervalRef.current);
const stepUpMode = checkMouseStepUpMode(); const stepUpMode = checkMouseStepUpMode();
setDisplayStep(stepUpMode); setDisplayStep(stepUpMode);
performStepMouse(current, stepUpMode);
performStep(current, stepUpMode);
intervalRef.current = window.setTimeout(() => { intervalRef.current = window.setTimeout(() => {
const stepUpMode = checkMouseStepUpMode(); const stepUpMode = checkMouseStepUpMode();
setDisplayStep(stepUpMode); setDisplayStep(stepUpMode);
performStepMouse(current, stepUpMode);
performStep(current, stepUpMode);
intervalRef.current = window.setInterval(() => { intervalRef.current = window.setInterval(() => {
const stepUpMode = checkMouseStepUpMode(); const stepUpMode = checkMouseStepUpMode();
setDisplayStep(stepUpMode); setDisplayStep(stepUpMode);
performStepMouse(current, stepUpMode);
performStep(current, stepUpMode);
}, stepInterval); }, stepInterval);
}, initialStepDelay); }, initialStepDelay);
}); });
@@ -196,11 +197,11 @@ export const NumberSpinner = React.forwardRef<NumberSpinnerDerivedElement, Numbe
setDisplayStep(theStepUpMode); setDisplayStep(theStepUpMode);
setTimeout(() => { setTimeout(() => {
clearInterval(intervalRef.current); clearInterval(intervalRef.current);
performStepMouse(current, theStepUpMode);
performStep(current, theStepUpMode);
intervalRef.current = window.setTimeout(() => { intervalRef.current = window.setTimeout(() => {
performStepMouse(current, theStepUpMode);
performStep(current, theStepUpMode);
intervalRef.current = window.setInterval(() => { intervalRef.current = window.setInterval(() => {
performStepMouse(current, theStepUpMode);
performStep(current, theStepUpMode);
}, stepInterval); }, stepInterval);
}, initialStepDelay); }, initialStepDelay);
}); });


+ 35
- 3
categories/web/number/react/src/components/Slider/Slider.stories.tsx View File

@@ -1,10 +1,28 @@
import * as React from 'react'; import * as React from 'react';
import type { Meta } from '@storybook/react'; import type { Meta } from '@storybook/react';
import { Slider as Component, SliderProps as Props } from '.';
import { Slider as Component, SliderProps as Props, AVAILABLE_SLIDER_ORIENTATIONS } from '.';


const meta: Meta<typeof Component> = { const meta: Meta<typeof Component> = {
component: Component, component: Component,
argTypes: { argTypes: {
orient: {
control: {
type: 'select',
},
options: AVAILABLE_SLIDER_ORIENTATIONS,
},
max: {
control: { type: 'number' },
},
min: {
control: { type: 'number' },
},
length: {
control: { type: 'number' },
},
children: {
control: { type: 'text' },
},
onChange: { onChange: {
table: { table: {
disable: true, disable: true,
@@ -14,13 +32,27 @@ const meta: Meta<typeof Component> = {
}, },
args: { args: {
...(Component.defaultProps ?? {}), ...(Component.defaultProps ?? {}),
max: 100,
min: 0,
}, },
}; };


export const Slider = (args: Omit<Props, 'ref'>) => (
export const Slider = ({children, ...args}: Omit<Props, 'ref'>) => (
<Component <Component
{...args} {...args}
/>
>
{(children ? children.toString() : '').split('\n').filter(s => s.length > 0).map((s, i) => {
const [label, value = label] = s.split(':').map(s => s.trim()) as string[];
return (
<option
key={`${s}:${i}`}
value={value}
>
{label}
</option>
);
})}
</Component>
); );


export default meta; export default meta;

+ 4
- 2
categories/web/number/react/src/components/Slider/index.tsx View File

@@ -36,10 +36,12 @@ const filterOptions = (children: React.ReactNode): React.ReactNode => {
* sliders and vv. * sliders and vv.
*/ */


export const AVAILABLE_SLIDER_ORIENTATIONS = ['horizontal', 'vertical'] as const;

/** /**
* Orientation of the {@link Slider} component. * Orientation of the {@link Slider} component.
*/ */
export type SliderOrientation = 'horizontal' | 'vertical';
export type SliderOrientation = typeof AVAILABLE_SLIDER_ORIENTATIONS[number];


/** /**
* Derived HTML element of the {@link Slider} component. * Derived HTML element of the {@link Slider} component.
@@ -407,7 +409,7 @@ export const Slider = React.forwardRef<SliderDerivedElement, SliderProps>((
} }
}); });
} }
}, [ref, orient, browser]);
}, [ref, orient, browser, children]);


const block = typeof length === 'string' && length.trim() === '100%'; const block = typeof length === 'string' && length.trim() === '100%';
const minValue = Number(min); const minValue = Number(min);


+ 23
- 0
categories/web/temporal/react/src/components/DateDropdown/DateDropdown.stories.tsx View File

@@ -1,10 +1,32 @@
import * as React from 'react'; import * as React from 'react';
import type { Meta } from '@storybook/react'; import type { Meta } from '@storybook/react';
import { TextControl } from '@tesseract-design/web-base';
import { DateDropdown as Component, DateDropdownProps as Props } from '.'; import { DateDropdown as Component, DateDropdownProps as Props } from '.';


const meta: Meta<typeof Component> = { const meta: Meta<typeof Component> = {
component: Component, component: Component,
argTypes: { argTypes: {
label: {
control: { type: 'text' },
},
hint: {
control: { type: 'text' },
},
variant: {
control: {
type: 'select',
},
options: TextControl.AVAILABLE_VARIANTS,
},
size: {
control: {
type: 'select',
},
options: TextControl.AVAILABLE_SIZES,
},
length: {
control: { type: 'number' },
},
onChange: { onChange: {
table: { table: {
disable: true, disable: true,
@@ -14,6 +36,7 @@ const meta: Meta<typeof Component> = {
}, },
args: { args: {
...(Component.defaultProps ?? {}), ...(Component.defaultProps ?? {}),
label: Component.displayName,
}, },
}; };




+ 20
- 0
categories/web/temporal/react/src/components/TimeSpinner/TimeSpinner.stories.tsx View File

@@ -1,10 +1,29 @@
import * as React from 'react'; import * as React from 'react';
import type { Meta } from '@storybook/react'; import type { Meta } from '@storybook/react';
import { TextControl } from '@tesseract-design/web-base';
import { TimeSpinner as Component, TimeSpinnerProps as Props } from '.'; import { TimeSpinner as Component, TimeSpinnerProps as Props } from '.';


const meta: Meta<typeof Component> = { const meta: Meta<typeof Component> = {
component: Component, component: Component,
argTypes: { argTypes: {
label: {
control: { type: 'text' },
},
hint: {
control: { type: 'text' },
},
variant: {
control: {
type: 'select',
},
options: TextControl.AVAILABLE_VARIANTS,
},
size: {
control: {
type: 'select',
},
options: TextControl.AVAILABLE_SIZES,
},
onChange: { onChange: {
table: { table: {
disable: true, disable: true,
@@ -14,6 +33,7 @@ const meta: Meta<typeof Component> = {
}, },
args: { args: {
...(Component.defaultProps ?? {}), ...(Component.defaultProps ?? {}),
label: Component.displayName,
}, },
}; };




+ 40
- 1
storybook/react/tailwind.config.ts View File

@@ -1,5 +1,29 @@
import {Config} from 'tailwindcss'; import {Config} from 'tailwindcss';
import defaultTheme from 'tailwindcss/defaultTheme'; import defaultTheme from 'tailwindcss/defaultTheme';
import {
radioButtonPlugin,
menuSelectPlugin,
radioTickBoxPlugin,
dropdownSelectPlugin,
} from '../../categories/web/choice/react/src';
import {
colorPickerPlugin,
} from '../../categories/web/color/react/src';
import {
menuMultiSelectPlugin,
tagInputPlugin,
toggleButtonPlugin,
toggleSwitchPlugin,
toggleTickBoxPlugin,
} from '../../categories/web/multichoice/react/src';
import {
numberSpinnerPlugin,
sliderPlugin,
} from '../../categories/web/number/react/src';
import {
dateDropdownPlugin,
timeSpinnerPlugin,
} from '../../categories/web/temporal/react/src';


const config: Config = { const config: Config = {
content: [ content: [
@@ -73,7 +97,22 @@ const config: Config = {
}, },
}, },
}, },
plugins: [],
plugins: [
radioButtonPlugin,
menuSelectPlugin,
radioTickBoxPlugin,
dropdownSelectPlugin,
colorPickerPlugin,
menuMultiSelectPlugin,
tagInputPlugin,
toggleButtonPlugin,
toggleSwitchPlugin,
toggleTickBoxPlugin,
numberSpinnerPlugin,
sliderPlugin,
dateDropdownPlugin,
timeSpinnerPlugin,
],
}; };


export default config; export default config;

Loading…
Cancel
Save