@toptal/picasso-form 4.1.2 → 4.1.3

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.
@@ -13,6 +13,10 @@ export interface Props extends StandardProps, TextLabelProps, FormControlLabelAt
13
13
  disabled?: boolean;
14
14
  /** Whether to show asterisk or (optional) postfix as a 'required' decoration */
15
15
  requiredDecoration?: RequiredDecoration;
16
+ classes?: {
17
+ root?: string;
18
+ label?: string;
19
+ };
16
20
  }
17
21
  declare const FormControlLabel: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLLabelElement>>;
18
22
  export default FormControlLabel;
@@ -1 +1 @@
1
- {"version":3,"file":"FormControlLabel.d.ts","sourceRoot":"","sources":["../../../src/FormControlLabel/FormControlLabel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAA;AACzE,OAAO,KAAqB,MAAM,OAAO,CAAA;AACzC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAA;AAG/E,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAG3E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAKtD,oBAAY,8BAA8B,GACxC,mBAAmB,CAAC,gBAAgB,CAAC,GACnC,IAAI,CAAC,qBAAqB,EAAE,UAAU,CAAC,CAAA;AAE3C,MAAM,WAAW,KACf,SAAQ,aAAa,EACnB,cAAc,EACd,8BAA8B;IAChC,0EAA0E;IAC1E,OAAO,EAAE,YAAY,CAAA;IACrB,wDAAwD;IACxD,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,gFAAgF;IAChF,kBAAkB,CAAC,EAAE,kBAAkB,CAAA;CACxC;AAMD,QAAA,MAAM,gBAAgB,gFA+CrB,CAAA;AAID,eAAe,gBAAgB,CAAA"}
1
+ {"version":3,"file":"FormControlLabel.d.ts","sourceRoot":"","sources":["../../../src/FormControlLabel/FormControlLabel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAA;AACzE,OAAO,KAAqB,MAAM,OAAO,CAAA;AACzC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAA;AAC/E,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAG3E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAItD,oBAAY,8BAA8B,GACxC,mBAAmB,CAAC,gBAAgB,CAAC,GACnC,IAAI,CAAC,qBAAqB,EAAE,UAAU,CAAC,CAAA;AAE3C,MAAM,WAAW,KACf,SAAQ,aAAa,EACnB,cAAc,EACd,8BAA8B;IAChC,0EAA0E;IAC1E,OAAO,EAAE,YAAY,CAAA;IACrB,wDAAwD;IACxD,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,gFAAgF;IAChF,kBAAkB,CAAC,EAAE,kBAAkB,CAAA;IACvC,OAAO,CAAC,EAAE;QACR,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,KAAK,CAAC,EAAE,MAAM,CAAA;KACf,CAAA;CACF;AAED,QAAA,MAAM,gBAAgB,gFA+CrB,CAAA;AAID,eAAe,gBAAgB,CAAA"}
@@ -10,27 +10,16 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import React, { forwardRef } from 'react';
13
- import { makeStyles } from '@material-ui/core/styles';
14
- import cx from 'classnames';
15
- import styles from './styles';
13
+ import { twMerge } from '@toptal/picasso-tailwind-merge';
16
14
  import { FormCompound as Form } from '../FormCompound';
17
15
  import { useFieldsLayoutContext } from '../FieldsLayout';
18
- const useStyles = makeStyles(styles, {
19
- name: 'PicassoFormControlLabel',
20
- });
21
16
  const FormControlLabel = forwardRef(function FormControlLabel(props, ref) {
22
- const { control, label, className, style, disabled, requiredDecoration, titleCase,
23
- // Avoid passing external classes inside the rest props
24
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
25
- classes: externalClasses } = props, rest = __rest(props, ["control", "label", "className", "style", "disabled", "requiredDecoration", "titleCase", "classes"]);
26
- const classes = useStyles(props);
17
+ const { control, label, className, style, disabled, requiredDecoration, titleCase, classes } = props, rest = __rest(props, ["control", "label", "className", "style", "disabled", "requiredDecoration", "titleCase", "classes"]);
27
18
  const { layout } = useFieldsLayoutContext();
28
- return (React.createElement("label", Object.assign({}, rest, { ref: ref, className: cx(classes.root, {
29
- [classes.disabled]: disabled,
30
- [classes.horizontalLayout]: layout === 'horizontal',
31
- }, className), style: style }),
19
+ const isHorizontalLayout = layout === 'horizontal';
20
+ return (React.createElement("label", Object.assign({}, rest, { ref: ref, className: twMerge('inline-flex items-center', 'max-w-full', 'align-middle', '-webkit-tap-highlight-color-transparent', 'mx-0', disabled ? 'cursor-default' : 'cursor-pointer', isHorizontalLayout && 'col-start-1 col-span-2', classes === null || classes === void 0 ? void 0 : classes.root, className), style: style }),
32
21
  React.cloneElement(control, { disabled }),
33
- React.createElement(Form.Label, { className: classes.label, as: 'span', requiredDecoration: requiredDecoration, disabled: disabled, titleCase: titleCase }, label)));
22
+ React.createElement(Form.Label, { className: twMerge(disabled && 'pointer-events-auto', classes === null || classes === void 0 ? void 0 : classes.label), as: 'span', requiredDecoration: requiredDecoration, disabled: disabled, titleCase: titleCase }, label)));
34
23
  });
35
24
  FormControlLabel.displayName = 'FormControlLabel';
36
25
  export default FormControlLabel;
@@ -1 +1 @@
1
- {"version":3,"file":"FormControlLabel.js","sourceRoot":"","sources":["../../../src/FormControlLabel/FormControlLabel.tsx"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EA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AClB,SAAS,EAAE,SAAS,IAEnB,KAAK,CACK,CACP,CACT,CAAA;AACH,CAAC,CACF,CAAA;AAED,gBAAgB,CAAC,WAAW,GAAG,kBAAkB,CAAA;AAEjD,eAAe,gBAAgB,CAAA"}
1
+ {"version":3,"file":"FormControlLabel.js","sourceRoot":"","sources":["../../../src/FormControlLabel/FormControlLabel.tsx"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAGzC,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAA;AAGxD,OAAO,EAAE,YAAY,IAAI,IAAI,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAwBxD,MAAM,gBAAgB,GAAG,UAAU,CACjC,SAAS,gBAAgB,CAAC,KAAK,EAAE,GAAG;IAClC,MAAM,EACJ,OAAO,EACP,KAAK,EACL,SAAS,EACT,KAAK,EACL,QAAQ,EACR,kBAAkB,EAClB,SAAS,EACT,OAAO,KAEL,KAAK,EADJ,IAAI,UACL,KAAK,EAVH,oGAUL,CAAQ,CAAA;IAET,MAAM,EAAE,MAAM,EAAE,GAAG,sBAAsB,EAAE,CAAA;IAC3C,MAAM,kBAAkB,GAAG,MAAM,KAAK,YAAY,CAAA;IAElD,OAAO,CACL,+CACM,IAAI,IACR,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,OAAO,CAChB,0BAA0B,EAC1B,YAAY,EACZ,cAAc,EACd,yCAAyC,EACzC,MAAM,EACN,QAAQ,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,gBAAgB,EAC9C,kBAAkB,IAAI,wBAAwB,EAC9C,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,EACb,SAAS,CACV,EACD,KAAK,EAAE,KAAK;QAEX,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,CAAC;QAC1C,oBAAC,IAAI,CAAC,KAAK,IACT,SAAS,EAAE,OAAO,CAAC,QAAQ,IAAI,qBAAqB,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,CAAC,EACrE,EAAE,EAAC,MAAM,EACT,kBAAkB,EAAE,kBAAkB,EACtC,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,IAEnB,KAAK,CACK,CACP,CACT,CAAA;AACH,CAAC,CACF,CAAA;AAED,gBAAgB,CAAC,WAAW,GAAG,kBAAkB,CAAA;AAEjD,eAAe,gBAAgB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toptal/picasso-form",
3
- "version": "4.1.2",
3
+ "version": "4.1.3",
4
4
  "description": "Toptal UI components library - Form",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -1,13 +1,10 @@
1
1
  import type { ReactElement, ReactNode, LabelHTMLAttributes } from 'react'
2
2
  import React, { forwardRef } from 'react'
3
3
  import type { FormControlLabelProps } from '@material-ui/core/FormControlLabel'
4
- import type { Theme } from '@material-ui/core/styles'
5
- import { makeStyles } from '@material-ui/core/styles'
6
4
  import type { StandardProps, TextLabelProps } from '@toptal/picasso-shared'
7
- import cx from 'classnames'
5
+ import { twMerge } from '@toptal/picasso-tailwind-merge'
8
6
 
9
7
  import type { RequiredDecoration } from '../FormLabel'
10
- import styles from './styles'
11
8
  import { FormCompound as Form } from '../FormCompound'
12
9
  import { useFieldsLayoutContext } from '../FieldsLayout'
13
10
 
@@ -27,12 +24,12 @@ export interface Props
27
24
  disabled?: boolean
28
25
  /** Whether to show asterisk or (optional) postfix as a 'required' decoration */
29
26
  requiredDecoration?: RequiredDecoration
27
+ classes?: {
28
+ root?: string
29
+ label?: string
30
+ }
30
31
  }
31
32
 
32
- const useStyles = makeStyles<Theme, Props>(styles, {
33
- name: 'PicassoFormControlLabel',
34
- })
35
-
36
33
  const FormControlLabel = forwardRef<HTMLLabelElement, Props>(
37
34
  function FormControlLabel(props, ref) {
38
35
  const {
@@ -43,33 +40,33 @@ const FormControlLabel = forwardRef<HTMLLabelElement, Props>(
43
40
  disabled,
44
41
  requiredDecoration,
45
42
  titleCase,
46
- // Avoid passing external classes inside the rest props
47
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
48
- classes: externalClasses,
43
+ classes,
49
44
  ...rest
50
45
  } = props
51
46
 
52
- const classes = useStyles(props)
53
-
54
47
  const { layout } = useFieldsLayoutContext()
48
+ const isHorizontalLayout = layout === 'horizontal'
55
49
 
56
50
  return (
57
51
  <label
58
52
  {...rest}
59
53
  ref={ref}
60
- className={cx(
61
- classes.root,
62
- {
63
- [classes.disabled]: disabled,
64
- [classes.horizontalLayout]: layout === 'horizontal',
65
- },
54
+ className={twMerge(
55
+ 'inline-flex items-center',
56
+ 'max-w-full',
57
+ 'align-middle',
58
+ '-webkit-tap-highlight-color-transparent',
59
+ 'mx-0',
60
+ disabled ? 'cursor-default' : 'cursor-pointer',
61
+ isHorizontalLayout && 'col-start-1 col-span-2',
62
+ classes?.root,
66
63
  className
67
64
  )}
68
65
  style={style}
69
66
  >
70
67
  {React.cloneElement(control, { disabled })}
71
68
  <Form.Label
72
- className={classes.label}
69
+ className={twMerge(disabled && 'pointer-events-auto', classes?.label)}
73
70
  as='span'
74
71
  requiredDecoration={requiredDecoration}
75
72
  disabled={disabled}
@@ -1,3 +0,0 @@
1
- declare const _default: () => import("@material-ui/styles").StyleRules<{}, "label" | "disabled" | "root" | "horizontalLayout">;
2
- export default _default;
3
- //# sourceMappingURL=styles.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/FormControlLabel/styles.ts"],"names":[],"mappings":";AA4BA,wBA0BI"}
@@ -1,50 +0,0 @@
1
- import { createStyles } from '@material-ui/core/styles';
2
- import { PicassoProvider } from '@toptal/picasso-provider';
3
- PicassoProvider.override(({ palette, typography }) => ({
4
- MuiFormControlLabel: {
5
- root: {
6
- marginLeft: 0,
7
- marginRight: 0,
8
- },
9
- label: {
10
- display: 'inline-flex',
11
- alignItems: 'center',
12
- fontSize: '1em',
13
- color: palette.text.primary,
14
- lineHeight: '1.5em',
15
- fontWeight: typography.fontWeights.regular,
16
- cursor: 'pointer',
17
- userSelect: 'none',
18
- '&$disabled': {
19
- pointerEvents: 'auto',
20
- },
21
- },
22
- },
23
- }));
24
- export default () => createStyles({
25
- root: {
26
- display: 'inline-flex',
27
- alignItems: 'center',
28
- cursor: 'pointer',
29
- // For ellipsis
30
- maxWidth: '100%',
31
- // For correct alignment with the text.
32
- verticalAlign: 'middle',
33
- WebkitTapHighlightColor: 'transparent',
34
- '&$disabled': {
35
- cursor: 'default',
36
- },
37
- marginLeft: 0,
38
- marginRight: 0,
39
- },
40
- label: {
41
- '&$disabled': {
42
- pointerEvents: 'auto',
43
- },
44
- },
45
- disabled: {},
46
- horizontalLayout: {
47
- gridColumn: '1 / span 2',
48
- },
49
- });
50
- //# sourceMappingURL=styles.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/FormControlLabel/styles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAE1D,eAAe,CAAC,QAAQ,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,EAAS,EAAE,EAAE,CAAC,CAAC;IAC5D,mBAAmB,EAAE;QACnB,IAAI,EAAE;YACJ,UAAU,EAAE,CAAC;YACb,WAAW,EAAE,CAAC;SACf;QACD,KAAK,EAAE;YACL,OAAO,EAAE,aAAa;YACtB,UAAU,EAAE,QAAQ;YAEpB,QAAQ,EAAE,KAAK;YACf,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO;YAC3B,UAAU,EAAE,OAAO;YACnB,UAAU,EAAE,UAAU,CAAC,WAAW,CAAC,OAAO;YAC1C,MAAM,EAAE,SAAS;YACjB,UAAU,EAAE,MAAM;YAElB,YAAY,EAAE;gBACZ,aAAa,EAAE,MAAM;aACtB;SACF;KACF;CACF,CAAC,CAAC,CAAA;AAEH,eAAe,GAAG,EAAE,CAClB,YAAY,CAAC;IACX,IAAI,EAAE;QACJ,OAAO,EAAE,aAAa;QACtB,UAAU,EAAE,QAAQ;QACpB,MAAM,EAAE,SAAS;QACjB,eAAe;QACf,QAAQ,EAAE,MAAM;QAChB,uCAAuC;QACvC,aAAa,EAAE,QAAQ;QACvB,uBAAuB,EAAE,aAAa;QACtC,YAAY,EAAE;YACZ,MAAM,EAAE,SAAS;SAClB;QACD,UAAU,EAAE,CAAC;QACb,WAAW,EAAE,CAAC;KACf;IACD,KAAK,EAAE;QACL,YAAY,EAAE;YACZ,aAAa,EAAE,MAAM;SACtB;KACF;IACD,QAAQ,EAAE,EAAE;IACZ,gBAAgB,EAAE;QAChB,UAAU,EAAE,YAAY;KACzB;CACF,CAAC,CAAA"}
@@ -1,55 +0,0 @@
1
- import type { Theme } from '@material-ui/core/styles'
2
- import { createStyles } from '@material-ui/core/styles'
3
- import { PicassoProvider } from '@toptal/picasso-provider'
4
-
5
- PicassoProvider.override(({ palette, typography }: Theme) => ({
6
- MuiFormControlLabel: {
7
- root: {
8
- marginLeft: 0,
9
- marginRight: 0,
10
- },
11
- label: {
12
- display: 'inline-flex',
13
- alignItems: 'center',
14
-
15
- fontSize: '1em',
16
- color: palette.text.primary,
17
- lineHeight: '1.5em',
18
- fontWeight: typography.fontWeights.regular,
19
- cursor: 'pointer',
20
- userSelect: 'none',
21
-
22
- '&$disabled': {
23
- pointerEvents: 'auto',
24
- },
25
- },
26
- },
27
- }))
28
-
29
- export default () =>
30
- createStyles({
31
- root: {
32
- display: 'inline-flex',
33
- alignItems: 'center',
34
- cursor: 'pointer',
35
- // For ellipsis
36
- maxWidth: '100%',
37
- // For correct alignment with the text.
38
- verticalAlign: 'middle',
39
- WebkitTapHighlightColor: 'transparent',
40
- '&$disabled': {
41
- cursor: 'default',
42
- },
43
- marginLeft: 0,
44
- marginRight: 0,
45
- },
46
- label: {
47
- '&$disabled': {
48
- pointerEvents: 'auto',
49
- },
50
- },
51
- disabled: {},
52
- horizontalLayout: {
53
- gridColumn: '1 / span 2',
54
- },
55
- })