@mackin.com/styleguide 9.11.3 → 9.12.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 CHANGED
@@ -328,6 +328,8 @@ interface DateInputProps extends BaseProps$4 {
328
328
  max?: number;
329
329
  /** Whether to move the popover on collision with the parent's bounds. Default is true. */
330
330
  reposition?: boolean;
331
+ /** If `true`, the paging buttons for the years will be shown. Default is only the month pagers. */
332
+ pageYear?: boolean;
331
333
  onValueChange: (value: number | undefined) => void;
332
334
  }
333
335
  declare const DateInput: React.ForwardRefExoticComponent<DateInputProps & React.RefAttributes<HTMLInputElement>>;
package/index.esm.js CHANGED
@@ -3,10 +3,10 @@ import React__default, { createContext, useContext, useEffect, useState, useRef,
3
3
  import { cx, css, keyframes, injectGlobal } from '@emotion/css';
4
4
  import { faCheckCircle, faCircle, faChevronDown, faChevronUp, faSquare, faTimesCircle } from '@fortawesome/pro-regular-svg-icons';
5
5
  import { faPlus, faTrashAlt, faSave, faCrow, faTimes, faSync, faCheckSquare } from '@fortawesome/pro-solid-svg-icons';
6
- import { faWifi, faWifiSlash, faBars, faSearch, faQuestionCircle, faNarwhal, faChevronRight, faChevronLeft, faCloudDownload, faCloudUpload, faCalendarAlt, faCopy, faPaste, faEyeSlash, faEye } from '@fortawesome/pro-light-svg-icons';
6
+ import { faWifi, faWifiSlash, faBars, faSearch, faQuestionCircle, faNarwhal, faChevronRight, faChevronLeft, faCloudDownload, faCloudUpload, faChevronDoubleLeft, faChevronDoubleRight, faCalendarAlt, faCopy, faPaste, faEyeSlash, faEye } from '@fortawesome/pro-light-svg-icons';
7
7
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
8
8
  import { uniqueId, sumBy, orderBy, get } from 'lodash';
9
- import { getDaysInMonth, getDay, isSameMonth, isBefore, isAfter, isSameDay, format, endOfMonth, addMonths, startOfMonth, isExists } from 'date-fns';
9
+ import { getDaysInMonth, getDay, isSameMonth, isBefore, isAfter, isSameDay, format, endOfYear, addYears, endOfMonth, addMonths, startOfMonth, startOfYear, isExists } from 'date-fns';
10
10
  import { createPortal } from 'react-dom';
11
11
  import { Popover as Popover$1, ArrowContainer } from 'react-tiny-popover';
12
12
  import { Link as Link$1 } from 'react-router-dom';
@@ -67,6 +67,8 @@ const ICONS = {
67
67
  unselected: faSquare,
68
68
  pagerLeft: faChevronLeft,
69
69
  pagerRight: faChevronRight,
70
+ pagerDoubleLeft: faChevronDoubleLeft,
71
+ pagerDoubleRight: faChevronDoubleRight,
70
72
  sortAsc: faChevronUp,
71
73
  sortDesc: faChevronDown,
72
74
  pickDate: faCalendarAlt,
@@ -1988,6 +1990,11 @@ const FileUploader = (p) => {
1988
1990
  var _a;
1989
1991
  e.preventDefault();
1990
1992
  (_a = form.current) === null || _a === void 0 ? void 0 : _a.classList.remove(hoverClass);
1993
+ if (!p.multiple && e.dataTransfer.files.length > 1) {
1994
+ // we're mimicing the behavior of the file system "pick file" here.
1995
+ // it does not allow for multiple picks at all so we're just going to do the same and ignore.
1996
+ return;
1997
+ }
1991
1998
  onFilesChange(e.dataTransfer.files);
1992
1999
  }, onSubmit: e => {
1993
2000
  if (!files) {
@@ -2385,7 +2392,7 @@ const DateInput = React.forwardRef((props, ref) => {
2385
2392
  }
2386
2393
  }, [dateValue, showCalendar]);
2387
2394
  const popover = React.useRef(null);
2388
- const nativeProps = __rest(props, ["customError", "reposition", "onValueChange", "allowUpdateOnFocus"]);
2395
+ const nativeProps = __rest(props, ["customError", "reposition", "onValueChange", "allowUpdateOnFocus", "pageYear"]);
2389
2396
  useIgnoreMount(() => {
2390
2397
  var _a;
2391
2398
  /*
@@ -2462,6 +2469,8 @@ const DateInput = React.forwardRef((props, ref) => {
2462
2469
  justifyContent: 'space-between',
2463
2470
  alignItems: 'center'
2464
2471
  }) },
2472
+ props.pageYear && (React.createElement(Button, { disabled: !!props.min && isBefore(endOfYear(addYears(calendarDate, -1)), props.min), small: true, variant: "icon", onClick: () => setCalendarDate(addYears(calendarDate, -1)) },
2473
+ React.createElement(Icon, { id: "pagerDoubleLeft" }))),
2465
2474
  React.createElement(Button, { disabled: !!props.min && isBefore(endOfMonth(addMonths(calendarDate, -1)), props.min), small: true, variant: "icon", onClick: () => setCalendarDate(addMonths(calendarDate, -1)) },
2466
2475
  React.createElement(Icon, { id: "pagerLeft" })),
2467
2476
  React.createElement(Text, { align: "center" },
@@ -2469,7 +2478,9 @@ const DateInput = React.forwardRef((props, ref) => {
2469
2478
  " ",
2470
2479
  calendarDate.getFullYear()),
2471
2480
  React.createElement(Button, { disabled: !!props.max && isAfter(startOfMonth(addMonths(calendarDate, 1)), props.max), small: true, variant: "icon", onClick: () => setCalendarDate(addMonths(calendarDate, 1)) },
2472
- React.createElement(Icon, { id: "pagerRight" }))), month: calendarDate.getMonth() + 1, year: calendarDate.getFullYear(), showCurrent: true, smallHeader: true, selectedValue: dateValue, cellSize: '2rem', min: props.min, max: props.max }))) }));
2481
+ React.createElement(Icon, { id: "pagerRight" })),
2482
+ props.pageYear && (React.createElement(Button, { disabled: !!props.max && isAfter(startOfYear(addYears(calendarDate, 1)), props.max), small: true, variant: "icon", onClick: () => setCalendarDate(addYears(calendarDate, 1)) },
2483
+ React.createElement(Icon, { id: "pagerDoubleRight" })))), month: calendarDate.getMonth() + 1, year: calendarDate.getFullYear(), showCurrent: true, smallHeader: true, selectedValue: dateValue, cellSize: '2rem', min: props.min, max: props.max }))) }));
2473
2484
  });
2474
2485
  const parseDateNumber = (rawValue) => {
2475
2486
  if (!rawValue) {
package/index.js CHANGED
@@ -94,6 +94,8 @@ const ICONS = {
94
94
  unselected: proRegularSvgIcons.faSquare,
95
95
  pagerLeft: proLightSvgIcons.faChevronLeft,
96
96
  pagerRight: proLightSvgIcons.faChevronRight,
97
+ pagerDoubleLeft: proLightSvgIcons.faChevronDoubleLeft,
98
+ pagerDoubleRight: proLightSvgIcons.faChevronDoubleRight,
97
99
  sortAsc: proRegularSvgIcons.faChevronUp,
98
100
  sortDesc: proRegularSvgIcons.faChevronDown,
99
101
  pickDate: proLightSvgIcons.faCalendarAlt,
@@ -2015,6 +2017,11 @@ const FileUploader = (p) => {
2015
2017
  var _a;
2016
2018
  e.preventDefault();
2017
2019
  (_a = form.current) === null || _a === void 0 ? void 0 : _a.classList.remove(hoverClass);
2020
+ if (!p.multiple && e.dataTransfer.files.length > 1) {
2021
+ // we're mimicing the behavior of the file system "pick file" here.
2022
+ // it does not allow for multiple picks at all so we're just going to do the same and ignore.
2023
+ return;
2024
+ }
2018
2025
  onFilesChange(e.dataTransfer.files);
2019
2026
  }, onSubmit: e => {
2020
2027
  if (!files) {
@@ -2412,7 +2419,7 @@ const DateInput = React__namespace.forwardRef((props, ref) => {
2412
2419
  }
2413
2420
  }, [dateValue, showCalendar]);
2414
2421
  const popover = React__namespace.useRef(null);
2415
- const nativeProps = __rest(props, ["customError", "reposition", "onValueChange", "allowUpdateOnFocus"]);
2422
+ const nativeProps = __rest(props, ["customError", "reposition", "onValueChange", "allowUpdateOnFocus", "pageYear"]);
2416
2423
  useIgnoreMount(() => {
2417
2424
  var _a;
2418
2425
  /*
@@ -2489,6 +2496,8 @@ const DateInput = React__namespace.forwardRef((props, ref) => {
2489
2496
  justifyContent: 'space-between',
2490
2497
  alignItems: 'center'
2491
2498
  }) },
2499
+ props.pageYear && (React__namespace.createElement(Button, { disabled: !!props.min && dateFns.isBefore(dateFns.endOfYear(dateFns.addYears(calendarDate, -1)), props.min), small: true, variant: "icon", onClick: () => setCalendarDate(dateFns.addYears(calendarDate, -1)) },
2500
+ React__namespace.createElement(Icon, { id: "pagerDoubleLeft" }))),
2492
2501
  React__namespace.createElement(Button, { disabled: !!props.min && dateFns.isBefore(dateFns.endOfMonth(dateFns.addMonths(calendarDate, -1)), props.min), small: true, variant: "icon", onClick: () => setCalendarDate(dateFns.addMonths(calendarDate, -1)) },
2493
2502
  React__namespace.createElement(Icon, { id: "pagerLeft" })),
2494
2503
  React__namespace.createElement(Text, { align: "center" },
@@ -2496,7 +2505,9 @@ const DateInput = React__namespace.forwardRef((props, ref) => {
2496
2505
  " ",
2497
2506
  calendarDate.getFullYear()),
2498
2507
  React__namespace.createElement(Button, { disabled: !!props.max && dateFns.isAfter(dateFns.startOfMonth(dateFns.addMonths(calendarDate, 1)), props.max), small: true, variant: "icon", onClick: () => setCalendarDate(dateFns.addMonths(calendarDate, 1)) },
2499
- React__namespace.createElement(Icon, { id: "pagerRight" }))), month: calendarDate.getMonth() + 1, year: calendarDate.getFullYear(), showCurrent: true, smallHeader: true, selectedValue: dateValue, cellSize: '2rem', min: props.min, max: props.max }))) }));
2508
+ React__namespace.createElement(Icon, { id: "pagerRight" })),
2509
+ props.pageYear && (React__namespace.createElement(Button, { disabled: !!props.max && dateFns.isAfter(dateFns.startOfYear(dateFns.addYears(calendarDate, 1)), props.max), small: true, variant: "icon", onClick: () => setCalendarDate(dateFns.addYears(calendarDate, 1)) },
2510
+ React__namespace.createElement(Icon, { id: "pagerDoubleRight" })))), month: calendarDate.getMonth() + 1, year: calendarDate.getFullYear(), showCurrent: true, smallHeader: true, selectedValue: dateValue, cellSize: '2rem', min: props.min, max: props.max }))) }));
2500
2511
  });
2501
2512
  const parseDateNumber = (rawValue) => {
2502
2513
  if (!rawValue) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mackin.com/styleguide",
3
- "version": "9.11.3",
3
+ "version": "9.12.0",
4
4
  "description": "",
5
5
  "main": "./index.js",
6
6
  "module": "./index.esm.js",