@spscommerce/ds-react 6.30.1 → 6.31.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
@@ -25027,7 +25027,8 @@ const propsDoc$$ = {
25027
25027
  help: "ReactNodeOrRenderFn",
25028
25028
  helpIcon: "SpsIcon",
25029
25029
  helpIconColor: "string",
25030
- errors: "ReactNodeOrRenderFn"
25030
+ errors: "ReactNodeOrRenderFn",
25031
+ interactiveIcons: "Array<{icon: SpsIcon, iconColor: string, onClick: () => void}>"
25031
25032
  };
25032
25033
  const propTypes$10 = __spreadProps(__spreadValues({}, spsGlobalPropTypes), {
25033
25034
  description: propTypes$1I.exports.string,
@@ -25039,7 +25040,8 @@ const propTypes$10 = __spreadProps(__spreadValues({}, spsGlobalPropTypes), {
25039
25040
  help: nodeOrRenderFn,
25040
25041
  helpIcon: enumValue(SpsIcon),
25041
25042
  helpIconColor: propTypes$1I.exports.string,
25042
- errors: nodeOrRenderFn
25043
+ errors: nodeOrRenderFn,
25044
+ interactiveIcons: propTypes$1I.exports.arrayOf(impl())
25043
25045
  });
25044
25046
  function SpsLabel(_y) {
25045
25047
  var _z = _y, {
@@ -25052,6 +25054,7 @@ function SpsLabel(_y) {
25052
25054
  helpIcon = SpsIcon.QUESTION_CIRCLE,
25053
25055
  helpIconColor = "blue200",
25054
25056
  errors,
25057
+ interactiveIcons,
25055
25058
  unsafelyReplaceClassName,
25056
25059
  "data-testid": testId
25057
25060
  } = _z, rest = __objRest(_z, [
@@ -25064,6 +25067,7 @@ function SpsLabel(_y) {
25064
25067
  "helpIcon",
25065
25068
  "helpIconColor",
25066
25069
  "errors",
25070
+ "interactiveIcons",
25067
25071
  "unsafelyReplaceClassName",
25068
25072
  "data-testid"
25069
25073
  ]);
@@ -25194,7 +25198,12 @@ function SpsLabel(_y) {
25194
25198
  className: clsx("sps-icon", `sps-icon-${helpIcon}`, helpIconColor, !help && "d-none"),
25195
25199
  onClick: handleHelpClick,
25196
25200
  onMouseLeave: delayedHideTooltips
25197
- })), /* @__PURE__ */ React.createElement(SpsTooltip, {
25201
+ }), interactiveIcons && interactiveIcons.map((icon, idx) => /* @__PURE__ */ React.createElement("i", {
25202
+ key: idx,
25203
+ "data-testid": `${testId}__interactive-icon-${idx}`,
25204
+ className: clsx("sps-icon", `sps-icon-${icon.icon}`, icon.iconColor, "interactive-icon"),
25205
+ onClick: () => icon.onClick()
25206
+ }))), /* @__PURE__ */ React.createElement(SpsTooltip, {
25198
25207
  kind: TooltipKind.DEFAULT,
25199
25208
  for: helpIconRef,
25200
25209
  showOn: TooltipShowTrigger.MANUAL,
@@ -25313,39 +25322,6 @@ const SpsLabelExamples = {
25313
25322
  }
25314
25323
  `
25315
25324
  },
25316
- settingsIcon: {
25317
- 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, {
25318
- to: "modal"
25319
- }, "Modal"), " window or ", /* @__PURE__ */ React.createElement(NavigateTo, {
25320
- to: "focused-task"
25321
- }, "Focused Task View"), " containing settings or preferences related to a specific input field.")),
25322
- react: code`
25323
- function DemoComponent() {
25324
- const { formValue, formMeta, updateForm } = useSpsForm({
25325
- companyName: ""
25326
- });
25327
-
25328
- function iconClickHandler(event) {
25329
- // screen out non-icon clicks
25330
- if (event.target.tagName !== "I") return;
25331
- alert("settings action triggered");
25332
- }
25333
-
25334
- return <>
25335
- <SpsLabel for={formMeta.fields.companyName}
25336
- help="Pretend there's something helpful written here."
25337
- helpIcon={SpsIcon.GEAR}
25338
- onClick={iconClickHandler}
25339
- >
25340
- Company Name
25341
- </SpsLabel>
25342
- <SpsTextInput formMeta={formMeta.fields.companyName}
25343
- value={formValue.companyName}
25344
- ></SpsTextInput>
25345
- </>;
25346
- }
25347
- `
25348
- },
25349
25325
  customIcons: {
25350
25326
  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.")),
25351
25327
  react: code`
@@ -25370,6 +25346,49 @@ const SpsLabelExamples = {
25370
25346
  }
25371
25347
  }
25372
25348
  },
25349
+ interactiveIcons: {
25350
+ label: "Interactive Icons",
25351
+ description: ({ NavigateTo }) => /* @__PURE__ */ React.createElement("p", null, "The Interactive Icons can be used to launch a ", /* @__PURE__ */ React.createElement(NavigateTo, {
25352
+ to: "modal"
25353
+ }, "Modal"), " ", "window or ", /* @__PURE__ */ React.createElement(NavigateTo, {
25354
+ to: "focused-task"
25355
+ }, "Focused Task View"), " containing settings or preferences related to a specific input field."),
25356
+ examples: {
25357
+ basic: {
25358
+ react: code`
25359
+ function DemoComponent() {
25360
+ const { formValue, formMeta, updateForm } = useSpsForm({
25361
+ companyName: ""
25362
+ });
25363
+
25364
+ const [showModal, setShowModal] = React.useState(false);
25365
+ const [showFocusedTask, setShowFocusedTask] = React.useState(false);
25366
+
25367
+ return <>
25368
+ <SpsLabel for={formMeta.fields.companyName}
25369
+ interactiveIcons={[
25370
+ {icon: SpsIcon.GEAR, onClick: () => setShowModal(true)},
25371
+ {icon: SpsIcon.WRENCH, onClick: () => setShowFocusedTask(true), iconColor: "blue200"}
25372
+ ]}
25373
+ >
25374
+ Company Name
25375
+ </SpsLabel>
25376
+ <SpsTextInput formMeta={formMeta.fields.companyName}
25377
+ value={formValue.companyName}
25378
+ ></SpsTextInput>
25379
+ {showModal && (
25380
+ <SpsModal onClose={() => setShowModal(false)}>
25381
+ </SpsModal>
25382
+ )}
25383
+ <SpsFocusedTask isOpen={showFocusedTask} onClose={() => setShowFocusedTask(false)}>
25384
+ <h2>Focused Task</h2>
25385
+ </SpsFocusedTask>
25386
+ </>;
25387
+ }
25388
+ `
25389
+ }
25390
+ }
25391
+ },
25373
25392
  validation: {
25374
25393
  label: "Validation",
25375
25394
  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."),
@@ -2,6 +2,11 @@ import { SpsIcon } from "@spscommerce/ds-shared";
2
2
  import * as PropTypes from "../prop-types";
3
3
  import type { SpsFormControl } from "../form/hooks/formControl";
4
4
  import { SpsFormMetaBase } from "../form/hooks/useSpsForm";
5
+ interface InteractiveIcon {
6
+ icon: SpsIcon;
7
+ iconColor: string;
8
+ onClick: () => void;
9
+ }
5
10
  declare const propTypes: {
6
11
  description: PropTypes.Requireable<string>;
7
12
  for: PropTypes.Validator<SpsFormMetaBase<any> | SpsFormControl<any>>;
@@ -10,11 +15,12 @@ declare const propTypes: {
10
15
  helpIcon: PropTypes.Requireable<SpsIcon>;
11
16
  helpIconColor: PropTypes.Requireable<string>;
12
17
  errors: PropTypes.Requireable<PropTypes.ReactNodeOrRenderFn>;
18
+ interactiveIcons: PropTypes.Requireable<InteractiveIcon[]>;
13
19
  children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
14
20
  className: PropTypes.Requireable<string>;
15
21
  "data-testid": PropTypes.Requireable<string>;
16
22
  unsafelyReplaceClassName: PropTypes.Requireable<string>;
17
23
  };
18
24
  export declare type SpsLabelProps = PropTypes.InferTS<typeof propTypes, HTMLLabelElement>;
19
- export declare function SpsLabel({ children, className, description, for: forProp, stronglySuggested, help, helpIcon, helpIconColor, errors, unsafelyReplaceClassName, "data-testid": testId, ...rest }: SpsLabelProps): JSX.Element;
25
+ export declare function SpsLabel({ children, className, description, for: forProp, stronglySuggested, help, helpIcon, helpIconColor, errors, interactiveIcons, unsafelyReplaceClassName, "data-testid": testId, ...rest }: SpsLabelProps): JSX.Element;
20
26
  export {};
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.30.1",
4
+ "version": "6.31.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,10 +28,10 @@
28
28
  },
29
29
  "peerDependencies": {
30
30
  "@react-stately/collections": "^3.3.3",
31
- "@spscommerce/ds-colors": "6.30.1",
32
- "@spscommerce/ds-illustrations": "6.30.1",
33
- "@spscommerce/ds-shared": "6.30.1",
34
- "@spscommerce/positioning": "6.30.1",
31
+ "@spscommerce/ds-colors": "6.31.0",
32
+ "@spscommerce/ds-illustrations": "6.31.0",
33
+ "@spscommerce/ds-shared": "6.31.0",
34
+ "@spscommerce/positioning": "6.31.0",
35
35
  "@spscommerce/utils": "^6.11.3",
36
36
  "moment": "^2.25.3",
37
37
  "moment-timezone": "^0.5.28",
@@ -40,10 +40,10 @@
40
40
  },
41
41
  "devDependencies": {
42
42
  "@react-stately/collections": "^3.3.3",
43
- "@spscommerce/ds-colors": "6.30.1",
44
- "@spscommerce/ds-illustrations": "6.30.1",
45
- "@spscommerce/ds-shared": "6.30.1",
46
- "@spscommerce/positioning": "6.30.1",
43
+ "@spscommerce/ds-colors": "6.31.0",
44
+ "@spscommerce/ds-illustrations": "6.31.0",
45
+ "@spscommerce/ds-shared": "6.31.0",
46
+ "@spscommerce/positioning": "6.31.0",
47
47
  "@spscommerce/utils": "^6.11.3",
48
48
  "@testing-library/react": "^10.4.0",
49
49
  "@types/prop-types": "^15.7.1",