@mackin.com/styleguide 10.1.1 → 10.2.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
@@ -667,17 +667,22 @@ interface PopoverProps {
667
667
  declare const Popover: (p: PopoverProps) => React.JSX.Element;
668
668
 
669
669
  interface ProgressBarProps {
670
+ /** The value in whole pct - 55 NOT 0.55. */
670
671
  pct: number;
672
+ /** If `true`, the bar will be rounded at the corners. */
671
673
  round?: boolean;
674
+ /** If `true`, the current percent will be shown as a label. */
672
675
  showPct?: boolean;
676
+ /** Where to place the pct label from `showPct`. Defaults to `bottom`. Ignored if `showPct` is false. */
677
+ showPctPosition?: 'bottom' | 'right';
678
+ /** This will be applied to the bar. */
673
679
  className?: string;
680
+ /** This will be applied to the bar fill. Override this to change the transitions or remove them. */
681
+ barFillClassName?: string;
682
+ /** Applied to the percent label element. Ignored if `showPct` is false. */
683
+ pctLabelClassName?: string;
674
684
  }
675
- declare const ProgressBar: (props: {
676
- pct: number;
677
- round?: boolean;
678
- showPct?: boolean;
679
- className?: string;
680
- }) => React.JSX.Element;
685
+ declare const ProgressBar: (props: ProgressBarProps) => React.JSX.Element;
681
686
 
682
687
  type BaseProps$1 = Omit<TextInputProps, 'rightControl' | 'wrapperClassName' | 'type' | 'className'> & InputOnFocusProps;
683
688
  interface SearchBoxProps extends BaseProps$1 {
package/index.esm.js CHANGED
@@ -982,11 +982,11 @@ const Autocomplete = (p) => {
982
982
  return p.options.slice(0, maxShowValues);
983
983
  }
984
984
  return p.options.slice();
985
- }, [p.options]);
985
+ }, [p.options, p.allowScroll, maxShowValues]);
986
986
  const { getText, language } = useLocalization();
987
987
  const resultsText = React.useMemo(() => {
988
988
  return `${getText("Showing")} ${displayOptions.length.toLocaleString()} ${getText("of")} ${p.options.length.toLocaleString()} ${getText("results")}.`;
989
- }, [language]);
989
+ }, [language, displayOptions, p.options]);
990
990
  const getNextTabElement = (fromIndex, direction) => {
991
991
  var _a, _b, _c;
992
992
  if (fromIndex === -1) {
@@ -1409,7 +1409,7 @@ const Calendar = (p) => {
1409
1409
  const monthTitle = getText(format(monthStart, 'LLLL'));
1410
1410
  const weekdays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'].map(d => getText(d));
1411
1411
  return { monthTitle, weekdays };
1412
- }, [language]);
1412
+ }, [language, monthStart]);
1413
1413
  const days = getDaysInMonth(monthStart);
1414
1414
  const startDayOfWeek = getDay(monthStart);
1415
1415
  const dayEndIndex = startDayOfWeek + days - 1;
@@ -1766,7 +1766,7 @@ const ConfirmModal = (props) => {
1766
1766
  const confirmText = props.confirmText || getText('OK');
1767
1767
  const cancelText = props.cancelText || getText('Cancel');
1768
1768
  return { confirmText, cancelText };
1769
- }, [language]);
1769
+ }, [language, props.confirmText, props.cancelText]);
1770
1770
  return (React.createElement(Modal, { id: props.id, __debug: props.__debug, className: cx('confirmModal', modalStyle, props.className), heading: props.header, closeButton: true, show: props.show, onClick: props.onCancel },
1771
1771
  React.createElement("div", { className: css({ padding: '1rem' }) },
1772
1772
  React.createElement(Text, { align: "center" }, props.text),
@@ -1783,7 +1783,7 @@ const CopyButton = React.forwardRef((props, ref) => {
1783
1783
  const copiedText = getText('Copied!');
1784
1784
  const titleText = props.title || getText('Copy to clipboard');
1785
1785
  return { copiedText, titleText };
1786
- }, [language]);
1786
+ }, [language, props.title]);
1787
1787
  return (React.createElement(Button, Object.assign({}, buttonProps, { ref: ref, title: copied ? copiedText : titleText, variant: "icon", onBlur: e => {
1788
1788
  var _a;
1789
1789
  setCopied(false);
@@ -1989,7 +1989,7 @@ const FileUploader = (p) => {
1989
1989
  }
1990
1990
  }
1991
1991
  return "";
1992
- }, [language]);
1992
+ }, [language, files, p.instructionMessage, totalFileSize, message]);
1993
1993
  const setAllFiles = (inputFiles) => {
1994
1994
  if (input.current && inputFiles === undefined) {
1995
1995
  input.current.value = '';
@@ -2424,7 +2424,7 @@ const DateInput = React.forwardRef((props, ref) => {
2424
2424
  }, [dateValue, textValue, language]);
2425
2425
  const [showCalendar, setShowCalendar] = React.useState(false);
2426
2426
  const [calendarDate, setCalendarDate] = React.useState(getCalendarDate(props.value, props.min, props.max));
2427
- const monthTitle = React.useMemo(() => getText(format(calendarDate, 'LLLL')), [language]);
2427
+ const monthTitle = React.useMemo(() => getText(format(calendarDate, 'LLLL')), [language, calendarDate]);
2428
2428
  // controls the one-time focus set on show
2429
2429
  const needsFocus = React.useRef(false);
2430
2430
  const toggleCalendar = React.useCallback((show) => {
@@ -3230,7 +3230,7 @@ const Pager = (props) => {
3230
3230
  pageText = `${(_a = props.pageText) !== null && _a !== void 0 ? _a : getText('Page')} ${(props.pageIndex + 1).toLocaleString()} ${dividerText} ${props.totalPages.toLocaleString()}`;
3231
3231
  }
3232
3232
  return { itemText, pageText };
3233
- }, [language]);
3233
+ }, [language, props.totalItems, props.pageIndex, props.totalPages]);
3234
3234
  const theme = useThemeSafely();
3235
3235
  const pagerStyles = css `
3236
3236
  display: grid;
@@ -3282,7 +3282,7 @@ const BoundMemoryPager = (p) => {
3282
3282
  const limitText = (_a = p.limitText) !== null && _a !== void 0 ? _a : getText("Limit");
3283
3283
  const sortText = (_b = p.sortText) !== null && _b !== void 0 ? _b : getText("Sort");
3284
3284
  return { limitText, sortText };
3285
- }, [language]);
3285
+ }, [language, p.limitText, p.sortText]);
3286
3286
  return (React.createElement(Pager, Object.assign({}, rest, { pageIndex: showPageText ? pager.page : undefined, totalPages: showPageText ? pager.totalPages : undefined, canGoNext: pager.hasNext, canGoPrevious: pager.hasPrevious, minItem: pager.minItemIndex + 1, maxItem: pager.maxItemIndex + 1, totalItems: pager.totalItems, leftControls: pager.limitOptions.length > 1 && p.onLimit ? (React.createElement(Label, { text: limitText, orientation: "horizontal" },
3287
3287
  React.createElement(Picker, { value: pager.limit, options: pager.limitOptions, onValueChange: v => { var _a; return (_a = p.onLimit) === null || _a === void 0 ? void 0 : _a.call(p, v); } }))) : undefined, rightControls: pager.sortOptions.length > 1 && p.onSort ? (React.createElement(Label, { text: sortText, orientation: "horizontalReverse" },
3288
3288
  React.createElement(Picker, { value: (_a = pager.sort) !== null && _a !== void 0 ? _a : '', options: pager.sortOptions, onValueChange: v => { var _a; return (_a = p.onSort) === null || _a === void 0 ? void 0 : _a.call(p, v); } }))) : undefined, page: d => {
@@ -3299,7 +3299,7 @@ const BoundStaticPager = (p) => {
3299
3299
  const limitText = (_a = p.limitText) !== null && _a !== void 0 ? _a : getText("Limit");
3300
3300
  const sortText = (_b = p.sortText) !== null && _b !== void 0 ? _b : getText("Sort");
3301
3301
  return { limitText, sortText };
3302
- }, [language]);
3302
+ }, [language, p.limitText, p.sortText]);
3303
3303
  const showLimit = !!(result.limit && p.limitOptions && p.limitOptions.length > 1 && p.onLimit);
3304
3304
  const showSort = !!(p.sort !== undefined && p.sortOptions && p.sortOptions.length > 1 && p.onSort);
3305
3305
  return (React.createElement(Pager, Object.assign({}, rest, { pageIndex: showPageText ? result.page : undefined, totalPages: showPageText ? result.totalPages : undefined, canGoNext: result.hasNext, canGoPrevious: result.hasPrevious, minItem: result.minPageItemIndex + 1, maxItem: result.maxPageItemIndex + 1, totalItems: result.total, leftControls: showLimit ? (React.createElement(Label, { text: limitText, orientation: "horizontal" },
@@ -3665,6 +3665,7 @@ class ItemPager {
3665
3665
  }
3666
3666
 
3667
3667
  const ProgressBar = (props) => {
3668
+ var _a;
3668
3669
  const bar = React.useRef(null);
3669
3670
  React.useEffect(() => {
3670
3671
  const pct = cleanPct(props.pct);
@@ -3690,12 +3691,23 @@ const ProgressBar = (props) => {
3690
3691
  border-radius: 1rem;
3691
3692
  `}
3692
3693
  `;
3693
- return (React.createElement("div", { className: "progressBar" },
3694
+ const showPctPosition = (_a = props.showPctPosition) !== null && _a !== void 0 ? _a : 'bottom';
3695
+ const wrapStyles = css({
3696
+ label: 'ProgressBar',
3697
+ display: 'flex',
3698
+ flexDirection: showPctPosition === 'bottom' ? 'column' : 'row',
3699
+ alignItems: showPctPosition === 'right' ? 'center' : undefined,
3700
+ gap: showPctPosition === 'right' ? '0.5rem' : undefined,
3701
+ });
3702
+ const pctLabelStyles = (props.showPct && props.showPctPosition === 'right') ? css({
3703
+ width: '3rem'
3704
+ }) : undefined;
3705
+ return (React.createElement("div", { className: cx(wrapStyles, "progressBar") },
3694
3706
  React.createElement("div", { className: cx(barStyles, props.className) },
3695
- React.createElement("div", { ref: bar, className: fillStyles })),
3696
- props.showPct && React.createElement(Text, { align: "center", tag: "div", spacedOut: true },
3697
- props.pct,
3698
- "\u00A0%")));
3707
+ React.createElement("div", { ref: bar, className: cx(fillStyles, props.barFillClassName) })),
3708
+ props.showPct && (React.createElement(Text, { align: "center", tag: "div", spacedOut: true, className: cx(pctLabelStyles, props.pctLabelClassName) },
3709
+ cleanPct(props.pct),
3710
+ "%"))));
3699
3711
  };
3700
3712
  const cleanPct = (value) => {
3701
3713
  if (value) {
@@ -3917,7 +3929,7 @@ const HandleText = (p) => {
3917
3929
  const renderValueWidth = (_c = p.renderValueWidth) !== null && _c !== void 0 ? _c : p.sliderHandleSize;
3918
3930
  const renderValueLeft = useMemo(() => {
3919
3931
  return `calc(${renderValueWidth} * 0.5 * -1 + (${p.sliderHandleSize} * 0.5))`;
3920
- }, [p.renderValueWidth]);
3932
+ }, [p.renderValueWidth, p.sliderHandleSize]);
3921
3933
  const [flipText, setFlipText] = useState(false);
3922
3934
  const offset = '2px';
3923
3935
  useEffect(() => {
package/index.js CHANGED
@@ -1000,11 +1000,11 @@ const Autocomplete = (p) => {
1000
1000
  return p.options.slice(0, maxShowValues);
1001
1001
  }
1002
1002
  return p.options.slice();
1003
- }, [p.options]);
1003
+ }, [p.options, p.allowScroll, maxShowValues]);
1004
1004
  const { getText, language } = useLocalization();
1005
1005
  const resultsText = React__namespace.useMemo(() => {
1006
1006
  return `${getText("Showing")} ${displayOptions.length.toLocaleString()} ${getText("of")} ${p.options.length.toLocaleString()} ${getText("results")}.`;
1007
- }, [language]);
1007
+ }, [language, displayOptions, p.options]);
1008
1008
  const getNextTabElement = (fromIndex, direction) => {
1009
1009
  var _a, _b, _c;
1010
1010
  if (fromIndex === -1) {
@@ -1427,7 +1427,7 @@ const Calendar = (p) => {
1427
1427
  const monthTitle = getText(dateFns.format(monthStart, 'LLLL'));
1428
1428
  const weekdays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'].map(d => getText(d));
1429
1429
  return { monthTitle, weekdays };
1430
- }, [language]);
1430
+ }, [language, monthStart]);
1431
1431
  const days = dateFns.getDaysInMonth(monthStart);
1432
1432
  const startDayOfWeek = dateFns.getDay(monthStart);
1433
1433
  const dayEndIndex = startDayOfWeek + days - 1;
@@ -1784,7 +1784,7 @@ const ConfirmModal = (props) => {
1784
1784
  const confirmText = props.confirmText || getText('OK');
1785
1785
  const cancelText = props.cancelText || getText('Cancel');
1786
1786
  return { confirmText, cancelText };
1787
- }, [language]);
1787
+ }, [language, props.confirmText, props.cancelText]);
1788
1788
  return (React__namespace.createElement(Modal, { id: props.id, __debug: props.__debug, className: css.cx('confirmModal', modalStyle, props.className), heading: props.header, closeButton: true, show: props.show, onClick: props.onCancel },
1789
1789
  React__namespace.createElement("div", { className: css.css({ padding: '1rem' }) },
1790
1790
  React__namespace.createElement(Text, { align: "center" }, props.text),
@@ -1801,7 +1801,7 @@ const CopyButton = React__namespace.forwardRef((props, ref) => {
1801
1801
  const copiedText = getText('Copied!');
1802
1802
  const titleText = props.title || getText('Copy to clipboard');
1803
1803
  return { copiedText, titleText };
1804
- }, [language]);
1804
+ }, [language, props.title]);
1805
1805
  return (React__namespace.createElement(Button, Object.assign({}, buttonProps, { ref: ref, title: copied ? copiedText : titleText, variant: "icon", onBlur: e => {
1806
1806
  var _a;
1807
1807
  setCopied(false);
@@ -2007,7 +2007,7 @@ const FileUploader = (p) => {
2007
2007
  }
2008
2008
  }
2009
2009
  return "";
2010
- }, [language]);
2010
+ }, [language, files, p.instructionMessage, totalFileSize, message]);
2011
2011
  const setAllFiles = (inputFiles) => {
2012
2012
  if (input.current && inputFiles === undefined) {
2013
2013
  input.current.value = '';
@@ -2442,7 +2442,7 @@ const DateInput = React__namespace.forwardRef((props, ref) => {
2442
2442
  }, [dateValue, textValue, language]);
2443
2443
  const [showCalendar, setShowCalendar] = React__namespace.useState(false);
2444
2444
  const [calendarDate, setCalendarDate] = React__namespace.useState(getCalendarDate(props.value, props.min, props.max));
2445
- const monthTitle = React__namespace.useMemo(() => getText(dateFns.format(calendarDate, 'LLLL')), [language]);
2445
+ const monthTitle = React__namespace.useMemo(() => getText(dateFns.format(calendarDate, 'LLLL')), [language, calendarDate]);
2446
2446
  // controls the one-time focus set on show
2447
2447
  const needsFocus = React__namespace.useRef(false);
2448
2448
  const toggleCalendar = React__namespace.useCallback((show) => {
@@ -3248,7 +3248,7 @@ const Pager = (props) => {
3248
3248
  pageText = `${(_a = props.pageText) !== null && _a !== void 0 ? _a : getText('Page')} ${(props.pageIndex + 1).toLocaleString()} ${dividerText} ${props.totalPages.toLocaleString()}`;
3249
3249
  }
3250
3250
  return { itemText, pageText };
3251
- }, [language]);
3251
+ }, [language, props.totalItems, props.pageIndex, props.totalPages]);
3252
3252
  const theme = useThemeSafely();
3253
3253
  const pagerStyles = css.css `
3254
3254
  display: grid;
@@ -3300,7 +3300,7 @@ const BoundMemoryPager = (p) => {
3300
3300
  const limitText = (_a = p.limitText) !== null && _a !== void 0 ? _a : getText("Limit");
3301
3301
  const sortText = (_b = p.sortText) !== null && _b !== void 0 ? _b : getText("Sort");
3302
3302
  return { limitText, sortText };
3303
- }, [language]);
3303
+ }, [language, p.limitText, p.sortText]);
3304
3304
  return (React__namespace.createElement(Pager, Object.assign({}, rest, { pageIndex: showPageText ? pager.page : undefined, totalPages: showPageText ? pager.totalPages : undefined, canGoNext: pager.hasNext, canGoPrevious: pager.hasPrevious, minItem: pager.minItemIndex + 1, maxItem: pager.maxItemIndex + 1, totalItems: pager.totalItems, leftControls: pager.limitOptions.length > 1 && p.onLimit ? (React__namespace.createElement(Label, { text: limitText, orientation: "horizontal" },
3305
3305
  React__namespace.createElement(Picker, { value: pager.limit, options: pager.limitOptions, onValueChange: v => { var _a; return (_a = p.onLimit) === null || _a === void 0 ? void 0 : _a.call(p, v); } }))) : undefined, rightControls: pager.sortOptions.length > 1 && p.onSort ? (React__namespace.createElement(Label, { text: sortText, orientation: "horizontalReverse" },
3306
3306
  React__namespace.createElement(Picker, { value: (_a = pager.sort) !== null && _a !== void 0 ? _a : '', options: pager.sortOptions, onValueChange: v => { var _a; return (_a = p.onSort) === null || _a === void 0 ? void 0 : _a.call(p, v); } }))) : undefined, page: d => {
@@ -3317,7 +3317,7 @@ const BoundStaticPager = (p) => {
3317
3317
  const limitText = (_a = p.limitText) !== null && _a !== void 0 ? _a : getText("Limit");
3318
3318
  const sortText = (_b = p.sortText) !== null && _b !== void 0 ? _b : getText("Sort");
3319
3319
  return { limitText, sortText };
3320
- }, [language]);
3320
+ }, [language, p.limitText, p.sortText]);
3321
3321
  const showLimit = !!(result.limit && p.limitOptions && p.limitOptions.length > 1 && p.onLimit);
3322
3322
  const showSort = !!(p.sort !== undefined && p.sortOptions && p.sortOptions.length > 1 && p.onSort);
3323
3323
  return (React__namespace.createElement(Pager, Object.assign({}, rest, { pageIndex: showPageText ? result.page : undefined, totalPages: showPageText ? result.totalPages : undefined, canGoNext: result.hasNext, canGoPrevious: result.hasPrevious, minItem: result.minPageItemIndex + 1, maxItem: result.maxPageItemIndex + 1, totalItems: result.total, leftControls: showLimit ? (React__namespace.createElement(Label, { text: limitText, orientation: "horizontal" },
@@ -3683,6 +3683,7 @@ class ItemPager {
3683
3683
  }
3684
3684
 
3685
3685
  const ProgressBar = (props) => {
3686
+ var _a;
3686
3687
  const bar = React__namespace.useRef(null);
3687
3688
  React__namespace.useEffect(() => {
3688
3689
  const pct = cleanPct(props.pct);
@@ -3708,12 +3709,23 @@ const ProgressBar = (props) => {
3708
3709
  border-radius: 1rem;
3709
3710
  `}
3710
3711
  `;
3711
- return (React__namespace.createElement("div", { className: "progressBar" },
3712
+ const showPctPosition = (_a = props.showPctPosition) !== null && _a !== void 0 ? _a : 'bottom';
3713
+ const wrapStyles = css.css({
3714
+ label: 'ProgressBar',
3715
+ display: 'flex',
3716
+ flexDirection: showPctPosition === 'bottom' ? 'column' : 'row',
3717
+ alignItems: showPctPosition === 'right' ? 'center' : undefined,
3718
+ gap: showPctPosition === 'right' ? '0.5rem' : undefined,
3719
+ });
3720
+ const pctLabelStyles = (props.showPct && props.showPctPosition === 'right') ? css.css({
3721
+ width: '3rem'
3722
+ }) : undefined;
3723
+ return (React__namespace.createElement("div", { className: css.cx(wrapStyles, "progressBar") },
3712
3724
  React__namespace.createElement("div", { className: css.cx(barStyles, props.className) },
3713
- React__namespace.createElement("div", { ref: bar, className: fillStyles })),
3714
- props.showPct && React__namespace.createElement(Text, { align: "center", tag: "div", spacedOut: true },
3715
- props.pct,
3716
- "\u00A0%")));
3725
+ React__namespace.createElement("div", { ref: bar, className: css.cx(fillStyles, props.barFillClassName) })),
3726
+ props.showPct && (React__namespace.createElement(Text, { align: "center", tag: "div", spacedOut: true, className: css.cx(pctLabelStyles, props.pctLabelClassName) },
3727
+ cleanPct(props.pct),
3728
+ "%"))));
3717
3729
  };
3718
3730
  const cleanPct = (value) => {
3719
3731
  if (value) {
@@ -3935,7 +3947,7 @@ const HandleText = (p) => {
3935
3947
  const renderValueWidth = (_c = p.renderValueWidth) !== null && _c !== void 0 ? _c : p.sliderHandleSize;
3936
3948
  const renderValueLeft = React.useMemo(() => {
3937
3949
  return `calc(${renderValueWidth} * 0.5 * -1 + (${p.sliderHandleSize} * 0.5))`;
3938
- }, [p.renderValueWidth]);
3950
+ }, [p.renderValueWidth, p.sliderHandleSize]);
3939
3951
  const [flipText, setFlipText] = React.useState(false);
3940
3952
  const offset = '2px';
3941
3953
  React.useEffect(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mackin.com/styleguide",
3
- "version": "10.1.1",
3
+ "version": "10.2.0",
4
4
  "description": "",
5
5
  "main": "./index.js",
6
6
  "module": "./index.esm.js",