@nypl/design-system-react-components 0.25.5 → 0.25.6

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,4 +1,4 @@
1
- import { useStyleConfig, Icon as Icon$2, Box, Accordion as Accordion$2, AccordionPanel, AccordionItem, AccordionButton, Breadcrumb as Breadcrumb$1, BreadcrumbItem, BreadcrumbLink, Button as Button$2, Link as Link$2, Heading as Heading$2, useMultiStyleConfig, LinkBox, LinkOverlay, Checkbox as Checkbox$2, CheckboxGroup as CheckboxGroup$2, Stack, SimpleGrid as SimpleGrid$1, Input as Input$1, Textarea, extendTheme, ChakraProvider, Radio as Radio$2, useRadioGroup, Select as Select$2, Skeleton as Skeleton$1, Tabs as Tabs$1, Tab, TabPanel, TabList, TabPanels, Text as Text$2, useTheme } from '@chakra-ui/react';
1
+ import { useStyleConfig, Icon as Icon$2, Box, Accordion as Accordion$2, AccordionPanel, AccordionItem, AccordionButton, Breadcrumb as Breadcrumb$1, BreadcrumbItem, BreadcrumbLink, Button as Button$2, Link as Link$2, Heading as Heading$2, useMultiStyleConfig, LinkBox, LinkOverlay, Checkbox as Checkbox$2, CheckboxGroup as CheckboxGroup$2, Stack, SimpleGrid as SimpleGrid$1, Input as Input$1, Textarea, extendTheme, ChakraProvider, CircularProgress, CircularProgressLabel, Progress, Radio as Radio$2, useRadioGroup, Select as Select$2, Skeleton as Skeleton$1, RangeSlider, RangeSliderTrack, RangeSliderFilledTrack, RangeSliderThumb, Slider as Slider$1, SliderTrack, SliderFilledTrack, SliderThumb, Tabs as Tabs$1, Tab, TabPanel, TabList, TabPanels, Text as Text$2, useTheme } from '@chakra-ui/react';
2
2
  export { Box, ButtonGroup, Center, Circle, Grid, GridItem, HStack, Square, Stack, Tab, TabList, TabPanel, TabPanels, VStack } from '@chakra-ui/react';
3
3
  import React__default, { createElement, cloneElement, Fragment, Children, forwardRef, useState, Component, useEffect } from 'react';
4
4
  import { v4 } from 'uuid';
@@ -2282,6 +2282,7 @@ function Accordion(props) {
2282
2282
  var ColorVariants;
2283
2283
 
2284
2284
  (function (ColorVariants) {
2285
+ ColorVariants["Blogs"] = "blogs";
2285
2286
  ColorVariants["BooksAndMore"] = "booksAndMore";
2286
2287
  ColorVariants["Locations"] = "locations";
2287
2288
  ColorVariants["Research"] = "research";
@@ -4129,6 +4130,15 @@ var Accordion$1 = {
4129
4130
  };
4130
4131
 
4131
4132
  // Variant styling
4133
+ var blogs = {
4134
+ bg: "section.blogs.secondary",
4135
+ color: "ui.black",
4136
+ a: {
4137
+ _hover: {
4138
+ color: "ui.gray.xdark"
4139
+ }
4140
+ }
4141
+ };
4132
4142
  var booksAndMore = {
4133
4143
  bg: "section.books-and-more.secondary"
4134
4144
  };
@@ -4217,6 +4227,7 @@ var Breadcrumb = {
4217
4227
  },
4218
4228
  // Available variants:
4219
4229
  variants: {
4230
+ blogs: blogs,
4220
4231
  booksAndMore: booksAndMore,
4221
4232
  locations: locations,
4222
4233
  research: research,
@@ -7351,6 +7362,88 @@ var Pagination$1 = function Pagination(props) {
7351
7362
  }, previousLiLink, getPaginationNumbers(currentPage), nextLiLink));
7352
7363
  };
7353
7364
 
7365
+ /**
7366
+ * A component that displays a progress status for any task that takes a long
7367
+ * time to complete or consists of multiple steps. Examples include downloading,
7368
+ * uploading, or processing.
7369
+ */
7370
+
7371
+ var ProgressIndicator$1 = function ProgressIndicator(props) {
7372
+ var _props$darkMode = props.darkMode,
7373
+ darkMode = _props$darkMode === void 0 ? false : _props$darkMode,
7374
+ _props$id = props.id,
7375
+ id = _props$id === void 0 ? generateUUID() : _props$id,
7376
+ _props$indicatorType = props.indicatorType,
7377
+ indicatorType = _props$indicatorType === void 0 ? ProgressIndicatorTypes.Linear : _props$indicatorType,
7378
+ _props$isIndeterminat = props.isIndeterminate,
7379
+ isIndeterminate = _props$isIndeterminat === void 0 ? false : _props$isIndeterminat,
7380
+ labelText = props.labelText,
7381
+ _props$showLabel = props.showLabel,
7382
+ showLabel = _props$showLabel === void 0 ? true : _props$showLabel,
7383
+ _props$size = props.size,
7384
+ size = _props$size === void 0 ? ProgressIndicatorSizes.Default : _props$size,
7385
+ _props$value = props.value,
7386
+ value = _props$value === void 0 ? 0 : _props$value;
7387
+ var styles = useMultiStyleConfig("ProgressIndicator", {
7388
+ darkMode: darkMode,
7389
+ size: size
7390
+ });
7391
+ var finalValue = value;
7392
+
7393
+ if (finalValue < 0 || finalValue > 100) {
7394
+ console.warn("ProgressIndicator: pass in a `value` between 0 and 100. Defaulting to 0.");
7395
+ finalValue = 0;
7396
+ }
7397
+
7398
+ var progressProps = {
7399
+ id: id,
7400
+ // If the label is visually shown, associate it with the progress indicator.
7401
+ // Otherwise, the `aria-label` will be added.
7402
+ "aria-label": showLabel ? null : labelText,
7403
+ "aria-labelledby": showLabel ? id + "-label" : null,
7404
+ // If `isIndeterminate` is true, then it overrides the `value` prop.
7405
+ isIndeterminate: isIndeterminate || null,
7406
+ value: isIndeterminate ? null : finalValue
7407
+ };
7408
+
7409
+ var progressComponent = function progressComponent(indicatorType) {
7410
+ // Only display the percentage text for the default size, not in the
7411
+ // indeterminate state, and when `showLabel` is true.
7412
+ if (indicatorType === ProgressIndicatorTypes.Circular) {
7413
+ // For the small size, since the label won't be visible, we need to add
7414
+ // it to the parent component's `aria-label` attribute.
7415
+ if (size === ProgressIndicatorSizes.Small) {
7416
+ progressProps["aria-label"] = labelText;
7417
+ }
7418
+
7419
+ return React__default.createElement(Box, {
7420
+ __css: styles.circularContainer
7421
+ }, React__default.createElement(CircularProgress, Object.assign({}, progressProps, {
7422
+ sx: styles.circular
7423
+ }), showLabel && !isIndeterminate && size !== ProgressIndicatorSizes.Small && React__default.createElement(CircularProgressLabel, null, finalValue, "%")), showLabel && size !== ProgressIndicatorSizes.Small && React__default.createElement(Label, {
7424
+ id: id + "-label",
7425
+ htmlFor: id
7426
+ }, labelText));
7427
+ } // The Linear progress indicator is the default.
7428
+
7429
+
7430
+ return React__default.createElement(React__default.Fragment, null, showLabel && React__default.createElement(Label, {
7431
+ id: id + "-label",
7432
+ htmlFor: id
7433
+ }, labelText), React__default.createElement(Box, {
7434
+ __css: styles.linearContainer
7435
+ }, React__default.createElement(Progress, Object.assign({}, progressProps, {
7436
+ sx: styles.linear
7437
+ })), showLabel && !isIndeterminate && React__default.createElement(Box, {
7438
+ __css: styles.linearPercentage
7439
+ }, finalValue, "%")));
7440
+ };
7441
+
7442
+ return React__default.createElement(Box, {
7443
+ __css: styles
7444
+ }, progressComponent(indicatorType));
7445
+ };
7446
+
7354
7447
  var Radio$1 = /*#__PURE__*/forwardRef(function (props, ref) {
7355
7448
  var className = props.className,
7356
7449
  helperText = props.helperText,
@@ -7643,7 +7736,8 @@ function SearchBar$1(props) {
7643
7736
  var helperErrorTextID = generateUUID();
7644
7737
  var ariaDescribedby = helperErrorTextID;
7645
7738
  var footnote = isInvalid ? invalidText : helperErrorText;
7646
- var finalAriaLabel = footnote ? labelText + " - " + footnote : labelText; // Render the `Select` component.
7739
+ var finalAriaLabel = footnote ? labelText + " - " + footnote : labelText;
7740
+ var textInputPlaceholder = (textInputProps == null ? void 0 : textInputProps.placeholder) + " " + (isRequired ? "(Required)" : ""); // Render the `Select` component.
7647
7741
 
7648
7742
  var selectElem = selectProps && createElement(Select$1, Object.assign({
7649
7743
  id: generateUUID(),
@@ -7660,7 +7754,7 @@ function SearchBar$1(props) {
7660
7754
  var textInputNative = textInputProps && createElement(TextInput, Object.assign({
7661
7755
  id: generateUUID(),
7662
7756
  labelText: textInputProps == null ? void 0 : textInputProps.labelText,
7663
- placeholder: textInputProps == null ? void 0 : textInputProps.placeholder,
7757
+ placeholder: textInputPlaceholder,
7664
7758
  onChange: textInputProps == null ? void 0 : textInputProps.onChange,
7665
7759
  name: textInputProps == null ? void 0 : textInputProps.name,
7666
7760
  type: TextInputTypes.text,
@@ -7804,6 +7898,224 @@ function SkeletonLoader$1(props) {
7804
7898
  })))));
7805
7899
  }
7806
7900
 
7901
+ /**
7902
+ * The `Slider` component renders a singular value slider or a range slider
7903
+ * with a min and max value. The value(s) can be updated through the slider
7904
+ * thumb(s) or through the text input(s) elements.
7905
+ */
7906
+
7907
+ function Slider(props) {
7908
+ var className = props.className,
7909
+ _props$defaultValue = props.defaultValue,
7910
+ defaultValue = _props$defaultValue === void 0 ? 0 : _props$defaultValue,
7911
+ helperText = props.helperText,
7912
+ _props$id = props.id,
7913
+ id = _props$id === void 0 ? generateUUID() : _props$id,
7914
+ invalidText = props.invalidText,
7915
+ _props$isDisabled = props.isDisabled,
7916
+ isDisabled = _props$isDisabled === void 0 ? false : _props$isDisabled,
7917
+ _props$isInvalid = props.isInvalid,
7918
+ isInvalid = _props$isInvalid === void 0 ? false : _props$isInvalid,
7919
+ _props$isRangeSlider = props.isRangeSlider,
7920
+ isRangeSlider = _props$isRangeSlider === void 0 ? false : _props$isRangeSlider,
7921
+ _props$isRequired = props.isRequired,
7922
+ isRequired = _props$isRequired === void 0 ? false : _props$isRequired,
7923
+ labelText = props.labelText,
7924
+ _props$max = props.max,
7925
+ max = _props$max === void 0 ? 100 : _props$max,
7926
+ _props$min = props.min,
7927
+ min = _props$min === void 0 ? 0 : _props$min,
7928
+ name = props.name,
7929
+ _onChange = props.onChange,
7930
+ _props$optReqFlag = props.optReqFlag,
7931
+ optReqFlag = _props$optReqFlag === void 0 ? true : _props$optReqFlag,
7932
+ _props$showBoxes = props.showBoxes,
7933
+ showBoxes = _props$showBoxes === void 0 ? true : _props$showBoxes,
7934
+ _props$showHelperInva = props.showHelperInvalidText,
7935
+ showHelperInvalidText = _props$showHelperInva === void 0 ? true : _props$showHelperInva,
7936
+ _props$showLabel = props.showLabel,
7937
+ showLabel = _props$showLabel === void 0 ? true : _props$showLabel,
7938
+ _props$showValues = props.showValues,
7939
+ showValues = _props$showValues === void 0 ? true : _props$showValues,
7940
+ _props$step = props.step,
7941
+ step = _props$step === void 0 ? 1 : _props$step;
7942
+
7943
+ var _React$useState = useState(defaultValue),
7944
+ currentValue = _React$useState[0],
7945
+ setCurrentValue = _React$useState[1];
7946
+
7947
+ var finalIsInvalid = isInvalid; // In the Range Slider, if the first value is bigger than the second value,
7948
+ // then set the invalid state.
7949
+
7950
+ if (isRangeSlider && currentValue[0] > currentValue[1]) {
7951
+ finalIsInvalid = true;
7952
+ }
7953
+
7954
+ var optReqText = isRequired ? "Required" : "Optional";
7955
+ var footnote = finalIsInvalid ? invalidText : helperText;
7956
+ var styles = useMultiStyleConfig("CustomSlider", {
7957
+ isDisabled: isDisabled,
7958
+ isInvalid: finalIsInvalid,
7959
+ isRangeSlider: isRangeSlider,
7960
+ showBoxes: showBoxes
7961
+ }); // Props that the `Slider` and `RangeSlider` Chakra
7962
+ // components both use.
7963
+
7964
+ var sliderSharedProps = {
7965
+ // Don't focus on the thumbs for every small change.
7966
+ focusThumbOnChange: false,
7967
+ id: id,
7968
+ isDisabled: isDisabled,
7969
+ max: max,
7970
+ min: min,
7971
+ name: name,
7972
+ onChange: function onChange(val) {
7973
+ return setCurrentValue(val);
7974
+ },
7975
+ // Call the passed in `onChange` function prop to get the
7976
+ // *final* value once a user stops dragging the slider.
7977
+ onChangeEnd: function onChangeEnd(val) {
7978
+ return _onChange(val);
7979
+ },
7980
+ step: step
7981
+ }; // Props that the two `TextInput` components use.
7982
+
7983
+ var textInputSharedProps = {
7984
+ attributes: {
7985
+ max: max,
7986
+ min: min
7987
+ },
7988
+ isDisabled: isDisabled,
7989
+ isInvalid: finalIsInvalid,
7990
+ isRequired: isRequired,
7991
+ // Never show the label or helper text for the `TextInput` component.
7992
+ showHelperInvalidText: false,
7993
+ showLabel: false,
7994
+ step: step,
7995
+ type: TextInputTypes.number
7996
+ };
7997
+ /**
7998
+ * This returns either the "start" or "end" `TextInput` component. Note that
7999
+ * the "end" `TextInput` component is always rendered but the "start" is
8000
+ * only used for the `isRangeSlider` case.
8001
+ */
8002
+
8003
+ var getTextInput = function getTextInput(type) {
8004
+ var inputProps = {
8005
+ start: _extends({
8006
+ // We only want the value for this box in the `isRangeSlider` case.
8007
+ value: isRangeSlider ? currentValue[0].toString() : "",
8008
+ onChange: function onChange(val) {
8009
+ // If the value is empty, set it to 0.
8010
+ var nextValue = parseInt(val.target.value, 10) ? parseInt(val.target.value, 10) : 0; // Only update the first value in the range.
8011
+
8012
+ var newValue = [nextValue, currentValue[1]];
8013
+ setCurrentValue(newValue); // If the text input was updated directly,
8014
+ // send the data back to the user.
8015
+
8016
+ _onChange && _onChange(newValue);
8017
+ }
8018
+ }, textInputSharedProps),
8019
+ end: _extends({
8020
+ // This text input *always* shows. In the default case, we only
8021
+ // keep track of one value. For the `isRangeSlider` case, we keep
8022
+ // track of an array but only want the second value.
8023
+ value: isRangeSlider ? currentValue[1].toString() : currentValue.toString(),
8024
+ onChange: function onChange(val) {
8025
+ // If the value is empty, set it to 0.
8026
+ var nextValue = parseInt(val.target.value, 10) ? parseInt(val.target.value, 10) : 0; // If the value entered is bigger than the max value,
8027
+ // then set it to the max value.
8028
+
8029
+ if (nextValue > max) {
8030
+ nextValue = max;
8031
+ } // Only update the second value in the `isRangeSlider` case,
8032
+ // or the single value in the default case.
8033
+
8034
+
8035
+ var newValue = isRangeSlider ? [currentValue[0], nextValue] : nextValue;
8036
+ setCurrentValue(newValue); // If the text input was updated directly,
8037
+ // send the data back to the user.
8038
+
8039
+ _onChange && _onChange(newValue);
8040
+ }
8041
+ }, textInputSharedProps)
8042
+ };
8043
+ var updatedLabel = !isRangeSlider ? labelText : labelText + " - " + type + " value";
8044
+ return createElement(TextInput, Object.assign({
8045
+ id: id + "-textInput-" + type,
8046
+ labelText: updatedLabel,
8047
+ additionalStyles: _extends({}, styles.textInput, {
8048
+ // Specific margins for each text input to
8049
+ // push the elements inside.
8050
+ marginRight: type === "start" ? "s" : null,
8051
+ marginLeft: type === "end" ? "s" : null
8052
+ })
8053
+ }, inputProps[type]));
8054
+ };
8055
+ /**
8056
+ * Returns a Chakra `Slider` or `RangeSlider` component based on the
8057
+ * `isRangeSlider` prop from the DS `Slider` component.
8058
+ */
8059
+
8060
+
8061
+ var getSliderType = function getSliderType() {
8062
+ return isRangeSlider ? createElement(RangeSlider // Both slider thumbs need values and should be in an array.
8063
+ , Object.assign({
8064
+ "aria-label": !showLabel ? [labelText + " - start value", labelText + " - end value"] : null,
8065
+ "aria-labelledby": showLabel ? [id + "-label", id + "-label"] : null,
8066
+ value: currentValue,
8067
+ // Make the thumbs larger.
8068
+ size: "lg"
8069
+ }, sliderSharedProps), createElement(RangeSliderTrack, {
8070
+ sx: styles.track
8071
+ }, createElement(RangeSliderFilledTrack, {
8072
+ sx: styles.filledTrack
8073
+ })), createElement(RangeSliderThumb, {
8074
+ index: 0,
8075
+ sx: styles.thumb
8076
+ }), createElement(RangeSliderThumb, {
8077
+ index: 1,
8078
+ sx: styles.thumb
8079
+ })) : createElement(Slider$1, Object.assign({
8080
+ "aria-label": !showLabel ? labelText : null,
8081
+ "aria-labelledby": id + "-label",
8082
+ value: currentValue,
8083
+ // Make the thumb larger.
8084
+ size: "lg"
8085
+ }, sliderSharedProps), createElement(SliderTrack, {
8086
+ sx: styles.track
8087
+ }, createElement(SliderFilledTrack, {
8088
+ sx: styles.filledTrack
8089
+ })), createElement(SliderThumb, {
8090
+ sx: styles.thumb
8091
+ }));
8092
+ };
8093
+
8094
+ return createElement(Box, {
8095
+ className: className,
8096
+ __css: styles
8097
+ }, showLabel && createElement(Label, {
8098
+ id: id + "-label",
8099
+ // We can't target the slider thumbs since those are divs and we
8100
+ // should link the label somewhere. So either target the first
8101
+ // input box in a `RangeSlider` or the only input box in a `Slider`.
8102
+ // When the input fields are not visible, remove this attribute.
8103
+ htmlFor: showBoxes ? id + "-textInput-" + (isRangeSlider ? "start" : "end") : null,
8104
+ optReqFlag: optReqFlag && optReqText
8105
+ }, labelText), createElement(Box, {
8106
+ __css: styles.container
8107
+ }, showBoxes && isRangeSlider && getTextInput("start"), showValues && createElement(Box, {
8108
+ __css: styles.leftValue
8109
+ }, min), getSliderType(), showValues && createElement(Box, {
8110
+ __css: styles.rightValue
8111
+ }, max), showBoxes && getTextInput("end")), footnote && showHelperInvalidText && createElement(Box, {
8112
+ __css: styles.helper
8113
+ }, createElement(HelperErrorText, {
8114
+ id: id + "-helperText",
8115
+ isInvalid: finalIsInvalid
8116
+ }, footnote)));
8117
+ }
8118
+
7807
8119
  var StatusBadgeTypes;
7808
8120
 
7809
8121
  (function (StatusBadgeTypes) {
@@ -8497,5 +8809,5 @@ function VideoPlayer$1(props) {
8497
8809
  }, embedCode)));
8498
8810
  }
8499
8811
 
8500
- export { Accordion, Breadcrumbs, Button, ButtonTypes, Card, CardActions, CardContent, CardEdition, CardHeading, CardLayouts, Checkbox, CheckboxGroup, CheckboxGroupLayoutTypes, ColorVariants, DSProvider, DatePicker, DatePickerTypes, Fieldset, Form, FormField, FormRow, GridGaps as FormSpacing, GridGaps, Heading, HeadingDisplaySizes, HeadingLevels, HelperErrorText, Hero$1 as Hero, HeroTypes, HorizontalRule$1 as HorizontalRule, Icon, IconAlign, IconColors, IconNames, IconRotationTypes, IconSizes, IconTypes, Image, ImageRatios, ImageSizes, ImageTypes, Input, InputTypes, Label, Link$1 as Link, LinkTypes, List$1 as List, ListTypes, LogoNames, Modal, Notification$1 as Notification, NotificationTypes, Pagination$1 as Pagination, Radio$1 as Radio, RadioGroup$1 as RadioGroup, RadioGroupLayoutTypes, SearchBar$1 as SearchBar, Select$1 as Select, SimpleGrid, SkeletonLoader$1 as SkeletonLoader, SkeletonLoaderImageRatios, SkeletonLoaderLayouts, StatusBadge$1 as StatusBadge, StatusBadgeTypes, Tabs, Template$1 as Template, TemplateAppContainer, TemplateBreakout$1 as TemplateBreakout, TemplateContent$1 as TemplateContent, TemplateContentPrimary$1 as TemplateContentPrimary, TemplateContentSidebar$1 as TemplateContentSidebar, TemplateContentTop$1 as TemplateContentTop, TemplateFooter, TemplateHeader$1 as TemplateHeader, Text$1 as Text, TextDisplaySizes, TextInput, TextInputTypes, VideoPlayer$1 as VideoPlayer, VideoPlayerAspectRatios, VideoPlayerTypes, useNYPLTheme };
8812
+ export { Accordion, Breadcrumbs, Button, ButtonTypes, Card, CardActions, CardContent, CardEdition, CardHeading, CardLayouts, Checkbox, CheckboxGroup, CheckboxGroupLayoutTypes, ColorVariants, DSProvider, DatePicker, DatePickerTypes, Fieldset, Form, FormField, FormRow, GridGaps as FormSpacing, GridGaps, Heading, HeadingDisplaySizes, HeadingLevels, HelperErrorText, Hero$1 as Hero, HeroTypes, HorizontalRule$1 as HorizontalRule, Icon, IconAlign, IconColors, IconNames, IconRotationTypes, IconSizes, IconTypes, Image, ImageRatios, ImageSizes, ImageTypes, Input, InputTypes, Label, Link$1 as Link, LinkTypes, List$1 as List, ListTypes, LogoNames, Modal, Notification$1 as Notification, NotificationTypes, Pagination$1 as Pagination, ProgressIndicator$1 as ProgressIndicator, Radio$1 as Radio, RadioGroup$1 as RadioGroup, RadioGroupLayoutTypes, SearchBar$1 as SearchBar, Select$1 as Select, SimpleGrid, SkeletonLoader$1 as SkeletonLoader, SkeletonLoaderImageRatios, SkeletonLoaderLayouts, Slider, StatusBadge$1 as StatusBadge, StatusBadgeTypes, Tabs, Template$1 as Template, TemplateAppContainer, TemplateBreakout$1 as TemplateBreakout, TemplateContent$1 as TemplateContent, TemplateContentPrimary$1 as TemplateContentPrimary, TemplateContentSidebar$1 as TemplateContentSidebar, TemplateContentTop$1 as TemplateContentTop, TemplateFooter, TemplateHeader$1 as TemplateHeader, Text$1 as Text, TextDisplaySizes, TextInput, TextInputTypes, VideoPlayer$1 as VideoPlayer, VideoPlayerAspectRatios, VideoPlayerTypes, useNYPLTheme };
8501
8813
  //# sourceMappingURL=design-system-react-components.esm.js.map