@threekit-tools/treble 0.0.82 → 0.0.85
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/Treble/Treble.d.ts +9 -3
- package/dist/Treble/Treble.js +40 -11
- package/dist/Treble/index.d.ts +2 -2
- package/dist/Treble/index.js +2 -2
- package/dist/Treble/{Snapshots.d.ts → snapshots.d.ts} +4 -9
- package/dist/Treble/snapshots.js +247 -0
- package/dist/Treble/{Wishlist.d.ts → wishlist.d.ts} +2 -6
- package/dist/Treble/wishlist.js +135 -0
- package/dist/api/catalog.js +6 -6
- package/dist/api/configurations.js +3 -3
- package/dist/api/datatables.js +5 -5
- package/dist/api/orders.d.ts +5 -7
- package/dist/api/orders.js +12 -12
- package/dist/api/price.js +2 -2
- package/dist/api/products.js +2 -2
- package/dist/components/Accordion/index.js +1 -6
- package/dist/components/AttributeTitle/index.d.ts +0 -9
- package/dist/components/AttributeTitle/index.js +0 -9
- package/dist/components/AttributeValue/index.d.ts +0 -6
- package/dist/components/AttributeValue/index.js +2 -8
- package/dist/components/Button/index.d.ts +0 -27
- package/dist/components/Button/index.js +0 -27
- package/dist/components/Cards/index.d.ts +2 -55
- package/dist/components/Cards/index.js +3 -60
- package/dist/components/Drawer/index.js +0 -13
- package/dist/components/Dropdown/index.d.ts +2 -59
- package/dist/components/Dropdown/index.js +4 -69
- package/dist/components/FlatForm/index.d.ts +0 -21
- package/dist/components/FlatForm/index.js +5 -24
- package/dist/components/Modal/index.js +0 -13
- package/dist/components/Player/index.d.ts +1 -1
- package/dist/components/PortalToElement/index.js +0 -8
- package/dist/components/ProductDescription/index.d.ts +0 -6
- package/dist/components/ProductDescription/index.js +0 -6
- package/dist/components/ProductName/index.d.ts +0 -9
- package/dist/components/ProductName/index.js +0 -9
- package/dist/components/Share/index.d.ts +2 -12
- package/dist/components/Share/index.js +139 -21
- package/dist/components/Share/share.styles.d.ts +9 -0
- package/dist/components/Share/share.styles.js +23 -0
- package/dist/components/Snapshots/index.d.ts +0 -8
- package/dist/components/Snapshots/index.js +0 -8
- package/dist/components/Strips/index.d.ts +2 -55
- package/dist/components/Strips/index.js +3 -60
- package/dist/components/Swatch/index.d.ts +2 -64
- package/dist/components/Swatch/index.js +3 -69
- package/dist/components/Switch/index.d.ts +2 -34
- package/dist/components/Switch/index.js +2 -38
- package/dist/components/TextInput/index.d.ts +2 -1
- package/dist/components/TextInput/index.js +2 -3
- package/dist/components/Tiles/index.d.ts +2 -29
- package/dist/components/Tiles/index.js +3 -33
- package/dist/components/TilesGroup/index.d.ts +2 -26
- package/dist/components/TilesGroup/index.js +3 -30
- package/dist/components/TotalPrice/index.d.ts +0 -6
- package/dist/components/TotalPrice/index.js +0 -6
- package/dist/components/Upload/index.d.ts +2 -1
- package/dist/components/Upload/index.js +7 -8
- package/dist/components/UploadArea/index.d.ts +2 -1
- package/dist/components/UploadArea/index.js +6 -7
- package/dist/components/Wishlist/index.d.ts +1 -4
- package/dist/components/Wishlist/index.js +2 -5
- package/dist/components/Zoom/index.d.ts +1 -18
- package/dist/components/Zoom/index.js +0 -17
- package/dist/components/formComponents.d.ts +12 -0
- package/dist/components/formComponents.js +5 -7
- package/dist/components/message/index.d.ts +0 -9
- package/dist/components/message/index.js +0 -9
- package/dist/connection.js +2 -2
- package/dist/constants.d.ts +0 -49
- package/dist/constants.js +1 -59
- package/dist/hooks/useAttribute/index.js +6 -6
- package/dist/hooks/useConfigurationLoader/index.js +5 -5
- package/dist/hooks/useNestedConfigurator/index.js +2 -2
- package/dist/hooks/useShare/index.js +3 -3
- package/dist/hooks/useSingleAnimation/index.js +20 -25
- package/dist/http/datatables.js +0 -1
- package/dist/http/orders.d.ts +6 -8
- package/dist/icons/index.d.ts +0 -41
- package/dist/icons/index.js +0 -42
- package/dist/index.d.ts +42 -3
- package/dist/index.js +84 -30
- package/dist/store/attributes.d.ts +0 -12
- package/dist/store/attributes.js +2 -15
- package/dist/store/price.d.ts +0 -12
- package/dist/store/price.js +2 -16
- package/dist/store/product.d.ts +2 -17
- package/dist/store/product.js +26 -38
- package/dist/store/translations.d.ts +0 -12
- package/dist/store/translations.js +2 -12
- package/dist/store/treble.d.ts +0 -15
- package/dist/store/treble.js +31 -66
- package/dist/store/wishlist.d.ts +0 -12
- package/dist/store/wishlist.js +4 -17
- package/dist/types.d.ts +71 -58
- package/dist/types.js +54 -0
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +8 -16
- package/package.json +18 -4
- package/dist/Treble/Snapshots.js +0 -251
- package/dist/Treble/Wishlist.js +0 -136
|
@@ -34,7 +34,7 @@ var FormComponentDescription_1 = __importDefault(require("../FormComponentDescri
|
|
|
34
34
|
var dropdown_styles_1 = require("./dropdown.styles");
|
|
35
35
|
var CaretDown_1 = __importDefault(require("../../icons/CaretDown"));
|
|
36
36
|
var utils_1 = require("../../utils");
|
|
37
|
-
var
|
|
37
|
+
var types_1 = require("../../types");
|
|
38
38
|
var formInputContainer_1 = __importDefault(require("../containers/formInputContainer"));
|
|
39
39
|
var Thumbnail = function (props) {
|
|
40
40
|
var imageUrl = props.imageUrl, color = props.color, name = props.name, className = props.className;
|
|
@@ -82,11 +82,7 @@ var Dropdown = function (props) {
|
|
|
82
82
|
return (react_1.default.createElement("div", { className: cls },
|
|
83
83
|
react_1.default.createElement(FormComponentTitle_1.default, { title: title, className: cls }),
|
|
84
84
|
react_1.default.createElement(FormComponentDescription_1.default, { description: description, className: cls }),
|
|
85
|
-
react_1.default.createElement(dropdown_styles_1.DropdownWrapper
|
|
86
|
-
// active={!hide}
|
|
87
|
-
, {
|
|
88
|
-
// active={!hide}
|
|
89
|
-
ref: ref, className: "".concat(cls, " dropdown") },
|
|
85
|
+
react_1.default.createElement(dropdown_styles_1.DropdownWrapper, { ref: ref, className: "".concat(cls, " dropdown") },
|
|
90
86
|
react_1.default.createElement(dropdown_styles_1.DropdownMain, { active: !hide, className: "".concat(cls, " selected"), onClick: function () { return setHide(!hide); }, hasPlaceholder: !value },
|
|
91
87
|
react_1.default.createElement(Thumbnail, { imageUrl: selectedOpt === null || selectedOpt === void 0 ? void 0 : selectedOpt.imageUrl, color: selectedOpt === null || selectedOpt === void 0 ? void 0 : selectedOpt.color, name: selectedOpt === null || selectedOpt === void 0 ? void 0 : selectedOpt.name, className: "".concat(cls, " selected") }),
|
|
92
88
|
react_1.default.createElement("div", null,
|
|
@@ -118,33 +114,11 @@ var Dropdown = function (props) {
|
|
|
118
114
|
};
|
|
119
115
|
exports.Dropdown = Dropdown;
|
|
120
116
|
exports.Dropdown.propTypes = {
|
|
121
|
-
/**
|
|
122
|
-
* Is the attribute name on the initialized asset that we are
|
|
123
|
-
* using this component for. If the attribute prop is used,
|
|
124
|
-
* the component will ignore the props for: `value`, `options`, `onClick`.
|
|
125
|
-
*/
|
|
126
117
|
attribute: prop_types_1.default.string,
|
|
127
|
-
/**
|
|
128
|
-
* Used to add a title to the input
|
|
129
|
-
*/
|
|
130
118
|
title: prop_types_1.default.string,
|
|
131
|
-
/**
|
|
132
|
-
* Used to provide a custom description for the input component
|
|
133
|
-
*/
|
|
134
119
|
description: prop_types_1.default.string,
|
|
135
|
-
/**
|
|
136
|
-
* Selected value from the option set. Should match the 'value' property
|
|
137
|
-
* of one of the items in the options array.
|
|
138
|
-
*/
|
|
139
120
|
value: prop_types_1.default.string,
|
|
140
|
-
/**
|
|
141
|
-
* Handles the user seletion by passing the value of the selected
|
|
142
|
-
* option as the argument into the onClick callback.
|
|
143
|
-
*/
|
|
144
121
|
onClick: prop_types_1.default.func,
|
|
145
|
-
/**
|
|
146
|
-
* The options set to be displayed for the user
|
|
147
|
-
*/
|
|
148
122
|
options: prop_types_1.default.arrayOf(prop_types_1.default.shape({
|
|
149
123
|
name: prop_types_1.default.string,
|
|
150
124
|
description: prop_types_1.default.string,
|
|
@@ -154,64 +128,25 @@ exports.Dropdown.propTypes = {
|
|
|
154
128
|
color: prop_types_1.default.string,
|
|
155
129
|
disabled: prop_types_1.default.bool,
|
|
156
130
|
})),
|
|
157
|
-
/**
|
|
158
|
-
* Used to add a custom class name to each of the components html elements
|
|
159
|
-
*/
|
|
160
131
|
className: prop_types_1.default.string,
|
|
161
|
-
/**
|
|
162
|
-
* By default the thumbnail (image/color value) is soruced from the `_thumbnail`
|
|
163
|
-
* metadata key in the option's Catalog Item. This metadata key can be overwritten
|
|
164
|
-
* by passing in the prefered key value to the **thumbnailFromMetadata** prop.
|
|
165
|
-
*/
|
|
166
132
|
metadataKeyThumbnail: prop_types_1.default.string,
|
|
167
|
-
/**
|
|
168
|
-
* By default the description is soruced from the `_description` metadata
|
|
169
|
-
* key in the option's Catalog Item. This metadata key can be overwritten
|
|
170
|
-
* by passing in the prefered key value to the **metadataKeyDescription**
|
|
171
|
-
* prop.
|
|
172
|
-
*/
|
|
173
133
|
metadataKeyDescription: prop_types_1.default.string,
|
|
174
|
-
/**
|
|
175
|
-
* By default the price of an item is soruced from the pricebook entry for
|
|
176
|
-
* the option's Catalog Item. The price can alternatively be soruced from
|
|
177
|
-
* the option's Catalog Item metadata, by specifying the key under which the
|
|
178
|
-
* price can be found as the **metadataKeyPrice** prop.
|
|
179
|
-
*/
|
|
180
134
|
metadataKeyPrice: prop_types_1.default.string,
|
|
181
|
-
/**
|
|
182
|
-
* A boolean to set whether or all the Cards should display thumbnails
|
|
183
|
-
* for the options.
|
|
184
|
-
*/
|
|
185
135
|
showThumbnail: prop_types_1.default.bool,
|
|
186
|
-
/**
|
|
187
|
-
* A boolean to set whether or all the Cards should display the description
|
|
188
|
-
* for the options.
|
|
189
|
-
*/
|
|
190
136
|
showDescription: prop_types_1.default.bool,
|
|
191
|
-
/**
|
|
192
|
-
* A boolean to set whether or all the Cards should display the price
|
|
193
|
-
* for the options.
|
|
194
|
-
*/
|
|
195
137
|
showPrice: prop_types_1.default.bool,
|
|
196
|
-
/**
|
|
197
|
-
* The maximum height the dropdown area should extend to before scrolling
|
|
198
|
-
* is introduced
|
|
199
|
-
*/
|
|
200
138
|
dropdownMaxHeight: prop_types_1.default.string,
|
|
201
139
|
};
|
|
202
140
|
exports.Dropdown.defaultProps = {
|
|
203
141
|
description: undefined,
|
|
204
142
|
className: undefined,
|
|
205
|
-
// Default use
|
|
206
143
|
attribute: undefined,
|
|
207
|
-
// Default user overrides
|
|
208
144
|
metadataKeyThumbnail: '_thumbnail',
|
|
209
145
|
metadataKeyDescription: undefined,
|
|
210
146
|
metadataKeyPrice: undefined,
|
|
211
147
|
showThumbnail: true,
|
|
212
148
|
showPrice: true,
|
|
213
149
|
showDescription: true,
|
|
214
|
-
// Custom use
|
|
215
150
|
value: undefined,
|
|
216
151
|
options: undefined,
|
|
217
152
|
onClick: undefined,
|
|
@@ -219,7 +154,7 @@ exports.Dropdown.defaultProps = {
|
|
|
219
154
|
};
|
|
220
155
|
exports.Dropdown.componentName = 'dropdown';
|
|
221
156
|
exports.Dropdown.compatibleAttributes = new Set([
|
|
222
|
-
|
|
223
|
-
|
|
157
|
+
types_1.ATTRIBUTE_TYPES.ASSET,
|
|
158
|
+
types_1.ATTRIBUTE_TYPES.STRING,
|
|
224
159
|
]);
|
|
225
160
|
exports.default = (0, formInputContainer_1.default)(exports.Dropdown);
|
|
@@ -12,36 +12,15 @@ interface FlatFormProps {
|
|
|
12
12
|
export declare const FlatForm: {
|
|
13
13
|
(props: FlatFormProps): JSX.Element | null;
|
|
14
14
|
propTypes: {
|
|
15
|
-
/**
|
|
16
|
-
* Used to add a title to Form (defaults to the intialized Catalog Item's name)
|
|
17
|
-
*/
|
|
18
15
|
title: PropTypes.Requireable<string>;
|
|
19
|
-
/**
|
|
20
|
-
* Alignement for the title. Options include `left`, `center` or `right`
|
|
21
|
-
*/
|
|
22
16
|
alignTitle: PropTypes.Requireable<string>;
|
|
23
|
-
/**
|
|
24
|
-
* Used to add a description to Form
|
|
25
|
-
*/
|
|
26
17
|
description: PropTypes.Requireable<string>;
|
|
27
|
-
/**
|
|
28
|
-
* The attributes prop allows us to specify which components to use for
|
|
29
|
-
* our attributes and what props we want to pass into their components.
|
|
30
|
-
*
|
|
31
|
-
* The attributes prop takes and object with the keys matching the name
|
|
32
|
-
* of the attribute you wish to target and value as an object includeing
|
|
33
|
-
* the component to use and props to pass in.
|
|
34
|
-
*/
|
|
35
18
|
attributes: PropTypes.Requireable<{
|
|
36
19
|
[x: string]: PropTypes.InferProps<{
|
|
37
20
|
component: PropTypes.Requireable<string>;
|
|
38
21
|
props: PropTypes.Requireable<object>;
|
|
39
22
|
}> | null | undefined;
|
|
40
23
|
}>;
|
|
41
|
-
/**
|
|
42
|
-
*
|
|
43
|
-
* Used to add a custom class name to each of the components html elements
|
|
44
|
-
*/
|
|
45
24
|
className: PropTypes.Requireable<string>;
|
|
46
25
|
};
|
|
47
26
|
defaultProps: {
|
|
@@ -46,7 +46,7 @@ var ProductDescription_1 = __importDefault(require("../ProductDescription"));
|
|
|
46
46
|
var formComponents_1 = __importStar(require("../formComponents"));
|
|
47
47
|
var utils_1 = require("../../utils");
|
|
48
48
|
var useConfigurator_1 = __importDefault(require("../../hooks/useConfigurator"));
|
|
49
|
-
var
|
|
49
|
+
var types_1 = require("../../types");
|
|
50
50
|
var FlatForm = function (props) {
|
|
51
51
|
var _a = Object.assign({
|
|
52
52
|
alignTitle: 'center',
|
|
@@ -68,10 +68,12 @@ var FlatForm = function (props) {
|
|
|
68
68
|
var Component;
|
|
69
69
|
var props = ((_b = (_a = (attributes || {})) === null || _a === void 0 ? void 0 : _a[attr.name]) === null || _b === void 0 ? void 0 : _b.props) || {};
|
|
70
70
|
var type = attr.type;
|
|
71
|
-
if (attr.type ===
|
|
71
|
+
if (attr.type === types_1.ATTRIBUTE_TYPES.ASSET &&
|
|
72
|
+
attr.assetType === types_1.ASSET_TYPES.UPLOAD) {
|
|
72
73
|
type = attr.assetType;
|
|
73
74
|
}
|
|
74
|
-
else if (attr.type ===
|
|
75
|
+
else if (attr.type === types_1.ATTRIBUTE_TYPES.STRING &&
|
|
76
|
+
attr.values.length === 0) {
|
|
75
77
|
type = formComponents_1.FORM_COMPONENT_TYPES.stringInput;
|
|
76
78
|
}
|
|
77
79
|
if ((_d = (_c = (attributes || {})) === null || _c === void 0 ? void 0 : _c[attr.name]) === null || _d === void 0 ? void 0 : _d.component) {
|
|
@@ -93,34 +95,13 @@ var FlatForm = function (props) {
|
|
|
93
95
|
};
|
|
94
96
|
exports.FlatForm = FlatForm;
|
|
95
97
|
exports.FlatForm.propTypes = {
|
|
96
|
-
/**
|
|
97
|
-
* Used to add a title to Form (defaults to the intialized Catalog Item's name)
|
|
98
|
-
*/
|
|
99
98
|
title: prop_types_1.default.string,
|
|
100
|
-
/**
|
|
101
|
-
* Alignement for the title. Options include `left`, `center` or `right`
|
|
102
|
-
*/
|
|
103
99
|
alignTitle: prop_types_1.default.string,
|
|
104
|
-
/**
|
|
105
|
-
* Used to add a description to Form
|
|
106
|
-
*/
|
|
107
100
|
description: prop_types_1.default.string,
|
|
108
|
-
/**
|
|
109
|
-
* The attributes prop allows us to specify which components to use for
|
|
110
|
-
* our attributes and what props we want to pass into their components.
|
|
111
|
-
*
|
|
112
|
-
* The attributes prop takes and object with the keys matching the name
|
|
113
|
-
* of the attribute you wish to target and value as an object includeing
|
|
114
|
-
* the component to use and props to pass in.
|
|
115
|
-
*/
|
|
116
101
|
attributes: prop_types_1.default.objectOf(prop_types_1.default.shape({
|
|
117
102
|
component: prop_types_1.default.string,
|
|
118
103
|
props: prop_types_1.default.object,
|
|
119
104
|
})),
|
|
120
|
-
/**
|
|
121
|
-
*
|
|
122
|
-
* Used to add a custom class name to each of the components html elements
|
|
123
|
-
*/
|
|
124
105
|
className: prop_types_1.default.string,
|
|
125
106
|
};
|
|
126
107
|
exports.FlatForm.defaultProps = {
|
|
@@ -39,22 +39,9 @@ var Modal = function (props) {
|
|
|
39
39
|
};
|
|
40
40
|
exports.Modal = Modal;
|
|
41
41
|
exports.ModalComponent.propTypes = {
|
|
42
|
-
/**
|
|
43
|
-
* The title to be shown in the Modal header
|
|
44
|
-
*/
|
|
45
42
|
title: prop_types_1.default.string,
|
|
46
|
-
/**
|
|
47
|
-
* Callback function to close the modal. Can be used with custom UI
|
|
48
|
-
* components in the Modal
|
|
49
|
-
*/
|
|
50
43
|
handleClose: prop_types_1.default.func,
|
|
51
|
-
/**
|
|
52
|
-
* Whether or not to render the default Modal header
|
|
53
|
-
*/
|
|
54
44
|
showHeader: prop_types_1.default.bool,
|
|
55
|
-
/**
|
|
56
|
-
* Used to add a custom class name to each of the components html elements
|
|
57
|
-
*/
|
|
58
45
|
className: prop_types_1.default.string,
|
|
59
46
|
};
|
|
60
47
|
exports.ModalComponent.defaultProps = {
|
|
@@ -24,15 +24,7 @@ var PortalToElement = function (props) {
|
|
|
24
24
|
};
|
|
25
25
|
exports.PortalToElement = PortalToElement;
|
|
26
26
|
exports.PortalToElement.propTypes = {
|
|
27
|
-
/**
|
|
28
|
-
* The id of the HTML element you want the content to be rendered in
|
|
29
|
-
*/
|
|
30
27
|
to: prop_types_1.default.string,
|
|
31
|
-
/**
|
|
32
|
-
* Defines the behaviour if the HTML element is not found. If strict is
|
|
33
|
-
* set to `true` the content will not render, if set to `false` the
|
|
34
|
-
* content will render out in its defualt flow.
|
|
35
|
-
*/
|
|
36
28
|
strict: prop_types_1.default.bool,
|
|
37
29
|
};
|
|
38
30
|
exports.PortalToElement.defaultProps = {};
|
|
@@ -7,13 +7,7 @@ interface IProductDescription {
|
|
|
7
7
|
export declare const ProductDescriptionComponent: {
|
|
8
8
|
(props: IProductDescription): JSX.Element;
|
|
9
9
|
propTypes: {
|
|
10
|
-
/**
|
|
11
|
-
* The description displayed to the user
|
|
12
|
-
*/
|
|
13
10
|
description: PropTypes.Requireable<string>;
|
|
14
|
-
/**
|
|
15
|
-
* Custom classNames applied to the HTML Element to apply custom CSS styling.
|
|
16
|
-
*/
|
|
17
11
|
className: PropTypes.Requireable<string>;
|
|
18
12
|
};
|
|
19
13
|
defaultProps: {
|
|
@@ -28,13 +28,7 @@ var ProductDescription = function (props) {
|
|
|
28
28
|
return (react_1.default.createElement(exports.ProductDescriptionComponent, { className: className, description: ((_a = metadata === null || metadata === void 0 ? void 0 : metadata._description) === null || _a === void 0 ? void 0 : _a.toString()) || description }));
|
|
29
29
|
};
|
|
30
30
|
exports.ProductDescriptionComponent.propTypes = {
|
|
31
|
-
/**
|
|
32
|
-
* The description displayed to the user
|
|
33
|
-
*/
|
|
34
31
|
description: prop_types_1.default.string,
|
|
35
|
-
/**
|
|
36
|
-
* Custom classNames applied to the HTML Element to apply custom CSS styling.
|
|
37
|
-
*/
|
|
38
32
|
className: prop_types_1.default.string,
|
|
39
33
|
};
|
|
40
34
|
exports.ProductDescriptionComponent.defaultProps = {
|
|
@@ -8,17 +8,8 @@ interface ITitle {
|
|
|
8
8
|
export declare const ProductNameComponent: {
|
|
9
9
|
(props: ITitle): JSX.Element;
|
|
10
10
|
propTypes: {
|
|
11
|
-
/**
|
|
12
|
-
* The title displayed to the user
|
|
13
|
-
*/
|
|
14
11
|
title: PropTypes.Requireable<string>;
|
|
15
|
-
/**
|
|
16
|
-
* Custom classNames applied to the HTML Element to apply custom CSS styling.
|
|
17
|
-
*/
|
|
18
12
|
className: PropTypes.Requireable<string>;
|
|
19
|
-
/**
|
|
20
|
-
* The CSS Text alignment property. Options: 'left' | 'center' | 'right'
|
|
21
|
-
*/
|
|
22
13
|
align: PropTypes.Requireable<string>;
|
|
23
14
|
};
|
|
24
15
|
defaultProps: {
|
|
@@ -24,17 +24,8 @@ var ProductName = function (props) {
|
|
|
24
24
|
};
|
|
25
25
|
exports.ProductName = ProductName;
|
|
26
26
|
exports.ProductNameComponent.propTypes = {
|
|
27
|
-
/**
|
|
28
|
-
* The title displayed to the user
|
|
29
|
-
*/
|
|
30
27
|
title: prop_types_1.default.string,
|
|
31
|
-
/**
|
|
32
|
-
* Custom classNames applied to the HTML Element to apply custom CSS styling.
|
|
33
|
-
*/
|
|
34
28
|
className: prop_types_1.default.string,
|
|
35
|
-
/**
|
|
36
|
-
* The CSS Text alignment property. Options: 'left' | 'center' | 'right'
|
|
37
|
-
*/
|
|
38
29
|
align: prop_types_1.default.string,
|
|
39
30
|
};
|
|
40
31
|
exports.ProductNameComponent.defaultProps = {
|
|
@@ -1,30 +1,20 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { BUTTON_SHAPES, BUTTON_TYPES } from '../Button';
|
|
4
|
+
import type { Positions } from './share.styles';
|
|
4
5
|
interface ShareProps {
|
|
5
6
|
shape?: BUTTON_SHAPES;
|
|
6
7
|
type?: BUTTON_TYPES;
|
|
7
8
|
className?: string;
|
|
8
9
|
message?: string;
|
|
10
|
+
position: Positions;
|
|
9
11
|
}
|
|
10
12
|
export declare const Share: {
|
|
11
13
|
(props: ShareProps): JSX.Element | null;
|
|
12
14
|
propTypes: {
|
|
13
15
|
className: PropTypes.Requireable<string>;
|
|
14
|
-
/**
|
|
15
|
-
* The presentational type of the input component. Options
|
|
16
|
-
* include: `hollow`, `standard`, `accent`, `primary`
|
|
17
|
-
*/
|
|
18
16
|
type: PropTypes.Requireable<string>;
|
|
19
|
-
/**
|
|
20
|
-
* Used to set the shape of the Widget button. Options
|
|
21
|
-
* include: `square`, `round`
|
|
22
|
-
*/
|
|
23
17
|
shape: PropTypes.Requireable<string>;
|
|
24
|
-
/**
|
|
25
|
-
* Used to set an overwrite of the message presented to the user
|
|
26
|
-
* when the share URL has been successfully copied.
|
|
27
|
-
*/
|
|
28
18
|
message: PropTypes.Requireable<string>;
|
|
29
19
|
};
|
|
30
20
|
defaultProps: {
|
|
@@ -1,45 +1,163 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
+
function step(op) {
|
|
39
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
+
while (_) try {
|
|
41
|
+
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;
|
|
42
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
+
switch (op[0]) {
|
|
44
|
+
case 0: case 1: t = op; break;
|
|
45
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
+
default:
|
|
49
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
+
if (t[2]) _.ops.pop();
|
|
54
|
+
_.trys.pop(); continue;
|
|
55
|
+
}
|
|
56
|
+
op = body.call(thisArg, _);
|
|
57
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
+
}
|
|
60
|
+
};
|
|
2
61
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
62
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
63
|
};
|
|
5
64
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
65
|
exports.Share = void 0;
|
|
7
|
-
var react_1 =
|
|
66
|
+
var react_1 = __importStar(require("react"));
|
|
8
67
|
var prop_types_1 = __importDefault(require("prop-types"));
|
|
9
68
|
var Button_1 = __importDefault(require("../Button"));
|
|
69
|
+
var message_1 = __importDefault(require("../message"));
|
|
10
70
|
var Share_1 = __importDefault(require("../../icons/Share"));
|
|
11
71
|
var useThreekitInitStatus_1 = __importDefault(require("../../hooks/useThreekitInitStatus"));
|
|
12
|
-
var useShare_1 = __importDefault(require("../../hooks/useShare"));
|
|
13
72
|
var utils_1 = require("../../utils");
|
|
73
|
+
var share_styles_1 = require("./share.styles");
|
|
14
74
|
var Share = function (props) {
|
|
15
|
-
var _a = Object.assign({
|
|
75
|
+
var _a = Object.assign({
|
|
76
|
+
type: 'threekit',
|
|
77
|
+
shape: 'round',
|
|
78
|
+
message: 'Link copied!',
|
|
79
|
+
position: 'bottom-right',
|
|
80
|
+
}, props), shape = _a.shape, type = _a.type, className = _a.className, msg = _a.message, position = _a.position;
|
|
16
81
|
var hasLoaded = (0, useThreekitInitStatus_1.default)();
|
|
17
|
-
var
|
|
18
|
-
|
|
82
|
+
var _b = (0, react_1.useState)(false), show = _b[0], setShow = _b[1];
|
|
83
|
+
var _c = (0, react_1.useState)(null), resumeUrl = _c[0], setResumeUrl = _c[1];
|
|
84
|
+
var resumeUrlElRef = (0, react_1.useRef)(null);
|
|
85
|
+
var shareButtonRef = (0, react_1.useRef)(null);
|
|
86
|
+
var shareContentRef = (0, react_1.useRef)(null);
|
|
87
|
+
(0, react_1.useEffect)(function () {
|
|
88
|
+
var handleClickOutside = function (e) {
|
|
89
|
+
var _a, _b;
|
|
90
|
+
if (!e)
|
|
91
|
+
return;
|
|
92
|
+
if (!((_a = shareButtonRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target)) &&
|
|
93
|
+
!((_b = shareContentRef.current) === null || _b === void 0 ? void 0 : _b.contains(e.target))) {
|
|
94
|
+
setShow(false);
|
|
95
|
+
e.stopPropagation();
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
99
|
+
return function () {
|
|
100
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
101
|
+
};
|
|
102
|
+
}, [show, shareButtonRef, shareContentRef]);
|
|
103
|
+
if (!hasLoaded)
|
|
19
104
|
return null;
|
|
20
105
|
var cls = (0, utils_1.generateWidgetClassName)('share', className);
|
|
21
|
-
var handleClick = function () {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
106
|
+
var handleClick = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
107
|
+
var configuration, e_1;
|
|
108
|
+
return __generator(this, function (_a) {
|
|
109
|
+
switch (_a.label) {
|
|
110
|
+
case 0:
|
|
111
|
+
if (show) {
|
|
112
|
+
setResumeUrl(null);
|
|
113
|
+
setShow(!show);
|
|
114
|
+
return [2];
|
|
115
|
+
}
|
|
116
|
+
return [4, window.threekit.treble.saveConfiguration()];
|
|
117
|
+
case 1:
|
|
118
|
+
configuration = _a.sent();
|
|
119
|
+
_a.label = 2;
|
|
120
|
+
case 2:
|
|
121
|
+
_a.trys.push([2, 4, , 5]);
|
|
122
|
+
return [4, navigator.clipboard.writeText(configuration.resumableUrl)];
|
|
123
|
+
case 3:
|
|
124
|
+
_a.sent();
|
|
125
|
+
if (msg === null || msg === void 0 ? void 0 : msg.length)
|
|
126
|
+
message_1.default.info(msg);
|
|
127
|
+
return [3, 5];
|
|
128
|
+
case 4:
|
|
129
|
+
e_1 = _a.sent();
|
|
130
|
+
setResumeUrl(configuration.resumableUrl);
|
|
131
|
+
setShow(!show);
|
|
132
|
+
return [3, 5];
|
|
133
|
+
case 5: return [2];
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}); };
|
|
137
|
+
var handleClickCopy = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
138
|
+
var _a;
|
|
139
|
+
return __generator(this, function (_b) {
|
|
140
|
+
if (!((_a = resumeUrlElRef.current) === null || _a === void 0 ? void 0 : _a.value))
|
|
141
|
+
return [2];
|
|
142
|
+
navigator.clipboard.writeText(resumeUrlElRef.current.value);
|
|
143
|
+
if (msg === null || msg === void 0 ? void 0 : msg.length)
|
|
144
|
+
message_1.default.info(msg);
|
|
145
|
+
return [2];
|
|
146
|
+
});
|
|
147
|
+
}); };
|
|
148
|
+
return (react_1.default.createElement(share_styles_1.Wrapper, { ref: shareButtonRef },
|
|
149
|
+
react_1.default.createElement(Button_1.default, { className: cls, shape: shape, type: type, icon: Share_1.default.iconName, onClick: handleClick }),
|
|
150
|
+
show ? (react_1.default.createElement(share_styles_1.ShareWrapper, { position: position },
|
|
151
|
+
react_1.default.createElement(share_styles_1.Content, { ref: shareContentRef },
|
|
152
|
+
react_1.default.createElement("input", { type: "text", ref: resumeUrlElRef, value: resumeUrl || '', onChange: function () { } }),
|
|
153
|
+
react_1.default.createElement("button", { type: "button", onClick: handleClickCopy }, "copy link")),
|
|
154
|
+
react_1.default.createElement(share_styles_1.Caret, null))) : null));
|
|
25
155
|
};
|
|
26
156
|
exports.Share = Share;
|
|
27
157
|
exports.Share.propTypes = {
|
|
28
158
|
className: prop_types_1.default.string,
|
|
29
|
-
/**
|
|
30
|
-
* The presentational type of the input component. Options
|
|
31
|
-
* include: `hollow`, `standard`, `accent`, `primary`
|
|
32
|
-
*/
|
|
33
159
|
type: prop_types_1.default.string,
|
|
34
|
-
/**
|
|
35
|
-
* Used to set the shape of the Widget button. Options
|
|
36
|
-
* include: `square`, `round`
|
|
37
|
-
*/
|
|
38
160
|
shape: prop_types_1.default.string,
|
|
39
|
-
/**
|
|
40
|
-
* Used to set an overwrite of the message presented to the user
|
|
41
|
-
* when the share URL has been successfully copied.
|
|
42
|
-
*/
|
|
43
161
|
message: prop_types_1.default.string,
|
|
44
162
|
};
|
|
45
163
|
exports.Share.defaultProps = {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare type Positions = 'top-right' | 'bottom-right' | 'bottom-left' | 'top-left';
|
|
2
|
+
interface PositionProps {
|
|
3
|
+
position: Positions;
|
|
4
|
+
}
|
|
5
|
+
export declare const Wrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
6
|
+
export declare const Content: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
7
|
+
export declare const Caret: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
8
|
+
export declare const ShareWrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, PositionProps, never>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
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.ShareWrapper = exports.Caret = exports.Content = exports.Wrapper = void 0;
|
|
11
|
+
var styled_components_1 = __importDefault(require("styled-components"));
|
|
12
|
+
exports.Wrapper = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n height: 40px;\n width: 40px;\n position: relative;\n"], ["\n height: 40px;\n width: 40px;\n position: relative;\n"])));
|
|
13
|
+
var ShareWrapperStyles = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n position: relative;\n"], ["\n position: relative;\n"])));
|
|
14
|
+
exports.Content = styled_components_1.default.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n padding: 24px 18px;\n border-radius: 4px;\n background: rgba(0, 0, 0, 0.9);\n color: white;\n font-size: 16px;\n width: 290px;\n\n display: flex;\n flex-direction: row;\n justify-content: center;\n\n input {\n background: #555555;\n color: #ffffff;\n border: none;\n outline: none;\n padding: 9px;\n border-radius: 4px;\n font-size: 13px;\n text-overflow: ellipsis;\n width: 180px;\n }\n\n button {\n color: #2a94f5;\n font-size: 13px;\n background: none;\n outline: none;\n border: none;\n cursor: pointer;\n }\n"], ["\n padding: 24px 18px;\n border-radius: 4px;\n background: rgba(0, 0, 0, 0.9);\n color: white;\n font-size: 16px;\n width: 290px;\n\n display: flex;\n flex-direction: row;\n justify-content: center;\n\n input {\n background: #555555;\n color: #ffffff;\n border: none;\n outline: none;\n padding: 9px;\n border-radius: 4px;\n font-size: 13px;\n text-overflow: ellipsis;\n width: 180px;\n }\n\n button {\n color: #2a94f5;\n font-size: 13px;\n background: none;\n outline: none;\n border: none;\n cursor: pointer;\n }\n"])));
|
|
15
|
+
exports.Caret = styled_components_1.default.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n width: 0;\n height: 0;\n border-left: 10px solid transparent;\n border-right: 10px solid transparent;\n border-top: 8px solid rgba(0, 0, 0, 0.9);\n\n position: absolute;\n"], ["\n width: 0;\n height: 0;\n border-left: 10px solid transparent;\n border-right: 10px solid transparent;\n border-top: 8px solid rgba(0, 0, 0, 0.9);\n\n position: absolute;\n"])));
|
|
16
|
+
exports.ShareWrapper = (0, styled_components_1.default)(ShareWrapperStyles)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n top: ", ";\n left: ", ";\n transform: ", ";\n\n ", " {\n left: ", ";\n top: ", ";\n\n transform: ", ";\n }\n"], ["\n top: ", ";\n left: ", ";\n transform: ", ";\n\n ", " {\n left: ", ";\n top: ", ";\n\n transform: ", ";\n }\n"])), function (props) { return (props.position.includes('top') ? '14px' : '-100%'); }, function (props) { return (props.position.includes('right') ? '-250px' : 'auto'); }, function (props) {
|
|
17
|
+
return props.position.includes('top')
|
|
18
|
+
? ''
|
|
19
|
+
: 'translateY(calc(0px - 14px - 100%))';
|
|
20
|
+
}, exports.Caret, function (props) { return (props.position.includes('right') ? '260px' : '10px'); }, function (props) { return (props.position.includes('top') ? '0' : 'auto'); }, function (props) {
|
|
21
|
+
return props.position.includes('top') ? 'translateY(-100%) scaleY(-1)' : '';
|
|
22
|
+
});
|
|
23
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
|
|
@@ -13,15 +13,7 @@ export declare const Snapshots: {
|
|
|
13
13
|
(props: SnapshotProps): JSX.Element | null;
|
|
14
14
|
propTypes: {
|
|
15
15
|
className: PropTypes.Requireable<string>;
|
|
16
|
-
/**
|
|
17
|
-
* The presentational type of the input component. Options
|
|
18
|
-
* include: `hollow`, `standard`, `accent`, `primary`
|
|
19
|
-
*/
|
|
20
16
|
type: PropTypes.Requireable<string>;
|
|
21
|
-
/**
|
|
22
|
-
* Used to set the shape of the Widget button. Options
|
|
23
|
-
* include: `square`, `round`
|
|
24
|
-
*/
|
|
25
17
|
shape: PropTypes.Requireable<string>;
|
|
26
18
|
};
|
|
27
19
|
defaultProps: {
|
|
@@ -24,15 +24,7 @@ var Snapshots = function (props) {
|
|
|
24
24
|
exports.Snapshots = Snapshots;
|
|
25
25
|
exports.Snapshots.propTypes = {
|
|
26
26
|
className: prop_types_1.default.string,
|
|
27
|
-
/**
|
|
28
|
-
* The presentational type of the input component. Options
|
|
29
|
-
* include: `hollow`, `standard`, `accent`, `primary`
|
|
30
|
-
*/
|
|
31
27
|
type: prop_types_1.default.string,
|
|
32
|
-
/**
|
|
33
|
-
* Used to set the shape of the Widget button. Options
|
|
34
|
-
* include: `square`, `round`
|
|
35
|
-
*/
|
|
36
28
|
shape: prop_types_1.default.string,
|
|
37
29
|
};
|
|
38
30
|
exports.Snapshots.defaultProps = {
|