@spscommerce/ds-react 6.6.2 → 6.9.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/lib/index.es.js CHANGED
@@ -23437,532 +23437,7 @@ function useCustomValidator(validator, validatorConfig = {}, dependencies = [])
23437
23437
  }
23438
23438
  return React.useCallback(validator, dependencies);
23439
23439
  }
23440
- const SpsFormExamples = {
23441
- a_basic: {
23442
- label: "Basic Usage",
23443
- description: "",
23444
- examples: {
23445
- basic: {
23446
- react: code`
23447
- function DemoComponent() {
23448
- const COLOR_OPTIONS = ["red", "blue", "green"];
23449
- const initValue = {
23450
- name: "Foo",
23451
- color: COLOR_OPTIONS[0],
23452
- };
23453
- const { formValue, formMeta, updateForm } = useSpsForm(initValue, {
23454
- "name": value => value.color === COLOR_OPTIONS[0] ? [SpsValidators.required] : []
23455
- });
23456
-
23457
- function handleSubmit() {
23458
- console.log("submit", formValue);
23459
- }
23460
- function reset() {
23461
- updateForm(initValue);
23462
- }
23463
-
23464
- return <>
23465
- <SpsForm formMeta={formMeta} onSubmit={handleSubmit}>
23466
- <div className="sfg-row">
23467
- <div className="sfg-col-8">
23468
- <SpsLabel for={formMeta.fields.name}>Name</SpsLabel>
23469
- <SpsTextInput
23470
- value={formValue.name}
23471
- formMeta={formMeta.fields.name}
23472
- />
23473
- </div>
23474
- <div className="sfg-col-4">
23475
- <SpsLabel for={formMeta.fields.color}>Color</SpsLabel>
23476
- {COLOR_OPTIONS.map(color =>
23477
- <SpsRadioButton key={color} name={color} value={color} label={color}
23478
- checked={color === formValue.color}
23479
- formMeta={formMeta.fields.color}
23480
- />
23481
- )}
23482
- </div>
23483
- </div>
23484
- <div className="sfg-row">
23485
- <div className="sfg-col-12">
23486
- <SpsButton className="mr-1" onClick={reset}>Reset</SpsButton>
23487
- <SpsButton type={ButtonType.SUBMIT} kind={ButtonKind.CONFIRM}>Submit</SpsButton>
23488
- </div>
23489
- </div>
23490
- </SpsForm>
23491
- <br/>
23492
- {JSON.stringify(formValue)}
23493
- </>;
23494
- }
23495
- `
23496
- }
23497
- }
23498
- },
23499
- b_array: {
23500
- label: "Form Array",
23501
- description: "",
23502
- examples: {
23503
- array: {
23504
- react: code`
23505
- function DemoComponent() {
23506
- const initValue = {
23507
- itemList: ["foo"],
23508
- }
23509
- const { formValue, formMeta, updateForm } = useSpsForm(initValue, {
23510
- "itemList.*": [SpsValidators.required],
23511
- })
23512
-
23513
- function handleSubmit() {
23514
- console.log("submit", formValue)
23515
- }
23516
- function reset() {
23517
- updateForm(initValue)
23518
- }
23519
-
23520
- function addItem() {
23521
- updateForm({
23522
- ...formValue,
23523
- itemList: [...formValue.itemList, ""],
23524
- })
23525
- }
23526
- function removeItem(index) {
23527
- updateForm({
23528
- ...formValue,
23529
- itemList: formValue.itemList.filter((_, i) => index !== i),
23530
- })
23531
- }
23532
-
23533
- return (
23534
- <>
23535
- <SpsForm formMeta={formMeta} onSubmit={handleSubmit}>
23536
- {formValue.itemList.map((item, index) => (
23537
- <div className="sfg-row" key={index}>
23538
- <div className="sfg-col-4">
23539
- <SpsLabel for={formMeta.fields.itemList.fields[index]}>
23540
- Item
23541
- </SpsLabel>
23542
- <SpsTextInput
23543
- value={item}
23544
- formMeta={formMeta.fields.itemList.fields[index]}
23545
- />
23546
- </div>
23547
- <div className="sfg-col-1">
23548
- <SpsButton
23549
- kind={ButtonKind.ICON}
23550
- icon={SpsIcon.TRASH}
23551
- className="sps-label-spacing"
23552
- onClick={() => removeItem(index)}
23553
- />
23554
- </div>
23555
- </div>
23556
- ))}
23557
- <div className="sfg-row">
23558
- <div className="sfg-col-12">
23559
- <SpsButton
23560
- className="mr-1"
23561
- kind={ButtonKind.KEY}
23562
- icon={SpsIcon.PLUS_SIGN}
23563
- onClick={addItem}
23564
- >
23565
- Add Item
23566
- </SpsButton>
23567
- <SpsButton className="mr-1" onClick={reset}>
23568
- Reset
23569
- </SpsButton>
23570
- <SpsButton
23571
- type={ButtonType.SUBMIT}
23572
- kind={ButtonKind.CONFIRM}
23573
- >
23574
- Submit
23575
- </SpsButton>
23576
- </div>
23577
- </div>
23578
- </SpsForm>
23579
- <br />
23580
- {JSON.stringify(formValue)}
23581
- </>
23582
- )
23583
- }
23584
- `
23585
- }
23586
- }
23587
- },
23588
- c_dynamic_group: {
23589
- label: "Dynamic Group",
23590
- description: "",
23591
- examples: {
23592
- basic: {
23593
- react: code`
23594
- function DemoComponent() {
23595
- const initValue = {
23596
- name: "Foo",
23597
- }
23598
- const { formValue, formMeta, updateForm } = useSpsForm(initValue)
23599
-
23600
- function handleFieldsetToggle(enabled) {
23601
- if (enabled) {
23602
- updateForm({
23603
- ...formValue,
23604
- other_stuff: {
23605
- tagline: "",
23606
- description: "",
23607
- },
23608
- })
23609
- } else {
23610
- updateForm(omit(formValue, "other_stuff"))
23611
- }
23612
- }
23613
-
23614
- function handleSubmit() {
23615
- console.log("submit", formValue)
23616
- }
23617
- function reset() {
23618
- updateForm(initValue)
23619
- }
23620
-
23621
- return (
23622
- <>
23623
- <SpsForm formMeta={formMeta} onSubmit={handleSubmit}>
23624
- <div className="sfg-row">
23625
- <div className="sfg-col-8">
23626
- <SpsLabel for={formMeta.fields.name}>Name</SpsLabel>
23627
- <SpsTextInput
23628
- value={formValue.name}
23629
- formMeta={formMeta.fields.name}
23630
- />
23631
- </div>
23632
- <div className="sfg-col-4"></div>
23633
- </div>
23634
- <div className="sfg-row">
23635
- <div className="sfg-col-12">
23636
- <SpsFieldset
23637
- optional
23638
- enabled={formMeta.fields.other_stuff}
23639
- formMeta={formMeta.fields.other_stuff}
23640
- onToggled={handleFieldsetToggle}
23641
- legend="Other Stuff"
23642
- >
23643
- {formMeta.fields.other_stuff && (
23644
- <>
23645
- <div className="sfg-row">
23646
- <div className="sfg-col-12">
23647
- <SpsLabel
23648
- for={formMeta.fields.other_stuff.fields.tagline}
23649
- >
23650
- Tagline
23651
- </SpsLabel>
23652
- <SpsTextInput
23653
- value={formValue.other_stuff.tagline}
23654
- formMeta={formMeta.fields.other_stuff.fields.tagline}
23655
- />
23656
- </div>
23657
- </div>
23658
- <div className="sfg-row">
23659
- <div className="sfg-col-12">
23660
- <SpsLabel
23661
- for={formMeta.fields.other_stuff.fields.description}
23662
- >
23663
- Description
23664
- </SpsLabel>
23665
- <SpsTextInput
23666
- value={formValue.other_stuff.description}
23667
- formMeta={
23668
- formMeta.fields.other_stuff.fields.description
23669
- }
23670
- />
23671
- </div>
23672
- </div>
23673
- </>
23674
- )}
23675
- </SpsFieldset>
23676
- </div>
23677
- </div>
23678
- <div className="sfg-row">
23679
- <div className="sfg-col-12">
23680
- <SpsButton className="mr-1" onClick={reset}>
23681
- Reset
23682
- </SpsButton>
23683
- <SpsButton
23684
- type={ButtonType.SUBMIT}
23685
- kind={ButtonKind.CONFIRM}
23686
- >
23687
- Submit
23688
- </SpsButton>
23689
- </div>
23690
- </div>
23691
- </SpsForm>
23692
- <br />
23693
- {JSON.stringify(formValue)}
23694
- </>
23695
- )
23696
- }
23697
- `
23698
- }
23699
- }
23700
- },
23701
- preventative_validators: {
23702
- label: "Preventative validators",
23703
- examples: {
23704
- basic: {
23705
- react: code`
23706
- function DemoComponent() {
23707
- const initValue = {
23708
- maxLength: "",
23709
- alpha: "",
23710
- numeric: "",
23711
- nonNumeric: ""
23712
- };
23713
-
23714
- const { formValue, formMeta, updateForm } = useSpsForm(initValue, {
23715
- "maxLength": [SpsValidators.maxLength(5)],
23716
- "alpha": [SpsValidators.alpha],
23717
- "numeric": [SpsValidators.numeric],
23718
- "nonNumeric": [SpsValidators.nonNumeric]
23719
- });
23720
-
23721
- function handleSubmit() {
23722
- console.log("submit", formValue);
23723
- }
23724
-
23725
- function reset() {
23726
- updateForm(initValue);
23727
- formMeta.markAsPristine();
23728
- }
23729
-
23730
- return <>
23731
- <SpsForm formMeta={formMeta} onSubmit={handleSubmit}>
23732
- <div className="sfg-row">
23733
- <div className="sfg-col-8">
23734
- <SpsLabel
23735
- for={formMeta.fields.maxLength}
23736
- >
23737
- MaxLength
23738
- </SpsLabel>
23739
- <SpsTextInput
23740
- value={formValue.maxLength}
23741
- formMeta={formMeta.fields.maxLength}
23742
- />
23743
- </div>
23744
- </div>
23745
- <div className="sfg-row">
23746
- <div className="sfg-col-8">
23747
- <SpsLabel
23748
- for={formMeta.fields.alpha}
23749
- >
23750
- Alpha
23751
- </SpsLabel>
23752
- <SpsTextInput
23753
- value={formValue.alpha}
23754
- formMeta={formMeta.fields.alpha}
23755
- />
23756
- </div>
23757
- </div>
23758
- <div className="sfg-row">
23759
- <div className="sfg-col-8">
23760
- <SpsLabel
23761
- for={formMeta.fields.numeric}
23762
- >
23763
- Numeric
23764
- </SpsLabel>
23765
- <SpsTextInput
23766
- value={formValue.numeric}
23767
- formMeta={formMeta.fields.numeric}
23768
- />
23769
- </div>
23770
- </div>
23771
- <div className="sfg-row">
23772
- <div className="sfg-col-8">
23773
- <SpsLabel
23774
- for={formMeta.fields.nonNumeric}
23775
- >
23776
- nonNumeric
23777
- </SpsLabel>
23778
- <SpsTextInput
23779
- value={formValue.nonNumeric}
23780
- formMeta={formMeta.fields.nonNumeric}
23781
- />
23782
- </div>
23783
- </div>
23784
-
23785
- <div className="sfg-row">
23786
- <div className="sfg-col-12">
23787
- <SpsButton className="mr-1" onClick={reset}>Reset</SpsButton>
23788
- <SpsButton type={ButtonType.SUBMIT} kind={ButtonKind.CONFIRM}>Submit</SpsButton>
23789
- </div>
23790
- </div>
23791
- </SpsForm>
23792
- </>;
23793
- }
23794
- `
23795
- },
23796
- custom_text: {
23797
- description: () => /* @__PURE__ */ React.createElement("p", null, "Using custom text in the tooltip"),
23798
- react: code`
23799
- function DemoComponent() {
23800
- const initValue = {
23801
- maxLength: ""
23802
- };
23803
-
23804
- const { formValue, formMeta, updateForm } = useSpsForm(initValue, {
23805
- "maxLength": [SpsValidators.maxLength(5)]
23806
- });
23807
-
23808
- return <>
23809
- <SpsForm formMeta={formMeta} >
23810
- <div className="sfg-row">
23811
- <div className="sfg-col-8">
23812
- <SpsLabel
23813
- for={formMeta.fields.maxLength}
23814
- errors={() => formMeta.fields.maxLength.hasPreventativeError("maxLength")
23815
- && "This field accepts a maximum of 5 characters."}
23816
- >
23817
- MaxLength
23818
- </SpsLabel>
23819
- <SpsTextInput
23820
- value={formValue.maxLength}
23821
- formMeta={formMeta.fields.maxLength}
23822
- />
23823
- </div>
23824
- </div>
23825
- </SpsForm>
23826
- </>;
23827
- }
23828
- `
23829
- }
23830
- }
23831
- },
23832
- custom_errors: {
23833
- label: "Custom errors",
23834
- description: () => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("p", null, "When using custom validators you can specify when to show the errors - on Change, on Blur or on Submit.", /* @__PURE__ */ React.createElement("br", null), "On Blur is the default behavior. If you want to change that behavior you can use", " ", /* @__PURE__ */ React.createElement("b", null, "useCustomValidator hook"), ". It takes validation function as first argument, validator configuration (object containing errorKey as key and ValidationMode as value) as second argument and dependencies as third argument. useCustomValidator returns a React callback of the validation function with the given dependencies."), /* @__PURE__ */ React.createElement("p", null, /* @__PURE__ */ React.createElement("b", null, "!Note:"), " useCustomValidator hook will make changes to the global scope and once you set a custom error key you can't change it.")),
23835
- examples: {
23836
- basic: {
23837
- react: code`
23838
- function DemoComponent() {
23839
-
23840
- const customValidator = useCustomValidator(
23841
- (value) => value < 3 ? null : { customErrorKey: true },
23842
- { customErrorKey: ValidationMode.ON_CHANGE }
23843
- // or { customErrorKey: ValidationMode.ON_SUBMIT }
23844
- );
23845
-
23846
- const initValue = {
23847
- customErrorField: "",
23848
- };
23849
-
23850
- const { formValue, formMeta, updateForm } = useSpsForm(initValue, {
23851
- "customErrorField": [customValidator],
23852
- });
23853
-
23854
- function handleSubmit() {
23855
- console.log("submit", formValue);
23856
- }
23857
-
23858
- function reset() {
23859
- updateForm(initValue);
23860
- formMeta.markAsPristine();
23861
- }
23862
-
23863
- return <>
23864
- <SpsForm formMeta={formMeta} onSubmit={handleSubmit}>
23865
- <div className="sfg-row">
23866
- <div className="sfg-col-8">
23867
- <SpsLabel
23868
- for={formMeta.fields.customErrorField}
23869
- errors={() => formMeta.fields.customErrorField.hasError("customErrorKey")
23870
- && "Custom error description"}
23871
- >
23872
- Custom Error
23873
- </SpsLabel>
23874
- <SpsTextInput
23875
- value={formValue.customErrorField}
23876
- formMeta={formMeta.fields.customErrorField}
23877
- />
23878
- </div>
23879
- </div>
23880
-
23881
- <div className="sfg-row">
23882
- <div className="sfg-col-12">
23883
- <SpsButton className="mr-1" onClick={reset}>Reset</SpsButton>
23884
- <SpsButton type={ButtonType.SUBMIT} kind={ButtonKind.CONFIRM}>Submit</SpsButton>
23885
- </div>
23886
- </div>
23887
- </SpsForm>
23888
- </>;
23889
- }
23890
- `
23891
- }
23892
- }
23893
- },
23894
- updating_validators: {
23895
- label: "Updating validators",
23896
- description: () => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("p", null, "The updateForm function supports a seconds argument (options) that allows modifying multiple field validators at once.")),
23897
- examples: {
23898
- basic: {
23899
- react: code`
23900
- function DemoComponent() {
23901
- const initValue = {
23902
- fieldA: "",
23903
- fieldB: "",
23904
- };
23905
-
23906
- const { formValue, formMeta, updateForm } = useSpsForm(initValue, {
23907
- "fieldA": [SpsValidators.required],
23908
- });
23909
-
23910
- function handleSubmit() {
23911
- console.log("submit", formValue);
23912
- }
23913
-
23914
- function reset() {
23915
- updateForm(initValue, { validators: { fieldA: [SpsValidators.required], fieldB: [] }});
23916
- formMeta.markAsPristine();
23917
- }
23918
-
23919
- // This will make field A non required and field B required in a single operation
23920
- function updateValidators() {
23921
- updateForm(undefined, { validators: { fieldA: [], fieldB: [SpsValidators.required] }});
23922
- }
23923
-
23924
- return <>
23925
- <SpsForm formMeta={formMeta} onSubmit={handleSubmit}>
23926
- <div className="sfg-row">
23927
- <div className="sfg-col-8">
23928
- <SpsLabel
23929
- for={formMeta.fields.fieldA}
23930
- >
23931
- Field A
23932
- </SpsLabel>
23933
- <SpsTextInput
23934
- value={formValue.fieldA}
23935
- formMeta={formMeta.fields.fieldA}
23936
- />
23937
- </div>
23938
- <div className="sfg-col-8">
23939
- <SpsLabel
23940
- for={formMeta.fields.fieldB}
23941
- >
23942
- Field B
23943
- </SpsLabel>
23944
- <SpsTextInput
23945
- value={formValue.fieldB}
23946
- formMeta={formMeta.fields.fieldB}
23947
- />
23948
- </div>
23949
- </div>
23950
-
23951
- <div className="sfg-row">
23952
- <div className="sfg-col-12">
23953
- <SpsButton className="mr-1" onClick={reset}>Reset</SpsButton>
23954
- <SpsButton className="mr-1" onClick={updateValidators}>Update Validators</SpsButton>
23955
- <SpsButton type={ButtonType.SUBMIT} kind={ButtonKind.CONFIRM}>Submit</SpsButton>
23956
- </div>
23957
- </div>
23958
- </SpsForm>
23959
- </>;
23960
- }
23961
- `
23962
- }
23963
- }
23964
- }
23965
- };
23440
+ const SpsFormExamples = {};
23966
23441
  const SpsAddRemoveFormRowExamples = {
23967
23442
  ideal: {
23968
23443
  label: "Ideal",
@@ -33315,202 +32790,286 @@ const SpsScrollableContainerExamples = {
33315
32790
  }
33316
32791
  };
33317
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
+ },
33318
32813
  basic: {
33319
- label: "Basic",
33320
- 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."),
33321
32816
  examples: {
33322
- a_simple: {
33323
- description: "Simple value options",
32817
+ basic: {
33324
32818
  react: code`
33325
- function DemoComponent() {
33326
- const colors = ["red", "blue", "green"];
32819
+ function DemoComponent() {
32820
+ const colors = ["red", "blue", "green"];
33327
32821
 
33328
- return (
33329
- <SpsSelect id="basic" options={colors}/>
33330
- )
33331
- }
33332
- `
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
+ `
33333
32832
  },
33334
- b_formHooks: {
33335
- 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.")),
33336
32835
  react: code`
33337
- function DemoComponent() {
33338
- const colors = ["red", "blue", "green"];
33339
- const { formValue, formMeta, updateForm } = useSpsForm({
33340
- color: colors[0]
33341
- });
32836
+ function DemoComponent() {
32837
+ const colors = ["red", "blue", "green"];
33342
32838
 
33343
- return <>
33344
- <SpsLabel for={formMeta.fields.color}>Color</SpsLabel>
33345
- <SpsSelect options={colors} formMeta={formMeta.fields.color}
33346
- value={formValue.color}
33347
- />
33348
- </>
33349
- }
33350
- `
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
+ `
33351
32849
  },
33352
- c_placeholder: {
33353
- 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.")),
32852
+ react: code`
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
+ `
32866
+ },
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.")),
32869
+ react: code`
32870
+ function DemoComponent() {
32871
+
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
+ `
32882
+ },
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.")),
32887
+ react: code`
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
+ `
32904
+ }
32905
+ }
32906
+ },
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."),
32910
+ examples: {
32911
+ basic: {
33354
32912
  react: code`
33355
- function DemoComponent() {
33356
- const colors = ["red", "blue", "green"];
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
+ }
33357
32917
 
33358
- return (
33359
- <SpsSelect id="placeholder" options={colors} placeholder="Choose a color…"/>
33360
- )
33361
- }
33362
- `
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
+ `
33363
32928
  },
33364
- d_notClearable: {
33365
- description: "Not clearable",
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.")),
33366
32931
  react: code`
33367
- function DemoComponent() {
33368
- const colors = ["red", "blue", "green"];
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
+ }
33369
32939
 
33370
- return (
33371
- <SpsSelect options={colors} value="red" notClearable />
33372
- )
33373
- }
33374
- `
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
+ `
33375
32950
  },
33376
- e_zeroState: {
33377
- description: "Zero state",
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.")),
33378
32953
  react: code`
33379
- function DemoComponent() {
33380
- return (
33381
- <SpsSelect options={[]} zeroState="We're sorry, there are no options to choose from at this time, because reasons." />
33382
- )
33383
- }
33384
- `
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
+ `
33385
32969
  }
33386
32970
  }
33387
32971
  },
33388
- b_objectOpts: {
32972
+ objectOptions: {
33389
32973
  label: "Object Options",
33390
- description: "info about 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."),
33391
32975
  examples: {
33392
- a_basic: {
33393
- description: "Basic use of object options",
32976
+ basic: {
33394
32977
  react: code`
33395
- function DemoComponent() {
33396
- const sizes = [
33397
- { size: "S", price: "10.99" },
33398
- { size: "M", price: "12.99" },
33399
- { size: "L", price: "14.99" }
33400
- ];
33401
-
33402
- return (
33403
- <SpsSelect options={sizes} textKey="size" />
33404
- )
33405
- }
33406
- `
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
+ `
33407
32995
  },
33408
- b_captions: {
33409
- description: "Captions",
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.")),
33410
32998
  react: code`
33411
- function DemoComponent() {
33412
- const lorem = [
33413
- {
33414
- title: "Lorem",
33415
- description: "Ut enim ad minim veniam"
33416
- },
33417
- {
33418
- title: "Ipsum",
33419
- description: "Excepteur sint occaecat cupidatat non proident"
33420
- }
33421
- ];
33422
-
33423
- return (
33424
- <SpsSelect options={lorem} textKey="title" captionKey="description" />
33425
- )
33426
- }
33427
- `
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
+ `
33428
33015
  }
33429
33016
  }
33430
33017
  },
33431
- c_searchable: {
33432
- label: "Search/Filter",
33433
- description: "info about search/filter",
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."),
33434
33021
  examples: {
33435
- a_simple: {
33436
- description: "Simple search function",
33437
- react: code`
33438
- function DemoComponent() {
33439
- function colorSearch(search) {
33440
- return ["red", "orange", "yellow", "green", "blue", "indigo", "violet"]
33441
- .filter(s => (new RegExp(search, "i")).test(s));
33442
- }
33443
-
33444
- return (
33445
- <SpsSelect id="search-function" options={colorSearch} zeroState="While I'm sure that's a lovely color, it's not an option we support."/>
33446
- )
33447
- }
33448
- `
33449
- },
33450
- b_promise: {
33451
- description: "Search function returning a Promise",
33452
- react: code`
33453
- function DemoComponent() {
33454
- function colorSearch(search) {
33455
- return new Promise((resolve, reject) => {
33456
- const result = ["red", "orange", "yellow", "green", "blue", "indigo", "violet"]
33457
- .filter(s => new RegExp(search, "i").test(s));
33458
- resolve(result);
33459
- });
33460
- }
33461
-
33462
- return (
33463
- <SpsSelect options={colorSearch}/>
33464
- )
33465
- }
33466
- `
33467
- },
33468
- c_debounce: {
33469
- description: "Search with Debounce",
33022
+ basic: {
33470
33023
  react: code`
33471
- function DemoComponent() {
33472
- function colorSearch(search) {
33473
- return ["red", "orange", "yellow", "green", "blue", "indigo", "violet"]
33474
- .filter(s => (new RegExp(search, "i")).test(s));
33475
- }
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
+ }
33476
33041
 
33477
- return (
33478
- <SpsSelect id="debounce-select" options={colorSearch} searchDebounce={2000}/>
33479
- )
33480
- }
33481
- `
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
+ `
33482
33051
  }
33483
33052
  }
33484
33053
  },
33485
- d_specialAction: {
33486
- label: "Simple Action",
33487
- 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."),
33488
33057
  examples: {
33489
- a_action: {
33490
- description: "Action",
33058
+ basic: {
33491
33059
  react: code`
33492
- function DemoComponent() {
33493
- const colors = ["red", "orange", "yellow", "blue", "indigo", "violet"];
33494
- const [action, updateAction] = useSpsAction(
33495
- {
33496
- label: "Go to Overview",
33497
- icon: "dashboard",
33498
- href: "#/overview",
33499
- newTab: true
33500
- },
33501
- () => console.log("Action")
33502
- );
33503
- function handleChange(event) {
33504
- updateAction({
33505
- label: "Test Action"
33506
- });
33507
- }
33060
+ function DemoComponent() {
33061
+ const colors = ["red", "blue", "green"];
33508
33062
 
33509
- return (
33510
- <SpsSelect id="special-action" options={colors} action={action} onChange={handleChange}/>
33511
- )
33512
- }
33513
- `
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
+ `
33514
33073
  }
33515
33074
  }
33516
33075
  }
@@ -36469,85 +36028,235 @@ Object.assign(SpsToggle, {
36469
36028
  displayName: "SpsToggle"
36470
36029
  });
36471
36030
  const SpsToggleExamples = {
36472
- small: {
36473
- label: "Small",
36031
+ general: {
36032
+ label: "General Usage",
36033
+ description: ({ NavigateTo }) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("h5", null, "Use Toggles:"), /* @__PURE__ */ React.createElement("ul", null, /* @__PURE__ */ React.createElement("li", {
36034
+ className: "mb-2"
36035
+ }, 'When an option represents a specific "on/off" state.'), /* @__PURE__ */ React.createElement("li", {
36036
+ className: "mb-2"
36037
+ }, "When the selection causes an imeediate change in the system.")), /* @__PURE__ */ React.createElement("h5", null, "Do Not Use Toggles:"), /* @__PURE__ */ React.createElement("ul", null, /* @__PURE__ */ React.createElement("li", {
36038
+ className: "mb-2"
36039
+ }, "When a selection does not cause an immediate change in the system.", " ", /* @__PURE__ */ React.createElement(NavigateTo, {
36040
+ to: "checkbox"
36041
+ }, "Checkboxes"), " or", " ", /* @__PURE__ */ React.createElement(NavigateTo, {
36042
+ to: "radio-buttons"
36043
+ }, "Radio Buttons"), " instead."), /* @__PURE__ */ React.createElement("li", {
36044
+ className: "mb-2"
36045
+ }, "Inside a form with a save/submit button as this contradicts the immediate change in the system that a toggle controls.")))
36046
+ },
36047
+ basic: {
36048
+ label: "Basic Toggles",
36049
+ description: () => /* @__PURE__ */ React.createElement("p", null, "Basic toggles can appear with or without labels and can include an extended description if necessary."),
36474
36050
  examples: {
36475
- a_small: {
36051
+ basic: {
36052
+ description: () => /* @__PURE__ */ React.createElement("h4", {
36053
+ className: "mb-3"
36054
+ }, "Toggle"),
36476
36055
  react: code`
36477
- function DemoComponent() {
36478
- const { formValue, formMeta, updateForm } = useSpsForm({
36479
- toggle: false
36480
- });
36056
+ function DemoComponent() {
36057
+ const { formValue, formMeta, updateForm } = useSpsForm({
36058
+ toggle: true
36059
+ });
36481
36060
 
36482
- return <SpsToggle formMeta={formMeta.fields.toggle}
36483
- active={formValue.toggle}
36484
- label="Main Label"
36485
- description="Extra descriptive text"
36486
- />;
36487
- }
36488
- `
36061
+ return (
36062
+ <SpsToggle
36063
+ active={formValue.toggle}
36064
+ />
36065
+ )
36066
+ }
36067
+ `
36489
36068
  },
36490
- b_changeHandler: {
36491
- description: "With UseState",
36069
+ label: {
36070
+ description: () => /* @__PURE__ */ React.createElement("h4", {
36071
+ className: "mb-3"
36072
+ }, "Toggle + Label"),
36492
36073
  react: code`
36493
- function DemoComponent() {
36494
- function changeHandler() {
36495
- setActive(!checked);
36496
- }
36497
- const [active, setActive] = React.useState();
36498
- return (
36499
- <SpsToggle active={active} onChange={changeHandler}/>
36500
- )
36501
- }
36502
- `
36074
+ function DemoComponent() {
36075
+ const { formValue, formMeta, updateForm } = useSpsForm({
36076
+ toggle: true
36077
+ });
36078
+
36079
+ return (
36080
+ <SpsToggle
36081
+ active={formValue.toggle}
36082
+ label="Label"
36083
+ />
36084
+ )
36085
+ }
36086
+ `
36087
+ },
36088
+ extendedDescription: {
36089
+ description: () => /* @__PURE__ */ React.createElement("h4", {
36090
+ className: "mb-3"
36091
+ }, "Toggle + Label with Extended Description"),
36092
+ react: code`
36093
+ function DemoComponent() {
36094
+ const { formValue, formMeta, updateForm } = useSpsForm({
36095
+ toggle: true
36096
+ });
36097
+
36098
+ return (
36099
+ <SpsToggle
36100
+ active={formValue.toggle}
36101
+ label="Label"
36102
+ description="(optional extended description)"
36103
+ />
36104
+ )
36105
+ }
36106
+ `
36503
36107
  }
36504
36108
  }
36505
36109
  },
36506
- b_large: {
36507
- label: "Large",
36110
+ groups: {
36111
+ label: "Toggle Groups",
36112
+ description: () => /* @__PURE__ */ React.createElement("p", null, "Toggle Groups can appear as one of the two types listed."),
36508
36113
  examples: {
36509
- a_large: {
36114
+ group: {
36115
+ description: () => /* @__PURE__ */ React.createElement("h4", {
36116
+ className: "mb-3"
36117
+ }, "Toggle Group"),
36510
36118
  react: code`
36511
- function DemoComponent() {
36512
- const { formValue, formMeta, updateForm } = useSpsForm({
36513
- toggle: true
36514
- });
36119
+ function DemoComponent() {
36120
+ const { formValue, formMeta, updateForm } = useSpsForm({
36121
+ toggleLabel: true,
36122
+ toggle1: true,
36123
+ toggle2: true,
36124
+ toggle3: true,
36125
+ });
36515
36126
 
36516
- return <SpsToggle large formMeta={formMeta.fields.toggle}
36517
- active={formValue.toggle}
36518
- />;
36519
- }
36520
- `
36127
+ return (
36128
+ <>
36129
+ <SpsLabel for={formMeta.fields.toggleLabel}>Section Label</SpsLabel>
36130
+ <SpsToggle
36131
+ active={formValue.toggle1}
36132
+ label="Label"
36133
+ description="(optional extended description)"
36134
+ />
36135
+ <SpsToggle
36136
+ active={formValue.toggle2}
36137
+ label="Label"
36138
+ />
36139
+ <SpsToggle
36140
+ active={formValue.toggle3}
36141
+ label="Label"
36142
+ description="(optional extended description)"
36143
+ />
36144
+ </>
36145
+ )
36146
+ }
36147
+ `
36148
+ },
36149
+ alternate: {
36150
+ description: () => /* @__PURE__ */ React.createElement("h4", {
36151
+ className: "mb-3"
36152
+ }, "Toggle Group Alternate"),
36153
+ react: code`
36154
+ function DemoComponent() {
36155
+ const { formValue, formMeta, updateForm } = useSpsForm({
36156
+ toggleLabel: true,
36157
+ toggle1: true,
36158
+ toggle2: true,
36159
+ toggle3: true,
36160
+ });
36161
+
36162
+ return (
36163
+ <>
36164
+ <SpsLabel for={formMeta.fields.toggleLabel}>Section Label</SpsLabel>
36165
+ <div className="sfg-row">
36166
+ <div className="sfg-col-3">
36167
+ <div className="sfg-row">
36168
+ <div className="sfg-col-6">
36169
+ <span>Label</span>
36170
+ </div>
36171
+ <div className="sfg-col-6">
36172
+ <SpsToggle
36173
+ active={formValue.toggle1}
36174
+ />
36175
+ </div>
36176
+ </div>
36177
+ <div className="sfg-row">
36178
+ <div className="sfg-col-6">
36179
+ <span>Label</span>
36180
+ </div>
36181
+ <div className="sfg-col-6">
36182
+ <SpsToggle
36183
+ active={formValue.toggle2}
36184
+ />
36185
+ </div>
36186
+ </div>
36187
+ <div className="sfg-row">
36188
+ <div className="sfg-col-6">
36189
+ <span>Label</span>
36190
+ </div>
36191
+ <div className="sfg-col-6">
36192
+ <SpsToggle
36193
+ active={formValue.toggle3}
36194
+ />
36195
+ </div>
36196
+ </div>
36197
+ </div>
36198
+ </div>
36199
+ </>
36200
+ )
36201
+ }
36202
+ `
36521
36203
  }
36522
36204
  }
36523
36205
  },
36524
- d_disabled: {
36525
- label: "Disabled",
36206
+ disabled: {
36207
+ label: "Disabled States",
36208
+ description: () => /* @__PURE__ */ React.createElement("p", null, "Toggles have a disabled style for each possible state."),
36526
36209
  examples: {
36527
- disabled: {
36210
+ basic: {
36528
36211
  react: code`
36529
- function DemoComponent() {
36530
- const { formValue, formMeta, updateForm } = useSpsForm({
36531
- toggleA: false,
36532
- toggleB: true,
36533
- });
36212
+ function DemoComponent() {
36213
+ const { formValue, formMeta, updateForm } = useSpsForm({
36214
+ toggle: true
36215
+ });
36534
36216
 
36535
- return <>
36536
- <SpsToggle formMeta={formMeta.fields.toggleA}
36537
- active={formValue.toggleA}
36538
- label="Main Label"
36539
- description="Extra descriptive text"
36540
- disabled
36541
- />
36542
- <SpsToggle formMeta={formMeta.fields.toggleB}
36543
- active={formValue.toggleB}
36544
- label="Main Label"
36545
- description="Extra descriptive text"
36546
- disabled
36547
- />
36548
- </>;
36549
- }
36550
- `
36217
+ return (
36218
+ <SpsToggle
36219
+ active={formValue.toggle}
36220
+ disabled
36221
+ />
36222
+ )
36223
+ }
36224
+ `
36225
+ },
36226
+ label: {
36227
+ react: code`
36228
+ function DemoComponent() {
36229
+ const { formValue, formMeta, updateForm } = useSpsForm({
36230
+ toggle: true
36231
+ });
36232
+
36233
+ return (
36234
+ <SpsToggle
36235
+ active={formValue.toggle}
36236
+ label="Label"
36237
+ disabled
36238
+ />
36239
+ )
36240
+ }
36241
+ `
36242
+ },
36243
+ extendedDescription: {
36244
+ react: code`
36245
+ function DemoComponent() {
36246
+ const { formValue, formMeta, updateForm } = useSpsForm({
36247
+ toggle: true
36248
+ });
36249
+
36250
+ return (
36251
+ <SpsToggle
36252
+ active={formValue.toggle}
36253
+ label="Label"
36254
+ description="(optional extended description)"
36255
+ disabled
36256
+ />
36257
+ )
36258
+ }
36259
+ `
36551
36260
  }
36552
36261
  }
36553
36262
  }
@@ -38163,6 +37872,7 @@ const MANIFEST = {
38163
37872
  examples: SpsSearchResultsBarExamples
38164
37873
  },
38165
37874
  Select: {
37875
+ description: "Selects consist off a Label and a dropdown menu from which a user selects a value from a list of pre-defined options.",
38166
37876
  components: [SpsSelect],
38167
37877
  examples: SpsSelectExamples
38168
37878
  },
@@ -38223,6 +37933,7 @@ const MANIFEST = {
38223
37933
  examples: SpsTextareaExamples
38224
37934
  },
38225
37935
  Toggle: {
37936
+ description: () => /* @__PURE__ */ React.createElement("p", null, "Toggles allow a user to immediately turn a setting on or off."),
38226
37937
  components: [SpsToggle],
38227
37938
  examples: SpsToggleExamples
38228
37939
  },