@drivy/cobalt 0.29.2 → 0.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.
Files changed (43) hide show
  1. package/cjs/tokens/theme.js +1 -1
  2. package/components/Card/index.js +3 -2
  3. package/components/Card/index.js.map +1 -1
  4. package/components/Flash/index.js +4 -4
  5. package/components/Flash/index.js.map +1 -1
  6. package/components/Form/Autocomplete/index.js +1 -1
  7. package/components/Form/Autocomplete/index.js.map +1 -1
  8. package/components/Form/Slider.js.map +1 -1
  9. package/package.json +11 -11
  10. package/styles/components/Accordion/index.scss +1 -1
  11. package/styles/components/Alerter/index.scss +2 -4
  12. package/styles/components/BulletList/index.scss +1 -2
  13. package/styles/components/Buttons/DefaultButton/index.scss +12 -12
  14. package/styles/components/Buttons/GhostButton/index.scss +4 -4
  15. package/styles/components/Buttons/InversedButton/index.scss +2 -2
  16. package/styles/components/Buttons/index.scss +6 -7
  17. package/styles/components/Calendar/CalendarRangePicker/index.scss +13 -18
  18. package/styles/components/Calendar/CalendarView/index.scss +6 -8
  19. package/styles/components/Card/index.scss +16 -6
  20. package/styles/components/Cell/index.scss +1 -1
  21. package/styles/components/Flash/index.scss +2 -4
  22. package/styles/components/Form/Autocomplete/index.scss +10 -21
  23. package/styles/components/Form/CheckablePill.scss +5 -6
  24. package/styles/components/Form/Checkmark.scss +1 -5
  25. package/styles/components/Form/Hint.scss +0 -9
  26. package/styles/components/Form/RadioWithDetails.scss +5 -5
  27. package/styles/components/Form/TextInput.scss +5 -5
  28. package/styles/components/Form/ToggleSwitch.scss +1 -1
  29. package/styles/components/Helper/index.scss +0 -3
  30. package/styles/components/Icon/index.scss +1 -2
  31. package/styles/components/Note/index.scss +4 -0
  32. package/styles/components/PhotoDropzone/index.scss +1 -2
  33. package/styles/components/TabBar/index.scss +1 -1
  34. package/styles/components/Tag/index.scss +2 -4
  35. package/styles/core/_colors-map.scss +164 -164
  36. package/styles/core/color.scss +28 -6
  37. package/styles/core/text.scss +37 -19
  38. package/styles/core/theme.scss +486 -160
  39. package/styles/core/typography.scss +12 -12
  40. package/tokens/theme.js +1 -1
  41. package/types/components/Card/index.d.ts +3 -1
  42. package/types/components/Form/Slider.d.ts +2 -2
  43. package/utilities.css +651 -295
@@ -48,7 +48,7 @@ const text = {
48
48
  base: "graphite/navy.700/grey.100",
49
49
  baseInteractive: {
50
50
  DEFAULT: "graphite/navy.700/grey.100",
51
- hover: "graphite/navy.900/grey.100"
51
+ hover: "graphite/navy.300/grey.300"
52
52
  },
53
53
  subdued: "graphite.light/navy.300/grey.300",
54
54
  subduedInteractive: {
@@ -1,8 +1,9 @@
1
1
  import React, { PureComponent } from 'react';
2
2
  import cx from 'classnames';
3
3
 
4
- const Card = ({ children, className, flattened }) => (React.createElement("div", { className: cx("cobalt-Card", className, {
5
- "cobalt-Card--flattened": flattened,
4
+ const Card = ({ children, className, legacy, responsive, }) => (React.createElement("div", { className: cx("cobalt-Card", className, {
5
+ "cobalt-Card--legacy": legacy,
6
+ "cobalt-Card--responsive": responsive,
6
7
  }) }, children));
7
8
  const getClasses = ({ className = "", tabBar, tight, subdued, divided, }) => {
8
9
  return cx(className, "cobalt-Card__Section", {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/Card/index.tsx"],"sourcesContent":["import React, { PureComponent } from \"react\"\nimport cx from \"classnames\"\n\nexport type CardProps = {\n children?: React.ReactNode\n className?: string\n flattened?: boolean\n}\n\nexport const Card = ({ children, className, flattened }: CardProps) => (\n <div\n className={cx(\"cobalt-Card\", className, {\n \"cobalt-Card--flattened\": flattened,\n })}\n >\n {children}\n </div>\n)\n\nexport type CardSectionProps = {\n children: React.ReactNode\n className?: string\n tabBar?: boolean\n tight?: boolean\n subdued?: boolean\n /**\n * true or \"soft\"\n * @default false\n */\n divided?: boolean | string\n}\n\nexport type CardSectionLinkProps = CardSectionProps & {\n href: React.AnchorHTMLAttributes<HTMLAnchorElement>[\"href\"]\n target?: React.AnchorHTMLAttributes<HTMLAnchorElement>[\"target\"]\n rel?: React.AnchorHTMLAttributes<HTMLAnchorElement>[\"rel\"]\n}\n\nconst getClasses = ({\n className = \"\",\n tabBar,\n tight,\n subdued,\n divided,\n}: CardSectionProps) => {\n return cx(className, \"cobalt-Card__Section\", {\n \"cobalt-Card__Section--tabBar\": tabBar === true,\n \"cobalt-Card__Section--tight\": tight === true,\n \"cobalt-Card__Section--subdued\": subdued === true,\n \"cobalt-Card__Section--divided\": divided === true,\n \"cobalt-Card__Section--dividedSoft\": divided === \"soft\",\n })\n}\n\nconst CardSectionLink = ({\n href,\n target,\n rel,\n ...baseProps\n}: CardSectionLinkProps) => {\n return (\n <a\n className={getClasses(baseProps)}\n href={href}\n target={target}\n rel={target && !rel ? \"noopener noreferrer\" : rel}\n >\n {baseProps.children}\n </a>\n )\n}\nCardSectionLink.displayName = \"CardSection.Link\"\n\nexport class CardSection extends PureComponent<CardSectionProps, never> {\n static Link = CardSectionLink\n render() {\n return <div className={getClasses(this.props)}>{this.props.children}</div>\n }\n}\n\nCard.Section = CardSection\n\nexport default Card\n"],"names":[],"mappings":";;;AASa,MAAA,IAAI,GAAG,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAa,MAChE,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EACE,SAAS,EAAE,EAAE,CAAC,aAAa,EAAE,SAAS,EAAE;AACtC,QAAA,wBAAwB,EAAE,SAAS;AACpC,KAAA,CAAC,EAED,EAAA,QAAQ,CACL,EACP;AAqBD,MAAM,UAAU,GAAG,CAAC,EAClB,SAAS,GAAG,EAAE,EACd,MAAM,EACN,KAAK,EACL,OAAO,EACP,OAAO,GACU,KAAI;AACrB,IAAA,OAAO,EAAE,CAAC,SAAS,EAAE,sBAAsB,EAAE;QAC3C,8BAA8B,EAAE,MAAM,KAAK,IAAI;QAC/C,6BAA6B,EAAE,KAAK,KAAK,IAAI;QAC7C,+BAA+B,EAAE,OAAO,KAAK,IAAI;QACjD,+BAA+B,EAAE,OAAO,KAAK,IAAI;QACjD,mCAAmC,EAAE,OAAO,KAAK,MAAM;AACxD,KAAA,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,MAAM,eAAe,GAAG,CAAC,EACvB,IAAI,EACJ,MAAM,EACN,GAAG,EACH,GAAG,SAAS,EACS,KAAI;AACzB,IAAA,QACE,KACE,CAAA,aAAA,CAAA,GAAA,EAAA,EAAA,SAAS,EAAE,UAAU,CAAC,SAAS,CAAC,EAChC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,IAAI,CAAC,GAAG,GAAG,qBAAqB,GAAG,GAAG,EAEhD,EAAA,SAAS,CAAC,QAAQ,CACjB,EACL;AACH,CAAC,CAAA;AACD,eAAe,CAAC,WAAW,GAAG,kBAAkB,CAAA;AAE1C,MAAO,WAAY,SAAQ,aAAsC,CAAA;IAErE,MAAM,GAAA;AACJ,QAAA,OAAO,6BAAK,SAAS,EAAE,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,EAAA,EAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAO,CAAA;KAC3E;;AAHM,WAAI,CAAA,IAAA,GAAG,eAAe,CAAA;AAM/B,IAAI,CAAC,OAAO,GAAG,WAAW;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/Card/index.tsx"],"sourcesContent":["import React, { PureComponent } from \"react\"\nimport cx from \"classnames\"\n\nexport type CardProps = {\n children?: React.ReactNode\n className?: string\n legacy?: boolean\n // Not used anymore, to remove in the next release\n flattened?: boolean\n responsive?: boolean\n}\n\nexport const Card = ({\n children,\n className,\n legacy,\n responsive,\n}: CardProps) => (\n <div\n className={cx(\"cobalt-Card\", className, {\n \"cobalt-Card--legacy\": legacy,\n \"cobalt-Card--responsive\": responsive,\n })}\n >\n {children}\n </div>\n)\n\nexport type CardSectionProps = {\n children: React.ReactNode\n className?: string\n tabBar?: boolean\n tight?: boolean\n subdued?: boolean\n /**\n * true or \"soft\"\n * @default false\n */\n divided?: boolean | string\n}\n\nexport type CardSectionLinkProps = CardSectionProps & {\n href: React.AnchorHTMLAttributes<HTMLAnchorElement>[\"href\"]\n target?: React.AnchorHTMLAttributes<HTMLAnchorElement>[\"target\"]\n rel?: React.AnchorHTMLAttributes<HTMLAnchorElement>[\"rel\"]\n}\n\nconst getClasses = ({\n className = \"\",\n tabBar,\n tight,\n subdued,\n divided,\n}: CardSectionProps) => {\n return cx(className, \"cobalt-Card__Section\", {\n \"cobalt-Card__Section--tabBar\": tabBar === true,\n \"cobalt-Card__Section--tight\": tight === true,\n \"cobalt-Card__Section--subdued\": subdued === true,\n \"cobalt-Card__Section--divided\": divided === true,\n \"cobalt-Card__Section--dividedSoft\": divided === \"soft\",\n })\n}\n\nconst CardSectionLink = ({\n href,\n target,\n rel,\n ...baseProps\n}: CardSectionLinkProps) => {\n return (\n <a\n className={getClasses(baseProps)}\n href={href}\n target={target}\n rel={target && !rel ? \"noopener noreferrer\" : rel}\n >\n {baseProps.children}\n </a>\n )\n}\nCardSectionLink.displayName = \"CardSection.Link\"\n\nexport class CardSection extends PureComponent<CardSectionProps, never> {\n static Link = CardSectionLink\n render() {\n return <div className={getClasses(this.props)}>{this.props.children}</div>\n }\n}\n\nCard.Section = CardSection\n\nexport default Card\n"],"names":[],"mappings":";;;AAYa,MAAA,IAAI,GAAG,CAAC,EACnB,QAAQ,EACR,SAAS,EACT,MAAM,EACN,UAAU,GACA,MACV,KACE,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,SAAS,EAAE,EAAE,CAAC,aAAa,EAAE,SAAS,EAAE;AACtC,QAAA,qBAAqB,EAAE,MAAM;AAC7B,QAAA,yBAAyB,EAAE,UAAU;AACtC,KAAA,CAAC,EAED,EAAA,QAAQ,CACL,EACP;AAqBD,MAAM,UAAU,GAAG,CAAC,EAClB,SAAS,GAAG,EAAE,EACd,MAAM,EACN,KAAK,EACL,OAAO,EACP,OAAO,GACU,KAAI;AACrB,IAAA,OAAO,EAAE,CAAC,SAAS,EAAE,sBAAsB,EAAE;QAC3C,8BAA8B,EAAE,MAAM,KAAK,IAAI;QAC/C,6BAA6B,EAAE,KAAK,KAAK,IAAI;QAC7C,+BAA+B,EAAE,OAAO,KAAK,IAAI;QACjD,+BAA+B,EAAE,OAAO,KAAK,IAAI;QACjD,mCAAmC,EAAE,OAAO,KAAK,MAAM;AACxD,KAAA,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,MAAM,eAAe,GAAG,CAAC,EACvB,IAAI,EACJ,MAAM,EACN,GAAG,EACH,GAAG,SAAS,EACS,KAAI;AACzB,IAAA,QACE,KACE,CAAA,aAAA,CAAA,GAAA,EAAA,EAAA,SAAS,EAAE,UAAU,CAAC,SAAS,CAAC,EAChC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,IAAI,CAAC,GAAG,GAAG,qBAAqB,GAAG,GAAG,EAEhD,EAAA,SAAS,CAAC,QAAQ,CACjB,EACL;AACH,CAAC,CAAA;AACD,eAAe,CAAC,WAAW,GAAG,kBAAkB,CAAA;AAE1C,MAAO,WAAY,SAAQ,aAAsC,CAAA;IAErE,MAAM,GAAA;AACJ,QAAA,OAAO,6BAAK,SAAS,EAAE,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,EAAA,EAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAO,CAAA;KAC3E;;AAHM,WAAI,CAAA,IAAA,GAAG,eAAe,CAAA;AAM/B,IAAI,CAAC,OAAO,GAAG,WAAW;;;;"}
@@ -8,9 +8,9 @@ const STATUS_ICONS_MAP = {
8
8
  error: "contextualWarningCircleFilled",
9
9
  };
10
10
  const STATUS_ICON_COLOR_MAP = {
11
- info: "turquoise",
12
- success: "green",
13
- error: "red",
11
+ info: "info",
12
+ success: "success",
13
+ error: "error",
14
14
  };
15
15
  const Flash = ({ children, status = "info" }) => {
16
16
  const icon = STATUS_ICONS_MAP[status]
@@ -18,7 +18,7 @@ const Flash = ({ children, status = "info" }) => {
18
18
  : "infoFilled";
19
19
  const iconColor = STATUS_ICON_COLOR_MAP[status]
20
20
  ? STATUS_ICON_COLOR_MAP[status]
21
- : "turquoise";
21
+ : "base";
22
22
  return (React.createElement("div", { className: `cobalt-Flash cobalt-Flash--${status}` },
23
23
  React.createElement("div", { className: "cobalt-Flash__wrapper" },
24
24
  React.createElement("span", { className: "cobalt-Flash__Icon" },
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/Flash/index.tsx"],"sourcesContent":["import React from \"react\"\nimport { Icon, IconColorsType, IconSources } from \"../Icon\"\n\nexport type FlashStatus = \"info\" | \"success\" | \"error\"\n\nexport interface FlashProps {\n children: React.ReactNode\n status: FlashStatus\n}\n\nconst ICON_SIZE = 20\n\nconst STATUS_ICONS_MAP: { [k in FlashStatus]: IconSources } = {\n info: \"infoFilled\",\n success: \"checkCircle\",\n error: \"contextualWarningCircleFilled\",\n}\n\nconst STATUS_ICON_COLOR_MAP: { [k in FlashStatus]: IconColorsType } = {\n info: \"turquoise\",\n success: \"green\",\n error: \"red\",\n}\n\nexport const Flash = ({ children, status = \"info\" }: FlashProps) => {\n const icon = STATUS_ICONS_MAP[status]\n ? STATUS_ICONS_MAP[status]\n : \"infoFilled\"\n\n const iconColor: IconColorsType = STATUS_ICON_COLOR_MAP[status]\n ? STATUS_ICON_COLOR_MAP[status]\n : \"turquoise\"\n\n return (\n <div className={`cobalt-Flash cobalt-Flash--${status}`}>\n <div className=\"cobalt-Flash__wrapper\">\n <span className=\"cobalt-Flash__Icon\">\n <Icon source={icon} size={ICON_SIZE} color={iconColor} />\n </span>\n <span className=\"cobalt-Flash__content\">{children}</span>\n </div>\n </div>\n )\n}\n"],"names":[],"mappings":";;;AAUA,MAAM,SAAS,GAAG,EAAE,CAAA;AAEpB,MAAM,gBAAgB,GAAwC;AAC5D,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,OAAO,EAAE,aAAa;AACtB,IAAA,KAAK,EAAE,+BAA+B;CACvC,CAAA;AAED,MAAM,qBAAqB,GAA2C;AACpE,IAAA,IAAI,EAAE,WAAW;AACjB,IAAA,OAAO,EAAE,OAAO;AAChB,IAAA,KAAK,EAAE,KAAK;CACb,CAAA;AAEM,MAAM,KAAK,GAAG,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAc,KAAI;AACjE,IAAA,MAAM,IAAI,GAAG,gBAAgB,CAAC,MAAM,CAAC;AACnC,UAAE,gBAAgB,CAAC,MAAM,CAAC;UACxB,YAAY,CAAA;AAEhB,IAAA,MAAM,SAAS,GAAmB,qBAAqB,CAAC,MAAM,CAAC;AAC7D,UAAE,qBAAqB,CAAC,MAAM,CAAC;UAC7B,WAAW,CAAA;AAEf,IAAA,QACE,KAAK,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,SAAS,EAAE,CAAA,2BAAA,EAA8B,MAAM,CAAE,CAAA,EAAA;QACpD,KAAK,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,SAAS,EAAC,uBAAuB,EAAA;YACpC,KAAM,CAAA,aAAA,CAAA,MAAA,EAAA,EAAA,SAAS,EAAC,oBAAoB,EAAA;AAClC,gBAAA,KAAA,CAAA,aAAA,CAAC,IAAI,EAAA,EAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,GAAI,CACpD;YACP,KAAM,CAAA,aAAA,CAAA,MAAA,EAAA,EAAA,SAAS,EAAC,uBAAuB,EAAA,EAAE,QAAQ,CAAQ,CACrD,CACF,EACP;AACH;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/Flash/index.tsx"],"sourcesContent":["import React from \"react\"\nimport { Icon, IconColorsType, IconSources } from \"../Icon\"\n\nexport type FlashStatus = \"info\" | \"success\" | \"error\"\n\nexport interface FlashProps {\n children: React.ReactNode\n status: FlashStatus\n}\n\nconst ICON_SIZE = 20\n\nconst STATUS_ICONS_MAP: { [k in FlashStatus]: IconSources } = {\n info: \"infoFilled\",\n success: \"checkCircle\",\n error: \"contextualWarningCircleFilled\",\n}\n\nconst STATUS_ICON_COLOR_MAP: { [k in FlashStatus]: IconColorsType } = {\n info: \"info\",\n success: \"success\",\n error: \"error\",\n}\n\nexport const Flash = ({ children, status = \"info\" }: FlashProps) => {\n const icon = STATUS_ICONS_MAP[status]\n ? STATUS_ICONS_MAP[status]\n : \"infoFilled\"\n\n const iconColor: IconColorsType = STATUS_ICON_COLOR_MAP[status]\n ? STATUS_ICON_COLOR_MAP[status]\n : \"base\"\n\n return (\n <div className={`cobalt-Flash cobalt-Flash--${status}`}>\n <div className=\"cobalt-Flash__wrapper\">\n <span className=\"cobalt-Flash__Icon\">\n <Icon source={icon} size={ICON_SIZE} color={iconColor} />\n </span>\n <span className=\"cobalt-Flash__content\">{children}</span>\n </div>\n </div>\n )\n}\n"],"names":[],"mappings":";;;AAUA,MAAM,SAAS,GAAG,EAAE,CAAA;AAEpB,MAAM,gBAAgB,GAAwC;AAC5D,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,OAAO,EAAE,aAAa;AACtB,IAAA,KAAK,EAAE,+BAA+B;CACvC,CAAA;AAED,MAAM,qBAAqB,GAA2C;AACpE,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,OAAO,EAAE,SAAS;AAClB,IAAA,KAAK,EAAE,OAAO;CACf,CAAA;AAEM,MAAM,KAAK,GAAG,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAc,KAAI;AACjE,IAAA,MAAM,IAAI,GAAG,gBAAgB,CAAC,MAAM,CAAC;AACnC,UAAE,gBAAgB,CAAC,MAAM,CAAC;UACxB,YAAY,CAAA;AAEhB,IAAA,MAAM,SAAS,GAAmB,qBAAqB,CAAC,MAAM,CAAC;AAC7D,UAAE,qBAAqB,CAAC,MAAM,CAAC;UAC7B,MAAM,CAAA;AAEV,IAAA,QACE,KAAK,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,SAAS,EAAE,CAAA,2BAAA,EAA8B,MAAM,CAAE,CAAA,EAAA;QACpD,KAAK,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,SAAS,EAAC,uBAAuB,EAAA;YACpC,KAAM,CAAA,aAAA,CAAA,MAAA,EAAA,EAAA,SAAS,EAAC,oBAAoB,EAAA;AAClC,gBAAA,KAAA,CAAA,aAAA,CAAC,IAAI,EAAA,EAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,GAAI,CACpD;YACP,KAAM,CAAA,aAAA,CAAA,MAAA,EAAA,EAAA,SAAS,EAAC,uBAAuB,EAAA,EAAE,QAAQ,CAAQ,CACrD,CACF,EACP;AACH;;;;"}
@@ -151,7 +151,7 @@ function Autocomplete({ id, icon, status, items, selectedItem, autoFilter = true
151
151
  handleSelectItem(item, e);
152
152
  } }, renderItem ? (renderItem(item, term)) : (React.createElement("span", { className: "cobalt-Autocomplete__item-wrapper" },
153
153
  icon && (React.createElement("span", { className: "cobalt-Autocomplete__item-icon" },
154
- React.createElement(Icon, { source: icon, color: "indigo" }))),
154
+ React.createElement(Icon, { source: icon, color: "accent" }))),
155
155
  React.createElement("span", { className: "cobalt-Autocomplete__item-value" },
156
156
  React.createElement(ComboboxOptionText, null)))))))))),
157
157
  React.createElement("div", { className: "cobalt-Autocomplete__input-wrapper" },
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/components/Form/Autocomplete/index.tsx"],"sourcesContent":["import React, { useEffect, useRef, ElementType } from \"react\"\nimport { useState } from \"react\"\nimport classNames from \"classnames\"\n\nimport {\n Combobox,\n ComboboxInput,\n ComboboxPopover,\n ComboboxList,\n ComboboxOption,\n ComboboxOptionText,\n} from \"@reach/combobox\"\n\nimport { Icon, IconSources } from \"../../Icon\"\n\nimport { withFieldLabelAndHint } from \"../field\"\nimport { TextInputWrapper } from \"../TextInput\"\nimport { FormElement } from \"../form\"\n\nexport interface AutocompleteItem {\n [x: string]: any\n}\n\ntype ComboboxPopoverType = ElementType<\"div\"> & HTMLDivElement\ntype ComboboxOptionType = HTMLLIElement & React.ElementType<\"li\">\ntype ComboboxOptionMouseEventType = React.MouseEvent<\n ComboboxOptionType,\n MouseEvent\n>\n\ntype Props = {\n icon?: IconSources\n items: (AutocompleteItem | string)[]\n minQueryLength?: number\n autoFilter?: boolean\n selectedItem?: AutocompleteItem\n focusOnInit?: boolean\n autocomplete?: boolean\n valueKey?: string\n inputRef?: React.RefObject<HTMLInputElement>\n autocompleteRef?: React.RefObject<HTMLDivElement>\n onKeyDown?: (event: React.KeyboardEvent<HTMLElement>) => void\n onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void\n onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void\n onQueryChange?: (term: string) => void\n onSelectItem?: (item: AutocompleteItem, term: string) => boolean\n renderItem?: (item: AutocompleteItem, term: string) => React.ReactNode\n} & FormElement &\n React.InputHTMLAttributes<HTMLInputElement>\n\nfunction filterMatchingItems(\n items: AutocompleteItem[],\n term: string,\n minLength: number,\n valueKey: string\n) {\n const [matchingItems, setMatchingItems] = useState<AutocompleteItem[]>([])\n\n useEffect(() => {\n term.length >= minLength\n ? setMatchingItems(\n items.filter((item: AutocompleteItem) => {\n return item[valueKey].toLowerCase().indexOf(term.toLowerCase()) > -1\n })\n )\n : setMatchingItems([])\n }, [items, term, valueKey])\n\n return matchingItems\n}\n\nfunction sanitizeItems(items: (AutocompleteItem | string)[], valueKey: string) {\n const [sanitizedItems, setSanitizedItems] = useState<AutocompleteItem[]>([])\n useEffect(() => {\n setSanitizedItems(\n items.map((item) =>\n typeof item === \"string\" ? { [valueKey]: item } : item\n )\n )\n }, [items])\n return sanitizedItems\n}\n\nfunction Autocomplete({\n id,\n icon,\n status,\n items,\n selectedItem,\n autoFilter = true,\n minQueryLength = 1,\n focusOnInit = false,\n onKeyDown,\n onFocus,\n onBlur,\n onQueryChange,\n onSelectItem,\n renderItem,\n inputRef,\n autocompleteRef,\n valueKey = \"value\",\n ...inputProps\n}: Props) {\n const [term, setTerm] = useState(\"\")\n\n const [hasFocus, setHasFocus] = useState(false)\n\n let ignoreFocus = false // extra flag to ignore programmatical focus triggered by click on item\n\n const results = autoFilter\n ? filterMatchingItems(\n sanitizeItems(items, valueKey),\n term,\n minQueryLength,\n valueKey\n )\n : sanitizeItems(items, valueKey)\n\n const comboboxEl = autocompleteRef || useRef<HTMLDivElement>(null)\n\n const inputEl = inputRef || useRef<HTMLInputElement>(null)\n\n const popoverEl = useRef<ComboboxPopoverType>(null)\n\n const giveInputFocus = () => {\n inputEl.current && inputEl.current.focus()\n }\n\n const isMounted = useRef(true)\n const forceIdTimer = useRef<any>()\n const focusTimer = useRef<any>()\n const blurTimer = useRef<any>()\n const clearInputTimer = useRef<any>()\n\n function forceId() {\n // id is overriden by Reach ui Combobox\n forceIdTimer.current = setTimeout(() => {\n id && inputEl.current && inputEl.current.setAttribute(\"id\", id)\n })\n }\n\n useEffect(() => {\n // on mount ...\n focusOnInit && giveInputFocus()\n\n return () => {\n isMounted.current = false\n forceIdTimer.current && clearTimeout(forceIdTimer.current)\n focusTimer.current && clearTimeout(focusTimer.current)\n blurTimer.current && clearTimeout(blurTimer.current)\n clearInputTimer.current && clearTimeout(clearInputTimer.current)\n }\n }, [])\n\n useEffect(() => {\n forceId()\n }, [id])\n\n useEffect(() => {\n setTerm(selectedItem ? \"\" + selectedItem[valueKey] : \"\")\n }, [selectedItem])\n\n const handleFocus = (event: React.FocusEvent<HTMLInputElement>) => {\n !ignoreFocus && onFocus && onFocus(event)\n ignoreFocus = false\n focusTimer.current = setTimeout(() => {\n // required by \"forceDisplayResults\" mechanism\n isMounted.current && setHasFocus(true)\n }, 100)\n }\n\n const handleBlur = (event: React.FocusEvent<HTMLInputElement>) => {\n // blur interceptor required by \"forceDisplayResults\" mechanism\n onBlur && onBlur(event)\n blurTimer.current = setTimeout(() => {\n isMounted.current && setHasFocus(false)\n }, 100)\n }\n\n const handleChange = (event: React.FocusEvent<HTMLInputElement>) => {\n const inputValue = (event.target as HTMLInputElement).value\n if (inputValue.trim().length || term.length) {\n // to prevent starting with a space character\n setTerm(inputValue)\n onQueryChange && onQueryChange(inputValue)\n }\n }\n\n const handleClearInput = () => {\n setTerm(\"\")\n onQueryChange && onQueryChange(\"\")\n\n clearInputTimer.current = setTimeout(giveInputFocus) //timeout to trigger openOnFocus\n }\n\n const handleSelectItem = (\n item: AutocompleteItem,\n e: ComboboxOptionMouseEventType | React.KeyboardEvent<HTMLElement>\n ) => {\n // item click interceptor to enable custom select cancellation\n const processSelection = onSelectItem\n ? onSelectItem(item, term) !== false\n : true\n\n if (processSelection) {\n setTerm(item[valueKey])\n } else if (e) {\n e.preventDefault()\n ignoreFocus = true\n giveInputFocus()\n }\n }\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLElement>) => {\n onKeyDown && onKeyDown(e)\n\n // ENTER key down interceptor to enable custom select cancellation\n const KEY_CODE_ENTER = 13\n\n // BACKSPACE key down interceptor to synchonize react input value and dom input value in some edge case (Comnbobox autocomplete = true)\n const KEY_CODE_BACKSPACE = 8\n\n if (e.keyCode === KEY_CODE_ENTER) {\n if (!popoverEl.current) return\n\n const options = Array.from(\n popoverEl.current.querySelectorAll(\"[data-reach-combobox-option]\")\n )\n\n const selectedItemIndex = options.findIndex(\n (el) => el.getAttribute(\"aria-selected\") === \"true\"\n )\n\n selectedItemIndex >= 0 && handleSelectItem(results[selectedItemIndex], e)\n } else if (e.keyCode === KEY_CODE_BACKSPACE) {\n if (!inputEl.current) return\n if (inputEl.current.value.slice(0, -1) === term) {\n setTerm(inputEl.current.value)\n }\n }\n }\n\n const shouldDisplayItemsOnEmptyQuery = () => {\n return !autoFilter && results.length > 0 && term.length === 0 && hasFocus\n }\n\n const handleMouseDown = (\n item: AutocompleteItem,\n e: ComboboxOptionMouseEventType\n ) => {\n // In a specific case, we force the popover to display (results available, empty input using backspace)\n // But doing so, reach ui component is not ready for this case and will raise an error\n // We need to prevent the error and to force the selection\n if (\n shouldDisplayItemsOnEmptyQuery() &&\n popoverEl.current &&\n popoverEl.current.getAttribute(\"hidden\") != null\n ) {\n e.preventDefault() // it will prevent reach ui combobox to raise an error\n handleSelectItem(item, e) // we force the selection to be processed\n }\n }\n\n return (\n <Combobox\n className={classNames(\"cobalt-Autocomplete\", {\n \"cobalt-Autocomplete--forceDisplayResults\":\n shouldDisplayItemsOnEmptyQuery(), // Combobox Component, by design, hide the popover when the input is empty (on change) even if there are some results.\n })}\n as=\"div\"\n openOnFocus={true}\n ref={comboboxEl}\n >\n {results.length > 0 && (\n <ComboboxPopover\n className=\"cobalt-Autocomplete__popover\"\n portal={false}\n ref={popoverEl}\n >\n <ComboboxList\n className=\"cobalt-Autocomplete__list\"\n aria-label=\"Autocomplete option\"\n >\n {results.map((item, index) => (\n <ComboboxOption\n className=\"cobalt-Autocomplete__item\"\n key={index}\n value={item[valueKey]}\n onMouseDown={(e: ComboboxOptionMouseEventType) => {\n handleMouseDown(item, e)\n }}\n onClick={(e: ComboboxOptionMouseEventType) => {\n handleSelectItem(item, e)\n }}\n >\n {renderItem ? (\n renderItem(item, term)\n ) : (\n <span className=\"cobalt-Autocomplete__item-wrapper\">\n {icon && (\n <span className=\"cobalt-Autocomplete__item-icon\">\n <Icon source={icon} color=\"indigo\" />\n </span>\n )}\n\n <span className=\"cobalt-Autocomplete__item-value\">\n <ComboboxOptionText />\n </span>\n </span>\n )}\n </ComboboxOption>\n ))}\n </ComboboxList>\n </ComboboxPopover>\n )}\n <div className=\"cobalt-Autocomplete__input-wrapper\">\n <TextInputWrapper\n icon={icon}\n status={status}\n render={(className) => {\n return (\n <ComboboxInput\n {...inputProps}\n autoComplete=\"off\"\n autoCorrect=\"off\"\n autoCapitalize=\"off\"\n spellCheck={false}\n aria-label=\"autocomplete input\"\n type=\"text\"\n value={term}\n onChange={handleChange}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n ref={inputEl}\n className={className}\n />\n )\n }}\n />\n\n {term && (\n <div\n className=\"cobalt-Autocomplete__clear-button\"\n role=\"clear\"\n onClick={handleClearInput}\n >\n <Icon source=\"close\" size={16} />\n </div>\n )}\n </div>\n </Combobox>\n )\n}\n\nconst wrappedComponent = withFieldLabelAndHint(Autocomplete)\nwrappedComponent.displayName = \"Autocomplete\"\n\nexport { wrappedComponent as Autocomplete }\n"],"names":["classNames"],"mappings":";;;;;;;AAkDA,SAAS,mBAAmB,CAC1B,KAAyB,EACzB,IAAY,EACZ,SAAiB,EACjB,QAAgB,EAAA;IAEhB,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAqB,EAAE,CAAC,CAAA;IAE1E,SAAS,CAAC,MAAK;QACb,IAAI,CAAC,MAAM,IAAI,SAAS;cACpB,gBAAgB,CACd,KAAK,CAAC,MAAM,CAAC,CAAC,IAAsB,KAAI;AACtC,gBAAA,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,CAAC,CAAA;AACtE,aAAC,CAAC,CACH;AACH,cAAE,gBAAgB,CAAC,EAAE,CAAC,CAAA;KACzB,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAA;AAE3B,IAAA,OAAO,aAAa,CAAA;AACtB,CAAC;AAED,SAAS,aAAa,CAAC,KAAoC,EAAE,QAAgB,EAAA;IAC3E,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAqB,EAAE,CAAC,CAAA;IAC5E,SAAS,CAAC,MAAK;AACb,QAAA,iBAAiB,CACf,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,KACb,OAAO,IAAI,KAAK,QAAQ,GAAG,EAAE,CAAC,QAAQ,GAAG,IAAI,EAAE,GAAG,IAAI,CACvD,CACF,CAAA;AACH,KAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAA;AAC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AAC,OAAO,EACZ,OAAO,EAAE,gBAAgB,EAAA;AAEzB,gBAAA,KAAA,CAAA,aAAA,CAAC,IAAI,EAAA,EAAC,MAAM,EAAC,OAAO,EAAC,IAAI,EAAE,EAAE,GAAI,CAC7B,CACP,CACG,CACG,EACZ;AACH,CAAC;AAED,MAAM,gBAAgB,GAAG,qBAAqB,CAAC,YAAY,EAAC;AAC5D,gBAAgB,CAAC,WAAW,GAAG,cAAc;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/components/Form/Autocomplete/index.tsx"],"sourcesContent":["import React, { useEffect, useRef, ElementType } from \"react\"\nimport { useState } from \"react\"\nimport classNames from \"classnames\"\n\nimport {\n Combobox,\n ComboboxInput,\n ComboboxPopover,\n ComboboxList,\n ComboboxOption,\n ComboboxOptionText,\n} from \"@reach/combobox\"\n\nimport { Icon, IconSources } from \"../../Icon\"\n\nimport { withFieldLabelAndHint } from \"../field\"\nimport { TextInputWrapper } from \"../TextInput\"\nimport { FormElement } from \"../form\"\n\nexport interface AutocompleteItem {\n [x: string]: any\n}\n\ntype ComboboxPopoverType = ElementType<\"div\"> & HTMLDivElement\ntype ComboboxOptionType = HTMLLIElement & React.ElementType<\"li\">\ntype ComboboxOptionMouseEventType = React.MouseEvent<\n ComboboxOptionType,\n MouseEvent\n>\n\ntype Props = {\n icon?: IconSources\n items: (AutocompleteItem | string)[]\n minQueryLength?: number\n autoFilter?: boolean\n selectedItem?: AutocompleteItem\n focusOnInit?: boolean\n autocomplete?: boolean\n valueKey?: string\n inputRef?: React.RefObject<HTMLInputElement>\n autocompleteRef?: React.RefObject<HTMLDivElement>\n onKeyDown?: (event: React.KeyboardEvent<HTMLElement>) => void\n onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void\n onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void\n onQueryChange?: (term: string) => void\n onSelectItem?: (item: AutocompleteItem, term: string) => boolean\n renderItem?: (item: AutocompleteItem, term: string) => React.ReactNode\n} & FormElement &\n React.InputHTMLAttributes<HTMLInputElement>\n\nfunction filterMatchingItems(\n items: AutocompleteItem[],\n term: string,\n minLength: number,\n valueKey: string\n) {\n const [matchingItems, setMatchingItems] = useState<AutocompleteItem[]>([])\n\n useEffect(() => {\n term.length >= minLength\n ? setMatchingItems(\n items.filter((item: AutocompleteItem) => {\n return item[valueKey].toLowerCase().indexOf(term.toLowerCase()) > -1\n })\n )\n : setMatchingItems([])\n }, [items, term, valueKey])\n\n return matchingItems\n}\n\nfunction sanitizeItems(items: (AutocompleteItem | string)[], valueKey: string) {\n const [sanitizedItems, setSanitizedItems] = useState<AutocompleteItem[]>([])\n useEffect(() => {\n setSanitizedItems(\n items.map((item) =>\n typeof item === \"string\" ? { [valueKey]: item } : item\n )\n )\n }, [items])\n return sanitizedItems\n}\n\nfunction Autocomplete({\n id,\n icon,\n status,\n items,\n selectedItem,\n autoFilter = true,\n minQueryLength = 1,\n focusOnInit = false,\n onKeyDown,\n onFocus,\n onBlur,\n onQueryChange,\n onSelectItem,\n renderItem,\n inputRef,\n autocompleteRef,\n valueKey = \"value\",\n ...inputProps\n}: Props) {\n const [term, setTerm] = useState(\"\")\n\n const [hasFocus, setHasFocus] = useState(false)\n\n let ignoreFocus = false // extra flag to ignore programmatical focus triggered by click on item\n\n const results = autoFilter\n ? filterMatchingItems(\n sanitizeItems(items, valueKey),\n term,\n minQueryLength,\n valueKey\n )\n : sanitizeItems(items, valueKey)\n\n const comboboxEl = autocompleteRef || useRef<HTMLDivElement>(null)\n\n const inputEl = inputRef || useRef<HTMLInputElement>(null)\n\n const popoverEl = useRef<ComboboxPopoverType>(null)\n\n const giveInputFocus = () => {\n inputEl.current && inputEl.current.focus()\n }\n\n const isMounted = useRef(true)\n const forceIdTimer = useRef<any>()\n const focusTimer = useRef<any>()\n const blurTimer = useRef<any>()\n const clearInputTimer = useRef<any>()\n\n function forceId() {\n // id is overriden by Reach ui Combobox\n forceIdTimer.current = setTimeout(() => {\n id && inputEl.current && inputEl.current.setAttribute(\"id\", id)\n })\n }\n\n useEffect(() => {\n // on mount ...\n focusOnInit && giveInputFocus()\n\n return () => {\n isMounted.current = false\n forceIdTimer.current && clearTimeout(forceIdTimer.current)\n focusTimer.current && clearTimeout(focusTimer.current)\n blurTimer.current && clearTimeout(blurTimer.current)\n clearInputTimer.current && clearTimeout(clearInputTimer.current)\n }\n }, [])\n\n useEffect(() => {\n forceId()\n }, [id])\n\n useEffect(() => {\n setTerm(selectedItem ? \"\" + selectedItem[valueKey] : \"\")\n }, [selectedItem])\n\n const handleFocus = (event: React.FocusEvent<HTMLInputElement>) => {\n !ignoreFocus && onFocus && onFocus(event)\n ignoreFocus = false\n focusTimer.current = setTimeout(() => {\n // required by \"forceDisplayResults\" mechanism\n isMounted.current && setHasFocus(true)\n }, 100)\n }\n\n const handleBlur = (event: React.FocusEvent<HTMLInputElement>) => {\n // blur interceptor required by \"forceDisplayResults\" mechanism\n onBlur && onBlur(event)\n blurTimer.current = setTimeout(() => {\n isMounted.current && setHasFocus(false)\n }, 100)\n }\n\n const handleChange = (event: React.FocusEvent<HTMLInputElement>) => {\n const inputValue = (event.target as HTMLInputElement).value\n if (inputValue.trim().length || term.length) {\n // to prevent starting with a space character\n setTerm(inputValue)\n onQueryChange && onQueryChange(inputValue)\n }\n }\n\n const handleClearInput = () => {\n setTerm(\"\")\n onQueryChange && onQueryChange(\"\")\n\n clearInputTimer.current = setTimeout(giveInputFocus) //timeout to trigger openOnFocus\n }\n\n const handleSelectItem = (\n item: AutocompleteItem,\n e: ComboboxOptionMouseEventType | React.KeyboardEvent<HTMLElement>\n ) => {\n // item click interceptor to enable custom select cancellation\n const processSelection = onSelectItem\n ? onSelectItem(item, term) !== false\n : true\n\n if (processSelection) {\n setTerm(item[valueKey])\n } else if (e) {\n e.preventDefault()\n ignoreFocus = true\n giveInputFocus()\n }\n }\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLElement>) => {\n onKeyDown && onKeyDown(e)\n\n // ENTER key down interceptor to enable custom select cancellation\n const KEY_CODE_ENTER = 13\n\n // BACKSPACE key down interceptor to synchonize react input value and dom input value in some edge case (Comnbobox autocomplete = true)\n const KEY_CODE_BACKSPACE = 8\n\n if (e.keyCode === KEY_CODE_ENTER) {\n if (!popoverEl.current) return\n\n const options = Array.from(\n popoverEl.current.querySelectorAll(\"[data-reach-combobox-option]\")\n )\n\n const selectedItemIndex = options.findIndex(\n (el) => el.getAttribute(\"aria-selected\") === \"true\"\n )\n\n selectedItemIndex >= 0 && handleSelectItem(results[selectedItemIndex], e)\n } else if (e.keyCode === KEY_CODE_BACKSPACE) {\n if (!inputEl.current) return\n if (inputEl.current.value.slice(0, -1) === term) {\n setTerm(inputEl.current.value)\n }\n }\n }\n\n const shouldDisplayItemsOnEmptyQuery = () => {\n return !autoFilter && results.length > 0 && term.length === 0 && hasFocus\n }\n\n const handleMouseDown = (\n item: AutocompleteItem,\n e: ComboboxOptionMouseEventType\n ) => {\n // In a specific case, we force the popover to display (results available, empty input using backspace)\n // But doing so, reach ui component is not ready for this case and will raise an error\n // We need to prevent the error and to force the selection\n if (\n shouldDisplayItemsOnEmptyQuery() &&\n popoverEl.current &&\n popoverEl.current.getAttribute(\"hidden\") != null\n ) {\n e.preventDefault() // it will prevent reach ui combobox to raise an error\n handleSelectItem(item, e) // we force the selection to be processed\n }\n }\n\n return (\n <Combobox\n className={classNames(\"cobalt-Autocomplete\", {\n \"cobalt-Autocomplete--forceDisplayResults\":\n shouldDisplayItemsOnEmptyQuery(), // Combobox Component, by design, hide the popover when the input is empty (on change) even if there are some results.\n })}\n as=\"div\"\n openOnFocus={true}\n ref={comboboxEl}\n >\n {results.length > 0 && (\n <ComboboxPopover\n className=\"cobalt-Autocomplete__popover\"\n portal={false}\n ref={popoverEl}\n >\n <ComboboxList\n className=\"cobalt-Autocomplete__list\"\n aria-label=\"Autocomplete option\"\n >\n {results.map((item, index) => (\n <ComboboxOption\n className=\"cobalt-Autocomplete__item\"\n key={index}\n value={item[valueKey]}\n onMouseDown={(e: ComboboxOptionMouseEventType) => {\n handleMouseDown(item, e)\n }}\n onClick={(e: ComboboxOptionMouseEventType) => {\n handleSelectItem(item, e)\n }}\n >\n {renderItem ? (\n renderItem(item, term)\n ) : (\n <span className=\"cobalt-Autocomplete__item-wrapper\">\n {icon && (\n <span className=\"cobalt-Autocomplete__item-icon\">\n <Icon source={icon} color=\"accent\" />\n </span>\n )}\n\n <span className=\"cobalt-Autocomplete__item-value\">\n <ComboboxOptionText />\n </span>\n </span>\n )}\n </ComboboxOption>\n ))}\n </ComboboxList>\n </ComboboxPopover>\n )}\n <div className=\"cobalt-Autocomplete__input-wrapper\">\n <TextInputWrapper\n icon={icon}\n status={status}\n render={(className) => {\n return (\n <ComboboxInput\n {...inputProps}\n autoComplete=\"off\"\n autoCorrect=\"off\"\n autoCapitalize=\"off\"\n spellCheck={false}\n aria-label=\"autocomplete input\"\n type=\"text\"\n value={term}\n onChange={handleChange}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n ref={inputEl}\n className={className}\n />\n )\n }}\n />\n\n {term && (\n <div\n className=\"cobalt-Autocomplete__clear-button\"\n role=\"clear\"\n onClick={handleClearInput}\n >\n <Icon source=\"close\" size={16} />\n </div>\n )}\n </div>\n </Combobox>\n )\n}\n\nconst wrappedComponent = withFieldLabelAndHint(Autocomplete)\nwrappedComponent.displayName = \"Autocomplete\"\n\nexport { wrappedComponent as Autocomplete }\n"],"names":["classNames"],"mappings":";;;;;;;AAkDA,SAAS,mBAAmB,CAC1B,KAAyB,EACzB,IAAY,EACZ,SAAiB,EACjB,QAAgB,EAAA;IAEhB,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAqB,EAAE,CAAC,CAAA;IAE1E,SAAS,CAAC,MAAK;QACb,IAAI,CAAC,MAAM,IAAI,SAAS;cACpB,gBAAgB,CACd,KAAK,CAAC,MAAM,CAAC,CAAC,IAAsB,KAAI;AACtC,gBAAA,OAAO,IAAI,CAAC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EAAA;AACjD,YAAA,KAAA,CAAA,aAAA,CAAC,gBAAgB,EAAA,EACf,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,CAAC,SAAS,KAAI;oBACpB,QACE,KAAC,CAAA,aAAA,CAAA,aAAa,EACR,EAAA,GAAA,UAAU,EACd,YAAY,EAAC,KAAK,EAClB,WAAW,EAAC,KAAK,EACjB,cAAc,EAAC,KAAK,EACpB,UAAU,EAAE,KAAK,EAAA,YAAA,EACN,oBAAoB,EAC/B,IAAI,EAAC,MAAM,EACX,KAAK,EAAE,IAAI,EACX,QAAQ,EAAE,YAAY,EACtB,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,aAAa,EACxB,GAAG,EAAE,OAAO,EACZ,SAAS,EAAE,SAAS,EACpB,CAAA,EACH;AACH,iBAAC,EACD,CAAA;AAED,YAAA,IAAI,KACH,KACE,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,SAAS,EAAC,mCAAmC,EAC7C,IAAI,EAAC,OAAO,EACZ,OAAO,EAAE,gBAAgB,EAAA;AAEzB,gBAAA,KAAA,CAAA,aAAA,CAAC,IAAI,EAAA,EAAC,MAAM,EAAC,OAAO,EAAC,IAAI,EAAE,EAAE,GAAI,CAC7B,CACP,CACG,CACG,EACZ;AACH,CAAC;AAED,MAAM,gBAAgB,GAAG,qBAAqB,CAAC,YAAY,EAAC;AAC5D,gBAAgB,CAAC,WAAW,GAAG,cAAc;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"Slider.js","sources":["../../../src/components/Form/Slider.tsx"],"sourcesContent":["import React, { useState } from \"react\"\nimport { FormElement } from \"./form\"\nimport { withFieldLabelAndHint } from \"./field\"\nimport {\n Slider as ReachSlider,\n SliderProps as ReachSliderProps,\n} from \"@reach/slider\"\nimport classNames from \"classnames\"\n\ntype NativeEventType =\n | \"onPointerDown\"\n | \"onPointerUp\"\n | \"onMouseDown\"\n | \"onMouseMove\"\n | \"onMouseUp\"\n | \"onTouchStart\"\n | \"onTouchMove\"\n | \"onTouchEnd\"\n\nexport type SliderPropsType = {\n /**\n * mandatory for A11y\n */\n ariaLabel: string\n value?: number\n defaultValue?: number\n /**\n * minimum selectable value (default is 0)\n */\n min?: number\n /**\n * maximum selectable value (default is 100)\n */\n max?: number\n /**\n * values interval\n */\n step?: number\n disabled?: boolean\n /**\n * Listener called when the value is changed\n */\n onChange?: (newValue: number) => void\n /**\n * Function used to visually display the slider value\n */\n renderValue?: (\n value: number,\n status: FormElement[\"status\"]\n ) => React.ReactElement\n\n onPointerDown?: ReachSliderProps[\"onPointerDown\"]\n onPointerUp?: ReachSliderProps[\"onPointerUp\"]\n onMouseDown?: ReachSliderProps[\"onMouseDown\"]\n onMouseMove?: ReachSliderProps[\"onMouseMove\"]\n onMouseUp?: ReachSliderProps[\"onMouseUp\"]\n onTouchStart?: ReachSliderProps[\"onTouchStart\"]\n onTouchMove?: ReachSliderProps[\"onTouchMove\"]\n onTouchEnd?: ReachSliderProps[\"onTouchEnd\"]\n onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void\n} & FormElement &\n Omit<\n React.InputHTMLAttributes<HTMLInputElement>,\n NativeEventType | \"css\" | \"enterKeyHint\"\n >\n\nconst Slider = ({\n defaultValue,\n value,\n min,\n max,\n status,\n disabled,\n onChange,\n renderValue,\n ariaLabel,\n ...restProps\n}: SliderPropsType) => {\n function initValue() {\n if (value != null) return value\n if (defaultValue != null) return defaultValue\n if (min != null) return min\n return 0\n }\n\n const [sliderValue, setSliderValue] = useState(() => initValue())\n\n return (\n <div\n className={classNames(\"cobalt-slider\", {\n \"cobalt-slider--disabled\": disabled,\n })}\n >\n {renderValue && (\n <div className=\"cobalt-slider__value-container\">\n {renderValue(sliderValue, status)}\n </div>\n )}\n\n <ReachSlider\n {...restProps}\n aria-label={ariaLabel}\n handleAlignment=\"contain\"\n defaultValue={defaultValue}\n value={value}\n min={min}\n max={max}\n disabled={disabled}\n onChange={(newValue) => {\n setSliderValue(newValue)\n onChange && onChange(newValue)\n }}\n />\n </div>\n )\n}\n\nconst wrappedComponent = withFieldLabelAndHint(Slider)\nwrappedComponent.displayName = \"Slider\"\n\nexport default wrappedComponent\n\ntype SliderValueMetaProps = {\n children: React.ReactNode\n}\nexport const SliderValueMeta = ({ children }: SliderValueMetaProps) => {\n return <span className=\"cobalt-slider__value-meta\">{children}</span>\n}\n"],"names":["classNames","ReachSlider"],"mappings":";;;;;AAkEA,MAAM,MAAM,GAAG,CAAC,EACd,YAAY,EACZ,KAAK,EACL,GAAG,EACH,GAAG,EACH,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,SAAS,EACT,GAAG,SAAS,EACI,KAAI;AACpB,IAAA,SAAS,SAAS,GAAA;QAChB,IAAI,KAAK,IAAI,IAAI;AAAE,YAAA,OAAO,KAAK,CAAA;QAC/B,IAAI,YAAY,IAAI,IAAI;AAAE,YAAA,OAAO,YAAY,CAAA;QAC7C,IAAI,GAAG,IAAI,IAAI;AAAE,YAAA,OAAO,GAAG,CAAA;AAC3B,QAAA,OAAO,CAAC,CAAA;KACT;AAED,IAAA,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,MAAM,SAAS,EAAE,CAAC,CAAA;AAEjE,IAAA,QACE,KACE,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,SAAS,EAAEA,EAAU,CAAC,eAAe,EAAE;AACrC,YAAA,yBAAyB,EAAE,QAAQ;SACpC,CAAC,EAAA;AAED,QAAA,WAAW,KACV,KAAK,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,SAAS,EAAC,gCAAgC,EAAA,EAC5C,WAAW,CAAC,WAAW,EAAE,MAAM,CAAC,CAC7B,CACP;AAED,QAAA,KAAA,CAAA,aAAA,CAACC,QAAW,EAAA,EAAA,GACN,SAAS,EAAA,YAAA,EACD,SAAS,EACrB,eAAe,EAAC,SAAS,EACzB,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,CAAC,QAAQ,KAAI;gBACrB,cAAc,CAAC,QAAQ,CAAC,CAAA;AACxB,gBAAA,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC,CAAA;aAC/B,EAAA,CACD,CACE,EACP;AACH,CAAC,CAAA;AAED,MAAM,gBAAgB,GAAG,qBAAqB,CAAC,MAAM,EAAC;AACtD,gBAAgB,CAAC,WAAW,GAAG,QAAQ,CAAA;MAO1B,eAAe,GAAG,CAAC,EAAE,QAAQ,EAAwB,KAAI;AACpE,IAAA,OAAO,8BAAM,SAAS,EAAC,2BAA2B,EAAE,EAAA,QAAQ,CAAQ,CAAA;AACtE;;;;"}
1
+ {"version":3,"file":"Slider.js","sources":["../../../src/components/Form/Slider.tsx"],"sourcesContent":["import React, { useState } from \"react\"\nimport { FormElement } from \"./form\"\nimport { withFieldLabelAndHint } from \"./field\"\nimport {\n Slider as ReachSlider,\n SliderProps as ReachSliderProps,\n} from \"@reach/slider\"\nimport classNames from \"classnames\"\n\ntype NativeEventType =\n | \"onPointerDown\"\n | \"onPointerUp\"\n | \"onMouseDown\"\n | \"onMouseMove\"\n | \"onMouseUp\"\n | \"onTouchStart\"\n | \"onTouchMove\"\n | \"onTouchEnd\"\n\nexport type SliderPropsType = {\n /**\n * mandatory for A11y\n */\n ariaLabel: string\n value?: number\n defaultValue?: number\n /**\n * minimum selectable value (default is 0)\n */\n min?: number\n /**\n * maximum selectable value (default is 100)\n */\n max?: number\n /**\n * values interval\n */\n step?: number\n disabled?: boolean\n /**\n * Listener called when the value is changed\n */\n onChange?: (newValue: number) => void\n /**\n * Function used to visually display the slider value\n */\n renderValue?: (\n value: number,\n status: FormElement[\"status\"]\n ) => React.ReactElement\n\n onPointerDown?: ReachSliderProps[\"onPointerDown\"]\n onPointerUp?: ReachSliderProps[\"onPointerUp\"]\n onMouseDown?: ReachSliderProps[\"onMouseDown\"]\n onMouseMove?: ReachSliderProps[\"onMouseMove\"]\n onMouseUp?: ReachSliderProps[\"onMouseUp\"]\n onTouchStart?: ReachSliderProps[\"onTouchStart\"]\n onTouchMove?: ReachSliderProps[\"onTouchMove\"]\n onTouchEnd?: ReachSliderProps[\"onTouchEnd\"]\n onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void\n} & FormElement &\n Omit<\n React.InputHTMLAttributes<HTMLInputElement>,\n NativeEventType | \"css\" | \"enterKeyHint\" | \"onChange\"\n >\n\nconst Slider = ({\n defaultValue,\n value,\n min,\n max,\n status,\n disabled,\n onChange,\n renderValue,\n ariaLabel,\n ...restProps\n}: SliderPropsType) => {\n function initValue() {\n if (value != null) return value\n if (defaultValue != null) return defaultValue\n if (min != null) return min\n return 0\n }\n\n const [sliderValue, setSliderValue] = useState(() => initValue())\n\n return (\n <div\n className={classNames(\"cobalt-slider\", {\n \"cobalt-slider--disabled\": disabled,\n })}\n >\n {renderValue && (\n <div className=\"cobalt-slider__value-container\">\n {renderValue(sliderValue, status)}\n </div>\n )}\n\n <ReachSlider\n {...restProps}\n aria-label={ariaLabel}\n handleAlignment=\"contain\"\n defaultValue={defaultValue}\n value={value}\n min={min}\n max={max}\n disabled={disabled}\n onChange={(newValue) => {\n setSliderValue(newValue)\n onChange && onChange(newValue)\n }}\n />\n </div>\n )\n}\n\nconst wrappedComponent = withFieldLabelAndHint(Slider)\nwrappedComponent.displayName = \"Slider\"\n\nexport default wrappedComponent\n\ntype SliderValueMetaProps = {\n children: React.ReactNode\n}\nexport const SliderValueMeta = ({ children }: SliderValueMetaProps) => {\n return <span className=\"cobalt-slider__value-meta\">{children}</span>\n}\n"],"names":["classNames","ReachSlider"],"mappings":";;;;;AAkEA,MAAM,MAAM,GAAG,CAAC,EACd,YAAY,EACZ,KAAK,EACL,GAAG,EACH,GAAG,EACH,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,SAAS,EACT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AAA,OAAO,8BAAM,SAAS,EAAC,2BAA2B,EAAE,EAAA,QAAQ,CAAQ,CAAA;AACtE;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drivy/cobalt",
3
- "version": "0.29.2",
3
+ "version": "0.31.0",
4
4
  "description": "Opinionated design system for Drivy's projects.",
5
5
  "main": "src/index.js",
6
6
  "types": "types/index.d.ts",
@@ -31,7 +31,7 @@
31
31
  "date-fns": "2.29.3",
32
32
  "lodash.throttle": "4.1.1",
33
33
  "media-typer": "1.1.0",
34
- "nanoid": "4.0.0",
34
+ "nanoid": "4.0.1",
35
35
  "postcss": "8.4.21",
36
36
  "tailwindcss": "2.2.19",
37
37
  "tippy.js": "6.3.7"
@@ -49,11 +49,11 @@
49
49
  "@percy/storybook": "3.3.1",
50
50
  "@rollup/plugin-json": "6.0.0",
51
51
  "@rushstack/eslint-patch": "1.2.0",
52
- "@storybook/addon-essentials": "6.5.15",
53
- "@storybook/addons": "6.5.15",
54
- "@storybook/builder-webpack5": "6.5.15",
55
- "@storybook/manager-webpack5": "6.5.15",
56
- "@storybook/react": "6.5.15",
52
+ "@storybook/addon-essentials": "6.5.16",
53
+ "@storybook/addons": "6.5.16",
54
+ "@storybook/builder-webpack5": "6.5.16",
55
+ "@storybook/manager-webpack5": "6.5.16",
56
+ "@storybook/react": "6.5.16",
57
57
  "@svgr/cli": "6.5.1",
58
58
  "@testing-library/jest-dom": "5.16.5",
59
59
  "@testing-library/react": "13.4.0",
@@ -65,9 +65,9 @@
65
65
  "@types/react": "18.0.26",
66
66
  "@whitespace/storybook-addon-html": "^5.1.1",
67
67
  "autoprefixer": "10.4.13",
68
- "core-js": "3.27.2",
68
+ "core-js": "3.28.0",
69
69
  "css-loader": "6.7.3",
70
- "eslint": "8.32.0",
70
+ "eslint": "8.34.0",
71
71
  "file-loader": "6.2.0",
72
72
  "jest": "29.3.1",
73
73
  "jest-environment-jsdom": "29.3.1",
@@ -87,7 +87,7 @@
87
87
  "rollup-plugin-postcss": "4.0.2",
88
88
  "rollup-plugin-svgo": "2.0.0",
89
89
  "rollup-plugin-typescript2": "0.34.1",
90
- "sass": "1.57.1",
90
+ "sass": "1.58.1",
91
91
  "sass-loader": "13.2.0",
92
92
  "sharp": "0.31.3",
93
93
  "sharp-cli": "4.1.0",
@@ -97,7 +97,7 @@
97
97
  "svgo": "3.0.2",
98
98
  "ts-jest": "29.0.5",
99
99
  "ts-node": "10.9.1",
100
- "typescript": "4.9.4"
100
+ "typescript": "4.9.5"
101
101
  },
102
102
  "scripts": {
103
103
  "build": "./scripts/build.sh",
@@ -46,7 +46,7 @@
46
46
  &::before,
47
47
  &::after {
48
48
  // This element is actually an icon but animated, so we can use icon colors here
49
- @include semantic-color(subdued, icon, background-color);
49
+ @include semantic-color(icon, subdued, background-color);
50
50
  position: absolute;
51
51
 
52
52
  content: "";
@@ -34,10 +34,8 @@
34
34
  pointer-events: auto;
35
35
 
36
36
  &--info {
37
- // TOFIX: there is no matching semantic color for this case
38
- color: color(white);
39
-
40
- background-color: color(graphite);
37
+ @include bg-color(info);
38
+ @include text-color(info);
41
39
  }
42
40
 
43
41
  &--success {
@@ -26,8 +26,7 @@
26
26
  svg,
27
27
  use,
28
28
  g {
29
- // TOFIX: find a way to use new colors here
30
- fill: rgba(color(graphite), 0.5);
29
+ @include fill-color(subdued);
31
30
  }
32
31
  }
33
32
  }
@@ -1,19 +1,19 @@
1
1
  .cob-Button__default {
2
2
  @include semantic-color(
3
- secondaryInteractive,
4
3
  buttonBackground,
4
+ secondaryInteractive,
5
5
  background-color
6
6
  );
7
- @include semantic-color(baseInteractive, stroke, border-color);
8
- @include semantic-color(secondaryInteractive, buttonLabel, color);
7
+ @include semantic-color(stroke, baseInteractive, border-color);
8
+ @include semantic-color(buttonLabel, secondaryInteractive, color);
9
9
 
10
10
  &--primary {
11
11
  @include semantic-color(
12
- primaryInteractive,
13
12
  buttonBackground,
13
+ primaryInteractive,
14
14
  background-color
15
15
  );
16
- @include semantic-color(primaryInteractive, buttonLabel, color);
16
+ @include semantic-color(buttonLabel, primaryInteractive, color);
17
17
 
18
18
  border-color: transparent;
19
19
 
@@ -25,24 +25,24 @@
25
25
 
26
26
  &.cob-Button__default--destructive {
27
27
  @include semantic-color(
28
- destructiveInteractive,
29
28
  buttonBackground,
29
+ destructiveInteractive,
30
30
  background-color
31
31
  );
32
- @include semantic-color(destructiveInteractive, buttonLabel, color);
32
+ @include semantic-color(buttonLabel, destructiveInteractive, color);
33
33
 
34
34
  border-color: transparent;
35
35
  }
36
36
  }
37
37
 
38
38
  &--destructive {
39
- @include semantic-color(error, text, color);
39
+ @include semantic-color(text, error, color);
40
40
 
41
41
  &:hover,
42
42
  &:focus,
43
43
  &:active {
44
- @include semantic-color(error, text, color);
45
- @include semantic-color(error, stroke, border-color);
44
+ @include semantic-color(text, error, color);
45
+ @include semantic-color(stroke, error, border-color);
46
46
  }
47
47
  }
48
48
 
@@ -50,8 +50,8 @@
50
50
  &--selected:focus,
51
51
  &--selected:active,
52
52
  &--selected {
53
- @include semantic-color(selected, buttonBackground, background-color);
54
- @include semantic-color(selected, buttonLabel, color);
53
+ @include semantic-color(buttonBackground, selected, background-color);
54
+ @include semantic-color(buttonLabel, selected, color);
55
55
  @include border-color(accent);
56
56
  }
57
57
  }
@@ -1,8 +1,8 @@
1
1
  .cob-Button__ghost {
2
- @include semantic-color(tertiaryInteractive, buttonLabel, color);
2
+ @include semantic-color(buttonLabel, tertiaryInteractive, color);
3
3
  @include semantic-color(
4
- tertiaryInteractive,
5
4
  buttonBackground,
5
+ tertiaryInteractive,
6
6
  background-color
7
7
  );
8
8
  border-color: transparent;
@@ -18,7 +18,7 @@
18
18
  }
19
19
 
20
20
  &.cob-Button__ghost--destructive {
21
- @include semantic-color(error, text, color);
21
+ @include semantic-color(text, error, color);
22
22
  }
23
23
 
24
24
  &.cob-Button__ghost--standalone {
@@ -35,8 +35,8 @@
35
35
  &[data-disabled]:not([data-disabled="false"]),
36
36
  &.cob-Button--disabled {
37
37
  @include semantic-color(
38
- tertiaryInteractive,
39
38
  buttonBackground,
39
+ tertiaryInteractive,
40
40
  background-color
41
41
  );
42
42
  border-color: transparent;
@@ -1,6 +1,6 @@
1
1
  .cob-Button__inversed {
2
- @include semantic-color(inversed, text, color);
3
- @include semantic-color(base, stroke, border-color);
2
+ @include semantic-color(text, inversed, color);
3
+ @include semantic-color(stroke, base, border-color);
4
4
 
5
5
  background-color: transparent;
6
6
  box-shadow: none;
@@ -46,7 +46,6 @@
46
46
  white-space: normal;
47
47
 
48
48
  border-radius: border-radius(md);
49
- box-shadow: 0 2px 8px 0 rgba(#000, 0.08);
50
49
 
51
50
  cursor: pointer;
52
51
  user-select: none;
@@ -98,9 +97,9 @@
98
97
  &[disabled],
99
98
  &[data-disabled]:not([data-disabled="false"]),
100
99
  &.cob-Button--disabled {
101
- @include semantic-color(disabled, buttonBackground, background-color);
102
- @include semantic-color(disabled, buttonLabel, color);
103
- @include semantic-color(subdued, stroke, border-color);
100
+ @include semantic-color(buttonBackground, disabled, background-color);
101
+ @include semantic-color(buttonLabel, disabled, color);
102
+ @include semantic-color(stroke, subdued, border-color);
104
103
 
105
104
  opacity: 1;
106
105
  cursor: not-allowed;
@@ -111,9 +110,9 @@
111
110
  &:hover,
112
111
  &:focus,
113
112
  &:active {
114
- @include semantic-color(disabled, buttonBackground, background-color);
115
- @include semantic-color(disabled, buttonLabel, color);
116
- @include semantic-color(subdued, stroke, border-color);
113
+ @include semantic-color(buttonBackground, disabled, background-color);
114
+ @include semantic-color(buttonLabel, disabled, color);
115
+ @include semantic-color(stroke, subdued, border-color);
117
116
  box-shadow: none;
118
117
  }
119
118
  }
@@ -1,13 +1,9 @@
1
1
  @use "sass:math";
2
2
 
3
3
  .cobalt-CalendarRangePicker {
4
- // TOFIX change it to AccentAlt color
5
- $calendar-range-day-color: lighten(color(purple, light), 29);
6
- $calendar-selected-day-invalid-color: color(red);
7
- // TOFIX change it to ErrorAlt color
8
- $calendar-range-day-invalid-color: lighten(color(red), 20);
9
- // TOFIX find a semantic color equivalent
10
- $calendar-out-of-range-color: darken($calendar-range-day-invalid-color, 8);
4
+ $calendar-range-day-color: var(--c-background-accentAlt);
5
+ $calendar-range-day-invalid-color: var(--c-background-errorAlt);
6
+ $calendar-out-of-range-color: var(--c-background-error);
11
7
 
12
8
  $calendar-day-inner-height: 24px;
13
9
  $calendar-day-padding: 6px;
@@ -45,7 +41,7 @@
45
41
 
46
42
  border-radius: 50%;
47
43
 
48
- box-shadow: rgba(176, 26, 167, 0.4) 0 2px 6px 0;
44
+ box-shadow: var(--c-background-accentAlt) 0 2px 6px 0;
49
45
  }
50
46
 
51
47
  position: relative;
@@ -59,9 +55,8 @@
59
55
  }
60
56
 
61
57
  &__month {
58
+ @include bg-color(secondary);
62
59
  flex: 1;
63
-
64
- background-color: color(white);
65
60
  }
66
61
 
67
62
  &__month-header {
@@ -92,11 +87,11 @@
92
87
  }
93
88
 
94
89
  &__month__day-header {
90
+ @include text-color(subdued);
95
91
  flex: 1;
96
92
 
97
93
  text-align: center;
98
94
  text-transform: capitalize;
99
- color: color(grey, dark);
100
95
  font-weight: 400;
101
96
  font-size: 14px;
102
97
  }
@@ -129,7 +124,7 @@
129
124
  }
130
125
 
131
126
  &--today {
132
- color: color(purple);
127
+ @include text-color(accent);
133
128
  font-weight: 600;
134
129
  }
135
130
 
@@ -140,8 +135,7 @@
140
135
  }
141
136
 
142
137
  &--disabled {
143
- color: color(grey);
144
-
138
+ @include text-color(subdued);
145
139
  cursor: auto;
146
140
  }
147
141
 
@@ -178,7 +172,8 @@
178
172
  .cobalt-CalendarRangePicker__day-inner:before {
179
173
  @include start-end-day;
180
174
 
181
- box-shadow: white 0 0 0 2px, rgb(176, 26, 167) 0 0 0 4px;
175
+ box-shadow: var(--c-background-secondary) 0 0 0 2px,
176
+ var(--c-background-accent) 0 0 0 4px;
182
177
  }
183
178
 
184
179
  // start/end day content when the other one is currently edited + today
@@ -188,8 +183,8 @@
188
183
  &--endDay.cobalt-CalendarRangePicker__day--today:not(
189
184
  &--startDay
190
185
  ).cobalt-CalendarRangePicker__day--subdued {
186
+ @include text-color(accent);
191
187
  font-weight: 600;
192
- color: color(purple);
193
188
  }
194
189
 
195
190
  // not today
@@ -199,8 +194,8 @@
199
194
  &--endDay:not(&--startDay):not(
200
195
  &--today
201
196
  ).cobalt-CalendarRangePicker__day--subdued {
197
+ @include text-color(base);
202
198
  font-weight: inherit;
203
- color: black;
204
199
  }
205
200
 
206
201
  // start/end day background (circle) when the other one is currently edited
@@ -305,7 +300,7 @@
305
300
  &--endDay .cobalt-CalendarRangePicker__day-inner:after {
306
301
  @include bg-color(error);
307
302
 
308
- box-shadow: rgba($calendar-selected-day-invalid-color, 0.4) 0 2px 6px 0;
303
+ box-shadow: var(--c-background-errorAlt) 0 2px 6px 0;
309
304
  }
310
305
 
311
306
  // invalid start/end day background (circle) when the other one is currently edited
@@ -38,24 +38,22 @@ $daySize: spacing(md);
38
38
  border-radius: math.div($daySize, 2);
39
39
 
40
40
  &--disabled {
41
- @include bg-color(disabled);
41
+ @include bg-color(neutral);
42
+ @include text-color(subdued);
42
43
  }
43
44
 
44
45
  &--highlighted {
45
46
  @include text-color(inversed);
46
-
47
- // TOFIX find a semantic color equivalent
48
- background-color: color(turquoise);
47
+ @include bg-color(connect);
49
48
  }
50
49
 
51
50
  &--semi-highlighted {
52
- // TOFIX find a semantic color equivalent
53
- background-color: lighten(color(turquoise), 30);
51
+ @include bg-color(connectAlt);
54
52
  }
55
53
 
56
54
  &--past {
57
- // TOFIX find a semantic color equivalent
58
- color: color(grey);
55
+ @include text-color(subdued);
56
+ opacity: 0.4;
59
57
  }
60
58
 
61
59
  &:not(:first-child) {
@@ -1,20 +1,27 @@
1
1
  .cobalt- {
2
- $card-border-radius: border-radius(base);
2
+ $card-border-radius: border-radius(xl);
3
3
  // deprecated
4
4
  $legacy-card-padding-tight: 12px;
5
5
 
6
6
  &Card {
7
7
  @include bg-color(secondary);
8
+ @include border(base);
8
9
  width: 100%;
9
10
 
10
11
  border-radius: $card-border-radius;
11
12
 
12
- box-shadow: elevation(base);
13
+ &--legacy {
14
+ border: 0;
13
15
 
14
- &--flattened {
15
- @include border(base);
16
+ box-shadow: elevation(base);
17
+ }
16
18
 
17
- box-shadow: none;
19
+ &--responsive {
20
+ @include breakpoint($until: sm) {
21
+ border-radius: 0;
22
+ border-left-width: 0;
23
+ border-right-width: 0;
24
+ }
18
25
  }
19
26
  }
20
27
 
@@ -63,11 +70,14 @@
63
70
  padding-top: $legacy-card-padding-tight - 1px;
64
71
  }
65
72
 
66
- &Card > .cobalt-Card__Section:first-of-type {
73
+ // first-of-class, source: https://stackoverflow.com/questions/2717480/css-selector-for-first-element-with-class
74
+ &Card
75
+ > .cobalt-Card__Section:not(.cobalt-Card__Section ~ .cobalt-Card__Section) {
67
76
  border-top-left-radius: $card-border-radius;
68
77
  border-top-right-radius: $card-border-radius;
69
78
  }
70
79
 
80
+ // No last-of-class hack found for now
71
81
  &Card > .cobalt-Card__Section:last-of-type {
72
82
  border-bottom-right-radius: $card-border-radius;
73
83
  border-bottom-left-radius: $card-border-radius;