@instructure/ui-form-field 10.12.0 → 10.12.1-snapshot-1
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/CHANGELOG.md +11 -0
- package/es/FormField/index.js +0 -1
- package/es/FormFieldGroup/__new-tests__/FormFieldGroup.test.js +4 -4
- package/es/FormFieldGroup/index.js +18 -4
- package/es/FormFieldLayout/__new-tests__/FormFieldLayout.test.js +10 -8
- package/es/FormFieldLayout/index.js +73 -54
- package/es/FormFieldLayout/styles.js +109 -10
- package/es/FormFieldLayout/theme.js +28 -2
- package/es/FormFieldMessages/props.js +3 -2
- package/es/FormFieldMessages/styles.js +5 -3
- package/es/FormPropTypes.js +6 -0
- package/es/index.js +0 -1
- package/lib/FormField/index.js +0 -1
- package/lib/FormFieldGroup/__new-tests__/FormFieldGroup.test.js +4 -4
- package/lib/FormFieldGroup/index.js +18 -4
- package/lib/FormFieldLayout/__new-tests__/FormFieldLayout.test.js +9 -7
- package/lib/FormFieldLayout/index.js +72 -54
- package/lib/FormFieldLayout/styles.js +109 -10
- package/lib/FormFieldLayout/theme.js +28 -2
- package/lib/FormFieldMessages/props.js +3 -2
- package/lib/FormFieldMessages/styles.js +5 -3
- package/lib/FormPropTypes.js +6 -0
- package/lib/index.js +0 -7
- package/package.json +15 -15
- package/src/FormField/README.md +31 -3
- package/src/FormField/index.tsx +0 -1
- package/src/FormFieldGroup/__new-tests__/FormFieldGroup.test.tsx +4 -6
- package/src/FormFieldGroup/index.tsx +41 -6
- package/src/FormFieldLayout/__new-tests__/FormFieldLayout.test.tsx +6 -8
- package/src/FormFieldLayout/index.tsx +78 -92
- package/src/FormFieldLayout/props.ts +28 -2
- package/src/FormFieldLayout/styles.ts +128 -14
- package/src/FormFieldLayout/theme.ts +30 -4
- package/src/FormFieldMessages/props.ts +8 -2
- package/src/FormFieldMessages/styles.ts +5 -4
- package/src/FormPropTypes.ts +4 -0
- package/src/index.ts +0 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/FormField/index.d.ts.map +1 -1
- package/types/FormFieldGroup/index.d.ts +1 -0
- package/types/FormFieldGroup/index.d.ts.map +1 -1
- package/types/FormFieldLayout/index.d.ts +8 -7
- package/types/FormFieldLayout/index.d.ts.map +1 -1
- package/types/FormFieldLayout/props.d.ts +27 -3
- package/types/FormFieldLayout/props.d.ts.map +1 -1
- package/types/FormFieldLayout/styles.d.ts +4 -3
- package/types/FormFieldLayout/styles.d.ts.map +1 -1
- package/types/FormFieldLayout/theme.d.ts +7 -1
- package/types/FormFieldLayout/theme.d.ts.map +1 -1
- package/types/FormFieldMessages/index.d.ts +8 -2
- package/types/FormFieldMessages/index.d.ts.map +1 -1
- package/types/FormFieldMessages/props.d.ts +5 -0
- package/types/FormFieldMessages/props.d.ts.map +1 -1
- package/types/FormFieldMessages/styles.d.ts +2 -3
- package/types/FormFieldMessages/styles.d.ts.map +1 -1
- package/types/FormPropTypes.d.ts +3 -0
- package/types/FormPropTypes.d.ts.map +1 -1
- package/types/index.d.ts +0 -2
- package/types/index.d.ts.map +1 -1
- package/es/FormFieldLabel/__new-tests__/FormFieldLabel.test.js +0 -66
- package/es/FormFieldLabel/index.js +0 -79
- package/es/FormFieldLabel/props.js +0 -31
- package/es/FormFieldLabel/styles.js +0 -62
- package/es/FormFieldLabel/theme.js +0 -52
- package/lib/FormFieldLabel/__new-tests__/FormFieldLabel.test.js +0 -68
- package/lib/FormFieldLabel/index.js +0 -85
- package/lib/FormFieldLabel/props.js +0 -37
- package/lib/FormFieldLabel/styles.js +0 -68
- package/lib/FormFieldLabel/theme.js +0 -58
- package/src/FormFieldLabel/__new-tests__/FormFieldLabel.test.tsx +0 -79
- package/src/FormFieldLabel/index.tsx +0 -95
- package/src/FormFieldLabel/props.ts +0 -58
- package/src/FormFieldLabel/styles.ts +0 -74
- package/src/FormFieldLabel/theme.ts +0 -56
- package/types/FormFieldLabel/__new-tests__/FormFieldLabel.test.d.ts +0 -2
- package/types/FormFieldLabel/__new-tests__/FormFieldLabel.test.d.ts.map +0 -1
- package/types/FormFieldLabel/index.d.ts +0 -42
- package/types/FormFieldLabel/index.d.ts.map +0 -1
- package/types/FormFieldLabel/props.d.ts +0 -15
- package/types/FormFieldLabel/props.d.ts.map +0 -1
- package/types/FormFieldLabel/styles.d.ts +0 -15
- package/types/FormFieldLabel/styles.d.ts.map +0 -1
- package/types/FormFieldLabel/theme.d.ts +0 -10
- package/types/FormFieldLabel/theme.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/FormField/index.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAOxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C;;;;GAIG;AACH,cAAM,SAAU,SAAQ,SAAS,CAAC,cAAc,CAAC;IAC/C,MAAM,CAAC,QAAQ,CAAC,WAAW,eAAc;IAEzC,MAAM,CAAC,SAAS,gGAAY;IAC5B,MAAM,CAAC,YAAY,yDAAe;IAClC,MAAM,CAAC,YAAY;;;;;MAKlB;IAED,GAAG,EAAE,OAAO,GAAG,IAAI,CAAO;IAE1B,SAAS,OAAQ,OAAO,GAAG,IAAI,UAQ9B;IAED,MAAM;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/FormField/index.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAOxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C;;;;GAIG;AACH,cAAM,SAAU,SAAQ,SAAS,CAAC,cAAc,CAAC;IAC/C,MAAM,CAAC,QAAQ,CAAC,WAAW,eAAc;IAEzC,MAAM,CAAC,SAAS,gGAAY;IAC5B,MAAM,CAAC,YAAY,yDAAe;IAClC,MAAM,CAAC,YAAY;;;;;MAKlB;IAED,GAAG,EAAE,OAAO,GAAG,IAAI,CAAO;IAE1B,SAAS,OAAQ,OAAO,GAAG,IAAI,UAQ9B;IAED,MAAM;CAaP;AAED,eAAe,SAAS,CAAA;AACxB,OAAO,EAAE,SAAS,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/FormFieldGroup/index.tsx"],"names":[],"mappings":"AAwBA,eAAe;AACf,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/FormFieldGroup/index.tsx"],"names":[],"mappings":"AAwBA,eAAe;AACf,OAAO,EAAE,SAAS,EAA0C,MAAM,OAAO,CAAA;AAIzE,OAAO,EAAa,GAAG,EAAE,MAAM,sBAAsB,CAAA;AAQrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAE5E;;;;GAIG;AACH,cACM,cAAe,SAAQ,SAAS,CAAC,mBAAmB,CAAC;IACzD,MAAM,CAAC,QAAQ,CAAC,WAAW,oBAAmB;IAE9C,MAAM,CAAC,SAAS;qBAXD,MAAO,SAAS;;;;;mBAetB,MAAO,SACZ;;;;;;;OALwB;IAC5B,MAAM,CAAC,YAAY;qBAZJ,MAAO,SAAS;;;;;mBAetB,MAAO,SACZ;;;;;;;SAJ8B;IAClC,MAAM,CAAC,YAAY;;;;;;;MAOlB;IAED,GAAG,EAAE,OAAO,GAAG,IAAI,CAAO;IAE1B,SAAS,OAAQ,OAAO,GAAG,IAAI,UAQ9B;IAED,iBAAiB;IAIjB,kBAAkB;IAIlB,IAAI,mBAAmB,IAAI,wBAAwB,CAQlD;IAED,IAAI,OAAO,YAOV;IAED,aAAa;IAiBb,cAAc;IAgBd,YAAY;IAUZ,MAAM;CA+CP;AAED,eAAe,cAAc,CAAA;AAC7B,OAAO,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { Component } from 'react';
|
|
3
3
|
import { jsx } from '@instructure/emotion';
|
|
4
|
+
import { FormFieldStyleProps } from './props';
|
|
4
5
|
import type { FormFieldLayoutProps } from './props';
|
|
5
6
|
/**
|
|
6
7
|
---
|
|
@@ -19,17 +20,17 @@ declare class FormFieldLayout extends Component<FormFieldLayoutProps> {
|
|
|
19
20
|
};
|
|
20
21
|
constructor(props: FormFieldLayoutProps);
|
|
21
22
|
private _messagesId;
|
|
23
|
+
private _labelId;
|
|
22
24
|
ref: Element | null;
|
|
23
25
|
handleRef: (el: Element | null) => void;
|
|
24
26
|
componentDidMount(): void;
|
|
25
27
|
componentDidUpdate(): void;
|
|
26
|
-
|
|
27
|
-
get
|
|
28
|
-
get
|
|
29
|
-
get
|
|
30
|
-
handleInputContainerRef: (node:
|
|
31
|
-
renderLabel():
|
|
32
|
-
renderLegend(): jsx.JSX.Element;
|
|
28
|
+
makeStyleProps: () => FormFieldStyleProps;
|
|
29
|
+
get hasVisibleLabel(): boolean;
|
|
30
|
+
get hasMessages(): boolean;
|
|
31
|
+
get elementType(): import("react").ComponentClass<any, any> | import("react").FunctionComponent<Readonly<FormFieldLayoutProps>> | import("react").ComponentClass<Readonly<FormFieldLayoutProps>, any> | NonNullable<import("@instructure/shared-types").AsElementType | undefined>;
|
|
32
|
+
handleInputContainerRef: (node: HTMLElement | null) => void;
|
|
33
|
+
renderLabel(): jsx.JSX.Element | null;
|
|
33
34
|
renderVisibleMessages(): jsx.JSX.Element | null;
|
|
34
35
|
render(): jsx.JSX.Element;
|
|
35
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/FormFieldLayout/index.tsx"],"names":[],"mappings":"AAwBA,eAAe;AACf,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/FormFieldLayout/index.tsx"],"names":[],"mappings":"AAwBA,eAAe;AACf,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAQjC,OAAO,EAAa,GAAG,EAAE,MAAM,sBAAsB,CAAA;AAGrD,OAAO,EAA2B,mBAAmB,EAAE,MAAM,SAAS,CAAA;AACtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAGnD;;;;GAIG;AACH,cAEM,eAAgB,SAAQ,SAAS,CAAC,oBAAoB,CAAC;IAC3D,MAAM,CAAC,QAAQ,CAAC,WAAW,qBAAoB;IAE/C,MAAM,CAAC,SAAS,sGAAY;IAC5B,MAAM,CAAC,YAAY,+DAAe;IAClC,MAAM,CAAC,YAAY;;;;;MAKT;gBAEE,KAAK,EAAE,oBAAoB;IAMvC,OAAO,CAAC,WAAW,CAAQ;IAC3B,OAAO,CAAC,QAAQ,CAAQ;IAExB,GAAG,EAAE,OAAO,GAAG,IAAI,CAAO;IAE1B,SAAS,OAAQ,OAAO,GAAG,IAAI,UAQ9B;IAED,iBAAiB;IAIjB,kBAAkB;IAIlB,cAAc,QAAO,mBAAmB,CAUvC;IAED,IAAI,eAAe,YAElB;IAED,IAAI,WAAW,YAed;IAED,IAAI,WAAW,oQAEd;IAED,uBAAuB,SAAU,WAAW,GAAG,IAAI,UAIlD;IAED,WAAW;IA6BX,qBAAqB;IAUrB,MAAM;CAiCP;AAED,eAAe,eAAe,CAAA;AAC9B,OAAO,EAAE,eAAe,EAAE,CAAA"}
|
|
@@ -24,12 +24,31 @@ type FormFieldLayoutOwnProps = {
|
|
|
24
24
|
*/
|
|
25
25
|
messagesId?: string;
|
|
26
26
|
children?: React.ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* If `true` use an inline layout -- content will flow on the left/right side
|
|
29
|
+
* of this component
|
|
30
|
+
*/
|
|
27
31
|
inline?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* In `stacked` mode the container is below the label, in `inline` mode the
|
|
34
|
+
* container is to the right/left (depending on text direction)
|
|
35
|
+
*/
|
|
28
36
|
layout?: 'stacked' | 'inline';
|
|
37
|
+
/**
|
|
38
|
+
* The horizontal alignment of the label. Only works in `inline` layout
|
|
39
|
+
*/
|
|
29
40
|
labelAlign?: 'start' | 'end';
|
|
41
|
+
/**
|
|
42
|
+
* The vertical alignment of the label and the controls.
|
|
43
|
+
* "top" by default
|
|
44
|
+
*/
|
|
30
45
|
vAlign?: 'top' | 'middle' | 'bottom';
|
|
31
46
|
width?: string;
|
|
32
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Provides a reference to the container that holds the input element
|
|
49
|
+
* @param element The element that holds the input control as its children
|
|
50
|
+
*/
|
|
51
|
+
inputContainerRef?: (element: HTMLElement | null) => void;
|
|
33
52
|
/**
|
|
34
53
|
* provides a reference to the underlying html root element
|
|
35
54
|
*/
|
|
@@ -43,9 +62,14 @@ type FormFieldLayoutOwnProps = {
|
|
|
43
62
|
type PropKeys = keyof FormFieldLayoutOwnProps;
|
|
44
63
|
type AllowedPropKeys = Readonly<Array<PropKeys>>;
|
|
45
64
|
type FormFieldLayoutProps = FormFieldLayoutOwnProps & WithStyleProps<null, FormFieldLayoutStyle> & OtherHTMLAttributes<FormFieldLayoutOwnProps> & WithDeterministicIdProps;
|
|
46
|
-
type FormFieldLayoutStyle = ComponentStyle<'formFieldLayout' | '
|
|
65
|
+
type FormFieldLayoutStyle = ComponentStyle<'formFieldLayout' | 'formFieldLabel' | 'formFieldChildren'>;
|
|
47
66
|
declare const propTypes: PropValidators<PropKeys>;
|
|
48
67
|
declare const allowedProps: AllowedPropKeys;
|
|
49
|
-
|
|
68
|
+
type FormFieldStyleProps = {
|
|
69
|
+
hasMessages: boolean;
|
|
70
|
+
hasVisibleLabel: boolean;
|
|
71
|
+
hasNewErrorMsgAndIsGroup: boolean;
|
|
72
|
+
};
|
|
73
|
+
export type { FormFieldStyleProps, FormFieldLayoutProps, FormFieldLayoutStyle, FormFieldLayoutOwnProps };
|
|
50
74
|
export { propTypes, allowedProps };
|
|
51
75
|
//# sourceMappingURL=props.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../src/FormFieldLayout/props.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EACnB,cAAc,EACf,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,OAAO,EACR,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAA;AAE3E,KAAK,uBAAuB,GAAG;IAC7B,KAAK,EAAE,KAAK,CAAC,SAAS,CAAA;IACtB;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,EAAE,CAAC,EAAE,aAAa,CAAA;IAClB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAA;IACxB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,MAAM,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAA;IAC7B,UAAU,CAAC,EAAE,OAAO,GAAG,KAAK,CAAA;IAC5B,MAAM,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAA;IACpC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../src/FormFieldLayout/props.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EACnB,cAAc,EACf,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,OAAO,EACR,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAA;AAE3E,KAAK,uBAAuB,GAAG;IAC7B,KAAK,EAAE,KAAK,CAAC,SAAS,CAAA;IACtB;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,EAAE,CAAC,EAAE,aAAa,CAAA;IAClB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAA;IACxB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB;;;OAGG;IACH,MAAM,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAA;IAC7B;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,GAAG,KAAK,CAAA;IAC5B;;;OAGG;IACH,MAAM,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAA;IACpC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAA;IACzD;;OAEG;IACH,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAA;IAC9C,OAAO,CAAC,EAAE,OAAO,CAAA;IAEjB;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,KAAK,QAAQ,GAAG,MAAM,uBAAuB,CAAA;AAE7C,KAAK,eAAe,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAA;AAEhD,KAAK,oBAAoB,GAAG,uBAAuB,GACjD,cAAc,CAAC,IAAI,EAAE,oBAAoB,CAAC,GAC1C,mBAAmB,CAAC,uBAAuB,CAAC,GAC5C,wBAAwB,CAAA;AAE1B,KAAK,oBAAoB,GAAG,cAAc,CACxC,iBAAiB,GAAG,gBAAgB,GAAG,mBAAmB,CAC3D,CAAA;AAED,QAAA,MAAM,SAAS,EAAE,cAAc,CAAC,QAAQ,CAgBvC,CAAA;AAED,QAAA,MAAM,YAAY,EAAE,eAkBnB,CAAA;AAED,KAAK,mBAAmB,GAAG;IACzB,WAAW,EAAE,OAAO,CAAA;IACpB,eAAe,EAAE,OAAO,CAAA;IACxB,wBAAwB,EAAE,OAAO,CAAA;CAClC,CAAA;AAED,YAAY,EACV,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,EACxB,CAAA;AACD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { FormFieldLayoutProps, FormFieldLayoutStyle } from './props';
|
|
1
|
+
import type { FormFieldLayoutProps, FormFieldLayoutStyle, FormFieldStyleProps } from './props';
|
|
2
|
+
import type { FormFieldLayoutTheme } from '@instructure/shared-types';
|
|
2
3
|
/**
|
|
3
4
|
* ---
|
|
4
5
|
* private: true
|
|
@@ -6,9 +7,9 @@ import type { FormFieldLayoutProps, FormFieldLayoutStyle } from './props';
|
|
|
6
7
|
* Generates the style object from the theme and provided additional information
|
|
7
8
|
* @param {Object} componentTheme The theme variable object.
|
|
8
9
|
* @param {Object} props the props of the component, the style is applied to
|
|
9
|
-
* @param {Object}
|
|
10
|
+
* @param {Object} styleProps
|
|
10
11
|
* @return {Object} The final style object, which will be used in the component
|
|
11
12
|
*/
|
|
12
|
-
declare const generateStyle: (componentTheme:
|
|
13
|
+
declare const generateStyle: (componentTheme: FormFieldLayoutTheme, props: FormFieldLayoutProps, styleProps: FormFieldStyleProps) => FormFieldLayoutStyle;
|
|
13
14
|
export default generateStyle;
|
|
14
15
|
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/FormFieldLayout/styles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/FormFieldLayout/styles.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAiCrE;;;;;;;;;GASG;AACH,QAAA,MAAM,aAAa,mBACD,oBAAoB,SAC7B,oBAAoB,cACf,mBAAmB,KAC9B,oBA2GF,CAAA;AAED,eAAe,aAAa,CAAA"}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { Theme } from '@instructure/ui-themes';
|
|
2
|
-
|
|
2
|
+
import { FormFieldLayoutTheme } from '@instructure/shared-types';
|
|
3
|
+
/**
|
|
4
|
+
* Generates the theme object for the component from the theme and provided additional information
|
|
5
|
+
* @param {Object} theme The actual theme object.
|
|
6
|
+
* @return {Object} The final theme object with the overrides and component variables
|
|
7
|
+
*/
|
|
8
|
+
declare const generateComponentTheme: (theme: Theme) => FormFieldLayoutTheme;
|
|
3
9
|
export default generateComponentTheme;
|
|
4
10
|
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/FormFieldLayout/theme.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/FormFieldLayout/theme.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,KAAK,EAAsB,MAAM,wBAAwB,CAAA;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAEhE;;;;GAIG;AACH,QAAA,MAAM,sBAAsB,UAAW,KAAK,KAAG,oBAwB9C,CAAA;AAED,eAAe,sBAAsB,CAAA"}
|
|
@@ -22,8 +22,14 @@ type: example
|
|
|
22
22
|
**/
|
|
23
23
|
declare class FormFieldMessages extends Component<FormFieldMessagesProps> {
|
|
24
24
|
static readonly componentId = "FormFieldMessages";
|
|
25
|
-
static propTypes: import("@instructure/shared-types").PropValidators<
|
|
26
|
-
|
|
25
|
+
static propTypes: import("@instructure/shared-types").PropValidators<keyof {
|
|
26
|
+
messages?: import("..").FormMessage[];
|
|
27
|
+
gridArea?: string;
|
|
28
|
+
}>;
|
|
29
|
+
static allowedProps: readonly (keyof {
|
|
30
|
+
messages?: import("..").FormMessage[];
|
|
31
|
+
gridArea?: string;
|
|
32
|
+
})[];
|
|
27
33
|
static defaultProps: {};
|
|
28
34
|
ref: Element | null;
|
|
29
35
|
handleRef: (el: Element | null) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/FormFieldMessages/index.tsx"],"names":[],"mappings":"AAwBA,eAAe;AACf,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAIjC,OAAO,EAAa,GAAG,EAAE,MAAM,sBAAsB,CAAA;AAQrD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAErD;;;;;;;;;;;;;;;;;GAiBG;AACH,cACM,iBAAkB,SAAQ,SAAS,CAAC,sBAAsB,CAAC;IAC/D,MAAM,CAAC,QAAQ,CAAC,WAAW,uBAAsB;IAEjD,MAAM,CAAC,SAAS
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/FormFieldMessages/index.tsx"],"names":[],"mappings":"AAwBA,eAAe;AACf,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAIjC,OAAO,EAAa,GAAG,EAAE,MAAM,sBAAsB,CAAA;AAQrD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAErD;;;;;;;;;;;;;;;;;GAiBG;AACH,cACM,iBAAkB,SAAQ,SAAS,CAAC,sBAAsB,CAAC;IAC/D,MAAM,CAAC,QAAQ,CAAC,WAAW,uBAAsB;IAEjD,MAAM,CAAC,SAAS;;;OAAY;IAC5B,MAAM,CAAC,YAAY;;;SAAe;IAClC,MAAM,CAAC,YAAY,KAAK;IAExB,GAAG,EAAE,OAAO,GAAG,IAAI,CAAO;IAE1B,SAAS,OAAQ,OAAO,GAAG,IAAI,UAE9B;IAED,iBAAiB;IAIjB,kBAAkB;IAIlB,MAAM;CAmBP;AAED,eAAe,iBAAiB,CAAA;AAChC,OAAO,EAAE,iBAAiB,EAAE,CAAA"}
|
|
@@ -9,6 +9,11 @@ type FormFieldMessagesOwnProps = {
|
|
|
9
9
|
* }`
|
|
10
10
|
*/
|
|
11
11
|
messages?: FormMessage[];
|
|
12
|
+
/**
|
|
13
|
+
* Specifies the size and location if inside a CSS grid, see
|
|
14
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/grid-area
|
|
15
|
+
*/
|
|
16
|
+
gridArea?: string;
|
|
12
17
|
};
|
|
13
18
|
type PropKeys = keyof FormFieldMessagesOwnProps;
|
|
14
19
|
type AllowedPropKeys = Readonly<Array<PropKeys>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../src/FormFieldMessages/props.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EACV,cAAc,EACd,sBAAsB,EACtB,mBAAmB,EACpB,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD,KAAK,yBAAyB,GAAG;IAC/B;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../src/FormFieldMessages/props.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EACV,cAAc,EACd,sBAAsB,EACtB,mBAAmB,EACpB,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD,KAAK,yBAAyB,GAAG;IAC/B;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAA;IACxB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,KAAK,QAAQ,GAAG,MAAM,yBAAyB,CAAA;AAE/C,KAAK,eAAe,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAA;AAEhD,KAAK,sBAAsB,GAAG,yBAAyB,GACrD,cAAc,CAAC,sBAAsB,EAAE,sBAAsB,CAAC,GAC9D,mBAAmB,CAAC,yBAAyB,CAAC,CAAA;AAEhD,KAAK,sBAAsB,GAAG,cAAc,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAAA;AAE7E,QAAA,MAAM,SAAS,EAAE,cAAc,CAAC,QAAQ,CAGvC,CAAA;AAED,QAAA,MAAM,YAAY,EAAE,eAA0C,CAAA;AAE9D,YAAY,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,CAAA;AAC9D,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FormFieldMessagesTheme } from '@instructure/shared-types';
|
|
2
|
-
import type { FormFieldMessagesStyle } from './props';
|
|
2
|
+
import type { FormFieldMessagesProps, FormFieldMessagesStyle } from './props';
|
|
3
3
|
/**
|
|
4
4
|
* ---
|
|
5
5
|
* private: true
|
|
@@ -7,9 +7,8 @@ import type { FormFieldMessagesStyle } from './props';
|
|
|
7
7
|
* Generates the style object from the theme and provided additional information
|
|
8
8
|
* @param {Object} componentTheme The theme variable object.
|
|
9
9
|
* @param {Object} props the props of the component, the style is applied to
|
|
10
|
-
* @param {Object} state the state of the component, the style is applied to
|
|
11
10
|
* @return {Object} The final style object, which will be used in the component
|
|
12
11
|
*/
|
|
13
|
-
declare const generateStyle: (componentTheme: FormFieldMessagesTheme) => FormFieldMessagesStyle;
|
|
12
|
+
declare const generateStyle: (componentTheme: FormFieldMessagesTheme, props: FormFieldMessagesProps) => FormFieldMessagesStyle;
|
|
14
13
|
export default generateStyle;
|
|
15
14
|
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/FormFieldMessages/styles.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AACvE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/FormFieldMessages/styles.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AACvE,OAAO,KAAK,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAE7E;;;;;;;;GAQG;AACH,QAAA,MAAM,aAAa,mBACD,sBAAsB,SAC/B,sBAAsB,KAC5B,sBAcF,CAAA;AAED,eAAe,aAAa,CAAA"}
|
package/types/FormPropTypes.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
declare const formMessageTypePropType: PropTypes.Requireable<string>;
|
|
4
4
|
declare const formMessageChildPropType: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
5
5
|
type FormMessageType = 'newError' | 'error' | 'hint' | 'success' | 'screenreader-only';
|
|
6
|
+
/**
|
|
7
|
+
* The text to display in the form message
|
|
8
|
+
*/
|
|
6
9
|
type FormMessageChild = React.ReactNode;
|
|
7
10
|
/**
|
|
8
11
|
* ---
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormPropTypes.d.ts","sourceRoot":"","sources":["../src/FormPropTypes.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,SAAS,MAAM,YAAY,CAAA;AAElC,QAAA,MAAM,uBAAuB,+BAM3B,CAAA;AACF,QAAA,MAAM,wBAAwB,gDAAiB,CAAA;AAE/C,KAAK,eAAe,GAChB,UAAU,GACV,OAAO,GACP,MAAM,GACN,SAAS,GACT,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"FormPropTypes.d.ts","sourceRoot":"","sources":["../src/FormPropTypes.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,SAAS,MAAM,YAAY,CAAA;AAElC,QAAA,MAAM,uBAAuB,+BAM3B,CAAA;AACF,QAAA,MAAM,wBAAwB,gDAAiB,CAAA;AAE/C,KAAK,eAAe,GAChB,UAAU,GACV,OAAO,GACP,MAAM,GACN,SAAS,GACT,mBAAmB,CAAA;AAEvB;;GAEG;AACH,KAAK,gBAAgB,GAAG,KAAK,CAAC,SAAS,CAAA;AAEvC;;;;;;GAMG;AACH,QAAA,MAAM,aAAa;;;;;CAKlB,CAAA;AAED,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,eAAe,CAAA;IACrB,IAAI,EAAE,gBAAgB,CAAA;CACvB,CAAA;AAED,eAAe,aAAa,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,CAAA;AAC3E,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,gBAAgB,EAAE,CAAA"}
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { FormField } from './FormField';
|
|
2
|
-
export { FormFieldLabel } from './FormFieldLabel';
|
|
3
2
|
export { FormFieldMessage } from './FormFieldMessage';
|
|
4
3
|
export { FormFieldMessages } from './FormFieldMessages';
|
|
5
4
|
export { FormFieldLayout } from './FormFieldLayout';
|
|
@@ -7,7 +6,6 @@ export { FormFieldGroup } from './FormFieldGroup';
|
|
|
7
6
|
export { FormPropTypes } from './FormPropTypes';
|
|
8
7
|
export type { FormMessageType, FormMessage } from './FormPropTypes';
|
|
9
8
|
export type { FormFieldOwnProps, FormFieldProps } from './FormField/props';
|
|
10
|
-
export type { FormFieldLabelProps } from './FormFieldLabel/props';
|
|
11
9
|
export type { FormFieldMessageProps } from './FormFieldMessage/props';
|
|
12
10
|
export type { FormFieldMessagesProps } from './FormFieldMessages/props';
|
|
13
11
|
export type { FormFieldLayoutProps } from './FormFieldLayout/props';
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAEnE,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAC1E,YAAY,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAA;AACrE,YAAY,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AACvE,YAAY,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AACnE,YAAY,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA"}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
var _FormFieldLabel, _FormFieldLabel2, _FormFieldLabel3;
|
|
2
|
-
/*
|
|
3
|
-
* The MIT License (MIT)
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
6
|
-
*
|
|
7
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
* in the Software without restriction, including without limitation the rights
|
|
10
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
* furnished to do so, subject to the following conditions:
|
|
13
|
-
*
|
|
14
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
* copies or substantial portions of the Software.
|
|
16
|
-
*
|
|
17
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
* SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
import React from 'react';
|
|
27
|
-
import { render } from '@testing-library/react';
|
|
28
|
-
import { vi } from 'vitest';
|
|
29
|
-
import { runAxeCheck } from '@instructure/ui-axe-check';
|
|
30
|
-
import '@testing-library/jest-dom';
|
|
31
|
-
import { FormFieldLabel } from '../index';
|
|
32
|
-
describe('<FormFieldLabel />', () => {
|
|
33
|
-
let consoleWarningMock;
|
|
34
|
-
let consoleErrorMock;
|
|
35
|
-
beforeEach(() => {
|
|
36
|
-
// Mocking console to prevent test output pollution and expect for messages
|
|
37
|
-
consoleWarningMock = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
38
|
-
consoleErrorMock = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
39
|
-
});
|
|
40
|
-
afterEach(() => {
|
|
41
|
-
consoleWarningMock.mockRestore();
|
|
42
|
-
consoleErrorMock.mockRestore();
|
|
43
|
-
});
|
|
44
|
-
it('should render', () => {
|
|
45
|
-
const _render = render(_FormFieldLabel || (_FormFieldLabel = /*#__PURE__*/React.createElement(FormFieldLabel, null, "Foo"))),
|
|
46
|
-
container = _render.container;
|
|
47
|
-
const formFieldLabel = container.querySelector("span[class$='-formFieldLabel']");
|
|
48
|
-
expect(formFieldLabel).toBeInTheDocument();
|
|
49
|
-
expect(formFieldLabel).toHaveTextContent('Foo');
|
|
50
|
-
});
|
|
51
|
-
it('should render as specified via the `as` prop', () => {
|
|
52
|
-
const _render2 = render(_FormFieldLabel2 || (_FormFieldLabel2 = /*#__PURE__*/React.createElement(FormFieldLabel, {
|
|
53
|
-
as: "li"
|
|
54
|
-
}, "Foo"))),
|
|
55
|
-
container = _render2.container;
|
|
56
|
-
const formFieldLabel = container.querySelector('li');
|
|
57
|
-
expect(formFieldLabel).toBeInTheDocument();
|
|
58
|
-
expect(formFieldLabel).toHaveTextContent('Foo');
|
|
59
|
-
});
|
|
60
|
-
it('should meet a11y standards', async () => {
|
|
61
|
-
const _render3 = render(_FormFieldLabel3 || (_FormFieldLabel3 = /*#__PURE__*/React.createElement(FormFieldLabel, null, "Foo"))),
|
|
62
|
-
container = _render3.container;
|
|
63
|
-
const axeCheck = await runAxeCheck(container);
|
|
64
|
-
expect(axeCheck).toBe(true);
|
|
65
|
-
});
|
|
66
|
-
});
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
var _dec, _class, _FormFieldLabel;
|
|
2
|
-
/*
|
|
3
|
-
* The MIT License (MIT)
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
6
|
-
*
|
|
7
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
* in the Software without restriction, including without limitation the rights
|
|
10
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
* furnished to do so, subject to the following conditions:
|
|
13
|
-
*
|
|
14
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
* copies or substantial portions of the Software.
|
|
16
|
-
*
|
|
17
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
* SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
/** @jsx jsx */
|
|
27
|
-
import { Component } from 'react';
|
|
28
|
-
import { omitProps, getElementType } from '@instructure/ui-react-utils';
|
|
29
|
-
import { withStyle, jsx } from '@instructure/emotion';
|
|
30
|
-
import generateStyle from './styles';
|
|
31
|
-
import generateComponentTheme from './theme';
|
|
32
|
-
import { propTypes, allowedProps } from './props';
|
|
33
|
-
/**
|
|
34
|
-
---
|
|
35
|
-
parent: FormField
|
|
36
|
-
---
|
|
37
|
-
|
|
38
|
-
This is a helper component that is used by most of the custom form
|
|
39
|
-
components. In most cases it shouldn't be used directly.
|
|
40
|
-
|
|
41
|
-
```js
|
|
42
|
-
---
|
|
43
|
-
type: example
|
|
44
|
-
---
|
|
45
|
-
<FormFieldLabel>Hello</FormFieldLabel>
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
**/
|
|
49
|
-
let FormFieldLabel = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class = (_FormFieldLabel = class FormFieldLabel extends Component {
|
|
50
|
-
constructor(...args) {
|
|
51
|
-
super(...args);
|
|
52
|
-
this.ref = null;
|
|
53
|
-
this.handleRef = el => {
|
|
54
|
-
this.ref = el;
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
componentDidMount() {
|
|
58
|
-
var _this$props$makeStyle, _this$props;
|
|
59
|
-
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
60
|
-
}
|
|
61
|
-
componentDidUpdate() {
|
|
62
|
-
var _this$props$makeStyle2, _this$props2;
|
|
63
|
-
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
64
|
-
}
|
|
65
|
-
render() {
|
|
66
|
-
const ElementType = getElementType(FormFieldLabel, this.props);
|
|
67
|
-
const _this$props3 = this.props,
|
|
68
|
-
styles = _this$props3.styles,
|
|
69
|
-
children = _this$props3.children;
|
|
70
|
-
return jsx(ElementType, Object.assign({}, omitProps(this.props, FormFieldLabel.allowedProps), {
|
|
71
|
-
css: styles === null || styles === void 0 ? void 0 : styles.formFieldLabel,
|
|
72
|
-
ref: this.handleRef
|
|
73
|
-
}), children);
|
|
74
|
-
}
|
|
75
|
-
}, _FormFieldLabel.displayName = "FormFieldLabel", _FormFieldLabel.componentId = 'FormFieldLabel', _FormFieldLabel.propTypes = propTypes, _FormFieldLabel.allowedProps = allowedProps, _FormFieldLabel.defaultProps = {
|
|
76
|
-
as: 'span'
|
|
77
|
-
}, _FormFieldLabel)) || _class);
|
|
78
|
-
export default FormFieldLabel;
|
|
79
|
-
export { FormFieldLabel };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The MIT License (MIT)
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
import PropTypes from 'prop-types';
|
|
26
|
-
const propTypes = {
|
|
27
|
-
children: PropTypes.node.isRequired,
|
|
28
|
-
as: PropTypes.elementType
|
|
29
|
-
};
|
|
30
|
-
const allowedProps = ['as', 'children'];
|
|
31
|
-
export { propTypes, allowedProps };
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The MIT License (MIT)
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
import { hasVisibleChildren } from '@instructure/ui-a11y-utils';
|
|
26
|
-
/**
|
|
27
|
-
* ---
|
|
28
|
-
* private: true
|
|
29
|
-
* ---
|
|
30
|
-
* Generates the style object from the theme and provided additional information
|
|
31
|
-
* @param {Object} componentTheme The theme variable object.
|
|
32
|
-
* @param {Object} props the props of the component, the style is applied to
|
|
33
|
-
* @param {Object} state the state of the component, the style is applied to
|
|
34
|
-
* @return {Object} The final style object, which will be used in the component
|
|
35
|
-
*/
|
|
36
|
-
const generateStyle = (componentTheme, props) => {
|
|
37
|
-
const children = props.children;
|
|
38
|
-
const hasContent = hasVisibleChildren(children);
|
|
39
|
-
const labelStyles = {
|
|
40
|
-
all: 'initial',
|
|
41
|
-
display: 'block',
|
|
42
|
-
...(hasContent && {
|
|
43
|
-
color: componentTheme.color,
|
|
44
|
-
fontFamily: componentTheme.fontFamily,
|
|
45
|
-
fontWeight: componentTheme.fontWeight,
|
|
46
|
-
fontSize: componentTheme.fontSize,
|
|
47
|
-
lineHeight: componentTheme.lineHeight,
|
|
48
|
-
margin: 0,
|
|
49
|
-
textAlign: 'inherit'
|
|
50
|
-
})
|
|
51
|
-
};
|
|
52
|
-
return {
|
|
53
|
-
formFieldLabel: {
|
|
54
|
-
label: 'formFieldLabel',
|
|
55
|
-
...labelStyles,
|
|
56
|
-
// NOTE: needs separate groups for `:is()` and `:-webkit-any()` because of css selector group validation (see https://www.w3.org/TR/selectors-3/#grouping)
|
|
57
|
-
'&:is(label)': labelStyles,
|
|
58
|
-
'&:-webkit-any(label)': labelStyles
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
export default generateStyle;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The MIT License (MIT)
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Generates the theme object for the component from the theme and provided additional information
|
|
27
|
-
* @param {Object} theme The actual theme object.
|
|
28
|
-
* @return {Object} The final theme object with the overrides and component variables
|
|
29
|
-
*/
|
|
30
|
-
const generateComponentTheme = theme => {
|
|
31
|
-
var _colors$contrasts;
|
|
32
|
-
const colors = theme.colors,
|
|
33
|
-
typography = theme.typography,
|
|
34
|
-
themeName = theme.key;
|
|
35
|
-
const themeSpecificStyle = {
|
|
36
|
-
canvas: {
|
|
37
|
-
color: theme['ic-brand-font-color-dark']
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
const componentVariables = {
|
|
41
|
-
color: colors === null || colors === void 0 ? void 0 : (_colors$contrasts = colors.contrasts) === null || _colors$contrasts === void 0 ? void 0 : _colors$contrasts.grey125125,
|
|
42
|
-
fontFamily: typography === null || typography === void 0 ? void 0 : typography.fontFamily,
|
|
43
|
-
fontWeight: typography === null || typography === void 0 ? void 0 : typography.fontWeightBold,
|
|
44
|
-
fontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeMedium,
|
|
45
|
-
lineHeight: typography === null || typography === void 0 ? void 0 : typography.lineHeightFit
|
|
46
|
-
};
|
|
47
|
-
return {
|
|
48
|
-
...componentVariables,
|
|
49
|
-
...themeSpecificStyle[themeName]
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
export default generateComponentTheme;
|