@mackin.com/styleguide 7.9.1 → 7.10.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/index.d.ts +9 -5
- package/index.js +38 -20
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -204,17 +204,21 @@ interface FileUploaderProps {
|
|
|
204
204
|
instructionMessage?: string;
|
|
205
205
|
/** For additional info below the instructionMessage. */
|
|
206
206
|
infoMessage?: string | JSX.Element;
|
|
207
|
+
/** If false, the 'infoMessage' will be hidden when a file is picked. Defaults to 'true' */
|
|
208
|
+
showInfoOnPick?: boolean;
|
|
209
|
+
disabled?: boolean;
|
|
207
210
|
}
|
|
208
|
-
declare const FileUploader: (p: FileUploaderProps) => JSX.Element;
|
|
211
|
+
declare const FileUploader: (p: FileUploaderProps) => JSX.Element;
|
|
212
|
+
declare const getFileSizeDisplay: (size: number) => string;
|
|
209
213
|
|
|
210
|
-
declare type
|
|
211
|
-
interface
|
|
214
|
+
declare type BaseProps = React.ClassAttributes<HTMLFormElement> & React.FormHTMLAttributes<HTMLFormElement>;
|
|
215
|
+
interface FormProps extends BaseProps {
|
|
212
216
|
inline?: boolean;
|
|
213
217
|
/** If true, preventDefault and stopPropagation will be applied prior to onSubmit being called. Defaults to true. */
|
|
214
218
|
ajax?: boolean;
|
|
215
219
|
}
|
|
216
220
|
/** Use this instead of <form> directly. If we need to fight Chrome's autofill, we can do so at a global level. */
|
|
217
|
-
declare const Form: React.ForwardRefExoticComponent<Pick<
|
|
221
|
+
declare const Form: React.ForwardRefExoticComponent<Pick<FormProps, "inline" | "ajax" | "key" | "acceptCharset" | "action" | "autoComplete" | "encType" | "method" | "name" | "noValidate" | "target" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture"> & React.RefAttributes<HTMLFormElement>>;
|
|
218
222
|
declare const FormFlexRow: (props: {
|
|
219
223
|
children: React.ReactNode;
|
|
220
224
|
className?: string;
|
|
@@ -981,4 +985,4 @@ declare const WaitingIndicator: (p: {
|
|
|
981
985
|
debug?: boolean;
|
|
982
986
|
}) => JSX.Element;
|
|
983
987
|
|
|
984
|
-
export { Alignment, Autocomplete, AutocompleteProps, AutocompleteValue, Backdrop$1 as Backdrop, Backdrop as Backdrop2, BoundMemoryPager, BoundStaticPager, Button, ButtonProps, Calendar, CalendarProps, Checkbox, CheckboxProps, ConfirmModal, ConfirmModalProps, CopyButton, DateInput, DateInputProps, DatePicker, DatePickerProps, Divider, ErrorModal, FileUploader, Form, FormColumnRow, FormFlexRow, 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, mergeClassNames, useMediaQuery, useThemeSafely };
|
|
988
|
+
export { Alignment, Autocomplete, AutocompleteProps, AutocompleteValue, Backdrop$1 as Backdrop, Backdrop as Backdrop2, BoundMemoryPager, BoundStaticPager, Button, ButtonProps, Calendar, CalendarProps, Checkbox, CheckboxProps, ConfirmModal, ConfirmModalProps, CopyButton, DateInput, DateInputProps, DatePicker, DatePickerProps, 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, mergeClassNames, useMediaQuery, useThemeSafely };
|
package/index.js
CHANGED
|
@@ -1731,7 +1731,7 @@ const hoverClass = css.css({
|
|
|
1731
1731
|
backgroundColor: 'rgba(0,0,0,0.25) !important'
|
|
1732
1732
|
});
|
|
1733
1733
|
const FileUploader = (p) => {
|
|
1734
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
1734
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1735
1735
|
const [message, setMessage] = React.useState(undefined);
|
|
1736
1736
|
const [canUpload, setCanUpload] = React.useState(false);
|
|
1737
1737
|
const [uploading, setUploading] = React.useState(false);
|
|
@@ -1747,7 +1747,7 @@ const FileUploader = (p) => {
|
|
|
1747
1747
|
filesDisplay = (_b = p.instructionMessage) !== null && _b !== void 0 ? _b : `Click or drag and drop files.`;
|
|
1748
1748
|
}
|
|
1749
1749
|
else {
|
|
1750
|
-
filesDisplay = `${files.length.toLocaleString()} file${files.length > 1 ? 's' : ''} selected (${
|
|
1750
|
+
filesDisplay = `${files.length.toLocaleString()} file${files.length > 1 ? 's' : ''} selected (${getFileSizeDisplay(totalFileSize)}): ${files.files.map(f => f.name).join(', ')}`;
|
|
1751
1751
|
}
|
|
1752
1752
|
}
|
|
1753
1753
|
const setAllFiles = (inputFiles) => {
|
|
@@ -1769,8 +1769,9 @@ const FileUploader = (p) => {
|
|
|
1769
1769
|
maxBytes: p.maxBytes
|
|
1770
1770
|
});
|
|
1771
1771
|
};
|
|
1772
|
+
const showInfoOnPick = (_c = p.showInfoOnPick) !== null && _c !== void 0 ? _c : true;
|
|
1772
1773
|
let infoMessage;
|
|
1773
|
-
if (p.infoMessage) {
|
|
1774
|
+
if (p.infoMessage && (!files || showInfoOnPick)) {
|
|
1774
1775
|
if (typeof p.infoMessage === 'string') {
|
|
1775
1776
|
infoMessage = React__default['default'].createElement(Text, { noPad: true }, p.infoMessage);
|
|
1776
1777
|
}
|
|
@@ -1787,6 +1788,8 @@ const FileUploader = (p) => {
|
|
|
1787
1788
|
padding: '1rem',
|
|
1788
1789
|
overflow: 'hidden',
|
|
1789
1790
|
backgroundColor: theme.colors.lightBg,
|
|
1791
|
+
}, p.disabled && {
|
|
1792
|
+
opacity: theme.controls.disabledOpacity
|
|
1790
1793
|
}), onDragOver: e => {
|
|
1791
1794
|
var _a, _b;
|
|
1792
1795
|
e.preventDefault();
|
|
@@ -1820,7 +1823,7 @@ const FileUploader = (p) => {
|
|
|
1820
1823
|
setCanUpload(false);
|
|
1821
1824
|
});
|
|
1822
1825
|
} },
|
|
1823
|
-
React__default['default'].createElement("input", { ref: input, className: css.css({
|
|
1826
|
+
React__default['default'].createElement("input", { disabled: p.disabled, ref: input, className: css.css({
|
|
1824
1827
|
position: 'absolute',
|
|
1825
1828
|
top: -50,
|
|
1826
1829
|
left: 0,
|
|
@@ -1829,6 +1832,8 @@ const FileUploader = (p) => {
|
|
|
1829
1832
|
width: '100%',
|
|
1830
1833
|
cursor: 'pointer',
|
|
1831
1834
|
opacity: 0
|
|
1835
|
+
}, p.disabled && {
|
|
1836
|
+
cursor: 'not-allowed'
|
|
1832
1837
|
}), type: "file", multiple: p.multiple, accept: p.accept, onChange: e => {
|
|
1833
1838
|
try {
|
|
1834
1839
|
if (!e.target.files) {
|
|
@@ -1851,26 +1856,28 @@ const FileUploader = (p) => {
|
|
|
1851
1856
|
zIndex: !!(files === null || files === void 0 ? void 0 : files.length) ? 1 : undefined
|
|
1852
1857
|
}) },
|
|
1853
1858
|
!(files === null || files === void 0 ? void 0 : files.length) && React__default['default'].createElement(Icon, { style: { fontSize: '2rem' }, id: "upload" }),
|
|
1854
|
-
React__default['default'].createElement(Text, { align: "center", noPad: true, spacedOut: true
|
|
1859
|
+
React__default['default'].createElement(Text, { align: "center", noPad: true, spacedOut: true, className: css.css({
|
|
1860
|
+
width: '100%'
|
|
1861
|
+
}) },
|
|
1855
1862
|
filesDisplay,
|
|
1856
1863
|
!!(files === null || files === void 0 ? void 0 : files.length) && (React__default['default'].createElement(Button, { onClick: e => {
|
|
1857
1864
|
e.stopPropagation();
|
|
1858
1865
|
onFilesChange(undefined);
|
|
1859
1866
|
}, className: css.css({ marginLeft: '1rem', color: theme.colors.negative }), rightIcon: React__default['default'].createElement(Icon, { id: "clear" }), variant: "inlineLink" }, "Clear"))),
|
|
1860
1867
|
infoMessage,
|
|
1861
|
-
!!(files === null || files === void 0 ? void 0 : files.invalidFiles.length) && (React__default['default'].createElement(InfoPanel, { variant: "error" },
|
|
1868
|
+
!!(files === null || files === void 0 ? void 0 : files.invalidFiles.length) && (React__default['default'].createElement(InfoPanel, { variant: "error", className: css.css({ width: '100%' }) },
|
|
1862
1869
|
"Invalid files: ",
|
|
1863
1870
|
files.invalidFiles.map(f => f.name).join(', '),
|
|
1864
1871
|
".")),
|
|
1865
|
-
(files === null || files === void 0 ? void 0 : files.overMaxBytes) && (React__default['default'].createElement(InfoPanel, { variant: "error" },
|
|
1872
|
+
(files === null || files === void 0 ? void 0 : files.overMaxBytes) && (React__default['default'].createElement(InfoPanel, { variant: "error", className: css.css({ width: '100%' }) },
|
|
1866
1873
|
"Max file size exceeded (",
|
|
1867
|
-
|
|
1874
|
+
getFileSizeDisplay((_d = p.maxBytes) !== null && _d !== void 0 ? _d : 0),
|
|
1868
1875
|
").")))),
|
|
1869
1876
|
canUpload && !(files === null || files === void 0 ? void 0 : files.hasErrors) && (React__default['default'].createElement(Button, { className: css.css({
|
|
1870
|
-
width: (
|
|
1877
|
+
width: (_e = p.buttonWidth) !== null && _e !== void 0 ? _e : '10rem',
|
|
1871
1878
|
zIndex: 1,
|
|
1872
|
-
}), waiting: uploading, type: "submit", variant: (
|
|
1873
|
-
message === 'success' && (React__default['default'].createElement(UploadInfoPanel, { variant: "positive", message: (
|
|
1879
|
+
}), waiting: uploading, type: "submit", variant: (_f = p.buttonVariant) !== null && _f !== void 0 ? _f : 'primary' }, (_g = p.buttonText) !== null && _g !== void 0 ? _g : 'Upload')),
|
|
1880
|
+
message === 'success' && (React__default['default'].createElement(UploadInfoPanel, { variant: "positive", message: (_h = p.successMessage) !== null && _h !== void 0 ? _h : 'Upload successful.', onClear: () => setMessage(undefined) })),
|
|
1874
1881
|
message === 'failure' && (React__default['default'].createElement(UploadInfoPanel, { variant: "error", message: fullFailureMessage, onClear: () => setMessage(undefined) }))));
|
|
1875
1882
|
};
|
|
1876
1883
|
const UploadInfoPanel = (p) => {
|
|
@@ -1884,18 +1891,28 @@ const UploadInfoPanel = (p) => {
|
|
|
1884
1891
|
p.onClear();
|
|
1885
1892
|
}, rightIcon: React__default['default'].createElement(Icon, { id: "clear" }), variant: "inlineLink" }, "Clear")));
|
|
1886
1893
|
};
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
const
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1894
|
+
// OMG this is dumb. We're sticking with decimals for ease of use.
|
|
1895
|
+
// https://stackoverflow.com/questions/40949135/gigabyte-or-gibibyte-1000-or-1024
|
|
1896
|
+
const getFileSizeDisplay = (size) => {
|
|
1897
|
+
let value = 0;
|
|
1898
|
+
let suffix = '';
|
|
1899
|
+
if (size >= 1000000000) {
|
|
1900
|
+
value = size / 1000000000;
|
|
1901
|
+
suffix = 'GB';
|
|
1902
|
+
}
|
|
1903
|
+
else if (size >= 1000000) {
|
|
1904
|
+
value = size / 1000000;
|
|
1905
|
+
suffix = 'MB';
|
|
1906
|
+
}
|
|
1907
|
+
else if (size >= 1000) {
|
|
1908
|
+
value = size / 1000;
|
|
1909
|
+
suffix = 'KB';
|
|
1895
1910
|
}
|
|
1896
1911
|
else {
|
|
1897
|
-
|
|
1912
|
+
value = size;
|
|
1913
|
+
suffix = 'B';
|
|
1898
1914
|
}
|
|
1915
|
+
return value.toLocaleString(undefined, { minimumFractionDigits: 1, maximumFractionDigits: 1 }) + ` ${suffix}`;
|
|
1899
1916
|
};
|
|
1900
1917
|
|
|
1901
1918
|
/** @deprecated This will not work correctly with emotion/css. Use 'cx' for adding multiple class names together. */
|
|
@@ -3863,6 +3880,7 @@ exports.WaitingIndicator = WaitingIndicator;
|
|
|
3863
3880
|
exports.calcDynamicThemeProps = calcDynamicThemeProps;
|
|
3864
3881
|
exports.defaultTheme = defaultTheme;
|
|
3865
3882
|
exports.getCurrencyDisplay = getCurrencyDisplay;
|
|
3883
|
+
exports.getFileSizeDisplay = getFileSizeDisplay;
|
|
3866
3884
|
exports.mergeClassNames = mergeClassNames;
|
|
3867
3885
|
exports.useMediaQuery = useMediaQuery;
|
|
3868
3886
|
exports.useThemeSafely = useThemeSafely;
|