@mackin.com/styleguide 8.0.0-beta.14 → 8.0.0-beta.17
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/index.d.ts +11 -6
- package/index.js +52 -44
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -81,7 +81,7 @@ declare const Backdrop: (p: {
|
|
|
81
81
|
children: React__default.ReactNode;
|
|
82
82
|
/** Fade in time. Defaults to 250ms. */
|
|
83
83
|
showTimeMs?: number;
|
|
84
|
-
|
|
84
|
+
__debug?: boolean;
|
|
85
85
|
}) => JSX.Element;
|
|
86
86
|
|
|
87
87
|
declare type ButtonVariant = 'label' | 'circle' | 'icon' | 'link' | 'inlineLink' | 'primary' | 'secondary' | 'omg' | 'primary2' | 'positive' | 'negative';
|
|
@@ -159,7 +159,7 @@ interface ConfirmModalProps {
|
|
|
159
159
|
className?: string;
|
|
160
160
|
variant?: 'omg';
|
|
161
161
|
id?: string;
|
|
162
|
-
|
|
162
|
+
__debug?: boolean;
|
|
163
163
|
}
|
|
164
164
|
declare const ConfirmModal: (props: ConfirmModalProps) => JSX.Element;
|
|
165
165
|
|
|
@@ -176,7 +176,7 @@ declare const ErrorModal: (props: {
|
|
|
176
176
|
message: string;
|
|
177
177
|
show: boolean;
|
|
178
178
|
id?: string;
|
|
179
|
-
|
|
179
|
+
__debug?: boolean;
|
|
180
180
|
close: () => void;
|
|
181
181
|
}) => JSX.Element;
|
|
182
182
|
|
|
@@ -290,7 +290,7 @@ interface InfoTipProps {
|
|
|
290
290
|
/** Defaults to nav font color. */
|
|
291
291
|
fontColor?: string;
|
|
292
292
|
modalId?: string;
|
|
293
|
-
|
|
293
|
+
__debug?: boolean;
|
|
294
294
|
}
|
|
295
295
|
declare const InfoTip: (props: InfoTipProps) => JSX.Element;
|
|
296
296
|
|
|
@@ -440,7 +440,7 @@ interface ModalProps {
|
|
|
440
440
|
scrollable?: boolean;
|
|
441
441
|
id?: string;
|
|
442
442
|
className?: string;
|
|
443
|
-
|
|
443
|
+
__debug?: boolean;
|
|
444
444
|
onClick?: () => void;
|
|
445
445
|
}
|
|
446
446
|
declare const Modal: (p: ModalProps) => React__default.ReactPortal | null;
|
|
@@ -448,6 +448,7 @@ declare const Modal: (p: ModalProps) => React__default.ReactPortal | null;
|
|
|
448
448
|
declare const Nav: (props: {
|
|
449
449
|
show: boolean;
|
|
450
450
|
toggle: (show: boolean) => void;
|
|
451
|
+
id?: string | undefined;
|
|
451
452
|
children?: React.ReactNode;
|
|
452
453
|
responsive?: boolean | undefined;
|
|
453
454
|
className?: string | undefined;
|
|
@@ -804,6 +805,10 @@ interface MackinTheme {
|
|
|
804
805
|
desktop: string;
|
|
805
806
|
tablet: string;
|
|
806
807
|
};
|
|
808
|
+
mediaQueries: {
|
|
809
|
+
desktop: string;
|
|
810
|
+
tablet: string;
|
|
811
|
+
};
|
|
807
812
|
}
|
|
808
813
|
/** Call this on your theme after messing with the props. It will re-build things that depend on sizes and colors. */
|
|
809
814
|
declare const calcDynamicThemeProps: <T extends MackinTheme>(theme: T) => void;
|
|
@@ -980,7 +985,7 @@ declare const WaitingIndicator: (p: {
|
|
|
980
985
|
show: boolean;
|
|
981
986
|
minShowTimeMs?: number;
|
|
982
987
|
id?: string;
|
|
983
|
-
|
|
988
|
+
__debug?: boolean;
|
|
984
989
|
}) => JSX.Element;
|
|
985
990
|
|
|
986
991
|
export { Accordian, AccordianProps, Alignment, Autocomplete, AutocompleteProps, AutocompleteValue, Backdrop$1 as Backdrop, Backdrop as Backdrop2, BoundMemoryPager, BoundStaticPager, Button, ButtonProps, Calendar, CalendarProps, Checkbox, CheckboxProps, ConfirmModal, ConfirmModalProps, CopyButton, DateInput, DateInputProps, Divider, ErrorModal, FileUploader, Form, FormColumnRow, FormFlexRow, FormProps, GlobalStyles, Header, Highlight, ICONS, Icon, Image, InfoPanel, InfoTip, InfoTipProps, Input, InputProps, ItemPager, Label, LabelProps, List, ListItem, ListItemProps, ListProps, MackinTheme, Modal, Nav, NumberInput, NumberInputProps, OmniLink, OmniLinkProps, PagedResult, Pager, PagerProps, Picker, PickerProps, Popover, ProgressBar, ProgressBarProps, SearchBox, SearchBoxProps, Slider, TabHeader, TabHeaderProps, TabLocker, Table, Td, TdCurrency, TdNumber, Text, TextArea, TextAreaProps, TextInput, TextInputProps, TextProps, Th, ThSort, ThemeProvider, ToggleButton, ToggleButtonGroup, ToggleButtonGroupProps, ToggleButtonProps, TogglePasswordInput, Tr, WaitingIndicator, calcDynamicThemeProps, defaultTheme, getCurrencyDisplay, getFileSizeDisplay, useAccordianState, useMediaQuery, useThemeSafely };
|
package/index.js
CHANGED
|
@@ -116,6 +116,8 @@ const calcDynamicThemeProps = (theme) => {
|
|
|
116
116
|
theme.controls.focusOutlineRequiredShadow = `0px 0px 4px 2px ${theme.colors.focusOutlineRequired}`;
|
|
117
117
|
theme.controls.dividerBorder = `2px solid ${theme.colors.divider}`;
|
|
118
118
|
theme.controls.inputErrorMinHeight = `calc(${theme.fonts.sizeSmall} * 1.5 + 4px)`;
|
|
119
|
+
theme.mediaQueries.desktop = `@media(min-width:${theme.breakpoints.desktop})`;
|
|
120
|
+
theme.mediaQueries.tablet = `@media(min-width:${theme.breakpoints.tablet})`;
|
|
119
121
|
};
|
|
120
122
|
const defaultTheme = {
|
|
121
123
|
colors: {
|
|
@@ -203,6 +205,10 @@ const defaultTheme = {
|
|
|
203
205
|
breakpoints: {
|
|
204
206
|
desktop: '800px',
|
|
205
207
|
tablet: '768px'
|
|
208
|
+
},
|
|
209
|
+
mediaQueries: {
|
|
210
|
+
desktop: '',
|
|
211
|
+
tablet: ''
|
|
206
212
|
}
|
|
207
213
|
};
|
|
208
214
|
calcDynamicThemeProps(defaultTheme);
|
|
@@ -1102,6 +1108,19 @@ const Backdrop$1 = (props) => {
|
|
|
1102
1108
|
}, ref: backdrop, className: css.cx('backdrop', styles, props.className) }, props.children));
|
|
1103
1109
|
};
|
|
1104
1110
|
|
|
1111
|
+
/** useEffect but ignores the first call on component mount. */
|
|
1112
|
+
const useIgnoreMount = (effect, deps) => {
|
|
1113
|
+
const mounted = React__default['default'].useRef(false);
|
|
1114
|
+
React__default['default'].useEffect(() => {
|
|
1115
|
+
if (!mounted.current) {
|
|
1116
|
+
mounted.current = true;
|
|
1117
|
+
}
|
|
1118
|
+
else {
|
|
1119
|
+
effect();
|
|
1120
|
+
}
|
|
1121
|
+
}, deps);
|
|
1122
|
+
};
|
|
1123
|
+
|
|
1105
1124
|
const useLogger = (componentName, enabled) => {
|
|
1106
1125
|
return (...messages) => {
|
|
1107
1126
|
if (enabled) {
|
|
@@ -1111,19 +1130,20 @@ const useLogger = (componentName, enabled) => {
|
|
|
1111
1130
|
};
|
|
1112
1131
|
};
|
|
1113
1132
|
|
|
1133
|
+
const portalId = 'backdrop';
|
|
1114
1134
|
const BackdropContext = React__default['default'].createContext({
|
|
1115
1135
|
showing: false,
|
|
1116
1136
|
showCount: 0,
|
|
1117
|
-
portalId:
|
|
1118
|
-
setShow: s => {
|
|
1137
|
+
portalId: portalId,
|
|
1138
|
+
setShow: (s, f) => {
|
|
1119
1139
|
/* empty */
|
|
1120
1140
|
}
|
|
1121
1141
|
});
|
|
1122
1142
|
const BackdropContextProvider = (p) => {
|
|
1123
1143
|
var _a;
|
|
1124
1144
|
const [showCount, setShowCount] = React.useState(0);
|
|
1125
|
-
const log = useLogger('BackdropContextProvider', (_a = p.
|
|
1126
|
-
if (p.
|
|
1145
|
+
const log = useLogger('BackdropContextProvider', (_a = p.__debug) !== null && _a !== void 0 ? _a : false);
|
|
1146
|
+
if (p.__debug) {
|
|
1127
1147
|
React.useEffect(() => {
|
|
1128
1148
|
log('mounted');
|
|
1129
1149
|
return () => {
|
|
@@ -1133,35 +1153,33 @@ const BackdropContextProvider = (p) => {
|
|
|
1133
1153
|
React.useEffect(() => {
|
|
1134
1154
|
log('re-rendered');
|
|
1135
1155
|
});
|
|
1136
|
-
|
|
1156
|
+
useIgnoreMount(() => {
|
|
1137
1157
|
log('showCount changed', showCount);
|
|
1138
1158
|
}, [showCount]);
|
|
1139
1159
|
}
|
|
1140
1160
|
return (React__default['default'].createElement(BackdropContext.Provider, { value: {
|
|
1141
|
-
portalId:
|
|
1161
|
+
portalId: portalId,
|
|
1142
1162
|
showing: showCount > 0,
|
|
1143
1163
|
showCount: showCount,
|
|
1144
|
-
setShow: (show) => {
|
|
1164
|
+
setShow: (show, from) => {
|
|
1145
1165
|
if (show) {
|
|
1146
1166
|
setShowCount(s => {
|
|
1147
1167
|
const count = s + 1;
|
|
1148
|
-
log(
|
|
1149
|
-
log('showCount was', showCount);
|
|
1168
|
+
log(`setShow from ${from} ${s} -> ${count}`);
|
|
1150
1169
|
return count;
|
|
1151
1170
|
});
|
|
1152
1171
|
}
|
|
1153
1172
|
else {
|
|
1154
1173
|
setShowCount(s => {
|
|
1155
1174
|
const count = Math.max(0, s - 1);
|
|
1156
|
-
log(
|
|
1157
|
-
log('showCount was', showCount);
|
|
1175
|
+
log(`setShow from ${from} ${s} -> ${count}`);
|
|
1158
1176
|
return count;
|
|
1159
1177
|
});
|
|
1160
1178
|
}
|
|
1161
1179
|
}
|
|
1162
1180
|
} },
|
|
1163
1181
|
p.children,
|
|
1164
|
-
p.
|
|
1182
|
+
p.__debug && (React__default['default'].createElement("p", { className: css.css({
|
|
1165
1183
|
position: 'fixed',
|
|
1166
1184
|
top: 0, right: 0,
|
|
1167
1185
|
backgroundColor: '#ff00004f',
|
|
@@ -1178,8 +1196,8 @@ const BackdropOverlay = (p) => {
|
|
|
1178
1196
|
const context = React.useContext(BackdropContext);
|
|
1179
1197
|
const theme = useThemeSafely();
|
|
1180
1198
|
const showTimeMs = (_a = p.showTimeMs) !== null && _a !== void 0 ? _a : 250;
|
|
1181
|
-
const log = useLogger('BackdropOverlay', (_b = p.
|
|
1182
|
-
if (p.
|
|
1199
|
+
const log = useLogger('BackdropOverlay', (_b = p.__debug) !== null && _b !== void 0 ? _b : false);
|
|
1200
|
+
if (p.__debug) {
|
|
1183
1201
|
React.useEffect(() => {
|
|
1184
1202
|
log('mounted');
|
|
1185
1203
|
return () => {
|
|
@@ -1189,12 +1207,12 @@ const BackdropOverlay = (p) => {
|
|
|
1189
1207
|
React.useEffect(() => {
|
|
1190
1208
|
log('re-rendered');
|
|
1191
1209
|
});
|
|
1192
|
-
|
|
1210
|
+
useIgnoreMount(() => {
|
|
1193
1211
|
log('context.showing changed', context.showing);
|
|
1194
1212
|
}, [context.showing]);
|
|
1195
1213
|
}
|
|
1196
1214
|
return (React__default['default'].createElement("div", { onClick: () => {
|
|
1197
|
-
context === null || context === void 0 ? void 0 : context.setShow(false);
|
|
1215
|
+
context === null || context === void 0 ? void 0 : context.setShow(false, 'BackdropOverlay');
|
|
1198
1216
|
log('onClick', 'setShow', false);
|
|
1199
1217
|
}, id: context === null || context === void 0 ? void 0 : context.portalId, className: css.css({
|
|
1200
1218
|
cursor: 'pointer',
|
|
@@ -1210,12 +1228,12 @@ const BackdropOverlay = (p) => {
|
|
|
1210
1228
|
}) }));
|
|
1211
1229
|
};
|
|
1212
1230
|
const Backdrop = (p) => {
|
|
1213
|
-
return (React__default['default'].createElement(BackdropContextProvider, {
|
|
1231
|
+
return (React__default['default'].createElement(BackdropContextProvider, { __debug: p.__debug },
|
|
1214
1232
|
React__default['default'].createElement("div", { className: css.css({
|
|
1215
1233
|
height: '100%'
|
|
1216
1234
|
}) },
|
|
1217
1235
|
p.children,
|
|
1218
|
-
React__default['default'].createElement(BackdropOverlay, { showTimeMs: p.showTimeMs,
|
|
1236
|
+
React__default['default'].createElement(BackdropOverlay, { showTimeMs: p.showTimeMs, __debug: p.__debug }))));
|
|
1219
1237
|
};
|
|
1220
1238
|
|
|
1221
1239
|
const Calendar = (p) => {
|
|
@@ -1417,12 +1435,13 @@ const Modal = (p) => {
|
|
|
1417
1435
|
const theme = useThemeSafely();
|
|
1418
1436
|
const hasHeader = p.closeButton || p.heading;
|
|
1419
1437
|
const contentRef = React__default['default'].useRef(null);
|
|
1420
|
-
const log = useLogger(`Modal ${(_a = p.id) !== null && _a !== void 0 ? _a : '?'}`, (_b = p.
|
|
1438
|
+
const log = useLogger(`Modal ${(_a = p.id) !== null && _a !== void 0 ? _a : '?'}`, (_b = p.__debug) !== null && _b !== void 0 ? _b : false);
|
|
1421
1439
|
React.useEffect(() => {
|
|
1422
1440
|
log('mounted');
|
|
1423
1441
|
return () => {
|
|
1442
|
+
var _a;
|
|
1424
1443
|
// handle the use of modals that are rendered only as show=true and then unmounted.
|
|
1425
|
-
backdrop.setShow(false);
|
|
1444
|
+
backdrop.setShow(false, (_a = p.id) !== null && _a !== void 0 ? _a : 'Modal');
|
|
1426
1445
|
log('backdrop.setShow', false);
|
|
1427
1446
|
if (backdrop.showCount <= 1 && htmlBodyStyles) {
|
|
1428
1447
|
log('backdrop.showCount', backdrop.showCount, 'removing htmlBodyStyles');
|
|
@@ -1431,10 +1450,11 @@ const Modal = (p) => {
|
|
|
1431
1450
|
log('un-mounted');
|
|
1432
1451
|
};
|
|
1433
1452
|
}, []);
|
|
1434
|
-
|
|
1453
|
+
useIgnoreMount(() => {
|
|
1454
|
+
var _a;
|
|
1435
1455
|
log('show changed', p.show);
|
|
1436
|
-
backdrop.setShow(p.show);
|
|
1437
|
-
log('backdrop.setShow',
|
|
1456
|
+
backdrop.setShow(p.show, (_a = p.id) !== null && _a !== void 0 ? _a : 'Modal');
|
|
1457
|
+
log('backdrop.setShow', p.show);
|
|
1438
1458
|
if (!htmlBodyStyles) {
|
|
1439
1459
|
log('creating singleton htmlBodyStyles');
|
|
1440
1460
|
htmlBodyStyles = css.css({
|
|
@@ -1553,7 +1573,7 @@ const ConfirmModal = (props) => {
|
|
|
1553
1573
|
}
|
|
1554
1574
|
`}
|
|
1555
1575
|
`;
|
|
1556
|
-
return (React__namespace.createElement(Modal, { id: props.id,
|
|
1576
|
+
return (React__namespace.createElement(Modal, { id: props.id, __debug: props.__debug, className: css.cx('confirmModal', modalStyle, props.className), heading: props.header, closeButton: true, show: props.show, onClick: props.onCancel },
|
|
1557
1577
|
React__namespace.createElement("div", { className: css.css({ padding: '1rem' }) },
|
|
1558
1578
|
React__namespace.createElement(Text, { align: "center" }, props.text),
|
|
1559
1579
|
React__namespace.createElement("div", { className: css.css({ textAlign: 'center' }) },
|
|
@@ -1603,7 +1623,7 @@ const ErrorModal = (props) => {
|
|
|
1603
1623
|
color: ${theme.colors.omgFont};
|
|
1604
1624
|
}
|
|
1605
1625
|
`;
|
|
1606
|
-
return (React__namespace.createElement(Modal, { id: props.id,
|
|
1626
|
+
return (React__namespace.createElement(Modal, { id: props.id, __debug: props.__debug, className: css.cx('errorModal', modalStyles), heading: "Error", closeButton: true, show: props.show, onClick: props.close },
|
|
1607
1627
|
React__namespace.createElement("div", { className: css.css({ padding: '1rem' }) },
|
|
1608
1628
|
React__namespace.createElement(Text, { align: "center" }, message))));
|
|
1609
1629
|
};
|
|
@@ -2130,7 +2150,7 @@ const InfoTip = (props) => {
|
|
|
2130
2150
|
if (props.variant === 'modal') {
|
|
2131
2151
|
return (React__namespace.createElement(React__namespace.Fragment, null,
|
|
2132
2152
|
button,
|
|
2133
|
-
React__namespace.createElement(Modal, { id: props.modalId,
|
|
2153
|
+
React__namespace.createElement(Modal, { id: props.modalId, __debug: props.__debug, show: showTip, heading: props.modalHeader, onClick: closeTip, className: css.css({
|
|
2134
2154
|
whiteSpace: 'normal'
|
|
2135
2155
|
}), closeButton: true },
|
|
2136
2156
|
React__namespace.createElement("div", { className: css.css({ padding: '1rem' }) }, props.content))));
|
|
@@ -2269,19 +2289,6 @@ const tryClampDecimals = (value, step = 0) => {
|
|
|
2269
2289
|
return parseFloat(value.toFixed(decimals));
|
|
2270
2290
|
};
|
|
2271
2291
|
|
|
2272
|
-
/** useEffect but ignores the first call on component mount. */
|
|
2273
|
-
const useIgnoreMount = (effect, deps) => {
|
|
2274
|
-
const mounted = React__default['default'].useRef(false);
|
|
2275
|
-
React__default['default'].useEffect(() => {
|
|
2276
|
-
if (!mounted.current) {
|
|
2277
|
-
mounted.current = true;
|
|
2278
|
-
}
|
|
2279
|
-
else {
|
|
2280
|
-
effect();
|
|
2281
|
-
}
|
|
2282
|
-
}, deps);
|
|
2283
|
-
};
|
|
2284
|
-
|
|
2285
2292
|
/** Common state handling for displaying validation messages with inputs. */
|
|
2286
2293
|
const useInputValidationMessage = (ref, props) => {
|
|
2287
2294
|
const [validationError, setValidationError] = React__default['default'].useState('');
|
|
@@ -2810,8 +2817,9 @@ const Nav = (props) => {
|
|
|
2810
2817
|
props.toggle(false);
|
|
2811
2818
|
}
|
|
2812
2819
|
}, [backdrop.showing]);
|
|
2813
|
-
|
|
2814
|
-
|
|
2820
|
+
useIgnoreMount(() => {
|
|
2821
|
+
var _a;
|
|
2822
|
+
backdrop.setShow(props.show, (_a = props.id) !== null && _a !== void 0 ? _a : 'Nav');
|
|
2815
2823
|
}, [props.show]);
|
|
2816
2824
|
React__namespace.useLayoutEffect(() => {
|
|
2817
2825
|
if (nav && nav.current) {
|
|
@@ -4110,8 +4118,8 @@ const WaitingIndicator = (p) => {
|
|
|
4110
4118
|
const [show, setShow] = React.useState(p.show);
|
|
4111
4119
|
const hideTimer = React.useRef(0);
|
|
4112
4120
|
const lastShowStatus = React.useRef(false);
|
|
4113
|
-
const log = useLogger(`WaitingIndicator ${(_a = p.id) !== null && _a !== void 0 ? _a : '?'}`, (_b = p.
|
|
4114
|
-
if (p.
|
|
4121
|
+
const log = useLogger(`WaitingIndicator ${(_a = p.id) !== null && _a !== void 0 ? _a : '?'}`, (_b = p.__debug) !== null && _b !== void 0 ? _b : false);
|
|
4122
|
+
if (p.__debug) {
|
|
4115
4123
|
React.useEffect(() => {
|
|
4116
4124
|
log('mounted');
|
|
4117
4125
|
return () => {
|
|
@@ -4161,7 +4169,7 @@ const WaitingIndicator = (p) => {
|
|
|
4161
4169
|
}
|
|
4162
4170
|
}
|
|
4163
4171
|
}, [p.show]);
|
|
4164
|
-
return (React__default['default'].createElement(Modal, { id: p.id,
|
|
4172
|
+
return (React__default['default'].createElement(Modal, { id: p.id, __debug: p.__debug, className: "waitingIndicator", show: show, noBackground: true },
|
|
4165
4173
|
React__default['default'].createElement("div", { className: css.css({
|
|
4166
4174
|
color: 'white',
|
|
4167
4175
|
fontSize: '3rem'
|