@drivy/cobalt 2.0.0-beta.7 → 2.0.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/components/Modal/ModalHeader.js +1 -1
- package/components/Modal/ModalHeader.js.map +1 -1
- package/components/Rating/RatingIcons.js +1 -1
- package/components/Rating/RatingIcons.js.map +1 -1
- package/package.json +5 -5
- package/styles/components/Callout/index.scss +1 -1
- package/styles/components/Rating/index.scss +1 -1
- package/utils/getCobaltTailwindcssConfig.js.map +1 -1
|
@@ -8,7 +8,7 @@ const ModalHeader = ({ title, close, }) => {
|
|
|
8
8
|
return null;
|
|
9
9
|
return (React.createElement("div", { className: "cobalt-modal-header" },
|
|
10
10
|
React.createElement(Dialog.Title, { className: "cobalt-modal-header__title" }, title),
|
|
11
|
-
close && (React.createElement("
|
|
11
|
+
close && (React.createElement("button", { type: "button", className: "cobalt-modal-header__close-button", onClick: close },
|
|
12
12
|
React.createElement("span", { "aria-hidden": true },
|
|
13
13
|
React.createElement(CloseIcon, { color: "onSurfaceVariant" }))))));
|
|
14
14
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalHeader.js","sources":["../../../src/components/Modal/ModalHeader.tsx"],"sourcesContent":["import React from \"react\"\nimport { Dialog } from \"@ark-ui/react\"\n\nimport { CloseIcon } from \"../Icon\"\n\nconst ModalHeader = ({\n title,\n close,\n}: {\n title?: React.ReactNode\n close?: () => void\n}) => {\n if (!title && !close) return null\n\n return (\n <div className=\"cobalt-modal-header\">\n <Dialog.Title className=\"cobalt-modal-header__title\">\n {title}\n </Dialog.Title>\n {close && (\n <
|
|
1
|
+
{"version":3,"file":"ModalHeader.js","sources":["../../../src/components/Modal/ModalHeader.tsx"],"sourcesContent":["import React from \"react\"\nimport { Dialog } from \"@ark-ui/react\"\n\nimport { CloseIcon } from \"../Icon\"\n\nconst ModalHeader = ({\n title,\n close,\n}: {\n title?: React.ReactNode\n close?: () => void\n}) => {\n if (!title && !close) return null\n\n return (\n <div className=\"cobalt-modal-header\">\n <Dialog.Title className=\"cobalt-modal-header__title\">\n {title}\n </Dialog.Title>\n {close && (\n <button\n type=\"button\"\n className=\"cobalt-modal-header__close-button\"\n onClick={close}\n >\n <span aria-hidden>\n <CloseIcon color=\"onSurfaceVariant\" />\n </span>\n </button>\n )}\n </div>\n )\n}\n\nexport default ModalHeader\n"],"names":[],"mappings":";;;;;AAKM,MAAA,WAAW,GAAG,CAAC,EACnB,KAAK,EACL,KAAK,GAIN,KAAI;AACH,IAAA,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK;AAAE,QAAA,OAAO,IAAI,CAAA;AAEjC,IAAA,QACE,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,qBAAqB,EAAA;QAClC,KAAC,CAAA,aAAA,CAAA,MAAM,CAAC,KAAK,EAAA,EAAC,SAAS,EAAC,4BAA4B,EACjD,EAAA,KAAK,CACO;AACd,QAAA,KAAK,KACJ,KACE,CAAA,aAAA,CAAA,QAAA,EAAA,EAAA,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,mCAAmC,EAC7C,OAAO,EAAE,KAAK,EAAA;AAEd,YAAA,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA,EAAA,aAAA,EAAA,IAAA,EAAA;gBACE,KAAC,CAAA,aAAA,CAAA,SAAS,EAAC,EAAA,KAAK,EAAC,kBAAkB,EAAG,CAAA,CACjC,CACA,CACV,CACG,EACP;AACH;;;;"}
|
|
@@ -5,7 +5,7 @@ import '../Icon/index.js';
|
|
|
5
5
|
import StarIcon from '../Icon/__generated__/StarIcon.js';
|
|
6
6
|
|
|
7
7
|
const defaultRatingIcon = React.createElement(StarIcon, { color: "primary" });
|
|
8
|
-
const itemEmptyColor = "
|
|
8
|
+
const itemEmptyColor = "surfaceContainerVariant";
|
|
9
9
|
function roundHalf(num) {
|
|
10
10
|
const temp = num * 2;
|
|
11
11
|
return temp % 1 === 0.5 ? Math.floor(temp) / 2 : Math.round(temp) / 2;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RatingIcons.js","sources":["../../../src/components/Rating/RatingIcons.tsx"],"sourcesContent":["import React, { useState, useRef, useCallback } from \"react\"\nimport { nanoid } from \"nanoid\"\nimport cx from \"classnames\"\nimport { IconProps, StarIcon } from \"../Icon\"\n\nexport type RatingIconsPropsType = {\n className?: string\n max?: 5 | 10\n value: number\n size?: IconProps[\"size\"] | 48\n editable?: boolean\n disabled?: boolean\n onChange?: (newValue: number) => void\n icon?: JSX.Element | JSX.Element[]\n}\n\nexport type RatingIconPropsType = {\n icon: JSX.Element\n status?: \"full\" | \"half\" | \"empty\"\n size?: RatingIconsPropsType[\"size\"]\n}\n\nexport const defaultRatingIcon = <StarIcon color=\"primary\" />\nconst itemEmptyColor: IconProps[\"color\"] = \"
|
|
1
|
+
{"version":3,"file":"RatingIcons.js","sources":["../../../src/components/Rating/RatingIcons.tsx"],"sourcesContent":["import React, { useState, useRef, useCallback } from \"react\"\nimport { nanoid } from \"nanoid\"\nimport cx from \"classnames\"\nimport { IconProps, StarIcon } from \"../Icon\"\n\nexport type RatingIconsPropsType = {\n className?: string\n max?: 5 | 10\n value: number\n size?: IconProps[\"size\"] | 48\n editable?: boolean\n disabled?: boolean\n onChange?: (newValue: number) => void\n icon?: JSX.Element | JSX.Element[]\n}\n\nexport type RatingIconPropsType = {\n icon: JSX.Element\n status?: \"full\" | \"half\" | \"empty\"\n size?: RatingIconsPropsType[\"size\"]\n}\n\nexport const defaultRatingIcon = <StarIcon color=\"primary\" />\nconst itemEmptyColor: IconProps[\"color\"] = \"surfaceContainerVariant\"\n\nexport function roundHalf(num: number) {\n const temp = num * 2\n return temp % 1 === 0.5 ? Math.floor(temp) / 2 : Math.round(temp) / 2\n}\n\nexport function computeItemStatus(\n ratingValue: number,\n itemValue: number,\n icon: RatingIconsPropsType[\"icon\"]\n): RatingIconPropsType[\"status\"] {\n let itemStatus: RatingIconPropsType[\"status\"] = \"empty\"\n if (!Array.isArray(icon)) {\n // gauge\n const isHalfItem = itemValue > ratingValue && ratingValue > itemValue - 1\n if (isHalfItem) {\n itemStatus = \"half\"\n } else if (itemValue <= ratingValue) {\n itemStatus = \"full\"\n }\n } else if (itemValue === ratingValue) {\n // radio\n itemStatus = \"full\"\n }\n\n return itemStatus\n}\n\nexport const RatingIcon = ({\n icon,\n status = \"full\",\n size = 24,\n}: RatingIconPropsType) => {\n if (status === \"half\") {\n return (\n <>\n {React.cloneElement(icon, {\n color: itemEmptyColor,\n size,\n })}\n <div className=\"cobalt-rating-icons__icon-half-container\">\n {React.cloneElement(icon, { size })}\n </div>\n </>\n )\n } else {\n const iconColor: IconProps[\"color\"] =\n status === \"empty\" ? itemEmptyColor : icon.props.color\n\n return React.cloneElement(icon, {\n color: iconColor,\n size,\n })\n }\n}\n\nexport const RatingIcons = ({\n className,\n max = 5,\n value,\n size = 24,\n editable = false,\n onChange,\n icon = defaultRatingIcon,\n}: RatingIconsPropsType) => {\n const name = useRef(nanoid())\n\n const items = useRef(\n Array.from(new Array(Array.isArray(icon) ? icon.length : max))\n )\n\n const [ratingValue, setRatingValue] = useState(() =>\n editable ? Math.floor(value) : roundHalf(value)\n )\n const [selectedIndex, setSelectedIndex] = useState(-1) // used to enforce selection effect (icon scale reset)\n\n const resetSelection = useCallback(() => {\n setSelectedIndex(-1)\n }, [])\n\n const itemSize = size === 48 ? 16 : size\n\n // input element is used for a11y purpose ( focus feedback and keyboard selection )\n return (\n <div\n className={cx(\"cobalt-rating-icons\", className, {\n \"cobalt-rating-icons--icon-size-48\": size === 48,\n })}\n onPointerLeave={() => {\n if (editable) {\n ;(document.activeElement as HTMLInputElement).blur()\n }\n }}\n >\n {items.current.map((_value, idx) => {\n const itemValue = idx + 1\n\n const itemStatus = computeItemStatus(ratingValue, itemValue, icon)\n\n return (\n <label\n className={cx(\"cobalt-rating-icons__icon-wrapper\", {\n \"cobalt-rating-icons__icon-wrapper--selected\":\n selectedIndex === idx,\n })}\n key={idx}\n onClick={() => {\n if (editable) {\n setRatingValue(itemValue)\n setSelectedIndex(idx)\n }\n }}\n onMouseEnter={(e) => {\n if (editable) {\n ;(e.target as HTMLElement).focus()\n\n resetSelection()\n }\n }}\n >\n <input\n tabIndex={\n editable &&\n (ratingValue === itemValue ||\n (ratingValue === 0 && itemValue === 1))\n ? 0\n : -1\n }\n name={name.current}\n type=\"radio\"\n value={itemValue}\n onChange={() => {\n onChange && onChange(itemValue)\n }}\n disabled={!editable}\n />\n {\n <RatingIcon\n icon={Array.isArray(icon) ? icon[idx] : icon}\n status={itemStatus}\n size={itemSize}\n />\n }\n </label>\n )\n })}\n </div>\n )\n}\n"],"names":[],"mappings":";;;;;;AAsBa,MAAA,iBAAiB,GAAG,KAAA,CAAA,aAAA,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAC,SAAS,EAAA,EAAG;AAC7D,MAAM,cAAc,GAAuB,yBAAyB,CAAA;AAE9D,SAAU,SAAS,CAAC,GAAW,EAAA;AACnC,IAAA,MAAM,IAAI,GAAG,GAAG,GAAG,CAAC,CAAA;IACpB,OAAO,IAAI,GAAG,CAAC,KAAK,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACvE,CAAC;SAEe,iBAAiB,CAC/B,WAAmB,EACnB,SAAiB,EACjB,IAAkC,EAAA;IAElC,IAAI,UAAU,GAAkC,OAAO,CAAA;IACvD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;;QAExB,MAAM,UAAU,GAAG,SAAS,GAAG,WAAW,IAAI,WAAW,GAAG,SAAS,GAAG,CAAC,CAAA;QACzE,IAAI,UAAU,EAAE;YACd,UAAU,GAAG,MAAM,CAAA;SACpB;AAAM,aAAA,IAAI,SAAS,IAAI,WAAW,EAAE;YACnC,UAAU,GAAG,MAAM,CAAA;SAC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A;oBACzB,gBAAgB,CAAC,GAAG,CAAC,CAAA;iBACtB;AACH,aAAC,EACD,YAAY,EAAE,CAAC,CAAC,KAAI;gBAClB,IAAI,QAAQ,EAAE;AACV,oBAAA,CAAC,CAAC,MAAsB,CAAC,KAAK,EAAE,CAAA;AAElC,oBAAA,cAAc,EAAE,CAAA;iBACjB;aACF,EAAA;YAED,KACE,CAAA,aAAA,CAAA,OAAA,EAAA,EAAA,QAAQ,EACN,QAAQ;qBACP,WAAW,KAAK,SAAS;yBACvB,WAAW,KAAK,CAAC,IAAI,SAAS,KAAK,CAAC,CAAC,CAAC;AACvC,sBAAE,CAAC;sBACD,CAAC,CAAC,EAER,IAAI,EAAE,IAAI,CAAC,OAAO,EAClB,IAAI,EAAC,OAAO,EACZ,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,MAAK;AACb,oBAAA,QAAQ,IAAI,QAAQ,CAAC,SAAS,CAAC,CAAA;AACjC,iBAAC,EACD,QAAQ,EAAE,CAAC,QAAQ,EACnB,CAAA;AAEA,YAAA,KAAA,CAAA,aAAA,CAAC,UAAU,EAAA,EACT,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,EAC5C,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,QAAQ,EACd,CAAA,CAEE,EACT;KACF,CAAC,CACE,EACP;AACH;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drivy/cobalt",
|
|
3
|
-
"version": "2.0.0
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Opinionated design system for Drivy's projects.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "types/src/index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"lodash.throttle": "4.1.1",
|
|
29
29
|
"media-typer": "1.1.0",
|
|
30
30
|
"nanoid": "5.1.5",
|
|
31
|
-
"postcss": "8.5.
|
|
31
|
+
"postcss": "8.5.6",
|
|
32
32
|
"tailwindcss": "3.4.17",
|
|
33
33
|
"tippy.js": "6.3.7"
|
|
34
34
|
},
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@getaround-eu/prettier-config": "1.2.1",
|
|
43
43
|
"@getaround-eu/stylelint-config": "3.0.1",
|
|
44
44
|
"@getaround-eu/ts-config": "2.2.1",
|
|
45
|
-
"@rollup/plugin-commonjs": "28.0.
|
|
45
|
+
"@rollup/plugin-commonjs": "28.0.6",
|
|
46
46
|
"@rollup/plugin-json": "6.1.0",
|
|
47
47
|
"@rushstack/eslint-patch": "1.11.0",
|
|
48
48
|
"@storybook/addon-essentials": "7.6.20",
|
|
@@ -96,8 +96,8 @@
|
|
|
96
96
|
"stylelint": "15.11.0",
|
|
97
97
|
"svg2vectordrawable": "2.9.1",
|
|
98
98
|
"svgo": "3.3.2",
|
|
99
|
-
"ts-jest": "29.
|
|
100
|
-
"tsx": "4.20.
|
|
99
|
+
"ts-jest": "29.4.0",
|
|
100
|
+
"tsx": "4.20.3",
|
|
101
101
|
"typescript": "5.4.5"
|
|
102
102
|
},
|
|
103
103
|
"keywords": [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCobaltTailwindcssConfig.js","sources":["../../utils/getCobaltTailwindcssConfig.js?commonjs-entry"],"sourcesContent":["import { getDefaultExportFromCjs } from \"\u0000commonjsHelpers.js\";\nimport { __require as requireGetCobaltTailwindcssConfig } from \"/Users/
|
|
1
|
+
{"version":3,"file":"getCobaltTailwindcssConfig.js","sources":["../../utils/getCobaltTailwindcssConfig.js?commonjs-entry"],"sourcesContent":["import { getDefaultExportFromCjs } from \"\u0000commonjsHelpers.js\";\nimport { __require as requireGetCobaltTailwindcssConfig } from \"/Users/cedric/Dev/drivy/cobalt/utils/getCobaltTailwindcssConfig.js\";\nvar getCobaltTailwindcssConfigExports = requireGetCobaltTailwindcssConfig();\nexport { getCobaltTailwindcssConfigExports as __moduleExports };\nexport default /*@__PURE__*/getDefaultExportFromCjs(getCobaltTailwindcssConfigExports);"],"names":[],"mappings":";;;AAEA,IAAI,iCAAiC,GAAG,iCAAiC,EAAE,CAAC;AAE5E,iCAAe,aAAa,uBAAuB,CAAC,iCAAiC,CAAC;;;;"}
|