Repository: vazco/uniforms (ts)

Issue:
SemanticUI BoolField is missing wrapClassName
<!--
  Before you open an issue, please check if a similar one already exists or has been closed before.
  We will be grateful for using our reproduction sandbox available at
  https://codesandbox.io/s/github/vazco/uniforms/tree/master/reproductions
  whenever a code sample is presented for debugging purposes.
-->


Pull request description:
Update semantic BoolField (fixes #680, #681).
This pull request fixes #680 and #681 by introducing `wrapClassName` prop into `BoolField` and logic for adding _fitted_ class name  if `label` prop is falsy (instead of only if `label` is `undefined`, not passed). This last functionality differs from the one specified [here](https://react.semantic-ui.com/modules/checkbox/#variations-fitted).

Patch:
diff --git a/packages/uniforms-semantic/src/BoolField.tsx b/packages/uniforms-semantic/src/BoolField.tsx
index 14498580..3360c870 100644
--- a/packages/uniforms-semantic/src/BoolField.tsx
+++ b/packages/uniforms-semantic/src/BoolField.tsx
@@ -15,13 +15,21 @@ const Bool = ({
   required,
   showInlineError,
   value,
+  wrapClassName,
   ...props
 }) => (
   <div
     className={classnames(className, { disabled, error, required }, 'field')}
     {...filterDOMProps(props)}
   >
-    <div className="ui checkbox">
+    <div
+      className={classnames(
+        'ui',
+        wrapClassName,
+        !label && 'fitted',
+        'checkbox',
+      )}
+    >
       <input
         checked={value}
         className="hidden"
@@ -33,7 +41,7 @@ const Bool = ({
         type="checkbox"
       />
 
-      <label htmlFor={id}>{label}</label>
+      {!!label && <label htmlFor={id}>{label}</label>}
     </div>
 
     {!!(error && showInlineError) && (


Test patch:
diff --git a/packages/uniforms-semantic/__tests__/BoolField.tsx b/packages/uniforms-semantic/__tests__/BoolField.tsx
index b0e83b90..7095ce27 100644
--- a/packages/uniforms-semantic/__tests__/BoolField.tsx
+++ b/packages/uniforms-semantic/__tests__/BoolField.tsx
@@ -175,3 +175,26 @@ test('<BoolField> - renders correct error text (showInlineError=false)', () => {
       .text(),
   ).not.toBe('Error');
 });
+
+test('<BoolField> - renders with a custom wrapClassName', () => {
+  const element = <BoolField name="x" wrapClassName="test-class-name" />;
+  const wrapper = mount(element, createContext({ x: { type: String } }));
+
+  expect(wrapper.find('.ui.test-class-name')).toHaveLength(1);
+});
+
+test('<BoolField> - renders with a `fitted` className when `label` is disabled', () => {
+  const element = <BoolField name="x" />;
+  const wrapper = mount(element, createContext({ x: { type: String } }));
+
+  const found = wrapper.find('.ui');
+  expect(found.hasClass('fitted')).toEqual(true);
+});
+
+test('<BoolField> - renders without a `fitted` className when `label` is enabled', () => {
+  const element = <BoolField name="x" label />;
+  const wrapper = mount(element, createContext({ x: { type: String } }));
+
+  const found = wrapper.find('.ui');
+  expect(found.hasClass('fitted')).toEqual(false);
+});