@threekit-tools/treble 0.0.56 → 0.0.57

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.
@@ -10,6 +10,25 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
22
+ }) : function(o, v) {
23
+ o["default"] = v;
24
+ });
25
+ var __importStar = (this && this.__importStar) || function (mod) {
26
+ if (mod && mod.__esModule) return mod;
27
+ var result = {};
28
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
+ __setModuleDefault(result, mod);
30
+ return result;
31
+ };
13
32
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
33
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
34
  };
@@ -20,7 +39,7 @@ var prop_types_1 = __importDefault(require("prop-types"));
20
39
  var flatForm_styles_1 = require("./flatForm.styles");
21
40
  var ProductName_1 = __importDefault(require("../ProductName"));
22
41
  var ProductDescription_1 = __importDefault(require("../ProductDescription"));
23
- var formComponents_1 = __importDefault(require("../formComponents"));
42
+ var formComponents_1 = __importStar(require("../formComponents"));
24
43
  var utils_1 = require("../../utils");
25
44
  var useConfigurator_1 = __importDefault(require("../../hooks/useConfigurator"));
26
45
  var constants_1 = require("../../constants");
@@ -45,10 +64,12 @@ var FlatForm = function (props) {
45
64
  var Component;
46
65
  var props = ((_b = (_a = (attributes || {})) === null || _a === void 0 ? void 0 : _a[attr.name]) === null || _b === void 0 ? void 0 : _b.props) || {};
47
66
  var type = attr.type;
48
- if (type === 'Asset' &&
49
- attr.assetType === constants_1.ASSET_TYPES.upload) {
67
+ if (attr.type === 'Asset' && attr.assetType === constants_1.ASSET_TYPES.upload) {
50
68
  type = attr.assetType;
51
69
  }
70
+ else if (attr.type === 'String' && attr.values.length === 0) {
71
+ type = formComponents_1.FORM_COMPONENT_TYPES.stringInput;
72
+ }
52
73
  if ((_d = (_c = (attributes || {})) === null || _c === void 0 ? void 0 : _c[attr.name]) === null || _d === void 0 ? void 0 : _d.component) {
53
74
  Component = (_e = Object.entries(formComponents_1.default[type] || {}).find(function (_a) {
54
75
  var _b, _c;
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import { IFormComponentProps } from '../containers/formInputContainer';
3
+ export interface ITextInput extends IFormComponentProps<undefined> {
4
+ }
5
+ export declare const TextInput: {
6
+ (props: ITextInput): JSX.Element;
7
+ componentName: string;
8
+ compatibleAttributes: Set<string>;
9
+ };
10
+ declare const _default: (props: ITextInput) => JSX.Element | null;
11
+ export default _default;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.TextInput = void 0;
7
+ var react_1 = __importDefault(require("react"));
8
+ // import PropTypes from 'prop-types';
9
+ var FormComponentTitle_1 = __importDefault(require("../FormComponentTitle"));
10
+ var FormComponentDescription_1 = __importDefault(require("../FormComponentDescription"));
11
+ var textInput_styles_1 = require("./textInput.styles");
12
+ var shared_styles_1 = require("../shared.styles");
13
+ var utils_1 = require("../../utils");
14
+ var constants_1 = require("../../constants");
15
+ var formInputContainer_1 = __importDefault(require("../containers/formInputContainer"));
16
+ var TextInput = function (props) {
17
+ var title = props.title, description = props.description, value = props.value, onChange = props.onChange, customClassName = props.className;
18
+ var cls = (0, utils_1.generateInputClassName)('text-input', customClassName, title);
19
+ return (react_1.default.createElement(shared_styles_1.FormComponentWrapper, { className: cls },
20
+ react_1.default.createElement(FormComponentTitle_1.default, { title: title, className: cls }),
21
+ react_1.default.createElement(FormComponentDescription_1.default, { description: description, className: cls }),
22
+ react_1.default.createElement(textInput_styles_1.Input, { type: "text", value: value, onChange: function (e) { return onChange && onChange(e.target.value); }, className: cls })));
23
+ };
24
+ exports.TextInput = TextInput;
25
+ exports.TextInput.componentName = 'text-input';
26
+ exports.TextInput.compatibleAttributes = new Set([constants_1.ATTRIBUTE_TYPES.string]);
27
+ exports.default = (0, formInputContainer_1.default)(exports.TextInput);
@@ -0,0 +1 @@
1
+ export declare const Input: import("styled-components").StyledComponent<"input", import("styled-components").DefaultTheme, {}, never>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
+ return cooked;
5
+ };
6
+ var __importDefault = (this && this.__importDefault) || function (mod) {
7
+ return (mod && mod.__esModule) ? mod : { "default": mod };
8
+ };
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.Input = void 0;
11
+ var styled_components_1 = __importDefault(require("styled-components"));
12
+ exports.Input = styled_components_1.default.input(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: 100%;\n margin: 0;\n padding: 10px 6px;\n background: #fff;\n border: 1px solid #d9d9d9;\n color: ", ";\n outline: none;\n border-radius: 2px;\n font-size: 14px;\n transition: all 0.3s;\n font-family: ", ";\n\n &:hover {\n border-color: ", ";\n }\n\n &:focus {\n border-color: ", ";\n box-shadow: 0 0 0 2px ", ";\n }\n"], ["\n width: 100%;\n margin: 0;\n padding: 10px 6px;\n background: #fff;\n border: 1px solid #d9d9d9;\n color: ", ";\n outline: none;\n border-radius: 2px;\n font-size: 14px;\n transition: all 0.3s;\n font-family: ", ";\n\n &:hover {\n border-color: ", ";\n }\n\n &:focus {\n border-color: ", ";\n box-shadow: 0 0 0 2px ", ";\n }\n"])), function (props) { return props.theme.textColor; }, function (props) { return props.theme.fontFamily; }, function (props) { return props.theme.primaryColor; }, function (props) { return props.theme.primaryColor; }, function (props) { return "".concat(props.theme.primaryColor, "33"); });
13
+ var templateObject_1;
@@ -1,4 +1,5 @@
1
1
  import { FunctionComponent } from 'react';
2
+ import { RawAttributeValue } from '../../hooks/useAttribute';
2
3
  import { IDisplayAttributeAssetValue, IThreekitDisplayAttribute } from '../../threekit';
3
4
  export interface IOptionShared {
4
5
  name: string;
@@ -23,10 +24,11 @@ export interface IFormContainerProps extends Pick<MetadataKeys, 'metadataKeyThum
23
24
  title?: string;
24
25
  description?: string;
25
26
  value?: string;
26
- onClick?: (value: string) => void;
27
+ onClick?: (value: RawAttributeValue) => Promise<void>;
28
+ onChange?: (value: RawAttributeValue) => Promise<void>;
27
29
  className?: string;
28
30
  }
29
- export interface IFormComponentProps<T extends IOptionShared | undefined> extends Pick<IFormContainerProps, 'title' | 'description' | 'value' | 'onClick' | 'className'> {
31
+ export interface IFormComponentProps<T extends IOptionShared | undefined> extends Pick<IFormContainerProps, 'title' | 'description' | 'value' | 'onClick' | 'onChange' | 'className'> {
30
32
  options: null | undefined | Array<T>;
31
33
  }
32
34
  export interface IFormComponent<P> extends FunctionComponent<P> {
@@ -1,7 +1,10 @@
1
1
  /// <reference types="react" />
2
+ export declare const FORM_COMPONENT_TYPES: {
3
+ stringInput: string;
4
+ };
2
5
  export declare const formComponents: {
3
6
  [x: string]: {
4
- [x: string]: ((props: import("./Cards").ICards) => JSX.Element | null) | ((props: import("./Tiles").ITiles) => JSX.Element | null);
7
+ [x: string]: ((props: import("./Cards").ICards) => JSX.Element | null) | ((props: import("./Tiles").ITiles) => JSX.Element | null) | ((props: import("./TextInput").ITextInput) => JSX.Element | null);
5
8
  } | {
6
9
  [x: string]: (props: import("./Upload").IUpload) => JSX.Element | null;
7
10
  };
@@ -18,9 +18,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
18
18
  __setModuleDefault(result, mod);
19
19
  return result;
20
20
  };
21
- var _a, _b, _c, _d;
21
+ var _a, _b, _c, _d, _e;
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.formComponents = void 0;
23
+ exports.formComponents = exports.FORM_COMPONENT_TYPES = void 0;
24
24
  var constants_1 = require("../constants");
25
25
  var Cards_1 = __importStar(require("./Cards"));
26
26
  var Dropdown_1 = __importStar(require("./Dropdown"));
@@ -30,9 +30,13 @@ var Tiles_1 = __importStar(require("./Tiles"));
30
30
  var TilesGroup_1 = __importStar(require("./TilesGroup"));
31
31
  var Upload_1 = __importStar(require("./Upload"));
32
32
  // import UploadArea, { UploadArea as UploadAreaComponent } from './UploadArea';
33
+ var TextInput_1 = __importStar(require("./TextInput"));
34
+ exports.FORM_COMPONENT_TYPES = {
35
+ stringInput: 'string-input',
36
+ };
37
+ // First option for each attribute type is the default value
33
38
  exports.formComponents = (_a = {},
34
39
  _a[constants_1.ATTRIBUTE_TYPES.asset] = (_b = {},
35
- // First option is default
36
40
  _b[Strips_1.Strips.componentName] = Strips_1.default,
37
41
  _b[Cards_1.Cards.componentName] = Cards_1.default,
38
42
  _b[Dropdown_1.Dropdown.componentName] = Dropdown_1.default,
@@ -41,16 +45,19 @@ exports.formComponents = (_a = {},
41
45
  _b[TilesGroup_1.TilesGroup.componentName] = TilesGroup_1.default,
42
46
  _b),
43
47
  _a[constants_1.ATTRIBUTE_TYPES.string] = (_c = {},
44
- // First option is default
45
48
  _c[Tiles_1.Tiles.componentName] = Tiles_1.default,
46
49
  _c[Dropdown_1.Dropdown.componentName] = Dropdown_1.default,
47
50
  _c[Cards_1.Cards.componentName] = Cards_1.default,
48
51
  _c[Strips_1.Strips.componentName] = Strips_1.default,
49
52
  _c[Swatch_1.Swatch.componentName] = Swatch_1.default,
50
53
  _c[TilesGroup_1.TilesGroup.componentName] = TilesGroup_1.default,
54
+ _c[TextInput_1.TextInput.componentName] = TextInput_1.default,
51
55
  _c),
52
- _a[constants_1.ASSET_TYPES.upload] = (_d = {},
53
- _d[Upload_1.Upload.componentName] = Upload_1.default,
56
+ _a[exports.FORM_COMPONENT_TYPES.stringInput] = (_d = {},
57
+ _d[TextInput_1.TextInput.componentName] = TextInput_1.default,
54
58
  _d),
59
+ _a[constants_1.ASSET_TYPES.upload] = (_e = {},
60
+ _e[Upload_1.Upload.componentName] = Upload_1.default,
61
+ _e),
55
62
  _a);
56
63
  exports.default = exports.formComponents;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threekit-tools/treble",
3
- "version": "0.0.56",
3
+ "version": "0.0.57",
4
4
  "author": "Amaan Saeed",
5
5
  "license": "MIT",
6
6
  "files": [