@elliemae/ds-legacy-classnames 1.0.0-rc.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/dist/cjs/aggregatedClasses.js +87 -0
- package/dist/cjs/aggregatedClasses.js.map +7 -0
- package/dist/cjs/aggregatedClasses.md +323 -0
- package/dist/cjs/classNameManager.js +84 -0
- package/dist/cjs/classNameManager.js.map +7 -0
- package/dist/cjs/converPropsToFormModifiers.js +59 -0
- package/dist/cjs/converPropsToFormModifiers.js.map +7 -0
- package/dist/cjs/convertPropToFeedBackModifiers.js +61 -0
- package/dist/cjs/convertPropToFeedBackModifiers.js.map +7 -0
- package/dist/cjs/convertPropsToColorModifiers.js +59 -0
- package/dist/cjs/convertPropsToColorModifiers.js.map +7 -0
- package/dist/cjs/convertPropsToLayoutModifiers.js +61 -0
- package/dist/cjs/convertPropsToLayoutModifiers.js.map +7 -0
- package/dist/cjs/convertPropsToSizeModifiers.js +78 -0
- package/dist/cjs/convertPropsToSizeModifiers.js.map +7 -0
- package/dist/cjs/convertPropsToTextModifiers.js +59 -0
- package/dist/cjs/convertPropsToTextModifiers.js.map +7 -0
- package/dist/cjs/dimsum.config.js +38 -0
- package/dist/cjs/dimsum.config.js.map +7 -0
- package/dist/cjs/index.js +39 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/package.json +7 -0
- package/dist/cjs/validateNativeProps.js +430 -0
- package/dist/cjs/validateNativeProps.js.map +7 -0
- package/dist/esm/aggregatedClasses.js +60 -0
- package/dist/esm/aggregatedClasses.js.map +7 -0
- package/dist/esm/aggregatedClasses.md +323 -0
- package/dist/esm/classNameManager.js +54 -0
- package/dist/esm/classNameManager.js.map +7 -0
- package/dist/esm/converPropsToFormModifiers.js +29 -0
- package/dist/esm/converPropsToFormModifiers.js.map +7 -0
- package/dist/esm/convertPropToFeedBackModifiers.js +31 -0
- package/dist/esm/convertPropToFeedBackModifiers.js.map +7 -0
- package/dist/esm/convertPropsToColorModifiers.js +29 -0
- package/dist/esm/convertPropsToColorModifiers.js.map +7 -0
- package/dist/esm/convertPropsToLayoutModifiers.js +31 -0
- package/dist/esm/convertPropsToLayoutModifiers.js.map +7 -0
- package/dist/esm/convertPropsToSizeModifiers.js +48 -0
- package/dist/esm/convertPropsToSizeModifiers.js.map +7 -0
- package/dist/esm/convertPropsToTextModifiers.js +29 -0
- package/dist/esm/convertPropsToTextModifiers.js.map +7 -0
- package/dist/esm/dimsum.config.js +8 -0
- package/dist/esm/dimsum.config.js.map +7 -0
- package/dist/esm/index.js +9 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/package.json +7 -0
- package/dist/esm/validateNativeProps.js +400 -0
- package/dist/esm/validateNativeProps.js.map +7 -0
- package/dist/types/aggregatedClasses.d.ts +11 -0
- package/dist/types/classNameManager.d.ts +28 -0
- package/dist/types/converPropsToFormModifiers.d.ts +15 -0
- package/dist/types/convertPropToFeedBackModifiers.d.ts +17 -0
- package/dist/types/convertPropsToColorModifiers.d.ts +11 -0
- package/dist/types/convertPropsToLayoutModifiers.d.ts +17 -0
- package/dist/types/convertPropsToSizeModifiers.d.ts +25 -0
- package/dist/types/convertPropsToTextModifiers.d.ts +15 -0
- package/dist/types/dimsum.config.d.ts +4 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/validateNativeProps.d.ts +265 -0
- package/package.json +102 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var aggregatedClasses_exports = {};
|
|
30
|
+
__export(aggregatedClasses_exports, {
|
|
31
|
+
cssPrefix: () => cssPrefix,
|
|
32
|
+
default: () => aggregatedClasses_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(aggregatedClasses_exports);
|
|
35
|
+
var React = __toESM(require("react"));
|
|
36
|
+
var import_react = __toESM(require("react"));
|
|
37
|
+
var import_obj_str = __toESM(require("obj-str"));
|
|
38
|
+
var import_classNameManager = require("./classNameManager.js");
|
|
39
|
+
var import_dimsum_config = require("./dimsum.config.js");
|
|
40
|
+
var import_validateNativeProps = require("./validateNativeProps.js");
|
|
41
|
+
const cssPrefix = import_dimsum_config.dimsumConfig.classNamePrefix;
|
|
42
|
+
const generateClassNameWithModifier = (block, element, modifier) => `${cssPrefix}-${block}${element ? `__${element}` : ""}--${modifier}`;
|
|
43
|
+
const appendBlockAndPrefixToObj = (obj, block, element) => obj ? Object.keys(obj).reduce(
|
|
44
|
+
(acc, key) => ({
|
|
45
|
+
...acc,
|
|
46
|
+
[`${generateClassNameWithModifier(block, element, key)}`]: obj[key]
|
|
47
|
+
}),
|
|
48
|
+
{}
|
|
49
|
+
) : [];
|
|
50
|
+
const aggregatedClasses = (type, props) => (block, element, additionalModifiers, options = {}) => import_react.default.forwardRef(({ innerRef, children, classProps, useComponent, className, as, ...rest }, ref) => {
|
|
51
|
+
let otherModifiers = appendBlockAndPrefixToObj(additionalModifiers, block, element);
|
|
52
|
+
if (typeof additionalModifiers === "function")
|
|
53
|
+
otherModifiers = appendBlockAndPrefixToObj(
|
|
54
|
+
additionalModifiers({ ...rest, ...classProps, className }),
|
|
55
|
+
block,
|
|
56
|
+
element
|
|
57
|
+
);
|
|
58
|
+
const otherModifiersStr = (0, import_obj_str.default)(otherModifiers);
|
|
59
|
+
const { prefix, propsToRemoveFromFinalElement = [] } = options;
|
|
60
|
+
const { cssClassName: classNames } = (0, import_classNameManager.convertPropToCssClassName)(
|
|
61
|
+
block,
|
|
62
|
+
null,
|
|
63
|
+
{ ...classProps },
|
|
64
|
+
{ prefix, element }
|
|
65
|
+
);
|
|
66
|
+
const cleanedPropsPassedDown = { ...props, ...rest };
|
|
67
|
+
propsToRemoveFromFinalElement.forEach((propKey) => {
|
|
68
|
+
delete cleanedPropsPassedDown[propKey];
|
|
69
|
+
});
|
|
70
|
+
if ((0, import_validateNativeProps.isNativeHTMLElement)(block)) {
|
|
71
|
+
Object.keys(cleanedPropsPassedDown).forEach((key) => {
|
|
72
|
+
if (!(0, import_validateNativeProps.isValidNativeAttribute)(key))
|
|
73
|
+
delete cleanedPropsPassedDown[key];
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
return import_react.default.createElement(
|
|
77
|
+
as || type,
|
|
78
|
+
{
|
|
79
|
+
ref: innerRef || ref,
|
|
80
|
+
className: [classNames, otherModifiersStr, className].join(" "),
|
|
81
|
+
...cleanedPropsPassedDown
|
|
82
|
+
},
|
|
83
|
+
children
|
|
84
|
+
);
|
|
85
|
+
});
|
|
86
|
+
var aggregatedClasses_default = aggregatedClasses;
|
|
87
|
+
//# sourceMappingURL=aggregatedClasses.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/aggregatedClasses.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable prettier/prettier */\n/* eslint-disable max-params */\n/* eslint-disable react/prop-types */\nimport React from 'react';\nimport cx from 'obj-str';\nimport { convertPropToCssClassName } from './classNameManager.js';\nimport { dimsumConfig } from './dimsum.config.js';\nimport {\n isValidNativeAttribute,\n isNativeHTMLElement,\n} from './validateNativeProps.js';\n\nexport const cssPrefix = dimsumConfig.classNamePrefix;\n\ntype AggregatedClassesT<T = unknown> = (\n type: any,\n props?: any,\n) => (\n block: string,\n element?: string | null,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n additionalModifiers?: { [key: string]: unknown } | ((arg: any) => { [key: string]: unknown }),\n options?: { [key: string]: unknown },\n) => React.ForwardRefExoticComponent<React.RefAttributes<T>>;\n\nconst generateClassNameWithModifier = (block, element, modifier) =>\n `${cssPrefix}-${block}${element ? `__${element}` : ''}--${modifier}`;\n\nconst appendBlockAndPrefixToObj = (obj, block, element) =>\n obj\n ? Object.keys(obj).reduce(\n (acc, key) => ({\n ...acc,\n [`${generateClassNameWithModifier(block, element, key)}`]: obj[key],\n }),\n {},\n )\n : [];\n\nconst aggregatedClasses: AggregatedClassesT=\n (type, props) =>\n (block, element, additionalModifiers, options = {}) =>\n React.forwardRef(({ innerRef, children, classProps, useComponent, className, as, ...rest }, ref) => {\n // get the additional classNames either from a function or an object\n let otherModifiers = appendBlockAndPrefixToObj(additionalModifiers, block, element);\n if (typeof additionalModifiers === 'function')\n otherModifiers = appendBlockAndPrefixToObj(\n additionalModifiers({ ...rest, ...classProps, className }),\n block,\n element,\n );\n\n const otherModifiersStr = cx(otherModifiers);\n const { prefix, propsToRemoveFromFinalElement = [] } = options;\n const { cssClassName: classNames } = convertPropToCssClassName(\n block,\n null,\n { ...classProps },\n { prefix, element },\n );\n const cleanedPropsPassedDown = { ...props, ...rest };\n propsToRemoveFromFinalElement.forEach((propKey) => {\n delete cleanedPropsPassedDown[propKey];\n });\n\n if (isNativeHTMLElement(block)) {\n Object.keys(cleanedPropsPassedDown).forEach((key) => {\n if (!isValidNativeAttribute(key)) delete cleanedPropsPassedDown[key];\n });\n }\n\n return React.createElement(\n as || type,\n {\n ref: innerRef || ref,\n className: [classNames, otherModifiersStr, className].join(' '),\n ...cleanedPropsPassedDown,\n },\n children,\n );\n });\n\nexport default aggregatedClasses;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADIvB,mBAAkB;AAClB,qBAAe;AACf,8BAA0C;AAC1C,2BAA6B;AAC7B,iCAGO;AAEA,MAAM,YAAY,kCAAa;AAatC,MAAM,gCAAgC,CAAC,OAAO,SAAS,aACrD,GAAG,aAAa,QAAQ,UAAU,KAAK,YAAY,OAAO;AAE5D,MAAM,4BAA4B,CAAC,KAAK,OAAO,YAC7C,MACI,OAAO,KAAK,GAAG,EAAE;AAAA,EACjB,CAAC,KAAK,SAAS;AAAA,IACb,GAAG;AAAA,IACH,CAAC,GAAG,8BAA8B,OAAO,SAAS,GAAG,GAAG,GAAG,IAAI,GAAG;AAAA,EACpE;AAAA,EACA,CAAC;AACH,IACE,CAAC;AAEP,MAAM,oBACJ,CAAC,MAAM,UACL,CAAC,OAAO,SAAS,qBAAqB,UAAU,CAAC,MAC/C,aAAAA,QAAM,WAAW,CAAC,EAAE,UAAU,UAAU,YAAY,cAAc,WAAW,IAAI,GAAG,KAAK,GAAG,QAAQ;AAElG,MAAI,iBAAiB,0BAA0B,qBAAqB,OAAO,OAAO;AAClF,MAAI,OAAO,wBAAwB;AACjC,qBAAiB;AAAA,MACf,oBAAoB,EAAE,GAAG,MAAM,GAAG,YAAY,UAAU,CAAC;AAAA,MACzD;AAAA,MACA;AAAA,IACF;AAEF,QAAM,wBAAoB,eAAAC,SAAG,cAAc;AAC3C,QAAM,EAAE,QAAQ,gCAAgC,CAAC,EAAE,IAAI;AACvD,QAAM,EAAE,cAAc,WAAW,QAAI;AAAA,IACnC;AAAA,IACA;AAAA,IACA,EAAE,GAAG,WAAW;AAAA,IAChB,EAAE,QAAQ,QAAQ;AAAA,EACpB;AACA,QAAM,yBAAyB,EAAE,GAAG,OAAO,GAAG,KAAK;AACnD,gCAA8B,QAAQ,CAAC,YAAY;AACjD,WAAO,uBAAuB,OAAO;AAAA,EACvC,CAAC;AAED,UAAI,gDAAoB,KAAK,GAAG;AAC9B,WAAO,KAAK,sBAAsB,EAAE,QAAQ,CAAC,QAAQ;AACnD,UAAI,KAAC,mDAAuB,GAAG;AAAG,eAAO,uBAAuB,GAAG;AAAA,IACrE,CAAC;AAAA,EACH;AAEA,SAAO,aAAAD,QAAM;AAAA,IACX,MAAM;AAAA,IACN;AAAA,MACE,KAAK,YAAY;AAAA,MACjB,WAAW,CAAC,YAAY,mBAAmB,SAAS,EAAE,KAAK,GAAG;AAAA,MAC9D,GAAG;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF,CAAC;AAEP,IAAO,4BAAQ;",
|
|
6
|
+
"names": ["React", "cx"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
# aggregatedClasses
|
|
2
|
+
|
|
3
|
+
Utility to clean up the renders of too many classNames, internally uses the classNamePipeline and obj-str to ease the workflow.
|
|
4
|
+
Follows BEM methodology (block - element - modifier)
|
|
5
|
+
<br> This utility allows us to create components outside the render method with the block-element-modifiers injected in the className
|
|
6
|
+
## Constructor
|
|
7
|
+
|
|
8
|
+
```jsx
|
|
9
|
+
const blockName = 'form-item'
|
|
10
|
+
|
|
11
|
+
const Label = aggregatedClasses('div')(blockName, 'label')
|
|
12
|
+
const InputController = aggregatedClasses('div')(blockName, 'controller')
|
|
13
|
+
|
|
14
|
+
// generates
|
|
15
|
+
<div className='ds-em-form-item__label' />
|
|
16
|
+
<div className='ds-em-form-item__controller' />
|
|
17
|
+
|
|
18
|
+
// and based on the props passed through classProps is going to inject the proper modifiers
|
|
19
|
+
render() {
|
|
20
|
+
return (
|
|
21
|
+
<Label
|
|
22
|
+
classProps={{
|
|
23
|
+
hasError: true,
|
|
24
|
+
readOnly: true,
|
|
25
|
+
disabled: true
|
|
26
|
+
}}
|
|
27
|
+
/>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// generates
|
|
32
|
+
<div className='ds-em-form-item__label ds-em-form-item__label--error ds-em-form-item__label--readonly ds-em-form-item__label--disabled' />
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
This creates a component with the specified element or other component and creates the className based on the blockName, the elementName, and the props that this component is going to receive.
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### Parameters
|
|
40
|
+
```js
|
|
41
|
+
export default type => (block, element, additionalClassNames, options)
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
@type - element or component to create <br>
|
|
45
|
+
@block - block name <br>
|
|
46
|
+
@element - element name
|
|
47
|
+
@additionalModifiers - object that appends new modifiers to the className if the value is true. <br>
|
|
48
|
+
Also we can use a function that takes the props of the component created <br>
|
|
49
|
+
<br>
|
|
50
|
+
@options - Object to configure 'prefix'
|
|
51
|
+
|
|
52
|
+
####Example
|
|
53
|
+
```js
|
|
54
|
+
const Wrapper = aggregatedClasses('div')(blockName, 'elementName', props => ({
|
|
55
|
+
someModifier: true,
|
|
56
|
+
otherModifier: props.hasClass
|
|
57
|
+
}))
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
####Example
|
|
62
|
+
```js
|
|
63
|
+
const Wrapper = aggregatedClasses('div')(blockName, 'elementName', {someClassName: true}, {prefix: 'DIMSUM'})
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
```jsx
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
// this translates
|
|
70
|
+
const Wrapper = ({ children, ...rest }) => {
|
|
71
|
+
const { cssClassName } = convertPropToCssClassName(
|
|
72
|
+
blockName,
|
|
73
|
+
null,
|
|
74
|
+
{ ...rest })
|
|
75
|
+
return (
|
|
76
|
+
<div className={cssClassName}>
|
|
77
|
+
{ children }
|
|
78
|
+
</div>
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// to this
|
|
83
|
+
const WrapperClassed = aggregatedClasses('div')(blockName, null)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Complete example
|
|
87
|
+
before
|
|
88
|
+
```jsx
|
|
89
|
+
import React, { Component } from 'react'
|
|
90
|
+
import getSvgPath from 'components/basic/form/OutlinedInputField/getSvgPath'
|
|
91
|
+
import { convertPropToCssClassName } from '@elliemae/ds-classnames'
|
|
92
|
+
import { DSTextWrapper } from 'components/index'
|
|
93
|
+
|
|
94
|
+
const blockName = 'labeled-outline'
|
|
95
|
+
const pfxBlockName = `em-ds-${blockName}`
|
|
96
|
+
|
|
97
|
+
class DSFloatingLabelInput extends Component {
|
|
98
|
+
constructor(props) {
|
|
99
|
+
super(props)
|
|
100
|
+
this.wrapper = React.createRef()
|
|
101
|
+
this.pathEl = React.createRef()
|
|
102
|
+
this.outlineEl = React.createRef()
|
|
103
|
+
this.outlineIdleEl = React.createRef()
|
|
104
|
+
this.labelEl = React.createRef()
|
|
105
|
+
this.state = {
|
|
106
|
+
open: props.open,
|
|
107
|
+
value: props.value,
|
|
108
|
+
focused: false,
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
componentWillUnmount() {
|
|
112
|
+
window.removeEventListener('resize', this.updatePath)
|
|
113
|
+
}
|
|
114
|
+
get sizes() {
|
|
115
|
+
return {
|
|
116
|
+
labelWidth: this.labelEl.current.offsetWidth * 0.9,
|
|
117
|
+
width: this.wrapper.current.offsetWidth,
|
|
118
|
+
height: this.wrapper.current.offsetHeight,
|
|
119
|
+
radiusStyle: window.getComputedStyle(this.outlineIdleEl.current).getPropertyValue('border-radius'),
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
updatePath() {
|
|
123
|
+
const path = getSvgPath(this.sizes)
|
|
124
|
+
this.pathEl.current.setAttribute('d', path)
|
|
125
|
+
}
|
|
126
|
+
openOutline() {
|
|
127
|
+
this.setState({ open: true })
|
|
128
|
+
}
|
|
129
|
+
closeOutline() {
|
|
130
|
+
this.setState({ open: false })
|
|
131
|
+
}
|
|
132
|
+
render() {
|
|
133
|
+
const {
|
|
134
|
+
className,
|
|
135
|
+
hasError,
|
|
136
|
+
readOnly,
|
|
137
|
+
disabled,
|
|
138
|
+
inputComponent,
|
|
139
|
+
label,
|
|
140
|
+
} = this.props
|
|
141
|
+
const InputComponent = inputComponent
|
|
142
|
+
const { open, focused, value } = this.state
|
|
143
|
+
const isOpen = open || focused || !!value
|
|
144
|
+
|
|
145
|
+
const { cssClassName: classNames } = convertPropToCssClassName(
|
|
146
|
+
blockName,
|
|
147
|
+
className, {
|
|
148
|
+
hasError,
|
|
149
|
+
readOnly,
|
|
150
|
+
disabled,
|
|
151
|
+
})
|
|
152
|
+
return (
|
|
153
|
+
<div
|
|
154
|
+
ref={this.wrapper}
|
|
155
|
+
className={`${classNames} ${isOpen ? `${pfxBlockName}--opened` : ''} ${focused ? `${pfxBlockName}--focused` : ''}`}
|
|
156
|
+
onMouseEnter={this.openOutline}
|
|
157
|
+
onMouseLeave={this.closeOutline}
|
|
158
|
+
>
|
|
159
|
+
<div
|
|
160
|
+
ref={this.outlineEl}
|
|
161
|
+
className={`${pfxBlockName}__outline`}
|
|
162
|
+
>
|
|
163
|
+
<svg>
|
|
164
|
+
<path
|
|
165
|
+
ref={this.pathEl}
|
|
166
|
+
className={`${pfxBlockName}__outline__path`}
|
|
167
|
+
/>
|
|
168
|
+
</svg>
|
|
169
|
+
</div>
|
|
170
|
+
<div
|
|
171
|
+
ref={this.outlineIdleEl}
|
|
172
|
+
className={`${pfxBlockName}__idle`}
|
|
173
|
+
/>
|
|
174
|
+
<div className={`${pfxBlockName}__content`}>
|
|
175
|
+
<InputComponent
|
|
176
|
+
disabled={disabled}
|
|
177
|
+
hasError={hasError}
|
|
178
|
+
onBlur={() => this.setState({ focused: false })}
|
|
179
|
+
onChange={e => this.setState({ value: e.target.value })}
|
|
180
|
+
onFocus={() => this.setState({ focused: true })}
|
|
181
|
+
readOnly={readOnly}
|
|
182
|
+
value={value}
|
|
183
|
+
/>
|
|
184
|
+
<label
|
|
185
|
+
ref={this.labelEl}
|
|
186
|
+
className={`${pfxBlockName}__label ${isOpen ? `${pfxBlockName}__label--floated` : ''}`}
|
|
187
|
+
>
|
|
188
|
+
<DSTextWrapper
|
|
189
|
+
innerRef={this.labelEl}
|
|
190
|
+
maxWidth='20px'
|
|
191
|
+
text={label}
|
|
192
|
+
textEllipsis
|
|
193
|
+
/>
|
|
194
|
+
</label>
|
|
195
|
+
</div>
|
|
196
|
+
</div>
|
|
197
|
+
)
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export default DSFloatingLabelInput
|
|
202
|
+
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
after
|
|
206
|
+
|
|
207
|
+
```jsx
|
|
208
|
+
import React, { Component } from 'react'
|
|
209
|
+
import getSvgPath from 'components/basic/form/OutlinedInputField/getSvgPath'
|
|
210
|
+
import { DSTextWrapper } from 'components/index'
|
|
211
|
+
import { aggregatedClasses } from '@elliemae/ds-classnames'
|
|
212
|
+
|
|
213
|
+
const blockName = 'labeled-outline'
|
|
214
|
+
|
|
215
|
+
const Wrapper = aggregatedClasses('div')(blockName, null, ({ isOpen, isFocused }) => ({
|
|
216
|
+
opened: isOpen,
|
|
217
|
+
focused: isFocused,
|
|
218
|
+
}))
|
|
219
|
+
|
|
220
|
+
const FloatingLabel = aggregatedClasses('label')(blockName, 'label', ({ isOpen }) => ({
|
|
221
|
+
floated: isOpen,
|
|
222
|
+
}))
|
|
223
|
+
|
|
224
|
+
const OutlineContent = aggregatedClasses('div')(blockName, 'content')
|
|
225
|
+
const OutlineIdle = aggregatedClasses('div')(blockName, 'idle')
|
|
226
|
+
const Outline = aggregatedClasses('div')(blockName, 'outline')
|
|
227
|
+
const OutlinePath = aggregatedClasses('path')(blockName, 'outline__path')
|
|
228
|
+
|
|
229
|
+
class DSFloatingLabelInput extends Component {
|
|
230
|
+
constructor(props) {
|
|
231
|
+
super(props)
|
|
232
|
+
this.wrapper = React.createRef()
|
|
233
|
+
this.pathEl = React.createRef()
|
|
234
|
+
this.outlineEl = React.createRef()
|
|
235
|
+
this.outlineIdleEl = React.createRef()
|
|
236
|
+
this.labelEl = React.createRef()
|
|
237
|
+
this.state = {
|
|
238
|
+
open: props.open,
|
|
239
|
+
value: props.value,
|
|
240
|
+
focused: false,
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
componentDidMount() {
|
|
244
|
+
// TODO: not getting referenced elements height / width without this
|
|
245
|
+
// this is a temporary workaround
|
|
246
|
+
setTimeout(() => this.updatePath(), 1)
|
|
247
|
+
window.addEventListener('resize', this.updatePath)
|
|
248
|
+
}
|
|
249
|
+
componentWillUnmount() {
|
|
250
|
+
window.removeEventListener('resize', this.updatePath)
|
|
251
|
+
}
|
|
252
|
+
get sizes() {
|
|
253
|
+
return {
|
|
254
|
+
labelWidth: this.labelEl.current.offsetWidth * 0.9,
|
|
255
|
+
width: this.wrapper.current.offsetWidth,
|
|
256
|
+
height: this.wrapper.current.offsetHeight,
|
|
257
|
+
radiusStyle: window.getComputedStyle(this.outlineIdleEl.current).getPropertyValue('border-radius'),
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
updatePath() {
|
|
261
|
+
const path = getSvgPath(this.sizes)
|
|
262
|
+
this.pathEl.current.setAttribute('d', path)
|
|
263
|
+
}
|
|
264
|
+
openOutline() {
|
|
265
|
+
this.setState({ open: true })
|
|
266
|
+
}
|
|
267
|
+
closeOutline() {
|
|
268
|
+
this.setState({ open: false })
|
|
269
|
+
}
|
|
270
|
+
render() {
|
|
271
|
+
const {
|
|
272
|
+
hasError,
|
|
273
|
+
readOnly,
|
|
274
|
+
disabled,
|
|
275
|
+
inputComponent,
|
|
276
|
+
label,
|
|
277
|
+
} = this.props
|
|
278
|
+
const InputComponent = inputComponent
|
|
279
|
+
const { open, focused, value } = this.state
|
|
280
|
+
const isOpen = open || focused || !!value
|
|
281
|
+
|
|
282
|
+
return (
|
|
283
|
+
<Wrapper
|
|
284
|
+
classProps={{ hasError, isOpen, isFocused: focused, readOnly, disabled }}
|
|
285
|
+
innerRef={this.wrapper}
|
|
286
|
+
onMouseEnter={this.openOutline}
|
|
287
|
+
onMouseLeave={this.closeOutline}
|
|
288
|
+
>
|
|
289
|
+
<Outline innerRef={this.outlineEl}>
|
|
290
|
+
<svg>
|
|
291
|
+
<OutlinePath innerRef={this.pathEl} />
|
|
292
|
+
</svg>
|
|
293
|
+
</Outline>
|
|
294
|
+
<OutlineIdle innerRef={this.outlineIdleEl} />
|
|
295
|
+
<OutlineContent>
|
|
296
|
+
<InputComponent
|
|
297
|
+
disabled={disabled}
|
|
298
|
+
hasError={hasError}
|
|
299
|
+
onBlur={() => this.setState({ focused: false })}
|
|
300
|
+
onChange={e => this.setState({ value: e.target.value })}
|
|
301
|
+
onFocus={() => this.setState({ focused: true })}
|
|
302
|
+
readOnly={readOnly}
|
|
303
|
+
value={value}
|
|
304
|
+
/>
|
|
305
|
+
<FloatingLabel
|
|
306
|
+
classProps={{ isOpen }}
|
|
307
|
+
innerRef={this.labelEl}
|
|
308
|
+
>
|
|
309
|
+
<DSTextWrapper
|
|
310
|
+
maxWidth='20px'
|
|
311
|
+
text={label}
|
|
312
|
+
textEllipsis
|
|
313
|
+
/>
|
|
314
|
+
</FloatingLabel>
|
|
315
|
+
</OutlineContent>
|
|
316
|
+
</Wrapper>
|
|
317
|
+
)
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export default DSFloatingLabelInput
|
|
322
|
+
|
|
323
|
+
```
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var classNameManager_exports = {};
|
|
30
|
+
__export(classNameManager_exports, {
|
|
31
|
+
convertPropToCssClassName: () => cssPipeline,
|
|
32
|
+
cssPrefix: () => cssPrefix,
|
|
33
|
+
default: () => classNameManager_default
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(classNameManager_exports);
|
|
36
|
+
var React = __toESM(require("react"));
|
|
37
|
+
var import_ds_legacy_utilities = require("@elliemae/ds-legacy-utilities");
|
|
38
|
+
var import_dimsum_config = require("./dimsum.config.js");
|
|
39
|
+
var import_converPropsToFormModifiers = require("./converPropsToFormModifiers.js");
|
|
40
|
+
var import_convertPropsToLayoutModifiers = require("./convertPropsToLayoutModifiers.js");
|
|
41
|
+
var import_convertPropToFeedBackModifiers = require("./convertPropToFeedBackModifiers.js");
|
|
42
|
+
var import_convertPropsToSizeModifiers = require("./convertPropsToSizeModifiers.js");
|
|
43
|
+
var import_convertPropsToTextModifiers = require("./convertPropsToTextModifiers.js");
|
|
44
|
+
var import_convertPropsToColorModifiers = require("./convertPropsToColorModifiers.js");
|
|
45
|
+
const cssPrefix = `${import_dimsum_config.dimsumConfig.classNamePrefix}-`;
|
|
46
|
+
const executePipelines = (props) => {
|
|
47
|
+
const form = (0, import_converPropsToFormModifiers.pipe)().execute(props);
|
|
48
|
+
const layout = (0, import_convertPropsToLayoutModifiers.pipe)().execute(props);
|
|
49
|
+
const feedback = (0, import_convertPropToFeedBackModifiers.pipe)().execute(props);
|
|
50
|
+
const size = (0, import_convertPropsToSizeModifiers.pipe)().execute(props);
|
|
51
|
+
const text = (0, import_convertPropsToTextModifiers.pipe)().execute(props);
|
|
52
|
+
const color = (0, import_convertPropsToColorModifiers.pipe)().execute(props);
|
|
53
|
+
return [...form, ...layout, ...feedback, ...size, ...text, ...color];
|
|
54
|
+
};
|
|
55
|
+
const cssPipeline = (blockName = "block", cssClassNameModifier = "", props = {}, options = {}) => {
|
|
56
|
+
const { prefix, element } = options;
|
|
57
|
+
const prefixBlockName = `${prefix || cssPrefix}${blockName}${element ? `__${element}` : ""}`;
|
|
58
|
+
const pipes = !(0, import_ds_legacy_utilities.isEmpty)(props) ? executePipelines(props) : [];
|
|
59
|
+
const basePipeline = [prefixBlockName, ...pipes];
|
|
60
|
+
const className = cssClassNameModifier ? [...basePipeline].join(` ${prefixBlockName}--`).concat(` ${cssClassNameModifier}`) : [...basePipeline].join(` ${prefixBlockName}--`);
|
|
61
|
+
return {
|
|
62
|
+
blockName,
|
|
63
|
+
cssPrefix,
|
|
64
|
+
prefixBlockName,
|
|
65
|
+
cssClassName: className,
|
|
66
|
+
mainModifier(modifier) {
|
|
67
|
+
return `${className}--${modifier}`;
|
|
68
|
+
},
|
|
69
|
+
classNameBlock(elementName, usePrefix = true) {
|
|
70
|
+
return `${!usePrefix ? blockName : prefixBlockName}-${elementName}`;
|
|
71
|
+
},
|
|
72
|
+
classNameBlockModifier(modifierName, elementBlockName = "") {
|
|
73
|
+
return `${prefixBlockName}-${elementBlockName}--${modifierName}`;
|
|
74
|
+
},
|
|
75
|
+
classNameElement(elementName, elementBlockName = "") {
|
|
76
|
+
return `${prefixBlockName}${elementBlockName ? `-${elementBlockName}` : ""}__${elementName}`;
|
|
77
|
+
},
|
|
78
|
+
classNameModifier(modifierName, elementName = "") {
|
|
79
|
+
return `${prefixBlockName}${elementName ? `__${elementName}` : ""}--${modifierName}`;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
var classNameManager_default = cssPipeline;
|
|
84
|
+
//# sourceMappingURL=classNameManager.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/classNameManager.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable max-params */\nimport { isEmpty } from '@elliemae/ds-legacy-utilities';\nimport { dimsumConfig } from './dimsum.config.js';\nimport { pipe as formPipe } from './converPropsToFormModifiers.js';\nimport { pipe as layoutModifiers } from './convertPropsToLayoutModifiers.js';\nimport { pipe as feedBackModifiers } from './convertPropToFeedBackModifiers.js';\nimport { pipe as sizeModifiers } from './convertPropsToSizeModifiers.js';\nimport { pipe as textModifiers } from './convertPropsToTextModifiers.js';\nimport { pipe as colorModifiers } from './convertPropsToColorModifiers.js';\n\nexport const cssPrefix = `${dimsumConfig.classNamePrefix}-`;\n\nconst executePipelines = (props) => {\n const form = formPipe().execute(props);\n const layout = layoutModifiers().execute(props);\n const feedback = feedBackModifiers().execute(props);\n const size = sizeModifiers().execute(props);\n const text = textModifiers().execute(props);\n const color = colorModifiers().execute(props);\n return [...form, ...layout, ...feedback, ...size, ...text, ...color];\n};\n\n/**\n * Docs: http://getbem.com/naming/\n * blockName\n * cssClassNameModifier: Main modifier\n * props { hasError, hasWarning, hasSuccess, readOnly, disabled}\n * @param blockName\n * @param cssClassNameModifier\n * @param props\n * @param options\n */\nconst cssPipeline: (\n blockName?: string,\n cssClassNameModifier?: string,\n props?: { [key: string]: any },\n options?: { [key: string]: any },\n) => {\n blockName: string;\n cssPrefix: string;\n prefixBlockName: string;\n cssClassName: string;\n mainModifier(modifier: any): string;\n classNameBlock(elementName: any, usePrefix?: boolean): string;\n classNameBlockModifier(modifierName: any, elementBlockName?: string): string;\n classNameElement(elementName: any, elementBlockName?: string): string;\n classNameModifier(modifierName: any, elementName?: string): string;\n} = (blockName = 'block', cssClassNameModifier = '', props = {}, options = {}) => {\n const { prefix, element } = options;\n\n const prefixBlockName = `${prefix || cssPrefix}${blockName}${element ? `__${element}` : ''}`;\n\n // PipeLine\n const pipes = !isEmpty(props) ? executePipelines(props) : [];\n\n const basePipeline = [prefixBlockName, ...pipes];\n\n // specific classname\n const className = cssClassNameModifier\n ? [...basePipeline].join(` ${prefixBlockName}--`).concat(` ${cssClassNameModifier}`)\n : [...basePipeline].join(` ${prefixBlockName}--`);\n\n return {\n blockName,\n cssPrefix,\n prefixBlockName,\n cssClassName: className,\n mainModifier(modifier) {\n return `${className}--${modifier}`;\n },\n classNameBlock(elementName, usePrefix = true) {\n return `${!usePrefix ? blockName : prefixBlockName}-${elementName}`;\n },\n classNameBlockModifier(modifierName, elementBlockName = '') {\n return `${prefixBlockName}-${elementBlockName}--${modifierName}`;\n },\n classNameElement(elementName, elementBlockName = '') {\n return `${prefixBlockName}${elementBlockName ? `-${elementBlockName}` : ''}__${elementName}`;\n },\n classNameModifier(modifierName, elementName = '') {\n return `${prefixBlockName}${elementName ? `__${elementName}` : ''}--${modifierName}`;\n },\n };\n};\n\nexport { cssPipeline as convertPropToCssClassName };\nexport default cssPipeline;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,iCAAwB;AACxB,2BAA6B;AAC7B,wCAAiC;AACjC,2CAAwC;AACxC,4CAA0C;AAC1C,yCAAsC;AACtC,yCAAsC;AACtC,0CAAuC;AAEhC,MAAM,YAAY,GAAG,kCAAa;AAEzC,MAAM,mBAAmB,CAAC,UAAU;AAClC,QAAM,WAAO,kCAAAA,MAAS,EAAE,QAAQ,KAAK;AACrC,QAAM,aAAS,qCAAAC,MAAgB,EAAE,QAAQ,KAAK;AAC9C,QAAM,eAAW,sCAAAC,MAAkB,EAAE,QAAQ,KAAK;AAClD,QAAM,WAAO,mCAAAC,MAAc,EAAE,QAAQ,KAAK;AAC1C,QAAM,WAAO,mCAAAC,MAAc,EAAE,QAAQ,KAAK;AAC1C,QAAM,YAAQ,oCAAAC,MAAe,EAAE,QAAQ,KAAK;AAC5C,SAAO,CAAC,GAAG,MAAM,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK;AACrE;AAYA,MAAM,cAeF,CAAC,YAAY,SAAS,uBAAuB,IAAI,QAAQ,CAAC,GAAG,UAAU,CAAC,MAAM;AAChF,QAAM,EAAE,QAAQ,QAAQ,IAAI;AAE5B,QAAM,kBAAkB,GAAG,UAAU,YAAY,YAAY,UAAU,KAAK,YAAY;AAGxF,QAAM,QAAQ,KAAC,oCAAQ,KAAK,IAAI,iBAAiB,KAAK,IAAI,CAAC;AAE3D,QAAM,eAAe,CAAC,iBAAiB,GAAG,KAAK;AAG/C,QAAM,YAAY,uBACd,CAAC,GAAG,YAAY,EAAE,KAAK,IAAI,mBAAmB,EAAE,OAAO,IAAI,sBAAsB,IACjF,CAAC,GAAG,YAAY,EAAE,KAAK,IAAI,mBAAmB;AAElD,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd,aAAa,UAAU;AACrB,aAAO,GAAG,cAAc;AAAA,IAC1B;AAAA,IACA,eAAe,aAAa,YAAY,MAAM;AAC5C,aAAO,GAAG,CAAC,YAAY,YAAY,mBAAmB;AAAA,IACxD;AAAA,IACA,uBAAuB,cAAc,mBAAmB,IAAI;AAC1D,aAAO,GAAG,mBAAmB,qBAAqB;AAAA,IACpD;AAAA,IACA,iBAAiB,aAAa,mBAAmB,IAAI;AACnD,aAAO,GAAG,kBAAkB,mBAAmB,IAAI,qBAAqB,OAAO;AAAA,IACjF;AAAA,IACA,kBAAkB,cAAc,cAAc,IAAI;AAChD,aAAO,GAAG,kBAAkB,cAAc,KAAK,gBAAgB,OAAO;AAAA,IACxE;AAAA,EACF;AACF;AAGA,IAAO,2BAAQ;",
|
|
6
|
+
"names": ["formPipe", "layoutModifiers", "feedBackModifiers", "sizeModifiers", "textModifiers", "colorModifiers"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var converPropsToFormModifiers_exports = {};
|
|
30
|
+
__export(converPropsToFormModifiers_exports, {
|
|
31
|
+
default: () => converPropsToFormModifiers_default,
|
|
32
|
+
pipe: () => pipe
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(converPropsToFormModifiers_exports);
|
|
35
|
+
var React = __toESM(require("react"));
|
|
36
|
+
const basicAction = ({ readOnly = false, disabled = false, checked = false }) => {
|
|
37
|
+
const cssModifier = [];
|
|
38
|
+
if (checked)
|
|
39
|
+
cssModifier.push("checked");
|
|
40
|
+
if (readOnly)
|
|
41
|
+
cssModifier.push("readonly");
|
|
42
|
+
if (disabled)
|
|
43
|
+
cssModifier.push("disabled");
|
|
44
|
+
return cssModifier;
|
|
45
|
+
};
|
|
46
|
+
const instance = [basicAction];
|
|
47
|
+
const pipe = () => ({
|
|
48
|
+
getInstance() {
|
|
49
|
+
return instance;
|
|
50
|
+
},
|
|
51
|
+
add(customModifier) {
|
|
52
|
+
instance.push(customModifier);
|
|
53
|
+
},
|
|
54
|
+
execute(props) {
|
|
55
|
+
return instance.reduce((temp, action) => [...temp, ...action(props)], []);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
var converPropsToFormModifiers_default = pipe;
|
|
59
|
+
//# sourceMappingURL=converPropsToFormModifiers.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/converPropsToFormModifiers.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["const basicAction = ({ readOnly = false, disabled = false, checked = false }) => {\n const cssModifier = [];\n // input state modifiers\n if (checked) cssModifier.push('checked');\n if (readOnly) cssModifier.push('readonly');\n if (disabled) cssModifier.push('disabled');\n return cssModifier;\n};\n\nconst instance = [basicAction];\nconst pipe = () => ({\n getInstance() {\n return instance;\n },\n add(customModifier) {\n instance.push(customModifier);\n },\n execute(props) {\n return instance.reduce((temp, action) => [...temp, ...action(props)], []);\n },\n});\n\nexport { pipe };\nexport default pipe;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,MAAM,cAAc,CAAC,EAAE,WAAW,OAAO,WAAW,OAAO,UAAU,MAAM,MAAM;AAC/E,QAAM,cAAc,CAAC;AAErB,MAAI;AAAS,gBAAY,KAAK,SAAS;AACvC,MAAI;AAAU,gBAAY,KAAK,UAAU;AACzC,MAAI;AAAU,gBAAY,KAAK,UAAU;AACzC,SAAO;AACT;AAEA,MAAM,WAAW,CAAC,WAAW;AAC7B,MAAM,OAAO,OAAO;AAAA,EAClB,cAAc;AACZ,WAAO;AAAA,EACT;AAAA,EACA,IAAI,gBAAgB;AAClB,aAAS,KAAK,cAAc;AAAA,EAC9B;AAAA,EACA,QAAQ,OAAO;AACb,WAAO,SAAS,OAAO,CAAC,MAAM,WAAW,CAAC,GAAG,MAAM,GAAG,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;AAAA,EAC1E;AACF;AAGA,IAAO,qCAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var convertPropToFeedBackModifiers_exports = {};
|
|
30
|
+
__export(convertPropToFeedBackModifiers_exports, {
|
|
31
|
+
default: () => convertPropToFeedBackModifiers_default,
|
|
32
|
+
pipe: () => pipe
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(convertPropToFeedBackModifiers_exports);
|
|
35
|
+
var React = __toESM(require("react"));
|
|
36
|
+
const basicAction = ({ hasError = false, hasWarning = false, hasSuccess = false, modalType }) => {
|
|
37
|
+
const cssModifier = [];
|
|
38
|
+
if (hasError)
|
|
39
|
+
cssModifier.push("error");
|
|
40
|
+
else if (hasWarning)
|
|
41
|
+
cssModifier.push("warning");
|
|
42
|
+
else if (hasSuccess)
|
|
43
|
+
cssModifier.push("success");
|
|
44
|
+
if (modalType)
|
|
45
|
+
cssModifier.push(`modal-type-${modalType}`);
|
|
46
|
+
return cssModifier;
|
|
47
|
+
};
|
|
48
|
+
const instance = [basicAction];
|
|
49
|
+
const pipe = () => ({
|
|
50
|
+
getInstance() {
|
|
51
|
+
return instance;
|
|
52
|
+
},
|
|
53
|
+
add(customModifier) {
|
|
54
|
+
instance.push(customModifier);
|
|
55
|
+
},
|
|
56
|
+
execute(props) {
|
|
57
|
+
return instance.reduce((temp, action) => [...temp, ...action(props)], []);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
var convertPropToFeedBackModifiers_default = pipe;
|
|
61
|
+
//# sourceMappingURL=convertPropToFeedBackModifiers.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/convertPropToFeedBackModifiers.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["const basicAction = ({ hasError = false, hasWarning = false, hasSuccess = false, modalType }) => {\n const cssModifier = [];\n // valid state modifier\n if (hasError) cssModifier.push('error');\n else if (hasWarning) cssModifier.push('warning');\n else if (hasSuccess) cssModifier.push('success');\n if (modalType) cssModifier.push(`modal-type-${modalType}`);\n return cssModifier;\n};\n\nconst instance = [basicAction];\nconst pipe = () => ({\n getInstance() {\n return instance;\n },\n add(customModifier) {\n instance.push(customModifier);\n },\n execute(props) {\n return instance.reduce((temp, action) => [...temp, ...action(props)], []);\n },\n});\n\nexport { pipe };\nexport default pipe;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,MAAM,cAAc,CAAC,EAAE,WAAW,OAAO,aAAa,OAAO,aAAa,OAAO,UAAU,MAAM;AAC/F,QAAM,cAAc,CAAC;AAErB,MAAI;AAAU,gBAAY,KAAK,OAAO;AAAA,WAC7B;AAAY,gBAAY,KAAK,SAAS;AAAA,WACtC;AAAY,gBAAY,KAAK,SAAS;AAC/C,MAAI;AAAW,gBAAY,KAAK,cAAc,WAAW;AACzD,SAAO;AACT;AAEA,MAAM,WAAW,CAAC,WAAW;AAC7B,MAAM,OAAO,OAAO;AAAA,EAClB,cAAc;AACZ,WAAO;AAAA,EACT;AAAA,EACA,IAAI,gBAAgB;AAClB,aAAS,KAAK,cAAc;AAAA,EAC9B;AAAA,EACA,QAAQ,OAAO;AACb,WAAO,SAAS,OAAO,CAAC,MAAM,WAAW,CAAC,GAAG,MAAM,GAAG,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;AAAA,EAC1E;AACF;AAGA,IAAO,yCAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|