@threekit-tools/treble 0.0.61 → 0.0.64

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.
@@ -1,4 +1,3 @@
1
- import threekitAPI from '../api';
2
1
  import { IThreekitPlayer, IConfiguration, ISetConfiguration, IThreekitPrivateConfigurator } from '../threekit';
3
2
  import { IWishlist } from './Wishlist';
4
3
  import Snapshots from './Snapshots';
@@ -14,7 +13,6 @@ interface IEmailShareCredentials {
14
13
  templateId: string;
15
14
  }
16
15
  declare class Treble {
17
- _api: typeof threekitAPI;
18
16
  _player: IThreekitPlayer;
19
17
  wishlist: IWishlist;
20
18
  private _initialConfiguration;
@@ -120,7 +120,6 @@ var Treble = /** @class */ (function () {
120
120
  return api_1.default.server.sendEmail(data);
121
121
  };
122
122
  // Threekit API
123
- this._api = api_1.default;
124
123
  this._player = player;
125
124
  this.wishlist = (0, Wishlist_1.default)(orgId);
126
125
  this._snapshots = new Snapshots_1.default();
@@ -0,0 +1,7 @@
1
+ interface IDatatableConfig {
2
+ format: string;
3
+ }
4
+ export declare const getDatatable: (datatableId: string, config: IDatatableConfig) => Promise<string | {
5
+ [key: string]: any;
6
+ }[] | undefined>;
7
+ export {};
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.getDatatable = void 0;
43
+ var http_1 = __importDefault(require("../http"));
44
+ var utils_1 = require("../utils");
45
+ var constants_1 = require("../constants");
46
+ var getDatatable = function (datatableId, config) { return __awaiter(void 0, void 0, void 0, function () {
47
+ var message, format, response, csvData, headings, datatableJson;
48
+ return __generator(this, function (_a) {
49
+ switch (_a.label) {
50
+ case 0:
51
+ if (!datatableId)
52
+ message = 'Requires a datatable ID';
53
+ if (message)
54
+ return [2 /*return*/, Promise.resolve(undefined)];
55
+ format = Object.assign({ format: constants_1.DATATABLE_FORMATS.json }, config).format;
56
+ return [4 /*yield*/, http_1.default.datatables.getDatatable(datatableId)];
57
+ case 1:
58
+ response = _a.sent();
59
+ if (response.status !== 200)
60
+ return [2 /*return*/, Promise.resolve(undefined)];
61
+ if (format.toLowerCase() === constants_1.DATATABLE_FORMATS.csv)
62
+ return [2 /*return*/, Promise.resolve(response.data)];
63
+ csvData = response.data
64
+ .replace(/"/g, '')
65
+ .split('\n')
66
+ .map(function (el) { return el.split(','); });
67
+ headings = csvData[0];
68
+ datatableJson = csvData.reduce(function (output, row, idx) {
69
+ if (!idx)
70
+ return output;
71
+ var rowOutput = row.reduce(function (result, el, i) {
72
+ var _a;
73
+ if (!i)
74
+ return result;
75
+ return Object.assign(result, (_a = {},
76
+ _a[headings[i]] = el.length
77
+ ? (0, utils_1.isJsonString)(el)
78
+ ? JSON.parse(el)
79
+ : el
80
+ : undefined,
81
+ _a));
82
+ }, {});
83
+ output.push(rowOutput);
84
+ return output;
85
+ }, []);
86
+ return [2 /*return*/, Promise.resolve(datatableJson)];
87
+ }
88
+ });
89
+ }); };
90
+ exports.getDatatable = getDatatable;
@@ -3,6 +3,7 @@ import * as configurations from './configurations';
3
3
  import * as price from './price';
4
4
  import * as orders from './orders';
5
5
  import * as catalog from './catalog';
6
+ import * as datatables from './datatables';
6
7
  import * as server from './server';
7
8
  declare const _default: {
8
9
  products: typeof products;
@@ -10,6 +11,7 @@ declare const _default: {
10
11
  price: typeof price;
11
12
  orders: typeof orders;
12
13
  catalog: typeof catalog;
14
+ datatables: typeof datatables;
13
15
  server: typeof server;
14
16
  };
15
17
  export default _default;
package/dist/api/index.js CHANGED
@@ -24,6 +24,7 @@ var configurations = __importStar(require("./configurations"));
24
24
  var price = __importStar(require("./price"));
25
25
  var orders = __importStar(require("./orders"));
26
26
  var catalog = __importStar(require("./catalog"));
27
+ var datatables = __importStar(require("./datatables"));
27
28
  var server = __importStar(require("./server"));
28
29
  exports.default = {
29
30
  products: products,
@@ -31,5 +32,6 @@ exports.default = {
31
32
  price: price,
32
33
  orders: orders,
33
34
  catalog: catalog,
35
+ datatables: datatables,
34
36
  server: server,
35
37
  };
@@ -0,0 +1,66 @@
1
+ /// <reference types="react" />
2
+ import PropTypes from 'prop-types';
3
+ import { IFormComponentProps, IOption } from '../containers/formInputContainer';
4
+ export interface ISwitch extends IFormComponentProps<IOption> {
5
+ showDescription?: boolean;
6
+ }
7
+ export declare const Switch: {
8
+ (props: ISwitch): JSX.Element;
9
+ propTypes: {
10
+ /**
11
+ * Is the attribute name on the initialized asset that we are
12
+ * using this component for. If the attribute prop is used,
13
+ * the component will ignore the props for: `value`, `options`, `onClick`.
14
+ */
15
+ attribute: PropTypes.Requireable<string>;
16
+ /**
17
+ * Used to add a title to the input
18
+ */
19
+ title: PropTypes.Requireable<string>;
20
+ /**
21
+ * Used to provide a custom description for the input component
22
+ */
23
+ description: PropTypes.Requireable<string>;
24
+ /**
25
+ * Selected value from the option set. Should match the 'value' property
26
+ * of one of the items in the options array.
27
+ */
28
+ value: PropTypes.Requireable<boolean>;
29
+ /**
30
+ * The size of the for a Switch option. The size should be a valid CSS
31
+ * height/width property.
32
+ *
33
+ */
34
+ onClick: PropTypes.Requireable<(...args: any[]) => any>;
35
+ /**
36
+ * Used to add a custom class name to each of the components html elements
37
+ */
38
+ className: PropTypes.Requireable<string>;
39
+ /**
40
+ * By default the description is soruced from the `_description` metadata
41
+ * key in the option's Catalog Item. This metadata key can be overwritten
42
+ * by passing in the prefered key value to the **metadataKeyDescription**
43
+ * prop.
44
+ */
45
+ metadataKeyDescription: PropTypes.Requireable<string>;
46
+ /**
47
+ * A boolean to set whether or all the Cards should display the description
48
+ * for the options.
49
+ */
50
+ showDescription: PropTypes.Requireable<boolean>;
51
+ };
52
+ defaultProps: {
53
+ description: undefined;
54
+ className: undefined;
55
+ attribute: undefined;
56
+ metadataKeyDescription: undefined;
57
+ showDescription: boolean;
58
+ title: undefined;
59
+ value: undefined;
60
+ onClick: undefined;
61
+ };
62
+ componentName: string;
63
+ compatibleAttributes: Set<string>;
64
+ };
65
+ declare const _default: (props: ISwitch) => JSX.Element | null;
66
+ export default _default;
@@ -0,0 +1,86 @@
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.Switch = void 0;
7
+ var react_1 = __importDefault(require("react"));
8
+ var prop_types_1 = __importDefault(require("prop-types"));
9
+ var FormComponentTitle_1 = __importDefault(require("../FormComponentTitle"));
10
+ var FormComponentDescription_1 = __importDefault(require("../FormComponentDescription"));
11
+ var switch_styles_1 = require("./switch.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 Switch = function (props) {
17
+ var title = props.title, value = props.value, onChange = props.onChange, description = props.description, customClassName = props.className, showDescription = props.showDescription;
18
+ var cls = (0, utils_1.generateInputClassName)('Switch', 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: showDescription ? description : undefined, className: cls }),
22
+ react_1.default.createElement(switch_styles_1.SwitchWrapper, null,
23
+ react_1.default.createElement(switch_styles_1.Checkbox, { type: "checkbox", checked: !!value, onChange: function () { return onChange === null || onChange === void 0 ? void 0 : onChange(!!!value); } }),
24
+ react_1.default.createElement(switch_styles_1.Knob, null),
25
+ react_1.default.createElement(switch_styles_1.Layer, null))));
26
+ };
27
+ exports.Switch = Switch;
28
+ exports.Switch.propTypes = {
29
+ /**
30
+ * Is the attribute name on the initialized asset that we are
31
+ * using this component for. If the attribute prop is used,
32
+ * the component will ignore the props for: `value`, `options`, `onClick`.
33
+ */
34
+ attribute: prop_types_1.default.string,
35
+ /**
36
+ * Used to add a title to the input
37
+ */
38
+ title: prop_types_1.default.string,
39
+ /**
40
+ * Used to provide a custom description for the input component
41
+ */
42
+ description: prop_types_1.default.string,
43
+ /**
44
+ * Selected value from the option set. Should match the 'value' property
45
+ * of one of the items in the options array.
46
+ */
47
+ value: prop_types_1.default.bool,
48
+ /**
49
+ * The size of the for a Switch option. The size should be a valid CSS
50
+ * height/width property.
51
+ *
52
+ */
53
+ onClick: prop_types_1.default.func,
54
+ /**
55
+ * Used to add a custom class name to each of the components html elements
56
+ */
57
+ className: prop_types_1.default.string,
58
+ /**
59
+ * By default the description is soruced from the `_description` metadata
60
+ * key in the option's Catalog Item. This metadata key can be overwritten
61
+ * by passing in the prefered key value to the **metadataKeyDescription**
62
+ * prop.
63
+ */
64
+ metadataKeyDescription: prop_types_1.default.string,
65
+ /**
66
+ * A boolean to set whether or all the Cards should display the description
67
+ * for the options.
68
+ */
69
+ showDescription: prop_types_1.default.bool,
70
+ };
71
+ exports.Switch.defaultProps = {
72
+ description: undefined,
73
+ className: undefined,
74
+ // Default use
75
+ attribute: undefined,
76
+ // Default user overrides
77
+ metadataKeyDescription: undefined,
78
+ showDescription: true,
79
+ // Custom use
80
+ title: undefined,
81
+ value: undefined,
82
+ onClick: undefined,
83
+ };
84
+ exports.Switch.componentName = 'Switch';
85
+ exports.Switch.compatibleAttributes = new Set([constants_1.ATTRIBUTE_TYPES.boolean]);
86
+ exports.default = (0, formInputContainer_1.default)(exports.Switch);
@@ -0,0 +1,4 @@
1
+ export declare const Layer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
2
+ export declare const Knob: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
3
+ export declare const Checkbox: import("styled-components").StyledComponent<"input", import("styled-components").DefaultTheme, {}, never>;
4
+ export declare const SwitchWrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
@@ -0,0 +1,16 @@
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.SwitchWrapper = exports.Checkbox = exports.Knob = exports.Layer = void 0;
11
+ var styled_components_1 = __importDefault(require("styled-components"));
12
+ exports.Layer = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n\n width: 100%;\n border-radius: 100px;\n background-color: #bbb;\n transition: 0.3s ease all;\n z-index: 1;\n"], ["\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n\n width: 100%;\n border-radius: 100px;\n background-color: #bbb;\n transition: 0.3s ease all;\n z-index: 1;\n"])));
13
+ exports.Knob = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n z-index: 2;\n\n &:before {\n content: '';\n position: absolute;\n top: 4px;\n left: 4px;\n width: 20px;\n height: 10px;\n color: #fff;\n font-size: 10px;\n font-weight: bold;\n text-align: center;\n line-height: 1;\n padding: 9px 4px;\n background-color: #fff;\n border-radius: 50%;\n transition: 0.3s ease all, left 0.3s cubic-bezier(0.18, 0.89, 0.35, 1.15);\n }\n"], ["\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n z-index: 2;\n\n &:before {\n content: '';\n position: absolute;\n top: 4px;\n left: 4px;\n width: 20px;\n height: 10px;\n color: #fff;\n font-size: 10px;\n font-weight: bold;\n text-align: center;\n line-height: 1;\n padding: 9px 4px;\n background-color: #fff;\n border-radius: 50%;\n transition: 0.3s ease all, left 0.3s cubic-bezier(0.18, 0.89, 0.35, 1.15);\n }\n"])));
14
+ exports.Checkbox = styled_components_1.default.input(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: relative;\n width: 100%;\n height: 100%;\n padding: 0;\n margin: 0;\n opacity: 0;\n cursor: pointer;\n z-index: 3;\n"], ["\n position: relative;\n width: 100%;\n height: 100%;\n padding: 0;\n margin: 0;\n opacity: 0;\n cursor: pointer;\n z-index: 3;\n"])));
15
+ exports.SwitchWrapper = styled_components_1.default.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n position: relative;\n width: 74px;\n height: 36px;\n overflow: hidden;\n\n & ", ":active + ", ":before {\n width: 46px;\n border-radius: 100px;\n }\n\n & ", ":checked + ", ":before {\n content: '';\n left: 42px;\n }\n\n & ", ":checked:active + ", ":before {\n margin-left: -26px;\n }\n\n & ", ":checked ~ ", " {\n background-color: ", ";\n }\n"], ["\n position: relative;\n width: 74px;\n height: 36px;\n overflow: hidden;\n\n & ", ":active + ", ":before {\n width: 46px;\n border-radius: 100px;\n }\n\n & ", ":checked + ", ":before {\n content: '';\n left: 42px;\n }\n\n & ", ":checked:active + ", ":before {\n margin-left: -26px;\n }\n\n & ", ":checked ~ ", " {\n background-color: ", ";\n }\n"])), exports.Checkbox, exports.Knob, exports.Checkbox, exports.Knob, exports.Checkbox, exports.Knob, exports.Checkbox, exports.Layer, function (props) { return props.theme.primaryColor; });
16
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
@@ -16,6 +16,8 @@ var formInputContainer_1 = __importDefault(require("../containers/formInputConta
16
16
  var TextInput = function (props) {
17
17
  var title = props.title, description = props.description, value = props.value, onChange = props.onChange, maxLength = props.maxLength, customClassName = props.className;
18
18
  var cls = (0, utils_1.generateInputClassName)('text-input', customClassName, title);
19
+ if (typeof value !== 'string')
20
+ return react_1.default.createElement(react_1.default.Fragment, null);
19
21
  return (react_1.default.createElement(shared_styles_1.FormComponentWrapper, { className: cls },
20
22
  react_1.default.createElement(FormComponentTitle_1.default, { title: title, className: cls }),
21
23
  react_1.default.createElement(FormComponentDescription_1.default, { description: description, className: cls }),
@@ -69,8 +69,9 @@ var icons_1 = require("../../icons");
69
69
  var formInputContainer_1 = __importDefault(require("../containers/formInputContainer"));
70
70
  var upload_styles_1 = require("./upload.styles");
71
71
  var Upload = function (props) {
72
+ var _a, _b;
72
73
  var title = props.title, description = props.description, value = props.value, onChange = props.onChange, customClassName = props.className;
73
- var _a = (0, react_1.useState)(false), isUploading = _a[0], setIsUploading = _a[1];
74
+ var _c = (0, react_1.useState)(false), isUploading = _c[0], setIsUploading = _c[1];
74
75
  var inputRef = (0, react_1.useRef)(null);
75
76
  var imgRef = (0, react_1.useRef)(null);
76
77
  var cls = (0, utils_1.generateInputClassName)('upload', customClassName, title);
@@ -78,7 +79,7 @@ var Upload = function (props) {
78
79
  var _a;
79
80
  if (isUploading)
80
81
  return;
81
- if (value === null || value === void 0 ? void 0 : value.length)
82
+ if (typeof value === 'string' && (value === null || value === void 0 ? void 0 : value.length))
82
83
  return;
83
84
  (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.click();
84
85
  };
@@ -109,7 +110,7 @@ var Upload = function (props) {
109
110
  return (react_1.default.createElement(shared_styles_1.FormComponentWrapper, null,
110
111
  react_1.default.createElement(FormComponentTitle_1.default, { title: title, className: cls }),
111
112
  react_1.default.createElement(FormComponentDescription_1.default, { description: description, className: cls }),
112
- react_1.default.createElement(upload_styles_1.UploadWrapper, { className: cls, uploaded: !!(!isUploading && (value === null || value === void 0 ? void 0 : value.length)) },
113
+ react_1.default.createElement(upload_styles_1.UploadWrapper, { className: cls, uploaded: !!(!isUploading && ((_a = value) === null || _a === void 0 ? void 0 : _a.length)) },
113
114
  react_1.default.createElement("input", { type: "file", ref: inputRef, onChange: function (e) { return __awaiter(void 0, void 0, void 0, function () {
114
115
  var _a;
115
116
  return __generator(this, function (_b) {
@@ -122,7 +123,7 @@ var Upload = function (props) {
122
123
  react_1.default.createElement("button", { type: "button", onClick: handleClick }, isUploading ? (react_1.default.createElement(react_1.default.Fragment, null,
123
124
  react_1.default.createElement(upload_styles_1.IconWrapper, null,
124
125
  react_1.default.createElement(icons_1.SpinnerIcon, { size: "28px" })),
125
- react_1.default.createElement("div", null, "Uploading..."))) : (value === null || value === void 0 ? void 0 : value.length) ? (react_1.default.createElement(upload_styles_1.ImageWrapper, null,
126
+ react_1.default.createElement("div", null, "Uploading..."))) : ((_b = value) === null || _b === void 0 ? void 0 : _b.length) ? (react_1.default.createElement(upload_styles_1.ImageWrapper, null,
126
127
  react_1.default.createElement("div", null,
127
128
  react_1.default.createElement("img", { ref: imgRef, src: "#" })),
128
129
  react_1.default.createElement(upload_styles_1.ImageActionArea, null,
@@ -69,9 +69,10 @@ var icons_1 = require("../../icons");
69
69
  var formInputContainer_1 = __importDefault(require("../containers/formInputContainer"));
70
70
  var uploadArea_styles_1 = require("./uploadArea.styles");
71
71
  var UploadArea = function (props) {
72
+ var _a;
72
73
  var title = props.title, description = props.description, value = props.value, onChange = props.onChange, customClassName = props.className;
73
- var _a = (0, react_1.useState)(false), isUploading = _a[0], setIsUploading = _a[1];
74
- var _b = (0, react_1.useState)(undefined), filename = _b[0], setFilename = _b[1];
74
+ var _b = (0, react_1.useState)(false), isUploading = _b[0], setIsUploading = _b[1];
75
+ var _c = (0, react_1.useState)(undefined), filename = _c[0], setFilename = _c[1];
75
76
  var inputRef = (0, react_1.useRef)(null);
76
77
  var imgRef = (0, react_1.useRef)(null);
77
78
  var cls = (0, utils_1.generateInputClassName)('upload', customClassName, title);
@@ -120,7 +121,7 @@ var UploadArea = function (props) {
120
121
  react_1.default.createElement("button", { type: "button", onClick: handleClick }, isUploading ? (react_1.default.createElement(uploadArea_styles_1.UploadingWrapper, null,
121
122
  react_1.default.createElement("div", null,
122
123
  react_1.default.createElement(icons_1.SpinnerIcon, { size: "28px" })),
123
- react_1.default.createElement("div", null, "Uploading..."))) : (value === null || value === void 0 ? void 0 : value.length) ? (react_1.default.createElement(uploadArea_styles_1.UploadingWrapper, null,
124
+ react_1.default.createElement("div", null, "Uploading..."))) : ((_a = value) === null || _a === void 0 ? void 0 : _a.length) ? (react_1.default.createElement(uploadArea_styles_1.UploadingWrapper, null,
124
125
  react_1.default.createElement("div", null,
125
126
  react_1.default.createElement("img", { ref: imgRef, src: "#" })),
126
127
  react_1.default.createElement("div", null,
@@ -25,7 +25,7 @@ export interface IFormContainerProps extends Pick<MetadataKeys, 'metadataKeyThum
25
25
  sort?: string;
26
26
  title?: string;
27
27
  description?: string;
28
- value?: string;
28
+ value?: string | boolean;
29
29
  onClick?: (value: RawAttributeValue) => Promise<void>;
30
30
  onChange?: (value: RawAttributeValue) => Promise<void>;
31
31
  className?: string;
@@ -41,7 +41,7 @@ interface IHydrateAttributeConfig {
41
41
  sort?: string;
42
42
  }
43
43
  export declare const hydrateAttributeForComponent: (attribute: IHydratedAttribute, config: IHydrateAttributeConfig) => {
44
- selected: string | number | import("../../threekit").IConfigurationAsset | import("../../threekit").IConfigurationColor;
44
+ selected: string | number | boolean | import("../../threekit").IConfigurationAsset | import("../../threekit").IConfigurationColor;
45
45
  options: {
46
46
  name: string;
47
47
  handleSelect: () => Promise<void>;
@@ -18,7 +18,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
18
18
  __setModuleDefault(result, mod);
19
19
  return result;
20
20
  };
21
- var _a, _b, _c, _d, _e;
21
+ var _a, _b, _c, _d, _e, _f;
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.formComponents = exports.FORM_COMPONENT_TYPES = void 0;
24
24
  var constants_1 = require("../constants");
@@ -31,6 +31,7 @@ var TilesGroup_1 = __importStar(require("./TilesGroup"));
31
31
  var Upload_1 = __importStar(require("./Upload"));
32
32
  // import UploadArea, { UploadArea as UploadAreaComponent } from './UploadArea';
33
33
  var TextInput_1 = __importStar(require("./TextInput"));
34
+ var Switch_1 = __importStar(require("./Switch"));
34
35
  exports.FORM_COMPONENT_TYPES = {
35
36
  stringInput: 'string-input',
36
37
  };
@@ -59,5 +60,8 @@ exports.formComponents = (_a = {},
59
60
  _a[constants_1.ASSET_TYPES.upload] = (_e = {},
60
61
  _e[Upload_1.Upload.componentName] = Upload_1.default,
61
62
  _e),
63
+ _a[constants_1.ATTRIBUTE_TYPES.boolean] = (_f = {},
64
+ _f[Switch_1.Switch.componentName] = Switch_1.default,
65
+ _f),
62
66
  _a);
63
67
  exports.default = exports.formComponents;
@@ -84,3 +84,10 @@ export declare const SNAPSHOT_OUTPUTS: {
84
84
  * Wishlist
85
85
  ****************************************************/
86
86
  export declare const WISHLIST_LOCALSTORAGE_KEY = "tk_wishlist";
87
+ /*****************************************************
88
+ * Datatables
89
+ ****************************************************/
90
+ export declare const DATATABLE_FORMATS: {
91
+ csv: string;
92
+ json: string;
93
+ };
package/dist/constants.js CHANGED
@@ -4,7 +4,7 @@
4
4
  ****************************************************/
5
5
  var _a;
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.WISHLIST_LOCALSTORAGE_KEY = exports.SNAPSHOT_OUTPUTS = exports.SNAPSHOT_FORMATS = exports.METADATA_RESERVED = exports.ATTRIBUTES_RESERVED = exports.SORT_OPTIONS = exports.ASSET_TYPES = exports.ATTRIBUTE_TYPES = exports.DEFAULT_PLAYER_CONFIG = exports.TK_PLAYER_ROOT_DIV = exports.TK_PLAYER_LOADER_DIV = exports.TK_SAVED_CONFIG_PARAM_KEY = exports.TK_PRODUCT_ID_PARAM_KEY = exports.IS_TREBLE_SCRIPTS = exports.FORM_CLASS_NAME = exports.DISPLAY_CLASS_NAME = exports.TOOL_CLASS_NAME = exports.LAYOUT_CLASS_NAME = exports.WIDGET_CLASS_NAME = exports.INPUT_COMPONENT_CLASS_NAME = exports.CLASS_NAME_PREFIX = exports.DEFAULT_CLASS_NAME = void 0;
7
+ exports.DATATABLE_FORMATS = exports.WISHLIST_LOCALSTORAGE_KEY = exports.SNAPSHOT_OUTPUTS = exports.SNAPSHOT_FORMATS = exports.METADATA_RESERVED = exports.ATTRIBUTES_RESERVED = exports.SORT_OPTIONS = exports.ASSET_TYPES = exports.ATTRIBUTE_TYPES = exports.DEFAULT_PLAYER_CONFIG = exports.TK_PLAYER_ROOT_DIV = exports.TK_PLAYER_LOADER_DIV = exports.TK_SAVED_CONFIG_PARAM_KEY = exports.TK_PRODUCT_ID_PARAM_KEY = exports.IS_TREBLE_SCRIPTS = exports.FORM_CLASS_NAME = exports.DISPLAY_CLASS_NAME = exports.TOOL_CLASS_NAME = exports.LAYOUT_CLASS_NAME = exports.WIDGET_CLASS_NAME = exports.INPUT_COMPONENT_CLASS_NAME = exports.CLASS_NAME_PREFIX = exports.DEFAULT_CLASS_NAME = void 0;
8
8
  exports.DEFAULT_CLASS_NAME = 'threekit-react';
9
9
  exports.CLASS_NAME_PREFIX = 'tk';
10
10
  exports.INPUT_COMPONENT_CLASS_NAME = "".concat(exports.DEFAULT_CLASS_NAME, " ").concat(exports.CLASS_NAME_PREFIX, "-input");
@@ -97,3 +97,10 @@ exports.SNAPSHOT_OUTPUTS = {
97
97
  * Wishlist
98
98
  ****************************************************/
99
99
  exports.WISHLIST_LOCALSTORAGE_KEY = 'tk_wishlist';
100
+ /*****************************************************
101
+ * Datatables
102
+ ****************************************************/
103
+ exports.DATATABLE_FORMATS = {
104
+ csv: 'csv',
105
+ json: 'json',
106
+ };
@@ -0,0 +1,18 @@
1
+ interface IDatatable {
2
+ id: string;
3
+ orgId: string;
4
+ name: string;
5
+ version: number;
6
+ columnInfo: string;
7
+ createdBy: string;
8
+ updatedBy: string;
9
+ createdAt: string;
10
+ updatedAt: string;
11
+ deletedAt: null | string;
12
+ deletedBy: null | string;
13
+ }
14
+ export declare const getDatatablesList: () => Promise<import("axios").AxiosResponse<{
15
+ datatables: Array<IDatatable>;
16
+ }>>;
17
+ export declare const getDatatable: (datatableId: string) => Promise<import("axios").AxiosResponse<string>>;
18
+ export {};
@@ -0,0 +1,22 @@
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.getDatatable = exports.getDatatablesList = void 0;
7
+ var request_1 = __importDefault(require("./request"));
8
+ var DATATABLES_API_ROUTE = "/api/datatables";
9
+ var getDatatablesList = function () {
10
+ return request_1.default.get(DATATABLES_API_ROUTE);
11
+ };
12
+ exports.getDatatablesList = getDatatablesList;
13
+ var getDatatable = function (datatableId) {
14
+ var error;
15
+ if (!datatableId)
16
+ error = 'Requires a datatableId';
17
+ if (error)
18
+ throw new Error(error);
19
+ // return threekitRequest.get<Array<IDatatable>>(
20
+ return request_1.default.get("".concat(DATATABLES_API_ROUTE, "/").concat(datatableId, "/download"));
21
+ };
22
+ exports.getDatatable = getDatatable;
@@ -3,6 +3,7 @@ import * as products from './products';
3
3
  import * as configurations from './configurations';
4
4
  import * as pricebook from './pricebook';
5
5
  import * as catalog from './catalog';
6
+ import * as datatables from './datatables';
6
7
  import * as server from './server';
7
8
  declare const _default: {
8
9
  orders: typeof orders;
@@ -10,6 +11,7 @@ declare const _default: {
10
11
  configurations: typeof configurations;
11
12
  pricebook: typeof pricebook;
12
13
  catalog: typeof catalog;
14
+ datatables: typeof datatables;
13
15
  server: typeof server;
14
16
  };
15
17
  export default _default;
@@ -24,6 +24,7 @@ var products = __importStar(require("./products"));
24
24
  var configurations = __importStar(require("./configurations"));
25
25
  var pricebook = __importStar(require("./pricebook"));
26
26
  var catalog = __importStar(require("./catalog"));
27
+ var datatables = __importStar(require("./datatables"));
27
28
  var server = __importStar(require("./server"));
28
29
  exports.default = {
29
30
  orders: orders,
@@ -31,5 +32,6 @@ exports.default = {
31
32
  configurations: configurations,
32
33
  pricebook: pricebook,
33
34
  catalog: catalog,
35
+ datatables: datatables,
34
36
  server: server,
35
37
  };
package/dist/index.d.ts CHANGED
@@ -22,6 +22,7 @@ import Swatch from './components/Swatch';
22
22
  import Tiles from './components/Tiles';
23
23
  import TilesGroup from './components/TilesGroup';
24
24
  import Upload from './components/Upload';
25
+ import Switch from './components/Switch';
25
26
  import ProductName from './components/ProductName';
26
27
  import ProductDescription from './components/ProductDescription';
27
28
  import AttributeTitle from './components/AttributeTitle';
@@ -43,4 +44,4 @@ import icons from './icons';
43
44
  export * from './icons';
44
45
  import TrebleApp from './components/TrebleApp';
45
46
  import ProductLayout from './components/ProductLayout';
46
- export { useAttribute, useConfigurator, useMetadata, useName, usePlayerLoadingStatus, usePrice, useThreekitInitStatus, useZoom, useSnapshot, useWishlist, useShare, usePlayerPortal, useProductCache, useNestedConfigurator, ThreekitProvider, Player, Button, Cards, Dropdown, Strips, Swatch, Tiles, TilesGroup, Upload, ProductName, ProductDescription, AttributeTitle, AttributeValue, TotalPrice, message, Modal, Drawer, Accordion, Tabs, PortalToElement, AwaitThreekitLoad, FlatForm, Zoom, Snapshots, Wishlist, Share, icons, TrebleApp, ProductLayout, };
47
+ export { useAttribute, useConfigurator, useMetadata, useName, usePlayerLoadingStatus, usePrice, useThreekitInitStatus, useZoom, useSnapshot, useWishlist, useShare, usePlayerPortal, useProductCache, useNestedConfigurator, ThreekitProvider, Player, Button, Cards, Dropdown, Strips, Swatch, Tiles, TilesGroup, Upload, Switch, ProductName, ProductDescription, AttributeTitle, AttributeValue, TotalPrice, message, Modal, Drawer, Accordion, Tabs, PortalToElement, AwaitThreekitLoad, FlatForm, Zoom, Snapshots, Wishlist, Share, icons, TrebleApp, ProductLayout, };
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  return (mod && mod.__esModule) ? mod : { "default": mod };
14
14
  };
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.ProductLayout = exports.TrebleApp = exports.icons = exports.Share = exports.Wishlist = exports.Snapshots = exports.Zoom = exports.FlatForm = exports.AwaitThreekitLoad = exports.PortalToElement = exports.Tabs = exports.Accordion = exports.Drawer = exports.Modal = exports.message = exports.TotalPrice = exports.AttributeValue = exports.AttributeTitle = exports.ProductDescription = exports.ProductName = exports.Upload = exports.TilesGroup = exports.Tiles = exports.Swatch = exports.Strips = exports.Dropdown = exports.Cards = exports.Button = exports.Player = exports.ThreekitProvider = exports.useNestedConfigurator = exports.useProductCache = exports.usePlayerPortal = exports.useShare = exports.useWishlist = exports.useSnapshot = exports.useZoom = exports.useThreekitInitStatus = exports.usePrice = exports.usePlayerLoadingStatus = exports.useName = exports.useMetadata = exports.useConfigurator = exports.useAttribute = void 0;
16
+ exports.ProductLayout = exports.TrebleApp = exports.icons = exports.Share = exports.Wishlist = exports.Snapshots = exports.Zoom = exports.FlatForm = exports.AwaitThreekitLoad = exports.PortalToElement = exports.Tabs = exports.Accordion = exports.Drawer = exports.Modal = exports.message = exports.TotalPrice = exports.AttributeValue = exports.AttributeTitle = exports.ProductDescription = exports.ProductName = exports.Switch = exports.Upload = exports.TilesGroup = exports.Tiles = exports.Swatch = exports.Strips = exports.Dropdown = exports.Cards = exports.Button = exports.Player = exports.ThreekitProvider = exports.useNestedConfigurator = exports.useProductCache = exports.usePlayerPortal = exports.useShare = exports.useWishlist = exports.useSnapshot = exports.useZoom = exports.useThreekitInitStatus = exports.usePrice = exports.usePlayerLoadingStatus = exports.useName = exports.useMetadata = exports.useConfigurator = exports.useAttribute = void 0;
17
17
  // Hooks
18
18
  var useAttribute_1 = __importDefault(require("./hooks/useAttribute"));
19
19
  exports.useAttribute = useAttribute_1.default;
@@ -66,6 +66,8 @@ var TilesGroup_1 = __importDefault(require("./components/TilesGroup"));
66
66
  exports.TilesGroup = TilesGroup_1.default;
67
67
  var Upload_1 = __importDefault(require("./components/Upload"));
68
68
  exports.Upload = Upload_1.default;
69
+ var Switch_1 = __importDefault(require("./components/Switch"));
70
+ exports.Switch = Switch_1.default;
69
71
  // Display
70
72
  var ProductName_1 = __importDefault(require("./components/ProductName"));
71
73
  exports.ProductName = ProductName_1.default;
@@ -190,6 +190,7 @@ var initPlayer = function (config) { return function (dispatch) { return __await
190
190
  window.threekit = {
191
191
  player: player,
192
192
  configurator: configurator,
193
+ services: api_1.default,
193
194
  treble: new Treble_1.default({
194
195
  player: player,
195
196
  orgId: orgId,
@@ -1,9 +1,10 @@
1
1
  /// <reference types="webpack-env" />
2
+ import threekitAPI from './api';
2
3
  import Treble from './Treble';
3
4
  declare type SCENE_PHASES = 'LOADED' | 'PRELOADED' | 'RENDERED';
4
5
  declare type PRIVATE_APIS = 'scene' | 'player';
5
6
  export declare type DISPLAY_OPTIONS = 'webgl' | 'image';
6
- export declare type IAttributeTypes = 'String' | 'Asset' | 'Color' | 'Number';
7
+ export declare type IAttributeTypes = 'String' | 'Asset' | 'Color' | 'Number' | 'Boolean';
7
8
  export declare type AssetType = 'upload' | 'item';
8
9
  export declare type IMetadata = Record<string, string | number | null>;
9
10
  /***************************************************
@@ -53,7 +54,7 @@ export interface IConfigurationColor {
53
54
  g: number;
54
55
  b: number;
55
56
  }
56
- export declare type IConfigurationAttribute = IConfigurationAsset | IConfigurationColor | string | number | undefined;
57
+ export declare type IConfigurationAttribute = IConfigurationAsset | IConfigurationColor | string | number | boolean | undefined;
57
58
  export declare type IConfiguration = Record<string, IConfigurationAttribute>;
58
59
  export declare type ISetConfiguration = Record<string, IConfigurationAttribute>;
59
60
  /***************************************************
@@ -131,12 +132,16 @@ export interface IAttributeNumber extends IAttributeBase<'Number', number> {
131
132
  min?: number;
132
133
  step: number;
133
134
  }
135
+ /****** NUMBER TYPE ATTRIBUTE *******/
136
+ export interface IAttributeBoolean extends IAttributeBase<'Boolean', boolean> {
137
+ defaultValue: boolean;
138
+ }
134
139
  /****** getAttributes() *******/
135
- export declare type IThreekitAttribute = IAttributeAsset | IAttributeColor | IAttributeString | IAttributeNumber;
140
+ export declare type IThreekitAttribute = IAttributeAsset | IAttributeColor | IAttributeString | IAttributeNumber | IAttributeBoolean;
136
141
  /****** getDisplayAttributes() *******/
137
- export declare type IThreekitDisplayAttribute = IDisplayAttributeAsset | IDisplayAttributeString | IAttributeColor | IAttributeNumber;
142
+ export declare type IThreekitDisplayAttribute = IDisplayAttributeAsset | IDisplayAttributeString | IAttributeColor | IAttributeNumber | IAttributeBoolean;
138
143
  /****** Treble Hydrated Values *******/
139
- export declare type IHydratedAttribute = IHydratedAttributeAsset | IHydratedAttributeString | IAttributeColor | IAttributeNumber;
144
+ export declare type IHydratedAttribute = IHydratedAttributeAsset | IHydratedAttributeString | IAttributeColor | IAttributeNumber | IAttributeBoolean;
140
145
  /***************************************************
141
146
  * Camera
142
147
  **************************************************/
@@ -292,6 +297,7 @@ declare global {
292
297
  threekit: {
293
298
  player: IThreekitPlayer;
294
299
  configurator: IThreekitConfigurator;
300
+ services: typeof threekitAPI;
295
301
  treble: Treble;
296
302
  };
297
303
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threekit-tools/treble",
3
- "version": "0.0.61",
3
+ "version": "0.0.64",
4
4
  "author": "Amaan Saeed",
5
5
  "license": "MIT",
6
6
  "files": [