@openedx/paragon 22.11.0 → 22.11.2
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/dist/Form/FormGroup.d.ts +41 -0
- package/dist/Form/FormGroup.js +3 -11
- package/dist/Form/FormGroup.js.map +1 -1
- package/dist/Form/FormGroupContext.d.ts +24 -0
- package/dist/Form/FormGroupContext.js +2 -17
- package/dist/Form/FormGroupContext.js.map +1 -1
- package/dist/Form/FormLabel.d.ts +20 -0
- package/dist/Form/FormLabel.js +2 -10
- package/dist/Form/FormLabel.js.map +1 -1
- package/dist/Form/constants.d.ts +13 -0
- package/dist/Form/constants.js +5 -8
- package/dist/Form/constants.js.map +1 -0
- package/dist/Form/fieldUtils.d.ts +9 -0
- package/dist/Form/fieldUtils.js +27 -29
- package/dist/Form/fieldUtils.js.map +1 -0
- package/dist/Form/index.d.ts +39 -0
- package/dist/Form/index.js +18 -1
- package/dist/Form/index.js.map +1 -1
- package/dist/Form/messages.d.ts +13 -0
- package/dist/Form/messages.js +4 -5
- package/dist/Form/messages.js.map +1 -0
- package/dist/IconButton/index.d.ts +3 -0
- package/dist/IconButton/index.js +4 -1
- package/dist/IconButton/index.js.map +1 -1
- package/dist/index.d.ts +22 -22
- package/dist/index.js +22 -22
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/newId.d.ts +2 -0
- package/dist/utils/newId.js +3 -3
- package/dist/utils/newId.js.map +1 -0
- package/dist/utils/propTypes/utils.js +1 -1
- package/package.json +1 -1
- package/src/Collapsible/README.md +2 -2
- package/src/DataTable/README.md +2 -2
- package/src/Dropdown/README.md +1 -1
- package/src/Dropzone/README.md +1 -1
- package/src/Form/{FormGroup.jsx → FormGroup.tsx} +24 -14
- package/src/Form/{FormGroupContext.jsx → FormGroupContext.tsx} +29 -27
- package/src/Form/{FormLabel.jsx → FormLabel.tsx} +8 -11
- package/src/Form/{constants.js → constants.ts} +4 -7
- package/src/Form/{fieldUtils.js → fieldUtils.ts} +14 -11
- package/src/Form/form-control.mdx +4 -6
- package/src/Form/{index.jsx → index.tsx} +33 -1
- package/src/IconButton/index.tsx +5 -0
- package/src/InputSelect/README.md +2 -3
- package/src/InputText/README.md +4 -6
- package/src/ListBox/README.md +1 -1
- package/src/Modal/standard-modal.mdx +1 -1
- package/src/TextArea/README.md +2 -3
- package/src/index.d.ts +22 -22
- package/src/index.js +22 -22
- package/src/utils/propTypes/utils.js +1 -1
- /package/src/Form/{messages.js → messages.ts} +0 -0
- /package/src/utils/{index.js → index.ts} +0 -0
- /package/src/utils/{newId.js → newId.ts} +0 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { FORM_CONTROL_SIZES } from './constants';
|
|
4
|
+
interface Props<As extends React.ElementType> {
|
|
5
|
+
/** Specifies contents of the component. */
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
/** Specifies class name to append to the base element. */
|
|
8
|
+
className?: string;
|
|
9
|
+
/** Specifies base element for the component. */
|
|
10
|
+
as?: As;
|
|
11
|
+
/** Specifies id to use in the group, it will be used as `htmlFor` in `FormLabel` and as `id` in input components.
|
|
12
|
+
* Will be autogenerated if none is supplied. */
|
|
13
|
+
controlId?: string;
|
|
14
|
+
/** Specifies whether to display components in invalid state, this affects styling. */
|
|
15
|
+
isInvalid?: boolean;
|
|
16
|
+
/** Specifies whether to display components in valid state, this affects styling. */
|
|
17
|
+
isValid?: boolean;
|
|
18
|
+
/** Specifies size for the component. */
|
|
19
|
+
size?: typeof FORM_CONTROL_SIZES.SMALL | typeof FORM_CONTROL_SIZES.LARGE;
|
|
20
|
+
}
|
|
21
|
+
declare function FormGroup<As extends React.ElementType = 'div'>({ children, controlId, isInvalid, isValid, size, as, ...props }: Props<As> & React.ComponentPropsWithoutRef<As>): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
22
|
+
declare namespace FormGroup {
|
|
23
|
+
var propTypes: {
|
|
24
|
+
/** Specifies contents of the component. */
|
|
25
|
+
children: PropTypes.Validator<NonNullable<PropTypes.ReactNodeLike>>;
|
|
26
|
+
/** Specifies class name to append to the base element. */
|
|
27
|
+
className: PropTypes.Requireable<string>;
|
|
28
|
+
/** Specifies base element for the component. */
|
|
29
|
+
as: PropTypes.Requireable<PropTypes.ReactComponentLike>;
|
|
30
|
+
/** Specifies id to use in the group, it will be used as `htmlFor` in `FormLabel` and as `id` in input components.
|
|
31
|
+
* Will be autogenerated if none is supplied. */
|
|
32
|
+
controlId: PropTypes.Requireable<string>;
|
|
33
|
+
/** Specifies whether to display components in invalid state, this affects styling. */
|
|
34
|
+
isInvalid: PropTypes.Requireable<boolean>;
|
|
35
|
+
/** Specifies whether to display components in valid state, this affects styling. */
|
|
36
|
+
isValid: PropTypes.Requireable<boolean>;
|
|
37
|
+
/** Specifies size for the component. */
|
|
38
|
+
size: PropTypes.Requireable<string>;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export default FormGroup;
|
package/dist/Form/FormGroup.js
CHANGED
|
@@ -6,13 +6,13 @@ function FormGroup(_ref) {
|
|
|
6
6
|
let {
|
|
7
7
|
children,
|
|
8
8
|
controlId,
|
|
9
|
-
isInvalid,
|
|
10
|
-
isValid,
|
|
9
|
+
isInvalid = false,
|
|
10
|
+
isValid = false,
|
|
11
11
|
size,
|
|
12
12
|
as,
|
|
13
13
|
...props
|
|
14
14
|
} = _ref;
|
|
15
|
-
return /*#__PURE__*/React.createElement(as, {
|
|
15
|
+
return /*#__PURE__*/React.createElement(as ?? 'div', {
|
|
16
16
|
...props,
|
|
17
17
|
className: classNames('pgn__form-group', props.className)
|
|
18
18
|
}, /*#__PURE__*/React.createElement(FormGroupContextProvider, {
|
|
@@ -40,13 +40,5 @@ FormGroup.propTypes = {
|
|
|
40
40
|
/** Specifies size for the component. */
|
|
41
41
|
size: PropTypes.oneOf(SIZE_CHOICES)
|
|
42
42
|
};
|
|
43
|
-
FormGroup.defaultProps = {
|
|
44
|
-
as: 'div',
|
|
45
|
-
className: undefined,
|
|
46
|
-
controlId: undefined,
|
|
47
|
-
isInvalid: false,
|
|
48
|
-
isValid: false,
|
|
49
|
-
size: undefined
|
|
50
|
-
};
|
|
51
43
|
export default FormGroup;
|
|
52
44
|
//# sourceMappingURL=FormGroup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormGroup.js","names":["React","PropTypes","classNames","FormGroupContextProvider","FormGroup","_ref","children","controlId","isInvalid","isValid","size","as","props","createElement","className","SIZE_CHOICES","propTypes","node","isRequired","string","elementType","bool","oneOf"
|
|
1
|
+
{"version":3,"file":"FormGroup.js","names":["React","PropTypes","classNames","FormGroupContextProvider","FormGroup","_ref","children","controlId","isInvalid","isValid","size","as","props","createElement","className","SIZE_CHOICES","propTypes","node","isRequired","string","elementType","bool","oneOf"],"sources":["../../src/Form/FormGroup.tsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport { FormGroupContextProvider } from './FormGroupContext';\nimport { FORM_CONTROL_SIZES } from './constants';\n\ninterface Props<As extends React.ElementType> {\n /** Specifies contents of the component. */\n children: React.ReactNode;\n /** Specifies class name to append to the base element. */\n className?: string;\n /** Specifies base element for the component. */\n as?: As;\n /** Specifies id to use in the group, it will be used as `htmlFor` in `FormLabel` and as `id` in input components.\n * Will be autogenerated if none is supplied. */\n controlId?: string;\n /** Specifies whether to display components in invalid state, this affects styling. */\n isInvalid?: boolean;\n /** Specifies whether to display components in valid state, this affects styling. */\n isValid?: boolean;\n /** Specifies size for the component. */\n size?: typeof FORM_CONTROL_SIZES.SMALL | typeof FORM_CONTROL_SIZES.LARGE;\n}\n\nfunction FormGroup<As extends React.ElementType = 'div'>({\n children,\n controlId,\n isInvalid = false,\n isValid = false,\n size,\n as,\n ...props\n}: Props<As> & React.ComponentPropsWithoutRef<As>) {\n return React.createElement(\n as ?? 'div',\n {\n ...props,\n className: classNames('pgn__form-group', props.className),\n }, (\n <FormGroupContextProvider\n controlId={controlId}\n isInvalid={isInvalid}\n isValid={isValid}\n size={size}\n >\n {children}\n </FormGroupContextProvider>\n ),\n );\n}\n\nconst SIZE_CHOICES = ['sm', 'lg'];\n\nFormGroup.propTypes = {\n /** Specifies contents of the component. */\n children: PropTypes.node.isRequired,\n /** Specifies class name to append to the base element. */\n className: PropTypes.string,\n /** Specifies base element for the component. */\n as: PropTypes.elementType,\n /** Specifies id to use in the group, it will be used as `htmlFor` in `FormLabel` and as `id` in input components.\n * Will be autogenerated if none is supplied. */\n controlId: PropTypes.string,\n /** Specifies whether to display components in invalid state, this affects styling. */\n isInvalid: PropTypes.bool,\n /** Specifies whether to display components in valid state, this affects styling. */\n isValid: PropTypes.bool,\n /** Specifies size for the component. */\n size: PropTypes.oneOf(SIZE_CHOICES),\n};\n\nexport default FormGroup;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,UAAU,MAAM,YAAY;AACnC,SAASC,wBAAwB,QAAQ,oBAAoB;AAqB7D,SAASC,SAASA,CAAAC,IAAA,EAQiC;EAAA,IARM;IACvDC,QAAQ;IACRC,SAAS;IACTC,SAAS,GAAG,KAAK;IACjBC,OAAO,GAAG,KAAK;IACfC,IAAI;IACJC,EAAE;IACF,GAAGC;EAC2C,CAAC,GAAAP,IAAA;EAC/C,oBAAOL,KAAK,CAACa,aAAa,CACxBF,EAAE,IAAI,KAAK,EACX;IACE,GAAGC,KAAK;IACRE,SAAS,EAAEZ,UAAU,CAAC,iBAAiB,EAAEU,KAAK,CAACE,SAAS;EAC1D,CAAC,eACCd,KAAA,CAAAa,aAAA,CAACV,wBAAwB;IACvBI,SAAS,EAAEA,SAAU;IACrBC,SAAS,EAAEA,SAAU;IACrBC,OAAO,EAAEA,OAAQ;IACjBC,IAAI,EAAEA;EAAK,GAEVJ,QACuB,CAE9B,CAAC;AACH;AAEA,MAAMS,YAAY,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC;AAEjCX,SAAS,CAACY,SAAS,GAAG;EACpB;EACAV,QAAQ,EAAEL,SAAS,CAACgB,IAAI,CAACC,UAAU;EACnC;EACAJ,SAAS,EAAEb,SAAS,CAACkB,MAAM;EAC3B;EACAR,EAAE,EAAEV,SAAS,CAACmB,WAAW;EACzB;AACF;EACEb,SAAS,EAAEN,SAAS,CAACkB,MAAM;EAC3B;EACAX,SAAS,EAAEP,SAAS,CAACoB,IAAI;EACzB;EACAZ,OAAO,EAAER,SAAS,CAACoB,IAAI;EACvB;EACAX,IAAI,EAAET,SAAS,CAACqB,KAAK,CAACP,YAAY;AACpC,CAAC;AAED,eAAeX,SAAS","ignoreList":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FORM_CONTROL_SIZES } from './constants';
|
|
3
|
+
interface FormGroupContextData {
|
|
4
|
+
getControlProps: (props: Record<string, any>) => Record<string, any>;
|
|
5
|
+
getLabelProps: (props: React.ComponentPropsWithoutRef<'label'>) => React.ComponentPropsWithoutRef<'label'>;
|
|
6
|
+
getDescriptorProps: (props: Record<string, any>) => Record<string, any>;
|
|
7
|
+
useSetIsControlGroupEffect: (isControlGroup: boolean) => void;
|
|
8
|
+
isControlGroup?: boolean;
|
|
9
|
+
controlId?: string;
|
|
10
|
+
isInvalid?: boolean;
|
|
11
|
+
isValid?: boolean;
|
|
12
|
+
size?: string;
|
|
13
|
+
hasFormGroupProvider?: boolean;
|
|
14
|
+
}
|
|
15
|
+
declare const FormGroupContext: React.Context<FormGroupContextData>;
|
|
16
|
+
declare const useFormGroupContext: () => FormGroupContextData;
|
|
17
|
+
declare function FormGroupContextProvider({ children, controlId: explicitControlId, isInvalid, isValid, size, }: {
|
|
18
|
+
children: React.ReactNode;
|
|
19
|
+
controlId?: string;
|
|
20
|
+
isInvalid?: boolean;
|
|
21
|
+
isValid?: boolean;
|
|
22
|
+
size?: typeof FORM_CONTROL_SIZES.SMALL | typeof FORM_CONTROL_SIZES.LARGE;
|
|
23
|
+
}): React.JSX.Element;
|
|
24
|
+
export { FormGroupContext, FormGroupContextProvider, useFormGroupContext, };
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import React, { useState, useEffect, useMemo, useCallback } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
2
|
import classNames from 'classnames';
|
|
4
3
|
import { newId } from '../utils';
|
|
5
4
|
import { useIdList, omitUndefinedProperties } from './fieldUtils';
|
|
6
|
-
import { FORM_CONTROL_SIZES } from './constants';
|
|
7
5
|
const identityFn = props => props;
|
|
8
6
|
const noop = () => {};
|
|
9
7
|
const FormGroupContext = /*#__PURE__*/React.createContext({
|
|
@@ -14,13 +12,13 @@ const FormGroupContext = /*#__PURE__*/React.createContext({
|
|
|
14
12
|
hasFormGroupProvider: false
|
|
15
13
|
});
|
|
16
14
|
const useFormGroupContext = () => React.useContext(FormGroupContext);
|
|
17
|
-
|
|
15
|
+
function useStateEffect(initialState) {
|
|
18
16
|
const [state, setState] = useState(initialState);
|
|
19
17
|
const useSetStateEffect = newState => {
|
|
20
18
|
useEffect(() => setState(newState), [newState]);
|
|
21
19
|
};
|
|
22
20
|
return [state, useSetStateEffect];
|
|
23
|
-
}
|
|
21
|
+
}
|
|
24
22
|
function FormGroupContextProvider(_ref) {
|
|
25
23
|
let {
|
|
26
24
|
children,
|
|
@@ -85,18 +83,5 @@ function FormGroupContextProvider(_ref) {
|
|
|
85
83
|
value: contextValue
|
|
86
84
|
}, children);
|
|
87
85
|
}
|
|
88
|
-
FormGroupContextProvider.propTypes = {
|
|
89
|
-
children: PropTypes.node.isRequired,
|
|
90
|
-
controlId: PropTypes.string,
|
|
91
|
-
isInvalid: PropTypes.bool,
|
|
92
|
-
isValid: PropTypes.bool,
|
|
93
|
-
size: PropTypes.oneOf([FORM_CONTROL_SIZES.SMALL, FORM_CONTROL_SIZES.LARGE])
|
|
94
|
-
};
|
|
95
|
-
FormGroupContextProvider.defaultProps = {
|
|
96
|
-
controlId: undefined,
|
|
97
|
-
isInvalid: undefined,
|
|
98
|
-
isValid: undefined,
|
|
99
|
-
size: undefined
|
|
100
|
-
};
|
|
101
86
|
export { FormGroupContext, FormGroupContextProvider, useFormGroupContext };
|
|
102
87
|
//# sourceMappingURL=FormGroupContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormGroupContext.js","names":["React","useState","useEffect","useMemo","useCallback","
|
|
1
|
+
{"version":3,"file":"FormGroupContext.js","names":["React","useState","useEffect","useMemo","useCallback","classNames","newId","useIdList","omitUndefinedProperties","identityFn","props","noop","FormGroupContext","createContext","getControlProps","useSetIsControlGroupEffect","getLabelProps","getDescriptorProps","hasFormGroupProvider","useFormGroupContext","useContext","useStateEffect","initialState","state","setState","useSetStateEffect","newState","FormGroupContextProvider","_ref","children","controlId","explicitControlId","isInvalid","isValid","size","describedByIds","registerDescriptorId","labelledByIds","registerLabelerId","isControlGroup","controlProps","labelledByIdsForControl","undefined","id","labelProps","htmlFor","descriptorProps","contextValue","createElement","Provider","value"],"sources":["../../src/Form/FormGroupContext.tsx"],"sourcesContent":["import React, {\n useState, useEffect, useMemo, useCallback,\n} from 'react';\nimport classNames from 'classnames';\nimport { newId } from '../utils';\nimport { useIdList, omitUndefinedProperties } from './fieldUtils';\nimport { FORM_CONTROL_SIZES } from './constants';\n\nconst identityFn = (props: Record<string, any>) => props;\nconst noop = () => {};\n\ninterface FormGroupContextData {\n getControlProps: (props: Record<string, any>) => Record<string, any>;\n getLabelProps: (props: React.ComponentPropsWithoutRef<'label'>) => React.ComponentPropsWithoutRef<'label'>;\n getDescriptorProps: (props: Record<string, any>) => Record<string, any>;\n useSetIsControlGroupEffect: (isControlGroup: boolean) => void;\n isControlGroup?: boolean;\n controlId?: string;\n isInvalid?: boolean;\n isValid?: boolean;\n size?: string;\n hasFormGroupProvider?: boolean;\n}\n\nconst FormGroupContext = React.createContext<FormGroupContextData>({\n getControlProps: identityFn,\n useSetIsControlGroupEffect: noop,\n getLabelProps: identityFn,\n getDescriptorProps: identityFn,\n hasFormGroupProvider: false,\n});\n\nconst useFormGroupContext = () => React.useContext(FormGroupContext);\n\nfunction useStateEffect<ValueType extends any>(\n initialState: ValueType,\n): [value: ValueType, setter: (v: ValueType) => void] {\n const [state, setState] = useState(initialState);\n const useSetStateEffect = (newState: ValueType) => {\n useEffect(() => setState(newState), [newState]);\n };\n return [state, useSetStateEffect];\n}\n\nfunction FormGroupContextProvider({\n children,\n controlId: explicitControlId,\n isInvalid,\n isValid,\n size,\n}: {\n children: React.ReactNode;\n controlId?: string;\n isInvalid?: boolean;\n isValid?: boolean;\n size?: typeof FORM_CONTROL_SIZES.SMALL | typeof FORM_CONTROL_SIZES.LARGE;\n}) {\n const controlId = useMemo(() => explicitControlId || newId('form-field'), [explicitControlId]);\n const [describedByIds, registerDescriptorId] = useIdList(controlId);\n const [labelledByIds, registerLabelerId] = useIdList(controlId);\n const [isControlGroup, useSetIsControlGroupEffect] = useStateEffect(false);\n\n const getControlProps = useCallback((controlProps) => {\n // labelledByIds from the list above should only be added to a control\n // if it the control is a group. We prefer adding a condition here because:\n // - Hooks cannot be called inside conditionals\n // - The getLabelProps function below is forced to generate an id\n // whether it is needed or not.\n // - This is what allows consumers of Paragon to use <Form.Label>\n // interchangeably between ControlGroup type controls and regular Controls\n const labelledByIdsForControl = isControlGroup ? labelledByIds : undefined;\n return omitUndefinedProperties({\n ...controlProps,\n 'aria-describedby': classNames(controlProps['aria-describedby'], describedByIds) || undefined,\n 'aria-labelledby': classNames(controlProps['aria-labelledby'], labelledByIdsForControl) || undefined,\n id: controlId,\n });\n }, [\n isControlGroup,\n describedByIds,\n labelledByIds,\n controlId,\n ]);\n\n const getLabelProps = (labelProps: React.ComponentPropsWithoutRef<'label'>) => {\n const id = registerLabelerId(labelProps?.id);\n if (isControlGroup) {\n return { ...labelProps, id };\n }\n return { ...labelProps, htmlFor: controlId };\n };\n\n const getDescriptorProps = (descriptorProps: Record<string, any>) => {\n const id = registerDescriptorId(descriptorProps?.id);\n return { ...descriptorProps, id };\n };\n\n const contextValue: FormGroupContextData = {\n getControlProps,\n getLabelProps,\n getDescriptorProps,\n useSetIsControlGroupEffect,\n isControlGroup,\n controlId,\n isInvalid,\n isValid,\n size,\n hasFormGroupProvider: true,\n };\n\n return (\n <FormGroupContext.Provider value={contextValue}>\n {children}\n </FormGroupContext.Provider>\n );\n}\n\nexport {\n FormGroupContext,\n FormGroupContextProvider,\n useFormGroupContext,\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IACVC,QAAQ,EAAEC,SAAS,EAAEC,OAAO,EAAEC,WAAW,QACpC,OAAO;AACd,OAAOC,UAAU,MAAM,YAAY;AACnC,SAASC,KAAK,QAAQ,UAAU;AAChC,SAASC,SAAS,EAAEC,uBAAuB,QAAQ,cAAc;AAGjE,MAAMC,UAAU,GAAIC,KAA0B,IAAKA,KAAK;AACxD,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AAerB,MAAMC,gBAAgB,gBAAGZ,KAAK,CAACa,aAAa,CAAuB;EACjEC,eAAe,EAAEL,UAAU;EAC3BM,0BAA0B,EAAEJ,IAAI;EAChCK,aAAa,EAAEP,UAAU;EACzBQ,kBAAkB,EAAER,UAAU;EAC9BS,oBAAoB,EAAE;AACxB,CAAC,CAAC;AAEF,MAAMC,mBAAmB,GAAGA,CAAA,KAAMnB,KAAK,CAACoB,UAAU,CAACR,gBAAgB,CAAC;AAEpE,SAASS,cAAcA,CACrBC,YAAuB,EAC6B;EACpD,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGvB,QAAQ,CAACqB,YAAY,CAAC;EAChD,MAAMG,iBAAiB,GAAIC,QAAmB,IAAK;IACjDxB,SAAS,CAAC,MAAMsB,QAAQ,CAACE,QAAQ,CAAC,EAAE,CAACA,QAAQ,CAAC,CAAC;EACjD,CAAC;EACD,O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;QAAED;MAAG,CAAC;IAC9B;IACA,OAAO;MAAE,GAAGC,UAAU;MAAEC,OAAO,EAAEf;IAAU,CAAC;EAC9C,CAAC;EAED,MAAMb,kBAAkB,GAAI6B,eAAoC,IAAK;IACnE,MAAMH,EAAE,GAAGP,oBAAoB,CAACU,eAAe,EAAEH,EAAE,CAAC;IACpD,OAAO;MAAE,GAAGG,eAAe;MAAEH;IAAG,CAAC;EACnC,CAAC;EAED,MAAMI,YAAkC,GAAG;IACzCjC,eAAe;IACfE,aAAa;IACbC,kBAAkB;IAClBF,0BAA0B;IAC1BwB,cAAc;IACdT,SAAS;IACTE,SAAS;IACTC,OAAO;IACPC,IAAI;IACJhB,oBAAoB,EAAE;EACxB,CAAC;EAED,oBACElB,KAAA,CAAAgD,aAAA,CAACpC,gBAAgB,CAACqC,QAAQ;IAACC,KAAK,EAAEH;EAAa,GAC5ClB,QACwB,CAAC;AAEhC;AAEA,SACEjB,gBAAgB,EAChBe,wBAAwB,EACxBR,mBAAmB","ignoreList":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
interface Props {
|
|
4
|
+
/** Specifies contents of the component. */
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
/** Specifies whether the component should be displayed with inline styling. */
|
|
7
|
+
isInline?: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare function FormLabel({ children, isInline, ...props }: Props & React.ComponentPropsWithoutRef<'label'>): React.ReactElement<Omit<React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "ref">, string | React.JSXElementConstructor<any>>;
|
|
10
|
+
declare namespace FormLabel {
|
|
11
|
+
var propTypes: {
|
|
12
|
+
/** Specifies class name to append to the base element. */
|
|
13
|
+
className: PropTypes.Requireable<string>;
|
|
14
|
+
/** Specifies contents of the component. */
|
|
15
|
+
children: PropTypes.Validator<NonNullable<PropTypes.ReactNodeLike>>;
|
|
16
|
+
/** Specifies whether the component should be displayed with inline styling. */
|
|
17
|
+
isInline: PropTypes.Requireable<boolean>;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export default FormLabel;
|
package/dist/Form/FormLabel.js
CHANGED
|
@@ -6,7 +6,7 @@ import { FORM_CONTROL_SIZES } from './constants';
|
|
|
6
6
|
function FormLabel(_ref) {
|
|
7
7
|
let {
|
|
8
8
|
children,
|
|
9
|
-
isInline,
|
|
9
|
+
isInline = false,
|
|
10
10
|
...props
|
|
11
11
|
} = _ref;
|
|
12
12
|
const {
|
|
@@ -26,21 +26,13 @@ function FormLabel(_ref) {
|
|
|
26
26
|
const componentType = isControlGroup ? 'p' : 'label';
|
|
27
27
|
return /*#__PURE__*/React.createElement(componentType, labelProps, children);
|
|
28
28
|
}
|
|
29
|
-
const SIZE_CHOICES = ['sm', 'lg'];
|
|
30
29
|
FormLabel.propTypes = {
|
|
31
30
|
/** Specifies class name to append to the base element. */
|
|
32
31
|
className: PropTypes.string,
|
|
33
32
|
/** Specifies contents of the component. */
|
|
34
33
|
children: PropTypes.node.isRequired,
|
|
35
34
|
/** Specifies whether the component should be displayed with inline styling. */
|
|
36
|
-
isInline: PropTypes.bool
|
|
37
|
-
/** Specifies size of the component. */
|
|
38
|
-
size: PropTypes.oneOf(SIZE_CHOICES)
|
|
39
|
-
};
|
|
40
|
-
FormLabel.defaultProps = {
|
|
41
|
-
isInline: false,
|
|
42
|
-
size: undefined,
|
|
43
|
-
className: undefined
|
|
35
|
+
isInline: PropTypes.bool
|
|
44
36
|
};
|
|
45
37
|
export default FormLabel;
|
|
46
38
|
//# sourceMappingURL=FormLabel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormLabel.js","names":["React","PropTypes","classNames","useFormGroupContext","FORM_CONTROL_SIZES","FormLabel","_ref","children","isInline","props","size","isControlGroup","getLabelProps","className","LARGE","SMALL","labelProps","componentType","createElement","
|
|
1
|
+
{"version":3,"file":"FormLabel.js","names":["React","PropTypes","classNames","useFormGroupContext","FORM_CONTROL_SIZES","FormLabel","_ref","children","isInline","props","size","isControlGroup","getLabelProps","className","LARGE","SMALL","labelProps","componentType","createElement","propTypes","string","node","isRequired","bool"],"sources":["../../src/Form/FormLabel.tsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport { useFormGroupContext } from './FormGroupContext';\nimport { FORM_CONTROL_SIZES } from './constants';\n\ninterface Props {\n /** Specifies contents of the component. */\n children: React.ReactNode;\n /** Specifies whether the component should be displayed with inline styling. */\n isInline?: boolean;\n}\n\nfunction FormLabel({ children, isInline = false, ...props }: Props & React.ComponentPropsWithoutRef<'label'>) {\n const { size, isControlGroup, getLabelProps } = useFormGroupContext();\n const className = classNames(\n 'pgn__form-label',\n {\n 'pgn__form-label-inline': isInline,\n 'pgn__form-label-lg': size === FORM_CONTROL_SIZES.LARGE,\n 'pgn__form-label-sm': size === FORM_CONTROL_SIZES.SMALL,\n },\n props.className,\n );\n const labelProps = getLabelProps({ ...props, className });\n const componentType = isControlGroup ? 'p' : 'label';\n return React.createElement(componentType, labelProps, children);\n}\n\nFormLabel.propTypes = {\n /** Specifies class name to append to the base element. */\n className: PropTypes.string,\n /** Specifies contents of the component. */\n children: PropTypes.node.isRequired,\n /** Specifies whether the component should be displayed with inline styling. */\n isInline: PropTypes.bool,\n};\n\nexport default FormLabel;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,UAAU,MAAM,YAAY;AACnC,SAASC,mBAAmB,QAAQ,oBAAoB;AACxD,SAASC,kBAAkB,QAAQ,aAAa;AAShD,SAASC,SAASA,CAAAC,IAAA,EAA4F;EAAA,IAA3F;IAAEC,QAAQ;IAAEC,QAAQ,GAAG,KAAK;IAAE,GAAGC;EAAuD,CAAC,GAAAH,IAAA;EAC1G,MAAM;IAAEI,IAAI;IAAEC,cAAc;IAAEC;EAAc,CAAC,GAAGT,mBAAmB,CAAC,CAAC;EACrE,MAAMU,SAAS,GAAGX,UAAU,CAC1B,iBAAiB,EACjB;IACE,wBAAwB,EAAEM,QAAQ;IAClC,oBAAoB,EAAEE,IAAI,KAAKN,kBAAkB,CAACU,KAAK;IACvD,oBAAoB,EAAEJ,IAAI,KAAKN,kBAAkB,CAACW;EACpD,CAAC,EACDN,KAAK,CAACI,SACR,CAAC;EACD,MAAMG,UAAU,GAAGJ,aAAa,CAAC;IAAE,GAAGH,KAAK;IAAEI;EAAU,CAAC,CAAC;EACzD,MAAMI,aAAa,GAAGN,cAAc,GAAG,GAAG,GAAG,OAAO;EACpD,oBAAOX,KAAK,CAACkB,aAAa,CAACD,aAAa,EAAED,UAAU,EAAET,QAAQ,CAAC;AACjE;AAEAF,SAAS,CAACc,SAAS,GAAG;EACpB;EACAN,SAAS,EAAEZ,SAAS,CAACmB,MAAM;EAC3B;EACAb,QAAQ,EAAEN,SAAS,CAACoB,IAAI,CAACC,UAAU;EACnC;EACAd,QAAQ,EAAEP,SAAS,CAACsB;AACtB,CAAC;AAED,eAAelB,SAAS","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const FORM_CONTROL_SIZES: {
|
|
2
|
+
readonly SMALL: "sm";
|
|
3
|
+
readonly LARGE: "lg";
|
|
4
|
+
};
|
|
5
|
+
export declare const FORM_TEXT_TYPES: {
|
|
6
|
+
readonly DEFAULT: "default";
|
|
7
|
+
readonly VALID: "valid";
|
|
8
|
+
readonly INVALID: "invalid";
|
|
9
|
+
readonly WARNING: "warning";
|
|
10
|
+
readonly CRITERIA_EMPTY: "criteria-empty";
|
|
11
|
+
readonly CRITERIA_VALID: "criteria-valid";
|
|
12
|
+
readonly CRITERIA_INVALID: "criteria-invalid";
|
|
13
|
+
};
|
package/dist/Form/constants.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
const FORM_CONTROL_SIZES = {
|
|
1
|
+
export const FORM_CONTROL_SIZES = {
|
|
3
2
|
SMALL: 'sm',
|
|
4
|
-
LARGE: 'lg'
|
|
3
|
+
LARGE: 'lg'
|
|
5
4
|
};
|
|
6
|
-
|
|
7
|
-
const FORM_TEXT_TYPES = {
|
|
5
|
+
export const FORM_TEXT_TYPES = {
|
|
8
6
|
DEFAULT: 'default',
|
|
9
7
|
VALID: 'valid',
|
|
10
8
|
INVALID: 'invalid',
|
|
11
9
|
WARNING: 'warning',
|
|
12
10
|
CRITERIA_EMPTY: 'criteria-empty',
|
|
13
11
|
CRITERIA_VALID: 'criteria-valid',
|
|
14
|
-
CRITERIA_INVALID: 'criteria-invalid'
|
|
12
|
+
CRITERIA_INVALID: 'criteria-invalid'
|
|
15
13
|
};
|
|
16
|
-
|
|
17
|
-
export { FORM_CONTROL_SIZES, FORM_TEXT_TYPES };
|
|
14
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","names":["FORM_CONTROL_SIZES","SMALL","LARGE","FORM_TEXT_TYPES","DEFAULT","VALID","INVALID","WARNING","CRITERIA_EMPTY","CRITERIA_VALID","CRITERIA_INVALID"],"sources":["../../src/Form/constants.ts"],"sourcesContent":["export const FORM_CONTROL_SIZES = {\n SMALL: 'sm',\n LARGE: 'lg',\n} as const;\n\nexport const FORM_TEXT_TYPES = {\n DEFAULT: 'default',\n VALID: 'valid',\n INVALID: 'invalid',\n WARNING: 'warning',\n CRITERIA_EMPTY: 'criteria-empty',\n CRITERIA_VALID: 'criteria-valid',\n CRITERIA_INVALID: 'criteria-invalid',\n} as const;\n"],"mappings":"AAAA,OAAO,MAAMA,kBAAkB,GAAG;EAChCC,KAAK,EAAE,IAAI;EACXC,KAAK,EAAE;AACT,CAAU;AAEV,OAAO,MAAMC,eAAe,GAAG;EAC7BC,OAAO,EAAE,SAAS;EAClBC,KAAK,EAAE,OAAO;EACdC,OAAO,EAAE,SAAS;EAClBC,OAAO,EAAE,SAAS;EAClBC,cAAc,EAAE,gBAAgB;EAChCC,cAAc,EAAE,gBAAgB;EAChCC,gBAAgB,EAAE;AACpB,CAAU","ignoreList":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare const omitUndefinedProperties: (obj?: {}) => Record<string, any>;
|
|
2
|
+
declare const callAllHandlers: <EventType extends Object>(...handlers: ((event: EventType) => void)[]) => (event: EventType) => void;
|
|
3
|
+
declare const useHasValue: <ValueType>({ defaultValue, value }: {
|
|
4
|
+
defaultValue?: ValueType | undefined;
|
|
5
|
+
value?: ValueType | undefined;
|
|
6
|
+
}) => (boolean | ((e: React.ChangeEvent<HTMLInputElement>) => void))[];
|
|
7
|
+
declare const useIdList: (uniqueIdPrefix: string, initialList?: string[]) => [idList: string[], useRegisteredId: (id: string | undefined) => string | undefined];
|
|
8
|
+
declare const mergeAttributeValues: (...values: (string | undefined)[]) => string | undefined;
|
|
9
|
+
export { callAllHandlers, useHasValue, mergeAttributeValues, useIdList, omitUndefinedProperties, };
|
package/dist/Form/fieldUtils.js
CHANGED
|
@@ -1,34 +1,38 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
2
|
import { useState, useEffect } from 'react';
|
|
3
3
|
import { newId } from '../utils';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
.reduce((acc,
|
|
4
|
+
const omitUndefinedProperties = function () {
|
|
5
|
+
let obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
6
|
+
return Object.entries(obj).reduce((acc, _ref) => {
|
|
7
|
+
let [key, value] = _ref;
|
|
7
8
|
if (value !== undefined) {
|
|
8
9
|
acc[key] = value;
|
|
9
10
|
}
|
|
10
11
|
return acc;
|
|
11
12
|
}, {});
|
|
12
|
-
|
|
13
|
-
const callAllHandlers = (
|
|
14
|
-
|
|
15
|
-
handlers
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
};
|
|
14
|
+
const callAllHandlers = function () {
|
|
15
|
+
for (var _len = arguments.length, handlers = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
16
|
+
handlers[_key] = arguments[_key];
|
|
17
|
+
}
|
|
18
|
+
const unifiedEventHandler = event => {
|
|
19
|
+
handlers.filter(handler => typeof handler === 'function').forEach(handler => handler(event));
|
|
18
20
|
};
|
|
19
21
|
return unifiedEventHandler;
|
|
20
22
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
const useHasValue = _ref2 => {
|
|
24
|
+
let {
|
|
25
|
+
defaultValue,
|
|
26
|
+
value
|
|
27
|
+
} = _ref2;
|
|
23
28
|
const [hasUncontrolledValue, setHasUncontrolledValue] = useState(!!defaultValue || defaultValue === 0);
|
|
24
29
|
const hasValue = !!value || value === 0 || hasUncontrolledValue;
|
|
25
|
-
const handleInputEvent =
|
|
30
|
+
const handleInputEvent = e => setHasUncontrolledValue(!!e.target.value);
|
|
26
31
|
return [hasValue, handleInputEvent];
|
|
27
32
|
};
|
|
28
|
-
|
|
29
33
|
const useIdList = (uniqueIdPrefix, initialList) => {
|
|
30
34
|
const [idList, setIdList] = useState(initialList || []);
|
|
31
|
-
const addId =
|
|
35
|
+
const addId = idToAdd => {
|
|
32
36
|
setIdList(oldIdList => [...oldIdList, idToAdd]);
|
|
33
37
|
return idToAdd;
|
|
34
38
|
};
|
|
@@ -36,35 +40,29 @@ const useIdList = (uniqueIdPrefix, initialList) => {
|
|
|
36
40
|
const idToAdd = newId(`${uniqueIdPrefix}-`);
|
|
37
41
|
return addId(idToAdd);
|
|
38
42
|
};
|
|
39
|
-
const removeId =
|
|
43
|
+
const removeId = idToRemove => {
|
|
40
44
|
setIdList(oldIdList => oldIdList.filter(id => id !== idToRemove));
|
|
41
45
|
};
|
|
42
|
-
|
|
43
|
-
const useRegisteredId = (explicitlyRegisteredId) => {
|
|
46
|
+
const useRegisteredId = explicitlyRegisteredId => {
|
|
44
47
|
const [registeredId, setRegisteredId] = useState(explicitlyRegisteredId);
|
|
45
48
|
useEffect(() => {
|
|
46
49
|
if (explicitlyRegisteredId) {
|
|
47
50
|
addId(explicitlyRegisteredId);
|
|
48
51
|
} else if (!registeredId) {
|
|
49
|
-
setRegisteredId(getNewId(
|
|
52
|
+
setRegisteredId(getNewId());
|
|
50
53
|
}
|
|
51
54
|
return () => removeId(registeredId);
|
|
52
55
|
}, [registeredId, explicitlyRegisteredId]);
|
|
53
56
|
return registeredId;
|
|
54
57
|
};
|
|
55
|
-
|
|
56
58
|
return [idList, useRegisteredId];
|
|
57
59
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
const mergeAttributeValues = function () {
|
|
61
|
+
for (var _len2 = arguments.length, values = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
62
|
+
values[_key2] = arguments[_key2];
|
|
63
|
+
}
|
|
60
64
|
const mergedValues = classNames(values);
|
|
61
65
|
return mergedValues || undefined;
|
|
62
66
|
};
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
callAllHandlers,
|
|
66
|
-
useHasValue,
|
|
67
|
-
mergeAttributeValues,
|
|
68
|
-
useIdList,
|
|
69
|
-
omitUndefinedProperties,
|
|
70
|
-
};
|
|
67
|
+
export { callAllHandlers, useHasValue, mergeAttributeValues, useIdList, omitUndefinedProperties };
|
|
68
|
+
//# sourceMappingURL=fieldUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fieldUtils.js","names":["classNames","useState","useEffect","newId","omitUndefinedProperties","obj","arguments","length","undefined","Object","entries","reduce","acc","_ref","key","value","callAllHandlers","_len","handlers","Array","_key","unifiedEventHandler","event","filter","handler","forEach","useHasValue","_ref2","defaultValue","hasUncontrolledValue","setHasUncontrolledValue","hasValue","handleInputEvent","e","target","useIdList","uniqueIdPrefix","initialList","idList","setIdList","addId","idToAdd","oldIdList","getNewId","removeId","idToRemove","id","useRegisteredId","explicitlyRegisteredId","registeredId","setRegisteredId","mergeAttributeValues","_len2","values","_key2","mergedValues"],"sources":["../../src/Form/fieldUtils.ts"],"sourcesContent":["import classNames from 'classnames';\nimport { useState, useEffect } from 'react';\nimport { newId } from '../utils';\n\nconst omitUndefinedProperties = (obj = {}) => Object.entries(obj)\n .reduce((acc, [key, value]) => {\n if (value !== undefined) {\n acc[key] = value;\n }\n return acc;\n }, {} as Record<string, any>);\n\nconst callAllHandlers = <EventType extends Object>(...handlers: ((event: EventType) => void)[]) => {\n const unifiedEventHandler = (event: EventType) => {\n handlers\n .filter(handler => typeof handler === 'function')\n .forEach(handler => handler(event));\n };\n return unifiedEventHandler;\n};\n\nconst useHasValue = <ValueType>({ defaultValue, value }: { defaultValue?: ValueType, value?: ValueType }) => {\n const [hasUncontrolledValue, setHasUncontrolledValue] = useState(!!defaultValue || defaultValue === 0);\n const hasValue = !!value || value === 0 || hasUncontrolledValue;\n const handleInputEvent = (e: React.ChangeEvent<HTMLInputElement>) => setHasUncontrolledValue(!!e.target.value);\n return [hasValue, handleInputEvent];\n};\n\nconst useIdList = (\n uniqueIdPrefix: string,\n initialList?: string[],\n): [idList: string[], useRegisteredId: (id: string | undefined) => string | undefined] => {\n const [idList, setIdList] = useState(initialList || []);\n const addId = (idToAdd: string) => {\n setIdList(oldIdList => [...oldIdList, idToAdd]);\n return idToAdd;\n };\n const getNewId = () => {\n const idToAdd = newId(`${uniqueIdPrefix}-`);\n return addId(idToAdd);\n };\n const removeId = (idToRemove: string | undefined) => {\n setIdList(oldIdList => oldIdList.filter(id => id !== idToRemove));\n };\n\n const useRegisteredId = (explicitlyRegisteredId: string | undefined) => {\n const [registeredId, setRegisteredId] = useState(explicitlyRegisteredId);\n useEffect(() => {\n if (explicitlyRegisteredId) {\n addId(explicitlyRegisteredId);\n } else if (!registeredId) {\n setRegisteredId(getNewId());\n }\n return () => removeId(registeredId);\n }, [registeredId, explicitlyRegisteredId]);\n return registeredId;\n };\n\n return [idList, useRegisteredId];\n};\n\nconst mergeAttributeValues = (...values: (string | undefined)[]) => {\n const mergedValues = classNames(values);\n return mergedValues || undefined;\n};\n\nexport {\n callAllHandlers,\n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AAC,CAAC,CAAC;MAC7B;MACA,OAAO,MAAMC,QAAQ,CAACK,YAAY,CAAC;IACrC,CAAC,EAAE,CAACA,YAAY,EAAED,sBAAsB,CAAC,CAAC;IAC1C,OAAOC,YAAY;EACrB,CAAC;EAED,OAAO,CAACX,MAAM,EAAES,eAAe,CAAC;AAClC,CAAC;AAED,MAAMI,oBAAoB,GAAG,SAAAA,CAAA,EAAuC;EAAA,SAAAC,KAAA,GAAA9C,SAAA,CAAAC,MAAA,EAAnC8C,MAAM,OAAAlC,KAAA,CAAAiC,KAAA,GAAAE,KAAA,MAAAA,KAAA,GAAAF,KAAA,EAAAE,KAAA;IAAND,MAAM,CAAAC,KAAA,IAAAhD,SAAA,CAAAgD,KAAA;EAAA;EACrC,MAAMC,YAAY,GAAGvD,UAAU,CAACqD,MAAM,CAAC;EACvC,OAAOE,YAAY,IAAI/C,SAAS;AAClC,CAAC;AAED,SACEQ,eAAe,EACfU,WAAW,EACXyB,oBAAoB,EACpBhB,SAAS,EACT/B,uBAAuB","ignoreList":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import BootstrapForm, { FormProps } from 'react-bootstrap/Form';
|
|
2
|
+
import { ComponentWithAsProp } from '../utils/types/bootstrap';
|
|
3
|
+
import FormControl from './FormControl';
|
|
4
|
+
import FormLabel from './FormLabel';
|
|
5
|
+
import FormGroup from './FormGroup';
|
|
6
|
+
import FormControlFeedback from './FormControlFeedback';
|
|
7
|
+
import FormText from './FormText';
|
|
8
|
+
import FormControlDecoratorGroup from './FormControlDecoratorGroup';
|
|
9
|
+
import FormRadio, { RadioControl } from './FormRadio';
|
|
10
|
+
import FormRadioSet from './FormRadioSet';
|
|
11
|
+
import FormRadioSetContext from './FormRadioSetContext';
|
|
12
|
+
import FormAutosuggest from './FormAutosuggest';
|
|
13
|
+
import FormAutosuggestOption from './FormAutosuggestOption';
|
|
14
|
+
import FormCheckbox, { CheckboxControl } from './FormCheckbox';
|
|
15
|
+
import FormSwitch, { SwitchControl } from './FormSwitch';
|
|
16
|
+
import FormCheckboxSet from './FormCheckboxSet';
|
|
17
|
+
import FormSwitchSet from './FormSwitchSet';
|
|
18
|
+
import FormCheckboxSetContext from './FormCheckboxSetContext';
|
|
19
|
+
import useCheckboxSetValues from './useCheckboxSetValues';
|
|
20
|
+
declare const Form: ComponentWithAsProp<"form", FormProps> & {
|
|
21
|
+
Control: any;
|
|
22
|
+
Radio: any;
|
|
23
|
+
RadioSet: any;
|
|
24
|
+
Autosuggest: any;
|
|
25
|
+
AutosuggestOption: any;
|
|
26
|
+
Checkbox: any;
|
|
27
|
+
CheckboxSet: any;
|
|
28
|
+
Row: typeof BootstrapForm.Row;
|
|
29
|
+
Switch: any;
|
|
30
|
+
SwitchSet: any;
|
|
31
|
+
Label: typeof FormLabel;
|
|
32
|
+
Group: typeof FormGroup;
|
|
33
|
+
Text: any;
|
|
34
|
+
};
|
|
35
|
+
export default Form;
|
|
36
|
+
export { FormControl, FormLabel, FormRadio, FormRadioSet, FormRadioSetContext, FormCheckbox, FormSwitch, FormAutosuggest, FormAutosuggestOption, FormCheckboxSet, FormCheckboxSetContext, FormGroup, FormControlDecoratorGroup, FormControlFeedback, FormText, CheckboxControl, RadioControl, SwitchControl, FormSwitchSet, useCheckboxSetValues, };
|
|
37
|
+
export { default as FormCheck } from 'react-bootstrap/FormCheck';
|
|
38
|
+
export { default as FormFile } from 'react-bootstrap/FormFile';
|
|
39
|
+
export { default as InputGroup } from 'react-bootstrap/InputGroup';
|
package/dist/Form/index.js
CHANGED
|
@@ -1,21 +1,38 @@
|
|
|
1
|
-
import
|
|
1
|
+
import BootstrapForm from 'react-bootstrap/Form';
|
|
2
|
+
// TODO: add more typing and remove the @ts-ignore directives here
|
|
3
|
+
// @ts-ignore
|
|
2
4
|
import FormControl from './FormControl';
|
|
3
5
|
import FormLabel from './FormLabel';
|
|
4
6
|
import FormGroup from './FormGroup';
|
|
7
|
+
// @ts-ignore
|
|
5
8
|
import FormControlFeedback from './FormControlFeedback';
|
|
9
|
+
// @ts-ignore
|
|
6
10
|
import FormText from './FormText';
|
|
11
|
+
// @ts-ignore
|
|
7
12
|
import FormControlDecoratorGroup from './FormControlDecoratorGroup';
|
|
13
|
+
// @ts-ignore
|
|
8
14
|
import FormRadio, { RadioControl } from './FormRadio';
|
|
15
|
+
// @ts-ignore
|
|
9
16
|
import FormRadioSet from './FormRadioSet';
|
|
17
|
+
// @ts-ignore
|
|
10
18
|
import FormRadioSetContext from './FormRadioSetContext';
|
|
19
|
+
// @ts-ignore
|
|
11
20
|
import FormAutosuggest from './FormAutosuggest';
|
|
21
|
+
// @ts-ignore
|
|
12
22
|
import FormAutosuggestOption from './FormAutosuggestOption';
|
|
23
|
+
// @ts-ignore
|
|
13
24
|
import FormCheckbox, { CheckboxControl } from './FormCheckbox';
|
|
25
|
+
// @ts-ignore
|
|
14
26
|
import FormSwitch, { SwitchControl } from './FormSwitch';
|
|
27
|
+
// @ts-ignore
|
|
15
28
|
import FormCheckboxSet from './FormCheckboxSet';
|
|
29
|
+
// @ts-ignore
|
|
16
30
|
import FormSwitchSet from './FormSwitchSet';
|
|
31
|
+
// @ts-ignore
|
|
17
32
|
import FormCheckboxSetContext from './FormCheckboxSetContext';
|
|
33
|
+
// @ts-ignore
|
|
18
34
|
import useCheckboxSetValues from './useCheckboxSetValues';
|
|
35
|
+
const Form = BootstrapForm;
|
|
19
36
|
Form.Control = FormControl;
|
|
20
37
|
Form.Radio = FormRadio;
|
|
21
38
|
Form.RadioSet = FormRadioSet;
|
package/dist/Form/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["BootstrapForm","FormControl","FormLabel","FormGroup","FormControlFeedback","FormText","FormControlDecoratorGroup","FormRadio","RadioControl","FormRadioSet","FormRadioSetContext","FormAutosuggest","FormAutosuggestOption","FormCheckbox","CheckboxControl","FormSwitch","SwitchControl","FormCheckboxSet","FormSwitchSet","FormCheckboxSetContext","useCheckboxSetValues","Form","Control","Radio","RadioSet","Autosuggest","AutosuggestOption","Checkbox","CheckboxSet","Switch","SwitchSet","Label","Group","Text","default","FormCheck","FormFile","InputGroup"],"sources":["../../src/Form/index.tsx"],"sourcesContent":["import BootstrapForm, { FormProps } from 'react-bootstrap/Form';\nimport { ComponentWithAsProp } from '../utils/types/bootstrap';\n// TODO: add more typing and remove the @ts-ignore directives here\n// @ts-ignore\nimport FormControl from './FormControl';\nimport FormLabel from './FormLabel';\nimport FormGroup from './FormGroup';\n// @ts-ignore\nimport FormControlFeedback from './FormControlFeedback';\n// @ts-ignore\nimport FormText from './FormText';\n// @ts-ignore\nimport FormControlDecoratorGroup from './FormControlDecoratorGroup';\n// @ts-ignore\nimport FormRadio, { RadioControl } from './FormRadio';\n// @ts-ignore\nimport FormRadioSet from './FormRadioSet';\n// @ts-ignore\nimport FormRadioSetContext from './FormRadioSetContext';\n// @ts-ignore\nimport FormAutosuggest from './FormAutosuggest';\n// @ts-ignore\nimport FormAutosuggestOption from './FormAutosuggestOption';\n// @ts-ignore\nimport FormCheckbox, { CheckboxControl } from './FormCheckbox';\n// @ts-ignore\nimport FormSwitch, { SwitchControl } from './FormSwitch';\n// @ts-ignore\nimport FormCheckboxSet from './FormCheckboxSet';\n// @ts-ignore\nimport FormSwitchSet from './FormSwitchSet';\n// @ts-ignore\nimport FormCheckboxSetContext from './FormCheckboxSetContext';\n// @ts-ignore\nimport useCheckboxSetValues from './useCheckboxSetValues';\n\nconst Form = BootstrapForm as any as ComponentWithAsProp<'form', FormProps> & {\n Control: typeof FormControl;\n Radio: typeof FormRadio;\n RadioSet: typeof FormRadioSet;\n Autosuggest: typeof FormAutosuggest;\n AutosuggestOption: typeof FormAutosuggestOption;\n Checkbox: typeof FormCheckbox;\n CheckboxSet: typeof FormCheckboxSet;\n Row: typeof BootstrapForm.Row;\n Switch: typeof FormSwitch;\n SwitchSet: typeof FormSwitchSet;\n Label: typeof FormLabel;\n Group: typeof FormGroup;\n Text: typeof FormText;\n};\nForm.Control = FormControl;\nForm.Radio = FormRadio;\nForm.RadioSet = FormRadioSet;\nForm.Autosuggest = FormAutosuggest;\nForm.AutosuggestOption = FormAutosuggestOption;\nForm.Checkbox = FormCheckbox;\nForm.CheckboxSet = FormCheckboxSet;\nForm.Switch = FormSwitch;\nForm.SwitchSet = FormSwitchSet;\nForm.Label = FormLabel;\nForm.Group = FormGroup;\nForm.Text = FormText;\n\nexport default Form;\nexport {\n FormControl,\n FormLabel,\n FormRadio,\n FormRadioSet,\n FormRadioSetContext,\n FormCheckbox,\n FormSwitch,\n FormAutosuggest,\n FormAutosuggestOption,\n FormCheckboxSet,\n FormCheckboxSetContext,\n FormGroup,\n FormControlDecoratorGroup,\n FormControlFeedback,\n FormText,\n CheckboxControl,\n RadioControl,\n SwitchControl,\n FormSwitchSet,\n useCheckboxSetValues,\n};\n\nexport { default as FormCheck } from 'react-bootstrap/FormCheck';\nexport { default as FormFile } from 'react-bootstrap/FormFile';\nexport { default as InputGroup } from 'react-bootstrap/InputGroup';\n"],"mappings":"AAAA,OAAOA,aAAa,MAAqB,sBAAsB;AAE/D;AACA;AACA,OAAOC,WAAW,MAAM,eAAe;AACvC,OAAOC,SAAS,MAAM,aAAa;AACnC,OAAOC,SAAS,MAAM,aAAa;AACnC;AACA,OAAOC,mBAAmB,MAAM,uBAAuB;AACvD;AACA,OAAOC,QAAQ,MAAM,YAAY;AACjC;AACA,OAAOC,yBAAyB,MAAM,6BAA6B;AACnE;AACA,OAAOC,SAAS,IAAIC,YAAY,QAAQ,aAAa;AACrD;AACA,OAAOC,YAAY,MAAM,gBAAgB;AACzC;AACA,OAAOC,mBAAmB,MAAM,uBAAuB;AACvD;AACA,OAAOC,eAAe,MAAM,mBAAmB;AAC/C;AACA,OAAOC,qBAAqB,MAAM,yBAAyB;AAC3D;AACA,OAAOC,YAAY,IAAIC,eAAe,QAAQ,gBAAgB;AAC9D;AACA,OAAOC,UAAU,IAAIC,aAAa,Q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|
|
2
|
-
|
|
3
2
|
const messages = defineMessages({
|
|
4
3
|
iconButtonOpened: {
|
|
5
4
|
id: 'pgn.FormAutosuggest.iconButtonOpened',
|
|
6
5
|
defaultMessage: 'Open the options menu',
|
|
7
|
-
description: 'A message shown in case when the autosuggest menu is closed.'
|
|
6
|
+
description: 'A message shown in case when the autosuggest menu is closed.'
|
|
8
7
|
},
|
|
9
8
|
iconButtonClosed: {
|
|
10
9
|
id: 'pgn.FormAutosuggest.iconButtonClosed',
|
|
11
10
|
defaultMessage: 'Close the options menu',
|
|
12
|
-
description: 'A message shown in case when the autosuggest menu is opened.'
|
|
13
|
-
}
|
|
11
|
+
description: 'A message shown in case when the autosuggest menu is opened.'
|
|
12
|
+
}
|
|
14
13
|
});
|
|
15
|
-
|
|
16
14
|
export default messages;
|
|
15
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","names":["defineMessages","messages","iconButtonOpened","id","defaultMessage","description","iconButtonClosed"],"sources":["../../src/Form/messages.ts"],"sourcesContent":["import { defineMessages } from 'react-intl';\n\nconst messages = defineMessages({\n iconButtonOpened: {\n id: 'pgn.FormAutosuggest.iconButtonOpened',\n defaultMessage: 'Open the options menu',\n description: 'A message shown in case when the autosuggest menu is closed.',\n },\n iconButtonClosed: {\n id: 'pgn.FormAutosuggest.iconButtonClosed',\n defaultMessage: 'Close the options menu',\n description: 'A message shown in case when the autosuggest menu is opened.',\n },\n});\n\nexport default messages;\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ,YAAY;AAE3C,MAAMC,QAAQ,GAAGD,cAAc,CAAC;EAC9BE,gBAAgB,EAAE;IAChBC,EAAE,EAAE,sCAAsC;IAC1CC,cAAc,EAAE,uBAAuB;IACvCC,WAAW,EAAE;EACf,CAAC;EACDC,gBAAgB,EAAE;IAChBH,EAAE,EAAE,sCAAsC;IAC1CC,cAAc,EAAE,wBAAwB;IACxCC,WAAW,EAAE;EACf;AACF,CAAC,CAAC;AAEF,eAAeJ,QAAQ","ignoreList":[]}
|
|
@@ -33,6 +33,8 @@ interface Props extends React.HTMLAttributes<HTMLButtonElement> {
|
|
|
33
33
|
variant?: 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'light' | 'dark' | 'black' | 'brand';
|
|
34
34
|
/** size of button to render */
|
|
35
35
|
size?: 'sm' | 'md' | 'inline';
|
|
36
|
+
/** Used with `IconButtonToggle` */
|
|
37
|
+
value?: string;
|
|
36
38
|
/** no children */
|
|
37
39
|
children?: never;
|
|
38
40
|
}
|
|
@@ -64,6 +66,7 @@ declare namespace IconButtonWithTooltip {
|
|
|
64
66
|
} | undefined;
|
|
65
67
|
variant?: "primary" | "success" | "warning" | "secondary" | "danger" | "dark" | "light" | "black" | "brand" | undefined;
|
|
66
68
|
size?: "sm" | "md" | "inline" | undefined;
|
|
69
|
+
value?: string | undefined;
|
|
67
70
|
children?: undefined;
|
|
68
71
|
defaultChecked?: boolean | undefined;
|
|
69
72
|
defaultValue?: string | number | readonly string[] | undefined;
|