@mackin.com/styleguide 8.0.0-beta.22 → 8.0.0-beta.23
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 +19 -5
- package/index.js +34 -28
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -282,13 +282,20 @@ interface InfoTipProps {
|
|
|
282
282
|
onClose?: () => void;
|
|
283
283
|
/** Defaults to 'info'. */
|
|
284
284
|
variant?: 'info' | 'modal';
|
|
285
|
-
modalHeader?: string;
|
|
286
285
|
/** Defaults to nav color. */
|
|
287
286
|
bgColor?: string;
|
|
288
287
|
/** Defaults to nav font color. */
|
|
289
288
|
fontColor?: string;
|
|
289
|
+
/** For variant=modal only. */
|
|
290
|
+
modalHeader?: string;
|
|
291
|
+
/** For variant=modal only. */
|
|
290
292
|
modalId?: string;
|
|
291
|
-
|
|
293
|
+
/** For variant=modal only. */
|
|
294
|
+
__modalDebug?: boolean;
|
|
295
|
+
/** Whether to move the popover on collision with the parent's bounds. Default is false. For variant=info only. */
|
|
296
|
+
reposition?: boolean;
|
|
297
|
+
/** Order of positions as the Popover colides with the window edge. The default order is ['right', 'top', 'left', 'bottom']. For variant=info only. */
|
|
298
|
+
positions?: ("bottom" | "left" | "right" | "top")[] | undefined;
|
|
292
299
|
}
|
|
293
300
|
declare const InfoTip: (props: InfoTipProps) => JSX.Element;
|
|
294
301
|
|
|
@@ -686,7 +693,7 @@ interface PopoverProps {
|
|
|
686
693
|
border?: string;
|
|
687
694
|
/** Popover background. Defaults to theme.colors.bg. */
|
|
688
695
|
backgroundColor?: string;
|
|
689
|
-
/** Order of positions as the Popover colides with the window edge. */
|
|
696
|
+
/** Order of positions as the Popover colides with the window edge. The default order is ['right', 'top', 'left', 'bottom']. */
|
|
690
697
|
positions?: ("bottom" | "left" | "right" | "top")[] | undefined;
|
|
691
698
|
}
|
|
692
699
|
declare const Popover: (p: PopoverProps) => JSX.Element;
|
|
@@ -721,7 +728,14 @@ declare type Alignment = 'left' | 'right' | 'center';
|
|
|
721
728
|
|
|
722
729
|
declare const GlobalStyles: () => null;
|
|
723
730
|
|
|
724
|
-
declare const getCurrencyDisplay: (value: number, isCents?: boolean | undefined, denomination?: string) => string;
|
|
731
|
+
declare const getCurrencyDisplay: (value: number, isCents?: boolean | undefined, denomination?: string) => string;
|
|
732
|
+
/** Converts an enum to an array of entities with id and name. The enum can be an integer or string enum.*/
|
|
733
|
+
declare const enumToEntities: <T extends {
|
|
734
|
+
[key: string]: string | number;
|
|
735
|
+
}>(enumObj: T) => {
|
|
736
|
+
id: string | number;
|
|
737
|
+
name: string;
|
|
738
|
+
}[];
|
|
725
739
|
|
|
726
740
|
interface MackinTheme {
|
|
727
741
|
colors: {
|
|
@@ -1008,4 +1022,4 @@ declare const useWaiting: <TArgs extends any[], TReturn>(func: (...args: TArgs)
|
|
|
1008
1022
|
*/
|
|
1009
1023
|
declare const useBooleanChanged: (effect: (current: boolean, previous: boolean) => void, dep: boolean | undefined) => void;
|
|
1010
1024
|
|
|
1011
|
-
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, PickerOption, PickerProps, PickerValue, 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, useBooleanChanged, useIgnoreMount, useMediaQuery, useScrollbarSize, useThemeSafely, useWaiting };
|
|
1025
|
+
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, PickerOption, PickerProps, PickerValue, 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, enumToEntities, getCurrencyDisplay, getFileSizeDisplay, useAccordianState, useBooleanChanged, useIgnoreMount, useMediaQuery, useScrollbarSize, useThemeSafely, useWaiting };
|
package/index.js
CHANGED
|
@@ -1148,9 +1148,6 @@ const BackdropContextProvider = (p) => {
|
|
|
1148
1148
|
log('un-mounted');
|
|
1149
1149
|
};
|
|
1150
1150
|
}, []);
|
|
1151
|
-
React.useEffect(() => {
|
|
1152
|
-
log('re-rendered');
|
|
1153
|
-
});
|
|
1154
1151
|
useIgnoreMount(() => {
|
|
1155
1152
|
log('showCount changed', showCount);
|
|
1156
1153
|
}, [showCount]);
|
|
@@ -1202,9 +1199,6 @@ const BackdropOverlay = (p) => {
|
|
|
1202
1199
|
log('unmounted');
|
|
1203
1200
|
};
|
|
1204
1201
|
}, []);
|
|
1205
|
-
React.useEffect(() => {
|
|
1206
|
-
log('re-rendered');
|
|
1207
|
-
});
|
|
1208
1202
|
useIgnoreMount(() => {
|
|
1209
1203
|
log('context.showing changed', context.showing);
|
|
1210
1204
|
}, [context.showing]);
|
|
@@ -1464,6 +1458,7 @@ const Modal = (p) => {
|
|
|
1464
1458
|
const hasHeader = p.closeButton || p.heading;
|
|
1465
1459
|
const contentRef = React__default['default'].useRef(null);
|
|
1466
1460
|
const log = useLogger((_a = p.id) !== null && _a !== void 0 ? _a : 'Modal', (_b = p.__debug) !== null && _b !== void 0 ? _b : false);
|
|
1461
|
+
const showing = React.useRef(p.show);
|
|
1467
1462
|
const tryRemoveBodyStyles = () => {
|
|
1468
1463
|
if (backdrop.showCount <= 1 && htmlBodyStyles) {
|
|
1469
1464
|
log('backdrop.showCount', backdrop.showCount, 'removing singleton htmlBodyStyles');
|
|
@@ -1474,10 +1469,7 @@ const Modal = (p) => {
|
|
|
1474
1469
|
log('mounted');
|
|
1475
1470
|
return () => {
|
|
1476
1471
|
var _a;
|
|
1477
|
-
|
|
1478
|
-
//TB: BUG, handle unmounted if already showing.
|
|
1479
|
-
// p.show here doesn't work. we need some sort of ref that is controlled via the p.show call below
|
|
1480
|
-
if (p.show) {
|
|
1472
|
+
if (showing.current) {
|
|
1481
1473
|
log(`un-mount in progress and this modal is showing. decrement the backdrop and try to remove singleton body styles.`);
|
|
1482
1474
|
backdrop.setShow(false, (_a = p.id) !== null && _a !== void 0 ? _a : 'Modal');
|
|
1483
1475
|
log('backdrop.setShow', false);
|
|
@@ -1493,10 +1485,12 @@ const Modal = (p) => {
|
|
|
1493
1485
|
var _a;
|
|
1494
1486
|
log('show changed', `${previousShow !== null && previousShow !== void 0 ? previousShow : 'undefined'} > ${show}`);
|
|
1495
1487
|
backdrop.setShow(show, (_a = p.id) !== null && _a !== void 0 ? _a : 'Modal');
|
|
1488
|
+
showing.current = show;
|
|
1496
1489
|
log('backdrop.setShow', show);
|
|
1497
1490
|
if (!htmlBodyStyles) {
|
|
1498
1491
|
log('creating singleton htmlBodyStyles');
|
|
1499
1492
|
htmlBodyStyles = css.css({
|
|
1493
|
+
label: 'ModalBodyOverrides',
|
|
1500
1494
|
overflow: 'hidden',
|
|
1501
1495
|
paddingRight: `${useScrollbarSize()}px`
|
|
1502
1496
|
});
|
|
@@ -1973,18 +1967,8 @@ const getFileSizeDisplay = (size) => {
|
|
|
1973
1967
|
return value.toLocaleString(undefined, { minimumFractionDigits: 1, maximumFractionDigits: 1 }) + ` ${suffix}`;
|
|
1974
1968
|
};
|
|
1975
1969
|
|
|
1976
|
-
const getCurrencyDisplay = (value, isCents, denomination = '$') => {
|
|
1977
|
-
let actualValue = value || 0;
|
|
1978
|
-
if (isCents) {
|
|
1979
|
-
actualValue /= 100;
|
|
1980
|
-
}
|
|
1981
|
-
return `${denomination}${actualValue.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
|
1982
|
-
};
|
|
1983
|
-
const noop = () => {
|
|
1984
|
-
// lil' noop would be a great rap name. (thanks linter)
|
|
1985
|
-
};
|
|
1986
|
-
|
|
1987
1970
|
const Header = (props) => {
|
|
1971
|
+
var _a;
|
|
1988
1972
|
const theme = useThemeSafely();
|
|
1989
1973
|
const bodyStyles = css.css `
|
|
1990
1974
|
padding-top: calc(${theme.layout.headerHeight} + ${theme.layout.headerBodyOffset});
|
|
@@ -1996,7 +1980,9 @@ const Header = (props) => {
|
|
|
1996
1980
|
document.body.classList.remove(bodyStyles);
|
|
1997
1981
|
};
|
|
1998
1982
|
});
|
|
1999
|
-
const toggleMenu = props.toggleMenu
|
|
1983
|
+
const toggleMenu = (_a = props.toggleMenu) !== null && _a !== void 0 ? _a : (() => {
|
|
1984
|
+
/* noop */
|
|
1985
|
+
});
|
|
2000
1986
|
const headerStyles = css.css `
|
|
2001
1987
|
display: flex;
|
|
2002
1988
|
gap: ${theme.controls.gap};
|
|
@@ -2126,7 +2112,7 @@ const Popover = (p) => {
|
|
|
2126
2112
|
};
|
|
2127
2113
|
|
|
2128
2114
|
const InfoTip = (props) => {
|
|
2129
|
-
var _a, _b;
|
|
2115
|
+
var _a, _b, _c;
|
|
2130
2116
|
const [showTip, setShowTip] = React__namespace.useState(false);
|
|
2131
2117
|
const theme = useThemeSafely();
|
|
2132
2118
|
const bgColor = (_a = props.bgColor) !== null && _a !== void 0 ? _a : theme.colors.nav;
|
|
@@ -2188,13 +2174,13 @@ const InfoTip = (props) => {
|
|
|
2188
2174
|
if (props.variant === 'modal') {
|
|
2189
2175
|
return (React__namespace.createElement(React__namespace.Fragment, null,
|
|
2190
2176
|
button,
|
|
2191
|
-
React__namespace.createElement(Modal, { id: props.modalId, __debug: props.
|
|
2177
|
+
React__namespace.createElement(Modal, { id: props.modalId, __debug: props.__modalDebug, show: showTip, heading: props.modalHeader, onClick: closeTip, className: css.css({
|
|
2192
2178
|
whiteSpace: 'normal'
|
|
2193
2179
|
}), closeButton: true },
|
|
2194
2180
|
React__namespace.createElement("div", { className: css.css({ padding: '1rem' }) }, props.content))));
|
|
2195
2181
|
}
|
|
2196
2182
|
else {
|
|
2197
|
-
return (React__namespace.createElement(Popover, { reposition: false, isOpen: showTip, onClickOutside: closeTip, arrorColor: bgColor, border: '', backgroundColor: bgColor, parent: button, content: (React__namespace.createElement("div", { className: css.css({
|
|
2183
|
+
return (React__namespace.createElement(Popover, { positions: props.positions, reposition: (_c = props.reposition) !== null && _c !== void 0 ? _c : false, isOpen: showTip, onClickOutside: closeTip, arrorColor: bgColor, border: '', backgroundColor: bgColor, parent: button, content: (React__namespace.createElement("div", { className: css.css({
|
|
2198
2184
|
padding: '0.5rem',
|
|
2199
2185
|
fontSize: '0.75rem',
|
|
2200
2186
|
maxWidth: '22rem'
|
|
@@ -3716,6 +3702,28 @@ const GlobalStyles = () => {
|
|
|
3716
3702
|
return null;
|
|
3717
3703
|
};
|
|
3718
3704
|
|
|
3705
|
+
const getCurrencyDisplay = (value, isCents, denomination = '$') => {
|
|
3706
|
+
let actualValue = value || 0;
|
|
3707
|
+
if (isCents) {
|
|
3708
|
+
actualValue /= 100;
|
|
3709
|
+
}
|
|
3710
|
+
return `${denomination}${actualValue.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
|
3711
|
+
};
|
|
3712
|
+
/** Converts an enum to an array of entities with id and name. The enum can be an integer or string enum.*/
|
|
3713
|
+
const enumToEntities = (enumObj) => {
|
|
3714
|
+
const entities = [];
|
|
3715
|
+
for (const key in enumObj) {
|
|
3716
|
+
if (isNaN(parseInt(key, 10))) {
|
|
3717
|
+
entities.push({
|
|
3718
|
+
id: enumObj[key],
|
|
3719
|
+
name: key
|
|
3720
|
+
});
|
|
3721
|
+
}
|
|
3722
|
+
}
|
|
3723
|
+
return entities;
|
|
3724
|
+
};
|
|
3725
|
+
//TB: FUTURE Expose in UI.
|
|
3726
|
+
|
|
3719
3727
|
const Slider = (p) => {
|
|
3720
3728
|
const theme = useThemeSafely();
|
|
3721
3729
|
const currentValue = React.useRef(p.value);
|
|
@@ -4173,9 +4181,6 @@ const WaitingIndicator = (p) => {
|
|
|
4173
4181
|
log('unmounted');
|
|
4174
4182
|
};
|
|
4175
4183
|
}, []);
|
|
4176
|
-
React.useEffect(() => {
|
|
4177
|
-
log('re-rendered');
|
|
4178
|
-
});
|
|
4179
4184
|
}
|
|
4180
4185
|
React.useEffect(() => {
|
|
4181
4186
|
log('show changed', p.show);
|
|
@@ -4285,6 +4290,7 @@ exports.Tr = Tr;
|
|
|
4285
4290
|
exports.WaitingIndicator = WaitingIndicator;
|
|
4286
4291
|
exports.calcDynamicThemeProps = calcDynamicThemeProps;
|
|
4287
4292
|
exports.defaultTheme = defaultTheme;
|
|
4293
|
+
exports.enumToEntities = enumToEntities;
|
|
4288
4294
|
exports.getCurrencyDisplay = getCurrencyDisplay;
|
|
4289
4295
|
exports.getFileSizeDisplay = getFileSizeDisplay;
|
|
4290
4296
|
exports.useAccordianState = useAccordianState;
|