@stack-spot/citric-react 0.36.0 → 0.37.1-beta.1
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 +2844 -2832
- package/dist/components/Accordion.d.ts +1 -1
- package/dist/components/Accordion.js +1 -1
- package/dist/components/Alert.d.ts +1 -1
- package/dist/components/Alert.js +1 -1
- package/dist/components/AsyncContent.d.ts +1 -1
- package/dist/components/AsyncContent.js +1 -1
- package/dist/components/Avatar.d.ts +1 -1
- package/dist/components/Avatar.js +1 -1
- package/dist/components/AvatarGroup.d.ts +1 -1
- package/dist/components/AvatarGroup.js +1 -1
- package/dist/components/Badge.d.ts +1 -1
- package/dist/components/Badge.js +1 -1
- package/dist/components/Blockquote.d.ts +1 -1
- package/dist/components/Blockquote.js +1 -1
- package/dist/components/Breadcrumb.d.ts +1 -1
- package/dist/components/Breadcrumb.js +1 -1
- package/dist/components/Button.d.ts +1 -1
- package/dist/components/Button.js +1 -1
- package/dist/components/ButtonLink.d.ts +1 -1
- package/dist/components/ButtonLink.js +1 -1
- package/dist/components/Card.d.ts +1 -1
- package/dist/components/Card.js +1 -1
- package/dist/components/Checkbox.d.ts +1 -1
- package/dist/components/Checkbox.js +1 -1
- package/dist/components/CheckboxGroup.d.ts +1 -1
- package/dist/components/CheckboxGroup.js +1 -1
- package/dist/components/Circle.d.ts +1 -1
- package/dist/components/Circle.js +1 -1
- package/dist/components/Divider.d.ts +1 -1
- package/dist/components/Divider.js +1 -1
- package/dist/components/ErrorBoundary.d.ts +1 -1
- package/dist/components/ErrorBoundary.js +1 -1
- package/dist/components/ErrorMessage.d.ts +1 -1
- package/dist/components/ErrorMessage.js +1 -1
- package/dist/components/FallbackBoundary.d.ts +1 -1
- package/dist/components/FallbackBoundary.js +1 -1
- package/dist/components/Favorite.d.ts +1 -1
- package/dist/components/Favorite.js +1 -1
- package/dist/components/FieldGroup.d.ts +1 -1
- package/dist/components/FieldGroup.js +1 -1
- package/dist/components/Form.d.ts +2 -2
- package/dist/components/Form.js +1 -1
- package/dist/components/FormGroup.d.ts +1 -1
- package/dist/components/FormGroup.js +1 -1
- package/dist/components/Icon.d.ts +1 -1
- package/dist/components/Icon.js +1 -1
- package/dist/components/IconBox.d.ts +3 -3
- package/dist/components/IconBox.js +1 -1
- package/dist/components/ImageBox.d.ts +3 -3
- package/dist/components/ImageBox.js +1 -1
- package/dist/components/ImageWithFallback.d.ts +1 -1
- package/dist/components/ImageWithFallback.js +1 -1
- package/dist/components/Input.d.ts +1 -1
- package/dist/components/Input.js +1 -1
- package/dist/components/Link.d.ts +1 -1
- package/dist/components/Link.js +1 -1
- package/dist/components/LoadingPanel.d.ts +1 -1
- package/dist/components/LoadingPanel.js +1 -1
- package/dist/components/MenuOverlay/Menu.d.ts +1 -1
- package/dist/components/MenuOverlay/Menu.js +1 -1
- package/dist/components/MenuOverlay/index.d.ts +1 -1
- package/dist/components/MenuOverlay/index.js +1 -1
- package/dist/components/Overlay/index.d.ts +1 -1
- package/dist/components/Overlay/index.js +1 -1
- package/dist/components/Pagination.d.ts +1 -1
- package/dist/components/Pagination.js +1 -1
- package/dist/components/ProgressBar.d.ts +1 -1
- package/dist/components/ProgressBar.js +1 -1
- package/dist/components/ProgressCircular.d.ts +1 -1
- package/dist/components/ProgressCircular.js +1 -1
- package/dist/components/RadioGroup.d.ts +1 -1
- package/dist/components/RadioGroup.js +1 -1
- package/dist/components/Rating.d.ts +17 -3
- package/dist/components/Rating.d.ts.map +1 -1
- package/dist/components/Rating.js +11 -3
- package/dist/components/Rating.js.map +1 -1
- package/dist/components/Select/MultiSelect.d.ts +1 -1
- package/dist/components/Select/MultiSelect.js +1 -1
- package/dist/components/Select/RichSelect.d.ts +1 -1
- package/dist/components/Select/RichSelect.js +1 -1
- package/dist/components/Select/SimpleSelect.d.ts +1 -1
- package/dist/components/Select/SimpleSelect.js +1 -1
- package/dist/components/Select/index.d.ts +1 -1
- package/dist/components/Select/index.js +1 -1
- package/dist/components/SelectBox.d.ts +1 -1
- package/dist/components/SelectBox.js +1 -1
- package/dist/components/Skeleton.d.ts +1 -1
- package/dist/components/Skeleton.js +1 -1
- package/dist/components/Slider.d.ts +1 -1
- package/dist/components/Slider.js +1 -1
- package/dist/components/SmartTable.d.ts +1 -1
- package/dist/components/SmartTable.js +1 -1
- package/dist/components/Stepper.d.ts +1 -1
- package/dist/components/Stepper.js +1 -1
- package/dist/components/Table.d.ts +3 -3
- package/dist/components/Table.js +1 -1
- package/dist/components/Tabs/index.d.ts +1 -1
- package/dist/components/Tabs/index.js +1 -1
- package/dist/components/Textarea.d.ts +1 -1
- package/dist/components/Textarea.js +1 -1
- package/dist/components/Tooltip.d.ts +1 -1
- package/dist/components/Tooltip.js +1 -1
- package/dist/context/CitricProvider.d.ts +1 -1
- package/dist/context/CitricProvider.js +1 -1
- package/dist/overlay.js +1 -1
- package/dist/theme.css +415 -415
- package/package.json +2 -2
- package/scripts/build-css.ts +49 -49
- package/src/components/Accordion.tsx +130 -130
- package/src/components/Alert.tsx +24 -24
- package/src/components/AsyncContent.tsx +70 -70
- package/src/components/Avatar.tsx +45 -45
- package/src/components/AvatarGroup.tsx +49 -49
- package/src/components/Badge.tsx +47 -47
- package/src/components/Blockquote.tsx +18 -18
- package/src/components/Breadcrumb.tsx +33 -33
- package/src/components/Button.tsx +105 -105
- package/src/components/ButtonLink.tsx +45 -45
- package/src/components/Card.tsx +68 -68
- package/src/components/Checkbox.tsx +51 -51
- package/src/components/CheckboxGroup.tsx +152 -152
- package/src/components/Circle.tsx +43 -43
- package/src/components/CitricComponent.ts +47 -47
- package/src/components/Divider.tsx +24 -24
- package/src/components/ErrorBoundary.tsx +75 -75
- package/src/components/ErrorMessage.tsx +11 -11
- package/src/components/FallbackBoundary.tsx +40 -40
- package/src/components/Favorite.tsx +57 -57
- package/src/components/FieldGroup.tsx +46 -46
- package/src/components/Form.tsx +36 -36
- package/src/components/FormGroup.tsx +57 -57
- package/src/components/Icon.tsx +35 -35
- package/src/components/IconBox.tsx +134 -134
- package/src/components/ImageBox.tsx +125 -125
- package/src/components/ImageWithFallback.tsx +65 -65
- package/src/components/Input.tsx +49 -49
- package/src/components/Link.tsx +55 -55
- package/src/components/LoadingPanel.tsx +8 -8
- package/src/components/MenuOverlay/Menu.tsx +158 -158
- package/src/components/MenuOverlay/context.ts +20 -20
- package/src/components/MenuOverlay/index.tsx +55 -55
- package/src/components/MenuOverlay/keyboard.ts +60 -60
- package/src/components/MenuOverlay/types.ts +171 -171
- package/src/components/Overlay/context.ts +10 -10
- package/src/components/Overlay/index.tsx +164 -164
- package/src/components/Overlay/types.ts +70 -70
- package/src/components/Pagination.tsx +113 -113
- package/src/components/ProgressBar.tsx +45 -45
- package/src/components/ProgressCircular.tsx +45 -45
- package/src/components/RadioGroup.tsx +146 -146
- package/src/components/Rating.tsx +98 -35
- package/src/components/Select/MultiSelect.tsx +346 -217
- package/src/components/Select/RichSelect.tsx +128 -128
- package/src/components/Select/SimpleSelect.tsx +73 -73
- package/src/components/Select/hooks.ts +133 -133
- package/src/components/Select/index.tsx +35 -35
- package/src/components/Select/types.ts +134 -134
- package/src/components/SelectBox.tsx +167 -167
- package/src/components/Skeleton.tsx +53 -53
- package/src/components/Slider.tsx +89 -89
- package/src/components/SmartTable.tsx +227 -227
- package/src/components/Stepper.tsx +163 -163
- package/src/components/Table.tsx +234 -234
- package/src/components/Tabs/TabController.ts +54 -54
- package/src/components/Tabs/index.tsx +87 -87
- package/src/components/Tabs/types.ts +54 -54
- package/src/components/Tabs/utils.ts +6 -6
- package/src/components/Text.ts +111 -111
- package/src/components/Textarea.tsx +27 -27
- package/src/components/Tooltip.tsx +72 -72
- package/src/components/layout.tsx +101 -101
- package/src/context/CitricContext.tsx +4 -4
- package/src/context/CitricProvider.tsx +14 -14
- package/src/context/hooks.ts +6 -6
- package/src/index.ts +58 -58
- package/src/overlay.ts +341 -341
- package/src/types.ts +216 -216
- package/src/utils/ValueController.ts +28 -28
- package/src/utils/acessibility.ts +92 -92
- package/src/utils/checkbox.ts +121 -121
- package/src/utils/css.ts +119 -119
- package/src/utils/options.ts +9 -9
- package/src/utils/radio.ts +93 -93
- package/src/utils/react.ts +6 -6
- package/tsconfig.json +10 -10
package/src/types.ts
CHANGED
|
@@ -1,216 +1,216 @@
|
|
|
1
|
-
import { ColorKey, ColorPaletteName, ColorSchemeName } from '@stack-spot/portal-theme'
|
|
2
|
-
import { RadiusKey, SpacingKey } from '@stack-spot/portal-theme/dist/definition'
|
|
3
|
-
|
|
4
|
-
export interface WithColorScheme {
|
|
5
|
-
colorScheme?: ColorSchemeName,
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface WithColorPalette {
|
|
9
|
-
colorPalette?: ColorPaletteName,
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface WithColor {
|
|
13
|
-
color?: ColorKey,
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export type WithDataAttributes = { [key: `data-${string}`]: string | undefined }
|
|
17
|
-
|
|
18
|
-
export type TextAppearance = 'body1' | 'body2' | 'code1' | 'code2' | 'display1' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'microtext1' |
|
|
19
|
-
'overheader1' | 'overheader2' | 'subtitle1' | 'subtitle2' | 'subtitle3' | 'subtitle4'
|
|
20
|
-
|
|
21
|
-
// increase this list as needed. Generic uses of `JSX.IntrinsicElements` may lead to expensive operations.
|
|
22
|
-
export type HTMLTag = {
|
|
23
|
-
a: React.AnchorHTMLAttributes<HTMLAnchorElement>,
|
|
24
|
-
blockquote: React.BlockquoteHTMLAttributes<HTMLQuoteElement>,
|
|
25
|
-
button: React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
26
|
-
div: React.HTMLAttributes<HTMLDivElement>,
|
|
27
|
-
form: React.FormHTMLAttributes<HTMLFormElement>,
|
|
28
|
-
header: React.HTMLAttributes<HTMLElement>,
|
|
29
|
-
h1: React.HTMLAttributes<HTMLHeadingElement>,
|
|
30
|
-
h2: React.HTMLAttributes<HTMLHeadingElement>,
|
|
31
|
-
h3: React.HTMLAttributes<HTMLHeadingElement>,
|
|
32
|
-
h4: React.HTMLAttributes<HTMLHeadingElement>,
|
|
33
|
-
h5: React.HTMLAttributes<HTMLHeadingElement>,
|
|
34
|
-
h6: React.HTMLAttributes<HTMLHeadingElement>,
|
|
35
|
-
hr: React.HTMLAttributes<HTMLHRElement>,
|
|
36
|
-
i: React.HTMLAttributes<HTMLElement>,
|
|
37
|
-
image: React.ImgHTMLAttributes<HTMLImageElement>,
|
|
38
|
-
input: React.InputHTMLAttributes<HTMLInputElement>,
|
|
39
|
-
label: React.LabelHTMLAttributes<HTMLLabelElement>,
|
|
40
|
-
li: React.LiHTMLAttributes<HTMLLIElement>,
|
|
41
|
-
nav: React.HTMLAttributes<HTMLElement>,
|
|
42
|
-
p: React.HTMLAttributes<HTMLParagraphElement>,
|
|
43
|
-
pre: React.HTMLAttributes<HTMLPreElement>,
|
|
44
|
-
select: React.SelectHTMLAttributes<HTMLSelectElement>,
|
|
45
|
-
small: React.HTMLAttributes<HTMLElement>,
|
|
46
|
-
span: React.HTMLAttributes<HTMLSpanElement>,
|
|
47
|
-
table: React.TableHTMLAttributes<HTMLTableElement>,
|
|
48
|
-
td: React.TdHTMLAttributes<HTMLTableCellElement>,
|
|
49
|
-
th: React.ThHTMLAttributes<HTMLTableCellElement>,
|
|
50
|
-
tr: React.HTMLAttributes<HTMLTableRowElement>,
|
|
51
|
-
textarea: React.TextareaHTMLAttributes<HTMLTextAreaElement>,
|
|
52
|
-
ul: React.HTMLAttributes<HTMLUListElement>,
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export type ControlledInput = Omit<React.JSX.IntrinsicElements['input'], 'value' | 'onChange'>
|
|
56
|
-
export type ControlledTextarea = Omit<React.JSX.IntrinsicElements['textarea'], 'value' | 'onChange' | 'children'>
|
|
57
|
-
|
|
58
|
-
export interface WithStyleShortcuts {
|
|
59
|
-
/**
|
|
60
|
-
* Sets a theme color for the background.
|
|
61
|
-
*/
|
|
62
|
-
bg?: ColorKey,
|
|
63
|
-
/**
|
|
64
|
-
* Sets a theme color for the foreground.
|
|
65
|
-
*/
|
|
66
|
-
fg?: ColorKey,
|
|
67
|
-
/**
|
|
68
|
-
* Sets a theme color for the border and set it to 1px width.
|
|
69
|
-
*/
|
|
70
|
-
border?: ColorKey,
|
|
71
|
-
/**
|
|
72
|
-
* Sets the border radius.
|
|
73
|
-
*/
|
|
74
|
-
radius?: RadiusKey,
|
|
75
|
-
/**
|
|
76
|
-
* Sets the margin for every side.
|
|
77
|
-
*
|
|
78
|
-
* When a number is provided, the theme variable is used "spacing-1, ..., spacing-19". When a list of numbers is provided, the theme
|
|
79
|
-
* variable is used for each of the positions, following the CSS order ([top, right, bottom, left]) When a string is provided, this acts
|
|
80
|
-
* as a shortcut for `style.margin`.
|
|
81
|
-
*/
|
|
82
|
-
m?: SpacingKey | SpacingKey[] | string,
|
|
83
|
-
/**
|
|
84
|
-
* Sets the margin from the top.
|
|
85
|
-
*
|
|
86
|
-
* When a number is provided, the theme variable is used "spacing-1, ..., spacing-19". When a string is provided, this acts as a shortcut
|
|
87
|
-
* for `style.marginTop`.
|
|
88
|
-
*/
|
|
89
|
-
mt?: SpacingKey | string,
|
|
90
|
-
/**
|
|
91
|
-
* Sets the margin from the bottom.
|
|
92
|
-
*
|
|
93
|
-
* When a number is provided, the theme variable is used "spacing-1, ..., spacing-19". When a string is provided, this acts as a shortcut
|
|
94
|
-
* for `style.marginBottom`.
|
|
95
|
-
*/
|
|
96
|
-
mb?: SpacingKey | string,
|
|
97
|
-
/**
|
|
98
|
-
* Sets the margin from the left.
|
|
99
|
-
*
|
|
100
|
-
* When a number is provided, the theme variable is used "spacing-1, ..., spacing-19". When a string is provided, this acts as a shortcut
|
|
101
|
-
* for `style.marginLeft`.
|
|
102
|
-
*/
|
|
103
|
-
ml?: SpacingKey | string,
|
|
104
|
-
/**
|
|
105
|
-
* Sets the margin from the right.
|
|
106
|
-
*
|
|
107
|
-
* When a number is provided, the theme variable is used "spacing-1, ..., spacing-19". When a string is provided, this acts as a shortcut
|
|
108
|
-
* for `style.marginRight`.
|
|
109
|
-
*/
|
|
110
|
-
mr?: SpacingKey | string,
|
|
111
|
-
/**
|
|
112
|
-
* Sets the padding for every side.
|
|
113
|
-
*
|
|
114
|
-
* When a number is provided, the theme variable is used "spacing-1, ..., spacing-19". When a list of numbers is provided, the theme
|
|
115
|
-
* variable is used for each of the positions, following the CSS order ([top, right, bottom, left]) When a string is provided, this acts
|
|
116
|
-
* as a shortcut for `style.padding`.
|
|
117
|
-
*/
|
|
118
|
-
p?: SpacingKey | SpacingKey[] | string,
|
|
119
|
-
/**
|
|
120
|
-
* Sets the padding from the top.
|
|
121
|
-
*
|
|
122
|
-
* When a number is provided, the theme variable is used "spacing-1, ..., spacing-19". When a string is provided, this acts as a shortcut
|
|
123
|
-
* for `style.paddingTop`.
|
|
124
|
-
*/
|
|
125
|
-
pt?: SpacingKey | string,
|
|
126
|
-
/**
|
|
127
|
-
* Sets the padding from the bottom.
|
|
128
|
-
*
|
|
129
|
-
* When a number is provided, the theme variable is used "spacing-1, ..., spacing-19". When a string is provided, this acts as a shortcut
|
|
130
|
-
* for `style.paddingBottom`.
|
|
131
|
-
*/
|
|
132
|
-
pb?: SpacingKey | string,
|
|
133
|
-
/**
|
|
134
|
-
* Sets the padding from the left.
|
|
135
|
-
*
|
|
136
|
-
* When a number is provided, the theme variable is used "spacing-1, ..., spacing-19". When a string is provided, this acts as a shortcut
|
|
137
|
-
* for `style.paddingLeft`.
|
|
138
|
-
*/
|
|
139
|
-
pl?: SpacingKey | string,
|
|
140
|
-
/**
|
|
141
|
-
* Sets the padding from the right.
|
|
142
|
-
*
|
|
143
|
-
* When a number is provided, the theme variable is used "spacing-1, ..., spacing-19". When a string is provided, this acts as a shortcut
|
|
144
|
-
* for `style.paddingRight`.
|
|
145
|
-
*/
|
|
146
|
-
pr?: SpacingKey | string,
|
|
147
|
-
/**
|
|
148
|
-
* Shortcut for `style.width`.
|
|
149
|
-
*/
|
|
150
|
-
w?: string | number,
|
|
151
|
-
/**
|
|
152
|
-
* Shortcut for `style.height`.
|
|
153
|
-
*/
|
|
154
|
-
h?: string | number,
|
|
155
|
-
/**
|
|
156
|
-
* Shortcut for `style.flex`.
|
|
157
|
-
*/
|
|
158
|
-
flex?: React.CSSProperties['flex'],
|
|
159
|
-
/**
|
|
160
|
-
* Shortcut for `style.justifyContent`.
|
|
161
|
-
*/
|
|
162
|
-
justifyContent?: React.CSSProperties['justifyContent'],
|
|
163
|
-
/**
|
|
164
|
-
* Shortcut for `style.alignItems`.
|
|
165
|
-
*/
|
|
166
|
-
alignItems?: React.CSSProperties['alignItems'],
|
|
167
|
-
/**
|
|
168
|
-
* Shortcut for `style.gap`.
|
|
169
|
-
*/
|
|
170
|
-
gap?: React.CSSProperties['gap'],
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
export interface CitricController {
|
|
174
|
-
/**
|
|
175
|
-
* If set, instead of rendering the HTML tag "a", the Link component will render the return value of this function.
|
|
176
|
-
* @param props the props for the anchor element
|
|
177
|
-
* @returns
|
|
178
|
-
*/
|
|
179
|
-
renderLink?: (props: JSX.IntrinsicElements['a']) => React.ReactElement,
|
|
180
|
-
/**
|
|
181
|
-
* A function to run whenever the component Button is clicked.
|
|
182
|
-
* @param event the click event.
|
|
183
|
-
* @param metadata metadata of the button.
|
|
184
|
-
*/
|
|
185
|
-
onClickButton?: (event: React.MouseEvent<HTMLButtonElement>, metadata: any) => void,
|
|
186
|
-
/**
|
|
187
|
-
* A function to run whenever the component Link is clicked.
|
|
188
|
-
* @param event the click event.
|
|
189
|
-
* @param metadata metadata of the anchor.
|
|
190
|
-
*/
|
|
191
|
-
onClickLink?: (event: React.MouseEvent<HTMLAnchorElement>, metadata: any) => void,
|
|
192
|
-
/**
|
|
193
|
-
* A custom renderer for error feedbacks.
|
|
194
|
-
*
|
|
195
|
-
* By default, a simple text with the error message is rendered.
|
|
196
|
-
*
|
|
197
|
-
* Errors are rendered when they're caught in an ErrorBoundary or AsyncContent.
|
|
198
|
-
* @param error the error caught.
|
|
199
|
-
* @returns the UI for the feedback.
|
|
200
|
-
*/
|
|
201
|
-
renderError?: (error: any) => React.ReactElement,
|
|
202
|
-
/**
|
|
203
|
-
* A custom renderer for loading feedbacks.
|
|
204
|
-
*
|
|
205
|
-
* By default, the component "ProgressCircular" is rendered with some padding.
|
|
206
|
-
*
|
|
207
|
-
* Loadings are rendered in Suspended calls or in AsyncContent.
|
|
208
|
-
* @returns the UI for the feedback.
|
|
209
|
-
*/
|
|
210
|
-
renderLoading?: () => void,
|
|
211
|
-
/**
|
|
212
|
-
* Function to run whenever an Error is caught.
|
|
213
|
-
* @param error the error caught.
|
|
214
|
-
*/
|
|
215
|
-
onError?: (error: any) => void,
|
|
216
|
-
}
|
|
1
|
+
import { ColorKey, ColorPaletteName, ColorSchemeName } from '@stack-spot/portal-theme'
|
|
2
|
+
import { RadiusKey, SpacingKey } from '@stack-spot/portal-theme/dist/definition'
|
|
3
|
+
|
|
4
|
+
export interface WithColorScheme {
|
|
5
|
+
colorScheme?: ColorSchemeName,
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface WithColorPalette {
|
|
9
|
+
colorPalette?: ColorPaletteName,
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface WithColor {
|
|
13
|
+
color?: ColorKey,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type WithDataAttributes = { [key: `data-${string}`]: string | undefined }
|
|
17
|
+
|
|
18
|
+
export type TextAppearance = 'body1' | 'body2' | 'code1' | 'code2' | 'display1' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'microtext1' |
|
|
19
|
+
'overheader1' | 'overheader2' | 'subtitle1' | 'subtitle2' | 'subtitle3' | 'subtitle4'
|
|
20
|
+
|
|
21
|
+
// increase this list as needed. Generic uses of `JSX.IntrinsicElements` may lead to expensive operations.
|
|
22
|
+
export type HTMLTag = {
|
|
23
|
+
a: React.AnchorHTMLAttributes<HTMLAnchorElement>,
|
|
24
|
+
blockquote: React.BlockquoteHTMLAttributes<HTMLQuoteElement>,
|
|
25
|
+
button: React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
26
|
+
div: React.HTMLAttributes<HTMLDivElement>,
|
|
27
|
+
form: React.FormHTMLAttributes<HTMLFormElement>,
|
|
28
|
+
header: React.HTMLAttributes<HTMLElement>,
|
|
29
|
+
h1: React.HTMLAttributes<HTMLHeadingElement>,
|
|
30
|
+
h2: React.HTMLAttributes<HTMLHeadingElement>,
|
|
31
|
+
h3: React.HTMLAttributes<HTMLHeadingElement>,
|
|
32
|
+
h4: React.HTMLAttributes<HTMLHeadingElement>,
|
|
33
|
+
h5: React.HTMLAttributes<HTMLHeadingElement>,
|
|
34
|
+
h6: React.HTMLAttributes<HTMLHeadingElement>,
|
|
35
|
+
hr: React.HTMLAttributes<HTMLHRElement>,
|
|
36
|
+
i: React.HTMLAttributes<HTMLElement>,
|
|
37
|
+
image: React.ImgHTMLAttributes<HTMLImageElement>,
|
|
38
|
+
input: React.InputHTMLAttributes<HTMLInputElement>,
|
|
39
|
+
label: React.LabelHTMLAttributes<HTMLLabelElement>,
|
|
40
|
+
li: React.LiHTMLAttributes<HTMLLIElement>,
|
|
41
|
+
nav: React.HTMLAttributes<HTMLElement>,
|
|
42
|
+
p: React.HTMLAttributes<HTMLParagraphElement>,
|
|
43
|
+
pre: React.HTMLAttributes<HTMLPreElement>,
|
|
44
|
+
select: React.SelectHTMLAttributes<HTMLSelectElement>,
|
|
45
|
+
small: React.HTMLAttributes<HTMLElement>,
|
|
46
|
+
span: React.HTMLAttributes<HTMLSpanElement>,
|
|
47
|
+
table: React.TableHTMLAttributes<HTMLTableElement>,
|
|
48
|
+
td: React.TdHTMLAttributes<HTMLTableCellElement>,
|
|
49
|
+
th: React.ThHTMLAttributes<HTMLTableCellElement>,
|
|
50
|
+
tr: React.HTMLAttributes<HTMLTableRowElement>,
|
|
51
|
+
textarea: React.TextareaHTMLAttributes<HTMLTextAreaElement>,
|
|
52
|
+
ul: React.HTMLAttributes<HTMLUListElement>,
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export type ControlledInput = Omit<React.JSX.IntrinsicElements['input'], 'value' | 'onChange'>
|
|
56
|
+
export type ControlledTextarea = Omit<React.JSX.IntrinsicElements['textarea'], 'value' | 'onChange' | 'children'>
|
|
57
|
+
|
|
58
|
+
export interface WithStyleShortcuts {
|
|
59
|
+
/**
|
|
60
|
+
* Sets a theme color for the background.
|
|
61
|
+
*/
|
|
62
|
+
bg?: ColorKey,
|
|
63
|
+
/**
|
|
64
|
+
* Sets a theme color for the foreground.
|
|
65
|
+
*/
|
|
66
|
+
fg?: ColorKey,
|
|
67
|
+
/**
|
|
68
|
+
* Sets a theme color for the border and set it to 1px width.
|
|
69
|
+
*/
|
|
70
|
+
border?: ColorKey,
|
|
71
|
+
/**
|
|
72
|
+
* Sets the border radius.
|
|
73
|
+
*/
|
|
74
|
+
radius?: RadiusKey,
|
|
75
|
+
/**
|
|
76
|
+
* Sets the margin for every side.
|
|
77
|
+
*
|
|
78
|
+
* When a number is provided, the theme variable is used "spacing-1, ..., spacing-19". When a list of numbers is provided, the theme
|
|
79
|
+
* variable is used for each of the positions, following the CSS order ([top, right, bottom, left]) When a string is provided, this acts
|
|
80
|
+
* as a shortcut for `style.margin`.
|
|
81
|
+
*/
|
|
82
|
+
m?: SpacingKey | SpacingKey[] | string,
|
|
83
|
+
/**
|
|
84
|
+
* Sets the margin from the top.
|
|
85
|
+
*
|
|
86
|
+
* When a number is provided, the theme variable is used "spacing-1, ..., spacing-19". When a string is provided, this acts as a shortcut
|
|
87
|
+
* for `style.marginTop`.
|
|
88
|
+
*/
|
|
89
|
+
mt?: SpacingKey | string,
|
|
90
|
+
/**
|
|
91
|
+
* Sets the margin from the bottom.
|
|
92
|
+
*
|
|
93
|
+
* When a number is provided, the theme variable is used "spacing-1, ..., spacing-19". When a string is provided, this acts as a shortcut
|
|
94
|
+
* for `style.marginBottom`.
|
|
95
|
+
*/
|
|
96
|
+
mb?: SpacingKey | string,
|
|
97
|
+
/**
|
|
98
|
+
* Sets the margin from the left.
|
|
99
|
+
*
|
|
100
|
+
* When a number is provided, the theme variable is used "spacing-1, ..., spacing-19". When a string is provided, this acts as a shortcut
|
|
101
|
+
* for `style.marginLeft`.
|
|
102
|
+
*/
|
|
103
|
+
ml?: SpacingKey | string,
|
|
104
|
+
/**
|
|
105
|
+
* Sets the margin from the right.
|
|
106
|
+
*
|
|
107
|
+
* When a number is provided, the theme variable is used "spacing-1, ..., spacing-19". When a string is provided, this acts as a shortcut
|
|
108
|
+
* for `style.marginRight`.
|
|
109
|
+
*/
|
|
110
|
+
mr?: SpacingKey | string,
|
|
111
|
+
/**
|
|
112
|
+
* Sets the padding for every side.
|
|
113
|
+
*
|
|
114
|
+
* When a number is provided, the theme variable is used "spacing-1, ..., spacing-19". When a list of numbers is provided, the theme
|
|
115
|
+
* variable is used for each of the positions, following the CSS order ([top, right, bottom, left]) When a string is provided, this acts
|
|
116
|
+
* as a shortcut for `style.padding`.
|
|
117
|
+
*/
|
|
118
|
+
p?: SpacingKey | SpacingKey[] | string,
|
|
119
|
+
/**
|
|
120
|
+
* Sets the padding from the top.
|
|
121
|
+
*
|
|
122
|
+
* When a number is provided, the theme variable is used "spacing-1, ..., spacing-19". When a string is provided, this acts as a shortcut
|
|
123
|
+
* for `style.paddingTop`.
|
|
124
|
+
*/
|
|
125
|
+
pt?: SpacingKey | string,
|
|
126
|
+
/**
|
|
127
|
+
* Sets the padding from the bottom.
|
|
128
|
+
*
|
|
129
|
+
* When a number is provided, the theme variable is used "spacing-1, ..., spacing-19". When a string is provided, this acts as a shortcut
|
|
130
|
+
* for `style.paddingBottom`.
|
|
131
|
+
*/
|
|
132
|
+
pb?: SpacingKey | string,
|
|
133
|
+
/**
|
|
134
|
+
* Sets the padding from the left.
|
|
135
|
+
*
|
|
136
|
+
* When a number is provided, the theme variable is used "spacing-1, ..., spacing-19". When a string is provided, this acts as a shortcut
|
|
137
|
+
* for `style.paddingLeft`.
|
|
138
|
+
*/
|
|
139
|
+
pl?: SpacingKey | string,
|
|
140
|
+
/**
|
|
141
|
+
* Sets the padding from the right.
|
|
142
|
+
*
|
|
143
|
+
* When a number is provided, the theme variable is used "spacing-1, ..., spacing-19". When a string is provided, this acts as a shortcut
|
|
144
|
+
* for `style.paddingRight`.
|
|
145
|
+
*/
|
|
146
|
+
pr?: SpacingKey | string,
|
|
147
|
+
/**
|
|
148
|
+
* Shortcut for `style.width`.
|
|
149
|
+
*/
|
|
150
|
+
w?: string | number,
|
|
151
|
+
/**
|
|
152
|
+
* Shortcut for `style.height`.
|
|
153
|
+
*/
|
|
154
|
+
h?: string | number,
|
|
155
|
+
/**
|
|
156
|
+
* Shortcut for `style.flex`.
|
|
157
|
+
*/
|
|
158
|
+
flex?: React.CSSProperties['flex'],
|
|
159
|
+
/**
|
|
160
|
+
* Shortcut for `style.justifyContent`.
|
|
161
|
+
*/
|
|
162
|
+
justifyContent?: React.CSSProperties['justifyContent'],
|
|
163
|
+
/**
|
|
164
|
+
* Shortcut for `style.alignItems`.
|
|
165
|
+
*/
|
|
166
|
+
alignItems?: React.CSSProperties['alignItems'],
|
|
167
|
+
/**
|
|
168
|
+
* Shortcut for `style.gap`.
|
|
169
|
+
*/
|
|
170
|
+
gap?: React.CSSProperties['gap'],
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export interface CitricController {
|
|
174
|
+
/**
|
|
175
|
+
* If set, instead of rendering the HTML tag "a", the Link component will render the return value of this function.
|
|
176
|
+
* @param props the props for the anchor element
|
|
177
|
+
* @returns
|
|
178
|
+
*/
|
|
179
|
+
renderLink?: (props: JSX.IntrinsicElements['a']) => React.ReactElement,
|
|
180
|
+
/**
|
|
181
|
+
* A function to run whenever the component Button is clicked.
|
|
182
|
+
* @param event the click event.
|
|
183
|
+
* @param metadata metadata of the button.
|
|
184
|
+
*/
|
|
185
|
+
onClickButton?: (event: React.MouseEvent<HTMLButtonElement>, metadata: any) => void,
|
|
186
|
+
/**
|
|
187
|
+
* A function to run whenever the component Link is clicked.
|
|
188
|
+
* @param event the click event.
|
|
189
|
+
* @param metadata metadata of the anchor.
|
|
190
|
+
*/
|
|
191
|
+
onClickLink?: (event: React.MouseEvent<HTMLAnchorElement>, metadata: any) => void,
|
|
192
|
+
/**
|
|
193
|
+
* A custom renderer for error feedbacks.
|
|
194
|
+
*
|
|
195
|
+
* By default, a simple text with the error message is rendered.
|
|
196
|
+
*
|
|
197
|
+
* Errors are rendered when they're caught in an ErrorBoundary or AsyncContent.
|
|
198
|
+
* @param error the error caught.
|
|
199
|
+
* @returns the UI for the feedback.
|
|
200
|
+
*/
|
|
201
|
+
renderError?: (error: any) => React.ReactElement,
|
|
202
|
+
/**
|
|
203
|
+
* A custom renderer for loading feedbacks.
|
|
204
|
+
*
|
|
205
|
+
* By default, the component "ProgressCircular" is rendered with some padding.
|
|
206
|
+
*
|
|
207
|
+
* Loadings are rendered in Suspended calls or in AsyncContent.
|
|
208
|
+
* @returns the UI for the feedback.
|
|
209
|
+
*/
|
|
210
|
+
renderLoading?: () => void,
|
|
211
|
+
/**
|
|
212
|
+
* Function to run whenever an Error is caught.
|
|
213
|
+
* @param error the error caught.
|
|
214
|
+
*/
|
|
215
|
+
onError?: (error: any) => void,
|
|
216
|
+
}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { pull } from 'lodash'
|
|
2
|
-
|
|
3
|
-
export type ValueListener<T> = (value: T) => void
|
|
4
|
-
|
|
5
|
-
export class ValueController<T> {
|
|
6
|
-
protected value: T
|
|
7
|
-
private listeners: ValueListener<T>[] = []
|
|
8
|
-
|
|
9
|
-
constructor(value: T) {
|
|
10
|
-
this.value = value
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
onChange(listener: ValueListener<T>) {
|
|
14
|
-
this.listeners.push(listener)
|
|
15
|
-
return () => {
|
|
16
|
-
pull(this.listeners, listener)
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
setValue(value: T) {
|
|
21
|
-
this.value = value
|
|
22
|
-
this.listeners.forEach(l => l(value))
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
getValue() {
|
|
26
|
-
return this.value
|
|
27
|
-
}
|
|
28
|
-
}
|
|
1
|
+
import { pull } from 'lodash'
|
|
2
|
+
|
|
3
|
+
export type ValueListener<T> = (value: T) => void
|
|
4
|
+
|
|
5
|
+
export class ValueController<T> {
|
|
6
|
+
protected value: T
|
|
7
|
+
private listeners: ValueListener<T>[] = []
|
|
8
|
+
|
|
9
|
+
constructor(value: T) {
|
|
10
|
+
this.value = value
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
onChange(listener: ValueListener<T>) {
|
|
14
|
+
this.listeners.push(listener)
|
|
15
|
+
return () => {
|
|
16
|
+
pull(this.listeners, listener)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
setValue(value: T) {
|
|
21
|
+
this.value = value
|
|
22
|
+
this.listeners.forEach(l => l(value))
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
getValue() {
|
|
26
|
+
return this.value
|
|
27
|
+
}
|
|
28
|
+
}
|