@stack-spot/citric-react 0.22.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/citric.css +17 -4
- package/dist/components/Accordion.d.ts +34 -0
- package/dist/components/Accordion.d.ts.map +1 -1
- package/dist/components/Accordion.js +34 -0
- package/dist/components/Accordion.js.map +1 -1
- package/dist/components/Alert.d.ts +8 -0
- package/dist/components/Alert.d.ts.map +1 -1
- package/dist/components/Alert.js +8 -0
- package/dist/components/Alert.js.map +1 -1
- package/dist/components/AsyncContent.d.ts +18 -4
- package/dist/components/AsyncContent.d.ts.map +1 -1
- package/dist/components/AsyncContent.js +18 -4
- package/dist/components/AsyncContent.js.map +1 -1
- package/dist/components/Avatar.d.ts +9 -0
- package/dist/components/Avatar.d.ts.map +1 -1
- package/dist/components/Avatar.js +11 -1
- package/dist/components/Avatar.js.map +1 -1
- package/dist/components/AvatarGroup.d.ts +8 -0
- package/dist/components/AvatarGroup.d.ts.map +1 -1
- package/dist/components/AvatarGroup.js +8 -0
- package/dist/components/AvatarGroup.js.map +1 -1
- package/dist/components/Badge.d.ts +13 -2
- package/dist/components/Badge.d.ts.map +1 -1
- package/dist/components/Badge.js +14 -3
- package/dist/components/Badge.js.map +1 -1
- package/dist/components/Blockquote.d.ts +8 -0
- package/dist/components/Blockquote.d.ts.map +1 -1
- package/dist/components/Blockquote.js +8 -0
- package/dist/components/Blockquote.js.map +1 -1
- package/dist/components/Breadcrumb.d.ts +8 -0
- package/dist/components/Breadcrumb.d.ts.map +1 -1
- package/dist/components/Breadcrumb.js +10 -1
- package/dist/components/Breadcrumb.js.map +1 -1
- package/dist/components/Button.d.ts +11 -0
- package/dist/components/Button.d.ts.map +1 -1
- package/dist/components/Button.js +14 -2
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Card.d.ts +15 -4
- package/dist/components/Card.d.ts.map +1 -1
- package/dist/components/Card.js +13 -1
- package/dist/components/Card.js.map +1 -1
- package/dist/components/Checkbox.d.ts +14 -0
- package/dist/components/Checkbox.d.ts.map +1 -1
- package/dist/components/Checkbox.js +14 -0
- package/dist/components/Checkbox.js.map +1 -1
- package/dist/components/CheckboxGroup.d.ts +22 -3
- package/dist/components/CheckboxGroup.d.ts.map +1 -1
- package/dist/components/CheckboxGroup.js +23 -3
- package/dist/components/CheckboxGroup.js.map +1 -1
- package/dist/components/Circle.d.ts +16 -0
- package/dist/components/Circle.d.ts.map +1 -1
- package/dist/components/Circle.js +8 -0
- package/dist/components/Circle.js.map +1 -1
- package/dist/components/CitricComponent.d.ts +14 -0
- package/dist/components/CitricComponent.d.ts.map +1 -1
- package/dist/components/CitricComponent.js +14 -0
- package/dist/components/CitricComponent.js.map +1 -1
- package/dist/components/Divider.d.ts +4 -1
- package/dist/components/Divider.d.ts.map +1 -1
- package/dist/components/Divider.js +4 -1
- package/dist/components/Divider.js.map +1 -1
- package/dist/components/ErrorBoundary.d.ts +13 -0
- package/dist/components/ErrorBoundary.d.ts.map +1 -1
- package/dist/components/ErrorBoundary.js +13 -0
- package/dist/components/ErrorBoundary.js.map +1 -1
- package/dist/components/ErrorMessage.js +1 -1
- package/dist/components/ErrorMessage.js.map +1 -1
- package/dist/components/FallbackBoundary.d.ts +12 -1
- package/dist/components/FallbackBoundary.d.ts.map +1 -1
- package/dist/components/FallbackBoundary.js +12 -1
- package/dist/components/FallbackBoundary.js.map +1 -1
- package/dist/components/Favorite.d.ts +12 -0
- package/dist/components/Favorite.d.ts.map +1 -1
- package/dist/components/Favorite.js +12 -0
- package/dist/components/Favorite.js.map +1 -1
- package/dist/components/FieldGroup.d.ts +13 -0
- package/dist/components/FieldGroup.d.ts.map +1 -1
- package/dist/components/FieldGroup.js +13 -0
- package/dist/components/FieldGroup.js.map +1 -1
- package/dist/components/Form.d.ts +18 -0
- package/dist/components/Form.d.ts.map +1 -1
- package/dist/components/Form.js +18 -0
- package/dist/components/Form.js.map +1 -1
- package/dist/components/FormGroup.d.ts +12 -0
- package/dist/components/FormGroup.d.ts.map +1 -1
- package/dist/components/FormGroup.js +12 -0
- package/dist/components/FormGroup.js.map +1 -1
- package/dist/components/IconBox.d.ts +33 -8
- package/dist/components/IconBox.d.ts.map +1 -1
- package/dist/components/IconBox.js +37 -11
- package/dist/components/IconBox.js.map +1 -1
- package/dist/components/ImageBox.d.ts +32 -8
- package/dist/components/ImageBox.d.ts.map +1 -1
- package/dist/components/ImageBox.js +36 -11
- package/dist/components/ImageBox.js.map +1 -1
- package/dist/components/ImageWithFallback.d.ts +18 -0
- package/dist/components/ImageWithFallback.d.ts.map +1 -1
- package/dist/components/ImageWithFallback.js +11 -0
- package/dist/components/ImageWithFallback.js.map +1 -1
- package/dist/components/Input.d.ts +15 -3
- package/dist/components/Input.d.ts.map +1 -1
- package/dist/components/Input.js +16 -3
- package/dist/components/Input.js.map +1 -1
- package/dist/components/Link.d.ts +6 -0
- package/dist/components/Link.d.ts.map +1 -1
- package/dist/components/Link.js +6 -0
- package/dist/components/Link.js.map +1 -1
- package/dist/components/MenuOverlay/index.d.ts +20 -0
- package/dist/components/MenuOverlay/index.d.ts.map +1 -1
- package/dist/components/MenuOverlay/index.js +20 -0
- package/dist/components/MenuOverlay/index.js.map +1 -1
- package/dist/components/Overlay/index.d.ts +16 -0
- package/dist/components/Overlay/index.d.ts.map +1 -1
- package/dist/components/Overlay/index.js +16 -0
- package/dist/components/Overlay/index.js.map +1 -1
- package/dist/components/Pagination.d.ts +27 -8
- package/dist/components/Pagination.d.ts.map +1 -1
- package/dist/components/Pagination.js +18 -5
- package/dist/components/Pagination.js.map +1 -1
- package/dist/components/ProgressBar.d.ts +14 -0
- package/dist/components/ProgressBar.d.ts.map +1 -1
- package/dist/components/ProgressBar.js +14 -0
- package/dist/components/ProgressBar.js.map +1 -1
- package/dist/components/ProgressCircular.d.ts +14 -0
- package/dist/components/ProgressCircular.d.ts.map +1 -1
- package/dist/components/ProgressCircular.js +14 -0
- package/dist/components/ProgressCircular.js.map +1 -1
- package/dist/components/RadioGroup.d.ts +24 -3
- package/dist/components/RadioGroup.d.ts.map +1 -1
- package/dist/components/RadioGroup.js +25 -3
- package/dist/components/RadioGroup.js.map +1 -1
- package/dist/components/Rating.d.ts +10 -0
- package/dist/components/Rating.d.ts.map +1 -1
- package/dist/components/Rating.js +10 -0
- package/dist/components/Rating.js.map +1 -1
- package/dist/components/Select/RichSelect.d.ts +3 -5
- package/dist/components/Select/RichSelect.d.ts.map +1 -1
- package/dist/components/Select/RichSelect.js +4 -4
- package/dist/components/Select/RichSelect.js.map +1 -1
- package/dist/components/Select/SimpleSelect.d.ts +2 -3
- package/dist/components/Select/SimpleSelect.d.ts.map +1 -1
- package/dist/components/Select/SimpleSelect.js +2 -3
- package/dist/components/Select/SimpleSelect.js.map +1 -1
- package/dist/components/Select/index.d.ts +25 -2
- package/dist/components/Select/index.d.ts.map +1 -1
- package/dist/components/Select/index.js +26 -3
- package/dist/components/Select/index.js.map +1 -1
- package/dist/components/Select/types.d.ts +1 -2
- package/dist/components/Select/types.d.ts.map +1 -1
- package/dist/components/SelectBox.d.ts +31 -2
- package/dist/components/SelectBox.d.ts.map +1 -1
- package/dist/components/SelectBox.js +32 -3
- package/dist/components/SelectBox.js.map +1 -1
- package/dist/components/Skeleton.d.ts +11 -0
- package/dist/components/Skeleton.d.ts.map +1 -1
- package/dist/components/Skeleton.js +11 -0
- package/dist/components/Skeleton.js.map +1 -1
- package/dist/components/Slider.d.ts +12 -0
- package/dist/components/Slider.d.ts.map +1 -1
- package/dist/components/Slider.js +12 -0
- package/dist/components/Slider.js.map +1 -1
- package/dist/components/SmartTable.d.ts +36 -2
- package/dist/components/SmartTable.d.ts.map +1 -1
- package/dist/components/SmartTable.js +37 -3
- package/dist/components/SmartTable.js.map +1 -1
- package/dist/components/Stepper.d.ts +20 -3
- package/dist/components/Stepper.d.ts.map +1 -1
- package/dist/components/Stepper.js +21 -3
- package/dist/components/Stepper.js.map +1 -1
- package/dist/components/Table.d.ts +10 -0
- package/dist/components/Table.d.ts.map +1 -1
- package/dist/components/Table.js +10 -0
- package/dist/components/Table.js.map +1 -1
- package/dist/components/Tabs/TabController.d.ts +14 -0
- package/dist/components/Tabs/TabController.d.ts.map +1 -1
- package/dist/components/Tabs/TabController.js +14 -0
- package/dist/components/Tabs/TabController.js.map +1 -1
- package/dist/components/Tabs/index.d.ts +20 -3
- package/dist/components/Tabs/index.d.ts.map +1 -1
- package/dist/components/Tabs/index.js +21 -3
- package/dist/components/Tabs/index.js.map +1 -1
- package/dist/components/Text.d.ts +16 -2
- package/dist/components/Text.d.ts.map +1 -1
- package/dist/components/Text.js +17 -3
- package/dist/components/Text.js.map +1 -1
- package/dist/components/Textarea.d.ts +11 -1
- package/dist/components/Textarea.d.ts.map +1 -1
- package/dist/components/Textarea.js +12 -2
- package/dist/components/Textarea.js.map +1 -1
- package/dist/components/Tooltip.d.ts +14 -1
- package/dist/components/Tooltip.d.ts.map +1 -1
- package/dist/components/Tooltip.js +13 -0
- package/dist/components/Tooltip.js.map +1 -1
- package/dist/components/layout.d.ts +41 -7
- package/dist/components/layout.d.ts.map +1 -1
- package/dist/components/layout.js +44 -9
- package/dist/components/layout.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/Accordion.tsx +34 -0
- package/src/components/Alert.tsx +8 -0
- package/src/components/AsyncContent.tsx +18 -4
- package/src/components/Avatar.tsx +11 -1
- package/src/components/AvatarGroup.tsx +8 -0
- package/src/components/Badge.tsx +24 -8
- package/src/components/Blockquote.tsx +8 -0
- package/src/components/Breadcrumb.tsx +10 -1
- package/src/components/Button.tsx +17 -2
- package/src/components/Card.tsx +34 -14
- package/src/components/Checkbox.tsx +14 -0
- package/src/components/CheckboxGroup.tsx +61 -40
- package/src/components/Circle.tsx +16 -0
- package/src/components/CitricComponent.ts +14 -0
- package/src/components/Divider.tsx +6 -5
- package/src/components/ErrorBoundary.tsx +13 -0
- package/src/components/ErrorMessage.tsx +1 -1
- package/src/components/FallbackBoundary.tsx +12 -1
- package/src/components/Favorite.tsx +12 -0
- package/src/components/FieldGroup.tsx +13 -0
- package/src/components/Form.tsx +18 -0
- package/src/components/FormGroup.tsx +12 -0
- package/src/components/IconBox.tsx +61 -30
- package/src/components/ImageBox.tsx +60 -30
- package/src/components/ImageWithFallback.tsx +18 -0
- package/src/components/Input.tsx +28 -14
- package/src/components/Link.tsx +6 -0
- package/src/components/MenuOverlay/index.tsx +20 -0
- package/src/components/Overlay/index.tsx +17 -0
- package/src/components/Pagination.tsx +40 -17
- package/src/components/ProgressBar.tsx +14 -0
- package/src/components/ProgressCircular.tsx +14 -0
- package/src/components/RadioGroup.tsx +62 -39
- package/src/components/Rating.tsx +10 -0
- package/src/components/Select/RichSelect.tsx +183 -182
- package/src/components/Select/SimpleSelect.tsx +57 -57
- package/src/components/Select/index.tsx +29 -5
- package/src/components/Select/types.ts +1 -1
- package/src/components/SelectBox.tsx +92 -62
- package/src/components/Skeleton.tsx +11 -0
- package/src/components/Slider.tsx +12 -0
- package/src/components/SmartTable.tsx +91 -56
- package/src/components/Stepper.tsx +76 -57
- package/src/components/Table.tsx +10 -0
- package/src/components/Tabs/TabController.ts +14 -0
- package/src/components/Tabs/index.tsx +56 -37
- package/src/components/Text.ts +36 -21
- package/src/components/Textarea.tsx +14 -4
- package/src/components/Tooltip.tsx +14 -1
- package/src/components/layout.tsx +56 -13
- package/src/index.ts +0 -1
- package/dist/components/Switch.d.ts +0 -10
- package/dist/components/Switch.d.ts.map +0 -1
- package/dist/components/Switch.js +0 -8
- package/dist/components/Switch.js.map +0 -1
- package/src/components/Switch.tsx +0 -30
|
@@ -12,46 +12,67 @@ import { findSelectedIndex } from './utils'
|
|
|
12
12
|
|
|
13
13
|
const ctx = createContext<TabController<any> | undefined>(undefined)
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Builds a Tab selector. The content of a tab is a React component and it can suspend, i.e. tabs can be asynchronously loaded.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
*
|
|
20
|
+
* ```
|
|
21
|
+
* const tabs: Tab[] = useMemo(() => [
|
|
22
|
+
* { key: 'tab1', label: 'Tab 1', content: <><h1>First tab</h1><p>Content of the first tab</p></> },
|
|
23
|
+
* { key: 'tab2', label: 'Tab 2', content: <><h1>Second tab</h1><p>Content of the second tab</p></> },
|
|
24
|
+
* { key: 'tab3', label: 'Tab 3', content: <><h1>Third tab</h1><p>Content of the third tab</p></> },
|
|
25
|
+
* ], [])
|
|
26
|
+
*
|
|
27
|
+
* return <Tabs tabs={tabs} />
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export const Tabs = withRef(
|
|
31
|
+
function Tabs<Key extends string>({ tabs, value, equallySized, onChange, controller: ctrl, className, ...props }: TabsProps<Key>) {
|
|
32
|
+
const controller = useMemo(() => ctrl ?? new TabController<Key>(tabs.map(t => t.key), value || tabs[0]?.key), [])
|
|
33
|
+
const t = useTranslate(dictionary)
|
|
34
|
+
const [selectedIndex, setSelectedIndex] = useState(findSelectedIndex(tabs, controller.getValue()))
|
|
19
35
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (value) controller.setValue(value)
|
|
38
|
+
}, [value])
|
|
23
39
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
40
|
+
useEffect(() => controller.onChange((v) => {
|
|
41
|
+
setSelectedIndex(findSelectedIndex(tabs, v))
|
|
42
|
+
onChange?.(v)
|
|
43
|
+
}), [tabs])
|
|
28
44
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
45
|
+
const nav = useMemo(
|
|
46
|
+
() => tabs.map(({ key, label, disabled }, index) => (
|
|
47
|
+
<label key={key}>
|
|
48
|
+
<input type="radio" role="tab" checked={index === selectedIndex} onChange={() => controller.setValue(key)} disabled={disabled} />
|
|
49
|
+
{label || key}
|
|
50
|
+
</label>
|
|
51
|
+
)),
|
|
52
|
+
[tabs, selectedIndex],
|
|
53
|
+
)
|
|
38
54
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
55
|
+
return (
|
|
56
|
+
<ctx.Provider value={controller}>
|
|
57
|
+
<CitricComponent tag="div" component="tabs" className={listToClass([className, equallySized && 'equally-sized'])} {...props}>
|
|
58
|
+
<nav>{nav}</nav>
|
|
59
|
+
<section>
|
|
60
|
+
<ErrorBoundary key={selectedIndex} message={t.error}>
|
|
61
|
+
<Suspense fallback={<Center style={{ padding: '20px' }}><ProgressCircular /></Center>}>
|
|
62
|
+
{selectedIndex === -1 ? null : tabs[selectedIndex]?.content}
|
|
63
|
+
</Suspense>
|
|
64
|
+
</ErrorBoundary>
|
|
65
|
+
</section>
|
|
66
|
+
</CitricComponent>
|
|
67
|
+
</ctx.Provider>
|
|
68
|
+
)
|
|
69
|
+
},
|
|
70
|
+
)
|
|
54
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Request the tab controller of the current context. Use this to control the tabs in the parent components. This returns undefined when
|
|
74
|
+
* no tab context is found.
|
|
75
|
+
*/
|
|
55
76
|
export function useTabController<Key extends string = string>(): TabController<Key> | undefined {
|
|
56
77
|
return useContext(ctx)
|
|
57
78
|
}
|
|
@@ -64,5 +85,3 @@ const dictionary = {
|
|
|
64
85
|
error: 'Ocorreu um erro ao carregar a aba.',
|
|
65
86
|
},
|
|
66
87
|
} satisfies Dictionary
|
|
67
|
-
|
|
68
|
-
export const Tabs = withRef(_Tabs)
|
package/src/components/Text.ts
CHANGED
|
@@ -73,24 +73,39 @@ const appearanceToTag: Record<TextAppearance, SupportedTags> = {
|
|
|
73
73
|
subtitle4: 'p',
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Renders a text. The tag can be set by the property "tag". If unset, the tag rendered will be based on the property "appearance". If
|
|
78
|
+
* "appearance" is also unset, the tag "p" is rendered.
|
|
79
|
+
*
|
|
80
|
+
* Texts have no margin by default, to enable margins, use `showMargins = true`.
|
|
81
|
+
*
|
|
82
|
+
* If the appearance is not set, it will be inherited from the parent.
|
|
83
|
+
*
|
|
84
|
+
* A font can be applied to a text without this component, just use `{ font: theme.font.$textAppearance }` in your style.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```
|
|
88
|
+
* <Text appearance="body2">Hello World!</Text>
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export const Text = withRef(
|
|
92
|
+
function Text<T extends SupportedTags>(
|
|
93
|
+
{ tag, appearance, color, showMargins, weight, align, nowrapEllipsis, style, className, children, ...props }: TextProps<T>,
|
|
94
|
+
) {
|
|
95
|
+
const renderedTag = tag || appearanceToTag[appearance || 'body2']
|
|
96
|
+
const renderedAppearance = appearance || (tag ? tagToAppearance[tag] : undefined)
|
|
97
|
+
if (!appearance && !showMargins) style = { margin: 0, ...style }
|
|
98
|
+
if (weight) style = { fontWeight: weight, ...style }
|
|
99
|
+
if (align) style = { textAlign: align, ...style }
|
|
100
|
+
if (nowrapEllipsis) style = { whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', ...style }
|
|
101
|
+
return createElement(
|
|
102
|
+
renderedTag,
|
|
103
|
+
{
|
|
104
|
+
className: applyTextAppearance(listToClass([className, showMargins && 'text-with-margins']), renderedAppearance),
|
|
105
|
+
style: applyColor(style, color),
|
|
106
|
+
...props,
|
|
107
|
+
},
|
|
108
|
+
children,
|
|
109
|
+
)
|
|
110
|
+
},
|
|
111
|
+
)
|
|
@@ -11,7 +11,17 @@ export interface BaseTextareaProps extends WithColorScheme {
|
|
|
11
11
|
|
|
12
12
|
export type TextareaProps = ControlledTextarea & BaseTextareaProps
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Renders a textarea HTML element. With the difference that the value is not determined by the children, but the property "value" instead.
|
|
16
|
+
*
|
|
17
|
+
* Attention: "onChange" receives the new value, not the event.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```
|
|
21
|
+
* const [value, setValue] = useState('')
|
|
22
|
+
* return <Textarea value={value} onChange={setValue} />
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export const Textarea = withRef(({ value, onChange, ...props }: TextareaProps) =>
|
|
26
|
+
<CitricComponent tag="textarea" component="textarea" value={value} onChange={e => onChange?.(e.target.value)} {...props} />,
|
|
27
|
+
)
|
|
@@ -32,8 +32,21 @@ export interface BaseTooltipProps extends
|
|
|
32
32
|
disabled?: boolean,
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
export type TooltipProps = React.JSX.IntrinsicElements['div'] & BaseTooltipProps
|
|
35
|
+
export type TooltipProps = Omit<React.JSX.IntrinsicElements['div'], 'content'> & BaseTooltipProps
|
|
36
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Renders a tooltip overlay for its child. By default, the tooltip is rendered on hover, but this can be changed through the property
|
|
39
|
+
* "triggerOn".
|
|
40
|
+
*
|
|
41
|
+
* The content of the tooltip can be any React element.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```
|
|
45
|
+
* <Tooltip content="This is some help for you">
|
|
46
|
+
* <IconButton icon="Question" />
|
|
47
|
+
* </Tooltip>
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
37
50
|
export const Tooltip = (
|
|
38
51
|
{ tooltipId, children, showArrow = true, compact = true, attributes, colorScheme, colorPalette, disabled, ...props }: TooltipProps,
|
|
39
52
|
) => {
|
|
@@ -41,18 +41,61 @@ export type CenterProps<T extends keyof HTMLTag> = HTMLTag[T] & BaseLayoutProps<
|
|
|
41
41
|
export type RowProps<T extends keyof HTMLTag> = HTMLTag[T] & BaseRowProps<T>
|
|
42
42
|
export type ColumnProps<T extends keyof HTMLTag> = HTMLTag[T] & BaseColumnProps<T>
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Centers the content both vertically and horizontally. Elements are placed in a column (flex).
|
|
46
|
+
*
|
|
47
|
+
* This element accepts many style shortcuts as attributes: bg, fg, border, radius, justifyContent, alignItems, flex, gap, m, mt, mb, ml,
|
|
48
|
+
* mr, p, pt, pb, pl, pr, w, h.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```
|
|
52
|
+
* <Center w="200px" h="200px" gap="10px">
|
|
53
|
+
* <img src="/an-image.png" />
|
|
54
|
+
* <Text>This content is centered!</Text>
|
|
55
|
+
* </Center>
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export const Center = withRef(
|
|
59
|
+
function Center<T extends keyof HTMLTag = 'div'>({ tag, className, ...props }: CenterProps<T>) {
|
|
60
|
+
return createElement(tag || 'div', { className: listToClass(['center', className]), ...applyStyles(props) })
|
|
61
|
+
},
|
|
62
|
+
)
|
|
51
63
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Creates a row (flex). The elements in this row are horizontally centered unless `center = false`.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```
|
|
69
|
+
* <Row gap={3}>
|
|
70
|
+
* <Icon icon="Stack" />
|
|
71
|
+
* <Text>Stacks</Text>
|
|
72
|
+
* </Row>
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export const Row = withRef(
|
|
76
|
+
function Row<T extends keyof HTMLTag = 'div'>({ tag, className, center, ...props }: RowProps<T>) {
|
|
77
|
+
return createElement(
|
|
78
|
+
tag || 'div',
|
|
79
|
+
{ className: listToClass(['row', center === false && 'no-center', className]), ...applyStyles(props) },
|
|
80
|
+
)
|
|
81
|
+
},
|
|
82
|
+
)
|
|
55
83
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
84
|
+
/**
|
|
85
|
+
* Creates a column (flex). The elements in this row are placed at the start of the horizontal axis, unless `center = true`, in this case,
|
|
86
|
+
* they're centered.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```
|
|
90
|
+
* <Column gap={5}>
|
|
91
|
+
* <Text>Item 1</Text>
|
|
92
|
+
* <Text>Item 2</Text>
|
|
93
|
+
* <Text>Item 3</Text>
|
|
94
|
+
* </Row>
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export const Column = withRef(
|
|
98
|
+
function Column<T extends keyof HTMLTag = 'div'>({ tag, className, center, ...props }: ColumnProps<T>) {
|
|
99
|
+
return createElement(tag || 'div', { className: listToClass(['column', center && 'center', className]), ...applyStyles(props) })
|
|
100
|
+
},
|
|
101
|
+
)
|
package/src/index.ts
CHANGED
|
@@ -40,7 +40,6 @@ export * from './components/Skeleton'
|
|
|
40
40
|
export * from './components/Slider'
|
|
41
41
|
export * from './components/SmartTable'
|
|
42
42
|
export * from './components/Stepper'
|
|
43
|
-
export * from './components/Switch'
|
|
44
43
|
export * from './components/Table'
|
|
45
44
|
export * from './components/Tabs'
|
|
46
45
|
export * from './components/Tabs/TabController'
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ControlledInput, WithColorScheme } from '../types.js';
|
|
2
|
-
interface Props extends WithColorScheme {
|
|
3
|
-
value?: boolean;
|
|
4
|
-
onChange?: (value: boolean) => void;
|
|
5
|
-
children?: React.ReactNode;
|
|
6
|
-
}
|
|
7
|
-
export type SwitchProps = ControlledInput & Props;
|
|
8
|
-
export declare const Switch: ({ value, onChange, children, className, style, ...props }: SwitchProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
-
export {};
|
|
10
|
-
//# sourceMappingURL=Switch.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../../src/components/Switch.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAI3D,UAAU,KAAM,SAAQ,eAAe;IACrC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACpC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,MAAM,MAAM,WAAW,GAAG,eAAe,GAAG,KAAK,CAAA;AAEjD,eAAO,MAAM,MAAM,8DAAuE,WAAW,4CAiBnG,CAAA"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { withRef } from '../utils/react.js';
|
|
3
|
-
import { CitricComponent } from './CitricComponent.js';
|
|
4
|
-
export const Switch = withRef(({ value, onChange, children, className, style, ...props }) => {
|
|
5
|
-
const handleChange = onChange ? () => onChange(!value) : undefined;
|
|
6
|
-
return children ? (_jsxs(CitricComponent, { tag: "label", component: "switch-row", style: style, className: className, children: [_jsx("input", { type: "checkbox", checked: value, onChange: handleChange, ...props }), children] })) : _jsx(CitricComponent, { tag: "input", type: "checkbox", component: "switch", checked: value, onChange: handleChange, className: className, style: style, ...props });
|
|
7
|
-
});
|
|
8
|
-
//# sourceMappingURL=Switch.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Switch.js","sourceRoot":"","sources":["../../src/components/Switch.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAUnD,MAAM,CAAC,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,KAAK,EAAe,EAAE,EAAE;IACvG,MAAM,YAAY,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IAClE,OAAO,QAAQ,CAAC,CAAC,CAAC,CAChB,MAAC,eAAe,IAAC,GAAG,EAAC,OAAO,EAAC,SAAS,EAAC,YAAY,EAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,aACpF,gBAAO,IAAI,EAAC,UAAU,EAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,KAAM,KAAK,GAAI,EAC3E,QAAQ,IACO,CACnB,CAAC,CAAC,CAAC,KAAC,eAAe,IAClB,GAAG,EAAC,OAAO,EACX,IAAI,EAAC,UAAU,EACf,SAAS,EAAC,QAAQ,EAClB,OAAO,EAAE,KAAK,EACd,QAAQ,EAAE,YAAY,EACtB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,KACR,KAAK,GACT,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { ControlledInput, WithColorScheme } from '../types'
|
|
2
|
-
import { withRef } from '../utils/react'
|
|
3
|
-
import { CitricComponent } from './CitricComponent'
|
|
4
|
-
|
|
5
|
-
interface Props extends WithColorScheme {
|
|
6
|
-
value?: boolean,
|
|
7
|
-
onChange?: (value: boolean) => void,
|
|
8
|
-
children?: React.ReactNode,
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export type SwitchProps = ControlledInput & Props
|
|
12
|
-
|
|
13
|
-
export const Switch = withRef(({ value, onChange, children, className, style, ...props }: SwitchProps) => {
|
|
14
|
-
const handleChange = onChange ? () => onChange(!value) : undefined
|
|
15
|
-
return children ? (
|
|
16
|
-
<CitricComponent tag="label" component="switch-row" style={style} className={className}>
|
|
17
|
-
<input type="checkbox" checked={value} onChange={handleChange} {...props} />
|
|
18
|
-
{children}
|
|
19
|
-
</CitricComponent>
|
|
20
|
-
) : <CitricComponent
|
|
21
|
-
tag="input"
|
|
22
|
-
type="checkbox"
|
|
23
|
-
component="switch"
|
|
24
|
-
checked={value}
|
|
25
|
-
onChange={handleChange}
|
|
26
|
-
className={className}
|
|
27
|
-
style={style}
|
|
28
|
-
{...props}
|
|
29
|
-
/>
|
|
30
|
-
})
|