From ed96cbf3701b2241236df3ba423e2af9768e1175 Mon Sep 17 00:00:00 2001 From: Jacques Date: Wed, 5 Aug 2020 20:54:07 +0200 Subject: [PATCH 1/7] fix: docs --- docs/themes/semantic-ui/uiSchema.md | 2 +- packages/semantic-ui/test/util.test.js | 60 ++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 packages/semantic-ui/test/util.test.js diff --git a/docs/themes/semantic-ui/uiSchema.md b/docs/themes/semantic-ui/uiSchema.md index c742a8345a..91dc5706a6 100644 --- a/docs/themes/semantic-ui/uiSchema.md +++ b/docs/themes/semantic-ui/uiSchema.md @@ -106,7 +106,7 @@ wrapLabel: wrap all labels in a div, for custom styling via CSS ```jsx
{ + + describe("getSemanticProps", () => { + + test("defaultSchemaProps should be returned", () => { + const uiSchema = { + "ui:options": { + } + }; + expect(getSemanticProps({ uiSchema, defaultSchemaProps:{ wrapItem: false , horizontalButtons: true } })).toEqual({ + "wrapItem": false, + "horizontalButtons": true + }); + }); + + test("semantic props if passed should overwrite defaultSchemaProps", () => { + const uiSchema = { + "ui:options": { + "semantic": { + "wrapItem": true, + "horizontalButtons": true + } + } + }; + expect(getSemanticProps({ uiSchema, defaultSchemaProps:{ wrapItem: false , horizontalButtons: true } })).toEqual({ + "wrapItem": true, + "horizontalButtons": true + }); + }); + }); + + describe("getSemanticErrorProps", () => { + test("default semantic errorOptions props should be returned", () => { + const uiSchema = { + "ui:options": { + } + }; + expect(getSemanticErrorProps({ uiSchema })).toEqual({ + size: 'small', pointing:'above' + }); + }); + + test("semantic errorOptions props if passed should overwrite defaultSchemaProps", () => { + const uiSchema = { + "ui:options": { + semantic: { + errorOptions: { 'size': 'large' } + } + } + }; + expect(getSemanticErrorProps({ uiSchema })).toEqual({ + 'size': 'large', + }); + }); + }); + +}); From e4c9d46daa180daa5036345e3a02e07a2ac5c3ea Mon Sep 17 00:00:00 2001 From: Jacques Date: Wed, 5 Aug 2020 20:58:53 +0200 Subject: [PATCH 2/7] update: custom fields --- .../src/DateTimeWidget/DateTimeWidget.js | 62 +++++++++++++++ .../semantic-ui/src/DateTimeWidget/index.js | 2 + .../semantic-ui/src/DateWidget/DateWidget.js | 60 ++++++++++++++ packages/semantic-ui/src/DateWidget/index.js | 2 + .../src/EmailWidget/EmailWidget.js | 78 +++++++++++++++++++ packages/semantic-ui/src/EmailWidget/index.js | 2 + .../src/SubmitButton/SubmitButton.js | 4 + .../semantic-ui/src/SubmitButton/index.js | 2 + .../semantic-ui/src/URLWidget/URLWidget.js | 62 +++++++++++++++ packages/semantic-ui/src/URLWidget/index.js | 2 + packages/semantic-ui/src/Widgets/Widgets.js | 9 ++- packages/semantic-ui/src/util.js | 55 +++++++++++-- 12 files changed, 331 insertions(+), 9 deletions(-) create mode 100644 packages/semantic-ui/src/DateTimeWidget/DateTimeWidget.js create mode 100644 packages/semantic-ui/src/DateTimeWidget/index.js create mode 100644 packages/semantic-ui/src/DateWidget/DateWidget.js create mode 100644 packages/semantic-ui/src/DateWidget/index.js create mode 100644 packages/semantic-ui/src/EmailWidget/EmailWidget.js create mode 100644 packages/semantic-ui/src/EmailWidget/index.js create mode 100644 packages/semantic-ui/src/SubmitButton/SubmitButton.js create mode 100644 packages/semantic-ui/src/SubmitButton/index.js create mode 100644 packages/semantic-ui/src/URLWidget/URLWidget.js create mode 100644 packages/semantic-ui/src/URLWidget/index.js diff --git a/packages/semantic-ui/src/DateTimeWidget/DateTimeWidget.js b/packages/semantic-ui/src/DateTimeWidget/DateTimeWidget.js new file mode 100644 index 0000000000..4ce2711642 --- /dev/null +++ b/packages/semantic-ui/src/DateTimeWidget/DateTimeWidget.js @@ -0,0 +1,62 @@ +/* eslint-disable react/prop-types */ +import React from "react"; +import { utils } from "@rjsf/core"; +import { getSemanticProps } from "../util"; +import { Form } from "semantic-ui-react"; + +const { localToUTC, utcToLocal, getDisplayLabel } = utils; + +function DateTimeWidget(props) { + const { + id, + required, + readonly, + disabled, + name, + label, + schema, + uiSchema, + value, + onChange, + onBlur, + onFocus, + autofocus, + options, + formContext, + } = props; + const semanticProps = getSemanticProps({ + uiSchema, + schema, + formContext, + options, + defaultSchemaProps: {}, + }); + const _onChange = ({ target: { value } }) => onChange && onChange(localToUTC(value)); + const _onBlur = () => onBlur && onBlur(id, value); + const _onFocus = () => onFocus && onFocus(id, value); + const dateValue = utcToLocal(value); + const displayLabel = getDisplayLabel( + schema, + uiSchema + /* TODO: , rootSchema */ + ); + return ( + + ); +} + +export default DateTimeWidget; diff --git a/packages/semantic-ui/src/DateTimeWidget/index.js b/packages/semantic-ui/src/DateTimeWidget/index.js new file mode 100644 index 0000000000..0db366167f --- /dev/null +++ b/packages/semantic-ui/src/DateTimeWidget/index.js @@ -0,0 +1,2 @@ +export { default } from './DateTimeWidget'; +export * from './DateTimeWidget'; diff --git a/packages/semantic-ui/src/DateWidget/DateWidget.js b/packages/semantic-ui/src/DateWidget/DateWidget.js new file mode 100644 index 0000000000..69f0815a80 --- /dev/null +++ b/packages/semantic-ui/src/DateWidget/DateWidget.js @@ -0,0 +1,60 @@ +/* eslint-disable react/prop-types */ +import React from "react"; +import { getSemanticProps } from "../util"; +import { Form } from "semantic-ui-react"; +import { utils } from "@rjsf/core"; + +const { getDisplayLabel } = utils; +function DateWidget(props) { + const { + id, + required, + readonly, + disabled, + name, + label, + value, + onChange, + onBlur, + onFocus, + autofocus, + options, + formContext, + schema, + uiSchema, + } = props; + const semanticProps = getSemanticProps({ + uiSchema, + schema, + formContext, + options, + defaultSchemaProps: {}, + }); + const _onChange = ({ target: { value } }) => onChange && onChange(value); + const _onBlur = () => onBlur && onBlur(id, value); + const _onFocus = () => onFocus && onFocus(id, value); + const displayLabel = getDisplayLabel( + schema, + uiSchema + /* TODO: , rootSchema */ + ); + return ( + + ); +} + +export default DateWidget; diff --git a/packages/semantic-ui/src/DateWidget/index.js b/packages/semantic-ui/src/DateWidget/index.js new file mode 100644 index 0000000000..923b0077fb --- /dev/null +++ b/packages/semantic-ui/src/DateWidget/index.js @@ -0,0 +1,2 @@ +export { default } from './DateWidget'; +export * from './DateWidget'; diff --git a/packages/semantic-ui/src/EmailWidget/EmailWidget.js b/packages/semantic-ui/src/EmailWidget/EmailWidget.js new file mode 100644 index 0000000000..cbf9fc988e --- /dev/null +++ b/packages/semantic-ui/src/EmailWidget/EmailWidget.js @@ -0,0 +1,78 @@ +import React from "react"; +import PropTypes from "prop-types"; +import { Form } from "semantic-ui-react"; +import { getSemanticProps } from "../util"; +import { utils } from "@rjsf/core"; + +const { getDisplayLabel } = utils; +function EmailWidget(props) { + const { + id, + required, + readonly, + disabled, + name, + label, + schema, + uiSchema, + value, + onChange, + onBlur, + onFocus, + autofocus, + options, + formContext, + } = props; + const semanticProps = getSemanticProps({ + schema, + uiSchema, + formContext, + options, + defaultSchemaProps:{ + inverted: false, + fluid: true, + } + }); + // eslint-disable-next-line no-shadow + const _onChange = ({ target: { value } }) => + onChange(value === "" ? options.emptyValue : value); + const _onBlur = () => onBlur && onBlur(id, value); + const _onFocus = () => onFocus && onFocus(id, value); + const displayLabel = getDisplayLabel( + schema, + uiSchema + /* TODO: , rootSchema */ + ); + return ( + + ); +} + +EmailWidget.defaultProps = { + options: { + semantic: { + fluid: true, + inverted: false, + }, + }, +}; + +EmailWidget.propTypes = { + options: PropTypes.object, +}; + +export default EmailWidget; diff --git a/packages/semantic-ui/src/EmailWidget/index.js b/packages/semantic-ui/src/EmailWidget/index.js new file mode 100644 index 0000000000..c48979eea8 --- /dev/null +++ b/packages/semantic-ui/src/EmailWidget/index.js @@ -0,0 +1,2 @@ +export { default } from './EmailWidget'; +export * from './EmailWidget'; diff --git a/packages/semantic-ui/src/SubmitButton/SubmitButton.js b/packages/semantic-ui/src/SubmitButton/SubmitButton.js new file mode 100644 index 0000000000..afab81e7fb --- /dev/null +++ b/packages/semantic-ui/src/SubmitButton/SubmitButton.js @@ -0,0 +1,4 @@ +import React from "react"; +import { Button } from "semantic-ui-react"; +export default () => ( - + `; @@ -68,7 +67,7 @@ exports[`array fields checkboxes 1`] = ` aria-expanded={false} aria-multiselectable={true} autoFocus={false} - className="ui fluid multiple selection scrolling dropdown" + className="ui multiple selection scrolling dropdown" inverted="false" onBlur={[Function]} onChange={[Function]} @@ -155,14 +154,13 @@ exports[`array fields checkboxes 1`] = ` -
- -
+ `; @@ -270,13 +268,12 @@ exports[`array fields fixed array 1`] = ` -
- -
+ `; diff --git a/packages/semantic-ui/test/__snapshots__/Form.test.js.snap b/packages/semantic-ui/test/__snapshots__/Form.test.js.snap index dcd22da680..0d7581fed2 100644 --- a/packages/semantic-ui/test/__snapshots__/Form.test.js.snap +++ b/packages/semantic-ui/test/__snapshots__/Form.test.js.snap @@ -9,14 +9,13 @@ exports[`single fields null field 1`] = `
-
- -
+ `; @@ -48,14 +47,13 @@ exports[`single fields number field 1`] = `
-
- -
+ `; @@ -81,14 +79,13 @@ exports[`single fields string field format data-url 1`] = `

-
- -
+ `; @@ -101,30 +98,32 @@ exports[`single fields string field format email 1`] = `
- -
-
- +
+ +
+
+ `; @@ -137,30 +136,32 @@ exports[`single fields string field format uri 1`] = `
- -
-
- +
+ +
+
+ `; @@ -192,14 +193,13 @@ exports[`single fields string field regular 1`] = ` -
- -
+ `; @@ -235,13 +235,12 @@ exports[`single fields unsupported field 1`] = ` -
- -
+ `; diff --git a/packages/semantic-ui/test/__snapshots__/Object.test.js.snap b/packages/semantic-ui/test/__snapshots__/Object.test.js.snap index 3b59e747c4..f2a7618faf 100644 --- a/packages/semantic-ui/test/__snapshots__/Object.test.js.snap +++ b/packages/semantic-ui/test/__snapshots__/Object.test.js.snap @@ -66,13 +66,12 @@ exports[`object fields object 1`] = ` -
- -
+ `; diff --git a/packages/semantic-ui/test/util.test.js b/packages/semantic-ui/test/util.test.js index d15e55c409..066415b627 100644 --- a/packages/semantic-ui/test/util.test.js +++ b/packages/semantic-ui/test/util.test.js @@ -1,4 +1,4 @@ -const { getSemanticProps,getSemanticErrorProps } = require("../src/util"); +import { getSemanticProps,getSemanticErrorProps } from '../src/util'; describe("util js functions", () => { From cc640d106f50e8946b5871383e9856c277fd2da5 Mon Sep 17 00:00:00 2001 From: Jacques Date: Wed, 12 Aug 2020 19:26:35 +0200 Subject: [PATCH 5/7] update: select widget label --- packages/semantic-ui/src/SelectWidget/SelectWidget.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/semantic-ui/src/SelectWidget/SelectWidget.js b/packages/semantic-ui/src/SelectWidget/SelectWidget.js index b6a734ae48..db13527371 100644 --- a/packages/semantic-ui/src/SelectWidget/SelectWidget.js +++ b/packages/semantic-ui/src/SelectWidget/SelectWidget.js @@ -66,6 +66,7 @@ function SelectWidget(props) { id, options, name, + label, required, disabled, readonly, @@ -107,10 +108,12 @@ function SelectWidget(props) { // eslint-disable-next-line no-shadow target: { value }, }) => onFocus && onFocus(id, processValue(schema, value)); + return ( Date: Mon, 14 Sep 2020 12:37:03 +0200 Subject: [PATCH 6/7] update: formContext props override others update: semantic --- .../themes/semantic-ui/uiSchema.md | 1 - packages/semantic-ui/package-lock.json | 12 +++++----- packages/semantic-ui/package.json | 4 ++-- packages/semantic-ui/src/util.js | 15 +++++++++--- packages/semantic-ui/test/util.test.js | 24 +++++++++++++++++++ 5 files changed, 44 insertions(+), 12 deletions(-) diff --git a/docs/api-reference/themes/semantic-ui/uiSchema.md b/docs/api-reference/themes/semantic-ui/uiSchema.md index 91dc5706a6..bc3f8fb257 100644 --- a/docs/api-reference/themes/semantic-ui/uiSchema.md +++ b/docs/api-reference/themes/semantic-ui/uiSchema.md @@ -110,7 +110,6 @@ wrapLabel: wrap all labels in a div, for custom styling via CSS "wrapLabel": true, "wrapContent": true } - uiSchema={uiSchema} // other props... }} /> diff --git a/packages/semantic-ui/package-lock.json b/packages/semantic-ui/package-lock.json index 260668383c..849310d802 100644 --- a/packages/semantic-ui/package-lock.json +++ b/packages/semantic-ui/package-lock.json @@ -3745,9 +3745,9 @@ } }, "@rjsf/core": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/@rjsf/core/-/core-2.2.2.tgz", - "integrity": "sha512-4d6DHIiTJEkUq5vyl4LIxLGIYYKKnHcprf94oVchUtGQvRFjNUDFxeFQoyr90oaxcBMs2WDDcCgjcFaKVyfErg==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@rjsf/core/-/core-2.4.0.tgz", + "integrity": "sha512-8zlydBkGldOxGXFEwNGFa1gzTxpcxaYn7ofegcu8XHJ7IKMCfpnU3ABg+H3eml1KZCX3FODmj1tHFJKuTmfynw==", "dev": true, "requires": { "@babel/runtime-corejs2": "^7.8.7", @@ -3764,9 +3764,9 @@ }, "dependencies": { "ajv": { - "version": "6.12.3", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.3.tgz", - "integrity": "sha512-4K0cK3L1hsqk9xIb2z9vs/XU+PGJZ9PNpJRDS9YLzmNdX6jmVPfamLvTJr0aDAusnHyCHO6MjzlkAsgtqp9teA==", + "version": "6.12.5", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.5.tgz", + "integrity": "sha512-lRF8RORchjpKG50/WFf8xmg7sgCLFiYNNnqdKflk63whMQcWR5ngGjiSXkL9bjxy6B2npOK2HSMN49jEBMSkag==", "dev": true, "requires": { "fast-deep-equal": "^3.1.1", diff --git a/packages/semantic-ui/package.json b/packages/semantic-ui/package.json index 3be6add0d2..639fdba118 100644 --- a/packages/semantic-ui/package.json +++ b/packages/semantic-ui/package.json @@ -31,8 +31,8 @@ "@rjsf/core": "^2.0.0", "lodash": "^4.17.15", "react": ">=16", - "semantic-ui-css": "^2.4.1", - "semantic-ui-react": "^0.87.3", + "semantic-ui-css": "2.4.1", + "semantic-ui-react": "1.2.1", "shortid": "^2.2.14" }, "devDependencies": { diff --git a/packages/semantic-ui/src/util.js b/packages/semantic-ui/src/util.js index f4dee505fc..4d1bdfd808 100644 --- a/packages/semantic-ui/src/util.js +++ b/packages/semantic-ui/src/util.js @@ -22,12 +22,21 @@ export function getSemanticProps({ const hasFormContextProps = formContext.semantic ? true : false; const hasSchemaProps = uiSchema["ui:options"] && uiSchema["ui:options"].semantic ? true : false; const hasOptionsProps = options.semantic ? true : false; + const formContextProps = hasFormContextProps ? formContext.semantic : defaultContextProps; + let schemaProps = hasSchemaProps ? uiSchema["ui:options"].semantic : defaultSchemaProps; + let optionProps = hasOptionsProps ? options.semantic : {}; + // formContext props should overide other props + if (hasFormContextProps){ + Object.keys(formContext.semantic).map((key) => { + optionProps[key] = formContext.semantic[key]; + }); + } return Object.assign( {}, - hasFormContextProps ? formContext.semantic : defaultContextProps, - hasSchemaProps ? uiSchema["ui:options"].semantic : defaultSchemaProps, - hasOptionsProps ? options.semantic : {}, + formContextProps, + schemaProps, + optionProps, ); } diff --git a/packages/semantic-ui/test/util.test.js b/packages/semantic-ui/test/util.test.js index 066415b627..c25cf5c432 100644 --- a/packages/semantic-ui/test/util.test.js +++ b/packages/semantic-ui/test/util.test.js @@ -30,6 +30,30 @@ describe("util js functions", () => { "horizontalButtons": true }); }); + + + test("formContext semantic props if passed should overwrite ui:options", () => { + const uiSchema = { + "ui:options": { + "semantic": { + "wrapItem": true, + "inverted": false, + "horizontalButtons": false + } + } + }; + const formContext = { semantic:{ + "inverted": true, + "horizontalButtons": true + } + }; + expect(getSemanticProps({ uiSchema,formContext, defaultSchemaProps:{ wrapItem: false , horizontalButtons: true } })).toEqual({ + "wrapItem": true, + "inverted": true, + "horizontalButtons": true + }); + }); + }); describe("getSemanticErrorProps", () => { From 9f54345469bfe3ce06ad63fa31ec4918932526b3 Mon Sep 17 00:00:00 2001 From: Jacques Nel Date: Mon, 1 Feb 2021 11:15:52 +0200 Subject: [PATCH 7/7] remove unused type prop --- packages/semantic-ui/src/TextWidget/TextWidget.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/semantic-ui/src/TextWidget/TextWidget.js b/packages/semantic-ui/src/TextWidget/TextWidget.js index ea359b5112..e49ce5c639 100644 --- a/packages/semantic-ui/src/TextWidget/TextWidget.js +++ b/packages/semantic-ui/src/TextWidget/TextWidget.js @@ -19,7 +19,6 @@ function TextWidget(props) { onFocus, autofocus, options, - type, schema, uiSchema, formContext,