@spscommerce/ds-react 5.26.1 → 6.0.0-rc1

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.
@@ -1,23 +1,21 @@
1
- import { MomentRange } from '@spscommerce/ds-shared';
2
- import * as momentImport from 'moment-timezone';
3
- import { Moment } from 'moment-timezone';
4
- import * as PropTypes from '../prop-types';
1
+ import type { SimpleDate, SimpleDateRange, DatePreset } from "@spscommerce/ds-shared";
2
+ import * as PropTypes from "../prop-types";
3
+ import type { SpsFormFieldMeta } from "../form/hooks/useSpsForm";
5
4
  declare const propTypes: {
6
- placeholder: PropTypes.Requireable<string>;
7
5
  disabled: PropTypes.Requireable<boolean>;
8
- format: PropTypes.Requireable<string>;
9
- minDate: PropTypes.Requireable<string>;
10
- maxDate: PropTypes.Requireable<string>;
11
- availablePresets: PropTypes.Requireable<any[]>;
12
- onChange: PropTypes.Requireable<(newValue: MomentRange) => void>;
13
- value: PropTypes.Requireable<MomentRange>;
14
- preset: PropTypes.Requireable<momentImport.Duration>;
6
+ formMeta: PropTypes.Requireable<SpsFormFieldMeta<SimpleDateRange | DatePreset>>;
7
+ maxDate: PropTypes.Requireable<SimpleDate>;
8
+ minDate: PropTypes.Requireable<SimpleDate>;
9
+ onChange: PropTypes.Requireable<(newDateRange: SimpleDateRange | DatePreset) => void>;
10
+ presets: PropTypes.Requireable<DatePreset[]>;
15
11
  children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
16
12
  className: PropTypes.Requireable<string>;
17
13
  "data-testid": PropTypes.Requireable<string>;
18
14
  unsafelyReplaceClassName: PropTypes.Requireable<string>;
19
15
  };
20
- export declare function weekOfMonth(mmt: Moment): number;
21
- export declare type SpsDateRangePickerProps = PropTypes.InferTS<typeof propTypes, HTMLDivElement>;
22
- export declare function SpsDateRangePicker(props: SpsDateRangePickerProps): JSX.Element;
16
+ export declare type SpsDateRangePickerProps = {
17
+ value?: SimpleDateRange | DatePreset;
18
+ } & Omit<PropTypes.InferTS<typeof propTypes, HTMLInputElement>, "value">;
19
+ export declare const DEFAULT_PRESETS: DatePreset[];
20
+ export declare function SpsDateRangePicker({ children, className, disabled, formMeta, id, maxDate, minDate, onChange, presets, value, "data-testid": testId, ...rest }: SpsDateRangePickerProps): JSX.Element;
23
21
  export {};
@@ -0,0 +1,21 @@
1
+ import type { SimpleDate, SimpleDateRange, DatePreset } from "@spscommerce/ds-shared";
2
+ import * as PropTypes from "../prop-types";
3
+ import type { SpsFormFieldMeta } from "../form/hooks/useSpsForm";
4
+ declare const propTypes: {
5
+ disabled: PropTypes.Requireable<boolean>;
6
+ formMeta: PropTypes.Requireable<SpsFormFieldMeta<SimpleDateRange | DatePreset>>;
7
+ maxDate: PropTypes.Requireable<SimpleDate>;
8
+ minDate: PropTypes.Requireable<SimpleDate>;
9
+ onChange: PropTypes.Requireable<(newDateRange: SimpleDateRange | DatePreset) => void>;
10
+ presets: PropTypes.Requireable<DatePreset[]>;
11
+ children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
12
+ className: PropTypes.Requireable<string>;
13
+ "data-testid": PropTypes.Requireable<string>;
14
+ unsafelyReplaceClassName: PropTypes.Requireable<string>;
15
+ };
16
+ export declare type SpsDateRangePickerProps = {
17
+ value?: SimpleDateRange | DatePreset;
18
+ } & Omit<PropTypes.InferTS<typeof propTypes, HTMLInputElement>, "value">;
19
+ export declare const DEFAULT_PRESETS: DatePreset[];
20
+ export declare function SpsDateRangePicker({ children, className, disabled, formMeta, id, maxDate, minDate, onChange, presets, value, "data-testid": testId, ...rest }: SpsDateRangePickerProps): JSX.Element;
21
+ export {};
@@ -1,19 +1,18 @@
1
- import type { Moment } from "moment-timezone";
1
+ import type { SimpleDate } from "@spscommerce/ds-shared";
2
2
  import * as PropTypes from "../prop-types";
3
+ import type { SpsFormFieldMeta } from "../form/hooks/useSpsForm";
3
4
  declare const propTypes: {
4
5
  disabled: PropTypes.Requireable<boolean>;
5
- format: PropTypes.Requireable<string>;
6
- maxDate: PropTypes.Requireable<string>;
7
- minDate: PropTypes.Requireable<string>;
8
- onChange: PropTypes.Requireable<(newValue: Moment) => void>;
9
- onClickOutside: PropTypes.Requireable<(event: MouseEvent) => void>;
10
- placeholder: PropTypes.Requireable<string>;
11
- value: PropTypes.Requireable<string>;
6
+ formMeta: PropTypes.Requireable<SpsFormFieldMeta<SimpleDate>>;
7
+ maxDate: PropTypes.Requireable<SimpleDate>;
8
+ minDate: PropTypes.Requireable<SimpleDate>;
9
+ onChange: PropTypes.Requireable<(newDate: SimpleDate) => void>;
10
+ value: PropTypes.Requireable<SimpleDate>;
12
11
  children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
13
12
  className: PropTypes.Requireable<string>;
14
13
  "data-testid": PropTypes.Requireable<string>;
15
14
  unsafelyReplaceClassName: PropTypes.Requireable<string>;
16
15
  };
17
- export declare type SpsDatepickerProps = PropTypes.InferTS<typeof propTypes, HTMLDivElement>;
18
- declare function SpsDatepicker(props: SpsDatepickerProps): JSX.Element;
19
- export { SpsDatepicker };
16
+ export declare type SpsDatepickerProps = PropTypes.InferTS<typeof propTypes, HTMLInputElement>;
17
+ export declare function SpsDatepicker({ children, className, disabled, formMeta, id, maxDate, minDate, onChange, value, "data-testid": testId, ...rest }: SpsDatepickerProps): JSX.Element;
18
+ export {};
@@ -0,0 +1,18 @@
1
+ import type { SimpleDate, SimpleDateRange } from "@spscommerce/ds-shared";
2
+ import * as PropTypes from "../prop-types";
3
+ declare const propTypes: {
4
+ maxDate: PropTypes.Requireable<SimpleDate>;
5
+ minDate: PropTypes.Requireable<SimpleDate>;
6
+ onNewSelection: PropTypes.Validator<(date: SimpleDate) => void>;
7
+ selectedDate: PropTypes.Requireable<SimpleDate>;
8
+ selectedRange: PropTypes.Requireable<SimpleDate[]>;
9
+ children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
10
+ className: PropTypes.Requireable<string>;
11
+ "data-testid": PropTypes.Requireable<string>;
12
+ unsafelyReplaceClassName: PropTypes.Requireable<string>;
13
+ };
14
+ export interface SpsDatepickerCalendarProps extends PropTypes.InferTS<typeof propTypes, HTMLDivElement> {
15
+ selectedRange?: SimpleDateRange;
16
+ }
17
+ export declare function SpsDatepickerCalendar(props: SpsDatepickerCalendarProps): JSX.Element;
18
+ export {};
@@ -0,0 +1,13 @@
1
+ import * as React from "react";
2
+ import * as PropTypes from "../prop-types";
3
+ declare const propTypes: {
4
+ attachTo: PropTypes.Validator<React.MutableRefObject<HTMLElement>>;
5
+ isOpen: PropTypes.Validator<boolean>;
6
+ children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
7
+ className: PropTypes.Requireable<string>;
8
+ "data-testid": PropTypes.Requireable<string>;
9
+ unsafelyReplaceClassName: PropTypes.Requireable<string>;
10
+ };
11
+ export declare type SpsDatepickerPopupProps = PropTypes.InferTS<typeof propTypes, HTMLDivElement>;
12
+ export declare const SpsDatepickerPopup: React.ForwardRefExoticComponent<Pick<SpsDatepickerPopupProps, "accept" | "acceptCharset" | "action" | "allowFullScreen" | "allowTransparency" | "alt" | "as" | "async" | "autoComplete" | "autoFocus" | "autoPlay" | "capture" | "cellPadding" | "cellSpacing" | "charSet" | "challenge" | "checked" | "cite" | "classID" | "cols" | "colSpan" | "content" | "controls" | "coords" | "crossOrigin" | "data" | "dateTime" | "default" | "defer" | "disabled" | "download" | "encType" | "form" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "frameBorder" | "headers" | "height" | "high" | "href" | "hrefLang" | "htmlFor" | "httpEquiv" | "integrity" | "keyParams" | "keyType" | "kind" | "label" | "list" | "loop" | "low" | "manifest" | "marginHeight" | "marginWidth" | "max" | "maxLength" | "media" | "mediaGroup" | "method" | "min" | "minLength" | "multiple" | "muted" | "name" | "nonce" | "noValidate" | "open" | "optimum" | "pattern" | "placeholder" | "playsInline" | "poster" | "preload" | "readOnly" | "rel" | "required" | "reversed" | "rows" | "rowSpan" | "sandbox" | "scope" | "scoped" | "scrolling" | "seamless" | "selected" | "shape" | "size" | "sizes" | "span" | "src" | "srcDoc" | "srcLang" | "srcSet" | "start" | "step" | "summary" | "target" | "type" | "useMap" | "value" | "width" | "wmode" | "wrap" | "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" | "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" | "key" | "data-testid" | "unsafelyReplaceClassName" | "isOpen" | "attachTo"> & React.RefAttributes<HTMLDivElement>>;
13
+ export {};
@@ -1,2 +1,4 @@
1
1
  export * from "./SpsDatepicker";
2
+ export { SimpleDateUtils } from "./utils";
3
+ export * from "./validation";
2
4
  export * from "./SpsDatepicker.examples";
@@ -0,0 +1,2 @@
1
+ import type { CalendarArray, SimpleDate } from "@spscommerce/ds-shared";
2
+ export declare function useCalendar(month: SimpleDate): CalendarArray;
@@ -0,0 +1,3 @@
1
+ import type { SimpleDate } from "@spscommerce/ds-shared";
2
+ import type { Moment } from "moment";
3
+ export declare function useMoment(date: SimpleDate): Moment;
@@ -0,0 +1,23 @@
1
+ import type { SimpleDate, SimpleDateRange, DatePreset } from "@spscommerce/ds-shared";
2
+ import type { Moment } from "moment-timezone";
3
+ export declare const FORMAT = "MM/DD/YYYY";
4
+ export declare const FORMAT_PATTERN: RegExp;
5
+ export declare const SYMBOL_DATE_PARSE_ERROR: unique symbol;
6
+ export declare const SimpleDateUtils: Readonly<{
7
+ createFrom(input: string | Moment): SimpleDate;
8
+ createRangeFrom(input: string): SimpleDateRange;
9
+ isValid(date: SimpleDate): boolean;
10
+ nullifyInvalidDate(value: any): SimpleDate | null;
11
+ toMoment(date: SimpleDate): Moment;
12
+ toString(date: SimpleDate): string;
13
+ toStringRange(dateRange: SimpleDateRange): string;
14
+ create(): SimpleDate;
15
+ isSameDate(d1: SimpleDate, d2: SimpleDate): boolean;
16
+ isSameMonth(d1: SimpleDate, d2: SimpleDate): boolean;
17
+ isAfter(date: SimpleDate, referenceDate: SimpleDate): boolean;
18
+ isBefore(date: SimpleDate, referenceDate: SimpleDate): boolean;
19
+ isInRange(date: SimpleDate, range: SimpleDateRange, inclusive?: boolean): boolean;
20
+ prevMonth(date: SimpleDate): SimpleDate;
21
+ nextMonth(date: SimpleDate): SimpleDate;
22
+ createRangeFromPreset(preset: DatePreset): SimpleDateRange;
23
+ }>;
@@ -0,0 +1,10 @@
1
+ import type { SimpleDate, SimpleDateRange } from "@spscommerce/ds-shared";
2
+ import type { Duration } from "moment-timezone";
3
+ import type { SpsValidator, SpsValidatorFactory } from "../form/validation/types";
4
+ export declare const date: SpsValidator<SimpleDate | SimpleDateRange>;
5
+ export declare const dateRange: SpsValidator<SimpleDateRange | Duration>;
6
+ export interface DateConstraintError {
7
+ minExceeded: string | null;
8
+ maxExceeded: string | null;
9
+ }
10
+ export declare const dateConstraint: SpsValidatorFactory<SimpleDate | SimpleDateRange>;