From cf2bd304cf26ebb1d0fef1cc819c8f9fcbe02a54 Mon Sep 17 00:00:00 2001 From: soupette Date: Thu, 4 Mar 2021 11:59:26 +0100 Subject: [PATCH] Upgrade buffet.js. Add icon to inputs label Signed-off-by: soupette --- .../api/address/models/Address.settings.json | 8 ++- .../category/models/Category.settings.json | 4 +- packages/strapi-admin/package.json | 12 ++-- .../src/components/LabelIconWrapper/index.js | 8 +++ .../strapi-helper-plugin/lib/src/index.js | 1 + packages/strapi-helper-plugin/package.json | 12 ++-- .../components/InputJSONWithErrors/index.js | 15 ++++- .../admin/src/components/InputUID/index.js | 21 ++++++- .../admin/src/components/Inputs/index.js | 2 + .../src/components/WysiwygWithErrors/index.js | 16 ++++- .../package.json | 12 ++-- .../package.json | 12 ++-- .../strapi-plugin-documentation/package.json | 12 ++-- .../admin/src/components/InputMedia/index.js | 29 ++++++++- packages/strapi-plugin-upload/package.json | 12 ++-- .../package.json | 12 ++-- yarn.lock | 62 +++++++++---------- 17 files changed, 163 insertions(+), 87 deletions(-) create mode 100644 packages/strapi-helper-plugin/lib/src/components/LabelIconWrapper/index.js diff --git a/examples/getstarted/api/address/models/Address.settings.json b/examples/getstarted/api/address/models/Address.settings.json index b1de327f5f..48e6b538f7 100755 --- a/examples/getstarted/api/address/models/Address.settings.json +++ b/examples/getstarted/api/address/models/Address.settings.json @@ -19,8 +19,8 @@ "type": "string" }, "categories": { - "via": "addresses", "collection": "category", + "via": "addresses", "dominant": true }, "cover": { @@ -51,6 +51,12 @@ "likes": { "collection": "like", "via": "address" + }, + "json": { + "type": "json" + }, + "slug": { + "type": "uid" } } } diff --git a/examples/getstarted/api/category/models/Category.settings.json b/examples/getstarted/api/category/models/Category.settings.json index 5f87982274..d775ee4215 100755 --- a/examples/getstarted/api/category/models/Category.settings.json +++ b/examples/getstarted/api/category/models/Category.settings.json @@ -16,8 +16,8 @@ "type": "string" }, "addresses": { - "collection": "address", - "via": "categories" + "via": "categories", + "collection": "address" } } } diff --git a/packages/strapi-admin/package.json b/packages/strapi-admin/package.json index 6961505bcb..4b09507517 100644 --- a/packages/strapi-admin/package.json +++ b/packages/strapi-admin/package.json @@ -24,12 +24,12 @@ "@babel/preset-env": "^7.9.5", "@babel/preset-react": "^7.9.4", "@babel/runtime": "^7.12.13", - "@buffetjs/core": "3.3.4", - "@buffetjs/custom": "3.3.4", - "@buffetjs/hooks": "3.3.4", - "@buffetjs/icons": "3.3.4", - "@buffetjs/styles": "3.3.4", - "@buffetjs/utils": "3.3.4", + "@buffetjs/core": "3.3.5-next.1", + "@buffetjs/custom": "3.3.5-next.1", + "@buffetjs/hooks": "3.3.5-next.1", + "@buffetjs/icons": "3.3.5-next.1", + "@buffetjs/styles": "3.3.5-next.1", + "@buffetjs/utils": "3.3.5-next.1", "@casl/ability": "^4.1.5", "@fortawesome/fontawesome-free": "^5.11.2", "@fortawesome/fontawesome-svg-core": "^1.2.32", diff --git a/packages/strapi-helper-plugin/lib/src/components/LabelIconWrapper/index.js b/packages/strapi-helper-plugin/lib/src/components/LabelIconWrapper/index.js new file mode 100644 index 0000000000..2538e3f9fa --- /dev/null +++ b/packages/strapi-helper-plugin/lib/src/components/LabelIconWrapper/index.js @@ -0,0 +1,8 @@ +import styled from 'styled-components'; + +const LabelIconWrapper = styled.span` + margin-left: 5px; + cursor: pointer; +`; + +export default LabelIconWrapper; diff --git a/packages/strapi-helper-plugin/lib/src/index.js b/packages/strapi-helper-plugin/lib/src/index.js index f10895ac0d..7be7df2a38 100644 --- a/packages/strapi-helper-plugin/lib/src/index.js +++ b/packages/strapi-helper-plugin/lib/src/index.js @@ -53,6 +53,7 @@ export { default as InputToggle } from './components/InputToggle'; export { default as InputToggleWithErrors } from './components/InputToggleWithErrors'; export { default as Label } from './components/Label'; +export { default as LabelIconWrapper } from './components/LabelIconWrapper'; export { default as LeftMenu } from './components/LeftMenu'; export { default as LeftMenuList } from './components/LeftMenuList'; export { default as LiLink } from './components/LiLink'; diff --git a/packages/strapi-helper-plugin/package.json b/packages/strapi-helper-plugin/package.json index 86d46eac3c..53422861ee 100644 --- a/packages/strapi-helper-plugin/package.json +++ b/packages/strapi-helper-plugin/package.json @@ -50,12 +50,12 @@ "rollup-plugin-terser": "^4.0.4" }, "dependencies": { - "@buffetjs/core": "3.3.4", - "@buffetjs/custom": "3.3.4", - "@buffetjs/hooks": "3.3.4", - "@buffetjs/icons": "3.3.4", - "@buffetjs/styles": "3.3.4", - "@buffetjs/utils": "3.3.4", + "@buffetjs/core": "3.3.5-next.1", + "@buffetjs/custom": "3.3.5-next.1", + "@buffetjs/hooks": "3.3.5-next.1", + "@buffetjs/icons": "3.3.5-next.1", + "@buffetjs/styles": "3.3.5-next.1", + "@buffetjs/utils": "3.3.5-next.1", "bootstrap": "^4.5.3", "classnames": "^2.2.5", "immutable": "^3.8.2", diff --git a/packages/strapi-plugin-content-manager/admin/src/components/InputJSONWithErrors/index.js b/packages/strapi-plugin-content-manager/admin/src/components/InputJSONWithErrors/index.js index 6ac68ba165..35e71eef93 100644 --- a/packages/strapi-plugin-content-manager/admin/src/components/InputJSONWithErrors/index.js +++ b/packages/strapi-plugin-content-manager/admin/src/components/InputJSONWithErrors/index.js @@ -8,7 +8,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { isEmpty, isFunction } from 'lodash'; import cn from 'classnames'; - +import { LabelIconWrapper } from 'strapi-helper-plugin'; import { Description, ErrorMessage, Label } from '@buffetjs/styles'; import { Error } from '@buffetjs/core'; @@ -31,6 +31,7 @@ class InputJSONWithErrors extends React.Component { inputDescription, inputStyle, label, + labelIcon, name, onBlur, placeholder, @@ -52,7 +53,12 @@ class InputJSONWithErrors extends React.Component { - + - {inputLabel} + + {inputLabel} + {labelIcon && ( + {labelIcon.icon} + )} + }} description={description} contentTypeUID={currentContentTypeLayout.uid} customInputs={{ diff --git a/packages/strapi-plugin-content-manager/admin/src/components/WysiwygWithErrors/index.js b/packages/strapi-plugin-content-manager/admin/src/components/WysiwygWithErrors/index.js index 21665006da..77106e454f 100644 --- a/packages/strapi-plugin-content-manager/admin/src/components/WysiwygWithErrors/index.js +++ b/packages/strapi-plugin-content-manager/admin/src/components/WysiwygWithErrors/index.js @@ -8,10 +8,9 @@ import React from 'react'; import PropTypes from 'prop-types'; import { isEmpty, isFunction } from 'lodash'; import cn from 'classnames'; - import { Description, ErrorMessage, Label } from '@buffetjs/styles'; import { Error } from '@buffetjs/core'; - +import { LabelIconWrapper } from 'strapi-helper-plugin'; import Wysiwyg from '../Wysiwyg'; import Wrapper from './Wrapper'; @@ -28,6 +27,7 @@ class WysiwygWithErrors extends React.Component { inputDescription, inputStyle, label, + labelIcon, name, onBlur: handleBlur, onChange, @@ -50,7 +50,12 @@ class WysiwygWithErrors extends React.Component { className={`${cn(!isEmpty(className) && className)} ${hasError ? 'bordered' : ''}`} style={style} > - + { +const InputMedia = ({ + disabled, + label, + onChange, + name, + attribute, + value, + type, + id, + error, + labelIcon, +}) => { const [modal, setModal] = useState({ isOpen: false, step: 'list', @@ -117,7 +132,10 @@ const InputMedia = ({ disabled, label, onChange, name, attribute, value, type, i return ( - {`${label}${displaySlidePagination}`} + + {`${label}${displaySlidePagination}`} + {labelIcon && {labelIcon.icon}} + @@ -199,6 +217,10 @@ InputMedia.propTypes = { error: PropTypes.string, id: PropTypes.string, label: PropTypes.string, + labelIcon: PropTypes.shape({ + icon: PropTypes.any, + title: PropTypes.string, + }), name: PropTypes.string.isRequired, onChange: PropTypes.func.isRequired, type: PropTypes.string.isRequired, @@ -209,6 +231,7 @@ InputMedia.defaultProps = { id: null, error: null, label: '', + labelIcon: null, value: null, }; diff --git a/packages/strapi-plugin-upload/package.json b/packages/strapi-plugin-upload/package.json index 8f097488df..e58a81f795 100644 --- a/packages/strapi-plugin-upload/package.json +++ b/packages/strapi-plugin-upload/package.json @@ -12,12 +12,12 @@ "test": "echo \"no tests yet\"" }, "dependencies": { - "@buffetjs/core": "3.3.4", - "@buffetjs/custom": "3.3.4", - "@buffetjs/hooks": "3.3.4", - "@buffetjs/icons": "3.3.4", - "@buffetjs/styles": "3.3.4", - "@buffetjs/utils": "3.3.4", + "@buffetjs/core": "3.3.5-next.1", + "@buffetjs/custom": "3.3.5-next.1", + "@buffetjs/hooks": "3.3.5-next.1", + "@buffetjs/icons": "3.3.5-next.1", + "@buffetjs/styles": "3.3.5-next.1", + "@buffetjs/utils": "3.3.5-next.1", "byte-size": "^7.0.0", "cropperjs": "^1.5.6", "immer": "^8.0.1", diff --git a/packages/strapi-plugin-users-permissions/package.json b/packages/strapi-plugin-users-permissions/package.json index 290d7e99b6..2f59bf626a 100644 --- a/packages/strapi-plugin-users-permissions/package.json +++ b/packages/strapi-plugin-users-permissions/package.json @@ -12,12 +12,12 @@ "test": "echo \"no tests yet\"" }, "dependencies": { - "@buffetjs/core": "3.3.4", - "@buffetjs/custom": "3.3.4", - "@buffetjs/hooks": "3.3.4", - "@buffetjs/icons": "3.3.4", - "@buffetjs/styles": "3.3.4", - "@buffetjs/utils": "3.3.4", + "@buffetjs/core": "3.3.5-next.1", + "@buffetjs/custom": "3.3.5-next.1", + "@buffetjs/hooks": "3.3.5-next.1", + "@buffetjs/icons": "3.3.5-next.1", + "@buffetjs/styles": "3.3.5-next.1", + "@buffetjs/utils": "3.3.5-next.1", "@purest/providers": "^1.0.2", "bcryptjs": "^2.4.3", "grant-koa": "5.4.8", diff --git a/yarn.lock b/yarn.lock index edc0a1bd98..51f9ec07cc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1053,15 +1053,15 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@buffetjs/core@3.3.4": - version "3.3.4" - resolved "https://registry.yarnpkg.com/@buffetjs/core/-/core-3.3.4.tgz#eb7583ab953738027e21da40e0d35c81d6f624dd" - integrity sha512-KxxmkXjgRvkqVwW959Ie2BWRYAPtQQbPXYLMZ7tr0KmNs3Eug6ifahiVSw5izcjGSTWnnuA45MOVxWq7EP9D3w== +"@buffetjs/core@3.3.5-next.1": + version "3.3.5-next.1" + resolved "https://registry.yarnpkg.com/@buffetjs/core/-/core-3.3.5-next.1.tgz#ec34c66f19ac064b2174c7c82a0f7042bb1f7c7e" + integrity sha512-04RSVtAQVRunvYRXoAEIIR1PIopCB7UP7l+zAVGraQmsebAWRoFeMGRQtwAyfoOIYV1of5tGwXJGPtY6KSV7bw== dependencies: - "@buffetjs/hooks" "3.3.4" - "@buffetjs/icons" "3.3.4" - "@buffetjs/styles" "3.3.4" - "@buffetjs/utils" "3.3.4" + "@buffetjs/hooks" "3.3.5-next.1" + "@buffetjs/icons" "3.3.5-next.1" + "@buffetjs/styles" "3.3.5-next.1" + "@buffetjs/utils" "3.3.5-next.1" "@fortawesome/fontawesome-svg-core" "^1.2.25" "@fortawesome/free-regular-svg-icons" "^5.11.2" "@fortawesome/free-solid-svg-icons" "^5.11.2" @@ -1077,35 +1077,35 @@ react-with-direction "^1.3.1" reactstrap "^8.5.1" -"@buffetjs/custom@3.3.4": - version "3.3.4" - resolved "https://registry.yarnpkg.com/@buffetjs/custom/-/custom-3.3.4.tgz#d26b3abd885e3a9f53c33b9a508e44e1652649ca" - integrity sha512-So/VOcDRWzHJ0VVIlnRPuUvOLdzjPARClvtSVwwxPPXG510J0AawNdfvj54gokwYAZbblBp9V74s1b2w1fWTZw== +"@buffetjs/custom@3.3.5-next.1": + version "3.3.5-next.1" + resolved "https://registry.yarnpkg.com/@buffetjs/custom/-/custom-3.3.5-next.1.tgz#c0b0be1f5a712e9646765c7d840e7f1a08d4955a" + integrity sha512-RoaXMVjjeAvYfy9Jd8GtXDwD2CxDuIWyO3dJRTfxaOl5uTHTXqJ0jG1N8RKeVbceTk/4nIAKB32O8mmdLgcydg== dependencies: - "@buffetjs/core" "3.3.4" - "@buffetjs/styles" "3.3.4" - "@buffetjs/utils" "3.3.4" + "@buffetjs/core" "3.3.5-next.1" + "@buffetjs/styles" "3.3.5-next.1" + "@buffetjs/utils" "3.3.5-next.1" lodash "4.17.20" moment "^2.24.0" prop-types "^15.5.10" react-moment-proptypes "^1.7.0" -"@buffetjs/hooks@3.3.4": - version "3.3.4" - resolved "https://registry.yarnpkg.com/@buffetjs/hooks/-/hooks-3.3.4.tgz#2fd7622673a0a28177e910ad85ba9f1386e9c47f" - integrity sha512-HUdnzBFovEXWnIVgzts6DtPSEJEn55Ivbu6Xd8AXyZoz5xYTwhD5iCtif0CS5uEtqsXGOoc320kcbPrRn6wEgw== +"@buffetjs/hooks@3.3.5-next.1": + version "3.3.5-next.1" + resolved "https://registry.yarnpkg.com/@buffetjs/hooks/-/hooks-3.3.5-next.1.tgz#7b49def2bb282b1bc3b485bd5460b1fff6008ec1" + integrity sha512-uAE0yarlZBsrMwaILu0eLbdn7pHbfXBHt9G4kKVtCzYjd2hUxN08rF95MHMqZj9qSx0Z7vmsuW7CE0ehyIj0Mg== -"@buffetjs/icons@3.3.4": - version "3.3.4" - resolved "https://registry.yarnpkg.com/@buffetjs/icons/-/icons-3.3.4.tgz#21b46eea90db7a88b2b929bfed63099275ef068a" - integrity sha512-uIjpnydas3TkT+5MyH7y/zP5ny813OFE4Q3Gl0do1nITUdwrkZXqV9VvfYeDDoYoOURaLI5N6yfR/kW6qgV3Kw== +"@buffetjs/icons@3.3.5-next.1": + version "3.3.5-next.1" + resolved "https://registry.yarnpkg.com/@buffetjs/icons/-/icons-3.3.5-next.1.tgz#cfd18f00a997e8e0672908392e7b4fe39e05eea1" + integrity sha512-9Qy4XTriN8pse4VYiKi1+hZDE5Xt7tNJuQgsHglM0k+kuSJddLXX2bxcUR8y+CUOoX1PNh0vDvyNxwX5r7ZFHQ== dependencies: prop-types "^15.5.10" -"@buffetjs/styles@3.3.4": - version "3.3.4" - resolved "https://registry.yarnpkg.com/@buffetjs/styles/-/styles-3.3.4.tgz#41a024e6dab5ccb19d3b16e02491177c6dba7edf" - integrity sha512-nAGYnR17D0DhdKxMyWcmKD5UZN29xG99yGraBR/vJ50S5YqEgL0N248oxVghw3YMVF4sLxrKvFIFkTGPSiDfiw== +"@buffetjs/styles@3.3.5-next.1": + version "3.3.5-next.1" + resolved "https://registry.yarnpkg.com/@buffetjs/styles/-/styles-3.3.5-next.1.tgz#e37e9da1ee0168d0517476e208e8d904c5f391e0" + integrity sha512-1iNxv38WaUTyQ7eee7WgyPW9/B3df+8ezwrBanzFJ3y3LR6DKCU53wNE/p/CT9g8VQBQ89loWtkahLQpPL/WkA== dependencies: "@fortawesome/fontawesome-free" "^5.12.0" "@fortawesome/fontawesome-svg-core" "^1.2.22" @@ -1116,10 +1116,10 @@ react-dates "^21.1.0" react-tooltip "^4.2.11" -"@buffetjs/utils@3.3.4": - version "3.3.4" - resolved "https://registry.yarnpkg.com/@buffetjs/utils/-/utils-3.3.4.tgz#6f000d58349d82f8e672aa4053d8f361a1a8a829" - integrity sha512-65Z4wFrcjTsSHkVNCxhq0vHOAugct42hgkwcqGcDN42McX45cac0ul8lA6xzJmE5yaA1dzkflgYeFTERHZzjmw== +"@buffetjs/utils@3.3.5-next.1": + version "3.3.5-next.1" + resolved "https://registry.yarnpkg.com/@buffetjs/utils/-/utils-3.3.5-next.1.tgz#0038d4ce6e54cfddf16067190301046a93e5fb13" + integrity sha512-lXCA+QGC+b38lYf0t0yWmWQmfggJA0QSOyW3ZBBnWf4dJFGbqlOU4j2cZsCLw5Us4on3PwmTkCpcC+YehsxcUw== dependencies: lodash "4.17.20" yup "^0.27.0"