@mackin.com/styleguide 8.11.2 → 9.0.0-beta.1
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 +18 -20
- package/index.js +34 -16
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -209,8 +209,8 @@ interface FileUploaderProps {
|
|
|
209
209
|
declare const FileUploader: (p: FileUploaderProps) => JSX.Element;
|
|
210
210
|
declare const getFileSizeDisplay: (size: number) => string;
|
|
211
211
|
|
|
212
|
-
declare type BaseProps$
|
|
213
|
-
interface FormProps extends BaseProps$
|
|
212
|
+
declare type BaseProps$4 = React.ClassAttributes<HTMLFormElement> & React.FormHTMLAttributes<HTMLFormElement>;
|
|
213
|
+
interface FormProps extends BaseProps$4 {
|
|
214
214
|
inline?: boolean;
|
|
215
215
|
/** If true, preventDefault and stopPropagation will be applied prior to onSubmit being called. Defaults to true. */
|
|
216
216
|
ajax?: boolean;
|
|
@@ -326,8 +326,8 @@ interface ValidationMessageProps {
|
|
|
326
326
|
patternErrorMessage?: string;
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
-
declare type BaseProps$
|
|
330
|
-
interface DateInputProps extends BaseProps$
|
|
329
|
+
declare type BaseProps$3 = Omit<BaseInputProps, 'type' | 'value' | 'min' | 'max' | 'step' | 'pattern' | 'maxLength' | 'rightControl' | 'ref'> & Omit<ValidationMessageProps, 'pattern'>;
|
|
330
|
+
interface DateInputProps extends BaseProps$3 {
|
|
331
331
|
/** The epoch timestamp. Equivalent to Date.valueOf(). */
|
|
332
332
|
value?: number;
|
|
333
333
|
/** The min epoch timestamp. */
|
|
@@ -384,8 +384,8 @@ interface InputProps {
|
|
|
384
384
|
/** @deprecated Use DateInput, NumberInput, or TextInput instead. */
|
|
385
385
|
declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<any>>;
|
|
386
386
|
|
|
387
|
-
declare type BaseProps$
|
|
388
|
-
interface NumberInputProps extends BaseProps$
|
|
387
|
+
declare type BaseProps$2 = Omit<BaseInputProps, 'type' | 'value' | 'min' | 'max' | 'step' | 'maxLength' | 'error' | 'pattern'> & Omit<ValidationMessageProps, 'pattern'>;
|
|
388
|
+
interface NumberInputProps extends BaseProps$2 {
|
|
389
389
|
value?: number;
|
|
390
390
|
min?: number;
|
|
391
391
|
max?: number;
|
|
@@ -397,8 +397,8 @@ interface NumberInputProps extends BaseProps$1 {
|
|
|
397
397
|
}
|
|
398
398
|
declare const NumberInput: React.ForwardRefExoticComponent<Pick<NumberInputProps, "value" | "min" | "max" | "step" | "rightControl" | "round" | "wrapperClassName" | "showErrorDisplay" | "key" | "accept" | "alt" | "autoComplete" | "autoFocus" | "capture" | "checked" | "crossOrigin" | "disabled" | "enterKeyHint" | "form" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "height" | "list" | "minLength" | "multiple" | "name" | "placeholder" | "readOnly" | "required" | "size" | "src" | "width" | "onChange" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "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" | "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" | "customError" | "patternErrorMessage" | "onValueChange"> & React.RefAttributes<HTMLInputElement>>;
|
|
399
399
|
|
|
400
|
-
declare type BaseProps = Omit<BaseInputProps, 'type' | 'value' | 'max' | 'min' | 'step' | 'error'> & ValidationMessageProps;
|
|
401
|
-
interface TextInputProps extends BaseProps {
|
|
400
|
+
declare type BaseProps$1 = Omit<BaseInputProps, 'type' | 'value' | 'max' | 'min' | 'step' | 'error'> & ValidationMessageProps;
|
|
401
|
+
interface TextInputProps extends BaseProps$1 {
|
|
402
402
|
value?: string;
|
|
403
403
|
/** Defaults to 'text'. */
|
|
404
404
|
type?: 'text' | 'email' | 'url' | 'password';
|
|
@@ -717,25 +717,23 @@ declare const ProgressBar: (props: {
|
|
|
717
717
|
className?: string;
|
|
718
718
|
}) => JSX.Element;
|
|
719
719
|
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
placeholder?: string;
|
|
725
|
-
round?: boolean;
|
|
726
|
-
/** Defaults to 250ms */
|
|
727
|
-
debounceMs?: number;
|
|
728
|
-
autoFocus?: boolean;
|
|
729
|
-
/** This will be applied to the containing element (Form). */
|
|
730
|
-
className?: string;
|
|
720
|
+
declare type BaseProps = Omit<TextInputProps, 'rightControl' | 'wrapperClassName' | 'type' | 'className'>;
|
|
721
|
+
interface SearchBoxProps extends BaseProps {
|
|
722
|
+
/** This will be applied to the containing element (Form or DIV when 'noForm'=true). */
|
|
723
|
+
wrapperClassName?: string;
|
|
731
724
|
buttonClassName?: string;
|
|
725
|
+
inputWrapperClassName?: string;
|
|
732
726
|
inputClassName?: string;
|
|
733
727
|
/** This will be ignored if 'noForm' is true. */
|
|
734
728
|
onSubmit?: () => Promise<void>;
|
|
735
729
|
/** If true, the controls will not be wrapped in a Form component. In addition, 'onSubmit' will be ignored. */
|
|
736
730
|
noForm?: boolean;
|
|
731
|
+
/** If true, the onSubmit handler will not be called when the input value is nullish or empty string. Defaults to 'true'. */
|
|
732
|
+
noSubmitWhenEmpty?: boolean;
|
|
733
|
+
/** The submit button will change to clear if present and there is a value. */
|
|
734
|
+
onClear?: () => void;
|
|
737
735
|
}
|
|
738
|
-
declare const SearchBox:
|
|
736
|
+
declare const SearchBox: React.ForwardRefExoticComponent<Pick<SearchBoxProps, "wrapperClassName" | "value" | "round" | "showErrorDisplay" | "key" | "accept" | "alt" | "autoComplete" | "autoFocus" | "capture" | "checked" | "crossOrigin" | "disabled" | "enterKeyHint" | "form" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "height" | "list" | "maxLength" | "minLength" | "multiple" | "name" | "pattern" | "placeholder" | "readOnly" | "required" | "size" | "src" | "width" | "onChange" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "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" | "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" | "trim" | "emptyString" | "onValueChange" | "customError" | "patternErrorMessage" | "buttonClassName" | "inputWrapperClassName" | "inputClassName" | "noForm" | "noSubmitWhenEmpty" | "onClear"> & React.RefAttributes<HTMLInputElement>>;
|
|
739
737
|
|
|
740
738
|
declare type Alignment = 'left' | 'right' | 'center';
|
|
741
739
|
|
package/index.js
CHANGED
|
@@ -3833,31 +3833,49 @@ const useWaiting = (func) => {
|
|
|
3833
3833
|
return [waiting, wrappedFunc];
|
|
3834
3834
|
};
|
|
3835
3835
|
|
|
3836
|
-
const SearchBox = (props) => {
|
|
3837
|
-
const
|
|
3836
|
+
const SearchBox = React__namespace.forwardRef((props, ref) => {
|
|
3837
|
+
const { wrapperClassName, buttonClassName, inputWrapperClassName, inputClassName, onSubmit, noForm, noSubmitWhenEmpty: onSubmitWhenEmpty, onClear } = props, inputProps = __rest(props, ["wrapperClassName", "buttonClassName", "inputWrapperClassName", "inputClassName", "onSubmit", "noForm", "noSubmitWhenEmpty", "onClear"]);
|
|
3838
|
+
const [waiting, handleSubmit] = useWaiting(async () => {
|
|
3838
3839
|
var _a, _b, _c;
|
|
3840
|
+
if (noForm) {
|
|
3841
|
+
return;
|
|
3842
|
+
}
|
|
3843
|
+
if (!props.onSubmit) {
|
|
3844
|
+
return;
|
|
3845
|
+
}
|
|
3846
|
+
if (((_a = props.noSubmitWhenEmpty) !== null && _a !== void 0 ? _a : true) && !props.value) {
|
|
3847
|
+
return;
|
|
3848
|
+
}
|
|
3839
3849
|
// the active element will be the input. if the submit action changes props.value it will
|
|
3840
3850
|
// be ignored due to Inputs focused handling.
|
|
3841
3851
|
if (document.activeElement) {
|
|
3842
|
-
(
|
|
3852
|
+
(_c = (_b = document.activeElement).blur) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
3843
3853
|
}
|
|
3844
|
-
return
|
|
3854
|
+
return props.onSubmit();
|
|
3845
3855
|
});
|
|
3846
3856
|
const theme = useThemeSafely();
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3857
|
+
let button;
|
|
3858
|
+
const buttonStyles = css.cx(css.css({
|
|
3859
|
+
color: `${theme.colors.font} !important;`,
|
|
3860
|
+
fontSize: '1rem'
|
|
3861
|
+
}), props.buttonClassName);
|
|
3862
|
+
if (props.onClear && !!props.value) {
|
|
3863
|
+
button = (React__namespace.createElement(Button, { onClick: props.onClear, tabIndex: -1, disabled: waiting, className: buttonStyles, variant: "icon", small: true },
|
|
3864
|
+
React__namespace.createElement(Icon, { id: waiting ? 'waiting' : 'clear', spin: waiting })));
|
|
3865
|
+
}
|
|
3866
|
+
else {
|
|
3867
|
+
button = (React__namespace.createElement(Button, { tabIndex: -1, disabled: waiting, readOnly: !props.onSubmit, type: "submit", className: buttonStyles, variant: "icon", small: true },
|
|
3868
|
+
React__namespace.createElement(Icon, { id: waiting ? 'waiting' : 'search', spin: waiting })));
|
|
3869
|
+
}
|
|
3870
|
+
const input = (React__namespace.createElement(TextInput, Object.assign({}, inputProps, { ref: ref, wrapperClassName: props.inputWrapperClassName, className: props.inputClassName, rightControl: button })));
|
|
3871
|
+
const searchBoxWrapperStyles = css.cx(css.css({
|
|
3872
|
+
label: 'SearchBox'
|
|
3873
|
+
}), props.wrapperClassName);
|
|
3856
3874
|
if (!props.noForm) {
|
|
3857
|
-
return (React__namespace.createElement(Form, { role: "search", className:
|
|
3875
|
+
return (React__namespace.createElement(Form, { role: "search", className: searchBoxWrapperStyles, onSubmit: handleSubmit }, input));
|
|
3858
3876
|
}
|
|
3859
|
-
return (React__namespace.createElement("div", { className:
|
|
3860
|
-
};
|
|
3877
|
+
return (React__namespace.createElement("div", { className: searchBoxWrapperStyles }, input));
|
|
3878
|
+
});
|
|
3861
3879
|
|
|
3862
3880
|
const GlobalStyles = (p) => {
|
|
3863
3881
|
const theme = useThemeSafely();
|