onekijs-ui 0.18.2 → 0.19.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/components/accordion/AccordionService.d.ts +2 -1
- package/dist/components/accordion/components/AccordionComponent.d.ts +1 -1
- package/dist/components/accordion/hooks/useAccordionPanel.d.ts +1 -1
- package/dist/components/accordion/index.d.ts +1 -1
- package/dist/components/accordion/typings.d.ts +5 -3
- package/dist/components/button/typings.d.ts +1 -0
- package/dist/components/icon/RefreshIcon.d.ts +4 -0
- package/dist/components/list/components/CollectionListComponent.d.ts +1 -1
- package/dist/components/list/components/ListBodyComponent.d.ts +1 -1
- package/dist/components/list/components/LoadingItem.d.ts +1 -0
- package/dist/components/list/components/VirtualListComponent.d.ts +1 -1
- package/dist/components/table/components/TableActionComponent.d.ts +3 -0
- package/dist/components/table/components/TableLoadingComponent.d.ts +1 -1
- package/dist/components/table/components/TableLoadingRowComponent.d.ts +2 -1
- package/dist/components/table/typings.d.ts +5 -0
- package/dist/index.js +190 -60
- package/dist/index.js.map +1 -1
- package/dist/index.module.js +190 -60
- package/dist/index.module.js.map +1 -1
- package/dist/styles/border.d.ts +1 -1
- package/dist/styles/size.d.ts +6 -6
- package/dist/styles/typings.d.ts +21 -7
- package/dist/styles/typography.d.ts +2 -2
- package/package.json +3 -3
- package/src/components/accordion/AccordionService.ts +21 -6
- package/src/components/accordion/components/AccordionComponent.tsx +2 -2
- package/src/components/accordion/components/AccordionPanel.tsx +6 -3
- package/src/components/accordion/hooks/useAccordionPanel.ts +2 -2
- package/src/components/accordion/index.ts +1 -1
- package/src/components/accordion/style.ts +2 -2
- package/src/components/accordion/typings.ts +5 -3
- package/src/components/button/style.ts +16 -7
- package/src/components/button/typings.ts +1 -0
- package/src/components/icon/RefreshIcon.tsx +41 -0
- package/src/components/list/components/CollectionListComponent.tsx +1 -1
- package/src/components/list/components/ListBodyComponent.tsx +18 -5
- package/src/components/list/components/LoadingItem.tsx +4 -2
- package/src/components/list/components/VirtualListComponent.tsx +2 -2
- package/src/components/list/hooks/useListView.tsx +4 -1
- package/src/components/notifications/components/NotificationsComponent.tsx +7 -1
- package/src/components/notifications/style.ts +13 -2
- package/src/components/select/components/SelectOptionComponent.tsx +4 -2
- package/src/components/table/components/ControllerTableComponent.tsx +38 -19
- package/src/components/table/components/TableActionComponent.tsx +22 -0
- package/src/components/table/components/TableBodyComponent.tsx +12 -4
- package/src/components/table/components/TableBodyRowComponent.tsx +15 -14
- package/src/components/table/components/TableLoadingComponent.tsx +1 -1
- package/src/components/table/components/TableLoadingRowComponent.tsx +7 -3
- package/src/components/table/style.ts +16 -1
- package/src/components/table/typings.ts +5 -0
- package/src/styles/typings.ts +21 -7
- package/src/theme/base.tsx +21 -7
package/dist/styles/border.d.ts
CHANGED
|
@@ -36,4 +36,4 @@ export declare const borderTopWidth: import("./typings").CssProperty<string | nu
|
|
|
36
36
|
export declare const borderBottomWidth: import("./typings").CssProperty<string | number>;
|
|
37
37
|
export declare const borderLeftWidth: import("./typings").CssProperty<string | number>;
|
|
38
38
|
export declare const borderRightWidth: import("./typings").CssProperty<string | number>;
|
|
39
|
-
export declare const boxShadow: import("./typings").CssProperty<"
|
|
39
|
+
export declare const boxShadow: import("./typings").CssProperty<"sm" | "md" | "lg" | "xl" | "xs" | "2xl" | "default" | "inner" | "outline" | Property.BoxShadow>;
|
package/dist/styles/size.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Property } from 'csstype';
|
|
2
|
-
export declare const width: import("./typings").CssProperty<string | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 12 | 16 | 20 | 24 | 32 | 40 | 48 | 56 | 64
|
|
3
|
-
export declare const minWidth: import("./typings").CssProperty<string | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 12 | 16 | 20 | 24 | 32 | 40 | 48 | 56 | 64
|
|
4
|
-
export declare const maxWidth: import("./typings").CssProperty<string | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 12 | 16 | 20 | 24 | 32 | 40 | 48 | 56 | 64
|
|
5
|
-
export declare const height: import("./typings").CssProperty<string | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 12 | 16 | 20 | 24 | 32 | 40 | 48 | 56 | 64
|
|
6
|
-
export declare const minHeight: import("./typings").CssProperty<string | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 12 | 16 | 20 | 24 | 32 | 40 | 48 | 56 | 64
|
|
7
|
-
export declare const maxHeight: import("./typings").CssProperty<string | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 12 | 16 | 20 | 24 | 32 | 40 | 48 | 56 | 64
|
|
2
|
+
export declare const width: import("./typings").CssProperty<string | 0 | (string & {}) | 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 12 | 16 | 20 | 24 | 32 | 40 | 48 | 56 | 64>;
|
|
3
|
+
export declare const minWidth: import("./typings").CssProperty<string | 0 | (string & {}) | 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 12 | 16 | 20 | 24 | 32 | 40 | 48 | 56 | 64>;
|
|
4
|
+
export declare const maxWidth: import("./typings").CssProperty<string | 0 | (string & {}) | 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 12 | 16 | 20 | 24 | 32 | 40 | 48 | 56 | 64>;
|
|
5
|
+
export declare const height: import("./typings").CssProperty<string | 0 | (string & {}) | 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 12 | 16 | 20 | 24 | 32 | 40 | 48 | 56 | 64>;
|
|
6
|
+
export declare const minHeight: import("./typings").CssProperty<string | 0 | (string & {}) | 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 12 | 16 | 20 | 24 | 32 | 40 | 48 | 56 | 64>;
|
|
7
|
+
export declare const maxHeight: import("./typings").CssProperty<string | 0 | (string & {}) | 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 12 | 16 | 20 | 24 | 32 | 40 | 48 | 56 | 64>;
|
|
8
8
|
export declare const overscrollBehavior: import("./typings").CssProperty<Property.OverscrollBehavior>;
|
|
9
9
|
export declare const overscrollBehaviorBlock: import("./typings").CssProperty<Property.OverscrollBehaviorBlock>;
|
|
10
10
|
export declare const overscrollBehaviorInline: import("./typings").CssProperty<Property.OverscrollBehaviorInline>;
|
package/dist/styles/typings.d.ts
CHANGED
|
@@ -235,15 +235,21 @@ export type Theme = {
|
|
|
235
235
|
borderColor: ColorPropertyTheme | Property.BorderColor;
|
|
236
236
|
borderColorFlat: ColorPropertyTheme | Property.BackgroundColor;
|
|
237
237
|
borderColorOutline: ColorPropertyTheme | Property.BackgroundColor;
|
|
238
|
-
|
|
238
|
+
borderRadiusMedium: RadiusPropertyTheme | string;
|
|
239
|
+
borderRadiusSmall: RadiusPropertyTheme | string;
|
|
240
|
+
borderRadiusLarge: RadiusPropertyTheme | string;
|
|
239
241
|
borderStyle: Property.BorderStyle;
|
|
240
|
-
|
|
242
|
+
borderWidthSmall: Property.BorderWidth<TLength>;
|
|
243
|
+
borderWidthMedium: Property.BorderWidth<TLength>;
|
|
244
|
+
borderWidthLarge: Property.BorderWidth<TLength>;
|
|
241
245
|
color: ColorPropertyTheme | Property.Color;
|
|
242
246
|
colorFlat: ColorPropertyTheme | Property.BackgroundColor;
|
|
243
247
|
colorOutline: ColorPropertyTheme | Property.BackgroundColor;
|
|
244
248
|
cursor: Property.Cursor;
|
|
245
249
|
cursorDisabled: Property.Cursor;
|
|
246
|
-
|
|
250
|
+
fontSizeMedium: FontSizePropertyTheme | Property.FontSize<TLength>;
|
|
251
|
+
fontSmallSize: FontSizePropertyTheme | Property.FontSize<TLength>;
|
|
252
|
+
fontLargeSize: FontSizePropertyTheme | Property.FontSize<TLength>;
|
|
247
253
|
fontWeight: FontWeightPropertyTheme | Property.FontWeight;
|
|
248
254
|
hoverBgColor: ColorPropertyTheme | Property.BackgroundColor;
|
|
249
255
|
hoverBgColorFlat: ColorPropertyTheme | Property.BackgroundColor;
|
|
@@ -254,12 +260,20 @@ export type Theme = {
|
|
|
254
260
|
hoverColor: ColorPropertyTheme | Property.Color;
|
|
255
261
|
hoverColorFlat: ColorPropertyTheme | Property.BackgroundColor;
|
|
256
262
|
hoverColorOutline: ColorPropertyTheme | Property.BackgroundColor;
|
|
257
|
-
|
|
258
|
-
|
|
263
|
+
letterSpacingSmall: LetterSpacingPropertyTheme | Property.LetterSpacing<TLength>;
|
|
264
|
+
letterSpacingMedium: LetterSpacingPropertyTheme | Property.LetterSpacing<TLength>;
|
|
265
|
+
letterSpacingLarge: LetterSpacingPropertyTheme | Property.LetterSpacing<TLength>;
|
|
266
|
+
lineHeightSmall: LineHeightPropertyTheme | Property.LineHeight<TLength>;
|
|
267
|
+
lineHeightMedium: LineHeightPropertyTheme | Property.LineHeight<TLength>;
|
|
268
|
+
lineHeightLarge: LineHeightPropertyTheme | Property.LineHeight<TLength>;
|
|
259
269
|
opacity: Property.Opacity;
|
|
260
270
|
opacityDisabled: Property.Opacity;
|
|
261
|
-
|
|
262
|
-
|
|
271
|
+
paddingYMedium: SpacingPropertyTheme | Property.Padding<TLength>;
|
|
272
|
+
paddingXMedium: SpacingPropertyTheme | Property.Padding<TLength>;
|
|
273
|
+
paddingYSmall: SpacingPropertyTheme | Property.Padding<TLength>;
|
|
274
|
+
paddingXSmall: SpacingPropertyTheme | Property.Padding<TLength>;
|
|
275
|
+
paddingYLarge: SpacingPropertyTheme | Property.Padding<TLength>;
|
|
276
|
+
paddingXLarge: SpacingPropertyTheme | Property.Padding<TLength>;
|
|
263
277
|
textOverflow: Property.TextOverflow;
|
|
264
278
|
textTransform: Property.TextTransform;
|
|
265
279
|
whiteSpace: Property.WhiteSpace;
|
|
@@ -20,10 +20,10 @@ export declare const fontVariantLigatures: import("./typings").CssProperty<Prope
|
|
|
20
20
|
export declare const fontVariantNumeric: import("./typings").CssProperty<Property.FontVariantNumeric>;
|
|
21
21
|
export declare const fontVariantPosition: import("./typings").CssProperty<Property.FontVariantPosition>;
|
|
22
22
|
export declare const fontVariationSettings: import("./typings").CssProperty<Property.FontVariationSettings>;
|
|
23
|
-
export declare const fontWeight: import("./typings").CssProperty<number | "
|
|
23
|
+
export declare const fontWeight: import("./typings").CssProperty<number | "medium" | (string & {}) | "-moz-initial" | "inherit" | "initial" | "revert" | "revert-layer" | "unset" | "lighter" | "light" | "black" | "hairline" | "thin" | "normal" | "semibold" | "bold" | "extrabold" | (number & {}) | "bolder">;
|
|
24
24
|
export declare const hyphens: import("./typings").CssProperty<Property.Hyphens>;
|
|
25
25
|
export declare const letterSpacing: import("./typings").CssProperty<Property.LetterSpacing<TLength>>;
|
|
26
|
-
export declare const lineHeight: import("./typings").CssProperty<string | 0 | 4 | 5 | 6 | 8 | 10 | (
|
|
26
|
+
export declare const lineHeight: import("./typings").CssProperty<string | 0 | (string & {}) | 4 | 5 | 6 | 8 | 10 | (number & {}) | 7 | 9>;
|
|
27
27
|
export declare const lineHeightStep: import("./typings").CssProperty<Property.LineHeightStep<TLength>>;
|
|
28
28
|
export declare const overflowWrap: import("./typings").CssProperty<Property.OverflowWrap>;
|
|
29
29
|
export declare const textAlign: import("./typings").CssProperty<Property.TextAlign>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "onekijs-ui",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.19.0",
|
|
5
5
|
"description": "Opiniated React framework built on top of Next.js",
|
|
6
6
|
"source": "src/index.ts",
|
|
7
7
|
"main": "dist/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@clr/city": "^1.1.0",
|
|
35
35
|
"@popperjs/core": "^2.4.4",
|
|
36
36
|
"@reach/observe-rect": "^1.2.0",
|
|
37
|
-
"onekijs-framework": "^0.
|
|
37
|
+
"onekijs-framework": "^0.19.0",
|
|
38
38
|
"react-popper": "^2.3.0",
|
|
39
39
|
"react-popper-tooltip": "^4.4.2",
|
|
40
40
|
"react-virtualized-auto-sizer": "^1.0.2",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"react-dom": ">=18"
|
|
54
54
|
},
|
|
55
55
|
"sideEffects": false,
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "90231c6bc045c8c24e38ea82f76a3c39660c02b3"
|
|
57
57
|
}
|
|
@@ -4,20 +4,33 @@ import { AccordionState } from './typings';
|
|
|
4
4
|
@service
|
|
5
5
|
export class AccordionService extends DefaultService<AccordionState> {
|
|
6
6
|
@reducer
|
|
7
|
-
initPanel(uid: string, initialActive = false): void {
|
|
7
|
+
initPanel(uid: string, initialActive = false, initialExpand = false): void {
|
|
8
8
|
if (this.state.panels[uid] === undefined) {
|
|
9
9
|
this.state.panels[uid] = {
|
|
10
10
|
uid,
|
|
11
11
|
active: initialActive,
|
|
12
|
+
expanded: initialExpand,
|
|
12
13
|
};
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
16
|
|
|
17
|
+
@reducer
|
|
18
|
+
activate(uid: string): void {
|
|
19
|
+
const panel = this.state.panels[uid];
|
|
20
|
+
if (panel) {
|
|
21
|
+
Object.keys(this.state.panels).forEach((uid) => {
|
|
22
|
+
this.state.panels[uid].active = false;
|
|
23
|
+
});
|
|
24
|
+
panel.active = true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
16
28
|
@reducer
|
|
17
29
|
collapse(uid: string): void {
|
|
18
30
|
const panel = this.state.panels[uid];
|
|
19
31
|
if (panel) {
|
|
20
32
|
panel.active = false;
|
|
33
|
+
panel.expanded = false;
|
|
21
34
|
}
|
|
22
35
|
}
|
|
23
36
|
|
|
@@ -25,11 +38,13 @@ export class AccordionService extends DefaultService<AccordionState> {
|
|
|
25
38
|
expand(uid: string): void {
|
|
26
39
|
const panel = this.state.panels[uid];
|
|
27
40
|
if (panel) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
41
|
+
Object.keys(this.state.panels).forEach((uid) => {
|
|
42
|
+
this.state.panels[uid].active = false;
|
|
43
|
+
if (!this.state.multiExpand) {
|
|
44
|
+
this.state.panels[uid].expanded = false;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
panel.expanded = true;
|
|
33
48
|
panel.active = true;
|
|
34
49
|
}
|
|
35
50
|
}
|
|
@@ -11,7 +11,7 @@ import AccordionContainer from './AccordionContainer';
|
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
13
|
* ```tsx
|
|
14
|
-
* <AccordionComponent
|
|
14
|
+
* <AccordionComponent multiExpand="true" />
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
17
17
|
* @group Accordion
|
|
@@ -20,7 +20,7 @@ import AccordionContainer from './AccordionContainer';
|
|
|
20
20
|
*/
|
|
21
21
|
const AccordionComponent: FCC<AccordionProps> = ({ Component = AccordionContainer, ...props }) => {
|
|
22
22
|
const [state, service] = useService(AccordionService, {
|
|
23
|
-
|
|
23
|
+
multiExpand: props.multiExpand,
|
|
24
24
|
panels: {},
|
|
25
25
|
animate: props.animate ?? 150,
|
|
26
26
|
mode: props.mode ?? 'push',
|
|
@@ -10,15 +10,18 @@ import AccordionPanelTitle from './AccordionPanelTitle';
|
|
|
10
10
|
const AccordionPanel: FCC<AccordionPanelProps<any>> = ({
|
|
11
11
|
title,
|
|
12
12
|
initialActive,
|
|
13
|
+
initialExpand,
|
|
13
14
|
children,
|
|
14
15
|
Component = AccordionPanelTitle,
|
|
15
16
|
link,
|
|
16
17
|
}) => {
|
|
17
|
-
|
|
18
|
+
initialExpand = initialExpand ?? initialActive;
|
|
19
|
+
const panel = useAccordionPanel(initialActive, initialExpand);
|
|
18
20
|
const service = useAccordionService();
|
|
19
21
|
const { animate } = useAccordionState();
|
|
20
22
|
const router = useTryRouter();
|
|
21
23
|
|
|
24
|
+
|
|
22
25
|
const toggle = () => {
|
|
23
26
|
if (!panel) return;
|
|
24
27
|
if (link) {
|
|
@@ -60,7 +63,7 @@ const AccordionPanel: FCC<AccordionPanelProps<any>> = ({
|
|
|
60
63
|
<div className={`o-accordion-panel${panel.active ? ' o-accordion-panel-active' : ''}`}>
|
|
61
64
|
<Component title={title} active={panel.active} onClick={toggle} link={link} />
|
|
62
65
|
<CSSTransition
|
|
63
|
-
in={panel.
|
|
66
|
+
in={panel.expanded}
|
|
64
67
|
classNames="o-accordion-animate"
|
|
65
68
|
timeout={animate}
|
|
66
69
|
mountOnEnter={false}
|
|
@@ -70,7 +73,7 @@ const AccordionPanel: FCC<AccordionPanelProps<any>> = ({
|
|
|
70
73
|
onEntering={onEntering}
|
|
71
74
|
onEntered={onEntered}
|
|
72
75
|
>
|
|
73
|
-
<div>{
|
|
76
|
+
<div>{<div className="o-accordion-content">{children}</div>}</div>
|
|
74
77
|
</CSSTransition>
|
|
75
78
|
</div>
|
|
76
79
|
);
|
|
@@ -3,14 +3,14 @@ import { AccordionPanelState } from '../typings';
|
|
|
3
3
|
import useAccordionService from './useAccordionService';
|
|
4
4
|
import { useAccordionState } from './useAccordionState';
|
|
5
5
|
|
|
6
|
-
const useAccordionPanel = (initialActive = false): AccordionPanelState | undefined => {
|
|
6
|
+
const useAccordionPanel = (initialActive = false, initialExpand = false): AccordionPanelState | undefined => {
|
|
7
7
|
const uid = useId();
|
|
8
8
|
const service = useAccordionService();
|
|
9
9
|
const state = useAccordionState();
|
|
10
10
|
const panel = state.panels[uid];
|
|
11
11
|
useEffect(() => {
|
|
12
12
|
if (panel === undefined) {
|
|
13
|
-
service.initPanel(uid, initialActive);
|
|
13
|
+
service.initPanel(uid, initialActive, initialExpand);
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
return panel;
|
|
@@ -45,11 +45,11 @@ export const accordionStyle: ComponentStyle<AccordionProps> = ({ border = false,
|
|
|
45
45
|
|
|
46
46
|
.o-accordion-panel-active {
|
|
47
47
|
.o-accordion-panel-title {
|
|
48
|
-
${backgroundColor(t.activeBgColor, { hover: t.
|
|
48
|
+
${backgroundColor(t.activeBgColor, { hover: t.activeBgColor })}
|
|
49
49
|
${color(t.activeFontColor, { hover: t.activeFontColor })}
|
|
50
50
|
}
|
|
51
51
|
.o-accordion-content {
|
|
52
|
-
|
|
52
|
+
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -2,6 +2,7 @@ import { AnonymousObject, AnyFunction, FCC } from 'onekijs-framework';
|
|
|
2
2
|
|
|
3
3
|
export type AccordionPanelProps<T = string> = {
|
|
4
4
|
initialActive?: boolean;
|
|
5
|
+
initialExpand?: boolean;
|
|
5
6
|
title: T;
|
|
6
7
|
Component?: FCC<AccordionPanelTitleProps<T>>;
|
|
7
8
|
link?: string;
|
|
@@ -19,6 +20,7 @@ export type AccordionPanelState = {
|
|
|
19
20
|
uid: string;
|
|
20
21
|
collapsing?: boolean;
|
|
21
22
|
expanding?: boolean;
|
|
23
|
+
expanded?: boolean;
|
|
22
24
|
};
|
|
23
25
|
|
|
24
26
|
/**
|
|
@@ -38,14 +40,14 @@ export type AccordionProps = {
|
|
|
38
40
|
/**
|
|
39
41
|
* @defaultValue false
|
|
40
42
|
*/
|
|
41
|
-
|
|
43
|
+
multiExpand?: boolean;
|
|
42
44
|
/**
|
|
43
45
|
* @defaultValue 150
|
|
44
46
|
*/
|
|
45
47
|
animate?: number;
|
|
46
48
|
/**
|
|
47
49
|
* push means that the height of the accordion panel is derived from the height of its content
|
|
48
|
-
* pushToBottom means that the height of the accordion panel is the remaining space given by the accordion's container after removing the space taken by the other accordion panel titles (do not work if
|
|
50
|
+
* pushToBottom means that the height of the accordion panel is the remaining space given by the accordion's container after removing the space taken by the other accordion panel titles (do not work if multiExpand is true)
|
|
49
51
|
*
|
|
50
52
|
* @defaultValue push
|
|
51
53
|
*/
|
|
@@ -54,7 +56,7 @@ export type AccordionProps = {
|
|
|
54
56
|
|
|
55
57
|
export type AccordionState = {
|
|
56
58
|
panels: AnonymousObject<AccordionPanelState>;
|
|
57
|
-
|
|
59
|
+
multiExpand?: boolean;
|
|
58
60
|
animate: number;
|
|
59
61
|
mode?: 'push' | 'pushToBottom';
|
|
60
62
|
};
|
|
@@ -28,10 +28,12 @@ const getColor = (key: string, pattern: 'solid' | 'outline' | 'flat'): string =>
|
|
|
28
28
|
const buttonStyle: ComponentStyle<ButtonProps> = ({
|
|
29
29
|
kind = 'primary',
|
|
30
30
|
pattern = 'solid',
|
|
31
|
+
size = 'medium',
|
|
31
32
|
disabled,
|
|
32
33
|
IconComponent,
|
|
33
34
|
theme,
|
|
34
35
|
}) => {
|
|
36
|
+
const uSize = ucfirst(size);
|
|
35
37
|
const t = theme.buttons[kind];
|
|
36
38
|
const bgColor = get<any>(t, getColor('bgColor', pattern)) as string;
|
|
37
39
|
const hoverBgColor = get<any>(t, getColor('hoverBgColor', pattern)) as string;
|
|
@@ -39,6 +41,13 @@ const buttonStyle: ComponentStyle<ButtonProps> = ({
|
|
|
39
41
|
const hoverFontColor = get<any>(t, getColor('hoverColor', pattern)) as string;
|
|
40
42
|
const bColor = get<any>(t, getColor('borderColor', pattern)) as string;
|
|
41
43
|
const hoverBorderColor = get<any>(t, getColor('hoverBorderColor', pattern)) as string;
|
|
44
|
+
const tPaddingX = get<any>(t, `paddingX${uSize}`) as string;
|
|
45
|
+
const tPaddingY = get<any>(t, `paddingY${uSize}`) as string;
|
|
46
|
+
const tBorderRadius = get<any>(t, `borderRadius${uSize}`) as string;
|
|
47
|
+
const tBorderWidth = get<any>(t, `borderWidth${uSize}`) as string;
|
|
48
|
+
const tLineHeight = get<any>(t, `lineHeight${uSize}`) as string;
|
|
49
|
+
const tFontSize = get<any>(t, `fontSize${uSize}`) as string;
|
|
50
|
+
const tLetterSpacing = get<any>(t, `letterSpacing${uSize}`) as string;
|
|
42
51
|
|
|
43
52
|
return css`
|
|
44
53
|
${display('inline-flex')}
|
|
@@ -49,11 +58,11 @@ const buttonStyle: ComponentStyle<ButtonProps> = ({
|
|
|
49
58
|
${color(fontColor, {
|
|
50
59
|
hover: disabled ? fontColor : hoverFontColor,
|
|
51
60
|
})}
|
|
52
|
-
${paddingX(
|
|
53
|
-
${paddingY(
|
|
54
|
-
${borderRadius(
|
|
61
|
+
${paddingX(tPaddingX)}
|
|
62
|
+
${paddingY(tPaddingY)}
|
|
63
|
+
${borderRadius(tBorderRadius)}
|
|
55
64
|
${borderStyle(t.borderStyle)}
|
|
56
|
-
${borderWidth(
|
|
65
|
+
${borderWidth(tBorderWidth)}
|
|
57
66
|
${borderColor(bColor, {
|
|
58
67
|
hover: disabled ? bColor : hoverBorderColor,
|
|
59
68
|
})}
|
|
@@ -66,9 +75,9 @@ const buttonStyle: ComponentStyle<ButtonProps> = ({
|
|
|
66
75
|
${whiteSpace(t.whiteSpace)}
|
|
67
76
|
${textOverflow(t.textOverflow)}
|
|
68
77
|
${textTransform(t.textTransform)}
|
|
69
|
-
${letterSpacing(
|
|
70
|
-
${lineHeight(
|
|
71
|
-
${fontSize(
|
|
78
|
+
${letterSpacing(tLetterSpacing)}
|
|
79
|
+
${lineHeight(tLineHeight)}
|
|
80
|
+
${fontSize(tFontSize)}
|
|
72
81
|
${opacity(disabled ? 0.6 : 1)}
|
|
73
82
|
${marginLeft(IconComponent ? 'xs' : 'none')}
|
|
74
83
|
${outline('none')}
|
|
@@ -8,6 +8,7 @@ export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElemen
|
|
|
8
8
|
pattern?: 'solid' | 'outline' | 'flat';
|
|
9
9
|
IconComponent?: React.FC<ButtonProps>;
|
|
10
10
|
loading?: boolean;
|
|
11
|
+
size?: 'small' | 'medium' | 'large';
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export interface SubmitButtonProps extends ButtonProps {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
|
+
import { alignItems } from '../../styles/alignment';
|
|
4
|
+
import { display } from '../../styles/display';
|
|
5
|
+
import { color } from '../../styles/typography';
|
|
6
|
+
import { IconProps } from './typings';
|
|
7
|
+
|
|
8
|
+
const RefreshIconComponent: FC<IconProps> = (props) => {
|
|
9
|
+
return (
|
|
10
|
+
<div {...props}>
|
|
11
|
+
<svg
|
|
12
|
+
className="o-icon-refresh-svg"
|
|
13
|
+
stroke="currentColor"
|
|
14
|
+
fill="none"
|
|
15
|
+
strokeWidth="2"
|
|
16
|
+
viewBox="0 0 24 24"
|
|
17
|
+
aria-hidden="true"
|
|
18
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
19
|
+
>
|
|
20
|
+
<path
|
|
21
|
+
strokeLinecap="round"
|
|
22
|
+
strokeLinejoin="round"
|
|
23
|
+
d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"
|
|
24
|
+
></path>
|
|
25
|
+
</svg>
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default styled(RefreshIconComponent)`
|
|
31
|
+
${({ width = '16px', height = '16px', color: cssColor = 'inherit' }) => css`
|
|
32
|
+
width: ${width};
|
|
33
|
+
height: ${height};
|
|
34
|
+
${display('flex')};
|
|
35
|
+
${alignItems('center')};
|
|
36
|
+
${color(cssColor)}
|
|
37
|
+
.o-icon-refresh-svg {
|
|
38
|
+
display: inline-block;
|
|
39
|
+
}
|
|
40
|
+
`}
|
|
41
|
+
`;
|
|
@@ -8,7 +8,7 @@ import ListBodyComponent from './ListBodyComponent';
|
|
|
8
8
|
import ListItemComponent, { ListItemContent } from './ListItemComponent';
|
|
9
9
|
import LoadingItem from './LoadingItem';
|
|
10
10
|
|
|
11
|
-
const CollectionListComponent = <T = any, I extends ListItem<T> = ListItem<T>>({
|
|
11
|
+
const CollectionListComponent = <T extends any = any, I extends ListItem<T> = ListItem<T>>({
|
|
12
12
|
autoRefresh,
|
|
13
13
|
className,
|
|
14
14
|
controller,
|
|
@@ -23,7 +23,7 @@ const findItemIndex = (items?: (Item<unknown> | undefined)[], uid?: string): num
|
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
const ListBodyComponent = <T = any, I extends ListItem<T> = ListItem<T>>({
|
|
26
|
+
const ListBodyComponent = <T extends any = any, I extends ListItem<T> = ListItem<T>>({
|
|
27
27
|
autoRefresh,
|
|
28
28
|
bodyRef,
|
|
29
29
|
className,
|
|
@@ -182,8 +182,9 @@ const ListBodyComponent = <T = any, I extends ListItem<T> = ListItem<T>>({
|
|
|
182
182
|
});
|
|
183
183
|
|
|
184
184
|
useEffect(() => {
|
|
185
|
+
const ref = parentRef ? parentRef : bodyRef;
|
|
186
|
+
//console.log('parentRef', parentRef, 'ref', ref)
|
|
185
187
|
const atBottom = () => {
|
|
186
|
-
const ref = parentRef ? parentRef : bodyRef;
|
|
187
188
|
if (ref && ref.current) {
|
|
188
189
|
const sh = ref.current.scrollHeight;
|
|
189
190
|
const st = ref.current.scrollTop;
|
|
@@ -193,9 +194,21 @@ const ListBodyComponent = <T = any, I extends ListItem<T> = ListItem<T>>({
|
|
|
193
194
|
return false;
|
|
194
195
|
};
|
|
195
196
|
|
|
196
|
-
if (tail && scrollToIndex && totalSize &&
|
|
197
|
-
|
|
198
|
-
|
|
197
|
+
if (tail && scrollToIndex && totalSize && ref && ref.current) {
|
|
198
|
+
// console.log(
|
|
199
|
+
// 'scrollTop',
|
|
200
|
+
// ref.current.scrollTop,
|
|
201
|
+
// 'mouseRef',
|
|
202
|
+
// mouseRef.current,
|
|
203
|
+
// 'wheelRef',
|
|
204
|
+
// wheelRef.current,
|
|
205
|
+
// 'applyTail',
|
|
206
|
+
// tailRef.current.applyTail,
|
|
207
|
+
// 'atBottom',
|
|
208
|
+
// atBottom(),
|
|
209
|
+
// );
|
|
210
|
+
tailRef.current.lastScrollTop = ref.current.scrollTop;
|
|
211
|
+
if (!atBottom() && (mouseRef.current || wheelRef.current)) {
|
|
199
212
|
tailRef.current.applyTail = false;
|
|
200
213
|
} else if (tailRef.current.applyTail === true || atBottom()) {
|
|
201
214
|
tailRef.current.applyTail = true;
|
|
@@ -4,14 +4,16 @@ import { height, minHeight, width } from '../../../styles/size';
|
|
|
4
4
|
import { marginY } from '../../../styles/spacing';
|
|
5
5
|
import { addClassname } from '../../../utils/style';
|
|
6
6
|
|
|
7
|
-
const LoadingItem: React.FC<{ className?: string }> = ({ className }) => {
|
|
7
|
+
const LoadingItem: React.FC<{ className?: string, minHeight?: number }> = ({ className }) => {
|
|
8
8
|
return <div className={addClassname('o-loading-item', className)} />;
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export default styled(LoadingItem)`
|
|
12
12
|
${height('full')}
|
|
13
13
|
${width('full')}
|
|
14
|
-
${
|
|
14
|
+
${(props) => {
|
|
15
|
+
return minHeight(`${props.minHeight ?? 37}px`)
|
|
16
|
+
}}
|
|
15
17
|
${marginY('1px')}
|
|
16
18
|
animation: skeleton-loading 1s linear infinite alternate;
|
|
17
19
|
|
|
@@ -4,7 +4,7 @@ import { ListItem, VirtualItemWrapperProps, VirtualListProps } from '../typings'
|
|
|
4
4
|
import ListItemComponent, { ListItemContent } from './ListItemComponent';
|
|
5
5
|
import LoadingItem from './LoadingItem';
|
|
6
6
|
|
|
7
|
-
const VirtualItemWrapper = <T = any, I extends ListItem<T> = ListItem<T>>({
|
|
7
|
+
const VirtualItemWrapper = <T extends any = any, I extends ListItem<T> = ListItem<T>>({
|
|
8
8
|
virtualItem,
|
|
9
9
|
listItem,
|
|
10
10
|
ItemComponent = ListItemComponent,
|
|
@@ -83,7 +83,7 @@ const VirtualItemWrapper = <T = any, I extends ListItem<T> = ListItem<T>>({
|
|
|
83
83
|
);
|
|
84
84
|
};
|
|
85
85
|
|
|
86
|
-
const VirtualListComponent = <T = any, I extends ListItem<T> = ListItem<T>>({
|
|
86
|
+
const VirtualListComponent = <T extends any = any, I extends ListItem<T> = ListItem<T>>({
|
|
87
87
|
items,
|
|
88
88
|
ItemComponent = ListItemComponent,
|
|
89
89
|
ItemLoadingComponent = LoadingItem,
|
|
@@ -81,6 +81,7 @@ const useListView: <T = any, I extends Item<T> = Item<T>>(
|
|
|
81
81
|
if (controller.status !== LoadingStatus.NotReady) {
|
|
82
82
|
if (isVirtual) {
|
|
83
83
|
if (controller.status === LoadingStatus.NotInitialized) {
|
|
84
|
+
scrollToOffset(0);
|
|
84
85
|
controller.load(preload, undefined, true);
|
|
85
86
|
} else {
|
|
86
87
|
const lastVirtualItem = virtualItems[virtualItems.length - 1];
|
|
@@ -100,7 +101,7 @@ const useListView: <T = any, I extends Item<T> = Item<T>>(
|
|
|
100
101
|
const first = Math.max(0, lastVirtualItemIndex - increment);
|
|
101
102
|
|
|
102
103
|
if (lastVirtualItemIndex > 0) {
|
|
103
|
-
let slice = state.items.slice(first, lastVirtualItemIndex);
|
|
104
|
+
let slice = state.items.slice(first, lastVirtualItemIndex).filter(() => true);
|
|
104
105
|
if (slice.length < lastVirtualItemIndex - first) {
|
|
105
106
|
const arr = new Array(lastVirtualItemIndex - first);
|
|
106
107
|
arr.splice(arr.length - slice.length, slice.length, ...slice);
|
|
@@ -121,6 +122,8 @@ const useListView: <T = any, I extends Item<T> = Item<T>>(
|
|
|
121
122
|
}
|
|
122
123
|
}
|
|
123
124
|
|
|
125
|
+
|
|
126
|
+
|
|
124
127
|
// check forward
|
|
125
128
|
const end =
|
|
126
129
|
state.total !== undefined
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useNotifications } from 'onekijs-framework';
|
|
1
|
+
import { useNotificationService, useNotifications } from 'onekijs-framework';
|
|
2
2
|
import React, { useRef } from 'react';
|
|
3
3
|
import ReactDOM from 'react-dom';
|
|
4
4
|
import { CSSTransition, TransitionGroup } from 'react-transition-group';
|
|
@@ -17,6 +17,7 @@ const NotificationsComponent: React.FC<NotificationsProps> = ({
|
|
|
17
17
|
}) => {
|
|
18
18
|
const classNames = addClassname('o-notifications', className);
|
|
19
19
|
const translateX = position === 'top-right' || position === 'bottom-right' ? '250px' : '-250px';
|
|
20
|
+
const notificationService = useNotificationService();
|
|
20
21
|
let notifications = useNotifications(topics);
|
|
21
22
|
if (max) {
|
|
22
23
|
notifications = notifications.slice(0, max);
|
|
@@ -87,6 +88,11 @@ const NotificationsComponent: React.FC<NotificationsProps> = ({
|
|
|
87
88
|
|
|
88
89
|
const element = (
|
|
89
90
|
<div className={classNames}>
|
|
91
|
+
{notifications.length > 1 && (
|
|
92
|
+
<div className="o-notification-close-all">
|
|
93
|
+
<span className="o-notification-close-all-content" onClick={() => notificationService.clearAll()}>Close all</span>
|
|
94
|
+
</div>
|
|
95
|
+
)}
|
|
90
96
|
<TransitionGroup component={null}>
|
|
91
97
|
{notifications.map((notification, index) => (
|
|
92
98
|
<CSSTransition
|
|
@@ -7,10 +7,10 @@ import { opacity } from '../../styles/effects';
|
|
|
7
7
|
import { cursor } from '../../styles/interactivity';
|
|
8
8
|
import { bottom, left, position, right, top, zIndex } from '../../styles/position';
|
|
9
9
|
import { maxWidth, minHeight, minWidth } from '../../styles/size';
|
|
10
|
-
import { marginBottom, marginRight, padding } from '../../styles/spacing';
|
|
10
|
+
import { marginBottom, marginRight, padding, paddingBottom, paddingRight } from '../../styles/spacing';
|
|
11
11
|
import { transform } from '../../styles/transform';
|
|
12
12
|
import { ComponentStyle } from '../../styles/typings';
|
|
13
|
-
import { color } from '../../styles/typography';
|
|
13
|
+
import { color, fontSize, fontWeight, textAlign } from '../../styles/typography';
|
|
14
14
|
import { NotificationsProps } from './typings';
|
|
15
15
|
|
|
16
16
|
export const notifcationsStyle: ComponentStyle<NotificationsProps> = ({ position: pos = 'bottom-right' }) => {
|
|
@@ -31,6 +31,17 @@ export const notifcationsStyle: ComponentStyle<NotificationsProps> = ({ position
|
|
|
31
31
|
${opacity(0)}
|
|
32
32
|
${display('flex')}
|
|
33
33
|
}
|
|
34
|
+
.o-notification-close-all {
|
|
35
|
+
${textAlign('right')}
|
|
36
|
+
${paddingRight('sm')}
|
|
37
|
+
${paddingBottom('sm')}
|
|
38
|
+
}
|
|
39
|
+
.o-notification-close-all-content{
|
|
40
|
+
${fontSize('lg')}
|
|
41
|
+
${cursor('pointer')}
|
|
42
|
+
${color('primary')}
|
|
43
|
+
${fontWeight('medium')}
|
|
44
|
+
}
|
|
34
45
|
.o-notification {
|
|
35
46
|
${minWidth('450px')}
|
|
36
47
|
${maxWidth('450px')}
|
|
@@ -84,12 +84,13 @@ const SelectOptionComponent = <T, I extends SelectItem<T> = SelectItem<T>>(props
|
|
|
84
84
|
|
|
85
85
|
return (
|
|
86
86
|
<>
|
|
87
|
-
{displayGroup && <OptionGroupComponent {...props} />}
|
|
87
|
+
{displayGroup && <OptionGroupComponent {...props} key="group" />}
|
|
88
88
|
<div
|
|
89
89
|
className={classNames}
|
|
90
90
|
onClick={() => onItemClick(item, index)}
|
|
91
91
|
onMouseEnter={() => hoverable && onMouseEnter && item && onMouseEnter(item, index)}
|
|
92
92
|
onMouseLeave={() => hoverable && onMouseLeave && item && onMouseLeave(item, index)}
|
|
93
|
+
key="content"
|
|
93
94
|
>
|
|
94
95
|
<div style={{display: 'flex'}} ref={ref}>
|
|
95
96
|
{/* {multiple && <div className="o-select-option-icon">{meta?.selected? <>✓</>:<></>}</div> } */}
|
|
@@ -99,9 +100,10 @@ const SelectOptionComponent = <T, I extends SelectItem<T> = SelectItem<T>>(props
|
|
|
99
100
|
onChange={() => onItemClick(item, index)}
|
|
100
101
|
color="currentColor"
|
|
101
102
|
className="o-select-option-multiple-checkbox"
|
|
103
|
+
key="checkbox"
|
|
102
104
|
></Checkbox>
|
|
103
105
|
)}
|
|
104
|
-
<OptionContentComponent {...props} onClick={() => onItemClick(item, index)} />
|
|
106
|
+
<OptionContentComponent {...props} onClick={() => onItemClick(item, index)} key="option_content" />
|
|
105
107
|
</div>
|
|
106
108
|
</div>
|
|
107
109
|
</>
|