@spscommerce/ds-react 6.7.0 → 6.8.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.
Files changed (3) hide show
  1. package/lib/index.cjs.js +243 -186
  2. package/lib/index.es.js +246 -161
  3. package/package.json +11 -11
package/lib/index.es.js CHANGED
@@ -32790,202 +32790,286 @@ const SpsScrollableContainerExamples = {
32790
32790
  }
32791
32791
  };
32792
32792
  const SpsSelectExamples = {
32793
+ general: {
32794
+ label: "General Usage",
32795
+ description: ({ NavigateTo }) => /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("h5", null, "Use a Select:"), /* @__PURE__ */ React__default.createElement("ul", null, /* @__PURE__ */ React__default.createElement("li", {
32796
+ className: "mb-2"
32797
+ }, "When a list of predetermined values can be provided.")), /* @__PURE__ */ React__default.createElement("h5", null, "Do Not Use a Select:"), /* @__PURE__ */ React__default.createElement("ul", null, /* @__PURE__ */ React__default.createElement("li", {
32798
+ className: "mb-2"
32799
+ }, "When there are only two possible options. Consider", " ", /* @__PURE__ */ React__default.createElement(NavigateTo, {
32800
+ to: "checkbox"
32801
+ }, "Checkboxes"), " or", " ", /* @__PURE__ */ React__default.createElement(NavigateTo, {
32802
+ to: "radio-buttons"
32803
+ }, "Radio Buttons"), " insead."), /* @__PURE__ */ React__default.createElement("li", {
32804
+ className: "mb-2"
32805
+ }, "When it is ideal to display all available options without requiring a click. Consider", " ", /* @__PURE__ */ React__default.createElement(NavigateTo, {
32806
+ to: "checkbox"
32807
+ }, "Checkboxes"), " or", " ", /* @__PURE__ */ React__default.createElement(NavigateTo, {
32808
+ to: "radio-buttons"
32809
+ }, "Radio Buttons"), " insead.")), /* @__PURE__ */ React__default.createElement("h5", null, "Using Selects in a Form"), /* @__PURE__ */ React__default.createElement("p", null, "Reference the ", /* @__PURE__ */ React__default.createElement(NavigateTo, {
32810
+ to: "form"
32811
+ }, "Forms"), " page for guidelines for placing inputs in Form layouts"))
32812
+ },
32793
32813
  basic: {
32794
- label: "Basic",
32795
- description: "info about basic selects",
32814
+ label: "Basic Select",
32815
+ description: () => /* @__PURE__ */ React__default.createElement("p", null, "Basic Selects include a label and dropdown menu containing a list of options. The user is allowed to make a single selection."),
32796
32816
  examples: {
32797
- a_simple: {
32798
- description: "Simple value options",
32817
+ basic: {
32799
32818
  react: code`
32800
- function DemoComponent() {
32801
- const colors = ["red", "blue", "green"];
32802
-
32803
- return (
32804
- <SpsSelect id="basic" options={colors}/>
32805
- )
32806
- }
32807
- `
32819
+ function DemoComponent() {
32820
+ const colors = ["red", "blue", "green"];
32821
+
32822
+ return (
32823
+ <div className="sfg-row">
32824
+ <div className="sfg-col-4">
32825
+ <SpsLabel>Color</SpsLabel>
32826
+ <SpsSelect options={colors} />
32827
+ </div>
32828
+ </div>
32829
+ )
32830
+ }
32831
+ `
32808
32832
  },
32809
- b_formHooks: {
32810
- description: "Form hooks",
32833
+ placeholderText: {
32834
+ description: () => /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("h4", null, "Customizable Placeholder Text"), /* @__PURE__ */ React__default.createElement("p", null, "Placeholder text can be customized to specifically reference the content in the dropdown menu.")),
32811
32835
  react: code`
32812
- function DemoComponent() {
32813
- const colors = ["red", "blue", "green"];
32814
- const { formValue, formMeta, updateForm } = useSpsForm({
32815
- color: colors[0]
32816
- });
32817
-
32818
- return <>
32819
- <SpsLabel for={formMeta.fields.color}>Color</SpsLabel>
32820
- <SpsSelect options={colors} formMeta={formMeta.fields.color}
32821
- value={formValue.color}
32822
- />
32823
- </>
32824
- }
32825
- `
32836
+ function DemoComponent() {
32837
+ const colors = ["red", "blue", "green"];
32838
+
32839
+ return (
32840
+ <div className="sfg-row">
32841
+ <div className="sfg-col-4">
32842
+ <SpsLabel>Color</SpsLabel>
32843
+ <SpsSelect options={colors} placeholder="Select a color..." />
32844
+ </div>
32845
+ </div>
32846
+ )
32847
+ }
32848
+ `
32826
32849
  },
32827
- c_placeholder: {
32828
- description: "Custom placeholder text",
32850
+ defaultSelection: {
32851
+ description: () => /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("h4", null, "Default Selection / No Clear Button"), /* @__PURE__ */ React__default.createElement("p", null, "Selects can default to a selection in certain cases. Use Default Selections only when a selection is required and a default selection can be confidently made. Selects with a default selection do not have a clear option.")),
32829
32852
  react: code`
32830
- function DemoComponent() {
32831
- const colors = ["red", "blue", "green"];
32832
-
32833
- return (
32834
- <SpsSelect id="placeholder" options={colors} placeholder="Choose a color…"/>
32835
- )
32836
- }
32837
- `
32853
+ function DemoComponent() {
32854
+ const colors = ["Small", "Medium", "Large"];
32855
+
32856
+ return (
32857
+ <div className="sfg-row">
32858
+ <div className="sfg-col-4">
32859
+ <SpsLabel>Size</SpsLabel>
32860
+ <SpsSelect options={colors} value="Small" notClearable />
32861
+ </div>
32862
+ </div>
32863
+ )
32864
+ }
32865
+ `
32838
32866
  },
32839
- d_notClearable: {
32840
- description: "Not clearable",
32867
+ zeroState: {
32868
+ description: () => /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("h4", null, "Zero State / No Available Options"), /* @__PURE__ */ React__default.createElement("p", null, "If no options are available in the dropdown menu, a zero state message appears. This option is most commonly used with the Select with Filter option.")),
32841
32869
  react: code`
32842
- function DemoComponent() {
32843
- const colors = ["red", "blue", "green"];
32870
+ function DemoComponent() {
32844
32871
 
32845
- return (
32846
- <SpsSelect options={colors} value="red" notClearable />
32847
- )
32848
- }
32849
- `
32872
+ return (
32873
+ <div className="sfg-row">
32874
+ <div className="sfg-col-4">
32875
+ <SpsLabel>Company</SpsLabel>
32876
+ <SpsSelect options={[]} zeroState="We're sorry, there are no options to choose from at this time." />
32877
+ </div>
32878
+ </div>
32879
+ )
32880
+ }
32881
+ `
32850
32882
  },
32851
- e_zeroState: {
32852
- description: "Zero state",
32883
+ formHooks: {
32884
+ description: ({ NavigateTo }) => /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("h4", null, "Form Hooks"), /* @__PURE__ */ React__default.createElement("p", null, "The ", /* @__PURE__ */ React__default.createElement("code", null, "formMeta"), " and ", /* @__PURE__ */ React__default.createElement("code", null, "formValue"), " props are used with the", " ", /* @__PURE__ */ React__default.createElement("code", null, "useSpsForm"), " hook. By using the ", /* @__PURE__ */ React__default.createElement("code", null, "useSpsForm"), " hook you can add validators, get the form value, update the form value, and more. The form is documented on the ", /* @__PURE__ */ React__default.createElement(NavigateTo, {
32885
+ to: "form"
32886
+ }, "Forms"), " page.")),
32853
32887
  react: code`
32854
- function DemoComponent() {
32855
- return (
32856
- <SpsSelect options={[]} zeroState="We're sorry, there are no options to choose from at this time, because reasons." />
32857
- )
32858
- }
32859
- `
32888
+ function DemoComponent() {
32889
+ const colors = ["red", "blue", "green"];
32890
+ const { formValue, formMeta, updateForm } = useSpsForm({
32891
+ color: colors[0]
32892
+ });
32893
+
32894
+ return (
32895
+ <div className="sfg-row">
32896
+ <div className="sfg-col-4">
32897
+ <SpsLabel for={formMeta.fields.color}>Color</SpsLabel>
32898
+ <SpsSelect options={colors} formMeta={formMeta.fields.color} formValue={formValue.color}/>
32899
+ </div>
32900
+ </div>
32901
+ )
32902
+ }
32903
+ `
32860
32904
  }
32861
32905
  }
32862
32906
  },
32863
- b_objectOpts: {
32864
- label: "Object Options",
32865
- description: "info about object options",
32907
+ filter: {
32908
+ label: "Select with Filter",
32909
+ description: () => /* @__PURE__ */ React__default.createElement("p", null, "It can be helpful to add a filter field to dropdown menus that contain a large amount of options to aid the user in finding the option they need."),
32866
32910
  examples: {
32867
- a_basic: {
32868
- description: "Basic use of object options",
32911
+ basic: {
32869
32912
  react: code`
32870
- function DemoComponent() {
32871
- const sizes = [
32872
- { size: "S", price: "10.99" },
32873
- { size: "M", price: "12.99" },
32874
- { size: "L", price: "14.99" }
32875
- ];
32913
+ function DemoComponent() {
32914
+ function colorSearch(search) {
32915
+ return ["red", "orange", "yellow", "green", "blue", "indigo", "violet"].filter(s => (new RegExp(search, "i")).test(s));
32916
+ }
32876
32917
 
32877
- return (
32878
- <SpsSelect options={sizes} textKey="size" />
32879
- )
32880
- }
32881
- `
32918
+ return (
32919
+ <div className="sfg-row">
32920
+ <div className="sfg-col-4">
32921
+ <SpsLabel>Color</SpsLabel>
32922
+ <SpsSelect options={colorSearch} zeroState="While I'm sure that's a lovely color, it's not an option we support.ssssssssss" />
32923
+ </div>
32924
+ </div>
32925
+ )
32926
+ }
32927
+ `
32882
32928
  },
32883
- b_captions: {
32884
- description: "Captions",
32929
+ promise: {
32930
+ description: () => /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("h4", null, "Return a Promise"), /* @__PURE__ */ React__default.createElement("p", null, "A promise should be used when the options are being returned asynchronously. A common use case for this is when the options are being returned as a result of an API call.")),
32885
32931
  react: code`
32886
- function DemoComponent() {
32887
- const lorem = [
32888
- {
32889
- title: "Lorem",
32890
- description: "Ut enim ad minim veniam"
32891
- },
32892
- {
32893
- title: "Ipsum",
32894
- description: "Excepteur sint occaecat cupidatat non proident"
32895
- }
32896
- ];
32932
+ function DemoComponent() {
32933
+ function colorSearch(search) {
32934
+ return new Promise((resolve, reject) => {
32935
+ const result = ["red", "orange", "yellow", "green", "blue", "indigo", "violet"].filter(s => new RegExp(search, "i").test(s));
32936
+ resolve(result);
32937
+ });
32938
+ }
32897
32939
 
32898
- return (
32899
- <SpsSelect options={lorem} textKey="title" captionKey="description" />
32900
- )
32901
- }
32902
- `
32940
+ return (
32941
+ <div className="sfg-row">
32942
+ <div className="sfg-col-4">
32943
+ <SpsLabel>Color</SpsLabel>
32944
+ <SpsSelect options={colorSearch} />
32945
+ </div>
32946
+ </div>
32947
+ )
32948
+ }
32949
+ `
32950
+ },
32951
+ debounce: {
32952
+ description: () => /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("h4", null, "Debounce"), /* @__PURE__ */ React__default.createElement("p", null, "When the options are a result of a search or are not available right away a debounce may be helpful. A debounce adds a delay to the option search so the search function is not getting called repeatedly.")),
32953
+ react: code`
32954
+ function DemoComponent() {
32955
+ function colorSearch(search) {
32956
+ return ["red", "orange", "yellow", "green", "blue", "indigo", "violet"].filter(s => new RegExp(search, "i").test(s));
32957
+ }
32958
+
32959
+ return (
32960
+ <div className="sfg-row">
32961
+ <div className="sfg-col-4">
32962
+ <SpsLabel>Color</SpsLabel>
32963
+ <SpsSelect options={colorSearch} searchDebounce={2000} />
32964
+ </div>
32965
+ </div>
32966
+ )
32967
+ }
32968
+ `
32903
32969
  }
32904
32970
  }
32905
32971
  },
32906
- c_searchable: {
32907
- label: "Search/Filter",
32908
- description: "info about search/filter",
32972
+ objectOptions: {
32973
+ label: "Object Options",
32974
+ description: () => /* @__PURE__ */ React__default.createElement("p", null, "The values in the select menu can be modified to provide more detail to the user or the system, when necessary."),
32909
32975
  examples: {
32910
- a_simple: {
32911
- description: "Simple search function",
32976
+ basic: {
32912
32977
  react: code`
32913
- function DemoComponent() {
32914
- function colorSearch(search) {
32915
- return ["red", "orange", "yellow", "green", "blue", "indigo", "violet"]
32916
- .filter(s => (new RegExp(search, "i")).test(s));
32917
- }
32918
-
32919
- return (
32920
- <SpsSelect id="search-function" options={colorSearch} zeroState="While I'm sure that's a lovely color, it's not an option we support."/>
32921
- )
32922
- }
32923
- `
32978
+ function DemoComponent() {
32979
+ const sizes = [
32980
+ { size: "S", price: "10.99" },
32981
+ { size: "M", price: "12.99" },
32982
+ { size: "S", price: "10.99" },
32983
+ ]
32984
+
32985
+ return (
32986
+ <div className="sfg-row">
32987
+ <div className="sfg-col-4">
32988
+ <SpsLabel>Size</SpsLabel>
32989
+ <SpsSelect options={sizes} textKey="size" />
32990
+ </div>
32991
+ </div>
32992
+ )
32993
+ }
32994
+ `
32924
32995
  },
32925
- b_promise: {
32926
- description: "Search function returning a Promise",
32996
+ extendedDetails: {
32997
+ description: () => /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("h4", null, "Extended Details"), /* @__PURE__ */ React__default.createElement("p", null, "Extended details can be displayed in the dropdown menu. Only the primary detail is displayed as the selection.")),
32927
32998
  react: code`
32928
- function DemoComponent() {
32929
- function colorSearch(search) {
32930
- return new Promise((resolve, reject) => {
32931
- const result = ["red", "orange", "yellow", "green", "blue", "indigo", "violet"]
32932
- .filter(s => new RegExp(search, "i").test(s));
32933
- resolve(result);
32934
- });
32935
- }
32936
-
32937
- return (
32938
- <SpsSelect options={colorSearch}/>
32939
- )
32940
- }
32941
- `
32942
- },
32943
- c_debounce: {
32944
- description: "Search with Debounce",
32999
+ function DemoComponent() {
33000
+ const sizes = [
33001
+ { size: "S", price: "$10.99" },
33002
+ { size: "M", price: "$12.99" },
33003
+ { size: "S", price: "$10.99" },
33004
+ ]
33005
+ return (
33006
+ <div className="sfg-row">
33007
+ <div className="sfg-col-4">
33008
+ <SpsLabel>Size</SpsLabel>
33009
+ <SpsSelect options={sizes} textKey="size" captionKey="price" />
33010
+ </div>
33011
+ </div>
33012
+ )
33013
+ }
33014
+ `
33015
+ }
33016
+ }
33017
+ },
33018
+ selectWithAction: {
33019
+ label: "Select with Action Button",
33020
+ description: () => /* @__PURE__ */ React__default.createElement("p", null, "A Text Button can be added to the bottom of the dropdown menu to provide a specific action."),
33021
+ examples: {
33022
+ basic: {
32945
33023
  react: code`
32946
- function DemoComponent() {
32947
- function colorSearch(search) {
32948
- return ["red", "orange", "yellow", "green", "blue", "indigo", "violet"]
32949
- .filter(s => (new RegExp(search, "i")).test(s));
32950
- }
33024
+ function DemoComponent() {
33025
+ const colors = ["red", "blue", "green"];
33026
+ const [action, updateAction] = useSpsAction(
33027
+ {
33028
+ label: "Go to Overview",
33029
+ icon: "dashboard",
33030
+ href: "#/overview",
33031
+ newTab: true
33032
+ },
33033
+ () => console.log("Action")
33034
+ );
33035
+
33036
+ function handleChange(event) {
33037
+ updateAction({
33038
+ label: "Test Action"
33039
+ });
33040
+ }
32951
33041
 
32952
- return (
32953
- <SpsSelect id="debounce-select" options={colorSearch} searchDebounce={2000}/>
32954
- )
32955
- }
32956
- `
33042
+ return (
33043
+ <div className="sfg-row">
33044
+ <div className="sfg-col-4">
33045
+ <SpsSelect options={colors} action={action} onChange={handleChange} />
33046
+ </div>
33047
+ </div>
33048
+ )
33049
+ }
33050
+ `
32957
33051
  }
32958
33052
  }
32959
33053
  },
32960
- d_specialAction: {
32961
- label: "Simple Action",
32962
- description: "info about simple action selects",
33054
+ disabled: {
33055
+ label: "Disabled State",
33056
+ description: () => /* @__PURE__ */ React__default.createElement("p", null, "In the disabled state, select inputs display the current selection or placeholder text, but cannot be interacted with."),
32963
33057
  examples: {
32964
- a_action: {
32965
- description: "Action",
33058
+ basic: {
32966
33059
  react: code`
32967
- function DemoComponent() {
32968
- const colors = ["red", "orange", "yellow", "blue", "indigo", "violet"];
32969
- const [action, updateAction] = useSpsAction(
32970
- {
32971
- label: "Go to Overview",
32972
- icon: "dashboard",
32973
- href: "#/overview",
32974
- newTab: true
32975
- },
32976
- () => console.log("Action")
32977
- );
32978
- function handleChange(event) {
32979
- updateAction({
32980
- label: "Test Action"
32981
- });
32982
- }
32983
-
32984
- return (
32985
- <SpsSelect id="special-action" options={colors} action={action} onChange={handleChange}/>
32986
- )
32987
- }
32988
- `
33060
+ function DemoComponent() {
33061
+ const colors = ["red", "blue", "green"];
33062
+
33063
+ return (
33064
+ <div className="sfg-row">
33065
+ <div className="sfg-col-4">
33066
+ <SpsLabel>Color</SpsLabel>
33067
+ <SpsSelect options={colors} disabled />
33068
+ </div>
33069
+ </div>
33070
+ )
33071
+ }
33072
+ `
32989
33073
  }
32990
33074
  }
32991
33075
  }
@@ -37638,6 +37722,7 @@ const MANIFEST = {
37638
37722
  examples: SpsSearchResultsBarExamples
37639
37723
  },
37640
37724
  Select: {
37725
+ description: "Selects consist off a Label and a dropdown menu from which a user selects a value from a list of pre-defined options.",
37641
37726
  components: [SpsSelect],
37642
37727
  examples: SpsSelectExamples
37643
37728
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@spscommerce/ds-react",
3
3
  "description": "SPS Design System React components",
4
- "version": "6.7.0",
4
+ "version": "6.8.0",
5
5
  "author": "SPS Commerce",
6
6
  "license": "UNLICENSED",
7
7
  "repository": "https://github.com/spscommerce/design-system/tree/main/packages/@spscommerce/ds-react",
@@ -28,11 +28,11 @@
28
28
  },
29
29
  "peerDependencies": {
30
30
  "@react-stately/collections": "^3.3.3",
31
- "@spscommerce/ds-colors": "6.7.0",
32
- "@spscommerce/ds-illustrations": "6.7.0",
33
- "@spscommerce/ds-shared": "6.7.0",
34
- "@spscommerce/positioning": "6.7.0",
35
- "@spscommerce/utils": "6.7.0",
31
+ "@spscommerce/ds-colors": "6.8.0",
32
+ "@spscommerce/ds-illustrations": "6.8.0",
33
+ "@spscommerce/ds-shared": "6.8.0",
34
+ "@spscommerce/positioning": "6.8.0",
35
+ "@spscommerce/utils": "6.8.0",
36
36
  "moment": "^2.25.3",
37
37
  "moment-timezone": "^0.5.28",
38
38
  "react": "^16.9.0",
@@ -40,11 +40,11 @@
40
40
  },
41
41
  "devDependencies": {
42
42
  "@react-stately/collections": "^3.3.3",
43
- "@spscommerce/ds-colors": "6.7.0",
44
- "@spscommerce/ds-illustrations": "6.7.0",
45
- "@spscommerce/ds-shared": "6.7.0",
46
- "@spscommerce/positioning": "6.7.0",
47
- "@spscommerce/utils": "6.7.0",
43
+ "@spscommerce/ds-colors": "6.8.0",
44
+ "@spscommerce/ds-illustrations": "6.8.0",
45
+ "@spscommerce/ds-shared": "6.8.0",
46
+ "@spscommerce/positioning": "6.8.0",
47
+ "@spscommerce/utils": "6.8.0",
48
48
  "@testing-library/react": "^9.3.2",
49
49
  "@types/prop-types": "^15.7.1",
50
50
  "@types/react": "^16.9.0",