diginet-core-ui 1.3.47-beta.1 → 1.3.47-beta.4
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/components/accordion/css.js +27 -30
- package/components/accordion/details.js +17 -15
- package/components/accordion/group.js +10 -10
- package/components/accordion/index.js +25 -21
- package/components/accordion/summary.js +28 -37
- package/components/form-control/dropdown/index.js +3 -3
- package/components/grid/Col.js +63 -0
- package/components/grid/Row.js +75 -0
- package/components/grid/context.js +3 -0
- package/components/grid/index.js +260 -0
- package/components/index.js +5 -1
- package/components/tree-view/css.js +1 -0
- package/components/typography/index.js +10 -10
- package/package.json +1 -1
- package/styles/general.js +7 -4
- package/theme/createBreakpoints.js +94 -0
- package/theme/make-styles.js +3 -1
- package/theme/settings.js +12 -42
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
import { css } from '@emotion/core';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { alignCenter, backgroundTransparent, borderBox, borderRadius4px, breakWord, cursorPointer, displayInlineBlock, flexRow, flexRowReverse, inlineFlex, justifyBetween, justifyCenter, justifyEnd, pointerEventsNone, positionAbsolute, positionRelative, userSelectNone } from '../../styles/general';
|
|
2
|
+
import theme from '../../theme/settings';
|
|
3
|
+
import { alignCenter, alignStart, backgroundTransparent, borderBox, borderRadius4px, breakWord, cursorPointer, displayInlineBlock, flexRow, flexRowReverse, inlineFlex, justifyBetween, justifyCenter, justifyEnd, parseWidthHeight, pointerEventsNone, positionAbsolute, positionRelative, userSelectNone } from '../../styles/general';
|
|
5
4
|
const {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
colors: {
|
|
6
|
+
system: {
|
|
7
|
+
active,
|
|
8
|
+
disabled: systemDisabled
|
|
9
|
+
},
|
|
10
|
+
fill: {
|
|
11
|
+
disabled: fillDisabled,
|
|
12
|
+
headerbar,
|
|
13
|
+
focus,
|
|
14
|
+
hover,
|
|
15
|
+
pressed
|
|
16
|
+
}
|
|
12
17
|
},
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
} = colors;
|
|
21
|
-
export const SummaryRootCSS = css`
|
|
18
|
+
typography: {
|
|
19
|
+
heading3
|
|
20
|
+
},
|
|
21
|
+
spacing
|
|
22
|
+
} = theme;
|
|
23
|
+
export const SummaryRootCSS = background => css`
|
|
22
24
|
${flexRow};
|
|
23
25
|
${positionRelative};
|
|
24
26
|
${justifyBetween};
|
|
25
|
-
${
|
|
27
|
+
${alignStart};
|
|
26
28
|
${cursorPointer};
|
|
27
29
|
${borderBox};
|
|
28
30
|
${borderRadius4px};
|
|
29
31
|
width: 100%;
|
|
30
32
|
min-height: 56px;
|
|
31
|
-
padding:
|
|
32
|
-
|
|
33
|
-
background-color: ${headerbar};
|
|
34
|
-
}
|
|
33
|
+
padding: ${spacing(4)}px ${spacing(6)}px;
|
|
34
|
+
${background && `background-color: ${background === true ? headerbar : theme.colors[background] || background};`};
|
|
35
35
|
.Accordion-Expand-Icon,
|
|
36
36
|
.Accordion-Collapse-Icon {
|
|
37
37
|
${cursorPointer};
|
|
@@ -47,8 +47,7 @@ export const SummaryRootCSS = css`
|
|
|
47
47
|
${flexRow};
|
|
48
48
|
.Accordion-Icon.rotate-able {
|
|
49
49
|
${borderBox};
|
|
50
|
-
|
|
51
|
-
height: 24px;
|
|
50
|
+
${parseWidthHeight(24, 24)};
|
|
52
51
|
&:not(.TreeView) {
|
|
53
52
|
transform: rotateZ(0deg);
|
|
54
53
|
transform-origin: center;
|
|
@@ -62,7 +61,7 @@ export const SummaryRootCSS = css`
|
|
|
62
61
|
${flexRowReverse};
|
|
63
62
|
${justifyEnd};
|
|
64
63
|
.Accordion-Icon.rotate-able {
|
|
65
|
-
margin-right:
|
|
64
|
+
margin-right: ${spacing(2)}px;
|
|
66
65
|
&.TreeView {
|
|
67
66
|
transform: rotateZ(-90deg);
|
|
68
67
|
}
|
|
@@ -70,7 +69,7 @@ export const SummaryRootCSS = css`
|
|
|
70
69
|
}
|
|
71
70
|
&.end {
|
|
72
71
|
.Accordion-Icon.rotate-able {
|
|
73
|
-
margin-left:
|
|
72
|
+
margin-left: ${spacing(2)}px;
|
|
74
73
|
&.TreeView {
|
|
75
74
|
transform: rotateZ(90deg);
|
|
76
75
|
}
|
|
@@ -144,8 +143,7 @@ export const SummaryRootCSS = css`
|
|
|
144
143
|
${displayInlineBlock};
|
|
145
144
|
${positionRelative};
|
|
146
145
|
${cursorPointer};
|
|
147
|
-
|
|
148
|
-
height: 24px;
|
|
146
|
+
${parseWidthHeight(24, 24)};
|
|
149
147
|
transition: transform 200ms linear;
|
|
150
148
|
.Accordion-Expand-Icon {
|
|
151
149
|
transform: scale(1);
|
|
@@ -169,7 +167,6 @@ export const SummaryRootCSS = css`
|
|
|
169
167
|
max-width: 34px;
|
|
170
168
|
min-height: 24px;
|
|
171
169
|
max-height: 34px;
|
|
172
|
-
padding: 3px;
|
|
173
170
|
}
|
|
174
171
|
}
|
|
175
172
|
`;
|
|
@@ -5,16 +5,18 @@ import { memo, forwardRef, useRef, useMemo, useImperativeHandle } from 'react';
|
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { jsx, css } from '@emotion/core';
|
|
7
7
|
import { borderBox, displayBlock, overflowHidden, pointerEventsNone, positionRelative, userSelectNone } from '../../styles/general';
|
|
8
|
-
import
|
|
9
|
-
import { color as colors } from '../../styles/colors';
|
|
8
|
+
import theme from '../../theme/settings';
|
|
10
9
|
const {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
colors: {
|
|
11
|
+
text: {
|
|
12
|
+
main
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
typography: {
|
|
16
|
+
paragraph1
|
|
17
|
+
},
|
|
18
|
+
spacing
|
|
19
|
+
} = theme;
|
|
18
20
|
const AccordionDetails = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
19
21
|
children,
|
|
20
22
|
className,
|
|
@@ -52,7 +54,7 @@ const DetailsRootCSS = css`
|
|
|
52
54
|
.DGN-UI-Accordion-Details-Content {
|
|
53
55
|
${borderBox};
|
|
54
56
|
${paragraph1};
|
|
55
|
-
padding: 0
|
|
57
|
+
padding: 0 ${spacing(6)}px ${spacing(4)}px ${spacing(6)}px;
|
|
56
58
|
color: ${main};
|
|
57
59
|
&.disabled {
|
|
58
60
|
${pointerEventsNone}
|
|
@@ -66,13 +68,13 @@ AccordionDetails.defaultProps = {
|
|
|
66
68
|
id: ''
|
|
67
69
|
};
|
|
68
70
|
AccordionDetails.propTypes = {
|
|
69
|
-
/** The
|
|
71
|
+
/** The content of the component. */
|
|
70
72
|
children: PropTypes.node,
|
|
71
73
|
|
|
72
|
-
/**
|
|
73
|
-
|
|
74
|
+
/** Style inline of component. */
|
|
75
|
+
style: PropTypes.object,
|
|
74
76
|
|
|
75
|
-
/**
|
|
76
|
-
|
|
77
|
+
/** Class for component. */
|
|
78
|
+
className: PropTypes.string
|
|
77
79
|
};
|
|
78
80
|
export default AccordionDetails;
|
|
@@ -41,10 +41,10 @@ const AccordionGroup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
41
41
|
ref: ref,
|
|
42
42
|
style: style,
|
|
43
43
|
className: ['DGN-UI-Accordion-Group', className].join(' ').trim().replace(/\s+/g, ' ')
|
|
44
|
-
}, Children.map(children, child => /*#__PURE__*/cloneElement(child, {
|
|
44
|
+
}, Children.map(children, child => child && /*#__PURE__*/cloneElement(child, {
|
|
45
45
|
onExpand: e => onCollapseOther(e, child.props.onExpand)
|
|
46
46
|
})));
|
|
47
|
-
}, [className, children]);
|
|
47
|
+
}, [style, className, children]);
|
|
48
48
|
}));
|
|
49
49
|
const AccordionGroupRootCSS = css`
|
|
50
50
|
${borderRadius4px};
|
|
@@ -113,16 +113,16 @@ AccordionGroup.defaultProps = {
|
|
|
113
113
|
style: {}
|
|
114
114
|
};
|
|
115
115
|
AccordionGroup.propTypes = {
|
|
116
|
-
/**
|
|
117
|
-
|
|
116
|
+
/** The content of the component. */
|
|
117
|
+
children: PropTypes.node,
|
|
118
118
|
|
|
119
|
-
/**
|
|
120
|
-
|
|
119
|
+
/** Style inline of component. */
|
|
120
|
+
style: PropTypes.object,
|
|
121
121
|
|
|
122
|
-
/**
|
|
123
|
-
|
|
122
|
+
/** Class for component. */
|
|
123
|
+
className: PropTypes.string,
|
|
124
124
|
|
|
125
|
-
/**
|
|
126
|
-
|
|
125
|
+
/** If `true`, collapse other when expand */
|
|
126
|
+
collapseOther: PropTypes.bool
|
|
127
127
|
};
|
|
128
128
|
export default AccordionGroup;
|
|
@@ -7,13 +7,16 @@ import { jsx, css } from '@emotion/core';
|
|
|
7
7
|
import AccordionContext from './context';
|
|
8
8
|
import Divider from '../divider';
|
|
9
9
|
import { borderRadius4px, displayBlock, positionRelative } from '../../styles/general';
|
|
10
|
-
import
|
|
10
|
+
import theme from '../../theme/settings';
|
|
11
11
|
const {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
colors: {
|
|
13
|
+
line: {
|
|
14
|
+
category
|
|
15
|
+
}
|
|
14
16
|
}
|
|
15
|
-
} =
|
|
17
|
+
} = theme;
|
|
16
18
|
const Accordion = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
19
|
+
id,
|
|
17
20
|
disabled,
|
|
18
21
|
expand,
|
|
19
22
|
expanded,
|
|
@@ -57,6 +60,7 @@ const Accordion = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
57
60
|
});
|
|
58
61
|
return useMemo(() => {
|
|
59
62
|
return jsx("div", {
|
|
63
|
+
id: id,
|
|
60
64
|
css: AccordionRootCSS,
|
|
61
65
|
ref: ref,
|
|
62
66
|
style: style,
|
|
@@ -78,7 +82,7 @@ const Accordion = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
78
82
|
display: 'none'
|
|
79
83
|
}
|
|
80
84
|
})));
|
|
81
|
-
}, [disabled, className, boxShadow, onClick, children, expanded, onExpand, onCollapse, expandState]);
|
|
85
|
+
}, [id, disabled, className, boxShadow, onClick, children, expanded, onExpand, onCollapse, expandState]);
|
|
82
86
|
}));
|
|
83
87
|
const AccordionRootCSS = css`
|
|
84
88
|
${displayBlock};
|
|
@@ -102,31 +106,31 @@ Accordion.defaultProps = {
|
|
|
102
106
|
style: {}
|
|
103
107
|
};
|
|
104
108
|
Accordion.propTypes = {
|
|
105
|
-
/**
|
|
109
|
+
/** The content of the component (insist <AccordionSummary />, <AccordionDetails />). */
|
|
110
|
+
children: PropTypes.node,
|
|
111
|
+
|
|
112
|
+
/** Style inline of component. */
|
|
113
|
+
style: PropTypes.object,
|
|
114
|
+
|
|
115
|
+
/** Class for component. */
|
|
116
|
+
className: PropTypes.string,
|
|
117
|
+
|
|
118
|
+
/** If `true`, the component is disabled. */
|
|
106
119
|
disabled: PropTypes.bool,
|
|
107
120
|
|
|
108
|
-
/** expand immediate after render
|
|
121
|
+
/** If `true`, expand immediate after render (shouldn't use this). */
|
|
109
122
|
expand: PropTypes.bool,
|
|
110
123
|
|
|
111
|
-
/**
|
|
124
|
+
/** Expand state of accordion (should use this). */
|
|
112
125
|
expanded: PropTypes.bool,
|
|
113
126
|
|
|
114
|
-
/**
|
|
115
|
-
className: PropTypes.string,
|
|
116
|
-
|
|
117
|
-
/** class on element */
|
|
127
|
+
/** The box-shadow of component. */
|
|
118
128
|
boxShadow: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
119
129
|
|
|
120
|
-
/**
|
|
130
|
+
/** Callback fired when Accordion is expanded. */
|
|
121
131
|
onExpand: PropTypes.func,
|
|
122
132
|
|
|
123
|
-
/**
|
|
124
|
-
onCollapse: PropTypes.func
|
|
125
|
-
|
|
126
|
-
/** insist <AccordionSummary />, <AccordionDetails /> */
|
|
127
|
-
children: PropTypes.node,
|
|
128
|
-
|
|
129
|
-
/** style inline of component */
|
|
130
|
-
style: PropTypes.object
|
|
133
|
+
/** Callback fired when Accordion is collapsed. */
|
|
134
|
+
onCollapse: PropTypes.func
|
|
131
135
|
};
|
|
132
136
|
export default Accordion;
|
|
@@ -8,6 +8,7 @@ import { renderIcon } from '../../utils';
|
|
|
8
8
|
import { SummaryRootCSS } from './css';
|
|
9
9
|
import AccordionContext from './context';
|
|
10
10
|
const AccordionSummary = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
11
|
+
id,
|
|
11
12
|
expandIcon,
|
|
12
13
|
collapseIcon,
|
|
13
14
|
expandIconAt,
|
|
@@ -18,9 +19,6 @@ const AccordionSummary = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
18
19
|
expandIconProps,
|
|
19
20
|
style
|
|
20
21
|
}, reference) => {
|
|
21
|
-
const ref = useRef(null);
|
|
22
|
-
const expandIconRef = useRef(null);
|
|
23
|
-
const timer = useRef(null);
|
|
24
22
|
const {
|
|
25
23
|
expanded,
|
|
26
24
|
expandState,
|
|
@@ -30,8 +28,13 @@ const AccordionSummary = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
30
28
|
onCollapse,
|
|
31
29
|
setExpandState
|
|
32
30
|
} = useContext(AccordionContext);
|
|
31
|
+
const ref = useRef(null);
|
|
32
|
+
const expandIconRef = useRef(null);
|
|
33
|
+
const timer = useRef(null);
|
|
33
34
|
|
|
34
|
-
const
|
|
35
|
+
const _SummaryRootCSS = SummaryRootCSS(background);
|
|
36
|
+
|
|
37
|
+
const _onClick = e => {
|
|
35
38
|
if (!disabled) {
|
|
36
39
|
const target = e.target;
|
|
37
40
|
|
|
@@ -93,19 +96,6 @@ const AccordionSummary = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
93
96
|
}
|
|
94
97
|
};
|
|
95
98
|
|
|
96
|
-
useEffect(() => {
|
|
97
|
-
if (/^(#|rgb)/.test(background)) {
|
|
98
|
-
if (ref.current) {
|
|
99
|
-
ref.current.style.backgroundColor = background;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return () => {
|
|
103
|
-
if (ref.current) {
|
|
104
|
-
ref.current.style.backgroundColor = null;
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
}, [background]);
|
|
109
99
|
useEffect(() => {
|
|
110
100
|
if (expandState) {
|
|
111
101
|
showHideDetailHandler('show');
|
|
@@ -124,19 +114,20 @@ const AccordionSummary = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
124
114
|
});
|
|
125
115
|
return useMemo(() => {
|
|
126
116
|
return jsx("div", {
|
|
127
|
-
|
|
117
|
+
id: id,
|
|
118
|
+
css: _SummaryRootCSS,
|
|
128
119
|
ref: ref,
|
|
129
120
|
tabIndex: "-1",
|
|
130
|
-
onClick:
|
|
121
|
+
onClick: _onClick,
|
|
131
122
|
style: style,
|
|
132
|
-
className: ['DGN-UI-Accordion-Summary', disabled ? 'disabled' : '', expandIcon ? expandIconAt : '',
|
|
123
|
+
className: ['DGN-UI-Accordion-Summary', disabled ? 'disabled' : '', expandIcon ? expandIconAt : '', expandState ? 'expanding' : '', className].join(' ').trim().replace(/\s+/g, ' ')
|
|
133
124
|
}, jsx("div", {
|
|
134
125
|
className: 'DGN-UI-Accordion-Summary-Content'
|
|
135
126
|
}, children), !!expandIcon && jsx("div", {
|
|
136
127
|
className: 'Accordion-Icon-Root'
|
|
137
128
|
}, jsx("div", { ...expandIconProps,
|
|
138
129
|
ref: expandIconRef,
|
|
139
|
-
className: ['Accordion-Icon', collapseIcon ? '' : 'rotate-able', expandIconProps.className ? expandIconProps.className : ''].join(' ').trim()
|
|
130
|
+
className: ['Accordion-Icon', collapseIcon ? '' : 'rotate-able', expandIconProps.className ? expandIconProps.className : ''].join(' ').trim().replace(/\s+/g, ' ')
|
|
140
131
|
}, typeof expandIcon === 'string' ? renderIcon(expandIcon, 'effect', {
|
|
141
132
|
className: 'Accordion-Expand-Icon'
|
|
142
133
|
}) : jsx("span", {
|
|
@@ -146,7 +137,7 @@ const AccordionSummary = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
146
137
|
}) : jsx("span", {
|
|
147
138
|
className: 'Accordion-Collapse-Icon effect'
|
|
148
139
|
}, collapseIcon)))));
|
|
149
|
-
}, [expandIcon, expandIconAt, className, background, children, collapseIcon, expandIconProps, expandState]);
|
|
140
|
+
}, [id, expandIcon, expandIconAt, className, background, children, collapseIcon, expandIconProps, expandState]);
|
|
150
141
|
}));
|
|
151
142
|
AccordionSummary.defaultProps = {
|
|
152
143
|
expandIconAt: 'start',
|
|
@@ -156,28 +147,28 @@ AccordionSummary.defaultProps = {
|
|
|
156
147
|
style: {}
|
|
157
148
|
};
|
|
158
149
|
AccordionSummary.propTypes = {
|
|
159
|
-
/**
|
|
150
|
+
/** The content of the component. */
|
|
151
|
+
children: PropTypes.node,
|
|
152
|
+
|
|
153
|
+
/** Style inline of component. */
|
|
154
|
+
style: PropTypes.object,
|
|
155
|
+
|
|
156
|
+
/** Class for component. */
|
|
157
|
+
className: PropTypes.string,
|
|
158
|
+
|
|
159
|
+
/** Icon display for expand icon. */
|
|
160
160
|
expandIcon: PropTypes.any,
|
|
161
161
|
|
|
162
|
-
/**
|
|
162
|
+
/** Icon display for collapse icon. */
|
|
163
163
|
collapseIcon: PropTypes.any,
|
|
164
164
|
|
|
165
|
-
/**
|
|
165
|
+
/** Position to render icon. */
|
|
166
166
|
expandIconAt: PropTypes.oneOf(['start', 'end']),
|
|
167
167
|
|
|
168
|
-
/**
|
|
168
|
+
/** Background for label summary. */
|
|
169
169
|
background: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
170
170
|
|
|
171
|
-
/**
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
/** The element to display in alert like text props (priority) */
|
|
175
|
-
children: PropTypes.node,
|
|
176
|
-
|
|
177
|
-
/** props of expand and collapse icons */
|
|
178
|
-
expandIconProps: PropTypes.any,
|
|
179
|
-
|
|
180
|
-
/** style inline of component */
|
|
181
|
-
style: PropTypes.object
|
|
171
|
+
/** Other props of icons. */
|
|
172
|
+
expandIconProps: PropTypes.any
|
|
182
173
|
};
|
|
183
174
|
export default AccordionSummary;
|
|
@@ -1327,7 +1327,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1327
1327
|
...labelProps
|
|
1328
1328
|
}, label) : null, [label, required, disabled, labelProps]);
|
|
1329
1329
|
const inputComp = useMemo(() => {
|
|
1330
|
-
const _InputCSS = InputCSS(multiple, renderSelectedItem
|
|
1330
|
+
const _InputCSS = InputCSS(multiple, renderSelectedItem);
|
|
1331
1331
|
|
|
1332
1332
|
const _DropdownFormCSS = DropdownFormCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem, disabled);
|
|
1333
1333
|
|
|
@@ -1422,10 +1422,10 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1422
1422
|
}));
|
|
1423
1423
|
/* Start styled */
|
|
1424
1424
|
|
|
1425
|
-
const InputCSS = (multiple, renderSelectedItem
|
|
1425
|
+
const InputCSS = (multiple, renderSelectedItem) => css`
|
|
1426
1426
|
${flexRow};
|
|
1427
1427
|
width: 100%;
|
|
1428
|
-
${!multiple && renderSelectedItem ? `width: calc(100% - 34px
|
|
1428
|
+
${!multiple && renderSelectedItem ? `width: calc(100% - 34px)` : ''}
|
|
1429
1429
|
`;
|
|
1430
1430
|
|
|
1431
1431
|
const DropdownIconCSS = css`
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/** @jsxRuntime classic */
|
|
2
|
+
|
|
3
|
+
/** @jsx jsx */
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import { jsx } from '@emotion/core';
|
|
6
|
+
import Grid from '.';
|
|
7
|
+
|
|
8
|
+
const Col = props => {
|
|
9
|
+
return jsx(Grid, { ...props,
|
|
10
|
+
item: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
Col.defaultProps = {
|
|
15
|
+
style: {},
|
|
16
|
+
className: '',
|
|
17
|
+
columns: 12,
|
|
18
|
+
lg: false,
|
|
19
|
+
md: false,
|
|
20
|
+
sm: false,
|
|
21
|
+
xl: false,
|
|
22
|
+
xs: false,
|
|
23
|
+
zeroMinWidth: false,
|
|
24
|
+
wrap: 'wrap'
|
|
25
|
+
};
|
|
26
|
+
Col.propTypes = {
|
|
27
|
+
/** The content of the component. */
|
|
28
|
+
children: PropTypes.node,
|
|
29
|
+
|
|
30
|
+
/** Style inline of component. */
|
|
31
|
+
style: PropTypes.object,
|
|
32
|
+
|
|
33
|
+
/** Class for component. */
|
|
34
|
+
className: PropTypes.string,
|
|
35
|
+
|
|
36
|
+
/** The number of columns. */
|
|
37
|
+
columns: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number, PropTypes.object]),
|
|
38
|
+
|
|
39
|
+
/** Defines the `flex-direction` style property. It is applied for all screen sizes. */
|
|
40
|
+
direction: PropTypes.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
|
|
41
|
+
|
|
42
|
+
/** If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for the `lg` breakpoint and wider screens if not overridden. */
|
|
43
|
+
lg: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
44
|
+
|
|
45
|
+
/** If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for the `md` breakpoint and wider screens if not overridden. */
|
|
46
|
+
md: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
47
|
+
|
|
48
|
+
/** If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for the `sm` breakpoint and wider screens if not overridden. */
|
|
49
|
+
sm: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
50
|
+
|
|
51
|
+
/** Defines the flex-wrap style property. It's applied for all screen sizes. */
|
|
52
|
+
wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
|
|
53
|
+
|
|
54
|
+
/** If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for the `xl` breakpoint and wider screens if not overridden. */
|
|
55
|
+
xl: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
56
|
+
|
|
57
|
+
/** If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for all the screen sizes with the lowest priority. */
|
|
58
|
+
xs: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
59
|
+
|
|
60
|
+
/** If `true`, it sets `min-width: 0` on the item. Refer to the limitations section of the documentation to better understand the use case. */
|
|
61
|
+
zeroMinWidth: PropTypes.bool
|
|
62
|
+
};
|
|
63
|
+
export default Col;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/** @jsxRuntime classic */
|
|
2
|
+
|
|
3
|
+
/** @jsx jsx */
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import { jsx } from '@emotion/core';
|
|
6
|
+
import Grid from '.';
|
|
7
|
+
|
|
8
|
+
const Row = props => {
|
|
9
|
+
return jsx(Grid, { ...props,
|
|
10
|
+
container: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
Row.defaultProps = {
|
|
15
|
+
style: {},
|
|
16
|
+
className: '',
|
|
17
|
+
columns: 12,
|
|
18
|
+
lg: false,
|
|
19
|
+
md: false,
|
|
20
|
+
sm: false,
|
|
21
|
+
xl: false,
|
|
22
|
+
xs: false,
|
|
23
|
+
zeroMinWidth: false,
|
|
24
|
+
spacing: 0,
|
|
25
|
+
direction: 'row',
|
|
26
|
+
wrap: 'wrap',
|
|
27
|
+
columnSpacing: 4
|
|
28
|
+
};
|
|
29
|
+
Row.propTypes = {
|
|
30
|
+
/** The content of the component. */
|
|
31
|
+
children: PropTypes.node,
|
|
32
|
+
|
|
33
|
+
/** Style inline of component. */
|
|
34
|
+
style: PropTypes.object,
|
|
35
|
+
|
|
36
|
+
/** Class for component. */
|
|
37
|
+
className: PropTypes.string,
|
|
38
|
+
|
|
39
|
+
/** The number of columns. */
|
|
40
|
+
columns: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number, PropTypes.object]),
|
|
41
|
+
|
|
42
|
+
/** Defines the horizontal space between the type `Col` components. It overrides the value of the `spacing` prop. */
|
|
43
|
+
columnSpacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
44
|
+
|
|
45
|
+
/** Defines the `flex-direction` style property. It is applied for all screen sizes. */
|
|
46
|
+
direction: PropTypes.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
|
|
47
|
+
|
|
48
|
+
/** If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for the `lg` breakpoint and wider screens if not overridden. */
|
|
49
|
+
lg: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
50
|
+
|
|
51
|
+
/** If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for the `md` breakpoint and wider screens if not overridden. */
|
|
52
|
+
md: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
53
|
+
|
|
54
|
+
/** Defines the vertical space between the type `Col` components. It overrides the value of the `spacing` prop. */
|
|
55
|
+
rowSpacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
56
|
+
|
|
57
|
+
/** If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for the `sm` breakpoint and wider screens if not overridden. */
|
|
58
|
+
sm: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
59
|
+
|
|
60
|
+
/** Defines the space between the type `Col` components */
|
|
61
|
+
spacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
62
|
+
|
|
63
|
+
/** Defines the flex-wrap style property. It's applied for all screen sizes. */
|
|
64
|
+
wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
|
|
65
|
+
|
|
66
|
+
/** If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for the `xl` breakpoint and wider screens if not overridden. */
|
|
67
|
+
xl: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
68
|
+
|
|
69
|
+
/** If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for all the screen sizes with the lowest priority. */
|
|
70
|
+
xs: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
71
|
+
|
|
72
|
+
/** If `true`, it sets `min-width: 0` on the item. Refer to the limitations section of the documentation to better understand the use case. */
|
|
73
|
+
zeroMinWidth: PropTypes.bool
|
|
74
|
+
};
|
|
75
|
+
export default Row;
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/** @jsxRuntime classic */
|
|
2
|
+
|
|
3
|
+
/** @jsx jsx */
|
|
4
|
+
import { memo, useContext, useRef, useMemo, forwardRef, useImperativeHandle } from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import { jsx, css } from '@emotion/core';
|
|
7
|
+
import GridContext from './context';
|
|
8
|
+
import theme from '../../theme/settings';
|
|
9
|
+
import { breakpointKeys } from '../../theme/createBreakpoints';
|
|
10
|
+
import { borderBox } from '../../styles/general';
|
|
11
|
+
const {
|
|
12
|
+
breakpoints: themeBreakpoints,
|
|
13
|
+
spacing: themeSpacing
|
|
14
|
+
} = theme;
|
|
15
|
+
const Grid = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
16
|
+
id,
|
|
17
|
+
style,
|
|
18
|
+
className,
|
|
19
|
+
children,
|
|
20
|
+
columns: columnsProp,
|
|
21
|
+
columnSpacing: columnSpacingProp,
|
|
22
|
+
container,
|
|
23
|
+
direction,
|
|
24
|
+
item,
|
|
25
|
+
lg,
|
|
26
|
+
md,
|
|
27
|
+
rowSpacing: rowSpacingProp,
|
|
28
|
+
sm,
|
|
29
|
+
spacing,
|
|
30
|
+
wrap,
|
|
31
|
+
xl,
|
|
32
|
+
xs,
|
|
33
|
+
zeroMinWidth
|
|
34
|
+
}, reference) => {
|
|
35
|
+
const columnsContext = useContext(GridContext);
|
|
36
|
+
const rowSpacing = rowSpacingProp || spacing;
|
|
37
|
+
const columnSpacing = columnSpacingProp || spacing;
|
|
38
|
+
const columns = container ? columnsProp : columnsContext;
|
|
39
|
+
const ref = useRef(null);
|
|
40
|
+
|
|
41
|
+
const _GridCSS = GridCSS(direction, zeroMinWidth, container, item, wrap);
|
|
42
|
+
|
|
43
|
+
const _GridSpacingCSS = GridSpacingCSS(rowSpacing, columnSpacing);
|
|
44
|
+
|
|
45
|
+
const _HandleGridCSS = HandleGridCSS([xs, sm, md, lg, xl], columns);
|
|
46
|
+
|
|
47
|
+
useImperativeHandle(reference, () => {
|
|
48
|
+
const currentRef = ref.current || {};
|
|
49
|
+
const _instance = {}; // methods
|
|
50
|
+
|
|
51
|
+
_instance.__proto__ = {}; // hidden methods
|
|
52
|
+
|
|
53
|
+
currentRef.instance = _instance;
|
|
54
|
+
return currentRef;
|
|
55
|
+
});
|
|
56
|
+
return useMemo(() => {
|
|
57
|
+
return jsx("div", {
|
|
58
|
+
id: id,
|
|
59
|
+
ref: ref,
|
|
60
|
+
css: [_GridCSS, container && (rowSpacing || columnSpacing) && _GridSpacingCSS, _HandleGridCSS],
|
|
61
|
+
style: style,
|
|
62
|
+
className: [`DGN-UI-Grid${item ? '-item' : ''}`, className].join(' ').trim().replace(/\s+/g, ' ')
|
|
63
|
+
}, jsx(GridContext.Provider, {
|
|
64
|
+
value: columns
|
|
65
|
+
}, children));
|
|
66
|
+
}, [id, container, item, direction, wrap, rowSpacing, columnSpacing, xs, sm, md, lg, xl, spacing, zeroMinWidth, className, columns, children]);
|
|
67
|
+
}));
|
|
68
|
+
|
|
69
|
+
const getOffset = val => {
|
|
70
|
+
const parse = parseFloat(val);
|
|
71
|
+
return `${parse}${String(val).replace(String(parse), '') || 'px'}`;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const handleBreakpoints = (propValue, cssFromPropValue) => {
|
|
75
|
+
let output = '';
|
|
76
|
+
|
|
77
|
+
if (Array.isArray(propValue)) {
|
|
78
|
+
propValue.map((item, index) => {
|
|
79
|
+
output = output.concat([themeBreakpoints.up(breakpointKeys[index])]).concat(`{${cssFromPropValue(propValue[index])}} `);
|
|
80
|
+
});
|
|
81
|
+
return output;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (typeof propValue === 'object') {
|
|
85
|
+
Object.keys(propValue).map(item => {
|
|
86
|
+
if (breakpointKeys.includes(item)) {
|
|
87
|
+
output = output.concat([themeBreakpoints.up(item)]).concat(`{${cssFromPropValue(propValue[item])}} `);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
return output;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
output = cssFromPropValue(propValue);
|
|
94
|
+
return output;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const progessSizeArray = sizeArr => {
|
|
98
|
+
let lastValue = false;
|
|
99
|
+
sizeArr = sizeArr.map(item => {
|
|
100
|
+
if (item === false) return lastValue;else lastValue = item;
|
|
101
|
+
return item;
|
|
102
|
+
});
|
|
103
|
+
return sizeArr;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const handleGrid = (size, value, columns) => {
|
|
107
|
+
let css = '';
|
|
108
|
+
|
|
109
|
+
if (value === true) {
|
|
110
|
+
css = `
|
|
111
|
+
flex-basis: 0;
|
|
112
|
+
flex-grow: 1;
|
|
113
|
+
max-width: 100%;
|
|
114
|
+
`;
|
|
115
|
+
} else if (value === 'auto') {
|
|
116
|
+
css = `
|
|
117
|
+
flex-basis: auto;
|
|
118
|
+
flex-grow: 0;
|
|
119
|
+
flex-shrink: 0;
|
|
120
|
+
max-width: none;
|
|
121
|
+
width: auto;
|
|
122
|
+
`;
|
|
123
|
+
} else if (typeof value === 'number' && value !== 0) {
|
|
124
|
+
css = handleBreakpoints(columns, propValue => {
|
|
125
|
+
return `
|
|
126
|
+
flex-basis: ${Math.round(value / propValue * 10e7) / 10e5}%;
|
|
127
|
+
flex-grow: 0;
|
|
128
|
+
max-width: ${Math.round(value / propValue * 10e7) / 10e5}%;
|
|
129
|
+
`;
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return `${themeBreakpoints.up(size)} {
|
|
134
|
+
${css}
|
|
135
|
+
}`;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const GridCSS = (direction, zeroMinWidth, container, item, wrap) => css`
|
|
139
|
+
${borderBox};
|
|
140
|
+
${container && `
|
|
141
|
+
display: flex;
|
|
142
|
+
flex-wrap: ${wrap};
|
|
143
|
+
width: 100%;
|
|
144
|
+
`};
|
|
145
|
+
${item && `
|
|
146
|
+
margin: 0;
|
|
147
|
+
`};
|
|
148
|
+
${zeroMinWidth && `min-width: 0;`}
|
|
149
|
+
${handleBreakpoints(direction, propValue => {
|
|
150
|
+
return `flex-direction: ${propValue}`;
|
|
151
|
+
})};
|
|
152
|
+
`;
|
|
153
|
+
|
|
154
|
+
const GridSpacingCSS = (rowSpacing, columnSpacing) => css`
|
|
155
|
+
${rowSpacing && handleBreakpoints(rowSpacing, propValue => {
|
|
156
|
+
const spacing = typeof propValue === 'number' ? themeSpacing(propValue) : propValue;
|
|
157
|
+
|
|
158
|
+
if (spacing !== '0px') {
|
|
159
|
+
return `
|
|
160
|
+
margin-top: -${getOffset(spacing)};
|
|
161
|
+
& > .DGN-UI-Grid-item {
|
|
162
|
+
padding-top: ${getOffset(spacing)};
|
|
163
|
+
}
|
|
164
|
+
`;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return '';
|
|
168
|
+
})};
|
|
169
|
+
${columnSpacing && handleBreakpoints(columnSpacing, propValue => {
|
|
170
|
+
const spacing = typeof propValue === 'number' ? themeSpacing(propValue) : propValue;
|
|
171
|
+
|
|
172
|
+
if (spacing !== '0px') {
|
|
173
|
+
return `
|
|
174
|
+
width: calc(100% + ${getOffset(spacing)});
|
|
175
|
+
margin-left: -${getOffset(spacing)};
|
|
176
|
+
& > .DGN-UI-Grid-item {
|
|
177
|
+
padding-left: ${getOffset(spacing)};
|
|
178
|
+
}
|
|
179
|
+
`;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return '';
|
|
183
|
+
})};
|
|
184
|
+
`;
|
|
185
|
+
|
|
186
|
+
const HandleGridCSS = (sizeArr, columns) => css`
|
|
187
|
+
${progessSizeArray(sizeArr).map((item, idx) => {
|
|
188
|
+
return handleGrid(breakpointKeys[idx], item, columns);
|
|
189
|
+
})}
|
|
190
|
+
`;
|
|
191
|
+
|
|
192
|
+
Grid.defaultProps = {
|
|
193
|
+
style: {},
|
|
194
|
+
className: '',
|
|
195
|
+
columns: 12,
|
|
196
|
+
container: false,
|
|
197
|
+
item: false,
|
|
198
|
+
lg: false,
|
|
199
|
+
md: false,
|
|
200
|
+
sm: false,
|
|
201
|
+
xl: false,
|
|
202
|
+
xs: false,
|
|
203
|
+
zeroMinWidth: false,
|
|
204
|
+
spacing: 0,
|
|
205
|
+
direction: 'row',
|
|
206
|
+
wrap: 'wrap'
|
|
207
|
+
};
|
|
208
|
+
Grid.propTypes = {
|
|
209
|
+
/** The content of the component. */
|
|
210
|
+
children: PropTypes.node,
|
|
211
|
+
|
|
212
|
+
/** Style inline of component. */
|
|
213
|
+
style: PropTypes.object,
|
|
214
|
+
|
|
215
|
+
/** Class for component. */
|
|
216
|
+
className: PropTypes.string,
|
|
217
|
+
|
|
218
|
+
/** The number of columns. */
|
|
219
|
+
columns: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number, PropTypes.object]),
|
|
220
|
+
|
|
221
|
+
/** Defines the horizontal space between the type `item` components. It overrides the value of the `spacing` prop. */
|
|
222
|
+
columnSpacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
223
|
+
|
|
224
|
+
/** If true, the component will have the flex *container* behavior. You should be wrapping *items* with a *container*. */
|
|
225
|
+
container: PropTypes.bool,
|
|
226
|
+
|
|
227
|
+
/** Defines the `flex-direction` style property. It is applied for all screen sizes. */
|
|
228
|
+
direction: PropTypes.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
|
|
229
|
+
|
|
230
|
+
/** If `true`, the component will have the flex *item* behavior. You should be wrapping *items* with a *container*. */
|
|
231
|
+
item: PropTypes.bool,
|
|
232
|
+
|
|
233
|
+
/** If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for the `lg` breakpoint and wider screens if not overridden. */
|
|
234
|
+
lg: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
235
|
+
|
|
236
|
+
/** If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for the `md` breakpoint and wider screens if not overridden. */
|
|
237
|
+
md: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
238
|
+
|
|
239
|
+
/** Defines the vertical space between the type `item` components. It overrides the value of the `spacing` prop. */
|
|
240
|
+
rowSpacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
241
|
+
|
|
242
|
+
/** If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for the `sm` breakpoint and wider screens if not overridden. */
|
|
243
|
+
sm: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
244
|
+
|
|
245
|
+
/** Defines the space between the type `item` components. It can only be used on a type `container` component. */
|
|
246
|
+
spacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
247
|
+
|
|
248
|
+
/** Defines the flex-wrap style property. It's applied for all screen sizes. */
|
|
249
|
+
wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
|
|
250
|
+
|
|
251
|
+
/** If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for the `xl` breakpoint and wider screens if not overridden. */
|
|
252
|
+
xl: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
253
|
+
|
|
254
|
+
/** If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for all the screen sizes with the lowest priority. */
|
|
255
|
+
xs: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
256
|
+
|
|
257
|
+
/** If `true`, it sets `min-width: 0` on the item. Refer to the limitations section of the documentation to better understand the use case. */
|
|
258
|
+
zeroMinWidth: PropTypes.bool
|
|
259
|
+
};
|
|
260
|
+
export default Grid;
|
package/components/index.js
CHANGED
|
@@ -53,7 +53,11 @@ export { default as HelperText } from './form-control/helper-text';
|
|
|
53
53
|
export { default as TextInput } from './form-control/text-input';
|
|
54
54
|
export { default as MoneyInput } from './form-control/money-input';
|
|
55
55
|
export { default as NumberInput } from './form-control/number-input/index2';
|
|
56
|
-
export { default as Toggle } from './form-control/toggle'; //
|
|
56
|
+
export { default as Toggle } from './form-control/toggle'; // Grid
|
|
57
|
+
|
|
58
|
+
export { default as Grid } from './grid';
|
|
59
|
+
export { default as Row } from './grid/Row';
|
|
60
|
+
export { default as Col } from './grid/Col'; // List
|
|
57
61
|
|
|
58
62
|
export { default as List } from './list/list';
|
|
59
63
|
export { default as ListItem } from './list/list-item';
|
|
@@ -158,16 +158,16 @@ Typography.defaultProps = {
|
|
|
158
158
|
hoverTooltip: false,
|
|
159
159
|
tooltipDirection: 'bottom'
|
|
160
160
|
};
|
|
161
|
-
/** type of text<br/>
|
|
162
|
-
* h1: Title <br/>
|
|
163
|
-
* h2: Header Popup <br/>
|
|
164
|
-
* h3: Header popup <br/>
|
|
165
|
-
* h4: Button, Tab, Title group <br/>
|
|
166
|
-
* h5: Label column, Title group <br/>
|
|
167
|
-
* h6: Label form <br/>
|
|
168
|
-
* p1: Body text <br/>
|
|
169
|
-
* p2: Body text <br/>
|
|
170
|
-
* p3: Notice, Tooltip <br/>
|
|
161
|
+
/** type of text<br/>
|
|
162
|
+
* h1: Title <br/>
|
|
163
|
+
* h2: Header Popup <br/>
|
|
164
|
+
* h3: Header popup <br/>
|
|
165
|
+
* h4: Button, Tab, Title group <br/>
|
|
166
|
+
* h5: Label column, Title group <br/>
|
|
167
|
+
* h6: Label form <br/>
|
|
168
|
+
* p1: Body text <br/>
|
|
169
|
+
* p2: Body text <br/>
|
|
170
|
+
* p3: Notice, Tooltip <br/>
|
|
171
171
|
*/
|
|
172
172
|
|
|
173
173
|
export const arrTypeTypography = ['t1', 't2', 't3', 't4', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p1', 'p2', 'p3', 'title1', 'title2', 'title3', 'title4', 'heading1', 'heading2', 'heading3', 'heading4', 'heading5', 'heading6', 'paragraph1', 'paragraph2', 'paragraph3'];
|
package/package.json
CHANGED
package/styles/general.js
CHANGED
|
@@ -16,13 +16,16 @@ export const zIndex = number => {
|
|
|
16
16
|
return rootZIndex + number;
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
19
|
-
* get value spacing with
|
|
20
|
-
* @param vl - default 1
|
|
21
|
-
* @returns {number}
|
|
19
|
+
* get value spacing with rootSpacing
|
|
20
|
+
* @param {(number|number[])} vl - default 1
|
|
21
|
+
* @returns {(number|string)}
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
export const getSpacing = (vl = 1) => {
|
|
25
|
-
return Number(vl) * rootSpacing;
|
|
25
|
+
if (typeof vl === 'number') return Number(vl) * rootSpacing;else if (Array.isArray(vl)) {
|
|
26
|
+
if (vl.length > 4) vl.length = 4;
|
|
27
|
+
return `${vl.flatMap(i => Number(i !== null && i !== void 0 ? i : 0) * rootSpacing).join('px ')}px`;
|
|
28
|
+
}
|
|
26
29
|
};
|
|
27
30
|
/**
|
|
28
31
|
* replace rootZIndex
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// Sorted ASC by size. That's important.
|
|
2
|
+
// It can't be configured as it's used statically for propTypes.
|
|
3
|
+
export const breakpointKeys = ['xs', 'sm', 'md', 'lg', 'xl'];
|
|
4
|
+
|
|
5
|
+
const sortBreakpointsValues = values => {
|
|
6
|
+
const breakpointsAsArray = Object.keys(values).map(key => ({
|
|
7
|
+
key,
|
|
8
|
+
val: values[key]
|
|
9
|
+
})) || []; // Sort in ascending order
|
|
10
|
+
|
|
11
|
+
breakpointsAsArray.sort((breakpoint1, breakpoint2) => breakpoint1.val - breakpoint2.val);
|
|
12
|
+
return breakpointsAsArray.reduce((acc, obj) => {
|
|
13
|
+
return { ...acc,
|
|
14
|
+
[obj.key]: obj.val
|
|
15
|
+
};
|
|
16
|
+
}, {});
|
|
17
|
+
}; // Keep in mind that @media is inclusive by the CSS specification.
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
const createBreakpoints = breakpoints => {
|
|
21
|
+
const {
|
|
22
|
+
// The breakpoint **start** at this value.
|
|
23
|
+
// For instance with the first breakpoint xs: [xs, sm).
|
|
24
|
+
values = {
|
|
25
|
+
xs: 0,
|
|
26
|
+
// extra-small
|
|
27
|
+
sm: 600,
|
|
28
|
+
// small
|
|
29
|
+
md: 900,
|
|
30
|
+
// medium
|
|
31
|
+
lg: 1200,
|
|
32
|
+
// large
|
|
33
|
+
xl: 1536 // extra-large
|
|
34
|
+
|
|
35
|
+
},
|
|
36
|
+
unit = 'px',
|
|
37
|
+
step = 5,
|
|
38
|
+
...other
|
|
39
|
+
} = breakpoints;
|
|
40
|
+
const sortedValues = sortBreakpointsValues(values);
|
|
41
|
+
const keys = Object.keys(sortedValues);
|
|
42
|
+
|
|
43
|
+
const up = key => {
|
|
44
|
+
const value = typeof values[key] === 'number' ? values[key] : key;
|
|
45
|
+
return `@media (min-width:${value}${unit})`;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const down = key => {
|
|
49
|
+
const value = typeof values[key] === 'number' ? values[key] : key;
|
|
50
|
+
return `@media (max-width:${value - step / 100}${unit})`;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const between = (start, end) => {
|
|
54
|
+
const endIndex = keys.indexOf(end);
|
|
55
|
+
return `@media (min-width:${typeof values[start] === 'number' ? values[start] : start}${unit}) and ` + `(max-width:${(endIndex !== -1 && typeof values[keys[endIndex]] === 'number' ? values[keys[endIndex]] : end) - step / 100}${unit})`;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const only = key => {
|
|
59
|
+
if (keys.indexOf(key) + 1 < keys.length) {
|
|
60
|
+
return between(key, keys[keys.indexOf(key) + 1]);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return up(key);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const not = key => {
|
|
67
|
+
// handle first and last key separately, for better readability
|
|
68
|
+
const keyIndex = keys.indexOf(key);
|
|
69
|
+
|
|
70
|
+
if (keyIndex === 0) {
|
|
71
|
+
return up(keys[1]);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (keyIndex === keys.length - 1) {
|
|
75
|
+
return down(keys[keyIndex]);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return between(key, keys[keys.indexOf(key) + 1]).replace('@media', '@media not all and');
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
keys,
|
|
83
|
+
values: sortedValues,
|
|
84
|
+
up,
|
|
85
|
+
down,
|
|
86
|
+
between,
|
|
87
|
+
only,
|
|
88
|
+
not,
|
|
89
|
+
unit,
|
|
90
|
+
...other
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export default createBreakpoints;
|
package/theme/make-styles.js
CHANGED
package/theme/settings.js
CHANGED
|
@@ -9,6 +9,7 @@ const {
|
|
|
9
9
|
fontFamilyMedium
|
|
10
10
|
} = font;
|
|
11
11
|
import { typography as typographies } from '../styles/typography';
|
|
12
|
+
import createBreakpoints from './createBreakpoints';
|
|
12
13
|
const settings = {
|
|
13
14
|
border: {
|
|
14
15
|
radius: '4px',
|
|
@@ -55,53 +56,22 @@ const settings = {
|
|
|
55
56
|
},
|
|
56
57
|
...typographies
|
|
57
58
|
},
|
|
58
|
-
breakpoints: {
|
|
59
|
+
breakpoints: createBreakpoints({
|
|
59
60
|
values: {
|
|
60
61
|
xs: 0,
|
|
62
|
+
// extra-small
|
|
61
63
|
sm: 600,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
},
|
|
64
|
+
// small
|
|
65
|
+
md: 900,
|
|
66
|
+
// medium
|
|
67
|
+
lg: 1200,
|
|
68
|
+
// large
|
|
69
|
+
xl: 1536 // extra-large
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
}),
|
|
71
73
|
spacing: vl => getSpacing(vl),
|
|
72
74
|
zIndex: vl => zIndex(vl),
|
|
73
75
|
setZIndex: vl => setZIndex(vl)
|
|
74
76
|
};
|
|
75
|
-
|
|
76
|
-
const getMedia = (value, type, value2 = '') => {
|
|
77
|
-
const values = settings.breakpoints.values;
|
|
78
|
-
let px1,
|
|
79
|
-
px2 = '';
|
|
80
|
-
|
|
81
|
-
if (typeof value === 'number') {
|
|
82
|
-
px1 = value + 'px'; // eslint-disable-next-line no-constant-condition
|
|
83
|
-
} else if (/^xs|sm|md|lg|xl$/) {
|
|
84
|
-
px1 = values[value] - (type === 'max' ? 0.05 : 0) + 'px';
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (value2) {
|
|
88
|
-
const keys = Object.keys(values);
|
|
89
|
-
|
|
90
|
-
if (value2 === value) {
|
|
91
|
-
// only
|
|
92
|
-
value2 = values[keys[keys.indexOf(value) + 1]] - 0.05 + 'px';
|
|
93
|
-
} else {
|
|
94
|
-
if (typeof value2 === 'number') {
|
|
95
|
-
value2 += 'px'; // eslint-disable-next-line no-constant-condition
|
|
96
|
-
} else if (/^xs|sm|md|lg|xl$/) {
|
|
97
|
-
value2 = values[keys[keys.indexOf(value2) + 1]] - 0.05 + 'px';
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
px2 = ` and (max-width: ${value2})`;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return `@media (${type}-width: ${px1}${px2})`;
|
|
105
|
-
};
|
|
106
|
-
|
|
107
77
|
export default settings;
|