@elliemae/ds-classnames 2.2.0-alpha.1 → 2.2.0-alpha.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/cjs/aggregatedClasses.js +68 -89
- package/cjs/aggregatedClasses.js.map +7 -0
- package/cjs/aggregatedClasses.md +323 -0
- package/cjs/classNameManager.js +68 -77
- package/cjs/classNameManager.js.map +7 -0
- package/cjs/converPropsToFormModifiers.js +48 -25
- package/cjs/converPropsToFormModifiers.js.map +7 -0
- package/cjs/convertPropToFeedBackModifiers.js +51 -25
- package/cjs/convertPropToFeedBackModifiers.js.map +7 -0
- package/cjs/convertPropsToColorModifiers.js +41 -21
- package/cjs/convertPropsToColorModifiers.js.map +7 -0
- package/cjs/convertPropsToLayoutModifiers.js +51 -27
- package/cjs/convertPropsToLayoutModifiers.js.map +7 -0
- package/cjs/convertPropsToSizeModifiers.js +62 -28
- package/cjs/convertPropsToSizeModifiers.js.map +7 -0
- package/cjs/convertPropsToTextModifiers.js +43 -23
- package/cjs/convertPropsToTextModifiers.js.map +7 -0
- package/cjs/index.js +38 -12
- package/cjs/index.js.map +7 -0
- package/cjs/validateNativeProps.js +48 -31
- package/cjs/validateNativeProps.js.map +7 -0
- package/esm/aggregatedClasses.js +41 -75
- package/esm/aggregatedClasses.js.map +7 -0
- package/esm/aggregatedClasses.md +323 -0
- package/esm/classNameManager.js +38 -67
- package/esm/classNameManager.js.map +7 -0
- package/esm/converPropsToFormModifiers.js +19 -23
- package/esm/converPropsToFormModifiers.js.map +7 -0
- package/esm/convertPropToFeedBackModifiers.js +22 -23
- package/esm/convertPropToFeedBackModifiers.js.map +7 -0
- package/esm/convertPropsToColorModifiers.js +12 -19
- package/esm/convertPropsToColorModifiers.js.map +7 -0
- package/esm/convertPropsToLayoutModifiers.js +22 -25
- package/esm/convertPropsToLayoutModifiers.js.map +7 -0
- package/esm/convertPropsToSizeModifiers.js +33 -26
- package/esm/convertPropsToSizeModifiers.js.map +7 -0
- package/esm/convertPropsToTextModifiers.js +14 -21
- package/esm/convertPropsToTextModifiers.js.map +7 -0
- package/esm/index.js +9 -2
- package/esm/index.js.map +7 -0
- package/esm/validateNativeProps.js +19 -19
- package/esm/validateNativeProps.js.map +7 -0
- package/package.json +3 -3
- package/types/classNameManager.d.ts +1 -0
- package/types/converPropsToFormModifiers.d.ts +1 -0
- package/types/convertPropToFeedBackModifiers.d.ts +1 -0
- package/types/convertPropsToColorModifiers.d.ts +1 -0
- package/types/convertPropsToLayoutModifiers.d.ts +1 -0
- package/types/convertPropsToSizeModifiers.d.ts +1 -0
- package/types/convertPropsToTextModifiers.d.ts +1 -0
package/cjs/index.js
CHANGED
|
@@ -1,12 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (module2, isNodeMode) => {
|
|
21
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
+
return (module2, temp) => {
|
|
25
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
+
};
|
|
27
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
+
var src_exports = {};
|
|
29
|
+
__export(src_exports, {
|
|
30
|
+
aggregatedClasses: () => import_aggregatedClasses.default,
|
|
31
|
+
convertPropToCssClassName: () => import_classNameManager.default,
|
|
32
|
+
cssPrefix: () => import_classNameManager.cssPrefix
|
|
33
|
+
});
|
|
34
|
+
var React = __toESM(require("react"));
|
|
35
|
+
var import_classNameManager = __toESM(require("./classNameManager"));
|
|
36
|
+
var import_aggregatedClasses = __toESM(require("./aggregatedClasses"));
|
|
37
|
+
module.exports = __toCommonJS(src_exports);
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
package/cjs/index.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["export { default as convertPropToCssClassName, cssPrefix } from './classNameManager';\nexport { default as aggregatedClasses } from './aggregatedClasses';\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,8BAAgE;AAChE,+BAA6C;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,23 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (module2, isNodeMode) => {
|
|
21
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
+
return (module2, temp) => {
|
|
25
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
+
};
|
|
27
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
+
var validateNativeProps_exports = {};
|
|
29
|
+
__export(validateNativeProps_exports, {
|
|
30
|
+
isAriaAttribute: () => isAriaAttribute,
|
|
31
|
+
isDataAttribute: () => isDataAttribute,
|
|
32
|
+
isNativeHTMLElement: () => isNativeHTMLElement,
|
|
33
|
+
isValidNativeAttribute: () => isValidNativeAttribute,
|
|
34
|
+
whiteList: () => whiteList
|
|
35
|
+
});
|
|
36
|
+
var React = __toESM(require("react"));
|
|
21
37
|
const attributeWhiteList = {
|
|
22
38
|
accept: true,
|
|
23
39
|
acceptCharset: true,
|
|
@@ -285,10 +301,15 @@ const eventsWhiteList = {
|
|
|
285
301
|
onTransitionEnd: true,
|
|
286
302
|
onToggle: true
|
|
287
303
|
};
|
|
288
|
-
const whiteList =
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
304
|
+
const whiteList = {
|
|
305
|
+
...attributeWhiteList,
|
|
306
|
+
...svgAttributesWhiteList,
|
|
307
|
+
...otherWhiteList,
|
|
308
|
+
...eventsWhiteList
|
|
309
|
+
};
|
|
310
|
+
const isDataAttribute = (attribute) => attribute.substring(0, 5) === "data-";
|
|
311
|
+
const isAriaAttribute = (attribute) => attribute.substring(0, 6) === "aria-";
|
|
312
|
+
const isValidNativeAttribute = (attribute) => whiteList[attribute] === true || isDataAttribute(attribute) || isAriaAttribute(attribute) || attribute.toLowerCase() === attribute;
|
|
292
313
|
const nativeHTMLElements = {
|
|
293
314
|
a: true,
|
|
294
315
|
abbr: true,
|
|
@@ -403,10 +424,6 @@ const nativeHTMLElements = {
|
|
|
403
424
|
video: true,
|
|
404
425
|
wbr: true
|
|
405
426
|
};
|
|
406
|
-
const isNativeHTMLElement = type => nativeHTMLElements[type] === true;
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
exports.isDataAttribute = isDataAttribute;
|
|
410
|
-
exports.isNativeHTMLElement = isNativeHTMLElement;
|
|
411
|
-
exports.isValidNativeAttribute = isValidNativeAttribute;
|
|
412
|
-
exports.whiteList = whiteList;
|
|
427
|
+
const isNativeHTMLElement = (type) => nativeHTMLElements[type] === true;
|
|
428
|
+
module.exports = __toCommonJS(validateNativeProps_exports);
|
|
429
|
+
//# sourceMappingURL=validateNativeProps.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/validateNativeProps.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-lines */\nconst attributeWhiteList = {\n accept: true,\n acceptCharset: true,\n accessKey: true,\n action: true,\n allowFullScreen: true,\n allowTransparency: true,\n alt: true,\n async: true,\n autoComplete: true,\n autoFocus: true,\n autoPlay: true,\n capture: true,\n cellPadding: true,\n cellSpacing: true,\n charSet: true,\n challenge: true,\n checked: true,\n classID: true,\n className: true,\n cols: true,\n colSpan: true,\n content: true,\n contentEditable: true,\n contextMenu: true,\n controls: true,\n coords: true,\n crossOrigin: true,\n data: true,\n dateTime: true,\n defer: true,\n dir: true,\n disabled: true,\n download: true,\n draggable: true,\n encType: true,\n form: true,\n formAction: true,\n formEncType: true,\n formMethod: true,\n formNoValidate: true,\n formTarget: true,\n frameBorder: true,\n headers: true,\n height: true,\n hidden: true,\n high: true,\n href: true,\n hrefLang: true,\n htmlFor: true,\n httpEquiv: true,\n icon: true,\n id: true,\n inputMode: true,\n keyParams: true,\n keyType: true,\n label: true,\n lang: true,\n list: true,\n loop: true,\n low: true,\n manifest: true,\n marginHeight: true,\n marginWidth: true,\n max: true,\n maxLength: true,\n media: true,\n mediaGroup: true,\n method: true,\n min: true,\n minLength: true,\n multiple: true,\n muted: true,\n name: true,\n noValidate: true,\n open: true,\n optimum: true,\n pattern: true,\n placeholder: true,\n poster: true,\n preload: true,\n radioGroup: true,\n readOnly: true,\n rel: true,\n required: true,\n role: true,\n rows: true,\n rowSpan: true,\n sandbox: true,\n scope: true,\n scoped: true,\n scrolling: true,\n seamless: true,\n selected: true,\n shape: true,\n size: true,\n sizes: true,\n span: true,\n spellCheck: true,\n src: true,\n srcDoc: true,\n srcSet: true,\n start: true,\n step: true,\n style: true,\n summary: true,\n tabIndex: true,\n target: true,\n title: true,\n type: true,\n useMap: true,\n value: true,\n width: true,\n wmode: true,\n wrap: true,\n};\n\nconst svgAttributesWhiteList = {\n clipPath: true,\n cx: true,\n cy: true,\n d: true,\n dx: true,\n dy: true,\n fill: true,\n fillOpacity: true,\n fontFamily: true,\n fontSize: true,\n fx: true,\n fy: true,\n gradientTransform: true,\n gradientUnits: true,\n markerEnd: true,\n markerMid: true,\n markerStart: true,\n offset: true,\n opacity: true,\n patternContentUnits: true,\n patternUnits: true,\n points: true,\n preserveAspectRatio: true,\n r: true,\n rx: true,\n ry: true,\n spreadMethod: true,\n stopColor: true,\n stopOpacity: true,\n stroke: true,\n strokeDasharray: true,\n strokeLinecap: true,\n strokeOpacity: true,\n strokeWidth: true,\n textAnchor: true,\n transform: true,\n version: true,\n viewBox: true,\n x1: true,\n x2: true,\n x: true,\n xlinkActuate: true,\n xlinkArcrole: true,\n xlinkHref: true,\n xlinkRole: true,\n xlinkShow: true,\n xlinkTitle: true,\n xlinkType: true,\n xmlBase: true,\n xmlLang: true,\n xmlSpace: true,\n y1: true,\n y2: true,\n y: true,\n};\n\nconst otherWhiteList = {\n autoCapitalize: true,\n autoCorrect: true,\n property: true,\n itemProp: true,\n itemScope: true,\n itemType: true,\n itemRef: true,\n itemID: true,\n unselectable: true,\n results: true,\n autoSave: true,\n};\n\nconst eventsWhiteList = {\n onCopy: true,\n onCut: true,\n onPaste: true,\n onCompositionEnd: true,\n onCompositionStart: true,\n onCompositionUpdate: true,\n onKeyDown: true,\n onKeyPress: true,\n onKeyUp: true,\n onFocus: true,\n onBlur: true,\n onChange: true,\n onInput: true,\n onInvalid: true,\n onReset: true,\n onSubmit: true,\n onError: true,\n onLoad: true,\n onClick: true,\n onContextMenu: true,\n onDoubleClick: true,\n onDrag: true,\n onDragEnd: true,\n onDragEnter: true,\n onDragExit: true,\n onDragLeave: true,\n onDragOver: true,\n onDragStart: true,\n onDrop: true,\n onMouseDown: true,\n onMouseEnter: true,\n onMouseLeave: true,\n onMouseMove: true,\n onMouseOut: true,\n onMouseOver: true,\n onMouseUp: true,\n onPointerDown: true,\n onPointerMove: true,\n onPointerUp: true,\n onPointerCancel: true,\n onGotPointerCapture: true,\n onLostPointerCapture: true,\n onPointerEnter: true,\n onPointerLeave: true,\n onPointerOver: true,\n onPointerOut: true,\n onSelect: true,\n onTouchCancel: true,\n onTouchEnd: true,\n onTouchMove: true,\n onTouchStart: true,\n onScroll: true,\n onWheel: true,\n onAbort: true,\n onCanPlay: true,\n onCanPlayThrough: true,\n onDurationChange: true,\n onEmptied: true,\n onEncrypted: true,\n onEnded: true,\n onLoadedData: true,\n onLoadedMetadata: true,\n onLoadStart: true,\n onPause: true,\n onPlay: true,\n onPlaying: true,\n onProgress: true,\n onRateChange: true,\n onSeeked: true,\n onSeeking: true,\n onStalled: true,\n onSuspend: true,\n onTimeUpdate: true,\n onVolumeChange: true,\n onWaiting: true,\n onAnimationStart: true,\n onAnimationEnd: true,\n onAnimationIteration: true,\n onTransitionEnd: true,\n onToggle: true,\n};\n\nexport const whiteList = {\n ...attributeWhiteList,\n ...svgAttributesWhiteList,\n ...otherWhiteList,\n ...eventsWhiteList,\n};\n\nexport const isDataAttribute = (attribute) =>\n attribute.substring(0, 5) === 'data-';\nexport const isAriaAttribute = (attribute) =>\n attribute.substring(0, 6) === 'aria-';\n\nexport const isValidNativeAttribute = (attribute) =>\n whiteList[attribute] === true ||\n isDataAttribute(attribute) ||\n isAriaAttribute(attribute) ||\n attribute.toLowerCase() === attribute;\n\nconst nativeHTMLElements = {\n a: true,\n abbr: true,\n address: true,\n area: true,\n article: true,\n aside: true,\n audio: true,\n b: true,\n base: true,\n bdi: true,\n bdo: true,\n big: true,\n blockquote: true,\n body: true,\n br: true,\n button: true,\n canvas: true,\n caption: true,\n cite: true,\n code: true,\n col: true,\n colgroup: true,\n data: true,\n datalist: true,\n dd: true,\n del: true,\n details: true,\n dfn: true,\n dialog: true,\n div: true,\n dl: true,\n dt: true,\n em: true,\n embed: true,\n fieldset: true,\n figcaption: true,\n figure: true,\n footer: true,\n form: true,\n h1: true,\n h2: true,\n h3: true,\n h4: true,\n h5: true,\n h6: true,\n head: true,\n header: true,\n hr: true,\n html: true,\n i: true,\n iframe: true,\n img: true,\n input: true,\n ins: true,\n kbd: true,\n keygen: true,\n label: true,\n legend: true,\n li: true,\n link: true,\n main: true,\n map: true,\n mark: true,\n menu: true,\n menuitem: true,\n meta: true,\n meter: true,\n nav: true,\n noscript: true,\n object: true,\n ol: true,\n optgroup: true,\n option: true,\n output: true,\n p: true,\n param: true,\n picture: true,\n pre: true,\n progress: true,\n q: true,\n rp: true,\n rt: true,\n ruby: true,\n s: true,\n samp: true,\n script: true,\n section: true,\n select: true,\n small: true,\n source: true,\n span: true,\n strong: true,\n style: true,\n sub: true,\n summary: true,\n sup: true,\n table: true,\n tbody: true,\n td: true,\n textarea: true,\n tfoot: true,\n th: true,\n thead: true,\n time: true,\n title: true,\n tr: true,\n track: true,\n u: true,\n ul: true,\n var: true,\n video: true,\n wbr: true,\n};\n\nexport const isNativeHTMLElement = (type) => nativeHTMLElements[type] === true;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,MAAM,qBAAqB;AAAA,EACzB,QAAQ;AAAA,EACR,eAAe;AAAA,EACf,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,iBAAiB;AAAA,EACjB,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EACL,UAAU;AAAA,EACV,GAAG;AAAA,EACH,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,GAAG;AAAA,EACH,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,KAAK;AAAA,EACL,SAAS;AAAA,EACT,KAAK;AAAA,EACL,OAAO;AAAA,EACP,OAAO;AAAA,EACP,IAAI;AAAA,EACJ,UAAU;AAAA,EACV,OAAO;AAAA,EACP,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,MAAM;AAAA,EACN,OAAO;AAAA,EACP,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,GAAG;AAAA,EACH,IAAI;AAAA,EACJ,KAAK;AAAA,EACL,OAAO;AAAA,EACP,KAAK;AAAA;AAGA,MAAM,sBAAsB,CAAC,SAAS,mBAAmB,UAAU;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/esm/aggregatedClasses.js
CHANGED
|
@@ -1,78 +1,44 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const _excluded = ["innerRef", "children", "classProps", "useComponent", "className", "as"];
|
|
17
|
-
|
|
18
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
19
|
-
|
|
20
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
|
-
const cssPrefix = DimsumConfig.classNamePrefix;
|
|
22
|
-
|
|
23
|
-
const generateClassNameWithModifier = (block, element, modifier) => "".concat(cssPrefix, "-").concat(block).concat(element ? "__".concat(element) : '', "--").concat(modifier);
|
|
24
|
-
|
|
25
|
-
const appendBlockAndPrefixToObj = (obj, block, element) => obj ? Object.keys(obj).reduce((acc, key) => _objectSpread(_objectSpread({}, acc), {}, {
|
|
26
|
-
["".concat(generateClassNameWithModifier(block, element, key))]: obj[key]
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2 from "react";
|
|
3
|
+
import cx from "obj-str";
|
|
4
|
+
import { convertPropToCssClassName } from "./classNameManager";
|
|
5
|
+
import { dimsumConfig } from "@elliemae/ds-shared/dimsum.config";
|
|
6
|
+
import {
|
|
7
|
+
isValidNativeAttribute,
|
|
8
|
+
isNativeHTMLElement
|
|
9
|
+
} from "./validateNativeProps";
|
|
10
|
+
const cssPrefix = dimsumConfig.classNamePrefix;
|
|
11
|
+
const generateClassNameWithModifier = (block, element, modifier) => `${cssPrefix}-${block}${element ? `__${element}` : ""}--${modifier}`;
|
|
12
|
+
const appendBlockAndPrefixToObj = (obj, block, element) => obj ? Object.keys(obj).reduce((acc, key) => ({
|
|
13
|
+
...acc,
|
|
14
|
+
[`${generateClassNameWithModifier(block, element, key)}`]: obj[key]
|
|
27
15
|
}), {}) : [];
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
as
|
|
39
|
-
} = _ref,
|
|
40
|
-
rest = _objectWithoutProperties(_ref, _excluded);
|
|
41
|
-
|
|
42
|
-
// get the additional classNames either from a function or an object
|
|
43
|
-
let otherModifiers = appendBlockAndPrefixToObj(additionalModifiers, block, element);
|
|
44
|
-
if (typeof additionalModifiers === 'function') otherModifiers = appendBlockAndPrefixToObj(additionalModifiers(_objectSpread(_objectSpread(_objectSpread({}, rest), classProps), {}, {
|
|
45
|
-
className
|
|
46
|
-
})), block, element);
|
|
47
|
-
const otherModifiersStr = cx(otherModifiers);
|
|
48
|
-
const {
|
|
49
|
-
prefix,
|
|
50
|
-
propsToRemoveFromFinalElement = []
|
|
51
|
-
} = options;
|
|
52
|
-
const {
|
|
53
|
-
cssClassName: classNames
|
|
54
|
-
} = cssPipeline(block, null, _objectSpread({}, classProps), {
|
|
55
|
-
prefix,
|
|
56
|
-
element
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
const cleanedPropsPassedDown = _objectSpread(_objectSpread({}, props), rest);
|
|
60
|
-
|
|
61
|
-
propsToRemoveFromFinalElement.forEach(propKey => {
|
|
62
|
-
delete cleanedPropsPassedDown[propKey];
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
if (isNativeHTMLElement(block)) {
|
|
66
|
-
Object.keys(cleanedPropsPassedDown).forEach(key => {
|
|
67
|
-
if (!isValidNativeAttribute(key)) delete cleanedPropsPassedDown[key];
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return /*#__PURE__*/React.createElement(as || type, _objectSpread({
|
|
72
|
-
ref: innerRef || ref,
|
|
73
|
-
className: [classNames, otherModifiersStr, className].join(' ')
|
|
74
|
-
}, cleanedPropsPassedDown), children);
|
|
16
|
+
const aggregatedClasses = (type, props) => (block, element, additionalModifiers, options = {}) => React2.forwardRef(({ innerRef, children, classProps, useComponent, className, as, ...rest }, ref) => {
|
|
17
|
+
let otherModifiers = appendBlockAndPrefixToObj(additionalModifiers, block, element);
|
|
18
|
+
if (typeof additionalModifiers === "function")
|
|
19
|
+
otherModifiers = appendBlockAndPrefixToObj(additionalModifiers({ ...rest, ...classProps, className }), block, element);
|
|
20
|
+
const otherModifiersStr = cx(otherModifiers);
|
|
21
|
+
const { prefix, propsToRemoveFromFinalElement = [] } = options;
|
|
22
|
+
const { cssClassName: classNames } = convertPropToCssClassName(block, null, { ...classProps }, { prefix, element });
|
|
23
|
+
const cleanedPropsPassedDown = { ...props, ...rest };
|
|
24
|
+
propsToRemoveFromFinalElement.forEach((propKey) => {
|
|
25
|
+
delete cleanedPropsPassedDown[propKey];
|
|
75
26
|
});
|
|
27
|
+
if (isNativeHTMLElement(block)) {
|
|
28
|
+
Object.keys(cleanedPropsPassedDown).forEach((key) => {
|
|
29
|
+
if (!isValidNativeAttribute(key))
|
|
30
|
+
delete cleanedPropsPassedDown[key];
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return React2.createElement(as || type, {
|
|
34
|
+
ref: innerRef || ref,
|
|
35
|
+
className: [classNames, otherModifiersStr, className].join(" "),
|
|
36
|
+
...cleanedPropsPassedDown
|
|
37
|
+
}, children);
|
|
38
|
+
});
|
|
39
|
+
var aggregatedClasses_default = aggregatedClasses;
|
|
40
|
+
export {
|
|
41
|
+
cssPrefix,
|
|
42
|
+
aggregatedClasses_default as default
|
|
76
43
|
};
|
|
77
|
-
|
|
78
|
-
export { cssPrefix, aggregatedClasses as default };
|
|
44
|
+
//# sourceMappingURL=aggregatedClasses.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/aggregatedClasses.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* 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';\nimport { dimsumConfig } from '@elliemae/ds-shared/dimsum.config';\nimport {\n isValidNativeAttribute,\n isNativeHTMLElement,\n} from './validateNativeProps';\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, other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,4BAAQ;",
|
|
6
|
+
"names": []
|
|
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
|
+
```
|