@spscommerce/ds-react 6.3.0 → 6.5.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 +629 -566
  2. package/lib/index.es.js +415 -326
  3. package/package.json +11 -11
package/lib/index.es.js CHANGED
@@ -24197,7 +24197,7 @@ function SpsGrowler(props2) {
24197
24197
  clearTimers();
24198
24198
  };
24199
24199
  }, []);
24200
- const portal = usePortal("sps-growler-display-area", ["sps-growler-area", "z-stratum-dialog"]);
24200
+ const portal = usePortal("sps-growler-display-area", ["sps-growler-area", "z-stratum-growlers"]);
24201
24201
  return portal(/* @__PURE__ */ React.createElement("div", __spreadValues({
24202
24202
  role: "alert",
24203
24203
  className: classes,
@@ -25442,8 +25442,12 @@ Object.assign(SpsLabel, {
25442
25442
  displayName: "SpsLabel"
25443
25443
  });
25444
25444
  const SpsLabelExamples = {
25445
+ general: {
25446
+ label: "General Usage",
25447
+ description: () => /* @__PURE__ */ React.createElement("p", null, "In almost all cases, input fields should be paired with a label describing the value to be entered into the field. Certain labels can be accompanied by icons to provide additional information or context about that particular field.")
25448
+ },
25445
25449
  basic: {
25446
- label: "Basic",
25450
+ label: "Basic Label",
25447
25451
  examples: {
25448
25452
  basic: {
25449
25453
  react: code`
@@ -25465,31 +25469,9 @@ const SpsLabelExamples = {
25465
25469
  }
25466
25470
  }
25467
25471
  },
25468
- b_suggested: {
25469
- label: "Strongly Suggested",
25470
- examples: {
25471
- basic: {
25472
- react: code`
25473
- function DemoComponent() {
25474
- const { formValue, formMeta, updateForm } = useSpsForm({
25475
- companyName: ""
25476
- });
25477
-
25478
- return <>
25479
- <SpsLabel for={formMeta.fields.companyName} stronglySuggested>
25480
- Company Name
25481
- </SpsLabel>
25482
- <SpsTextInput value={formValue.companyName}
25483
- formMeta={formMeta.fields.companyName}
25484
- ></SpsTextInput>
25485
- </>;
25486
- }
25487
- `
25488
- }
25489
- }
25490
- },
25491
- c_required: {
25492
- label: "Required",
25472
+ required: {
25473
+ label: "Required Labels",
25474
+ description: () => /* @__PURE__ */ React.createElement("p", null, "Many forms contain input fields that require values in order for the form to be submitted. Such fields have an accompanying red asterisk to the left of the Label."),
25493
25475
  examples: {
25494
25476
  basic: {
25495
25477
  react: code`
@@ -25516,11 +25498,12 @@ const SpsLabelExamples = {
25516
25498
  }
25517
25499
  }
25518
25500
  },
25519
- d_help: {
25520
- label: "Help Information",
25501
+ icons: {
25502
+ label: "Labels with Icons",
25503
+ description: () => /* @__PURE__ */ React.createElement("p", null, "Icons can be used with labels to reveal tooltips with additional contextual information or help text. Icons remain visible at all times, even when an input field is in an error state. For more information about error states view the Validation section of this page."),
25521
25504
  examples: {
25522
- a_defaultIcon: {
25523
- description: "<p>Default icon</p>",
25505
+ infoIcon: {
25506
+ description: () => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("h4", null, "Info Icons"), /* @__PURE__ */ React.createElement("p", null, "Info Icons reveal a tooltip providing more information, such as instructions on correct formatting required for the input field.")),
25524
25507
  react: code`
25525
25508
  function DemoComponent() {
25526
25509
  const { formValue, formMeta, updateForm } = useSpsForm({
@@ -25529,7 +25512,8 @@ const SpsLabelExamples = {
25529
25512
 
25530
25513
  return <>
25531
25514
  <SpsLabel for={formMeta.fields.companyName}
25532
- help="Pretend there's something helpful written here."
25515
+ helpIcon={SpsIcon.INFO}
25516
+ help="This is an informative and instructive tooltip."
25533
25517
  >
25534
25518
  Company Name
25535
25519
  </SpsLabel>
@@ -25540,18 +25524,29 @@ const SpsLabelExamples = {
25540
25524
  }
25541
25525
  `
25542
25526
  },
25543
- b_customIcon: {
25544
- description: "<p>Custom icon</p>",
25527
+ settingsIcon: {
25528
+ description: ({ NavigateTo }) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("h4", null, "Settings Icons"), /* @__PURE__ */ React.createElement("p", null, "The gear icon can be used to launch a ", /* @__PURE__ */ React.createElement(NavigateTo, {
25529
+ to: "modal"
25530
+ }, "Modal"), " window or ", /* @__PURE__ */ React.createElement(NavigateTo, {
25531
+ to: "focused-task"
25532
+ }, "Focused Task View"), " containing settings or preferences related to a specific input field.")),
25545
25533
  react: code`
25546
25534
  function DemoComponent() {
25547
25535
  const { formValue, formMeta, updateForm } = useSpsForm({
25548
25536
  companyName: ""
25549
25537
  });
25550
25538
 
25539
+ function iconClickHandler(event) {
25540
+ // screen out non-icon clicks
25541
+ if (event.target.tagName !== "I") return;
25542
+ alert("settings action triggered");
25543
+ }
25544
+
25551
25545
  return <>
25552
25546
  <SpsLabel for={formMeta.fields.companyName}
25553
25547
  help="Pretend there's something helpful written here."
25554
- helpIcon={SpsIcon.EXCHANGE} helpIconColor="red200"
25548
+ helpIcon={SpsIcon.GEAR}
25549
+ onClick={iconClickHandler}
25555
25550
  >
25556
25551
  Company Name
25557
25552
  </SpsLabel>
@@ -25561,11 +25556,34 @@ const SpsLabelExamples = {
25561
25556
  </>;
25562
25557
  }
25563
25558
  `
25559
+ },
25560
+ customIcons: {
25561
+ description: () => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("h4", null, "Custom Icons"), /* @__PURE__ */ React.createElement("p", null, "The icon can be customized, but only in the case when the Info Icon does not properly represent the tooltip message.")),
25562
+ react: code`
25563
+ function DemoComponent() {
25564
+ const { formValue, formMeta, updateForm } = useSpsForm({
25565
+ companyName: ""
25566
+ });
25567
+
25568
+ return <>
25569
+ <SpsLabel for={formMeta.fields.companyName}
25570
+ helpIcon={SpsIcon.BELL}
25571
+ help="This is a custom icon"
25572
+ >
25573
+ Company Name
25574
+ </SpsLabel>
25575
+ <SpsTextInput formMeta={formMeta.fields.companyName}
25576
+ value={formValue.companyName}
25577
+ ></SpsTextInput>
25578
+ </>
25579
+ }
25580
+ `
25564
25581
  }
25565
25582
  }
25566
25583
  },
25567
- e_validation: {
25584
+ validation: {
25568
25585
  label: "Validation",
25586
+ description: () => /* @__PURE__ */ React.createElement("p", null, "When an input field fails validation for any reason, an Error State style is applied, which includes an Error Icon tot he left of the label that reveals instructions for correcting the error."),
25569
25587
  examples: {
25570
25588
  basic: {
25571
25589
  react: code`
@@ -25596,64 +25614,6 @@ const SpsLabelExamples = {
25596
25614
  `
25597
25615
  }
25598
25616
  }
25599
- },
25600
- f_combinations: {
25601
- label: "Combinations",
25602
- examples: {
25603
- a_combo1: {
25604
- react: code`
25605
- function DemoComponent() {
25606
- const { formValue, formMeta, updateForm } = useSpsForm({
25607
- companyName: "Target"
25608
- }, {
25609
- "companyName": [SpsValidators.minLength(7)]
25610
- });
25611
-
25612
- React.useEffect(() => {
25613
- // Make validation error visible for the purpose of this demo
25614
- formMeta.markAsDirty();
25615
- }, []);
25616
-
25617
- return <>
25618
- <SpsLabel for={formMeta.fields.companyName}
25619
- stronglySuggested
25620
- errors={() => formMeta.fields.companyName.hasError("minLength")
25621
- && "Company Name must be at least 7 characters."}
25622
- >
25623
- Company Name
25624
- </SpsLabel>
25625
- <SpsTextInput formMeta={formMeta.fields.companyName}
25626
- value={formValue.companyName}
25627
- ></SpsTextInput>
25628
- </>;
25629
- }
25630
- `
25631
- },
25632
- b_combo2: {
25633
- react: code`
25634
- function DemoComponent() {
25635
- const { formValue, formMeta, updateForm } = useSpsForm({
25636
- companyName: ""
25637
- }, {
25638
- "companyName": [SpsValidators.required]
25639
- });
25640
-
25641
- return <>
25642
- <SpsLabel for={formMeta.fields.companyName}
25643
- help="Pretend there's something helpful written here."
25644
- errors={() => formMeta.fields.companyName.hasError("required")
25645
- && "Please enter a company name."}
25646
- >
25647
- Company Name
25648
- </SpsLabel>
25649
- <SpsTextInput formMeta={formMeta.fields.companyName}
25650
- value={formValue.companyName}
25651
- ></SpsTextInput>
25652
- </>;
25653
- }
25654
- `
25655
- }
25656
- }
25657
25617
  }
25658
25618
  };
25659
25619
  const propsDoc$Y = {
@@ -30282,212 +30242,375 @@ Object.assign(SpsMultiSelect, {
30282
30242
  displayName: "SpsMultiSelect"
30283
30243
  });
30284
30244
  const SpsMultiSelectExamples = {
30285
- basic: {
30286
- label: "Basic",
30287
- description: "<p>Multi select component</p>",
30245
+ general: {
30246
+ label: "General Usage",
30247
+ description: ({ NavigateTo }) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("h5", null, "Use a Mulit-Select"), /* @__PURE__ */ React.createElement("ul", null, /* @__PURE__ */ React.createElement("li", null, "When a list of predetermined values can be provided and the input allows multiple entries.")), /* @__PURE__ */ React.createElement("h5", null, "Do Not Use a Multi-Select:"), /* @__PURE__ */ React.createElement("ul", null, /* @__PURE__ */ React.createElement("li", {
30248
+ className: "mb-2"
30249
+ }, "When there are only two possible options. Consider", " ", /* @__PURE__ */ React.createElement(NavigateTo, {
30250
+ to: "checkbox"
30251
+ }, "Checkboxes"), " or", " ", /* @__PURE__ */ React.createElement(NavigateTo, {
30252
+ to: "radio-buttons"
30253
+ }, "Radio Buttons"), " instead."), /* @__PURE__ */ React.createElement("li", null, "When it is ideal to display all available options without requiring a click. Consider", " ", /* @__PURE__ */ React.createElement(NavigateTo, {
30254
+ to: "checkbox"
30255
+ }, "Checkboxes"), " or", " ", /* @__PURE__ */ React.createElement(NavigateTo, {
30256
+ to: "radio-buttons"
30257
+ }, "Radio Buttons"), " instead.")), /* @__PURE__ */ React.createElement("h5", null, "Using Multi-Selects in a Form"), /* @__PURE__ */ React.createElement("p", null, "Reference the ", /* @__PURE__ */ React.createElement(NavigateTo, {
30258
+ to: "form"
30259
+ }, "Forms"), " page for guidelines for placing", " ", /* @__PURE__ */ React.createElement(NavigateTo, {
30260
+ to: "text-inputs"
30261
+ }, "Inputs"), " in Form Layouts."))
30262
+ },
30263
+ basicMuliSelect: {
30264
+ label: "Basic Multi-Selects",
30265
+ description: "Basic Multi-Selects include a label and dropdown menu including a list of options. The user is allowed to make a single selection.",
30288
30266
  examples: {
30289
- a_basic: {
30267
+ basic: {
30290
30268
  react: code`
30291
- function Component() {
30292
- const [opts] = React.useState(["foo", "bar", "baz", "orp"])
30293
- const { formValue, formMeta, updateForm } = useSpsForm({
30294
- things: [ opts[0] ]
30295
- })
30296
-
30297
- return <>
30298
- <SpsLabel for={formMeta.fields.things}>Things</SpsLabel>
30299
- <SpsMultiSelect
30300
- options={opts}
30301
- formMeta={formMeta.fields.things}
30302
- value={formValue.things}
30303
- />
30304
- <br />
30305
- {JSON.stringify(formValue)}
30306
- </>
30307
- }
30308
- `
30269
+ function Component() {
30270
+ const [opts] = React.useState(["foo", "bar", "baz", "orp"])
30271
+ const { formValue, formMeta, updateForm } = useSpsForm({
30272
+ things: [opts[0]]
30273
+ })
30274
+
30275
+ return <>
30276
+ <SpsLabel for={formMeta.fields.things}>Company Names</SpsLabel>
30277
+ <SpsMultiSelect
30278
+ options={opts}
30279
+ formMeta={formMeta.fields.things}
30280
+ value={formValue.things}
30281
+ />
30282
+ <br />
30283
+ {JSON.stringify(formValue)}
30284
+ </>
30285
+ }`
30309
30286
  },
30310
- b_disabled: {
30287
+ customizablePlaceholderText: {
30288
+ description: () => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("h4", null, "Customizable Placeholder Text"), /* @__PURE__ */ React.createElement("p", null, "Placeholder text can be customized to specifically reference the content in the dropdown menu.")),
30311
30289
  react: code`
30312
- function Component() {
30313
- const [opts] = React.useState(["foo", "bar", "baz", "orp"])
30314
- const { formValue, formMeta, updateForm } = useSpsForm({
30315
- things: [ opts[0] ]
30316
- })
30317
-
30318
- return <>
30319
- <SpsLabel for={formMeta.fields.things}>Things</SpsLabel>
30320
- <SpsMultiSelect disabled
30321
- options={opts}
30322
- formMeta={formMeta.fields.things}
30323
- value={formValue.things}
30324
- />
30325
- <br />
30326
- {JSON.stringify(formValue)}
30327
- </>
30328
- }
30329
- `
30290
+ function Component() {
30291
+ const [opts] = React.useState(["foo", "bar", "baz", "orp"])
30292
+ const { formValue, formMeta, updateForm } = useSpsForm({
30293
+ things: []
30294
+ })
30295
+
30296
+ return <>
30297
+ <SpsLabel for={formMeta.fields.things}>Company Names</SpsLabel>
30298
+ <SpsMultiSelect
30299
+ placeholder= "Select companies..."
30300
+ options={opts}
30301
+ formMeta={formMeta.fields.things}
30302
+ value={formValue.things}
30303
+ />
30304
+ <br />
30305
+ {JSON.stringify(formValue)}
30306
+ </>
30307
+ }`
30330
30308
  },
30331
- c_externalTags: {
30309
+ zeroStateNoAvailableOptions: {
30310
+ description: () => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("h4", null, "Zero State / No Available Options"), /* @__PURE__ */ React.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.")),
30332
30311
  react: code`
30333
- function Component() {
30334
- const [foo, setFoo] = React.useState(["orp"])
30335
- const [opts] = React.useState(["foo", "bar", "baz", "orp"])
30336
- function handleChange(event) {
30337
- setFoo(event.target.value)
30338
- }
30339
- function removeByIndex(i) {
30340
- foo.splice(i, 1)
30341
- setFoo([...foo])
30342
- }
30343
- return (
30344
- <>
30345
- <SpsMultiSelect
30346
- hideSelected
30347
- options={opts}
30348
- value={foo}
30349
- onChange={handleChange}
30350
- />
30351
- <br />
30352
- {foo.map((opt, i) => (
30353
- <SpsClickableTag
30354
- className="mt-1 ml-1"
30355
- key={i}
30356
- onRemove={() => removeByIndex(i)}
30357
- >
30358
- {opt}
30359
- </SpsClickableTag>
30360
- ))}
30361
- </>
30362
- )
30363
- }
30364
- `
30365
- },
30366
- icon: {
30312
+ function Component() {
30313
+ const [opts] = React.useState([])
30314
+ const { formValue, formMeta, updateForm } = useSpsForm({
30315
+ things: []
30316
+ })
30317
+
30318
+ return <>
30319
+ <SpsLabel for={formMeta.fields.things}>Company Names</SpsLabel>
30320
+ <SpsMultiSelect
30321
+ zeroState="No options available"
30322
+ options={opts}
30323
+ formMeta={formMeta.fields.things}
30324
+ value={formValue.things}
30325
+ />
30326
+ <br />
30327
+ {JSON.stringify(formValue)}
30328
+ </>
30329
+ }`
30330
+ }
30331
+ }
30332
+ },
30333
+ promise: {
30334
+ label: "Asynchronous Data Source",
30335
+ description: "If the list of options must be sourced asynchronously, the options prop can take a function that returns a Promise.",
30336
+ examples: {
30337
+ returnAPromise: {
30338
+ react: code`function Component() {
30339
+ const { formValue, formMeta, updateForm } = useSpsForm({
30340
+ things: []
30341
+ })
30342
+ function colorSearch(search) {
30343
+ return new Promise((resolve, reject) => {
30344
+ const result = ["foo", "bar", "baz", "orp"]
30345
+ .filter(s => new RegExp(search, "i").test(s));
30346
+ resolve(result);
30347
+ });
30348
+ }
30349
+
30350
+ return <>
30351
+ <SpsLabel for={formMeta.fields.things}>Things</SpsLabel>
30352
+ <SpsMultiSelect
30353
+ options={colorSearch}
30354
+ formMeta={formMeta.fields.things}
30355
+ value={formValue.things}
30356
+ />
30357
+ <br />
30358
+ {JSON.stringify(formValue)}
30359
+ </>
30360
+ }`
30361
+ }
30362
+ }
30363
+ },
30364
+ objectOptions: {
30365
+ label: "Object Options",
30366
+ description: "The values in the select menu can be modified to provide more detail to the user or the system, when necssary.",
30367
+ examples: {
30368
+ basic: {
30367
30369
  react: code`
30368
- function Component() {
30369
- const [opts] = React.useState(["foo", "bar", "baz", "orp"])
30370
- const { formValue, formMeta, updateForm } = useSpsForm({
30371
- things: [ opts[0] ]
30372
- })
30373
-
30374
- return <>
30375
- <SpsLabel for={formMeta.fields.things}>Things</SpsLabel>
30376
- <SpsMultiSelect
30377
- icon={SpsIcon.FILTER}
30378
- options={opts}
30379
- formMeta={formMeta.fields.things}
30380
- value={formValue.things}
30381
- />
30382
- <br />
30383
- {JSON.stringify(formValue)}
30384
- </>
30385
- }
30386
- `
30370
+ function Component() {
30371
+ const [opts] = React.useState([
30372
+ { id: 1, name: "Target" },
30373
+ { id: 2, name: "Cabela's" },
30374
+ { id: 3, name: "Best Buy" },
30375
+ ])
30376
+ const [foo, setFoo] = React.useState([])
30377
+ function handleChange(event) {
30378
+ setFoo(event.target.value)
30379
+ }
30380
+ return (
30381
+ <>
30382
+ <SpsMultiSelect
30383
+ options={opts}
30384
+ textKey="name"
30385
+ value={foo}
30386
+ onChange={handleChange}
30387
+ />
30388
+ <br />
30389
+ {JSON.stringify(foo)}
30390
+ </>
30391
+ )
30392
+ }`
30387
30393
  },
30388
- objects: {
30394
+ extendedDetails: {
30395
+ description: () => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("h4", null, "Extended Details"), /* @__PURE__ */ React.createElement("p", null, "Extended details can be displayed in the dropdown menu. Only the primary detail is displayed as the selection.")),
30389
30396
  react: code`
30390
- function Component() {
30391
- const [opts] = React.useState([
30392
- { id: 1, name: "Target" },
30393
- { id: 2, name: "Cabela's" },
30394
- { id: 3, name: "Best Buy" },
30395
- ])
30396
- const [foo, setFoo] = React.useState([])
30397
- function handleChange(event) {
30398
- setFoo(event.target.value)
30399
- }
30400
- return (
30401
- <>
30402
- <SpsMultiSelect
30403
- options={opts}
30404
- textKey="name"
30405
- value={foo}
30406
- onChange={handleChange}
30407
- />
30408
- <br />
30409
- {JSON.stringify(foo)}
30410
- </>
30411
- )
30412
- }
30413
- `
30397
+ function Component() {
30398
+ const [opts] = React.useState([
30399
+ { id: 1, name: "Target", description: "blah", disabled: true },
30400
+ { id: 2, name: "Cabela's", description: "test", disabled: true },
30401
+ { id: 3, name: "Best Buy", description: "2" },
30402
+ ])
30403
+ const [foo, setFoo] = React.useState([])
30404
+ function handleChange(event) {
30405
+ setFoo(event.target.value)
30406
+ }
30407
+ return (
30408
+ <>
30409
+ <SpsMultiSelect
30410
+ options={opts}
30411
+ textKey="name"
30412
+ captionKey="description"
30413
+ value={foo}
30414
+ onChange={handleChange}
30415
+ />
30416
+ <br />
30417
+ {JSON.stringify(foo)}
30418
+ </>
30419
+ )
30420
+ }`
30414
30421
  },
30415
- disabledOptions: {
30422
+ disabledOption: {
30423
+ description: () => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("h4", null, "Disabled Options"), /* @__PURE__ */ React.createElement("p", null, "When options in the dropdown list are unavailable (as a result of having been selected or for any other reason) they should adopt a disabled style.")),
30416
30424
  react: code`
30417
- function Component() {
30418
- const [opts] = React.useState([
30419
- { id: 1, name: "Target", disabled: true },
30420
- { id: 2, name: "Cabela's", disabled: true },
30421
- { id: 3, name: "Best Buy" },
30422
- ])
30423
- const [foo, setFoo] = React.useState([])
30424
- function handleChange(event) {
30425
- setFoo(event.target.value)
30426
- }
30427
- return (
30428
- <>
30429
- <SpsMultiSelect
30430
- options={opts}
30431
- textKey="name"
30432
- value={foo}
30433
- onChange={handleChange}
30434
- />
30435
- <br />
30436
- {JSON.stringify(foo)}
30437
- </>
30438
- )
30439
- }
30440
- `
30425
+ function Component() {
30426
+ const [opts] = React.useState(["foo", "bar", "baz", "orp"])
30427
+ const { formValue, formMeta, updateForm } = useSpsForm({
30428
+ things: [ opts[0] ]
30429
+ })
30430
+
30431
+ return <>
30432
+ <SpsLabel for={formMeta.fields.things}>Company Names</SpsLabel>
30433
+ <SpsMultiSelect
30434
+ options={opts}
30435
+ formMeta={formMeta.fields.things}
30436
+ value={formValue.things}
30437
+ disableSelected
30438
+ />
30439
+ <br />
30440
+ {JSON.stringify(formValue)}
30441
+ </>
30442
+ }
30443
+ `
30441
30444
  }
30442
30445
  }
30443
30446
  },
30444
- searchText: {
30445
- label: "Search text",
30446
- description: "Get search text",
30447
+ getSearchText: {
30448
+ label: "Get Search Text",
30449
+ description: "The text that the user has entered into the input can be accessed via passing a handler to onSearchChange. This is typically used in combination with the action option to enable a user to add a value they don't find in the list.",
30447
30450
  examples: {
30448
- a_actionWithSearchText: {
30449
- react: code`
30450
- function Component() {
30451
- const [opts] = React.useState(["foo", "bar", "baz", "orp"]);
30452
- const { formValue, formMeta, updateForm } = useSpsForm({
30453
- tags: [opts[0]],
30451
+ basic: {
30452
+ react: code`function Component() {
30453
+ const [opts] = React.useState(["foo", "bar", "baz", "orp"]);
30454
+ const { formValue, formMeta, updateForm } = useSpsForm({
30455
+ tags: [opts[0]],
30456
+ });
30457
+
30458
+ const [searchText, setSearchText] = React.useState("");
30459
+
30460
+ React.useEffect(() => {
30461
+ updateAction({
30462
+ label: searchText ? \`Create a New Tag "\${searchText}"\` : "Create a New Tag",
30454
30463
  });
30455
-
30456
- const [searchText, setSearchText] = React.useState("");
30457
-
30458
- React.useEffect(() => {
30459
- updateAction({
30460
- label: searchText ? \`Create a New Tag "\${searchText}"\` : "Create a New Tag",
30461
- });
30462
- }, [searchText, opts]);
30463
-
30464
- const handleSearchChange = (searchTextValue) => {
30465
- setSearchText(searchTextValue)
30466
- }
30467
-
30468
- const [action, updateAction] = useSpsAction(
30469
- {
30470
- label: "Create a New Tag",
30471
- icon: SpsIcon.PLUS_SIGN,
30472
- },
30473
- () => console.log("New Tag has been created")
30474
- );
30475
-
30476
- return (
30477
- <>
30478
- <SpsLabel for={formMeta.fields.tags}>Tags</SpsLabel>
30464
+ }, [searchText, opts]);
30465
+
30466
+ const handleSearchChange = (searchTextValue) => {
30467
+ setSearchText(searchTextValue)
30468
+ }
30469
+
30470
+ const [action, updateAction] = useSpsAction(
30471
+ {
30472
+ label: "Create a New Tag",
30473
+ icon: SpsIcon.PLUS_SIGN,
30474
+ },
30475
+ () => console.log("New Tag has been created")
30476
+ );
30477
+
30478
+ return (
30479
+ <>
30480
+ <SpsLabel for={formMeta.fields.tags}>Tags</SpsLabel>
30481
+ <SpsMultiSelect
30482
+ disableSelected
30483
+ icon={SpsIcon.FILTER}
30484
+ options={opts}
30485
+ action={action}
30486
+ formMeta={formMeta.fields.tags}
30487
+ value={formValue.tags}
30488
+ onSearchChange={handleSearchChange}
30489
+ />
30490
+ </>
30491
+ );
30492
+ }`
30493
+ }
30494
+ }
30495
+ },
30496
+ createANewValue: {
30497
+ label: "Create a New Value",
30498
+ description: "This feature allows users to add, and select, a new value that doesn't exist in the current dropdown menu options.",
30499
+ examples: {
30500
+ basic: {
30501
+ react: code`function Component() {
30502
+ const [opts, setOpts] = React.useState(["foo", "bar", "baz", "orp"]);
30503
+ const { formValue, formMeta, updateForm } = useSpsForm({
30504
+ tags: [opts[0]],
30505
+ });
30506
+
30507
+ const [searchText, setSearchText] = React.useState("");
30508
+
30509
+ React.useEffect(() => {
30510
+ updateAction({
30511
+ label: searchText
30512
+ ? \`Create a New Tag "\${searchText}"\`
30513
+ : "Create a New Tag",
30514
+ disabled: searchText === ""
30515
+ });
30516
+ }, [searchText, opts]);
30517
+
30518
+ const handleSearchChange = (searchTextValue) => {
30519
+ setSearchText(searchTextValue);
30520
+ };
30521
+
30522
+ const [action, updateAction] = useSpsAction(
30523
+ {
30524
+ label: "Create a New Tag",
30525
+ icon: SpsIcon.PLUS_SIGN,
30526
+ },
30527
+ () => {
30528
+ setOpts([...opts, searchText]);
30529
+ updateForm({ ...formValue, tags: [...formValue.tags, searchText] });
30530
+ handleSearchChange("");
30531
+ }
30532
+ );
30533
+
30534
+ return (
30535
+ <>
30536
+ <SpsLabel for={formMeta.fields.tags}>Tags</SpsLabel>
30537
+ <SpsMultiSelect
30538
+ disableSelected
30539
+ icon={SpsIcon.FILTER}
30540
+ options={opts}
30541
+ action={action}
30542
+ formMeta={formMeta.fields.tags}
30543
+ value={formValue.tags}
30544
+ onSearchChange={handleSearchChange}
30545
+ clearSearchOnBlur
30546
+ />
30547
+ </>
30548
+ );
30549
+ }`
30550
+ }
30551
+ }
30552
+ },
30553
+ selectedValuesAlternate: {
30554
+ label: "Selected Values Alternate",
30555
+ description: () => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("p", null, "Use this option when it is ideal for the selected values to appear as tags outside of the input field. Opt for this option when adding or removing values from a large list of selections that would create a cumbersome field."), /* @__PURE__ */ React.createElement("p", null, /* @__PURE__ */ React.createElement("i", null, "Note: The placement of the selected values can appear belcow the input field or elsewhere in the UI if necessary."))),
30556
+ examples: {
30557
+ basic: {
30558
+ react: code`function Component() {
30559
+ const [foo, setFoo] = React.useState(["orp"])
30560
+ const [opts] = React.useState(["foo", "bar", "baz", "orp"])
30561
+ function handleChange(event) {
30562
+ setFoo(event.target.value)
30563
+ }
30564
+ function removeByIndex(i) {
30565
+ foo.splice(i, 1)
30566
+ setFoo([...foo])
30567
+ }
30568
+ return (
30569
+ <>
30479
30570
  <SpsMultiSelect
30480
- disableSelected
30481
- icon={SpsIcon.FILTER}
30482
- options={opts}
30483
- action={action}
30484
- formMeta={formMeta.fields.tags}
30485
- value={formValue.tags}
30486
- onSearchChange={handleSearchChange}
30571
+ hideSelected
30572
+ options={opts}
30573
+ value={foo}
30574
+ onChange={handleChange}
30487
30575
  />
30488
- </>
30489
- );
30490
- }`
30576
+ <br />
30577
+ {foo.map((opt, i) => (
30578
+ <SpsClickableTag
30579
+ className="mt-1 ml-1"
30580
+ key={i}
30581
+ onRemove={() => removeByIndex(i)}
30582
+ >
30583
+ {opt}
30584
+ </SpsClickableTag>
30585
+ ))}
30586
+ </>
30587
+ )
30588
+ }`
30589
+ }
30590
+ }
30591
+ },
30592
+ disabledState: {
30593
+ label: "Disabled State",
30594
+ description: "In the disabled state, select inputs display the current selection or placeholder text, but cannot be interacted with.",
30595
+ examples: {
30596
+ basic: {
30597
+ react: code`function Component() {
30598
+ const [opts] = React.useState(["foo", "bar", "baz", "orp"])
30599
+ const { formValue, formMeta, updateForm } = useSpsForm({
30600
+ things: [ opts[0] ]
30601
+ })
30602
+
30603
+ return <>
30604
+ <SpsLabel for={formMeta.fields.things}>Company Name</SpsLabel>
30605
+ <SpsMultiSelect disabled
30606
+ options={opts}
30607
+ formMeta={formMeta.fields.things}
30608
+ value={formValue.things}
30609
+ />
30610
+ <br />
30611
+ {JSON.stringify(formValue)}
30612
+ </>
30613
+ }`
30491
30614
  }
30492
30615
  }
30493
30616
  }
@@ -37390,13 +37513,7 @@ const MANIFEST = {
37390
37513
  },
37391
37514
  Cards: {
37392
37515
  description: () => /* @__PURE__ */ React.createElement("p", null, "Cards are used to group similar or related content together in a single container. They can be combined with additional elements such as Headers, Footers, or Tabs."),
37393
- components: [
37394
- SpsCardV2,
37395
- SpsCardV2Footer,
37396
- SpsCardV2Header,
37397
- SpsCardV2Title,
37398
- SpsTabsV2
37399
- ],
37516
+ components: [SpsCardV2, SpsCardV2Footer, SpsCardV2Header, SpsCardV2Title, SpsTabsV2],
37400
37517
  examples: SpsCardExamples
37401
37518
  },
37402
37519
  Checkbox: {
@@ -37427,12 +37544,7 @@ const MANIFEST = {
37427
37544
  examples: SpsContentRowExamples
37428
37545
  },
37429
37546
  "Content Tiles": {
37430
- components: [
37431
- SpsTile,
37432
- SpsTileList,
37433
- SpsSortingHeader,
37434
- SpsSortingHeaderCell
37435
- ],
37547
+ components: [SpsTile, SpsTileList, SpsSortingHeader, SpsSortingHeaderCell],
37436
37548
  examples: SpsTileListExamples
37437
37549
  },
37438
37550
  "Filter Tiles": {
@@ -37452,11 +37564,7 @@ const MANIFEST = {
37452
37564
  examples: SpsDatetimeExamples
37453
37565
  },
37454
37566
  "Description Lists": {
37455
- components: [
37456
- SpsDescriptionList,
37457
- SpsDescriptionListDefinition,
37458
- SpsDescriptionListTerm
37459
- ],
37567
+ components: [SpsDescriptionList, SpsDescriptionListDefinition, SpsDescriptionListTerm],
37460
37568
  examples: SpsDescriptionListExamples
37461
37569
  },
37462
37570
  Dropdown: {
@@ -37464,7 +37572,7 @@ const MANIFEST = {
37464
37572
  examples: SpsDropdownExamples
37465
37573
  },
37466
37574
  "Feedback Blocks": {
37467
- description: ({ NavigateTo }) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("p", null, "Feedback Blocks show static informational messages on a page. They should not dynamically appear or disappear. For feedback that responds to a user action, Use a ", /* @__PURE__ */ React.createElement(NavigateTo, {
37575
+ description: ({ NavigateTo }) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("p", null, "Feedback Blocks show static informational messages on a page. They should not dynamically appear or disappear. For feedback that responds to a user action, Use a", " ", /* @__PURE__ */ React.createElement(NavigateTo, {
37468
37576
  to: "growler"
37469
37577
  }, "Growler"), " instead."), /* @__PURE__ */ React.createElement("h5", null, "Variants"), /* @__PURE__ */ React.createElement("p", null, "Variants are generally tied to a specific color and an accompanying icon."), /* @__PURE__ */ React.createElement(SpsMicroBlock, {
37470
37578
  kind: FeedbackBlockKind.ERROR,
@@ -37490,12 +37598,7 @@ const MANIFEST = {
37490
37598
  examples: SpsFieldsetExamples
37491
37599
  },
37492
37600
  "Filter Panel": {
37493
- components: [
37494
- SpsFilterPanel,
37495
- SpsFilterPanelSection,
37496
- SpsFilterPanelCap,
37497
- SpsFilterPanelFilterBox
37498
- ],
37601
+ components: [SpsFilterPanel, SpsFilterPanelSection, SpsFilterPanelCap, SpsFilterPanelFilterBox],
37499
37602
  examples: SpsFilterPanelExamples
37500
37603
  },
37501
37604
  "Focused Task": {
@@ -37524,6 +37627,7 @@ const MANIFEST = {
37524
37627
  examples: SpsKeyValueListExamples
37525
37628
  },
37526
37629
  Label: {
37630
+ description: () => /* @__PURE__ */ React.createElement("p", null, "Labels provide a description for the value to be entered or selected in an accompanying input field."),
37527
37631
  components: [SpsLabel],
37528
37632
  examples: SpsLabelExamples
37529
37633
  },
@@ -37552,6 +37656,7 @@ const MANIFEST = {
37552
37656
  examples: SpsModalExamples
37553
37657
  },
37554
37658
  "Multi Select": {
37659
+ description: () => /* @__PURE__ */ React.createElement("p", null, "Multi-Selects consist of a Label and a dropdown menu from which a user selects one or more values from a list of pre-defined options."),
37555
37660
  components: [SpsMultiSelect],
37556
37661
  examples: SpsMultiSelectExamples
37557
37662
  },
@@ -37611,11 +37716,7 @@ const MANIFEST = {
37611
37716
  examples: SpsSlackLinkExamples
37612
37717
  },
37613
37718
  "Summary List Row": {
37614
- components: [
37615
- SpsSummaryListRow,
37616
- SpsSummaryListColumn,
37617
- SpsSummaryListExpansion
37618
- ],
37719
+ components: [SpsSummaryListRow, SpsSummaryListColumn, SpsSummaryListExpansion],
37619
37720
  examples: SpsSummaryListExamples
37620
37721
  },
37621
37722
  Tables: {
@@ -37628,14 +37729,7 @@ const MANIFEST = {
37628
37729
  }, "Content Tiles"), ") are one of three options for displaying a list of records on a page."), /* @__PURE__ */ React.createElement("br", null), /* @__PURE__ */ React.createElement("div", {
37629
37730
  className: "sps-body-14"
37630
37731
  }, "Tables are the ideal solution for displaying tabular data, especially when the listed records contain a considerable amount of data points. While tables are primarily used to display an extensive list of records, often in a paginated format, they can also be used to display smaller sets of tabular data in any context.")),
37631
- components: [
37632
- SpsTable,
37633
- SpsTableBody,
37634
- SpsTableCell,
37635
- SpsTableHead,
37636
- SpsTableHeader,
37637
- SpsTableRow
37638
- ],
37732
+ components: [SpsTable, SpsTableBody, SpsTableCell, SpsTableHead, SpsTableHeader, SpsTableRow],
37639
37733
  examples: SpsTableExamples
37640
37734
  },
37641
37735
  Tags: {
@@ -37669,12 +37763,7 @@ const MANIFEST = {
37669
37763
  examples: SpsWizardExamples
37670
37764
  },
37671
37765
  Workflow: {
37672
- components: [
37673
- SpsWorkflow,
37674
- SpsWorkflowDocument,
37675
- SpsWorkflowDocumentStatus,
37676
- SpsWorkflowStep
37677
- ],
37766
+ components: [SpsWorkflow, SpsWorkflowDocument, SpsWorkflowDocumentStatus, SpsWorkflowStep],
37678
37767
  examples: SpsWorkflowExamples
37679
37768
  },
37680
37769
  "Zero States": {