@supernova-studio/supernova-sdk-beta 1.6.14 → 1.6.15
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/build/sdk-typescript/src/core/areas/SDKAreaBulkOperations.d.ts +1 -1
- package/build/sdk-typescript/src/core/areas/SDKAreaComponents.d.ts +114 -2
- package/build/sdk-typescript/src/core/areas/SDKAreaTokenValues.d.ts +3 -7
- package/build/sdk-typescript/src/core/data/SDKDataCore.d.ts +41 -2
- package/build/sdk-typescript/src/core/data/requests/SDKDataCoreWriteRequests.d.ts +18 -2
- package/build/sdk-typescript/src/exports.d.ts +4 -2
- package/build/sdk-typescript/src/model/components/SDKComponent.d.ts +3 -1
- package/build/sdk-typescript/src/model/elements/SDKElementPropertyOption.d.ts +5 -0
- package/build/sdk-typescript/src/model/enums/SDKTokenType.d.ts +2 -2
- package/build/sdk-typescript/src/model/groups/SDKComponentGroup.d.ts +1 -0
- package/build/sdk-typescript/src/model/themes/SDKTokenTheme.d.ts +3 -3
- package/build/sdk-typescript/src/model/themes/SDKTokenThemeOverride.d.ts +3 -3
- package/build/sdk-typescript/src/model/tokens/SDKColorToken.d.ts +3 -0
- package/build/sdk-typescript/src/model/tokens/SDKDimensionToken.d.ts +8 -1
- package/build/sdk-typescript/src/tests/validators.d.ts +1 -0
- package/build/sdk-typescript/src/utils/ComponentUtils.d.ts +12 -0
- package/build/sdk-typescript/src/utils/TokenUtils.d.ts +137 -2
- package/build/supernova-sdk-typescript.js +1762 -731
- package/build/supernova-sdk-typescript.js.map +1 -1
- package/package.json +1 -1
|
@@ -35197,6 +35197,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
35197
35197
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
35198
35198
|
exports.AreaComponents = void 0;
|
|
35199
35199
|
const SDKElementProperty_1 = __webpack_require__(/*! ../../model/elements/SDKElementProperty */ "./src/model/elements/SDKElementProperty.ts");
|
|
35200
|
+
const ComponentUtils_1 = __webpack_require__(/*! ../../utils/ComponentUtils */ "./src/utils/ComponentUtils.ts");
|
|
35200
35201
|
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
|
|
35201
35202
|
// MARK: - Users Area
|
|
35202
35203
|
class AreaComponents {
|
|
@@ -35243,7 +35244,7 @@ class AreaComponents {
|
|
|
35243
35244
|
return this.dataCore.designComponentGroups(from.designSystemId, from.versionId);
|
|
35244
35245
|
});
|
|
35245
35246
|
}
|
|
35246
|
-
/** Retrieves all remote properties for
|
|
35247
|
+
/** Retrieves all remote properties for components
|
|
35247
35248
|
* @param from - Remote version to fetch from
|
|
35248
35249
|
* @returns All component properties in the specified version
|
|
35249
35250
|
*/
|
|
@@ -35252,6 +35253,15 @@ class AreaComponents {
|
|
|
35252
35253
|
return this.dataCore.elementPropertyDefinitions(from.designSystemId, from.versionId, SDKElementProperty_1.ElementPropertyTargetElementType.component);
|
|
35253
35254
|
});
|
|
35254
35255
|
}
|
|
35256
|
+
/** Retrieves all remote property definitions for components
|
|
35257
|
+
* @param from - Remote version to fetch from
|
|
35258
|
+
* @returns All property definitions in the specified version
|
|
35259
|
+
*/
|
|
35260
|
+
getComponentPropertyValues(from) {
|
|
35261
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35262
|
+
return this.dataCore.elementPropertyValues(from.designSystemId, from.versionId);
|
|
35263
|
+
});
|
|
35264
|
+
}
|
|
35255
35265
|
/** Retrieves all remote property views for components
|
|
35256
35266
|
* @param from - Remote version to fetch from
|
|
35257
35267
|
* @returns All component views in the specified version
|
|
@@ -35261,6 +35271,166 @@ class AreaComponents {
|
|
|
35261
35271
|
return this.dataCore.elementViews(from.designSystemId, from.versionId, SDKElementProperty_1.ElementPropertyTargetElementType.component);
|
|
35262
35272
|
});
|
|
35263
35273
|
}
|
|
35274
|
+
// --- --- --- --- --- --- --- --- --- ---
|
|
35275
|
+
// MARK: - Create/Update
|
|
35276
|
+
/** Creates remote component. This method can only be used once per component and will assign persistent id to the component. Calling this version on component that already has id assigned will result in error
|
|
35277
|
+
* @param to - Remote version to write to
|
|
35278
|
+
* @param component - Component to create
|
|
35279
|
+
* @param parentId - Id of the group to add the component to. This is id of the group, not the versioned id
|
|
35280
|
+
* @returns New remote component ids
|
|
35281
|
+
*/
|
|
35282
|
+
createComponent(to, component, parentId) {
|
|
35283
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35284
|
+
return this.dataCore.createComponent(to.designSystemId, to.versionId, component, parentId);
|
|
35285
|
+
});
|
|
35286
|
+
}
|
|
35287
|
+
/** Creates local component. This component doesn't have id associated with it on remote, and must be created once with `createComponent` to be stored in design system
|
|
35288
|
+
* @returns New component filled with default values not associated with remote (yet)
|
|
35289
|
+
*/
|
|
35290
|
+
createLocalComponent(versionId, brandId) {
|
|
35291
|
+
return ComponentUtils_1.ComponentUtils.createDefaultComponent(versionId, brandId);
|
|
35292
|
+
}
|
|
35293
|
+
/** Creates remote component group. This method can only be used once per group and will assign persistent id to the group. Calling this version on group that already has id assigned will result in error
|
|
35294
|
+
* @param to - Remote version to write to
|
|
35295
|
+
* @param group - Group to create
|
|
35296
|
+
* @param parentId - Id of the group to add the group to. This is id of the group, not the versioned id
|
|
35297
|
+
* @returns New remote component group ids
|
|
35298
|
+
*/
|
|
35299
|
+
createComponentGroup(to, group, parentId) {
|
|
35300
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35301
|
+
return this.dataCore.createComponentGroup(to.designSystemId, to.versionId, group, parentId);
|
|
35302
|
+
});
|
|
35303
|
+
}
|
|
35304
|
+
/** Creates local component group. This group doesn't have id associated with it on remote, and must be created once with `createComponentGroup` to be stored in design system
|
|
35305
|
+
* @param versionId - Id of the version to create the group in
|
|
35306
|
+
* @param brandId - Id of the brand to create the group in
|
|
35307
|
+
* @returns New group with id assigned
|
|
35308
|
+
*/
|
|
35309
|
+
createLocalComponentGroup(versionId, brandId) {
|
|
35310
|
+
return ComponentUtils_1.ComponentUtils.createDefaultComponentGroup(versionId, brandId);
|
|
35311
|
+
}
|
|
35312
|
+
/** Updates remote component. This method can only be used on components that already exist in the version
|
|
35313
|
+
* @param to - Remote version to write to
|
|
35314
|
+
* @param component - Component to update
|
|
35315
|
+
* @returns Nothing
|
|
35316
|
+
*/
|
|
35317
|
+
updateComponent(to, component) {
|
|
35318
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35319
|
+
return this.dataCore.updateComponent(to.designSystemId, to.versionId, component);
|
|
35320
|
+
});
|
|
35321
|
+
}
|
|
35322
|
+
/** Updates remote component groups. This method can only be used on component groups that already exist in the version
|
|
35323
|
+
* @param to - Remote version to write to
|
|
35324
|
+
* @param component - Component group to update
|
|
35325
|
+
* @returns Nothing
|
|
35326
|
+
*/
|
|
35327
|
+
updateComponentGroup(to, group) {
|
|
35328
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35329
|
+
return this.dataCore.updateComponentGroup(to.designSystemId, to.versionId, group);
|
|
35330
|
+
});
|
|
35331
|
+
}
|
|
35332
|
+
/** Updates remote component property value. This also creates the property value if it doesn't exist
|
|
35333
|
+
* @param to - Remote version to write to
|
|
35334
|
+
* @param newValue - Value to set - this can be multiple things, from ID to raw string value to others
|
|
35335
|
+
* @param forComponent - Component to assign the value to
|
|
35336
|
+
* @param forProperty - Property to assign the value to
|
|
35337
|
+
*/
|
|
35338
|
+
updateComponentPropertyValue(to, newValue, forComponent, forProperty) {
|
|
35339
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35340
|
+
return this.dataCore.updateComponentPropertyValue(to.designSystemId, to.versionId, newValue, forComponent, forProperty);
|
|
35341
|
+
});
|
|
35342
|
+
}
|
|
35343
|
+
/** Deletes remote component property value
|
|
35344
|
+
* @param to - Remote version to write to
|
|
35345
|
+
* @param valueId - Value identifier
|
|
35346
|
+
*/
|
|
35347
|
+
deleteComponentPropertyValue(to, valueId) {
|
|
35348
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35349
|
+
return this.dataCore.deleteComponentPropertyValue(to.designSystemId, to.versionId, valueId);
|
|
35350
|
+
});
|
|
35351
|
+
}
|
|
35352
|
+
/** Create component property
|
|
35353
|
+
* @param to - Remote version to write to
|
|
35354
|
+
* @param model - Property creation model to create the property from
|
|
35355
|
+
*/
|
|
35356
|
+
createComponentProperty(to, model) {
|
|
35357
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35358
|
+
return this.dataCore.createComponentProperty(to.designSystemId, to.versionId, model);
|
|
35359
|
+
});
|
|
35360
|
+
}
|
|
35361
|
+
/** Update component property
|
|
35362
|
+
* @param to - Remote version to write to
|
|
35363
|
+
* @param propertyIdInVersion - Remote element property to update
|
|
35364
|
+
* @param model - Property update model to apply to property
|
|
35365
|
+
*/
|
|
35366
|
+
updateComponentProperty(to, propertyIdInVersion, model) {
|
|
35367
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35368
|
+
return this.dataCore.updateComponentProperty(to.designSystemId, to.versionId, propertyIdInVersion, model);
|
|
35369
|
+
});
|
|
35370
|
+
}
|
|
35371
|
+
/** Delete component property. This will remove all values associated with the property
|
|
35372
|
+
* @param to - Remote version to write to
|
|
35373
|
+
* @param propertyIdInVersion - Id of the property to delete
|
|
35374
|
+
*/
|
|
35375
|
+
deleteComponentProperty(to, propertyIdInVersion) {
|
|
35376
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35377
|
+
return this.dataCore.deleteComponentProperty(to.designSystemId, to.versionId, propertyIdInVersion);
|
|
35378
|
+
});
|
|
35379
|
+
}
|
|
35380
|
+
/** Resize specific component column
|
|
35381
|
+
* @param to - Remote version to write to
|
|
35382
|
+
* @param columnIdInVersion - Id of the column to update
|
|
35383
|
+
* @param newWidth - New width of the column
|
|
35384
|
+
*/
|
|
35385
|
+
updateResizeComponentColumn(to, view, column, newWidth) {
|
|
35386
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35387
|
+
return this.dataCore.updateResizeComponentColumn(to.designSystemId, to.versionId, view, column, newWidth);
|
|
35388
|
+
});
|
|
35389
|
+
}
|
|
35390
|
+
/** Move column to a new index and reorder all other columns around it
|
|
35391
|
+
* @param to - Remote version to write to
|
|
35392
|
+
* @param colum - Column object to move
|
|
35393
|
+
* @param newIndex - New index to move the component to
|
|
35394
|
+
*/
|
|
35395
|
+
updateReorderComponentColumn(to, view, column, newIndex) {
|
|
35396
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35397
|
+
return this.dataCore.updateReorderComponentColumn(to.designSystemId, to.versionId, view, column, newIndex);
|
|
35398
|
+
});
|
|
35399
|
+
}
|
|
35400
|
+
// --- --- --- --- --- --- --- --- --- ---
|
|
35401
|
+
// MARK: - Delete
|
|
35402
|
+
/** Deletes remote component. Calling this method on component that doesn't exist in the version will result in error
|
|
35403
|
+
* @param to - Remote version to write to
|
|
35404
|
+
* @param componentIdInVersion - Component idInVersion to delete
|
|
35405
|
+
* @returns Nothing
|
|
35406
|
+
*/
|
|
35407
|
+
deleteComponent(to, componentIdInVersion) {
|
|
35408
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35409
|
+
return this.dataCore.deleteComponent(to.designSystemId, to.versionId, componentIdInVersion);
|
|
35410
|
+
});
|
|
35411
|
+
}
|
|
35412
|
+
/** Deletes remote component group. This method will also fix the component group tree by moving any subgroups to parent - do note it will NOT delete contents of the group. Calling this method on group that doesn't exist in the version will result in error
|
|
35413
|
+
* @param to - Remote version to write to
|
|
35414
|
+
* @param componentGroupIdInVersion - Component group idInVersion to delete
|
|
35415
|
+
* @returns Nothing
|
|
35416
|
+
*/
|
|
35417
|
+
ungroupComponentGroup(to, componentGroupIdInVersion) {
|
|
35418
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35419
|
+
return this.dataCore.ungroupComponentGroup(to.designSystemId, to.versionId, componentGroupIdInVersion);
|
|
35420
|
+
});
|
|
35421
|
+
}
|
|
35422
|
+
/** Deletes remote component group and all its descendants. All items (groups and components) underneath will be deleted. Calling this method on group that doesn't exist in the version will result in error
|
|
35423
|
+
* @param to - Remote version to write to
|
|
35424
|
+
* @param componentGroupToDelete - Component group to delete
|
|
35425
|
+
* @param allComponents - Components for lookup
|
|
35426
|
+
* @param allComponentGroup - Component group for lookup
|
|
35427
|
+
* @returns Nothing
|
|
35428
|
+
*/
|
|
35429
|
+
deleteComponentGroup(to, componentGroupToDelete, components, componentGroups) {
|
|
35430
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35431
|
+
return this.dataCore.deleteComponentGroup(to.designSystemId, to.versionId, componentGroupToDelete, components, componentGroups);
|
|
35432
|
+
});
|
|
35433
|
+
}
|
|
35264
35434
|
}
|
|
35265
35435
|
exports.AreaComponents = AreaComponents;
|
|
35266
35436
|
|
|
@@ -35792,721 +35962,253 @@ exports.AreaPipelines = AreaPipelines;
|
|
|
35792
35962
|
//
|
|
35793
35963
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
35794
35964
|
exports.AreaTokenValues = void 0;
|
|
35795
|
-
|
|
35796
|
-
// MARK: - Imports
|
|
35797
|
-
const exports_1 = __webpack_require__(/*! ../../exports */ "./src/exports.ts");
|
|
35798
|
-
const SDKThemeUtilities_1 = __webpack_require__(/*! ../../model/themes/SDKThemeUtilities */ "./src/model/themes/SDKThemeUtilities.ts");
|
|
35799
|
-
const SDKColorToken_1 = __webpack_require__(/*! ../../model/tokens/SDKColorToken */ "./src/model/tokens/SDKColorToken.ts");
|
|
35800
|
-
const SDKDimensionToken_1 = __webpack_require__(/*! ../../model/tokens/SDKDimensionToken */ "./src/model/tokens/SDKDimensionToken.ts");
|
|
35801
|
-
const SDKStringToken_1 = __webpack_require__(/*! ../../model/tokens/SDKStringToken */ "./src/model/tokens/SDKStringToken.ts");
|
|
35802
|
-
const SDKSupernovaError_1 = __webpack_require__(/*! ../errors/SDKSupernovaError */ "./src/core/errors/SDKSupernovaError.ts");
|
|
35803
|
-
const lodash_1 = __webpack_require__(/*! lodash */ "../../node_modules/lodash/lodash.js");
|
|
35965
|
+
const TokenUtils_1 = __webpack_require__(/*! ../../utils/TokenUtils */ "./src/utils/TokenUtils.ts");
|
|
35804
35966
|
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
|
|
35805
35967
|
// MARK: - Token Values Area
|
|
35806
35968
|
class AreaTokenValues {
|
|
35807
35969
|
/** Creates a new theme with updated overrides */
|
|
35808
35970
|
tokenThemeByUpdatingOverride(theme, override) {
|
|
35809
|
-
|
|
35810
|
-
const filteredOverrides = overrides.filter((o) => o.id !== override.id);
|
|
35811
|
-
filteredOverrides.push(override);
|
|
35812
|
-
theme.overriddenTokens = filteredOverrides;
|
|
35813
|
-
return theme;
|
|
35971
|
+
return TokenUtils_1.TokenUtils.tokenThemeByUpdatingOverride(theme, override);
|
|
35814
35972
|
}
|
|
35815
35973
|
/** Creates a new theme with removed override */
|
|
35816
35974
|
tokenThemeByRemovingOverride(theme, tokenId) {
|
|
35817
|
-
|
|
35818
|
-
const filteredOverrides = overrides.filter((o) => o.id !== tokenId && o.idInVersion !== tokenId);
|
|
35819
|
-
theme.overriddenTokens = filteredOverrides;
|
|
35820
|
-
return theme;
|
|
35975
|
+
return TokenUtils_1.TokenUtils.tokenThemeByRemovingOverride(theme, tokenId);
|
|
35821
35976
|
}
|
|
35822
35977
|
/** Creates a new color token with updated .color value */
|
|
35823
35978
|
colorTokenByUpdatingColor(token, newValue) {
|
|
35824
|
-
|
|
35825
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
35826
|
-
if (newValue instanceof SDKColorToken_1.ColorToken) {
|
|
35827
|
-
update.value = {
|
|
35828
|
-
opacity: update.value.opacity,
|
|
35829
|
-
color: {
|
|
35830
|
-
r: newValue.value.color.r,
|
|
35831
|
-
g: newValue.value.color.g,
|
|
35832
|
-
b: newValue.value.color.b,
|
|
35833
|
-
referencedTokenId: newValue.value.color.referencedTokenId,
|
|
35834
|
-
},
|
|
35835
|
-
referencedTokenId: newValue.id,
|
|
35836
|
-
};
|
|
35837
|
-
}
|
|
35838
|
-
else {
|
|
35839
|
-
update.value = {
|
|
35840
|
-
opacity: update.value.opacity,
|
|
35841
|
-
color: {
|
|
35842
|
-
r: newValue.r,
|
|
35843
|
-
g: newValue.g,
|
|
35844
|
-
b: newValue.b,
|
|
35845
|
-
referencedTokenId: newValue.referencedTokenId,
|
|
35846
|
-
},
|
|
35847
|
-
referencedTokenId: null,
|
|
35848
|
-
};
|
|
35849
|
-
}
|
|
35850
|
-
return update;
|
|
35979
|
+
return TokenUtils_1.TokenUtils.colorTokenByUpdatingColor(token, newValue);
|
|
35851
35980
|
}
|
|
35852
35981
|
/** Creates a new color token with updated .opacity value */
|
|
35853
35982
|
colorTokenByUpdatingOpacity(token, newValue) {
|
|
35854
|
-
|
|
35855
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
35856
|
-
if (newValue instanceof exports_1.OpacityToken) {
|
|
35857
|
-
update.value.opacity = {
|
|
35858
|
-
measure: newValue.value.measure,
|
|
35859
|
-
unit: newValue.value.unit,
|
|
35860
|
-
referencedTokenId: newValue.id,
|
|
35861
|
-
};
|
|
35862
|
-
}
|
|
35863
|
-
else {
|
|
35864
|
-
update.value.opacity = {
|
|
35865
|
-
measure: newValue,
|
|
35866
|
-
unit: exports_1.Unit.raw,
|
|
35867
|
-
referencedTokenId: null,
|
|
35868
|
-
};
|
|
35869
|
-
}
|
|
35870
|
-
return update;
|
|
35983
|
+
return TokenUtils_1.TokenUtils.colorTokenByUpdatingOpacity(token, newValue);
|
|
35871
35984
|
}
|
|
35872
35985
|
/** Creates a new blur token with updated .type value */
|
|
35873
35986
|
blurTokenByUpdatingType(token, newValue) {
|
|
35874
|
-
|
|
35875
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
35876
|
-
update.value.type = newValue;
|
|
35877
|
-
return update;
|
|
35987
|
+
return TokenUtils_1.TokenUtils.blurTokenByUpdatingType(token, newValue);
|
|
35878
35988
|
}
|
|
35879
35989
|
/** Creates a new blur token with updated .radius value */
|
|
35880
35990
|
blurTokenByUpdatingRadius(token, newValue) {
|
|
35881
|
-
|
|
35882
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
35883
|
-
update.value.radius = this.rawOrReferencedDimensionValue(newValue);
|
|
35884
|
-
return update;
|
|
35991
|
+
return TokenUtils_1.TokenUtils.blurTokenByUpdatingRadius(token, newValue);
|
|
35885
35992
|
}
|
|
35886
35993
|
/** Creates a new typography token with updated .fontFamily value */
|
|
35887
35994
|
typographyTokenByUpdatingFontFamily(token, newValue) {
|
|
35888
|
-
|
|
35889
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
35890
|
-
if (newValue instanceof SDKStringToken_1.FontFamilyToken) {
|
|
35891
|
-
update.value.fontFamily = {
|
|
35892
|
-
text: newValue.value.text,
|
|
35893
|
-
referencedTokenId: newValue.id,
|
|
35894
|
-
};
|
|
35895
|
-
}
|
|
35896
|
-
else {
|
|
35897
|
-
update.value.fontFamily = {
|
|
35898
|
-
text: newValue.text,
|
|
35899
|
-
referencedTokenId: null,
|
|
35900
|
-
};
|
|
35901
|
-
}
|
|
35902
|
-
return update;
|
|
35995
|
+
return TokenUtils_1.TokenUtils.typographyTokenByUpdatingFontFamily(token, newValue);
|
|
35903
35996
|
}
|
|
35904
35997
|
/** Creates a new typography token with updated .fontWeight value */
|
|
35905
35998
|
typographyTokenByUpdatingFontWeight(token, newValue) {
|
|
35906
|
-
|
|
35907
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
35908
|
-
if (newValue instanceof SDKStringToken_1.FontWeightToken) {
|
|
35909
|
-
update.value.fontWeight = {
|
|
35910
|
-
text: newValue.value.text,
|
|
35911
|
-
referencedTokenId: newValue.id,
|
|
35912
|
-
};
|
|
35913
|
-
}
|
|
35914
|
-
else {
|
|
35915
|
-
update.value.fontWeight = {
|
|
35916
|
-
text: newValue.text,
|
|
35917
|
-
referencedTokenId: null,
|
|
35918
|
-
};
|
|
35919
|
-
}
|
|
35920
|
-
return update;
|
|
35999
|
+
return TokenUtils_1.TokenUtils.typographyTokenByUpdatingFontWeight(token, newValue);
|
|
35921
36000
|
}
|
|
35922
36001
|
/** Creates a new typography token with updated .fontSize value */
|
|
35923
36002
|
typographyTokenByUpdatingFontSize(token, newValue) {
|
|
35924
|
-
|
|
35925
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
35926
|
-
update.value.fontSize = this.rawOrReferencedDimensionValue(newValue);
|
|
35927
|
-
return update;
|
|
36003
|
+
return TokenUtils_1.TokenUtils.typographyTokenByUpdatingFontSize(token, newValue);
|
|
35928
36004
|
}
|
|
35929
36005
|
/** Creates a new typography token with updated .letterSpacing value */
|
|
35930
36006
|
typographyTokenByUpdatingLetterSpacing(token, newValue) {
|
|
35931
|
-
|
|
35932
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
35933
|
-
update.value.letterSpacing = this.rawOrReferencedDimensionValue(newValue);
|
|
35934
|
-
return update;
|
|
36007
|
+
return TokenUtils_1.TokenUtils.typographyTokenByUpdatingLetterSpacing(token, newValue);
|
|
35935
36008
|
}
|
|
35936
36009
|
/** Creates a new typography token with updated .lineHeight value */
|
|
35937
36010
|
typographyTokenByUpdatingLineHeight(token, newValue) {
|
|
35938
|
-
|
|
35939
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
35940
|
-
update.value.lineHeight = this.rawOrReferencedDimensionValue(newValue);
|
|
35941
|
-
return update;
|
|
36011
|
+
return TokenUtils_1.TokenUtils.typographyTokenByUpdatingLineHeight(token, newValue);
|
|
35942
36012
|
}
|
|
35943
36013
|
/** Creates a new typography token with updated .paragraphSpacing value */
|
|
35944
36014
|
typographyTokenByUpdatingParagraphSpacing(token, newValue) {
|
|
35945
|
-
|
|
35946
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
35947
|
-
update.value.paragraphSpacing = this.rawOrReferencedDimensionValue(newValue);
|
|
35948
|
-
return update;
|
|
36015
|
+
return TokenUtils_1.TokenUtils.typographyTokenByUpdatingParagraphSpacing(token, newValue);
|
|
35949
36016
|
}
|
|
35950
36017
|
/** Creates a new typography token with updated .paragraphSpacing value */
|
|
35951
36018
|
typographyTokenByUpdatingParagraphIndent(token, newValue) {
|
|
35952
|
-
|
|
35953
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
35954
|
-
update.value.paragraphIndent = this.rawOrReferencedDimensionValue(newValue);
|
|
35955
|
-
return update;
|
|
36019
|
+
return TokenUtils_1.TokenUtils.typographyTokenByUpdatingParagraphIndent(token, newValue);
|
|
35956
36020
|
}
|
|
35957
36021
|
/** Creates a new border token with updated .position value */
|
|
35958
36022
|
typographyTokenByUpdatingTextDecoration(token, newValue) {
|
|
35959
|
-
|
|
35960
|
-
|
|
35961
|
-
|
|
35962
|
-
|
|
35963
|
-
|
|
35964
|
-
options: newValue.value.options,
|
|
35965
|
-
referencedTokenId: newValue.id,
|
|
35966
|
-
};
|
|
35967
|
-
}
|
|
35968
|
-
else {
|
|
35969
|
-
update.value.textDecoration = {
|
|
35970
|
-
value: newValue.value,
|
|
35971
|
-
options: newValue.options,
|
|
35972
|
-
referencedTokenId: null,
|
|
35973
|
-
};
|
|
35974
|
-
}
|
|
35975
|
-
return update;
|
|
36023
|
+
return TokenUtils_1.TokenUtils.typographyTokenByUpdatingTextDecoration(token, newValue);
|
|
36024
|
+
}
|
|
36025
|
+
/** Creates a new typography token with updated .textCase value */
|
|
36026
|
+
typographyTokenByUpdatingTextCase(token, newValue) {
|
|
36027
|
+
return TokenUtils_1.TokenUtils.typographyTokenByUpdatingTextCase(token, newValue);
|
|
35976
36028
|
}
|
|
35977
36029
|
/** Creates a new border token with updated .color value. Do note, opacity is ignored */
|
|
35978
36030
|
borderTokenByUpdatingColor(token, newValue) {
|
|
35979
|
-
|
|
35980
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
35981
|
-
if (newValue instanceof SDKColorToken_1.ColorToken) {
|
|
35982
|
-
update.value.color = {
|
|
35983
|
-
opacity: update.value.color.opacity,
|
|
35984
|
-
color: {
|
|
35985
|
-
r: newValue.value.color.r,
|
|
35986
|
-
g: newValue.value.color.g,
|
|
35987
|
-
b: newValue.value.color.b,
|
|
35988
|
-
referencedTokenId: newValue.value.color.referencedTokenId,
|
|
35989
|
-
},
|
|
35990
|
-
referencedTokenId: newValue.id,
|
|
35991
|
-
};
|
|
35992
|
-
}
|
|
35993
|
-
else {
|
|
35994
|
-
update.value.color = {
|
|
35995
|
-
opacity: update.value.color.opacity,
|
|
35996
|
-
color: {
|
|
35997
|
-
r: newValue.r,
|
|
35998
|
-
g: newValue.g,
|
|
35999
|
-
b: newValue.b,
|
|
36000
|
-
referencedTokenId: newValue.referencedTokenId,
|
|
36001
|
-
},
|
|
36002
|
-
referencedTokenId: null,
|
|
36003
|
-
};
|
|
36004
|
-
}
|
|
36005
|
-
return update;
|
|
36031
|
+
return TokenUtils_1.TokenUtils.borderTokenByUpdatingColor(token, newValue);
|
|
36006
36032
|
}
|
|
36007
36033
|
/** Creates a new border token with updated color.opacity value */
|
|
36008
36034
|
borderTokenByUpdatingOpacity(token, newValue) {
|
|
36009
|
-
|
|
36010
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36011
|
-
if (newValue instanceof exports_1.OpacityToken) {
|
|
36012
|
-
update.value.color.opacity = {
|
|
36013
|
-
measure: newValue.value.measure,
|
|
36014
|
-
unit: newValue.value.unit,
|
|
36015
|
-
referencedTokenId: newValue.id,
|
|
36016
|
-
};
|
|
36017
|
-
}
|
|
36018
|
-
else {
|
|
36019
|
-
update.value.color.opacity = {
|
|
36020
|
-
measure: newValue,
|
|
36021
|
-
unit: exports_1.Unit.raw,
|
|
36022
|
-
referencedTokenId: null,
|
|
36023
|
-
};
|
|
36024
|
-
}
|
|
36025
|
-
return update;
|
|
36035
|
+
return TokenUtils_1.TokenUtils.borderTokenByUpdatingOpacity(token, newValue);
|
|
36026
36036
|
}
|
|
36027
36037
|
/** Creates a new border token with updated .width value */
|
|
36028
36038
|
borderTokenByUpdatingWidth(token, newValue) {
|
|
36029
|
-
|
|
36030
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36031
|
-
update.value.width = this.rawOrReferencedDimensionValue(newValue);
|
|
36032
|
-
return update;
|
|
36039
|
+
return TokenUtils_1.TokenUtils.borderTokenByUpdatingWidth(token, newValue);
|
|
36033
36040
|
}
|
|
36034
36041
|
/** Creates a new border token with updated .position value */
|
|
36035
36042
|
borderTokenByUpdatingPosition(token, newValue) {
|
|
36036
|
-
|
|
36037
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36038
|
-
update.value.position = newValue;
|
|
36039
|
-
return update;
|
|
36043
|
+
return TokenUtils_1.TokenUtils.borderTokenByUpdatingPosition(token, newValue);
|
|
36040
36044
|
}
|
|
36041
36045
|
/** Creates a new border token with updated .style value */
|
|
36042
36046
|
borderTokenByUpdatingStyle(token, newValue) {
|
|
36043
|
-
|
|
36044
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36045
|
-
update.value.style = newValue;
|
|
36046
|
-
return update;
|
|
36047
|
+
return TokenUtils_1.TokenUtils.borderTokenByUpdatingStyle(token, newValue);
|
|
36047
36048
|
}
|
|
36048
36049
|
/** Creates a new dimension token with updated value */
|
|
36049
36050
|
dimensionTokenByUpdatingValue(token, newValue) {
|
|
36050
|
-
|
|
36051
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36052
|
-
update.value = this.rawOrReferencedDimensionValue(newValue);
|
|
36053
|
-
return update;
|
|
36051
|
+
return TokenUtils_1.TokenUtils.dimensionTokenByUpdatingValue(token, newValue);
|
|
36054
36052
|
}
|
|
36055
36053
|
/** Creates a new size token with updated value */
|
|
36056
36054
|
sizeTokenByUpdatingValue(token, newValue) {
|
|
36057
|
-
|
|
36058
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36059
|
-
update.value = this.rawOrReferencedDimensionValue(newValue);
|
|
36060
|
-
return update;
|
|
36055
|
+
return TokenUtils_1.TokenUtils.sizeTokenByUpdatingValue(token, newValue);
|
|
36061
36056
|
}
|
|
36062
36057
|
/** Creates a new space token with updated value */
|
|
36063
36058
|
spaceTokenByUpdatingValue(token, newValue) {
|
|
36064
|
-
|
|
36065
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36066
|
-
update.value = this.rawOrReferencedDimensionValue(newValue);
|
|
36067
|
-
return update;
|
|
36059
|
+
return TokenUtils_1.TokenUtils.spaceTokenByUpdatingValue(token, newValue);
|
|
36068
36060
|
}
|
|
36069
36061
|
/** Creates a new opacity token with updated value */
|
|
36070
36062
|
opacityTokenByUpdatingValue(token, newValue) {
|
|
36071
|
-
|
|
36072
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36073
|
-
update.value = this.rawOrReferencedDimensionValue(newValue);
|
|
36074
|
-
return update;
|
|
36063
|
+
return TokenUtils_1.TokenUtils.opacityTokenByUpdatingValue(token, newValue);
|
|
36075
36064
|
}
|
|
36076
36065
|
/** Creates a new font size token with updated value */
|
|
36077
36066
|
fontSizeTokenByUpdatingValue(token, newValue) {
|
|
36078
|
-
|
|
36079
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36080
|
-
update.value = this.rawOrReferencedDimensionValue(newValue);
|
|
36081
|
-
return update;
|
|
36067
|
+
return TokenUtils_1.TokenUtils.fontSizeTokenByUpdatingValue(token, newValue);
|
|
36082
36068
|
}
|
|
36083
36069
|
/** Creates a new font size token with updated value */
|
|
36084
36070
|
lineHeightTokenByUpdatingValue(token, newValue) {
|
|
36085
|
-
|
|
36086
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36087
|
-
update.value = this.rawOrReferencedDimensionValue(newValue);
|
|
36088
|
-
return update;
|
|
36071
|
+
return TokenUtils_1.TokenUtils.lineHeightTokenByUpdatingValue(token, newValue);
|
|
36089
36072
|
}
|
|
36090
36073
|
/** Creates a new letter spacing token with updated value */
|
|
36091
36074
|
letterSpacingTokenByUpdatingValue(token, newValue) {
|
|
36092
|
-
|
|
36093
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36094
|
-
update.value = this.rawOrReferencedDimensionValue(newValue);
|
|
36095
|
-
return update;
|
|
36075
|
+
return TokenUtils_1.TokenUtils.letterSpacingTokenByUpdatingValue(token, newValue);
|
|
36096
36076
|
}
|
|
36097
36077
|
/** Creates a new paragraph spacing token with updated value */
|
|
36098
36078
|
paragraphSpacingTokenByUpdatingValue(token, newValue) {
|
|
36099
|
-
|
|
36100
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36101
|
-
update.value = this.rawOrReferencedDimensionValue(newValue);
|
|
36102
|
-
return update;
|
|
36079
|
+
return TokenUtils_1.TokenUtils.paragraphSpacingTokenByUpdatingValue(token, newValue);
|
|
36103
36080
|
}
|
|
36104
36081
|
/** Creates a new border width token with updated value */
|
|
36105
36082
|
borderWidthTokenByUpdatingValue(token, newValue) {
|
|
36106
|
-
|
|
36107
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36108
|
-
update.value = this.rawOrReferencedDimensionValue(newValue);
|
|
36109
|
-
return update;
|
|
36083
|
+
return TokenUtils_1.TokenUtils.borderWidthTokenByUpdatingValue(token, newValue);
|
|
36110
36084
|
}
|
|
36111
36085
|
/** Creates a new radius token with updated value */
|
|
36112
36086
|
radiusTokenByUpdatingValue(token, newValue) {
|
|
36113
|
-
|
|
36114
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36115
|
-
update.value = this.rawOrReferencedDimensionValue(newValue);
|
|
36116
|
-
return update;
|
|
36087
|
+
return TokenUtils_1.TokenUtils.radiusTokenByUpdatingValue(token, newValue);
|
|
36117
36088
|
}
|
|
36118
36089
|
/** Creates a new duration token with updated value */
|
|
36119
36090
|
durationTokenByUpdatingValue(token, newValue) {
|
|
36120
|
-
|
|
36121
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36122
|
-
update.value = this.rawOrReferencedDimensionValue(newValue);
|
|
36123
|
-
return update;
|
|
36091
|
+
return TokenUtils_1.TokenUtils.durationTokenByUpdatingValue(token, newValue);
|
|
36124
36092
|
}
|
|
36125
36093
|
/** Creates a new z-index token with updated value */
|
|
36126
36094
|
zIndexTokenByUpdatingValue(token, newValue) {
|
|
36127
|
-
|
|
36128
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36129
|
-
update.value = this.rawOrReferencedDimensionValue(newValue);
|
|
36130
|
-
return update;
|
|
36095
|
+
return TokenUtils_1.TokenUtils.zIndexTokenByUpdatingValue(token, newValue);
|
|
36131
36096
|
}
|
|
36132
36097
|
/** Creates a new string token with updated value */
|
|
36133
36098
|
stringTokenByUpdatingValue(token, newValue) {
|
|
36134
|
-
|
|
36135
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36136
|
-
update.value = this.rawOrReferencedStringValue(newValue);
|
|
36137
|
-
return update;
|
|
36099
|
+
return TokenUtils_1.TokenUtils.stringTokenByUpdatingValue(token, newValue);
|
|
36138
36100
|
}
|
|
36139
36101
|
/** Creates a new product copy token with updated value */
|
|
36140
36102
|
productCopyTokenByUpdatingValue(token, newValue) {
|
|
36141
|
-
|
|
36142
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36143
|
-
update.value = this.rawOrReferencedStringValue(newValue);
|
|
36144
|
-
return update;
|
|
36103
|
+
return TokenUtils_1.TokenUtils.productCopyTokenByUpdatingValue(token, newValue);
|
|
36145
36104
|
}
|
|
36146
36105
|
/** Creates a new font family token with updated value */
|
|
36147
36106
|
fontFamilyTokenByUpdatingValue(token, newValue) {
|
|
36148
|
-
|
|
36149
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36150
|
-
update.value = this.rawOrReferencedStringValue(newValue);
|
|
36151
|
-
return update;
|
|
36107
|
+
return TokenUtils_1.TokenUtils.fontFamilyTokenByUpdatingValue(token, newValue);
|
|
36152
36108
|
}
|
|
36153
36109
|
/** Creates a new font weight token with updated value */
|
|
36154
36110
|
fontWeightTokenByUpdatingValue(token, newValue) {
|
|
36155
|
-
|
|
36156
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36157
|
-
update.value = this.rawOrReferencedStringValue(newValue);
|
|
36158
|
-
return update;
|
|
36111
|
+
return TokenUtils_1.TokenUtils.fontWeightTokenByUpdatingValue(token, newValue);
|
|
36159
36112
|
}
|
|
36160
36113
|
/** Creates a new text case token with updated value */
|
|
36161
36114
|
textCaseTokenByUpdatingValue(token, newValue) {
|
|
36162
|
-
|
|
36163
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36164
|
-
update.value = {
|
|
36165
|
-
value: newValue.value,
|
|
36166
|
-
options: newValue.options,
|
|
36167
|
-
referencedTokenId: null,
|
|
36168
|
-
};
|
|
36169
|
-
return update;
|
|
36115
|
+
return TokenUtils_1.TokenUtils.textCaseTokenByUpdatingValue(token, newValue);
|
|
36170
36116
|
}
|
|
36171
36117
|
/** Creates a new text case token with updated value */
|
|
36172
36118
|
textDecorationTokenByUpdatingValue(token, newValue) {
|
|
36173
|
-
|
|
36174
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36175
|
-
update.value = {
|
|
36176
|
-
value: newValue.value,
|
|
36177
|
-
options: newValue.options,
|
|
36178
|
-
referencedTokenId: null,
|
|
36179
|
-
};
|
|
36180
|
-
return update;
|
|
36119
|
+
return TokenUtils_1.TokenUtils.textDecorationTokenByUpdatingValue(token, newValue);
|
|
36181
36120
|
}
|
|
36182
36121
|
/** Creates a new visibility token with updated value */
|
|
36183
36122
|
visibilityTokenByUpdatingValue(token, newValue) {
|
|
36184
|
-
|
|
36185
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36186
|
-
update.value = {
|
|
36187
|
-
value: newValue.value,
|
|
36188
|
-
options: newValue.options,
|
|
36189
|
-
referencedTokenId: null,
|
|
36190
|
-
};
|
|
36191
|
-
return update;
|
|
36123
|
+
return TokenUtils_1.TokenUtils.visibilityTokenByUpdatingValue(token, newValue);
|
|
36192
36124
|
}
|
|
36193
36125
|
// --- --- --- --- --- --- --- --- --- ---
|
|
36194
36126
|
// MARK: - Multi-layer token manipulation
|
|
36195
36127
|
/** Creates a new shadow token with one new extra layer added at the end of all layers */
|
|
36196
36128
|
shadowTokenByAddingLayer(token) {
|
|
36197
|
-
|
|
36198
|
-
const layer = {
|
|
36199
|
-
color: {
|
|
36200
|
-
color: {
|
|
36201
|
-
r: 0,
|
|
36202
|
-
g: 0,
|
|
36203
|
-
b: 0,
|
|
36204
|
-
referencedTokenId: null,
|
|
36205
|
-
},
|
|
36206
|
-
opacity: {
|
|
36207
|
-
measure: 1,
|
|
36208
|
-
unit: exports_1.Unit.raw,
|
|
36209
|
-
referencedTokenId: null,
|
|
36210
|
-
},
|
|
36211
|
-
referencedTokenId: null,
|
|
36212
|
-
},
|
|
36213
|
-
opacity: {
|
|
36214
|
-
measure: 1,
|
|
36215
|
-
unit: exports_1.Unit.raw,
|
|
36216
|
-
referencedTokenId: null,
|
|
36217
|
-
},
|
|
36218
|
-
radius: 0,
|
|
36219
|
-
spread: 0,
|
|
36220
|
-
type: exports_1.ShadowType.drop,
|
|
36221
|
-
x: 0,
|
|
36222
|
-
y: 4,
|
|
36223
|
-
referencedTokenId: null,
|
|
36224
|
-
};
|
|
36225
|
-
update.value.push(layer);
|
|
36226
|
-
return update;
|
|
36129
|
+
return TokenUtils_1.TokenUtils.shadowTokenByAddingLayer(token);
|
|
36227
36130
|
}
|
|
36228
36131
|
/** Creates a new shadow token by removing one of the layers */
|
|
36229
36132
|
shadowTokenByRemovingLayer(token, layerIndex) {
|
|
36230
|
-
|
|
36231
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36232
|
-
update.value = update.value.splice(layerIndex, 1);
|
|
36233
|
-
return update;
|
|
36133
|
+
return TokenUtils_1.TokenUtils.shadowTokenByRemovingLayer(token, layerIndex);
|
|
36234
36134
|
}
|
|
36235
36135
|
/** Creates a new shadow token with updated .color value. Do note, opacity is ignored */
|
|
36236
36136
|
shadowTokenByUpdatingColor(token, layerIndex, newValue) {
|
|
36237
|
-
|
|
36238
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36239
|
-
const layer = update.value[layerIndex];
|
|
36240
|
-
if (newValue instanceof SDKColorToken_1.ColorToken) {
|
|
36241
|
-
layer.color = {
|
|
36242
|
-
opacity: layer.color.opacity,
|
|
36243
|
-
color: {
|
|
36244
|
-
r: newValue.value.color.r,
|
|
36245
|
-
g: newValue.value.color.g,
|
|
36246
|
-
b: newValue.value.color.b,
|
|
36247
|
-
referencedTokenId: newValue.value.color.referencedTokenId,
|
|
36248
|
-
},
|
|
36249
|
-
referencedTokenId: newValue.id,
|
|
36250
|
-
};
|
|
36251
|
-
}
|
|
36252
|
-
else {
|
|
36253
|
-
layer.color = {
|
|
36254
|
-
opacity: layer.color.opacity,
|
|
36255
|
-
color: {
|
|
36256
|
-
r: newValue.r,
|
|
36257
|
-
g: newValue.g,
|
|
36258
|
-
b: newValue.b,
|
|
36259
|
-
referencedTokenId: newValue.referencedTokenId,
|
|
36260
|
-
},
|
|
36261
|
-
referencedTokenId: null,
|
|
36262
|
-
};
|
|
36263
|
-
}
|
|
36264
|
-
return update;
|
|
36137
|
+
return TokenUtils_1.TokenUtils.shadowTokenByUpdatingColor(token, layerIndex, newValue);
|
|
36265
36138
|
}
|
|
36266
36139
|
/** Creates a new shadow token with updated .color value */
|
|
36267
36140
|
shadowTokenByUpdatingOpacity(token, layerIndex, newValue) {
|
|
36268
|
-
|
|
36269
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36270
|
-
const layer = update.value[layerIndex];
|
|
36271
|
-
if (newValue instanceof exports_1.OpacityToken) {
|
|
36272
|
-
layer.opacity = {
|
|
36273
|
-
measure: newValue.value.measure,
|
|
36274
|
-
unit: newValue.value.unit,
|
|
36275
|
-
referencedTokenId: newValue.id,
|
|
36276
|
-
};
|
|
36277
|
-
}
|
|
36278
|
-
else {
|
|
36279
|
-
layer.opacity = {
|
|
36280
|
-
measure: newValue,
|
|
36281
|
-
unit: exports_1.Unit.raw,
|
|
36282
|
-
referencedTokenId: null,
|
|
36283
|
-
};
|
|
36284
|
-
}
|
|
36285
|
-
return update;
|
|
36141
|
+
return TokenUtils_1.TokenUtils.shadowTokenByUpdatingOpacity(token, layerIndex, newValue);
|
|
36286
36142
|
}
|
|
36287
36143
|
/** Creates a new shadow token with updated .x value */
|
|
36288
36144
|
shadowTokenByUpdatingX(token, layerIndex, newValue) {
|
|
36289
|
-
|
|
36290
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36291
|
-
const layer = update.value[layerIndex];
|
|
36292
|
-
layer.x = newValue;
|
|
36293
|
-
return update;
|
|
36145
|
+
return TokenUtils_1.TokenUtils.shadowTokenByUpdatingX(token, layerIndex, newValue);
|
|
36294
36146
|
}
|
|
36295
36147
|
/** Creates a new shadow token with updated .y value */
|
|
36296
36148
|
shadowTokenByUpdatingY(token, layerIndex, newValue) {
|
|
36297
|
-
|
|
36298
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36299
|
-
const layer = update.value[layerIndex];
|
|
36300
|
-
layer.y = newValue;
|
|
36301
|
-
return update;
|
|
36149
|
+
return TokenUtils_1.TokenUtils.shadowTokenByUpdatingY(token, layerIndex, newValue);
|
|
36302
36150
|
}
|
|
36303
36151
|
/** Creates a new shadow token with updated .radius value */
|
|
36304
36152
|
shadowTokenByUpdatingRadius(token, layerIndex, newValue) {
|
|
36305
|
-
|
|
36306
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36307
|
-
const layer = update.value[layerIndex];
|
|
36308
|
-
layer.radius = newValue;
|
|
36309
|
-
return update;
|
|
36153
|
+
return TokenUtils_1.TokenUtils.shadowTokenByUpdatingRadius(token, layerIndex, newValue);
|
|
36310
36154
|
}
|
|
36311
36155
|
/** Creates a new shadow token with updated .spread value */
|
|
36312
36156
|
shadowTokenByUpdatingSpread(token, layerIndex, newValue) {
|
|
36313
|
-
|
|
36314
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36315
|
-
const layer = update.value[layerIndex];
|
|
36316
|
-
layer.spread = newValue;
|
|
36317
|
-
return update;
|
|
36157
|
+
return TokenUtils_1.TokenUtils.shadowTokenByUpdatingSpread(token, layerIndex, newValue);
|
|
36318
36158
|
}
|
|
36319
36159
|
/** Creates a new shadow token with updated .type value */
|
|
36320
36160
|
shadowTokenByUpdatingType(token, layerIndex, newValue) {
|
|
36321
|
-
|
|
36322
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36323
|
-
const layer = update.value[layerIndex];
|
|
36324
|
-
layer.type = newValue;
|
|
36325
|
-
return update;
|
|
36161
|
+
return TokenUtils_1.TokenUtils.shadowTokenByUpdatingType(token, layerIndex, newValue);
|
|
36326
36162
|
}
|
|
36327
36163
|
/** Creates a new gradient token with updated .to value */
|
|
36328
36164
|
gradientTokenByUpdatingTo(token, layerIndex, newValue) {
|
|
36329
|
-
|
|
36330
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36331
|
-
const layer = update.value[layerIndex];
|
|
36332
|
-
layer.to = newValue;
|
|
36333
|
-
return update;
|
|
36165
|
+
return TokenUtils_1.TokenUtils.gradientTokenByUpdatingTo(token, layerIndex, newValue);
|
|
36334
36166
|
}
|
|
36335
36167
|
/** Creates a new gradient token with updated .from value */
|
|
36336
36168
|
gradientTokenByUpdatingFrom(token, layerIndex, newValue) {
|
|
36337
|
-
|
|
36338
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36339
|
-
const layer = update.value[layerIndex];
|
|
36340
|
-
layer.from = newValue;
|
|
36341
|
-
return update;
|
|
36169
|
+
return TokenUtils_1.TokenUtils.gradientTokenByUpdatingFrom(token, layerIndex, newValue);
|
|
36342
36170
|
}
|
|
36343
36171
|
/** Creates a new gradient token with updated .to value */
|
|
36344
36172
|
gradientTokenByUpdatingType(token, layerIndex, newValue) {
|
|
36345
|
-
|
|
36346
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36347
|
-
const layer = update.value[layerIndex];
|
|
36348
|
-
layer.type = newValue;
|
|
36349
|
-
return update;
|
|
36173
|
+
return TokenUtils_1.TokenUtils.gradientTokenByUpdatingType(token, layerIndex, newValue);
|
|
36350
36174
|
}
|
|
36351
36175
|
/** Creates a new gradient token with updated .aspectRatio value */
|
|
36352
36176
|
gradientTokenByUpdatingAspectRatio(token, layerIndex, newValue) {
|
|
36353
|
-
|
|
36354
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36355
|
-
const layer = update.value[layerIndex];
|
|
36356
|
-
layer.aspectRatio = newValue;
|
|
36357
|
-
return update;
|
|
36177
|
+
return TokenUtils_1.TokenUtils.gradientTokenByUpdatingAspectRatio(token, layerIndex, newValue);
|
|
36358
36178
|
}
|
|
36359
36179
|
/** Creates a new gradient token with updated .to value */
|
|
36360
36180
|
gradientTokenByUpdatingStops(token, layerIndex, newValue) {
|
|
36361
|
-
|
|
36362
|
-
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
36363
|
-
const layer = update.value[layerIndex];
|
|
36364
|
-
layer.stops = this.gradientStopsFromRawData(newValue);
|
|
36365
|
-
return update;
|
|
36366
|
-
}
|
|
36367
|
-
/** Builds the gradient stop data from the elementary values */
|
|
36368
|
-
gradientStopsFromRawData(value) {
|
|
36369
|
-
const stops = new Array();
|
|
36370
|
-
for (const v of value) {
|
|
36371
|
-
if (v.color instanceof SDKColorToken_1.ColorToken) {
|
|
36372
|
-
const stop = {
|
|
36373
|
-
position: v.position,
|
|
36374
|
-
color: {
|
|
36375
|
-
opacity: v.color.value.opacity,
|
|
36376
|
-
color: {
|
|
36377
|
-
r: v.color.value.color.r,
|
|
36378
|
-
g: v.color.value.color.g,
|
|
36379
|
-
b: v.color.value.color.b,
|
|
36380
|
-
referencedTokenId: v.color.value.color.referencedTokenId,
|
|
36381
|
-
},
|
|
36382
|
-
referencedTokenId: v.color.id,
|
|
36383
|
-
},
|
|
36384
|
-
};
|
|
36385
|
-
stops.push(stop);
|
|
36386
|
-
}
|
|
36387
|
-
else {
|
|
36388
|
-
const stop = {
|
|
36389
|
-
position: v.position,
|
|
36390
|
-
color: {
|
|
36391
|
-
opacity: v.color.opacity,
|
|
36392
|
-
color: {
|
|
36393
|
-
r: v.color.color.r,
|
|
36394
|
-
g: v.color.color.g,
|
|
36395
|
-
b: v.color.color.b,
|
|
36396
|
-
referencedTokenId: v.color.color.referencedTokenId,
|
|
36397
|
-
},
|
|
36398
|
-
referencedTokenId: null,
|
|
36399
|
-
},
|
|
36400
|
-
};
|
|
36401
|
-
stops.push(stop);
|
|
36402
|
-
}
|
|
36403
|
-
}
|
|
36404
|
-
return stops;
|
|
36181
|
+
return TokenUtils_1.TokenUtils.gradientTokenByUpdatingStops(token, layerIndex, newValue);
|
|
36405
36182
|
}
|
|
36406
36183
|
// --- --- --- --- --- --- --- --- --- ---
|
|
36407
36184
|
// MARK: - Manipulating references
|
|
36408
36185
|
/** Creates a new token where value is reference to the provided token. Token and reference must be of the same type */
|
|
36409
36186
|
tokenByReferencing(token, reference) {
|
|
36410
|
-
|
|
36411
|
-
if (token.id === reference.id) {
|
|
36412
|
-
throw SDKSupernovaError_1.SupernovaError.fromMessage("Can't create reference where token would reference itself");
|
|
36413
|
-
}
|
|
36414
|
-
if (token.tokenType !== reference.tokenType) {
|
|
36415
|
-
throw SDKSupernovaError_1.SupernovaError.fromMessage("Can't reference token of different type");
|
|
36416
|
-
}
|
|
36417
|
-
update.value = Object.assign(Object.assign({}, (0, lodash_1.cloneDeep)(reference.value)), { referencedTokenId: reference.id });
|
|
36418
|
-
return update;
|
|
36187
|
+
return TokenUtils_1.TokenUtils.tokenByReferencing(token, reference);
|
|
36419
36188
|
}
|
|
36420
36189
|
/** Creates a new multilayer token where one of the layers is reference to the provided token. Token and reference must be of the same type */
|
|
36421
36190
|
multilayerTokenByReferencing(token, layerIndex, reference) {
|
|
36422
|
-
|
|
36423
|
-
if (token.id === reference.id) {
|
|
36424
|
-
throw SDKSupernovaError_1.SupernovaError.fromMessage("Can't create reference where token would reference itself");
|
|
36425
|
-
}
|
|
36426
|
-
if (token.tokenType !== reference.tokenType) {
|
|
36427
|
-
throw SDKSupernovaError_1.SupernovaError.fromMessage("Can't reference token of different type");
|
|
36428
|
-
}
|
|
36429
|
-
// TODO: Multilayer shadow & gradient copy of the references
|
|
36430
|
-
return update;
|
|
36191
|
+
return TokenUtils_1.TokenUtils.multilayerTokenByReferencing(token, layerIndex, reference);
|
|
36431
36192
|
}
|
|
36432
36193
|
/** Creates a new token where value is raw, but taken from the previously referenced token. Token must have had reference before */
|
|
36433
36194
|
tokenByDisconnectingReference(token) {
|
|
36434
|
-
|
|
36435
|
-
if (!token.value.referencedTokenId) {
|
|
36436
|
-
throw SDKSupernovaError_1.SupernovaError.fromMessage("Can't create raw token from a token that isn't previously a reference");
|
|
36437
|
-
}
|
|
36438
|
-
update.value = Object.assign(Object.assign({}, (0, lodash_1.cloneDeep)(token.value)), { referencedTokenId: null });
|
|
36439
|
-
return update;
|
|
36195
|
+
return TokenUtils_1.TokenUtils.tokenByDisconnectingReference(token);
|
|
36440
36196
|
}
|
|
36441
36197
|
/** Creates a new multilayer token where one of the layers value is raw, but taken from the previously referenced token. That layer must have had reference before */
|
|
36442
36198
|
multilayerTokenByDisconnectingReference(token, layerIndex) {
|
|
36443
|
-
|
|
36444
|
-
if (!token.value.referencedTokenId) {
|
|
36445
|
-
throw SDKSupernovaError_1.SupernovaError.fromMessage("Can't create raw token from a token that isn't previously a reference");
|
|
36446
|
-
}
|
|
36447
|
-
// TODO: Multilayer shadow & gradient disconnect of the references
|
|
36448
|
-
return update;
|
|
36199
|
+
return TokenUtils_1.TokenUtils.multilayerTokenByDisconnectingReference(token, layerIndex);
|
|
36449
36200
|
}
|
|
36450
36201
|
/** Checks if token as a whole is a reference to another token */
|
|
36451
36202
|
isReferencedToken(token) {
|
|
36452
|
-
return (token
|
|
36453
|
-
token.value.referencedTokenId !== undefined);
|
|
36203
|
+
return TokenUtils_1.TokenUtils.isReferencedToken(token);
|
|
36454
36204
|
}
|
|
36455
36205
|
/** Checks if a token layer of multilayer token is a reference to another token */
|
|
36456
36206
|
isReferencedMultilayerTokenLayer(token, layerIndex) {
|
|
36457
|
-
|
|
36458
|
-
const layer = token.value[layerIndex];
|
|
36459
|
-
return (layer.referencedTokenId !== null && layer.referencedTokenId !== undefined);
|
|
36207
|
+
return TokenUtils_1.TokenUtils.isReferencedMultilayerTokenLayer(token, layerIndex);
|
|
36460
36208
|
}
|
|
36461
36209
|
/** Checks if a token was imported from some foreign source. Not imported tokens were always created in Supernova */
|
|
36462
36210
|
isTokenImported(token) {
|
|
36463
|
-
|
|
36464
|
-
return (((_a = token.origin) === null || _a === void 0 ? void 0 : _a.sourceId) !== null && ((_b = token.origin) === null || _b === void 0 ? void 0 : _b.sourceId) !== undefined);
|
|
36465
|
-
}
|
|
36466
|
-
// --- --- --- --- --- --- --- --- --- ---
|
|
36467
|
-
// MARK: - Conveniences
|
|
36468
|
-
checkNotReference(token) {
|
|
36469
|
-
if (token.value.referencedTokenId) {
|
|
36470
|
-
throw SDKSupernovaError_1.SupernovaError.fromMessage("Performing value-replated operation on referenced token is not allowed");
|
|
36471
|
-
}
|
|
36472
|
-
}
|
|
36473
|
-
rawOrReferencedDimensionValue(newValue) {
|
|
36474
|
-
if (newValue instanceof SDKDimensionToken_1.DimensionCategoryToken) {
|
|
36475
|
-
return {
|
|
36476
|
-
measure: newValue.value.measure,
|
|
36477
|
-
unit: newValue.value.unit,
|
|
36478
|
-
referencedTokenId: newValue.id,
|
|
36479
|
-
};
|
|
36480
|
-
}
|
|
36481
|
-
return {
|
|
36482
|
-
measure: newValue.measure,
|
|
36483
|
-
unit: newValue.unit,
|
|
36484
|
-
referencedTokenId: null,
|
|
36485
|
-
};
|
|
36486
|
-
}
|
|
36487
|
-
rawOrReferencedStringValue(newValue) {
|
|
36488
|
-
if (newValue instanceof SDKStringToken_1.StringCategoryToken) {
|
|
36489
|
-
return {
|
|
36490
|
-
text: newValue.value.text,
|
|
36491
|
-
referencedTokenId: newValue.id,
|
|
36492
|
-
};
|
|
36493
|
-
}
|
|
36494
|
-
return {
|
|
36495
|
-
text: newValue.text,
|
|
36496
|
-
referencedTokenId: null,
|
|
36497
|
-
};
|
|
36498
|
-
}
|
|
36499
|
-
validateLayerAccess(token, index) {
|
|
36500
|
-
let layers;
|
|
36501
|
-
if (token instanceof exports_1.ShadowToken) {
|
|
36502
|
-
layers = token.shadowLayers;
|
|
36503
|
-
}
|
|
36504
|
-
else {
|
|
36505
|
-
layers = token.gradientLayers;
|
|
36506
|
-
}
|
|
36507
|
-
if (index < 0 || index >= layers.length) {
|
|
36508
|
-
throw SDKSupernovaError_1.SupernovaError.fromMessage(`Can't access layer at index ${index}, layer outside of allowed bounds`);
|
|
36509
|
-
}
|
|
36211
|
+
return TokenUtils_1.TokenUtils.isTokenImported(token);
|
|
36510
36212
|
}
|
|
36511
36213
|
}
|
|
36512
36214
|
exports.AreaTokenValues = AreaTokenValues;
|
|
@@ -37728,7 +37430,7 @@ class DataCore {
|
|
|
37728
37430
|
}
|
|
37729
37431
|
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
|
|
37730
37432
|
// MARK: - Elements: Tokens
|
|
37731
|
-
/** Download all
|
|
37433
|
+
/** Download all necessary data for tokens and retrieve them resolved */
|
|
37732
37434
|
tokens(designSystemId, versionId, filter) {
|
|
37733
37435
|
return __awaiter(this, void 0, void 0, function* () {
|
|
37734
37436
|
// Batch requests together
|
|
@@ -37874,24 +37576,26 @@ class DataCore {
|
|
|
37874
37576
|
/** Delete group from remote */
|
|
37875
37577
|
deleteTokenGroup(designSystemId, versionId, tokenGroupToDelete, tokens, tokenGroups) {
|
|
37876
37578
|
return __awaiter(this, void 0, void 0, function* () {
|
|
37877
|
-
const
|
|
37878
|
-
return this.writeTokenData(designSystemId, versionId, [], [], itemsToDelete
|
|
37579
|
+
const toDelete = this.itemsToDeleteFromGroup(tokenGroupToDelete, tokens, tokenGroups);
|
|
37580
|
+
return this.writeTokenData(designSystemId, versionId, [], [], toDelete.itemsToDelete, toDelete.groupsToDelete);
|
|
37879
37581
|
});
|
|
37880
37582
|
}
|
|
37881
37583
|
itemsToDeleteFromGroup(group, tokens, tokenGroups) {
|
|
37882
37584
|
const groupsToDelete = [];
|
|
37883
|
-
const tokensToDelete = tokens.filter((t) =>
|
|
37585
|
+
const tokensToDelete = tokens.filter((t) => {
|
|
37586
|
+
return group.childrenIds.includes(t.id);
|
|
37587
|
+
});
|
|
37884
37588
|
groupsToDelete.push(...tokenGroups.filter((g) => group.childrenIds.includes(g.id)));
|
|
37885
37589
|
// For each group, additionally, get all children
|
|
37886
37590
|
for (const child of groupsToDelete) {
|
|
37887
37591
|
const children = this.itemsToDeleteFromGroup(child, tokens, tokenGroups);
|
|
37888
|
-
tokensToDelete.push(...children.
|
|
37592
|
+
tokensToDelete.push(...children.itemsToDelete);
|
|
37889
37593
|
groupsToDelete.push(...children.groupsToDelete);
|
|
37890
37594
|
}
|
|
37891
37595
|
// Add top level group
|
|
37892
37596
|
groupsToDelete.push(group);
|
|
37893
37597
|
return {
|
|
37894
|
-
tokensToDelete,
|
|
37598
|
+
itemsToDelete: tokensToDelete,
|
|
37895
37599
|
groupsToDelete,
|
|
37896
37600
|
};
|
|
37897
37601
|
}
|
|
@@ -37958,9 +37662,9 @@ class DataCore {
|
|
|
37958
37662
|
}
|
|
37959
37663
|
/** Update column size */
|
|
37960
37664
|
updateResizeTokenColumn(designSystemId, versionId, view, column, newWidth) {
|
|
37961
|
-
var _a, _b;
|
|
37665
|
+
var _a, _b, _c;
|
|
37962
37666
|
return __awaiter(this, void 0, void 0, function* () {
|
|
37963
|
-
return this.write.updateResizeTokenColumn(designSystemId, versionId, view.id, column.type, column.id, (_a = column.themeId) !== null && _a !== void 0 ? _a : undefined, (_b = column.basePropertyType) !== null && _b !== void 0 ? _b : undefined, newWidth);
|
|
37667
|
+
return this.write.updateResizeTokenColumn(designSystemId, versionId, view.id, column.type, column.id, (_a = column.themeId) !== null && _a !== void 0 ? _a : undefined, (_b = column.basePropertyType) !== null && _b !== void 0 ? _b : undefined, (_c = column.propertyDefinitionId) !== null && _c !== void 0 ? _c : undefined, newWidth);
|
|
37964
37668
|
});
|
|
37965
37669
|
}
|
|
37966
37670
|
/** Delete theme from remote */
|
|
@@ -38024,6 +37728,137 @@ class DataCore {
|
|
|
38024
37728
|
return resolver.resolveGroupData(designComponentGroupData);
|
|
38025
37729
|
});
|
|
38026
37730
|
}
|
|
37731
|
+
/** Write new component to remote */
|
|
37732
|
+
createComponent(designSystemId, versionId, component, parentId) {
|
|
37733
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37734
|
+
const componentWriteObject = component.toWriteObject();
|
|
37735
|
+
componentWriteObject.groupPersistentId = parentId;
|
|
37736
|
+
const remoteComponent = yield this.write.createRemoteComponent(designSystemId, versionId, componentWriteObject);
|
|
37737
|
+
return {
|
|
37738
|
+
id: remoteComponent.persistentId,
|
|
37739
|
+
idInVersion: remoteComponent.id,
|
|
37740
|
+
};
|
|
37741
|
+
});
|
|
37742
|
+
}
|
|
37743
|
+
/** Update existing component in remote */
|
|
37744
|
+
updateComponent(designSystemId, versionId, component) {
|
|
37745
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37746
|
+
const componentWriteObject = component.toWriteObject();
|
|
37747
|
+
yield this.write.updateRemoteComponent(designSystemId, versionId, componentWriteObject);
|
|
37748
|
+
});
|
|
37749
|
+
}
|
|
37750
|
+
/** Write new component group to remote */
|
|
37751
|
+
createComponentGroup(designSystemId, versionId, group, parentId) {
|
|
37752
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37753
|
+
const groupWriteObject = group.toWriteObject();
|
|
37754
|
+
groupWriteObject.parentId = parentId;
|
|
37755
|
+
const remoteGroup = yield this.write.createRemoteComponentGroup(designSystemId, versionId, groupWriteObject);
|
|
37756
|
+
return {
|
|
37757
|
+
id: remoteGroup.persistentId,
|
|
37758
|
+
idInVersion: remoteGroup.id,
|
|
37759
|
+
};
|
|
37760
|
+
});
|
|
37761
|
+
}
|
|
37762
|
+
/** Update existing component group in remote */
|
|
37763
|
+
updateComponentGroup(designSystemId, versionId, group) {
|
|
37764
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37765
|
+
const componentGroupWriteObject = group.toWriteObject();
|
|
37766
|
+
yield this.write.updateRemoteComponentGroup(designSystemId, versionId, componentGroupWriteObject);
|
|
37767
|
+
});
|
|
37768
|
+
}
|
|
37769
|
+
/** Update component property at remote */
|
|
37770
|
+
updateComponentPropertyValue(designSystemId, versionId, newValue, component, property) {
|
|
37771
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37772
|
+
return this.write.updateComponentPropertyValue(designSystemId, versionId, newValue, component.id, property.id);
|
|
37773
|
+
});
|
|
37774
|
+
}
|
|
37775
|
+
/** Delete component property in remote */
|
|
37776
|
+
deleteComponentPropertyValue(designSystemId, versionId, valueId) {
|
|
37777
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37778
|
+
return this.write.deleteComponentPropertyValue(designSystemId, versionId, valueId);
|
|
37779
|
+
});
|
|
37780
|
+
}
|
|
37781
|
+
/** Create a custom property in remote */
|
|
37782
|
+
createComponentProperty(designSystemId, versionId, model) {
|
|
37783
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37784
|
+
const payload = {
|
|
37785
|
+
meta: {
|
|
37786
|
+
name: model.name,
|
|
37787
|
+
description: model.description,
|
|
37788
|
+
},
|
|
37789
|
+
type: model.type,
|
|
37790
|
+
targetElementType: SDKElementProperty_1.ElementPropertyTargetElementType.component,
|
|
37791
|
+
codeName: model.codeName,
|
|
37792
|
+
columnWidth: model.columnWidth,
|
|
37793
|
+
linkElementType: model.linkElementType,
|
|
37794
|
+
options: model.options,
|
|
37795
|
+
persistentId: (0, uuid_1.v4)(),
|
|
37796
|
+
};
|
|
37797
|
+
const remoteProperty = yield this.write.createComponentProperty(designSystemId, versionId, payload);
|
|
37798
|
+
return {
|
|
37799
|
+
id: remoteProperty.persistentId,
|
|
37800
|
+
idInVersion: remoteProperty.id,
|
|
37801
|
+
};
|
|
37802
|
+
});
|
|
37803
|
+
}
|
|
37804
|
+
/** Create a custom property in remote */
|
|
37805
|
+
updateComponentProperty(designSystemId, versionId, propertyIdInVersion, model) {
|
|
37806
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37807
|
+
const payload = {
|
|
37808
|
+
meta: {
|
|
37809
|
+
name: model.name,
|
|
37810
|
+
description: model.description,
|
|
37811
|
+
},
|
|
37812
|
+
codeName: model.codeName,
|
|
37813
|
+
options: model.options,
|
|
37814
|
+
};
|
|
37815
|
+
return this.write.updateComponentProperty(designSystemId, versionId, propertyIdInVersion, payload);
|
|
37816
|
+
});
|
|
37817
|
+
}
|
|
37818
|
+
/** Delete a custom property in remote */
|
|
37819
|
+
deleteComponentProperty(designSystemId, versionId, propertyId) {
|
|
37820
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37821
|
+
return this.write.deleteComponentProperty(designSystemId, versionId, propertyId);
|
|
37822
|
+
});
|
|
37823
|
+
}
|
|
37824
|
+
/** Move column to a new index and reorder all other columns around it */
|
|
37825
|
+
updateReorderComponentColumn(designSystemId, versionId, view, column, newIndex) {
|
|
37826
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37827
|
+
return this.write.updateReorderComponentColumn(designSystemId, versionId, view.id, column.id, newIndex);
|
|
37828
|
+
});
|
|
37829
|
+
}
|
|
37830
|
+
/** Update column size */
|
|
37831
|
+
updateResizeComponentColumn(designSystemId, versionId, view, column, newWidth) {
|
|
37832
|
+
var _a, _b, _c;
|
|
37833
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37834
|
+
return this.write.updateResizeComponentColumn(designSystemId, versionId, view.id, column.type, column.id, (_a = column.themeId) !== null && _a !== void 0 ? _a : undefined, (_b = column.basePropertyType) !== null && _b !== void 0 ? _b : undefined, (_c = column.propertyDefinitionId) !== null && _c !== void 0 ? _c : undefined, newWidth);
|
|
37835
|
+
});
|
|
37836
|
+
}
|
|
37837
|
+
/** Delete component from remote */
|
|
37838
|
+
deleteComponent(designSystemId, versionId, componentId) {
|
|
37839
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37840
|
+
return this.write.deleteRemoteComponent(designSystemId, versionId, componentId);
|
|
37841
|
+
});
|
|
37842
|
+
}
|
|
37843
|
+
/** Delete group from remote */
|
|
37844
|
+
ungroupComponentGroup(designSystemId, versionId, groupId) {
|
|
37845
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37846
|
+
return this.write.ungroupRemoteComponentGroup(designSystemId, versionId, groupId);
|
|
37847
|
+
});
|
|
37848
|
+
}
|
|
37849
|
+
/** Delete group from remote */
|
|
37850
|
+
deleteComponentGroup(designSystemId, versionId, componentGroupToDelete, components, componentGroups) {
|
|
37851
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37852
|
+
const toDelete = this.itemsToDeleteFromGroup(componentGroupToDelete, components, componentGroups);
|
|
37853
|
+
return this.writeComponentData(designSystemId, versionId, [], [], toDelete.itemsToDelete, toDelete.groupsToDelete);
|
|
37854
|
+
});
|
|
37855
|
+
}
|
|
37856
|
+
/** Write the component to remote */
|
|
37857
|
+
writeComponentData(designSystemId, versionId, components, groups, deleteComponents, deleteGroups) {
|
|
37858
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37859
|
+
return this.write.writeComponentData(designSystemId, versionId, components.map((t) => t.toWriteObject()), groups.map((g) => g.toWriteObject()), deleteComponents, deleteGroups);
|
|
37860
|
+
});
|
|
37861
|
+
}
|
|
38027
37862
|
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
|
|
38028
37863
|
// MARK: - Elements: Assets
|
|
38029
37864
|
/** Download all necessary data for assets and retrieve them resolved */
|
|
@@ -38354,7 +38189,7 @@ class DataCore {
|
|
|
38354
38189
|
// MARK: - Transactions
|
|
38355
38190
|
bulkUpdateTokenData(designSystemId, versionId, data) {
|
|
38356
38191
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38357
|
-
|
|
38192
|
+
let primaryPromise = Promise.resolve();
|
|
38358
38193
|
if (data.tokenMode === "create") {
|
|
38359
38194
|
// Create token if it didn't exist. We don't have to update the top level group, because BE will do that for us
|
|
38360
38195
|
const ids = yield this.createToken(designSystemId, versionId, data.token, data.tokenParent.id);
|
|
@@ -38363,10 +38198,10 @@ class DataCore {
|
|
|
38363
38198
|
}
|
|
38364
38199
|
else if (data.tokenMode === "update") {
|
|
38365
38200
|
// Update token because it did exist. In this case, also update group where it belongs
|
|
38366
|
-
|
|
38367
|
-
|
|
38368
|
-
|
|
38369
|
-
|
|
38201
|
+
// but make sure that `this.updateToken` runs first and `this.updateTokenGroup` after it
|
|
38202
|
+
primaryPromise = primaryPromise
|
|
38203
|
+
.then(() => this.updateToken(designSystemId, versionId, data.token))
|
|
38204
|
+
.then(() => this.updateTokenGroup(designSystemId, versionId, data.tokenParent));
|
|
38370
38205
|
}
|
|
38371
38206
|
// Add all secondary updates
|
|
38372
38207
|
const secondaryPromises = new Array();
|
|
@@ -38385,7 +38220,9 @@ class DataCore {
|
|
|
38385
38220
|
secondaryPromises.push(this.updateTokenTheme(designSystemId, versionId, t));
|
|
38386
38221
|
});
|
|
38387
38222
|
}
|
|
38388
|
-
|
|
38223
|
+
// NOTE: have the primary promise run first and secondary promises run after that
|
|
38224
|
+
yield primaryPromise;
|
|
38225
|
+
yield Promise.all(secondaryPromises);
|
|
38389
38226
|
});
|
|
38390
38227
|
}
|
|
38391
38228
|
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
|
|
@@ -39266,78 +39103,190 @@ class DataCoreWriteRequests {
|
|
|
39266
39103
|
yield this.bridge.put(endpoint, payload);
|
|
39267
39104
|
});
|
|
39268
39105
|
}
|
|
39269
|
-
updateResizeTokenColumn(designSystemId, versionId, viewId, columnType, columnId, columnThemeId, columnBasePropertyType, newWidth) {
|
|
39106
|
+
updateResizeTokenColumn(designSystemId, versionId, viewId, columnType, columnId, columnThemeId, columnBasePropertyType, columnPropertyDefinitionId, newWidth) {
|
|
39270
39107
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39271
39108
|
const payload = {
|
|
39272
39109
|
type: columnType,
|
|
39273
39110
|
width: newWidth,
|
|
39274
39111
|
themeId: columnThemeId,
|
|
39275
39112
|
basePropertyType: columnBasePropertyType,
|
|
39113
|
+
propertyDefinitionId: columnPropertyDefinitionId,
|
|
39276
39114
|
};
|
|
39277
|
-
console.log(`updateResizeTokenColumn`, payload);
|
|
39278
39115
|
const endpoint = this.bridge.getVersionEndpoint(designSystemId, versionId, `element-data-views/${viewId}/columns/${columnId}`);
|
|
39279
39116
|
yield this.bridge.put(endpoint, payload);
|
|
39280
39117
|
});
|
|
39281
39118
|
}
|
|
39282
39119
|
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
|
|
39283
|
-
// MARK: -
|
|
39284
|
-
|
|
39120
|
+
// MARK: - Components
|
|
39121
|
+
createRemoteComponent(designSystemId, versionId, component) {
|
|
39285
39122
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39286
|
-
const endpoint = this.bridge.getVersionEndpoint(designSystemId, versionId, "
|
|
39287
|
-
yield this.bridge.post(endpoint,
|
|
39288
|
-
return
|
|
39123
|
+
const endpoint = this.bridge.getVersionEndpoint(designSystemId, versionId, "components");
|
|
39124
|
+
const payload = yield this.bridge.post(endpoint, component);
|
|
39125
|
+
return payload.result.component;
|
|
39289
39126
|
});
|
|
39290
39127
|
}
|
|
39291
|
-
|
|
39292
|
-
|
|
39293
|
-
|
|
39294
|
-
|
|
39295
|
-
|
|
39296
|
-
|
|
39297
|
-
/***/ "./src/core/errors/SDKSupernovaError.ts":
|
|
39298
|
-
/*!**********************************************!*\
|
|
39299
|
-
!*** ./src/core/errors/SDKSupernovaError.ts ***!
|
|
39300
|
-
\**********************************************/
|
|
39301
|
-
/***/ ((__unused_webpack_module, exports) => {
|
|
39302
|
-
|
|
39303
|
-
"use strict";
|
|
39304
|
-
|
|
39305
|
-
//
|
|
39306
|
-
// SDKSupernovaError.ts
|
|
39307
|
-
// Supernova SDK
|
|
39308
|
-
//
|
|
39309
|
-
// Created by Jiri Trecak.
|
|
39310
|
-
//
|
|
39311
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
39312
|
-
exports.SupernovaError = void 0;
|
|
39313
|
-
const SupernovaNoNetworkResponse = "NO_NETWORK";
|
|
39314
|
-
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
|
|
39315
|
-
// MARK: - Function Definition
|
|
39316
|
-
/** Supernova-enhanced error. Contains both machine and user readable information about error */
|
|
39317
|
-
class SupernovaError extends Error {
|
|
39318
|
-
constructor(message, code, status, formErrors, requestId, serverTime, url) {
|
|
39319
|
-
super(message);
|
|
39320
|
-
this.code = code;
|
|
39321
|
-
this.status = status;
|
|
39322
|
-
this.formErrors = formErrors;
|
|
39323
|
-
this.requestId = requestId;
|
|
39324
|
-
this.serverTime = serverTime;
|
|
39325
|
-
this.url = url;
|
|
39326
|
-
}
|
|
39327
|
-
/** Creates Supernova error from received but failed network response */
|
|
39328
|
-
static fromNetworkResponse(response, url) {
|
|
39329
|
-
var _a, _b, _c;
|
|
39330
|
-
return new SupernovaError(response.message, response.reason, response.code, (_a = response.formErrors) !== null && _a !== void 0 ? _a : null, (_b = response.requestId) !== null && _b !== void 0 ? _b : null, (_c = response.serverTime) !== null && _c !== void 0 ? _c : null, url);
|
|
39128
|
+
updateRemoteComponent(designSystemId, versionId, component) {
|
|
39129
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39130
|
+
const endpoint = this.bridge.getVersionEndpoint(designSystemId, versionId, `components/${component.id}`);
|
|
39131
|
+
return this.bridge.put(endpoint, component);
|
|
39132
|
+
});
|
|
39331
39133
|
}
|
|
39332
|
-
|
|
39333
|
-
|
|
39334
|
-
|
|
39335
|
-
|
|
39134
|
+
createRemoteComponentGroup(designSystemId, versionId, group) {
|
|
39135
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39136
|
+
const endpoint = this.bridge.getVersionEndpoint(designSystemId, versionId, "component-groups");
|
|
39137
|
+
const payload = yield this.bridge.post(endpoint, group);
|
|
39138
|
+
return payload.result.group;
|
|
39139
|
+
});
|
|
39336
39140
|
}
|
|
39337
|
-
|
|
39338
|
-
|
|
39339
|
-
|
|
39340
|
-
|
|
39141
|
+
updateRemoteComponentGroup(designSystemId, versionId, group) {
|
|
39142
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39143
|
+
const endpoint = this.bridge.getVersionEndpoint(designSystemId, versionId, `component-groups/${group.id}`);
|
|
39144
|
+
return this.bridge.put(endpoint, group);
|
|
39145
|
+
});
|
|
39146
|
+
}
|
|
39147
|
+
deleteRemoteComponent(designSystemId, versionId, componentId) {
|
|
39148
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39149
|
+
const endpoint = this.bridge.getVersionEndpoint(designSystemId, versionId, `components/${componentId}`);
|
|
39150
|
+
return this.bridge.delete(endpoint);
|
|
39151
|
+
});
|
|
39152
|
+
}
|
|
39153
|
+
ungroupRemoteComponentGroup(designSystemId, versionId, componentGroupId) {
|
|
39154
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39155
|
+
const endpoint = this.bridge.getVersionEndpoint(designSystemId, versionId, `component-groups/${componentGroupId}`);
|
|
39156
|
+
return this.bridge.delete(endpoint);
|
|
39157
|
+
});
|
|
39158
|
+
}
|
|
39159
|
+
writeComponentData(designSystemId, versionId, components, groups, deleteComponents, deleteComponentGroups) {
|
|
39160
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39161
|
+
const endpoint = this.bridge.getVersionEndpoint(designSystemId, versionId, "bff/import");
|
|
39162
|
+
const payload = {
|
|
39163
|
+
components,
|
|
39164
|
+
componentGroups: groups,
|
|
39165
|
+
bulkDelete: {
|
|
39166
|
+
componentIds: deleteComponents.map((t) => t.idInVersion),
|
|
39167
|
+
componentGroupIds: deleteComponentGroups.map((t) => t.idInVersion),
|
|
39168
|
+
},
|
|
39169
|
+
};
|
|
39170
|
+
return this.bridge.post(endpoint, payload);
|
|
39171
|
+
});
|
|
39172
|
+
}
|
|
39173
|
+
updateComponentPropertyValue(designSystemId, versionId, newValue, componentId, propertyId) {
|
|
39174
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39175
|
+
const payload = {
|
|
39176
|
+
value: newValue,
|
|
39177
|
+
definitionId: propertyId,
|
|
39178
|
+
targetElementId: componentId,
|
|
39179
|
+
};
|
|
39180
|
+
const endpoint = this.bridge.getVersionEndpoint(designSystemId, versionId, `element-properties/values`);
|
|
39181
|
+
yield this.bridge.post(endpoint, payload);
|
|
39182
|
+
});
|
|
39183
|
+
}
|
|
39184
|
+
deleteComponentPropertyValue(designSystemId, versionId, valueId) {
|
|
39185
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39186
|
+
const endpoint = this.bridge.getVersionEndpoint(designSystemId, versionId, `element-properties/values/${valueId}`);
|
|
39187
|
+
yield this.bridge.delete(endpoint);
|
|
39188
|
+
});
|
|
39189
|
+
}
|
|
39190
|
+
createComponentProperty(designSystemId, versionId, model) {
|
|
39191
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39192
|
+
const endpoint = this.bridge.getVersionEndpoint(designSystemId, versionId, "element-properties/definitions");
|
|
39193
|
+
const payload = yield this.bridge.post(endpoint, model);
|
|
39194
|
+
return payload.result.definition;
|
|
39195
|
+
});
|
|
39196
|
+
}
|
|
39197
|
+
updateComponentProperty(designSystemId, versionId, propertyIdInVersion, model) {
|
|
39198
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39199
|
+
const endpoint = this.bridge.getVersionEndpoint(designSystemId, versionId, `element-properties/definitions/${propertyIdInVersion}`);
|
|
39200
|
+
return this.bridge.put(endpoint, model);
|
|
39201
|
+
});
|
|
39202
|
+
}
|
|
39203
|
+
deleteComponentProperty(designSystemId, versionId, propertyId) {
|
|
39204
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39205
|
+
const endpoint = this.bridge.getVersionEndpoint(designSystemId, versionId, `element-properties/definitions/${propertyId}`);
|
|
39206
|
+
yield this.bridge.delete(endpoint);
|
|
39207
|
+
});
|
|
39208
|
+
}
|
|
39209
|
+
updateReorderComponentColumn(designSystemId, versionId, viewId, columnId, newIndex) {
|
|
39210
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39211
|
+
const payload = {
|
|
39212
|
+
newIndex,
|
|
39213
|
+
};
|
|
39214
|
+
const endpoint = this.bridge.getVersionEndpoint(designSystemId, versionId, `element-data-views/${viewId}/columns/${columnId}/reorder`);
|
|
39215
|
+
yield this.bridge.put(endpoint, payload);
|
|
39216
|
+
});
|
|
39217
|
+
}
|
|
39218
|
+
updateResizeComponentColumn(designSystemId, versionId, viewId, columnType, columnId, columnThemeId, columnBasePropertyType, columnPropertyDefinitionId, newWidth) {
|
|
39219
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39220
|
+
const payload = {
|
|
39221
|
+
type: columnType,
|
|
39222
|
+
width: newWidth,
|
|
39223
|
+
themeId: columnThemeId,
|
|
39224
|
+
basePropertyType: columnBasePropertyType,
|
|
39225
|
+
propertyDefinitionId: columnPropertyDefinitionId,
|
|
39226
|
+
};
|
|
39227
|
+
const endpoint = this.bridge.getVersionEndpoint(designSystemId, versionId, `element-data-views/${viewId}/columns/${columnId}`);
|
|
39228
|
+
yield this.bridge.put(endpoint, payload);
|
|
39229
|
+
});
|
|
39230
|
+
}
|
|
39231
|
+
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
|
|
39232
|
+
// MARK: - TS Data
|
|
39233
|
+
writeTokenStudioJSONData(designSystemId, versionId, data) {
|
|
39234
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39235
|
+
const endpoint = this.bridge.getVersionEndpoint(designSystemId, versionId, "bff/token-studio");
|
|
39236
|
+
yield this.bridge.post(endpoint, data);
|
|
39237
|
+
return true;
|
|
39238
|
+
});
|
|
39239
|
+
}
|
|
39240
|
+
}
|
|
39241
|
+
exports.DataCoreWriteRequests = DataCoreWriteRequests;
|
|
39242
|
+
|
|
39243
|
+
|
|
39244
|
+
/***/ }),
|
|
39245
|
+
|
|
39246
|
+
/***/ "./src/core/errors/SDKSupernovaError.ts":
|
|
39247
|
+
/*!**********************************************!*\
|
|
39248
|
+
!*** ./src/core/errors/SDKSupernovaError.ts ***!
|
|
39249
|
+
\**********************************************/
|
|
39250
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
39251
|
+
|
|
39252
|
+
"use strict";
|
|
39253
|
+
|
|
39254
|
+
//
|
|
39255
|
+
// SDKSupernovaError.ts
|
|
39256
|
+
// Supernova SDK
|
|
39257
|
+
//
|
|
39258
|
+
// Created by Jiri Trecak.
|
|
39259
|
+
//
|
|
39260
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
39261
|
+
exports.SupernovaError = void 0;
|
|
39262
|
+
const SupernovaNoNetworkResponse = "NO_NETWORK";
|
|
39263
|
+
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
|
|
39264
|
+
// MARK: - Function Definition
|
|
39265
|
+
/** Supernova-enhanced error. Contains both machine and user readable information about error */
|
|
39266
|
+
class SupernovaError extends Error {
|
|
39267
|
+
constructor(message, code, status, formErrors, requestId, serverTime, url) {
|
|
39268
|
+
super(message);
|
|
39269
|
+
this.code = code;
|
|
39270
|
+
this.status = status;
|
|
39271
|
+
this.formErrors = formErrors;
|
|
39272
|
+
this.requestId = requestId;
|
|
39273
|
+
this.serverTime = serverTime;
|
|
39274
|
+
this.url = url;
|
|
39275
|
+
}
|
|
39276
|
+
/** Creates Supernova error from received but failed network response */
|
|
39277
|
+
static fromNetworkResponse(response, url) {
|
|
39278
|
+
var _a, _b, _c;
|
|
39279
|
+
return new SupernovaError(response.message, response.reason, response.code, (_a = response.formErrors) !== null && _a !== void 0 ? _a : null, (_b = response.requestId) !== null && _b !== void 0 ? _b : null, (_c = response.serverTime) !== null && _c !== void 0 ? _c : null, url);
|
|
39280
|
+
}
|
|
39281
|
+
/** Creates Supernova error with generic network failure message */
|
|
39282
|
+
static fromNoNetworkResponse(url) {
|
|
39283
|
+
return new SupernovaError("No network or internet unreachable", SupernovaNoNetworkResponse, 12163, // Internet connection lost
|
|
39284
|
+
null, new Date().toISOString(), null, url);
|
|
39285
|
+
}
|
|
39286
|
+
/** Creates Supernova error from local validation failure code */
|
|
39287
|
+
static fromCode(code) {
|
|
39288
|
+
// Error was thrown in the processing layer - tooling etc.
|
|
39289
|
+
return new SupernovaError(code, code, null, null, null, null, null);
|
|
39341
39290
|
}
|
|
39342
39291
|
/** Creates Supernova error from generic error message */
|
|
39343
39292
|
static fromMessage(message) {
|
|
@@ -40245,7 +40194,34 @@ class TokenResolver {
|
|
|
40245
40194
|
}
|
|
40246
40195
|
}
|
|
40247
40196
|
/*
|
|
40248
|
-
* Step 3: Create
|
|
40197
|
+
* Step 3: Create color tokens that can potentially reference pure resolved tokens
|
|
40198
|
+
*/
|
|
40199
|
+
for (const rawToken of data) {
|
|
40200
|
+
// Skip creation of all tokens that can have reference
|
|
40201
|
+
if (rawToken.data.aliasTo) {
|
|
40202
|
+
continue;
|
|
40203
|
+
}
|
|
40204
|
+
// Construct colors
|
|
40205
|
+
if (rawToken.type === SDKTokenType_1.TokenType.color) {
|
|
40206
|
+
const token = this.constructValueToken(rawToken, sortedElementProperties, elementValues);
|
|
40207
|
+
this.resolvedTokens.set(token.id, token);
|
|
40208
|
+
}
|
|
40209
|
+
}
|
|
40210
|
+
/*
|
|
40211
|
+
* Step 4: Create all remaining color tokens
|
|
40212
|
+
*/
|
|
40213
|
+
for (const rawToken of data) {
|
|
40214
|
+
// Skip creation of all tokens that are not references
|
|
40215
|
+
if (!rawToken.data.aliasTo) {
|
|
40216
|
+
continue;
|
|
40217
|
+
}
|
|
40218
|
+
if (rawToken.type === SDKTokenType_1.TokenType.color) {
|
|
40219
|
+
const token = this.constructReferencedToken(rawToken, sortedElementProperties, elementValues);
|
|
40220
|
+
this.resolvedTokens.set(token.id, token);
|
|
40221
|
+
}
|
|
40222
|
+
}
|
|
40223
|
+
/*
|
|
40224
|
+
* Step 5: Create mixin tokens that can potentially reference pure resolved tokens
|
|
40249
40225
|
*/
|
|
40250
40226
|
for (const rawToken of data) {
|
|
40251
40227
|
// Skip creation of all tokens that can have reference
|
|
@@ -40253,13 +40229,13 @@ class TokenResolver {
|
|
|
40253
40229
|
continue;
|
|
40254
40230
|
}
|
|
40255
40231
|
// Construct raw typography, gradient, shadow and border colors
|
|
40256
|
-
if (!(0, SDKTokenType_1.tokenTypeIsPure)(rawToken.type)) {
|
|
40232
|
+
if (!(0, SDKTokenType_1.tokenTypeIsPure)(rawToken.type) && rawToken.type !== SDKTokenType_1.TokenType.color) {
|
|
40257
40233
|
const token = this.constructValueToken(rawToken, sortedElementProperties, elementValues);
|
|
40258
40234
|
this.resolvedTokens.set(token.id, token);
|
|
40259
40235
|
}
|
|
40260
40236
|
}
|
|
40261
40237
|
/*
|
|
40262
|
-
* Step
|
|
40238
|
+
* Step 6: Create all remaining tokens, as all pure tokens that can be references and all value tokens with possible mixins were all resolved.
|
|
40263
40239
|
*/
|
|
40264
40240
|
for (const rawToken of data) {
|
|
40265
40241
|
// Skip creation of all tokens that are not references
|
|
@@ -40273,7 +40249,7 @@ class TokenResolver {
|
|
|
40273
40249
|
}
|
|
40274
40250
|
}
|
|
40275
40251
|
/*
|
|
40276
|
-
* Step
|
|
40252
|
+
* Step 7: Assign parents to the tree
|
|
40277
40253
|
*/
|
|
40278
40254
|
for (const tokenGroup of tokenGroups) {
|
|
40279
40255
|
for (const childId of tokenGroup.childrenIds) {
|
|
@@ -40392,10 +40368,6 @@ class TokenResolver {
|
|
|
40392
40368
|
}
|
|
40393
40369
|
constructPureValueForReplica(type, replica, override) {
|
|
40394
40370
|
switch (type) {
|
|
40395
|
-
case SDKTokenType_1.TokenType.color:
|
|
40396
|
-
;
|
|
40397
|
-
replica.value = this.constructColorValue(override.data.value);
|
|
40398
|
-
break;
|
|
40399
40371
|
case SDKTokenType_1.TokenType.dimension:
|
|
40400
40372
|
case SDKTokenType_1.TokenType.size:
|
|
40401
40373
|
case SDKTokenType_1.TokenType.space:
|
|
@@ -40464,7 +40436,7 @@ class TokenResolver {
|
|
|
40464
40436
|
if (override.data.aliasTo) {
|
|
40465
40437
|
continue;
|
|
40466
40438
|
}
|
|
40467
|
-
// Construct raw
|
|
40439
|
+
// Construct raw fonts, texts, radii and dimensions first
|
|
40468
40440
|
if ((0, SDKTokenType_1.tokenTypeIsPure)(override.type)) {
|
|
40469
40441
|
if (!override.data.value) {
|
|
40470
40442
|
throw new Error(`Override must always have alias or value, but ${override.tokenPersistentId} provided neither (1: raw)`);
|
|
@@ -40495,7 +40467,38 @@ class TokenResolver {
|
|
|
40495
40467
|
}
|
|
40496
40468
|
}
|
|
40497
40469
|
/*
|
|
40498
|
-
* Step 4: Create
|
|
40470
|
+
* Step 4: Create values for theme overrides that are color tokens
|
|
40471
|
+
*/
|
|
40472
|
+
for (const override of overrideData) {
|
|
40473
|
+
// Skip creation of all tokens that can have reference in this step
|
|
40474
|
+
if (override.data.aliasTo) {
|
|
40475
|
+
continue;
|
|
40476
|
+
}
|
|
40477
|
+
if (override.type === SDKTokenType_1.TokenType.color) {
|
|
40478
|
+
const token = this.constructThemedValueToken(override, themeId);
|
|
40479
|
+
this.resolvedOverrides.set(token.id, token);
|
|
40480
|
+
}
|
|
40481
|
+
}
|
|
40482
|
+
/*
|
|
40483
|
+
* Step 5: Create color tokens that are references. End of this step will provide us with all possible tokens resolved for mixins later
|
|
40484
|
+
*/
|
|
40485
|
+
for (const override of overrideData) {
|
|
40486
|
+
// Skip creation of all tokens that are not references
|
|
40487
|
+
if (!override.data.aliasTo) {
|
|
40488
|
+
continue;
|
|
40489
|
+
}
|
|
40490
|
+
if (override.type === SDKTokenType_1.TokenType.color &&
|
|
40491
|
+
!this.resolvedOverrides.get(override.tokenPersistentId)) {
|
|
40492
|
+
const resolvedOverride = this.resolvedOverrides.get(override.tokenPersistentId);
|
|
40493
|
+
if (!resolvedOverride) {
|
|
40494
|
+
// Only construct reference if it wasn't constructed already
|
|
40495
|
+
const replica = this.constructReferencedThemedToken(override, themeId);
|
|
40496
|
+
this.resolvedOverrides.set(replica.id, replica);
|
|
40497
|
+
}
|
|
40498
|
+
}
|
|
40499
|
+
}
|
|
40500
|
+
/*
|
|
40501
|
+
* Step 6: Create pure tokens that are references.
|
|
40499
40502
|
*/
|
|
40500
40503
|
for (const override of overrideData) {
|
|
40501
40504
|
// Skip creation of all tokens that can have reference in this step
|
|
@@ -40503,13 +40506,13 @@ class TokenResolver {
|
|
|
40503
40506
|
continue;
|
|
40504
40507
|
}
|
|
40505
40508
|
// Construct raw typography, gradient, shadow and border colors
|
|
40506
|
-
if (!(0, SDKTokenType_1.tokenTypeIsPure)(override.type)) {
|
|
40509
|
+
if (!(0, SDKTokenType_1.tokenTypeIsPure)(override.type) && override.type !== SDKTokenType_1.TokenType.color) {
|
|
40507
40510
|
const token = this.constructThemedValueToken(override, themeId);
|
|
40508
40511
|
this.resolvedOverrides.set(token.id, token);
|
|
40509
40512
|
}
|
|
40510
40513
|
}
|
|
40511
40514
|
/*
|
|
40512
|
-
* Step
|
|
40515
|
+
* Step 7: Create all remaining tokens, as all pure tokens that can be references and all value tokens with possible mixins were all resolved.
|
|
40513
40516
|
*/
|
|
40514
40517
|
for (const override of overrideData) {
|
|
40515
40518
|
// Skip creation of all tokens that are not references
|
|
@@ -40523,7 +40526,7 @@ class TokenResolver {
|
|
|
40523
40526
|
}
|
|
40524
40527
|
}
|
|
40525
40528
|
/*
|
|
40526
|
-
* Step
|
|
40529
|
+
* Step 8: Assign parents to the tree
|
|
40527
40530
|
*/
|
|
40528
40531
|
for (const tokenGroup of tokenGroups) {
|
|
40529
40532
|
for (const childId of tokenGroup.childrenIds) {
|
|
@@ -40535,7 +40538,7 @@ class TokenResolver {
|
|
|
40535
40538
|
}
|
|
40536
40539
|
}
|
|
40537
40540
|
/*
|
|
40538
|
-
* Step
|
|
40541
|
+
* Step 9: Create all remaining tokens, as all pure tokens that can be references and all value tokens with possible mixins were all resolved.
|
|
40539
40542
|
*/
|
|
40540
40543
|
const theme = new SDKTokenTheme_1.TokenTheme(data, this.versionId);
|
|
40541
40544
|
const themeOverrides = Array.from(this.resolvedOverrides.values());
|
|
@@ -40862,7 +40865,7 @@ class TokenResolver {
|
|
|
40862
40865
|
r,
|
|
40863
40866
|
g,
|
|
40864
40867
|
b,
|
|
40865
|
-
referencedTokenId: null
|
|
40868
|
+
referencedTokenId: null,
|
|
40866
40869
|
},
|
|
40867
40870
|
opacity,
|
|
40868
40871
|
referencedTokenId: null,
|
|
@@ -40878,7 +40881,7 @@ class TokenResolver {
|
|
|
40878
40881
|
b: color.color.b,
|
|
40879
40882
|
// TEST: Proper resolution of color.
|
|
40880
40883
|
// Maybe should set referencedTokenId above? Or here as one inside color.color.
|
|
40881
|
-
referencedTokenId: color.referencedTokenId
|
|
40884
|
+
referencedTokenId: color.referencedTokenId,
|
|
40882
40885
|
},
|
|
40883
40886
|
opacity,
|
|
40884
40887
|
referencedTokenId: null,
|
|
@@ -41293,16 +41296,22 @@ exports.TokenResolver = TokenResolver;
|
|
|
41293
41296
|
"use strict";
|
|
41294
41297
|
|
|
41295
41298
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
41296
|
-
exports.
|
|
41297
|
-
exports.
|
|
41298
|
-
exports.
|
|
41299
|
-
exports.SupernovaError = exports.UnreachableCaseError = exports.TokenTransform = exports.MarkdownTransformType = exports.MarkdownTransform = exports.DocSearchResultDataType = exports.DocSearch = exports.SupernovaToolsDesignTokensPlugin = exports.DTPluginToSupernovaMapType = exports.JSONBuilderNamingOption = exports.TokenJSONBuilder = exports.TokenUtilPreviewGenerator = exports.TokenThemeOverride = exports.TokenTheme = exports.Token = exports.VisibilityToken = void 0;
|
|
41299
|
+
exports.DocumentationPageBlockCallout = exports.DocumentationPageBlockAssets = exports.DocumentationPageBlockAsset = exports.Documentation = exports.DesignComponent = exports.ElementDataViewColumnType = exports.ElementDataViewColumnBasePropertyType = exports.ElementDataViewColumn = exports.ElementDataView = exports.ElementPropertyOption = exports.ElementPropertyType = exports.ElementPropertyTargetElementType = exports.ElementPropertyLinkElementType = exports.ElementProperty = exports.Component = exports.RenderedAsset = exports.Asset = exports.ExporterConfigurationPropertyType = exports.ExporterConfigurationPropertyInputType = exports.ExporterConfigurationProperty = exports.ExporterCustomBlockVariant = exports.ExporterCustomBlockPropertyInputType = exports.ExporterCustomBlockPropertyType = exports.ExporterCustomBlockProperty = exports.ExporterCustomBlockMode = exports.ExporterCustomBlock = exports.Exporter = exports.Membership = exports.DesignSystemVersion = exports.DesignSystem = exports.Brand = exports.SubscriptionProductFeatures = exports.Acl = exports.UserProfile = exports.User = exports.WorkspaceNPMRegistrySettings = exports.WorkspaceSSOSettings = exports.WorkspaceIPWhitelistSettings = exports.WorkspaceSubscription = exports.WorkspaceOnboarding = exports.WorkspaceProfile = exports.Workspace = exports.Supernova = exports.OPTION_TOKEN_TYPES = exports.STRING_TOKEN_TYPES = exports.DIMENSION_TOKEN_TYPES = exports.TokenUtils = exports.TokenUtilPreviewSegmentGenerator = exports.ElementPropertyValue = exports.ThemeUtilities = void 0;
|
|
41300
|
+
exports.BlurType = exports.AssetScaleType = exports.AssetScale = exports.AssetFormat = exports.Alignment = exports.TokenGroup = exports.DesignComponentGroup = exports.AssetGroup = exports.RichTextSpanAttribute = exports.RichTextSpan = exports.DocumentationRichText = exports.DocumentationPageAsset = exports.DocumentationPageBlock = exports.DocumentationPage = exports.DocumentationItem = exports.DocumentationGroup = exports.DocumentationConfiguration = exports.DocumentationItemConfiguration = exports.DocumentationItemHeader = exports.DocumentationPageBlockTableColumn = exports.DocumentationPageBlockTableRow = exports.DocumentationPageBlockTableCell = exports.DocumentationPageBlockTable = exports.DocumentationPageBlockTabItem = exports.DocumentationPageBlockTab = exports.DocumentationPageBlockColumnItem = exports.DocumentationPageBlockColumn = exports.DocumentationPageUnorderedList = exports.DocumentationPageBlockTokenList = exports.DocumentationPageBlockTokenGroup = exports.DocumentationPageBlockToken = exports.DocumentationPageBlockText = exports.DocumentationPageBlockShortcuts = exports.DocumentationPageBlockShortcutType = exports.DocumentationPageBlockShortcut = exports.DocumentationPageBlockRenderCode = exports.DocumentationPageBlockQuote = exports.DocumentationPageOrderedList = exports.DocumentationPageBlockImage = exports.DocumentationPageBlockHeading = exports.DocumentationPageBlockFrames = exports.DocumentationPageBlockFrame = exports.DocumentationPageBlockEmbedYoutube = exports.DocumentationPageBlockEmbedStorybook = exports.DocumentationPageBlockEmbedLink = exports.DocumentationPageBlockEmbedGeneric = exports.DocumentationPageBlockEmbedFigma = exports.DocumentationPageBlockDivider = exports.DocumentationPageBlockCustom = exports.DocumentationPageBlockCode = void 0;
|
|
41301
|
+
exports.ProductCopyToken = exports.StringToken = exports.TypographyToken = exports.ShadowToken = exports.ZIndexToken = exports.DurationToken = exports.RadiusToken = exports.BorderWidthToken = exports.ParagraphSpacingToken = exports.LetterSpacingToken = exports.LineHeightToken = exports.FontSizeToken = exports.OpacityToken = exports.SpaceToken = exports.SizeToken = exports.DimensionToken = exports.GradientToken = exports.ColorToken = exports.BorderToken = exports.BlurToken = exports.TokenOrigin = exports.Size = exports.Source = exports.DesignComponentOrigin = exports.WorkspaceNPMRegistryType = exports.WorkspaceNPMRegistryAuthType = exports.WorkspaceSubscriptionStatusInternal = exports.WorkspaceSubscriptionStatus = exports.WorkspaceSubscriptionProduct = exports.WorkspaceSubscriptionPlanInterval = exports.VisibilityType = exports.UserRole = exports.Unit = exports.TokenType = exports.TextDecoration = exports.TextCase = exports.ShadowType = exports.RichTextSpanAttributeType = exports.GradientType = exports.FrameLayout = exports.FrameAlignment = exports.DocumentationPageBlockThemeType = exports.DocumentationPageBlockType = exports.DocumentationPageAssetType = exports.DocumentationItemType = exports.DocumentationHeadingType = exports.DocumentationGroupBehavior = exports.DocumentationCalloutType = exports.BorderStyle = exports.BorderPosition = void 0;
|
|
41302
|
+
exports.SupernovaError = exports.UnreachableCaseError = exports.TokenTransform = exports.MarkdownTransformType = exports.MarkdownTransform = exports.DocSearchResultDataType = exports.DocSearch = exports.SupernovaToolsDesignTokensPlugin = exports.DTPluginToSupernovaMapType = exports.JSONBuilderNamingOption = exports.TokenJSONBuilder = exports.TokenUtilPreviewGenerator = exports.TokenThemeOverride = exports.TokenTheme = exports.Token = exports.VisibilityToken = exports.TextDecorationToken = exports.TextCaseToken = exports.FontWeightToken = exports.FontFamilyToken = void 0;
|
|
41303
|
+
var SDKThemeUtilities_1 = __webpack_require__(/*! ./model/themes/SDKThemeUtilities */ "./src/model/themes/SDKThemeUtilities.ts");
|
|
41304
|
+
Object.defineProperty(exports, "ThemeUtilities", ({ enumerable: true, get: function () { return SDKThemeUtilities_1.ThemeUtilities; } }));
|
|
41300
41305
|
var SDKElementPropertyValue_1 = __webpack_require__(/*! ./model/elements/values/SDKElementPropertyValue */ "./src/model/elements/values/SDKElementPropertyValue.ts");
|
|
41301
41306
|
Object.defineProperty(exports, "ElementPropertyValue", ({ enumerable: true, get: function () { return SDKElementPropertyValue_1.ElementPropertyValue; } }));
|
|
41302
41307
|
var TokenUtilPreviewSegmentGenerator_1 = __webpack_require__(/*! ./tools/token-preview/TokenUtilPreviewSegmentGenerator */ "./src/tools/token-preview/TokenUtilPreviewSegmentGenerator.ts");
|
|
41303
41308
|
Object.defineProperty(exports, "TokenUtilPreviewSegmentGenerator", ({ enumerable: true, get: function () { return TokenUtilPreviewSegmentGenerator_1.TokenUtilPreviewSegmentGenerator; } }));
|
|
41309
|
+
var TokenUtils_1 = __webpack_require__(/*! ./utils/TokenUtils */ "./src/utils/TokenUtils.ts");
|
|
41310
|
+
Object.defineProperty(exports, "TokenUtils", ({ enumerable: true, get: function () { return TokenUtils_1.TokenUtils; } }));
|
|
41304
41311
|
var SDKTokenType_1 = __webpack_require__(/*! ./model/enums/SDKTokenType */ "./src/model/enums/SDKTokenType.ts");
|
|
41305
41312
|
Object.defineProperty(exports, "DIMENSION_TOKEN_TYPES", ({ enumerable: true, get: function () { return SDKTokenType_1.DIMENSION_TOKEN_TYPES; } }));
|
|
41313
|
+
Object.defineProperty(exports, "STRING_TOKEN_TYPES", ({ enumerable: true, get: function () { return SDKTokenType_1.STRING_TOKEN_TYPES; } }));
|
|
41314
|
+
Object.defineProperty(exports, "OPTION_TOKEN_TYPES", ({ enumerable: true, get: function () { return SDKTokenType_1.OPTION_TOKEN_TYPES; } }));
|
|
41306
41315
|
// Export main Supernova object
|
|
41307
41316
|
var SDKSupernova_1 = __webpack_require__(/*! ./core/SDKSupernova */ "./src/core/SDKSupernova.ts");
|
|
41308
41317
|
Object.defineProperty(exports, "Supernova", ({ enumerable: true, get: function () { return SDKSupernova_1.Supernova; } }));
|
|
@@ -42091,8 +42100,8 @@ class Component {
|
|
|
42091
42100
|
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
|
|
42092
42101
|
// MARK: - Constructor
|
|
42093
42102
|
constructor(model, properties, propertyValues) {
|
|
42094
|
-
this.
|
|
42095
|
-
this.
|
|
42103
|
+
this.idInVersion = model.id;
|
|
42104
|
+
this.id = model.persistentId;
|
|
42096
42105
|
this.designSystemVersionId = model.designSystemVersionId;
|
|
42097
42106
|
this.brandId = model.brandId;
|
|
42098
42107
|
this.name = model.meta.name;
|
|
@@ -42100,7 +42109,7 @@ class Component {
|
|
|
42100
42109
|
this.properties = properties;
|
|
42101
42110
|
this.propertyValues = {};
|
|
42102
42111
|
for (const value of propertyValues) {
|
|
42103
|
-
if (value.targetElementId === this.
|
|
42112
|
+
if (value.targetElementId === this.id) {
|
|
42104
42113
|
// Property value refers to this element
|
|
42105
42114
|
for (const property of properties) {
|
|
42106
42115
|
if (property.id === value.definitionId) {
|
|
@@ -42113,6 +42122,19 @@ class Component {
|
|
|
42113
42122
|
this.createdAt = model.createdAt ? new Date(model.createdAt) : null;
|
|
42114
42123
|
this.updatedAt = model.updatedAt ? new Date(model.updatedAt) : null;
|
|
42115
42124
|
}
|
|
42125
|
+
toWriteObject() {
|
|
42126
|
+
var _a;
|
|
42127
|
+
return {
|
|
42128
|
+
id: this.idInVersion,
|
|
42129
|
+
brandId: this.brandId,
|
|
42130
|
+
designSystemVersionId: this.designSystemVersionId,
|
|
42131
|
+
persistentId: this.id,
|
|
42132
|
+
meta: {
|
|
42133
|
+
name: this.name,
|
|
42134
|
+
description: (_a = this.description) !== null && _a !== void 0 ? _a : "",
|
|
42135
|
+
},
|
|
42136
|
+
};
|
|
42137
|
+
}
|
|
42116
42138
|
}
|
|
42117
42139
|
exports.Component = Component;
|
|
42118
42140
|
|
|
@@ -44199,7 +44221,7 @@ exports.ElementProperty = ElementProperty;
|
|
|
44199
44221
|
/*!********************************************************!*\
|
|
44200
44222
|
!*** ./src/model/elements/SDKElementPropertyOption.ts ***!
|
|
44201
44223
|
\********************************************************/
|
|
44202
|
-
/***/ ((__unused_webpack_module, exports) => {
|
|
44224
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
44203
44225
|
|
|
44204
44226
|
"use strict";
|
|
44205
44227
|
|
|
@@ -44211,6 +44233,8 @@ exports.ElementProperty = ElementProperty;
|
|
|
44211
44233
|
//
|
|
44212
44234
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
44213
44235
|
exports.ElementPropertyOption = void 0;
|
|
44236
|
+
const SDKColorToken_1 = __webpack_require__(/*! ../tokens/SDKColorToken */ "./src/model/tokens/SDKColorToken.ts");
|
|
44237
|
+
const color2k_1 = __webpack_require__(/*! color2k */ "../../node_modules/color2k/dist/index.exports.require.cjs.js");
|
|
44214
44238
|
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
|
|
44215
44239
|
// MARK: - Object Definition
|
|
44216
44240
|
class ElementPropertyOption {
|
|
@@ -44224,14 +44248,96 @@ class ElementPropertyOption {
|
|
|
44224
44248
|
}
|
|
44225
44249
|
/** Constructs directly manipulable update object for user profile */
|
|
44226
44250
|
toUpdateObject() {
|
|
44251
|
+
var _a;
|
|
44227
44252
|
return {
|
|
44228
44253
|
id: this.id,
|
|
44229
44254
|
name: this.name,
|
|
44230
44255
|
backgroundColor: {
|
|
44231
|
-
value: this.backgroundColor,
|
|
44256
|
+
value: (_a = SDKColorToken_1.ColorToken.colorStringToNormalizedServerValue(this.backgroundColor, true)) !== null && _a !== void 0 ? _a : SDKColorToken_1.ColorToken.normalizedDefaultServerValue(),
|
|
44232
44257
|
},
|
|
44233
44258
|
};
|
|
44234
44259
|
}
|
|
44260
|
+
/** Returns background color represented as badge color. If badge color is different than what badge defines as base, return custom. Note: Only temporary implementation until BE supports it properly */
|
|
44261
|
+
asBadgeColor() {
|
|
44262
|
+
// Normalize current hex coming from BE and ignore alpha which is not supported by the badge
|
|
44263
|
+
if (!this.backgroundColor) {
|
|
44264
|
+
return "custom";
|
|
44265
|
+
}
|
|
44266
|
+
const rgba = (0, color2k_1.parseToRgba)(this.backgroundColor);
|
|
44267
|
+
const color = (0, color2k_1.toHex)(`rgba(${rgba[0]}, ${rgba[1]}, ${rgba[2]}, 1)`).toUpperCase();
|
|
44268
|
+
// Return badge color based on the hex or custom if not found
|
|
44269
|
+
switch (color) {
|
|
44270
|
+
case "#EDF5FF":
|
|
44271
|
+
return "blue";
|
|
44272
|
+
case "#D5FBFE":
|
|
44273
|
+
return "cyan";
|
|
44274
|
+
case "#FCF0FF":
|
|
44275
|
+
return "fuchsia";
|
|
44276
|
+
case "#EBFEF6":
|
|
44277
|
+
return "green";
|
|
44278
|
+
case "#EDEFF3":
|
|
44279
|
+
return "grey";
|
|
44280
|
+
case "#F6F7F9":
|
|
44281
|
+
return "light-grey";
|
|
44282
|
+
case "#FFF2E1":
|
|
44283
|
+
return "orange";
|
|
44284
|
+
case "#FDF0F7":
|
|
44285
|
+
return "pink";
|
|
44286
|
+
case "#F5F2FD":
|
|
44287
|
+
return "purple";
|
|
44288
|
+
case "#FEF1F2":
|
|
44289
|
+
return "red";
|
|
44290
|
+
case "#DFFDF6":
|
|
44291
|
+
return "teal";
|
|
44292
|
+
case "#FEF9C3":
|
|
44293
|
+
return "yellow";
|
|
44294
|
+
default:
|
|
44295
|
+
return "custom";
|
|
44296
|
+
}
|
|
44297
|
+
}
|
|
44298
|
+
/** Sets background color based on badge identifier color. Note: Only temporary implementation until BE supports it properly */
|
|
44299
|
+
setFromBadgeColor(color) {
|
|
44300
|
+
switch (color) {
|
|
44301
|
+
case "blue":
|
|
44302
|
+
this.backgroundColor = "#edf5ffff";
|
|
44303
|
+
break;
|
|
44304
|
+
case "cyan":
|
|
44305
|
+
this.backgroundColor = "#d5fbfeff";
|
|
44306
|
+
break;
|
|
44307
|
+
case "fuchsia":
|
|
44308
|
+
this.backgroundColor = "#fcf0ffff";
|
|
44309
|
+
break;
|
|
44310
|
+
case "green":
|
|
44311
|
+
this.backgroundColor = "#ebfef6ff";
|
|
44312
|
+
break;
|
|
44313
|
+
case "grey":
|
|
44314
|
+
this.backgroundColor = "#edeff3ff";
|
|
44315
|
+
break;
|
|
44316
|
+
case "light-grey":
|
|
44317
|
+
this.backgroundColor = "#f6f7f9ff";
|
|
44318
|
+
break;
|
|
44319
|
+
case "orange":
|
|
44320
|
+
this.backgroundColor = "#fff2e1ff";
|
|
44321
|
+
break;
|
|
44322
|
+
case "pink":
|
|
44323
|
+
this.backgroundColor = "#fdf0f7ff";
|
|
44324
|
+
break;
|
|
44325
|
+
case "purple":
|
|
44326
|
+
this.backgroundColor = "#f5f2fdff";
|
|
44327
|
+
break;
|
|
44328
|
+
case "red":
|
|
44329
|
+
this.backgroundColor = "#fef1f2ff";
|
|
44330
|
+
break;
|
|
44331
|
+
case "teal":
|
|
44332
|
+
this.backgroundColor = "#dffdf6ff";
|
|
44333
|
+
break;
|
|
44334
|
+
case "yellow":
|
|
44335
|
+
this.backgroundColor = "#fef9c3ff";
|
|
44336
|
+
break;
|
|
44337
|
+
default:
|
|
44338
|
+
throw new Error("Cannot set custom color using this method. Set background color directly");
|
|
44339
|
+
}
|
|
44340
|
+
}
|
|
44235
44341
|
}
|
|
44236
44342
|
exports.ElementPropertyOption = ElementPropertyOption;
|
|
44237
44343
|
|
|
@@ -45003,7 +45109,6 @@ exports.ALL_TOKEN_TYPES = [
|
|
|
45003
45109
|
TokenType.blur,
|
|
45004
45110
|
];
|
|
45005
45111
|
exports.PURE_TOKEN_TYPES = [
|
|
45006
|
-
TokenType.color,
|
|
45007
45112
|
...exports.DIMENSION_TOKEN_TYPES,
|
|
45008
45113
|
...exports.STRING_TOKEN_TYPES,
|
|
45009
45114
|
...exports.OPTION_TOKEN_TYPES,
|
|
@@ -47065,7 +47170,7 @@ class BorderToken extends SDKToken_1.Token {
|
|
|
47065
47170
|
return specificData;
|
|
47066
47171
|
}
|
|
47067
47172
|
static valueToWriteObject(value) {
|
|
47068
|
-
var _a, _b, _c;
|
|
47173
|
+
var _a, _b, _c, _d;
|
|
47069
47174
|
const valueObject = !value.referencedTokenId
|
|
47070
47175
|
? {
|
|
47071
47176
|
color: {
|
|
@@ -47075,15 +47180,18 @@ class BorderToken extends SDKToken_1.Token {
|
|
|
47075
47180
|
: {
|
|
47076
47181
|
color: SDKColorToken_1.ColorToken.colorValueToHex8(value.color),
|
|
47077
47182
|
opacity: {
|
|
47078
|
-
value:
|
|
47079
|
-
|
|
47080
|
-
|
|
47081
|
-
|
|
47183
|
+
aliasTo: (_b = value.color.opacity.referencedTokenId) !== null && _b !== void 0 ? _b : undefined,
|
|
47184
|
+
value: value.color.opacity.referencedTokenId
|
|
47185
|
+
? null
|
|
47186
|
+
: {
|
|
47187
|
+
measure: value.color.opacity.measure,
|
|
47188
|
+
unit: value.color.opacity.unit,
|
|
47189
|
+
},
|
|
47082
47190
|
},
|
|
47083
47191
|
},
|
|
47084
47192
|
},
|
|
47085
47193
|
width: {
|
|
47086
|
-
aliasTo: (
|
|
47194
|
+
aliasTo: (_c = value.width.referencedTokenId) !== null && _c !== void 0 ? _c : undefined,
|
|
47087
47195
|
value: value.width.referencedTokenId
|
|
47088
47196
|
? null
|
|
47089
47197
|
: {
|
|
@@ -47096,7 +47204,7 @@ class BorderToken extends SDKToken_1.Token {
|
|
|
47096
47204
|
}
|
|
47097
47205
|
: undefined;
|
|
47098
47206
|
return {
|
|
47099
|
-
aliasTo: (
|
|
47207
|
+
aliasTo: (_d = value.referencedTokenId) !== null && _d !== void 0 ? _d : undefined,
|
|
47100
47208
|
value: valueObject,
|
|
47101
47209
|
};
|
|
47102
47210
|
}
|
|
@@ -47189,7 +47297,7 @@ class ColorToken extends SDKToken_1.Token {
|
|
|
47189
47297
|
static colorValueFromDefinition(definition) {
|
|
47190
47298
|
const normalizedDefinition = this.normalizeColor(definition);
|
|
47191
47299
|
const result = (0, parse_color_1.default)(normalizedDefinition);
|
|
47192
|
-
if (!result) {
|
|
47300
|
+
if (!result || !result.rgba) {
|
|
47193
47301
|
console.log(`Unable to parse provided color value '${definition}'. Hex, RGB, HSL, HSV or CMYK are supported. Fix the error to import the color value properly.`);
|
|
47194
47302
|
// Handle gracefully
|
|
47195
47303
|
return {
|
|
@@ -47365,6 +47473,19 @@ class ColorToken extends SDKToken_1.Token {
|
|
|
47365
47473
|
.join("")
|
|
47366
47474
|
.toLowerCase()}`;
|
|
47367
47475
|
}
|
|
47476
|
+
/** Normalizes any color value to server readable value, and ignores alpha value optionally */
|
|
47477
|
+
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
47478
|
+
static colorStringToNormalizedServerValue(value, ignoreAlpha = false) {
|
|
47479
|
+
if (!value) {
|
|
47480
|
+
return null;
|
|
47481
|
+
}
|
|
47482
|
+
const rgba = (0, color2k_1.parseToRgba)(value);
|
|
47483
|
+
const color = (0, color2k_1.toHex)(`rgba(${rgba[0]}, ${rgba[1]}, ${rgba[2]}, ${ignoreAlpha ? "1" : rgba[3]})`).toLowerCase();
|
|
47484
|
+
return color.length === 7 ? `${color}ff` : color;
|
|
47485
|
+
}
|
|
47486
|
+
static normalizedDefaultServerValue() {
|
|
47487
|
+
return "#000000ff";
|
|
47488
|
+
}
|
|
47368
47489
|
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
|
|
47369
47490
|
// MARK: - Updates
|
|
47370
47491
|
updateWithRawValue(value) {
|
|
@@ -47391,7 +47512,7 @@ class ColorToken extends SDKToken_1.Token {
|
|
|
47391
47512
|
return specificData;
|
|
47392
47513
|
}
|
|
47393
47514
|
static valueToWriteObject(value) {
|
|
47394
|
-
var _a;
|
|
47515
|
+
var _a, _b;
|
|
47395
47516
|
return {
|
|
47396
47517
|
aliasTo: (_a = value.referencedTokenId) !== null && _a !== void 0 ? _a : undefined,
|
|
47397
47518
|
value: value.referencedTokenId
|
|
@@ -47401,10 +47522,13 @@ class ColorToken extends SDKToken_1.Token {
|
|
|
47401
47522
|
? { aliasTo: value.color.referencedTokenId }
|
|
47402
47523
|
: ColorToken.colorValueToHex8(value),
|
|
47403
47524
|
opacity: {
|
|
47404
|
-
value:
|
|
47405
|
-
|
|
47406
|
-
|
|
47407
|
-
|
|
47525
|
+
aliasTo: (_b = value.opacity.referencedTokenId) !== null && _b !== void 0 ? _b : undefined,
|
|
47526
|
+
value: value.opacity.referencedTokenId
|
|
47527
|
+
? null
|
|
47528
|
+
: {
|
|
47529
|
+
measure: value.opacity.measure,
|
|
47530
|
+
unit: value.opacity.unit,
|
|
47531
|
+
},
|
|
47408
47532
|
},
|
|
47409
47533
|
},
|
|
47410
47534
|
};
|
|
@@ -47505,6 +47629,7 @@ class DimensionCategoryToken extends SDKToken_1.Token {
|
|
|
47505
47629
|
case SDKTokenType_1.TokenType.fontSize:
|
|
47506
47630
|
case SDKTokenType_1.TokenType.letterSpacing:
|
|
47507
47631
|
case SDKTokenType_1.TokenType.paragraphSpacing:
|
|
47632
|
+
case SDKTokenType_1.TokenType.radius:
|
|
47508
47633
|
return SDKUnit_1.SIZE_UNITS.includes(unit) ? unit : SDKUnit_1.Unit.pixels;
|
|
47509
47634
|
case SDKTokenType_1.TokenType.lineHeight:
|
|
47510
47635
|
return SDKUnit_1.LINE_HEIGHT_UNITS.includes(unit) ? unit : SDKUnit_1.Unit.raw;
|
|
@@ -47512,7 +47637,6 @@ class DimensionCategoryToken extends SDKToken_1.Token {
|
|
|
47512
47637
|
// TODO: Consider transforming percent measure if it is referenced
|
|
47513
47638
|
return SDKUnit_1.Unit.raw;
|
|
47514
47639
|
case SDKTokenType_1.TokenType.borderWidth:
|
|
47515
|
-
case SDKTokenType_1.TokenType.radius:
|
|
47516
47640
|
return SDKUnit_1.Unit.pixels;
|
|
47517
47641
|
case SDKTokenType_1.TokenType.duration:
|
|
47518
47642
|
return SDKUnit_1.Unit.ms;
|
|
@@ -47533,7 +47657,9 @@ class DimensionCategoryToken extends SDKToken_1.Token {
|
|
|
47533
47657
|
if (SDKTokenType_1.MS_DIMENSION_TOKEN_TYPES.includes(type)) {
|
|
47534
47658
|
return SDKUnit_1.Unit.ms;
|
|
47535
47659
|
}
|
|
47536
|
-
if (type === SDKTokenType_1.TokenType.lineHeight &&
|
|
47660
|
+
if (type === SDKTokenType_1.TokenType.lineHeight &&
|
|
47661
|
+
parsedDefinition !== undefined &&
|
|
47662
|
+
parsedDefinition <= 10) {
|
|
47537
47663
|
return SDKUnit_1.Unit.raw;
|
|
47538
47664
|
}
|
|
47539
47665
|
if (type === SDKTokenType_1.TokenType.dimension && parsedDefinition !== undefined) {
|
|
@@ -47606,20 +47732,30 @@ class DimensionCategoryToken extends SDKToken_1.Token {
|
|
|
47606
47732
|
}
|
|
47607
47733
|
unit = SDKUnit_1.Unit.raw;
|
|
47608
47734
|
}
|
|
47609
|
-
else if ([SDKTokenType_1.TokenType.borderWidth
|
|
47735
|
+
else if ([SDKTokenType_1.TokenType.borderWidth].includes(type)) {
|
|
47610
47736
|
unit = SDKUnit_1.Unit.pixels;
|
|
47611
47737
|
}
|
|
47612
47738
|
else if (type === SDKTokenType_1.TokenType.duration) {
|
|
47613
47739
|
unit = SDKUnit_1.Unit.ms;
|
|
47614
47740
|
}
|
|
47615
|
-
else if ([
|
|
47741
|
+
else if ([
|
|
47742
|
+
SDKTokenType_1.TokenType.size,
|
|
47743
|
+
SDKTokenType_1.TokenType.space,
|
|
47744
|
+
SDKTokenType_1.TokenType.fontSize,
|
|
47745
|
+
SDKTokenType_1.TokenType.paragraphSpacing,
|
|
47746
|
+
SDKTokenType_1.TokenType.letterSpacing,
|
|
47747
|
+
SDKTokenType_1.TokenType.radius,
|
|
47748
|
+
].includes(type) &&
|
|
47749
|
+
!SDKUnit_1.SIZE_UNITS.includes(unit)) {
|
|
47616
47750
|
unit = SDKUnit_1.Unit.pixels;
|
|
47617
47751
|
}
|
|
47618
|
-
else if (type
|
|
47752
|
+
else if (type === SDKTokenType_1.TokenType.dimension && isUnitless) {
|
|
47619
47753
|
// Fallback to raw, for types that support raw and come unitless
|
|
47620
47754
|
unit = SDKUnit_1.Unit.raw;
|
|
47621
47755
|
}
|
|
47622
|
-
else if (type === SDKTokenType_1.TokenType.lineHeight &&
|
|
47756
|
+
else if (type === SDKTokenType_1.TokenType.lineHeight &&
|
|
47757
|
+
(!SDKUnit_1.LINE_HEIGHT_UNITS.includes(unit) ||
|
|
47758
|
+
(isUnitless && parsedMeasure <= 10))) {
|
|
47623
47759
|
// If the value of line height is larger than 10, import as pixels
|
|
47624
47760
|
// Some reasoning: usually, the raw is used for relative values like 1.4, 1.8, 2.5, etc. where pixels are used when define for absolute values like 12px, 16px, 36px etc
|
|
47625
47761
|
unit = SDKUnit_1.Unit.raw;
|
|
@@ -47681,11 +47817,27 @@ class DimensionCategoryToken extends SDKToken_1.Token {
|
|
|
47681
47817
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
47682
47818
|
return DimensionToken.valueToString(this.value);
|
|
47683
47819
|
}
|
|
47684
|
-
static valueToString(value
|
|
47685
|
-
|
|
47686
|
-
|
|
47687
|
-
|
|
47688
|
-
|
|
47820
|
+
static valueToString(value, options = {
|
|
47821
|
+
maxNumberOfDecimals: 2,
|
|
47822
|
+
clipTrailingZeroes: true,
|
|
47823
|
+
}) {
|
|
47824
|
+
const measureString = this.numberToString(value.measure, options);
|
|
47825
|
+
return `${measureString}${this.unitToString(value.unit)}`;
|
|
47826
|
+
}
|
|
47827
|
+
static numberToString(value, options = {
|
|
47828
|
+
maxNumberOfDecimals: 2,
|
|
47829
|
+
clipTrailingZeroes: true,
|
|
47830
|
+
}) {
|
|
47831
|
+
let measureString = value.toString();
|
|
47832
|
+
if ((options === null || options === void 0 ? void 0 : options.maxNumberOfDecimals) !== undefined) {
|
|
47833
|
+
const factor = Math.pow(10, options.maxNumberOfDecimals);
|
|
47834
|
+
const adjustedMeasure = Math.round(value * factor) / factor;
|
|
47835
|
+
measureString = adjustedMeasure.toFixed(options.maxNumberOfDecimals);
|
|
47836
|
+
}
|
|
47837
|
+
if (options === null || options === void 0 ? void 0 : options.clipTrailingZeroes) {
|
|
47838
|
+
measureString = parseFloat(measureString).toString();
|
|
47839
|
+
}
|
|
47840
|
+
return `${measureString}`;
|
|
47689
47841
|
}
|
|
47690
47842
|
static unitToString(unit) {
|
|
47691
47843
|
switch (unit) {
|
|
@@ -54892,7 +55044,7 @@ class TokenUtilPreviewMetadataGenerator {
|
|
|
54892
55044
|
}
|
|
54893
55045
|
case SDKTokenType_1.TokenType.blur: {
|
|
54894
55046
|
const t = token;
|
|
54895
|
-
return SDKDimensionToken_1.DimensionToken.valueToString(t.value.radius);
|
|
55047
|
+
return SDKDimensionToken_1.DimensionToken.valueToString(t.value.radius, {});
|
|
54896
55048
|
}
|
|
54897
55049
|
case SDKTokenType_1.TokenType.shadow: {
|
|
54898
55050
|
const t = token;
|
|
@@ -54909,16 +55061,16 @@ class TokenUtilPreviewMetadataGenerator {
|
|
|
54909
55061
|
if (layer) {
|
|
54910
55062
|
switch (layer.type) {
|
|
54911
55063
|
case SDKGradientType_1.GradientType.linear:
|
|
54912
|
-
return "linear
|
|
55064
|
+
return "linear";
|
|
54913
55065
|
case SDKGradientType_1.GradientType.angular:
|
|
54914
|
-
return "angular
|
|
55066
|
+
return "angular";
|
|
54915
55067
|
case SDKGradientType_1.GradientType.radial:
|
|
54916
|
-
return "radial
|
|
55068
|
+
return "radial";
|
|
54917
55069
|
default:
|
|
54918
55070
|
throw new Error(`Unknown gradient type`);
|
|
54919
55071
|
}
|
|
54920
55072
|
}
|
|
54921
|
-
return "linear
|
|
55073
|
+
return "linear";
|
|
54922
55074
|
}
|
|
54923
55075
|
case SDKTokenType_1.TokenType.fontFamily: {
|
|
54924
55076
|
const t = token;
|
|
@@ -55472,7 +55624,7 @@ class TokenUtilPreviewReferenceInfoGenerator {
|
|
|
55472
55624
|
key: [this.label("Font weight")],
|
|
55473
55625
|
value: [
|
|
55474
55626
|
{
|
|
55475
|
-
value: t.value.
|
|
55627
|
+
value: t.value.fontWeight.text,
|
|
55476
55628
|
prefersReferenceName: false,
|
|
55477
55629
|
referencedName: (_6 = (_5 = TokenUtils_1.TokenUtils.lookupReference((_4 = (_3 = t.value) === null || _3 === void 0 ? void 0 : _3.fontSize) === null || _4 === void 0 ? void 0 : _4.referencedTokenId, allTokens)) === null || _5 === void 0 ? void 0 : _5.name) !== null && _6 !== void 0 ? _6 : undefined,
|
|
55478
55630
|
},
|
|
@@ -55576,7 +55728,7 @@ class TokenUtilPreviewReferenceInfoGenerator {
|
|
|
55576
55728
|
var _a, _b, _c, _d;
|
|
55577
55729
|
switch (token.tokenType) {
|
|
55578
55730
|
case SDKTokenType_1.TokenType.shadow: {
|
|
55579
|
-
const layer = token.value
|
|
55731
|
+
const layer = token.value[layerIndex];
|
|
55580
55732
|
let shadowType = "";
|
|
55581
55733
|
switch (layer.type) {
|
|
55582
55734
|
case exports_1.ShadowType.drop:
|
|
@@ -55655,7 +55807,7 @@ class TokenUtilPreviewReferenceInfoGenerator {
|
|
|
55655
55807
|
};
|
|
55656
55808
|
}
|
|
55657
55809
|
case SDKTokenType_1.TokenType.gradient: {
|
|
55658
|
-
const layer = token.value
|
|
55810
|
+
const layer = token.value[layerIndex];
|
|
55659
55811
|
const transform = new exports_1.TokenTransform();
|
|
55660
55812
|
const cssString = transform.gradientTokenToCSS(layer);
|
|
55661
55813
|
return {
|
|
@@ -55735,6 +55887,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
55735
55887
|
exports.TokenUtilPreviewSegmentGenerator = void 0;
|
|
55736
55888
|
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
|
|
55737
55889
|
// MARK: - Imports
|
|
55890
|
+
const exports_1 = __webpack_require__(/*! ../../exports */ "./src/exports.ts");
|
|
55738
55891
|
const SDKBorderStyle_1 = __webpack_require__(/*! ../../model/enums/SDKBorderStyle */ "./src/model/enums/SDKBorderStyle.ts");
|
|
55739
55892
|
const SDKTextCase_1 = __webpack_require__(/*! ../../model/enums/SDKTextCase */ "./src/model/enums/SDKTextCase.ts");
|
|
55740
55893
|
const SDKTextDecoration_1 = __webpack_require__(/*! ../../model/enums/SDKTextDecoration */ "./src/model/enums/SDKTextDecoration.ts");
|
|
@@ -55743,29 +55896,33 @@ const SDKVisibilityType_1 = __webpack_require__(/*! ../../model/enums/SDKVisibil
|
|
|
55743
55896
|
const SDKColorToken_1 = __webpack_require__(/*! ../../model/tokens/SDKColorToken */ "./src/model/tokens/SDKColorToken.ts");
|
|
55744
55897
|
const SDKDimensionToken_1 = __webpack_require__(/*! ../../model/tokens/SDKDimensionToken */ "./src/model/tokens/SDKDimensionToken.ts");
|
|
55745
55898
|
const TokenUtils_1 = __webpack_require__(/*! ../../utils/TokenUtils */ "./src/utils/TokenUtils.ts");
|
|
55746
|
-
const SDKToolsTokenTransform_1 = __webpack_require__(/*! ../token-transform/SDKToolsTokenTransform */ "./src/tools/token-transform/SDKToolsTokenTransform.ts");
|
|
55747
55899
|
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
|
|
55748
55900
|
// MARK: - Utility
|
|
55749
55901
|
class TokenUtilPreviewSegmentGenerator {
|
|
55750
55902
|
static resolvedSegmentsForToken(token, allTokens) {
|
|
55751
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42;
|
|
55903
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44;
|
|
55752
55904
|
switch (token.tokenType) {
|
|
55753
55905
|
case SDKTokenType_1.TokenType.color: {
|
|
55754
55906
|
const t = token;
|
|
55755
55907
|
const reference = TokenUtils_1.TokenUtils.lookupReference((_a = t.value) === null || _a === void 0 ? void 0 : _a.referencedTokenId, allTokens);
|
|
55756
|
-
|
|
55908
|
+
let segments = [
|
|
55757
55909
|
{
|
|
55758
55910
|
value: SDKColorToken_1.ColorToken.colorValueToHex6(t.value).toUpperCase(),
|
|
55759
55911
|
prefersReferenceName: true,
|
|
55760
55912
|
referencedName: (_b = reference === null || reference === void 0 ? void 0 : reference.name) !== null && _b !== void 0 ? _b : undefined,
|
|
55761
55913
|
},
|
|
55762
|
-
"separator",
|
|
55763
|
-
{
|
|
55764
|
-
value: `${Math.round(t.value.opacity.measure * 100)}%`,
|
|
55765
|
-
prefersReferenceName: false,
|
|
55766
|
-
referencedName: (_c = reference === null || reference === void 0 ? void 0 : reference.name) !== null && _c !== void 0 ? _c : undefined,
|
|
55767
|
-
},
|
|
55768
55914
|
];
|
|
55915
|
+
if (t.value.opacity.measure !== 1) {
|
|
55916
|
+
segments = segments.concat([
|
|
55917
|
+
"separator",
|
|
55918
|
+
{
|
|
55919
|
+
value: `${Math.round(t.value.opacity.measure * 100)}%`,
|
|
55920
|
+
prefersReferenceName: false,
|
|
55921
|
+
referencedName: (_c = reference === null || reference === void 0 ? void 0 : reference.name) !== null && _c !== void 0 ? _c : undefined,
|
|
55922
|
+
},
|
|
55923
|
+
]);
|
|
55924
|
+
}
|
|
55925
|
+
return segments;
|
|
55769
55926
|
}
|
|
55770
55927
|
case SDKTokenType_1.TokenType.blur: {
|
|
55771
55928
|
const t = token;
|
|
@@ -55780,24 +55937,73 @@ class TokenUtilPreviewSegmentGenerator {
|
|
|
55780
55937
|
}
|
|
55781
55938
|
case SDKTokenType_1.TokenType.shadow: {
|
|
55782
55939
|
const t = token;
|
|
55783
|
-
|
|
55784
|
-
|
|
55940
|
+
if (t.value.length === 1) {
|
|
55941
|
+
return TokenUtilPreviewSegmentGenerator.shadowValuesToSegments(t.value[0], allTokens);
|
|
55942
|
+
}
|
|
55943
|
+
// For multiple shadows, we just show the number of layers
|
|
55944
|
+
return [
|
|
55945
|
+
{
|
|
55946
|
+
value: t.value.length > 0
|
|
55947
|
+
? `${t.value.length} shadow layers`
|
|
55948
|
+
: `No shadow layers`,
|
|
55949
|
+
prefersReferenceName: false,
|
|
55950
|
+
referencedName: undefined,
|
|
55951
|
+
},
|
|
55952
|
+
];
|
|
55785
55953
|
}
|
|
55786
55954
|
case SDKTokenType_1.TokenType.gradient: {
|
|
55787
55955
|
const t = token;
|
|
55788
55956
|
const layer = t.value[0];
|
|
55789
|
-
|
|
55790
|
-
const cssString = transform.gradientTokenToCSS(layer);
|
|
55957
|
+
let type = "";
|
|
55791
55958
|
if (layer) {
|
|
55792
|
-
|
|
55793
|
-
|
|
55794
|
-
|
|
55795
|
-
|
|
55796
|
-
|
|
55797
|
-
|
|
55798
|
-
|
|
55959
|
+
switch (layer.type) {
|
|
55960
|
+
case exports_1.GradientType.linear:
|
|
55961
|
+
type = "linear";
|
|
55962
|
+
break;
|
|
55963
|
+
case exports_1.GradientType.angular:
|
|
55964
|
+
type = "angular";
|
|
55965
|
+
break;
|
|
55966
|
+
case exports_1.GradientType.radial:
|
|
55967
|
+
type = "radial";
|
|
55968
|
+
break;
|
|
55969
|
+
default:
|
|
55970
|
+
throw new Error(`Unknown gradient type`);
|
|
55971
|
+
}
|
|
55799
55972
|
}
|
|
55800
|
-
return [
|
|
55973
|
+
return [
|
|
55974
|
+
{
|
|
55975
|
+
value: type,
|
|
55976
|
+
prefersReferenceName: false,
|
|
55977
|
+
referencedName: undefined,
|
|
55978
|
+
},
|
|
55979
|
+
];
|
|
55980
|
+
/*
|
|
55981
|
+
if (t.value.length === 1) {
|
|
55982
|
+
const layer = t.value[0]
|
|
55983
|
+
const transform = new TokenTransform()
|
|
55984
|
+
const cssString = transform.gradientTokenToCSS(layer)
|
|
55985
|
+
|
|
55986
|
+
return [
|
|
55987
|
+
{
|
|
55988
|
+
value: cssString,
|
|
55989
|
+
prefersReferenceName: false,
|
|
55990
|
+
referencedName: undefined,
|
|
55991
|
+
},
|
|
55992
|
+
]
|
|
55993
|
+
}
|
|
55994
|
+
|
|
55995
|
+
// For multiple gradients, we just show the number of layers
|
|
55996
|
+
return [
|
|
55997
|
+
{
|
|
55998
|
+
value:
|
|
55999
|
+
t.value.length > 0
|
|
56000
|
+
? `${t.value.length} gradient layers`
|
|
56001
|
+
: `No gradient layers`,
|
|
56002
|
+
prefersReferenceName: false,
|
|
56003
|
+
referencedName: undefined,
|
|
56004
|
+
},
|
|
56005
|
+
]
|
|
56006
|
+
*/
|
|
55801
56007
|
}
|
|
55802
56008
|
case SDKTokenType_1.TokenType.fontFamily: {
|
|
55803
56009
|
const t = token;
|
|
@@ -55870,7 +56076,7 @@ class TokenUtilPreviewSegmentGenerator {
|
|
|
55870
56076
|
const reference = TokenUtils_1.TokenUtils.lookupReference((_t = t.value) === null || _t === void 0 ? void 0 : _t.referencedTokenId, allTokens);
|
|
55871
56077
|
return [
|
|
55872
56078
|
{
|
|
55873
|
-
value: `${t.value.measure}
|
|
56079
|
+
value: `${Math.round(t.value.measure * 100)}%`,
|
|
55874
56080
|
prefersReferenceName: false,
|
|
55875
56081
|
referencedName: (_u = reference === null || reference === void 0 ? void 0 : reference.name) !== null && _u !== void 0 ? _u : undefined,
|
|
55876
56082
|
},
|
|
@@ -55895,7 +56101,7 @@ class TokenUtilPreviewSegmentGenerator {
|
|
|
55895
56101
|
default:
|
|
55896
56102
|
break;
|
|
55897
56103
|
}
|
|
55898
|
-
|
|
56104
|
+
let segments = [
|
|
55899
56105
|
{
|
|
55900
56106
|
value: SDKDimensionToken_1.DimensionToken.valueToString(t.value.width),
|
|
55901
56107
|
prefersReferenceName: false,
|
|
@@ -55907,53 +56113,65 @@ class TokenUtilPreviewSegmentGenerator {
|
|
|
55907
56113
|
referencedName: undefined,
|
|
55908
56114
|
},
|
|
55909
56115
|
{
|
|
55910
|
-
value: SDKColorToken_1.ColorToken.
|
|
56116
|
+
value: SDKColorToken_1.ColorToken.colorValueToHex6(t.value.color).toUpperCase(),
|
|
55911
56117
|
prefersReferenceName: true,
|
|
55912
56118
|
referencedName: (_2 = (_1 = TokenUtils_1.TokenUtils.lookupReference((_0 = (_z = t.value) === null || _z === void 0 ? void 0 : _z.color) === null || _0 === void 0 ? void 0 : _0.referencedTokenId, allTokens)) === null || _1 === void 0 ? void 0 : _1.name) !== null && _2 !== void 0 ? _2 : undefined,
|
|
55913
56119
|
},
|
|
55914
56120
|
];
|
|
56121
|
+
if (t.value.color.opacity.measure < 1) {
|
|
56122
|
+
// Only add opacity if it is not 100%
|
|
56123
|
+
segments = segments.concat([
|
|
56124
|
+
"separator",
|
|
56125
|
+
{
|
|
56126
|
+
value: `${Math.round(t.value.color.opacity.measure * 100)}%`,
|
|
56127
|
+
prefersReferenceName: false,
|
|
56128
|
+
referencedName: (_4 = (_3 = TokenUtils_1.TokenUtils.lookupReference(t.value.color.opacity.referencedTokenId, allTokens)) === null || _3 === void 0 ? void 0 : _3.name) !== null && _4 !== void 0 ? _4 : undefined,
|
|
56129
|
+
},
|
|
56130
|
+
]);
|
|
56131
|
+
}
|
|
56132
|
+
return segments;
|
|
55915
56133
|
}
|
|
55916
56134
|
case SDKTokenType_1.TokenType.radius: {
|
|
55917
56135
|
const t = token;
|
|
55918
|
-
const reference = TokenUtils_1.TokenUtils.lookupReference((
|
|
56136
|
+
const reference = TokenUtils_1.TokenUtils.lookupReference((_5 = t.value) === null || _5 === void 0 ? void 0 : _5.referencedTokenId, allTokens);
|
|
55919
56137
|
return [
|
|
55920
56138
|
{
|
|
55921
56139
|
value: SDKDimensionToken_1.DimensionToken.valueToString(t.value),
|
|
55922
56140
|
prefersReferenceName: false,
|
|
55923
|
-
referencedName: (
|
|
56141
|
+
referencedName: (_6 = reference === null || reference === void 0 ? void 0 : reference.name) !== null && _6 !== void 0 ? _6 : undefined,
|
|
55924
56142
|
},
|
|
55925
56143
|
];
|
|
55926
56144
|
}
|
|
55927
56145
|
case SDKTokenType_1.TokenType.borderWidth: {
|
|
55928
56146
|
const t = token;
|
|
55929
|
-
const reference = TokenUtils_1.TokenUtils.lookupReference((
|
|
56147
|
+
const reference = TokenUtils_1.TokenUtils.lookupReference((_7 = t.value) === null || _7 === void 0 ? void 0 : _7.referencedTokenId, allTokens);
|
|
55930
56148
|
return [
|
|
55931
56149
|
{
|
|
55932
56150
|
value: SDKDimensionToken_1.DimensionToken.valueToString(t.value),
|
|
55933
56151
|
prefersReferenceName: false,
|
|
55934
|
-
referencedName: (
|
|
56152
|
+
referencedName: (_8 = reference === null || reference === void 0 ? void 0 : reference.name) !== null && _8 !== void 0 ? _8 : undefined,
|
|
55935
56153
|
},
|
|
55936
56154
|
];
|
|
55937
56155
|
}
|
|
55938
56156
|
case SDKTokenType_1.TokenType.duration: {
|
|
55939
56157
|
const t = token;
|
|
55940
|
-
const reference = TokenUtils_1.TokenUtils.lookupReference((
|
|
56158
|
+
const reference = TokenUtils_1.TokenUtils.lookupReference((_9 = t.value) === null || _9 === void 0 ? void 0 : _9.referencedTokenId, allTokens);
|
|
55941
56159
|
return [
|
|
55942
56160
|
{
|
|
55943
56161
|
value: SDKDimensionToken_1.DimensionToken.valueToString(t.value),
|
|
55944
56162
|
prefersReferenceName: false,
|
|
55945
|
-
referencedName: (
|
|
56163
|
+
referencedName: (_10 = reference === null || reference === void 0 ? void 0 : reference.name) !== null && _10 !== void 0 ? _10 : undefined,
|
|
55946
56164
|
},
|
|
55947
56165
|
];
|
|
55948
56166
|
}
|
|
55949
56167
|
case SDKTokenType_1.TokenType.zIndex: {
|
|
55950
56168
|
const t = token;
|
|
55951
|
-
const reference = TokenUtils_1.TokenUtils.lookupReference((
|
|
56169
|
+
const reference = TokenUtils_1.TokenUtils.lookupReference((_11 = t.value) === null || _11 === void 0 ? void 0 : _11.referencedTokenId, allTokens);
|
|
55952
56170
|
return [
|
|
55953
56171
|
{
|
|
55954
56172
|
value: SDKDimensionToken_1.DimensionToken.valueToString(t.value),
|
|
55955
56173
|
prefersReferenceName: false,
|
|
55956
|
-
referencedName: (
|
|
56174
|
+
referencedName: (_12 = reference === null || reference === void 0 ? void 0 : reference.name) !== null && _12 !== void 0 ? _12 : undefined,
|
|
55957
56175
|
},
|
|
55958
56176
|
];
|
|
55959
56177
|
}
|
|
@@ -55979,12 +56197,12 @@ class TokenUtilPreviewSegmentGenerator {
|
|
|
55979
56197
|
default:
|
|
55980
56198
|
throw new Error("Unknown text case");
|
|
55981
56199
|
}
|
|
55982
|
-
const reference = TokenUtils_1.TokenUtils.lookupReference((
|
|
56200
|
+
const reference = TokenUtils_1.TokenUtils.lookupReference((_13 = t.value) === null || _13 === void 0 ? void 0 : _13.referencedTokenId, allTokens);
|
|
55983
56201
|
return [
|
|
55984
56202
|
{
|
|
55985
56203
|
value,
|
|
55986
56204
|
prefersReferenceName: false,
|
|
55987
|
-
referencedName: (
|
|
56205
|
+
referencedName: (_14 = reference === null || reference === void 0 ? void 0 : reference.name) !== null && _14 !== void 0 ? _14 : undefined,
|
|
55988
56206
|
},
|
|
55989
56207
|
];
|
|
55990
56208
|
}
|
|
@@ -56004,12 +56222,12 @@ class TokenUtilPreviewSegmentGenerator {
|
|
|
56004
56222
|
default:
|
|
56005
56223
|
throw new Error("Unknown text decoration option");
|
|
56006
56224
|
}
|
|
56007
|
-
const reference = TokenUtils_1.TokenUtils.lookupReference((
|
|
56225
|
+
const reference = TokenUtils_1.TokenUtils.lookupReference((_15 = t.value) === null || _15 === void 0 ? void 0 : _15.referencedTokenId, allTokens);
|
|
56008
56226
|
return [
|
|
56009
56227
|
{
|
|
56010
56228
|
value,
|
|
56011
56229
|
prefersReferenceName: false,
|
|
56012
|
-
referencedName: (
|
|
56230
|
+
referencedName: (_16 = reference === null || reference === void 0 ? void 0 : reference.name) !== null && _16 !== void 0 ? _16 : undefined,
|
|
56013
56231
|
},
|
|
56014
56232
|
];
|
|
56015
56233
|
}
|
|
@@ -56026,67 +56244,67 @@ class TokenUtilPreviewSegmentGenerator {
|
|
|
56026
56244
|
default:
|
|
56027
56245
|
throw new Error("Unknown visibility option");
|
|
56028
56246
|
}
|
|
56029
|
-
const reference = TokenUtils_1.TokenUtils.lookupReference((
|
|
56247
|
+
const reference = TokenUtils_1.TokenUtils.lookupReference((_17 = t.value) === null || _17 === void 0 ? void 0 : _17.referencedTokenId, allTokens);
|
|
56030
56248
|
return [
|
|
56031
56249
|
{
|
|
56032
56250
|
value,
|
|
56033
56251
|
prefersReferenceName: false,
|
|
56034
|
-
referencedName: (
|
|
56252
|
+
referencedName: (_18 = reference === null || reference === void 0 ? void 0 : reference.name) !== null && _18 !== void 0 ? _18 : undefined,
|
|
56035
56253
|
},
|
|
56036
56254
|
];
|
|
56037
56255
|
}
|
|
56038
56256
|
case SDKTokenType_1.TokenType.productCopy: {
|
|
56039
56257
|
const t = token;
|
|
56040
|
-
const reference = TokenUtils_1.TokenUtils.lookupReference((
|
|
56258
|
+
const reference = TokenUtils_1.TokenUtils.lookupReference((_19 = t.value) === null || _19 === void 0 ? void 0 : _19.referencedTokenId, allTokens);
|
|
56041
56259
|
return [
|
|
56042
56260
|
{
|
|
56043
56261
|
value: t.value.text,
|
|
56044
56262
|
prefersReferenceName: false,
|
|
56045
|
-
referencedName: (
|
|
56263
|
+
referencedName: (_20 = reference === null || reference === void 0 ? void 0 : reference.name) !== null && _20 !== void 0 ? _20 : undefined,
|
|
56046
56264
|
},
|
|
56047
56265
|
];
|
|
56048
56266
|
}
|
|
56049
56267
|
case SDKTokenType_1.TokenType.string: {
|
|
56050
56268
|
const t = token;
|
|
56051
|
-
const reference = TokenUtils_1.TokenUtils.lookupReference((
|
|
56269
|
+
const reference = TokenUtils_1.TokenUtils.lookupReference((_21 = t.value) === null || _21 === void 0 ? void 0 : _21.referencedTokenId, allTokens);
|
|
56052
56270
|
return [
|
|
56053
56271
|
{
|
|
56054
56272
|
value: t.value.text,
|
|
56055
56273
|
prefersReferenceName: false,
|
|
56056
|
-
referencedName: (
|
|
56274
|
+
referencedName: (_22 = reference === null || reference === void 0 ? void 0 : reference.name) !== null && _22 !== void 0 ? _22 : undefined,
|
|
56057
56275
|
},
|
|
56058
56276
|
];
|
|
56059
56277
|
}
|
|
56060
56278
|
case SDKTokenType_1.TokenType.dimension: {
|
|
56061
56279
|
const t = token;
|
|
56062
|
-
const reference = TokenUtils_1.TokenUtils.lookupReference((
|
|
56280
|
+
const reference = TokenUtils_1.TokenUtils.lookupReference((_23 = t.value) === null || _23 === void 0 ? void 0 : _23.referencedTokenId, allTokens);
|
|
56063
56281
|
return [
|
|
56064
56282
|
{
|
|
56065
56283
|
value: SDKDimensionToken_1.DimensionToken.valueToString(t.value),
|
|
56066
56284
|
prefersReferenceName: false,
|
|
56067
|
-
referencedName: (
|
|
56285
|
+
referencedName: (_24 = reference === null || reference === void 0 ? void 0 : reference.name) !== null && _24 !== void 0 ? _24 : undefined,
|
|
56068
56286
|
},
|
|
56069
56287
|
];
|
|
56070
56288
|
}
|
|
56071
56289
|
case SDKTokenType_1.TokenType.size: {
|
|
56072
56290
|
const t = token;
|
|
56073
|
-
const reference = TokenUtils_1.TokenUtils.lookupReference((
|
|
56291
|
+
const reference = TokenUtils_1.TokenUtils.lookupReference((_25 = t.value) === null || _25 === void 0 ? void 0 : _25.referencedTokenId, allTokens);
|
|
56074
56292
|
return [
|
|
56075
56293
|
{
|
|
56076
56294
|
value: SDKDimensionToken_1.DimensionToken.valueToString(t.value),
|
|
56077
56295
|
prefersReferenceName: false,
|
|
56078
|
-
referencedName: (
|
|
56296
|
+
referencedName: (_26 = reference === null || reference === void 0 ? void 0 : reference.name) !== null && _26 !== void 0 ? _26 : undefined,
|
|
56079
56297
|
},
|
|
56080
56298
|
];
|
|
56081
56299
|
}
|
|
56082
56300
|
case SDKTokenType_1.TokenType.space: {
|
|
56083
56301
|
const t = token;
|
|
56084
|
-
const reference = TokenUtils_1.TokenUtils.lookupReference((
|
|
56302
|
+
const reference = TokenUtils_1.TokenUtils.lookupReference((_27 = t.value) === null || _27 === void 0 ? void 0 : _27.referencedTokenId, allTokens);
|
|
56085
56303
|
return [
|
|
56086
56304
|
{
|
|
56087
56305
|
value: SDKDimensionToken_1.DimensionToken.valueToString(t.value),
|
|
56088
56306
|
prefersReferenceName: false,
|
|
56089
|
-
referencedName: (
|
|
56307
|
+
referencedName: (_28 = reference === null || reference === void 0 ? void 0 : reference.name) !== null && _28 !== void 0 ? _28 : undefined,
|
|
56090
56308
|
},
|
|
56091
56309
|
];
|
|
56092
56310
|
}
|
|
@@ -56099,7 +56317,7 @@ class TokenUtilPreviewSegmentGenerator {
|
|
|
56099
56317
|
{
|
|
56100
56318
|
value: SDKDimensionToken_1.DimensionToken.valueToString(t.value.lineHeight),
|
|
56101
56319
|
prefersReferenceName: false,
|
|
56102
|
-
referencedName: (
|
|
56320
|
+
referencedName: (_32 = (_31 = TokenUtils_1.TokenUtils.lookupReference((_30 = (_29 = t.value) === null || _29 === void 0 ? void 0 : _29.lineHeight) === null || _30 === void 0 ? void 0 : _30.referencedTokenId, allTokens)) === null || _31 === void 0 ? void 0 : _31.name) !== null && _32 !== void 0 ? _32 : undefined,
|
|
56103
56321
|
},
|
|
56104
56322
|
];
|
|
56105
56323
|
}
|
|
@@ -56107,18 +56325,18 @@ class TokenUtilPreviewSegmentGenerator {
|
|
|
56107
56325
|
{
|
|
56108
56326
|
value: SDKDimensionToken_1.DimensionToken.valueToString(t.value.fontSize),
|
|
56109
56327
|
prefersReferenceName: false,
|
|
56110
|
-
referencedName: (
|
|
56328
|
+
referencedName: (_36 = (_35 = TokenUtils_1.TokenUtils.lookupReference((_34 = (_33 = t.value) === null || _33 === void 0 ? void 0 : _33.fontSize) === null || _34 === void 0 ? void 0 : _34.referencedTokenId, allTokens)) === null || _35 === void 0 ? void 0 : _35.name) !== null && _36 !== void 0 ? _36 : undefined,
|
|
56111
56329
|
},
|
|
56112
56330
|
...lineHeightFragments,
|
|
56113
56331
|
{
|
|
56114
|
-
value: t.value.
|
|
56332
|
+
value: t.value.fontFamily.text,
|
|
56115
56333
|
prefersReferenceName: false,
|
|
56116
|
-
referencedName: (
|
|
56334
|
+
referencedName: (_40 = (_39 = TokenUtils_1.TokenUtils.lookupReference((_38 = (_37 = t.value) === null || _37 === void 0 ? void 0 : _37.fontFamily) === null || _38 === void 0 ? void 0 : _38.referencedTokenId, allTokens)) === null || _39 === void 0 ? void 0 : _39.name) !== null && _40 !== void 0 ? _40 : undefined,
|
|
56117
56335
|
},
|
|
56118
56336
|
{
|
|
56119
|
-
value: t.value.
|
|
56337
|
+
value: t.value.fontWeight.text,
|
|
56120
56338
|
prefersReferenceName: false,
|
|
56121
|
-
referencedName: (
|
|
56339
|
+
referencedName: (_44 = (_43 = TokenUtils_1.TokenUtils.lookupReference((_42 = (_41 = t.value) === null || _41 === void 0 ? void 0 : _41.fontWeight) === null || _42 === void 0 ? void 0 : _42.referencedTokenId, allTokens)) === null || _43 === void 0 ? void 0 : _43.name) !== null && _44 !== void 0 ? _44 : undefined,
|
|
56122
56340
|
},
|
|
56123
56341
|
];
|
|
56124
56342
|
}
|
|
@@ -56131,24 +56349,28 @@ class TokenUtilPreviewSegmentGenerator {
|
|
|
56131
56349
|
if (!layer) {
|
|
56132
56350
|
return [];
|
|
56133
56351
|
}
|
|
56134
|
-
|
|
56352
|
+
let segments = [
|
|
56135
56353
|
{
|
|
56136
|
-
value: layer.x === 0 ? `0` : `${layer.x}px`,
|
|
56354
|
+
value: layer.x === 0 ? `0` : `${SDKDimensionToken_1.DimensionToken.numberToString(layer.x)}px`,
|
|
56137
56355
|
prefersReferenceName: false,
|
|
56138
56356
|
referencedName: undefined,
|
|
56139
56357
|
},
|
|
56140
56358
|
{
|
|
56141
|
-
value: layer.y === 0 ? `0` : `${layer.y}px`,
|
|
56359
|
+
value: layer.y === 0 ? `0` : `${SDKDimensionToken_1.DimensionToken.numberToString(layer.y)}px`,
|
|
56142
56360
|
prefersReferenceName: false,
|
|
56143
56361
|
referencedName: undefined,
|
|
56144
56362
|
},
|
|
56145
56363
|
{
|
|
56146
|
-
value: layer.radius === 0
|
|
56364
|
+
value: layer.radius === 0
|
|
56365
|
+
? `0`
|
|
56366
|
+
: `${SDKDimensionToken_1.DimensionToken.numberToString(layer.radius)}px`,
|
|
56147
56367
|
prefersReferenceName: false,
|
|
56148
56368
|
referencedName: undefined,
|
|
56149
56369
|
},
|
|
56150
56370
|
{
|
|
56151
|
-
value: layer.spread === 0
|
|
56371
|
+
value: layer.spread === 0
|
|
56372
|
+
? `0`
|
|
56373
|
+
: `${SDKDimensionToken_1.DimensionToken.numberToString(layer.spread)}px`,
|
|
56152
56374
|
prefersReferenceName: false,
|
|
56153
56375
|
referencedName: undefined,
|
|
56154
56376
|
},
|
|
@@ -56157,13 +56379,19 @@ class TokenUtilPreviewSegmentGenerator {
|
|
|
56157
56379
|
prefersReferenceName: true,
|
|
56158
56380
|
referencedName: (_b = (_a = TokenUtils_1.TokenUtils.lookupReference(layer.color.referencedTokenId, allTokens)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : undefined,
|
|
56159
56381
|
},
|
|
56160
|
-
"separator",
|
|
56161
|
-
{
|
|
56162
|
-
value: `${Math.round(layer.opacity.measure * 100)}%`,
|
|
56163
|
-
prefersReferenceName: false,
|
|
56164
|
-
referencedName: (_d = (_c = TokenUtils_1.TokenUtils.lookupReference(layer.opacity.referencedTokenId, allTokens)) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : undefined,
|
|
56165
|
-
},
|
|
56166
56382
|
];
|
|
56383
|
+
if (layer.opacity.measure < 1) {
|
|
56384
|
+
// Only add opacity if it is not 100%
|
|
56385
|
+
segments = segments.concat([
|
|
56386
|
+
"separator",
|
|
56387
|
+
{
|
|
56388
|
+
value: `${Math.round(layer.opacity.measure * 100)}%`,
|
|
56389
|
+
prefersReferenceName: false,
|
|
56390
|
+
referencedName: (_d = (_c = TokenUtils_1.TokenUtils.lookupReference(layer.opacity.referencedTokenId, allTokens)) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : undefined,
|
|
56391
|
+
},
|
|
56392
|
+
]);
|
|
56393
|
+
}
|
|
56394
|
+
return segments;
|
|
56167
56395
|
}
|
|
56168
56396
|
}
|
|
56169
56397
|
exports.TokenUtilPreviewSegmentGenerator = TokenUtilPreviewSegmentGenerator;
|
|
@@ -56268,6 +56496,7 @@ class TokenUtilPreviewStyleGenerator {
|
|
|
56268
56496
|
case SDKTokenType_1.TokenType.border: {
|
|
56269
56497
|
const t = token;
|
|
56270
56498
|
let style = "solid";
|
|
56499
|
+
const widthCssUnit = SDKDimensionToken_1.DimensionToken.unitToString(t.value.width.unit);
|
|
56271
56500
|
switch (t.value.style) {
|
|
56272
56501
|
case SDKBorderStyle_1.BorderStyle.dashed:
|
|
56273
56502
|
style = "dashed";
|
|
@@ -56279,21 +56508,23 @@ class TokenUtilPreviewStyleGenerator {
|
|
|
56279
56508
|
break;
|
|
56280
56509
|
}
|
|
56281
56510
|
return {
|
|
56282
|
-
borderWidth: `${t.value.width.measure}
|
|
56511
|
+
borderWidth: `${t.value.width.measure}${widthCssUnit}`,
|
|
56283
56512
|
borderColor: SDKColorToken_1.ColorToken.colorValueToHex8(t.value.color).toUpperCase(),
|
|
56284
56513
|
borderStyle: style,
|
|
56285
56514
|
};
|
|
56286
56515
|
}
|
|
56287
56516
|
case SDKTokenType_1.TokenType.radius: {
|
|
56288
56517
|
const t = token;
|
|
56518
|
+
const cssUnit = SDKDimensionToken_1.DimensionToken.unitToString(t.value.unit);
|
|
56289
56519
|
return {
|
|
56290
|
-
borderRadius: `${t.value.measure}
|
|
56520
|
+
borderRadius: `${t.value.measure}${cssUnit}`,
|
|
56291
56521
|
};
|
|
56292
56522
|
}
|
|
56293
56523
|
case SDKTokenType_1.TokenType.borderWidth: {
|
|
56294
56524
|
const t = token;
|
|
56525
|
+
const cssUnit = SDKDimensionToken_1.DimensionToken.unitToString(t.value.unit);
|
|
56295
56526
|
return {
|
|
56296
|
-
borderWidth: `${t.value.measure}${
|
|
56527
|
+
borderWidth: `${t.value.measure}${cssUnit}`,
|
|
56297
56528
|
};
|
|
56298
56529
|
}
|
|
56299
56530
|
case SDKTokenType_1.TokenType.duration: {
|
|
@@ -56343,7 +56574,7 @@ class TokenUtilPreviewStyleGenerator {
|
|
|
56343
56574
|
? SDKDimensionToken_1.DimensionToken.valueToString(t.value.lineHeight)
|
|
56344
56575
|
: undefined,
|
|
56345
56576
|
fontWeight: t.value.fontWeight.text,
|
|
56346
|
-
fontFamily: t.value.
|
|
56577
|
+
fontFamily: t.value.fontFamily.text,
|
|
56347
56578
|
};
|
|
56348
56579
|
}
|
|
56349
56580
|
default:
|
|
@@ -56554,6 +56785,81 @@ class TokenTransform {
|
|
|
56554
56785
|
exports.TokenTransform = TokenTransform;
|
|
56555
56786
|
|
|
56556
56787
|
|
|
56788
|
+
/***/ }),
|
|
56789
|
+
|
|
56790
|
+
/***/ "./src/utils/ComponentUtils.ts":
|
|
56791
|
+
/*!*************************************!*\
|
|
56792
|
+
!*** ./src/utils/ComponentUtils.ts ***!
|
|
56793
|
+
\*************************************/
|
|
56794
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
56795
|
+
|
|
56796
|
+
"use strict";
|
|
56797
|
+
|
|
56798
|
+
//
|
|
56799
|
+
// ComponentUtils.ts
|
|
56800
|
+
// Supernova SDK
|
|
56801
|
+
//
|
|
56802
|
+
// Created by Jiri Trecak.
|
|
56803
|
+
//
|
|
56804
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
56805
|
+
exports.ComponentUtils = void 0;
|
|
56806
|
+
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
|
|
56807
|
+
// MARK: - Imports
|
|
56808
|
+
const SDKComponent_1 = __webpack_require__(/*! ../model/components/SDKComponent */ "./src/model/components/SDKComponent.ts");
|
|
56809
|
+
const SDKComponentGroup_1 = __webpack_require__(/*! ../model/groups/SDKComponentGroup */ "./src/model/groups/SDKComponentGroup.ts");
|
|
56810
|
+
const uuid_1 = __webpack_require__(/*! uuid */ "../../node_modules/uuid/dist/esm-node/index.js");
|
|
56811
|
+
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
|
|
56812
|
+
// MARK: - Component utilities
|
|
56813
|
+
class ComponentUtils {
|
|
56814
|
+
/** Map components for lookup */
|
|
56815
|
+
static componentsToReferenceMap(components) {
|
|
56816
|
+
const map = new Map();
|
|
56817
|
+
components.forEach((component) => {
|
|
56818
|
+
map.set(component.id, component);
|
|
56819
|
+
});
|
|
56820
|
+
return map;
|
|
56821
|
+
}
|
|
56822
|
+
/** Map component groups for lookup */
|
|
56823
|
+
static componentGroupsToReferenceMap(groups) {
|
|
56824
|
+
const map = new Map();
|
|
56825
|
+
groups.forEach((group) => {
|
|
56826
|
+
map.set(group.id, group);
|
|
56827
|
+
});
|
|
56828
|
+
return map;
|
|
56829
|
+
}
|
|
56830
|
+
/** Creates a new component group. Default values will be used for all properties */
|
|
56831
|
+
static createDefaultComponentGroup(versionId, brandId, name) {
|
|
56832
|
+
return new SDKComponentGroup_1.ComponentGroup({
|
|
56833
|
+
id: undefined,
|
|
56834
|
+
persistentId: (0, uuid_1.v4)(),
|
|
56835
|
+
brandId,
|
|
56836
|
+
designSystemVersionId: versionId,
|
|
56837
|
+
isRoot: false,
|
|
56838
|
+
meta: {
|
|
56839
|
+
name: name !== null && name !== void 0 ? name : "Group",
|
|
56840
|
+
description: "",
|
|
56841
|
+
},
|
|
56842
|
+
childrenIds: [],
|
|
56843
|
+
createdAt: new Date().toISOString(),
|
|
56844
|
+
});
|
|
56845
|
+
}
|
|
56846
|
+
/** Creates a new component. Default values will be used for all properties */
|
|
56847
|
+
static createDefaultComponent(versionId, brandId, name) {
|
|
56848
|
+
return new SDKComponent_1.Component({
|
|
56849
|
+
id: undefined,
|
|
56850
|
+
persistentId: (0, uuid_1.v4)(),
|
|
56851
|
+
brandId,
|
|
56852
|
+
designSystemVersionId: versionId,
|
|
56853
|
+
meta: {
|
|
56854
|
+
name: name !== null && name !== void 0 ? name : "Group",
|
|
56855
|
+
description: "",
|
|
56856
|
+
},
|
|
56857
|
+
}, [], []);
|
|
56858
|
+
}
|
|
56859
|
+
}
|
|
56860
|
+
exports.ComponentUtils = ComponentUtils;
|
|
56861
|
+
|
|
56862
|
+
|
|
56557
56863
|
/***/ }),
|
|
56558
56864
|
|
|
56559
56865
|
/***/ "./src/utils/StringUtils.ts":
|
|
@@ -57083,6 +57389,7 @@ exports.TokenUtils = void 0;
|
|
|
57083
57389
|
// MARK: - Imports
|
|
57084
57390
|
const exports_1 = __webpack_require__(/*! ../exports */ "./src/exports.ts");
|
|
57085
57391
|
const SDKTokenType_1 = __webpack_require__(/*! ../model/enums/SDKTokenType */ "./src/model/enums/SDKTokenType.ts");
|
|
57392
|
+
const SDKThemeUtilities_1 = __webpack_require__(/*! ../model/themes/SDKThemeUtilities */ "./src/model/themes/SDKThemeUtilities.ts");
|
|
57086
57393
|
const SDKBlurToken_1 = __webpack_require__(/*! ../model/tokens/SDKBlurToken */ "./src/model/tokens/SDKBlurToken.ts");
|
|
57087
57394
|
const SDKBorderToken_1 = __webpack_require__(/*! ../model/tokens/SDKBorderToken */ "./src/model/tokens/SDKBorderToken.ts");
|
|
57088
57395
|
const SDKColorToken_1 = __webpack_require__(/*! ../model/tokens/SDKColorToken */ "./src/model/tokens/SDKColorToken.ts");
|
|
@@ -57097,7 +57404,10 @@ const SDKTypographyToken_1 = __webpack_require__(/*! ../model/tokens/SDKTypograp
|
|
|
57097
57404
|
const SDKVisibilityToken_1 = __webpack_require__(/*! ../model/tokens/SDKVisibilityToken */ "./src/model/tokens/SDKVisibilityToken.ts");
|
|
57098
57405
|
const SDKDTTokenReferenceResolver_1 = __webpack_require__(/*! ../tools/design-tokens/utilities/SDKDTTokenReferenceResolver */ "./src/tools/design-tokens/utilities/SDKDTTokenReferenceResolver.ts");
|
|
57099
57406
|
const lodash_1 = __webpack_require__(/*! lodash */ "../../node_modules/lodash/lodash.js");
|
|
57407
|
+
const lodash_2 = __webpack_require__(/*! lodash */ "../../node_modules/lodash/lodash.js");
|
|
57100
57408
|
const uuid_1 = __webpack_require__(/*! uuid */ "../../node_modules/uuid/dist/esm-node/index.js");
|
|
57409
|
+
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
|
|
57410
|
+
// MARK: - Implementation
|
|
57101
57411
|
class TokenUtils {
|
|
57102
57412
|
/** Map tokens for lookup */
|
|
57103
57413
|
static tokensToReferenceMap(tokens) {
|
|
@@ -57452,6 +57762,728 @@ class TokenUtils {
|
|
|
57452
57762
|
}
|
|
57453
57763
|
}
|
|
57454
57764
|
}
|
|
57765
|
+
/** Creates a new theme with updated overrides */
|
|
57766
|
+
static tokenThemeByUpdatingOverride(theme, override) {
|
|
57767
|
+
const overrides = theme.overriddenTokens;
|
|
57768
|
+
const filteredOverrides = overrides.filter((o) => o.id !== override.id);
|
|
57769
|
+
filteredOverrides.push(override);
|
|
57770
|
+
theme.overriddenTokens = filteredOverrides;
|
|
57771
|
+
return theme;
|
|
57772
|
+
}
|
|
57773
|
+
/** Creates a new theme with removed override */
|
|
57774
|
+
static tokenThemeByRemovingOverride(theme, tokenId) {
|
|
57775
|
+
const overrides = theme.overriddenTokens;
|
|
57776
|
+
const filteredOverrides = overrides.filter((o) => o.id !== tokenId && o.idInVersion !== tokenId);
|
|
57777
|
+
theme.overriddenTokens = filteredOverrides;
|
|
57778
|
+
return theme;
|
|
57779
|
+
}
|
|
57780
|
+
/** Creates a new color token with updated .color value */
|
|
57781
|
+
static colorTokenByUpdatingColor(token, newValue) {
|
|
57782
|
+
this.checkNotReference(token);
|
|
57783
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
57784
|
+
if (newValue instanceof SDKColorToken_1.ColorToken) {
|
|
57785
|
+
update.value = {
|
|
57786
|
+
opacity: update.value.opacity,
|
|
57787
|
+
color: {
|
|
57788
|
+
r: newValue.value.color.r,
|
|
57789
|
+
g: newValue.value.color.g,
|
|
57790
|
+
b: newValue.value.color.b,
|
|
57791
|
+
referencedTokenId: newValue.value.color.referencedTokenId,
|
|
57792
|
+
},
|
|
57793
|
+
referencedTokenId: newValue.id,
|
|
57794
|
+
};
|
|
57795
|
+
}
|
|
57796
|
+
else {
|
|
57797
|
+
update.value = {
|
|
57798
|
+
opacity: update.value.opacity,
|
|
57799
|
+
color: {
|
|
57800
|
+
r: newValue.r,
|
|
57801
|
+
g: newValue.g,
|
|
57802
|
+
b: newValue.b,
|
|
57803
|
+
referencedTokenId: newValue.referencedTokenId,
|
|
57804
|
+
},
|
|
57805
|
+
referencedTokenId: null,
|
|
57806
|
+
};
|
|
57807
|
+
}
|
|
57808
|
+
return update;
|
|
57809
|
+
}
|
|
57810
|
+
/** Creates a new color token with updated .opacity value */
|
|
57811
|
+
static colorTokenByUpdatingOpacity(token, newValue) {
|
|
57812
|
+
TokenUtils.checkNotReference(token);
|
|
57813
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
57814
|
+
if (newValue instanceof SDKDimensionToken_1.OpacityToken) {
|
|
57815
|
+
update.value.opacity = {
|
|
57816
|
+
measure: newValue.value.measure,
|
|
57817
|
+
unit: newValue.value.unit,
|
|
57818
|
+
referencedTokenId: newValue.id,
|
|
57819
|
+
};
|
|
57820
|
+
}
|
|
57821
|
+
else {
|
|
57822
|
+
update.value.opacity = {
|
|
57823
|
+
measure: newValue,
|
|
57824
|
+
unit: exports_1.Unit.raw,
|
|
57825
|
+
referencedTokenId: null,
|
|
57826
|
+
};
|
|
57827
|
+
}
|
|
57828
|
+
return update;
|
|
57829
|
+
}
|
|
57830
|
+
/** Creates a new blur token with updated .type value */
|
|
57831
|
+
static blurTokenByUpdatingType(token, newValue) {
|
|
57832
|
+
this.checkNotReference(token);
|
|
57833
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
57834
|
+
update.value.type = newValue;
|
|
57835
|
+
return update;
|
|
57836
|
+
}
|
|
57837
|
+
/** Creates a new blur token with updated .radius value */
|
|
57838
|
+
static blurTokenByUpdatingRadius(token, newValue) {
|
|
57839
|
+
this.checkNotReference(token);
|
|
57840
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
57841
|
+
update.value.radius = this.rawOrReferencedDimensionValue(newValue);
|
|
57842
|
+
return update;
|
|
57843
|
+
}
|
|
57844
|
+
/** Creates a new typography token with updated .fontFamily value */
|
|
57845
|
+
static typographyTokenByUpdatingFontFamily(token, newValue) {
|
|
57846
|
+
this.checkNotReference(token);
|
|
57847
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
57848
|
+
if (newValue instanceof SDKStringToken_1.FontFamilyToken) {
|
|
57849
|
+
update.value.fontFamily = {
|
|
57850
|
+
text: newValue.value.text,
|
|
57851
|
+
referencedTokenId: newValue.id,
|
|
57852
|
+
};
|
|
57853
|
+
}
|
|
57854
|
+
else {
|
|
57855
|
+
update.value.fontFamily = {
|
|
57856
|
+
text: newValue.text,
|
|
57857
|
+
referencedTokenId: null,
|
|
57858
|
+
};
|
|
57859
|
+
}
|
|
57860
|
+
return update;
|
|
57861
|
+
}
|
|
57862
|
+
/** Creates a new typography token with updated .fontWeight value */
|
|
57863
|
+
static typographyTokenByUpdatingFontWeight(token, newValue) {
|
|
57864
|
+
this.checkNotReference(token);
|
|
57865
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
57866
|
+
if (newValue instanceof SDKStringToken_1.FontWeightToken) {
|
|
57867
|
+
update.value.fontWeight = {
|
|
57868
|
+
text: newValue.value.text,
|
|
57869
|
+
referencedTokenId: newValue.id,
|
|
57870
|
+
};
|
|
57871
|
+
}
|
|
57872
|
+
else {
|
|
57873
|
+
update.value.fontWeight = {
|
|
57874
|
+
text: newValue.text,
|
|
57875
|
+
referencedTokenId: null,
|
|
57876
|
+
};
|
|
57877
|
+
}
|
|
57878
|
+
return update;
|
|
57879
|
+
}
|
|
57880
|
+
/** Creates a new typography token with updated .fontSize value */
|
|
57881
|
+
static typographyTokenByUpdatingFontSize(token, newValue) {
|
|
57882
|
+
this.checkNotReference(token);
|
|
57883
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
57884
|
+
update.value.fontSize = this.rawOrReferencedDimensionValue(newValue);
|
|
57885
|
+
return update;
|
|
57886
|
+
}
|
|
57887
|
+
/** Creates a new typography token with updated .letterSpacing value */
|
|
57888
|
+
static typographyTokenByUpdatingLetterSpacing(token, newValue) {
|
|
57889
|
+
this.checkNotReference(token);
|
|
57890
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
57891
|
+
update.value.letterSpacing = this.rawOrReferencedDimensionValue(newValue);
|
|
57892
|
+
return update;
|
|
57893
|
+
}
|
|
57894
|
+
/** Creates a new typography token with updated .lineHeight value */
|
|
57895
|
+
static typographyTokenByUpdatingLineHeight(token, newValue) {
|
|
57896
|
+
this.checkNotReference(token);
|
|
57897
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
57898
|
+
update.value.lineHeight = this.rawOrReferencedDimensionValue(newValue);
|
|
57899
|
+
return update;
|
|
57900
|
+
}
|
|
57901
|
+
/** Creates a new typography token with updated .paragraphSpacing value */
|
|
57902
|
+
static typographyTokenByUpdatingParagraphSpacing(token, newValue) {
|
|
57903
|
+
this.checkNotReference(token);
|
|
57904
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
57905
|
+
update.value.paragraphSpacing = this.rawOrReferencedDimensionValue(newValue);
|
|
57906
|
+
return update;
|
|
57907
|
+
}
|
|
57908
|
+
/** Creates a new typography token with updated .paragraphSpacing value */
|
|
57909
|
+
static typographyTokenByUpdatingParagraphIndent(token, newValue) {
|
|
57910
|
+
this.checkNotReference(token);
|
|
57911
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
57912
|
+
update.value.paragraphIndent = this.rawOrReferencedDimensionValue(newValue);
|
|
57913
|
+
return update;
|
|
57914
|
+
}
|
|
57915
|
+
/** Creates a new typography token with updated .textCase value */
|
|
57916
|
+
static typographyTokenByUpdatingTextCase(token, newValue) {
|
|
57917
|
+
this.checkNotReference(token);
|
|
57918
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
57919
|
+
if (newValue instanceof SDKTextCaseToken_1.TextCaseToken) {
|
|
57920
|
+
update.value.textCase = {
|
|
57921
|
+
value: newValue.value.value,
|
|
57922
|
+
options: newValue.value.options,
|
|
57923
|
+
referencedTokenId: newValue.id,
|
|
57924
|
+
};
|
|
57925
|
+
}
|
|
57926
|
+
else {
|
|
57927
|
+
update.value.textCase = {
|
|
57928
|
+
value: newValue.value,
|
|
57929
|
+
options: newValue.options,
|
|
57930
|
+
referencedTokenId: null,
|
|
57931
|
+
};
|
|
57932
|
+
}
|
|
57933
|
+
return update;
|
|
57934
|
+
}
|
|
57935
|
+
/** Creates a new border token with updated .position value */
|
|
57936
|
+
static typographyTokenByUpdatingTextDecoration(token, newValue) {
|
|
57937
|
+
this.checkNotReference(token);
|
|
57938
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
57939
|
+
if (newValue instanceof SDKTextDecorationToken_1.TextDecorationToken) {
|
|
57940
|
+
update.value.textDecoration = {
|
|
57941
|
+
value: newValue.value.value,
|
|
57942
|
+
options: newValue.value.options,
|
|
57943
|
+
referencedTokenId: newValue.id,
|
|
57944
|
+
};
|
|
57945
|
+
}
|
|
57946
|
+
else {
|
|
57947
|
+
update.value.textDecoration = {
|
|
57948
|
+
value: newValue.value,
|
|
57949
|
+
options: newValue.options,
|
|
57950
|
+
referencedTokenId: null,
|
|
57951
|
+
};
|
|
57952
|
+
}
|
|
57953
|
+
return update;
|
|
57954
|
+
}
|
|
57955
|
+
/** Creates a new border token with updated .color value. Do note, opacity is ignored */
|
|
57956
|
+
static borderTokenByUpdatingColor(token, newValue) {
|
|
57957
|
+
this.checkNotReference(token);
|
|
57958
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
57959
|
+
if (newValue instanceof SDKColorToken_1.ColorToken) {
|
|
57960
|
+
update.value.color = {
|
|
57961
|
+
opacity: update.value.color.opacity,
|
|
57962
|
+
color: {
|
|
57963
|
+
r: newValue.value.color.r,
|
|
57964
|
+
g: newValue.value.color.g,
|
|
57965
|
+
b: newValue.value.color.b,
|
|
57966
|
+
referencedTokenId: newValue.value.color.referencedTokenId,
|
|
57967
|
+
},
|
|
57968
|
+
referencedTokenId: newValue.id,
|
|
57969
|
+
};
|
|
57970
|
+
}
|
|
57971
|
+
else {
|
|
57972
|
+
update.value.color = {
|
|
57973
|
+
opacity: update.value.color.opacity,
|
|
57974
|
+
color: {
|
|
57975
|
+
r: newValue.r,
|
|
57976
|
+
g: newValue.g,
|
|
57977
|
+
b: newValue.b,
|
|
57978
|
+
referencedTokenId: newValue.referencedTokenId,
|
|
57979
|
+
},
|
|
57980
|
+
referencedTokenId: null,
|
|
57981
|
+
};
|
|
57982
|
+
}
|
|
57983
|
+
return update;
|
|
57984
|
+
}
|
|
57985
|
+
/** Creates a new border token with updated color.opacity value */
|
|
57986
|
+
static borderTokenByUpdatingOpacity(token, newValue) {
|
|
57987
|
+
this.checkNotReference(token);
|
|
57988
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
57989
|
+
if (newValue instanceof SDKDimensionToken_1.OpacityToken) {
|
|
57990
|
+
update.value.color.opacity = {
|
|
57991
|
+
measure: newValue.value.measure,
|
|
57992
|
+
unit: newValue.value.unit,
|
|
57993
|
+
referencedTokenId: newValue.id,
|
|
57994
|
+
};
|
|
57995
|
+
}
|
|
57996
|
+
else {
|
|
57997
|
+
update.value.color.opacity = {
|
|
57998
|
+
measure: newValue,
|
|
57999
|
+
unit: exports_1.Unit.raw,
|
|
58000
|
+
referencedTokenId: null,
|
|
58001
|
+
};
|
|
58002
|
+
}
|
|
58003
|
+
return update;
|
|
58004
|
+
}
|
|
58005
|
+
/** Creates a new border token with updated .width value */
|
|
58006
|
+
static borderTokenByUpdatingWidth(token, newValue) {
|
|
58007
|
+
this.checkNotReference(token);
|
|
58008
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58009
|
+
update.value.width = this.rawOrReferencedDimensionValue(newValue);
|
|
58010
|
+
return update;
|
|
58011
|
+
}
|
|
58012
|
+
/** Creates a new border token with updated .position value */
|
|
58013
|
+
static borderTokenByUpdatingPosition(token, newValue) {
|
|
58014
|
+
this.checkNotReference(token);
|
|
58015
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58016
|
+
update.value.position = newValue;
|
|
58017
|
+
return update;
|
|
58018
|
+
}
|
|
58019
|
+
/** Creates a new border token with updated .style value */
|
|
58020
|
+
static borderTokenByUpdatingStyle(token, newValue) {
|
|
58021
|
+
this.checkNotReference(token);
|
|
58022
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58023
|
+
update.value.style = newValue;
|
|
58024
|
+
return update;
|
|
58025
|
+
}
|
|
58026
|
+
/** Creates a new dimension token with updated value */
|
|
58027
|
+
static dimensionTokenByUpdatingValue(token, newValue) {
|
|
58028
|
+
this.checkNotReference(token);
|
|
58029
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58030
|
+
update.value = this.rawOrReferencedDimensionValue(newValue);
|
|
58031
|
+
return update;
|
|
58032
|
+
}
|
|
58033
|
+
/** Creates a new size token with updated value */
|
|
58034
|
+
static sizeTokenByUpdatingValue(token, newValue) {
|
|
58035
|
+
this.checkNotReference(token);
|
|
58036
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58037
|
+
update.value = this.rawOrReferencedDimensionValue(newValue);
|
|
58038
|
+
return update;
|
|
58039
|
+
}
|
|
58040
|
+
/** Creates a new space token with updated value */
|
|
58041
|
+
static spaceTokenByUpdatingValue(token, newValue) {
|
|
58042
|
+
this.checkNotReference(token);
|
|
58043
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58044
|
+
update.value = this.rawOrReferencedDimensionValue(newValue);
|
|
58045
|
+
return update;
|
|
58046
|
+
}
|
|
58047
|
+
/** Creates a new opacity token with updated value */
|
|
58048
|
+
static opacityTokenByUpdatingValue(token, newValue) {
|
|
58049
|
+
this.checkNotReference(token);
|
|
58050
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58051
|
+
update.value = this.rawOrReferencedDimensionValue(newValue);
|
|
58052
|
+
return update;
|
|
58053
|
+
}
|
|
58054
|
+
/** Creates a new font size token with updated value */
|
|
58055
|
+
static fontSizeTokenByUpdatingValue(token, newValue) {
|
|
58056
|
+
this.checkNotReference(token);
|
|
58057
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58058
|
+
update.value = this.rawOrReferencedDimensionValue(newValue);
|
|
58059
|
+
return update;
|
|
58060
|
+
}
|
|
58061
|
+
/** Creates a new font size token with updated value */
|
|
58062
|
+
static lineHeightTokenByUpdatingValue(token, newValue) {
|
|
58063
|
+
this.checkNotReference(token);
|
|
58064
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58065
|
+
update.value = this.rawOrReferencedDimensionValue(newValue);
|
|
58066
|
+
return update;
|
|
58067
|
+
}
|
|
58068
|
+
/** Creates a new letter spacing token with updated value */
|
|
58069
|
+
static letterSpacingTokenByUpdatingValue(token, newValue) {
|
|
58070
|
+
this.checkNotReference(token);
|
|
58071
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58072
|
+
update.value = this.rawOrReferencedDimensionValue(newValue);
|
|
58073
|
+
return update;
|
|
58074
|
+
}
|
|
58075
|
+
/** Creates a new paragraph spacing token with updated value */
|
|
58076
|
+
static paragraphSpacingTokenByUpdatingValue(token, newValue) {
|
|
58077
|
+
this.checkNotReference(token);
|
|
58078
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58079
|
+
update.value = this.rawOrReferencedDimensionValue(newValue);
|
|
58080
|
+
return update;
|
|
58081
|
+
}
|
|
58082
|
+
/** Creates a new border width token with updated value */
|
|
58083
|
+
static borderWidthTokenByUpdatingValue(token, newValue) {
|
|
58084
|
+
this.checkNotReference(token);
|
|
58085
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58086
|
+
update.value = this.rawOrReferencedDimensionValue(newValue);
|
|
58087
|
+
return update;
|
|
58088
|
+
}
|
|
58089
|
+
/** Creates a new radius token with updated value */
|
|
58090
|
+
static radiusTokenByUpdatingValue(token, newValue) {
|
|
58091
|
+
this.checkNotReference(token);
|
|
58092
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58093
|
+
update.value = this.rawOrReferencedDimensionValue(newValue);
|
|
58094
|
+
return update;
|
|
58095
|
+
}
|
|
58096
|
+
/** Creates a new duration token with updated value */
|
|
58097
|
+
static durationTokenByUpdatingValue(token, newValue) {
|
|
58098
|
+
this.checkNotReference(token);
|
|
58099
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58100
|
+
update.value = this.rawOrReferencedDimensionValue(newValue);
|
|
58101
|
+
return update;
|
|
58102
|
+
}
|
|
58103
|
+
/** Creates a new z-index token with updated value */
|
|
58104
|
+
static zIndexTokenByUpdatingValue(token, newValue) {
|
|
58105
|
+
this.checkNotReference(token);
|
|
58106
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58107
|
+
update.value = this.rawOrReferencedDimensionValue(newValue);
|
|
58108
|
+
return update;
|
|
58109
|
+
}
|
|
58110
|
+
/** Creates a new string token with updated value */
|
|
58111
|
+
static stringTokenByUpdatingValue(token, newValue) {
|
|
58112
|
+
this.checkNotReference(token);
|
|
58113
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58114
|
+
update.value = this.rawOrReferencedStringValue(newValue);
|
|
58115
|
+
return update;
|
|
58116
|
+
}
|
|
58117
|
+
/** Creates a new product copy token with updated value */
|
|
58118
|
+
static productCopyTokenByUpdatingValue(token, newValue) {
|
|
58119
|
+
this.checkNotReference(token);
|
|
58120
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58121
|
+
update.value = this.rawOrReferencedStringValue(newValue);
|
|
58122
|
+
return update;
|
|
58123
|
+
}
|
|
58124
|
+
/** Creates a new font family token with updated value */
|
|
58125
|
+
static fontFamilyTokenByUpdatingValue(token, newValue) {
|
|
58126
|
+
this.checkNotReference(token);
|
|
58127
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58128
|
+
update.value = this.rawOrReferencedStringValue(newValue);
|
|
58129
|
+
return update;
|
|
58130
|
+
}
|
|
58131
|
+
/** Creates a new font weight token with updated value */
|
|
58132
|
+
static fontWeightTokenByUpdatingValue(token, newValue) {
|
|
58133
|
+
this.checkNotReference(token);
|
|
58134
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58135
|
+
update.value = this.rawOrReferencedStringValue(newValue);
|
|
58136
|
+
return update;
|
|
58137
|
+
}
|
|
58138
|
+
/** Creates a new text case token with updated value */
|
|
58139
|
+
static textCaseTokenByUpdatingValue(token, newValue) {
|
|
58140
|
+
this.checkNotReference(token);
|
|
58141
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58142
|
+
update.value = {
|
|
58143
|
+
value: newValue.value,
|
|
58144
|
+
options: newValue.options,
|
|
58145
|
+
referencedTokenId: null,
|
|
58146
|
+
};
|
|
58147
|
+
return update;
|
|
58148
|
+
}
|
|
58149
|
+
/** Creates a new text case token with updated value */
|
|
58150
|
+
static textDecorationTokenByUpdatingValue(token, newValue) {
|
|
58151
|
+
this.checkNotReference(token);
|
|
58152
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58153
|
+
update.value = {
|
|
58154
|
+
value: newValue.value,
|
|
58155
|
+
options: newValue.options,
|
|
58156
|
+
referencedTokenId: null,
|
|
58157
|
+
};
|
|
58158
|
+
return update;
|
|
58159
|
+
}
|
|
58160
|
+
/** Creates a new visibility token with updated value */
|
|
58161
|
+
static visibilityTokenByUpdatingValue(token, newValue) {
|
|
58162
|
+
this.checkNotReference(token);
|
|
58163
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58164
|
+
update.value = {
|
|
58165
|
+
value: newValue.value,
|
|
58166
|
+
options: newValue.options,
|
|
58167
|
+
referencedTokenId: null,
|
|
58168
|
+
};
|
|
58169
|
+
return update;
|
|
58170
|
+
}
|
|
58171
|
+
// --- --- --- --- --- --- --- --- --- ---
|
|
58172
|
+
// MARK: - Multi-layer token manipulation
|
|
58173
|
+
/** Creates a new shadow token with one new extra layer added at the end of all layers */
|
|
58174
|
+
static shadowTokenByAddingLayer(token) {
|
|
58175
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58176
|
+
const layer = {
|
|
58177
|
+
color: {
|
|
58178
|
+
color: {
|
|
58179
|
+
r: 0,
|
|
58180
|
+
g: 0,
|
|
58181
|
+
b: 0,
|
|
58182
|
+
referencedTokenId: null,
|
|
58183
|
+
},
|
|
58184
|
+
opacity: {
|
|
58185
|
+
measure: 1,
|
|
58186
|
+
unit: exports_1.Unit.raw,
|
|
58187
|
+
referencedTokenId: null,
|
|
58188
|
+
},
|
|
58189
|
+
referencedTokenId: null,
|
|
58190
|
+
},
|
|
58191
|
+
opacity: {
|
|
58192
|
+
measure: 1,
|
|
58193
|
+
unit: exports_1.Unit.raw,
|
|
58194
|
+
referencedTokenId: null,
|
|
58195
|
+
},
|
|
58196
|
+
radius: 0,
|
|
58197
|
+
spread: 0,
|
|
58198
|
+
type: exports_1.ShadowType.drop,
|
|
58199
|
+
x: 0,
|
|
58200
|
+
y: 4,
|
|
58201
|
+
referencedTokenId: null,
|
|
58202
|
+
};
|
|
58203
|
+
update.value.push(layer);
|
|
58204
|
+
return update;
|
|
58205
|
+
}
|
|
58206
|
+
/** Creates a new shadow token by removing one of the layers */
|
|
58207
|
+
static shadowTokenByRemovingLayer(token, layerIndex) {
|
|
58208
|
+
this.validateLayerAccess(token, layerIndex);
|
|
58209
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58210
|
+
update.value = update.value.splice(layerIndex, 1);
|
|
58211
|
+
return update;
|
|
58212
|
+
}
|
|
58213
|
+
/** Creates a new shadow token with updated .color value. Do note, opacity is ignored */
|
|
58214
|
+
static shadowTokenByUpdatingColor(token, layerIndex, newValue) {
|
|
58215
|
+
this.validateLayerAccess(token, layerIndex);
|
|
58216
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58217
|
+
const layer = update.value[layerIndex];
|
|
58218
|
+
if (newValue instanceof SDKColorToken_1.ColorToken) {
|
|
58219
|
+
layer.color = {
|
|
58220
|
+
opacity: layer.color.opacity,
|
|
58221
|
+
color: {
|
|
58222
|
+
r: newValue.value.color.r,
|
|
58223
|
+
g: newValue.value.color.g,
|
|
58224
|
+
b: newValue.value.color.b,
|
|
58225
|
+
referencedTokenId: newValue.value.color.referencedTokenId,
|
|
58226
|
+
},
|
|
58227
|
+
referencedTokenId: newValue.id,
|
|
58228
|
+
};
|
|
58229
|
+
}
|
|
58230
|
+
else {
|
|
58231
|
+
layer.color = {
|
|
58232
|
+
opacity: layer.color.opacity,
|
|
58233
|
+
color: {
|
|
58234
|
+
r: newValue.r,
|
|
58235
|
+
g: newValue.g,
|
|
58236
|
+
b: newValue.b,
|
|
58237
|
+
referencedTokenId: newValue.referencedTokenId,
|
|
58238
|
+
},
|
|
58239
|
+
referencedTokenId: null,
|
|
58240
|
+
};
|
|
58241
|
+
}
|
|
58242
|
+
return update;
|
|
58243
|
+
}
|
|
58244
|
+
/** Creates a new shadow token with updated .color value */
|
|
58245
|
+
static shadowTokenByUpdatingOpacity(token, layerIndex, newValue) {
|
|
58246
|
+
this.validateLayerAccess(token, layerIndex);
|
|
58247
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58248
|
+
const layer = update.value[layerIndex];
|
|
58249
|
+
if (newValue instanceof SDKDimensionToken_1.OpacityToken) {
|
|
58250
|
+
layer.opacity = {
|
|
58251
|
+
measure: newValue.value.measure,
|
|
58252
|
+
unit: newValue.value.unit,
|
|
58253
|
+
referencedTokenId: newValue.id,
|
|
58254
|
+
};
|
|
58255
|
+
}
|
|
58256
|
+
else {
|
|
58257
|
+
layer.opacity = {
|
|
58258
|
+
measure: newValue,
|
|
58259
|
+
unit: exports_1.Unit.raw,
|
|
58260
|
+
referencedTokenId: null,
|
|
58261
|
+
};
|
|
58262
|
+
}
|
|
58263
|
+
return update;
|
|
58264
|
+
}
|
|
58265
|
+
/** Creates a new shadow token with updated .x value */
|
|
58266
|
+
static shadowTokenByUpdatingX(token, layerIndex, newValue) {
|
|
58267
|
+
this.validateLayerAccess(token, layerIndex);
|
|
58268
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58269
|
+
const layer = update.value[layerIndex];
|
|
58270
|
+
layer.x = newValue;
|
|
58271
|
+
return update;
|
|
58272
|
+
}
|
|
58273
|
+
/** Creates a new shadow token with updated .y value */
|
|
58274
|
+
static shadowTokenByUpdatingY(token, layerIndex, newValue) {
|
|
58275
|
+
this.validateLayerAccess(token, layerIndex);
|
|
58276
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58277
|
+
const layer = update.value[layerIndex];
|
|
58278
|
+
layer.y = newValue;
|
|
58279
|
+
return update;
|
|
58280
|
+
}
|
|
58281
|
+
/** Creates a new shadow token with updated .radius value */
|
|
58282
|
+
static shadowTokenByUpdatingRadius(token, layerIndex, newValue) {
|
|
58283
|
+
this.validateLayerAccess(token, layerIndex);
|
|
58284
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58285
|
+
const layer = update.value[layerIndex];
|
|
58286
|
+
layer.radius = newValue;
|
|
58287
|
+
return update;
|
|
58288
|
+
}
|
|
58289
|
+
/** Creates a new shadow token with updated .spread value */
|
|
58290
|
+
static shadowTokenByUpdatingSpread(token, layerIndex, newValue) {
|
|
58291
|
+
this.validateLayerAccess(token, layerIndex);
|
|
58292
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58293
|
+
const layer = update.value[layerIndex];
|
|
58294
|
+
layer.spread = newValue;
|
|
58295
|
+
return update;
|
|
58296
|
+
}
|
|
58297
|
+
/** Creates a new shadow token with updated .type value */
|
|
58298
|
+
static shadowTokenByUpdatingType(token, layerIndex, newValue) {
|
|
58299
|
+
this.validateLayerAccess(token, layerIndex);
|
|
58300
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58301
|
+
const layer = update.value[layerIndex];
|
|
58302
|
+
layer.type = newValue;
|
|
58303
|
+
return update;
|
|
58304
|
+
}
|
|
58305
|
+
/** Creates a new gradient token with updated .to value */
|
|
58306
|
+
static gradientTokenByUpdatingTo(token, layerIndex, newValue) {
|
|
58307
|
+
this.validateLayerAccess(token, layerIndex);
|
|
58308
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58309
|
+
const layer = update.value[layerIndex];
|
|
58310
|
+
layer.to = newValue;
|
|
58311
|
+
return update;
|
|
58312
|
+
}
|
|
58313
|
+
/** Creates a new gradient token with updated .from value */
|
|
58314
|
+
static gradientTokenByUpdatingFrom(token, layerIndex, newValue) {
|
|
58315
|
+
this.validateLayerAccess(token, layerIndex);
|
|
58316
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58317
|
+
const layer = update.value[layerIndex];
|
|
58318
|
+
layer.from = newValue;
|
|
58319
|
+
return update;
|
|
58320
|
+
}
|
|
58321
|
+
/** Creates a new gradient token with updated .to value */
|
|
58322
|
+
static gradientTokenByUpdatingType(token, layerIndex, newValue) {
|
|
58323
|
+
this.validateLayerAccess(token, layerIndex);
|
|
58324
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58325
|
+
const layer = update.value[layerIndex];
|
|
58326
|
+
layer.type = newValue;
|
|
58327
|
+
return update;
|
|
58328
|
+
}
|
|
58329
|
+
/** Creates a new gradient token with updated .aspectRatio value */
|
|
58330
|
+
static gradientTokenByUpdatingAspectRatio(token, layerIndex, newValue) {
|
|
58331
|
+
this.validateLayerAccess(token, layerIndex);
|
|
58332
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58333
|
+
const layer = update.value[layerIndex];
|
|
58334
|
+
layer.aspectRatio = newValue;
|
|
58335
|
+
return update;
|
|
58336
|
+
}
|
|
58337
|
+
/** Creates a new gradient token with updated .to value */
|
|
58338
|
+
static gradientTokenByUpdatingStops(token, layerIndex, newValue) {
|
|
58339
|
+
TokenUtils.validateLayerAccess(token, layerIndex);
|
|
58340
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58341
|
+
const layer = update.value[layerIndex];
|
|
58342
|
+
const stops = new Array();
|
|
58343
|
+
for (const v of newValue) {
|
|
58344
|
+
if (v.color instanceof SDKColorToken_1.ColorToken) {
|
|
58345
|
+
const stop = {
|
|
58346
|
+
position: v.position,
|
|
58347
|
+
color: {
|
|
58348
|
+
opacity: v.color.value.opacity,
|
|
58349
|
+
color: {
|
|
58350
|
+
r: v.color.value.color.r,
|
|
58351
|
+
g: v.color.value.color.g,
|
|
58352
|
+
b: v.color.value.color.b,
|
|
58353
|
+
referencedTokenId: v.color.value.color.referencedTokenId,
|
|
58354
|
+
},
|
|
58355
|
+
referencedTokenId: v.color.id,
|
|
58356
|
+
},
|
|
58357
|
+
};
|
|
58358
|
+
stops.push(stop);
|
|
58359
|
+
}
|
|
58360
|
+
else {
|
|
58361
|
+
const stop = {
|
|
58362
|
+
position: v.position,
|
|
58363
|
+
color: {
|
|
58364
|
+
opacity: v.color.opacity,
|
|
58365
|
+
color: {
|
|
58366
|
+
r: v.color.color.r,
|
|
58367
|
+
g: v.color.color.g,
|
|
58368
|
+
b: v.color.color.b,
|
|
58369
|
+
referencedTokenId: v.color.color.referencedTokenId,
|
|
58370
|
+
},
|
|
58371
|
+
referencedTokenId: null,
|
|
58372
|
+
},
|
|
58373
|
+
};
|
|
58374
|
+
stops.push(stop);
|
|
58375
|
+
}
|
|
58376
|
+
}
|
|
58377
|
+
layer.stops = stops;
|
|
58378
|
+
return update;
|
|
58379
|
+
}
|
|
58380
|
+
// --- --- --- --- --- --- --- --- --- ---
|
|
58381
|
+
// MARK: - Manipulating references
|
|
58382
|
+
/** Creates a new token where value is reference to the provided token. Token and reference must be of the same type */
|
|
58383
|
+
static tokenByReferencing(token, reference) {
|
|
58384
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithoutValue(token);
|
|
58385
|
+
if (token.id === reference.id) {
|
|
58386
|
+
throw exports_1.SupernovaError.fromMessage("Can't create reference where token would reference itself");
|
|
58387
|
+
}
|
|
58388
|
+
if (token.tokenType !== reference.tokenType) {
|
|
58389
|
+
throw exports_1.SupernovaError.fromMessage("Can't reference token of different type");
|
|
58390
|
+
}
|
|
58391
|
+
update.value = Object.assign(Object.assign({}, (0, lodash_2.cloneDeep)(reference.value)), { referencedTokenId: reference.id });
|
|
58392
|
+
return update;
|
|
58393
|
+
}
|
|
58394
|
+
/** Creates a new multilayer token where one of the layers is reference to the provided token. Token and reference must be of the same type */
|
|
58395
|
+
static multilayerTokenByReferencing(token, layerIndex, reference) {
|
|
58396
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithValue(token);
|
|
58397
|
+
if (token.id === reference.id) {
|
|
58398
|
+
throw exports_1.SupernovaError.fromMessage("Can't create reference where token would reference itself");
|
|
58399
|
+
}
|
|
58400
|
+
if (token.tokenType !== reference.tokenType) {
|
|
58401
|
+
throw exports_1.SupernovaError.fromMessage("Can't reference token of different type");
|
|
58402
|
+
}
|
|
58403
|
+
// NOTE: make sure that token copy value is blank to have new value copied in
|
|
58404
|
+
update.value = [];
|
|
58405
|
+
update.value[layerIndex] = Object.assign(Object.assign({}, (0, lodash_2.cloneDeep)(reference.value[layerIndex])), { referencedTokenId: reference.id });
|
|
58406
|
+
return update;
|
|
58407
|
+
}
|
|
58408
|
+
/** Creates a new token where value is raw, but taken from the previously referenced token. Token must have had reference before */
|
|
58409
|
+
static tokenByDisconnectingReference(token, options = {}) {
|
|
58410
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithoutValue(token);
|
|
58411
|
+
if (!token.value.referencedTokenId && !options.supressErrorOnNoReference) {
|
|
58412
|
+
throw exports_1.SupernovaError.fromMessage("Can't create raw token from a token that isn't previously a reference");
|
|
58413
|
+
}
|
|
58414
|
+
update.value = Object.assign(Object.assign({}, (0, lodash_2.cloneDeep)(token.value)), { referencedTokenId: null });
|
|
58415
|
+
return update;
|
|
58416
|
+
}
|
|
58417
|
+
/** Creates a new multilayer token where one of the layers value is raw, but taken from the previously referenced token. That layer must have had reference before */
|
|
58418
|
+
static multilayerTokenByDisconnectingReference(token, layerIndex) {
|
|
58419
|
+
const update = SDKThemeUtilities_1.ThemeUtilities.replicateTokenWithoutValue(token);
|
|
58420
|
+
if (!token.value.referencedTokenId) {
|
|
58421
|
+
throw exports_1.SupernovaError.fromMessage("Can't create raw token from a token that isn't previously a reference");
|
|
58422
|
+
}
|
|
58423
|
+
// TODO: Multilayer shadow & gradient disconnect of the references
|
|
58424
|
+
return update;
|
|
58425
|
+
}
|
|
58426
|
+
/** Checks if token as a whole is a reference to another token */
|
|
58427
|
+
static isReferencedToken(token) {
|
|
58428
|
+
return (token.value.referencedTokenId !== null &&
|
|
58429
|
+
token.value.referencedTokenId !== undefined);
|
|
58430
|
+
}
|
|
58431
|
+
/** Checks if a token layer of multilayer token is a reference to another token */
|
|
58432
|
+
static isReferencedMultilayerTokenLayer(token, layerIndex) {
|
|
58433
|
+
this.validateLayerAccess(token, layerIndex);
|
|
58434
|
+
const layer = token.value[layerIndex];
|
|
58435
|
+
return (layer.referencedTokenId !== null && layer.referencedTokenId !== undefined);
|
|
58436
|
+
}
|
|
58437
|
+
/** Checks if a token was imported from some foreign source. Not imported tokens were always created in Supernova */
|
|
58438
|
+
static isTokenImported(token) {
|
|
58439
|
+
var _a, _b;
|
|
58440
|
+
return (((_a = token.origin) === null || _a === void 0 ? void 0 : _a.sourceId) !== null && ((_b = token.origin) === null || _b === void 0 ? void 0 : _b.sourceId) !== undefined);
|
|
58441
|
+
}
|
|
58442
|
+
// --- --- --- --- --- --- --- --- --- ---
|
|
58443
|
+
// MARK: - Conveniences
|
|
58444
|
+
static checkNotReference(token) {
|
|
58445
|
+
if (token.value.referencedTokenId) {
|
|
58446
|
+
throw exports_1.SupernovaError.fromMessage("Performing value-replated operation on referenced token is not allowed");
|
|
58447
|
+
}
|
|
58448
|
+
}
|
|
58449
|
+
static rawOrReferencedDimensionValue(newValue) {
|
|
58450
|
+
if (newValue instanceof SDKDimensionToken_1.DimensionCategoryToken) {
|
|
58451
|
+
return {
|
|
58452
|
+
measure: newValue.value.measure,
|
|
58453
|
+
unit: newValue.value.unit,
|
|
58454
|
+
referencedTokenId: newValue.id,
|
|
58455
|
+
};
|
|
58456
|
+
}
|
|
58457
|
+
return {
|
|
58458
|
+
measure: newValue.measure,
|
|
58459
|
+
unit: newValue.unit,
|
|
58460
|
+
referencedTokenId: null,
|
|
58461
|
+
};
|
|
58462
|
+
}
|
|
58463
|
+
static rawOrReferencedStringValue(newValue) {
|
|
58464
|
+
if (newValue instanceof SDKStringToken_1.StringCategoryToken) {
|
|
58465
|
+
return {
|
|
58466
|
+
text: newValue.value.text,
|
|
58467
|
+
referencedTokenId: newValue.id,
|
|
58468
|
+
};
|
|
58469
|
+
}
|
|
58470
|
+
return {
|
|
58471
|
+
text: newValue.text,
|
|
58472
|
+
referencedTokenId: null,
|
|
58473
|
+
};
|
|
58474
|
+
}
|
|
58475
|
+
static validateLayerAccess(token, index) {
|
|
58476
|
+
let layers;
|
|
58477
|
+
if (token instanceof SDKShadowToken_1.ShadowToken) {
|
|
58478
|
+
layers = token.shadowLayers;
|
|
58479
|
+
}
|
|
58480
|
+
else {
|
|
58481
|
+
layers = token.gradientLayers;
|
|
58482
|
+
}
|
|
58483
|
+
if (index < 0 || index >= layers.length) {
|
|
58484
|
+
throw exports_1.SupernovaError.fromMessage(`Can't access layer at index ${index}, layer outside of allowed bounds`);
|
|
58485
|
+
}
|
|
58486
|
+
}
|
|
57455
58487
|
static inlineValueIntoComplexTokens(token, candidateId, candidateValueToInline) {
|
|
57456
58488
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3;
|
|
57457
58489
|
switch (token.tokenType) {
|
|
@@ -57600,8 +58632,7 @@ class TokenUtils {
|
|
|
57600
58632
|
const fallbackKey2 = TokenUtils.buildFallbackKey(node);
|
|
57601
58633
|
// FIXMENOW: Verify and test
|
|
57602
58634
|
const fallbackKey3 = TokenUtils.buildFallbackKeyBack(node);
|
|
57603
|
-
if (key !== fallbackKey || key !== fallbackKey2)
|
|
57604
|
-
console.log({ key, fallbackKey, fallbackKey2 });
|
|
58635
|
+
// if (key !== fallbackKey || key !== fallbackKey2) console.log({ key, fallbackKey, fallbackKey2 })
|
|
57605
58636
|
return [key, fallbackKey, fallbackKey2, fallbackKey3];
|
|
57606
58637
|
}
|
|
57607
58638
|
static getTokenByKeyOrBackwardKey(node, map) {
|