UNPKG

@workday/canvas-kit-react

Version:

The parent module that contains all Workday Canvas Kit React components

29 lines (28 loc) 1.32 kB
"use strict"; /// <reference types="@types/node" /> Object.defineProperty(exports, "__esModule", { value: true }); exports.setCanvasKitTags = void 0; const version_1 = require("@workday/canvas-kit-react/version"); const canvas_kit_styling_1 = require("@workday/canvas-kit-styling"); // Only add the major version tag for development and test environments const versionTag = process.env.NODE_ENV === 'production' ? version_1.version : version_1.version.split('.')[0]; /** * This function returns data attributes for tagging * We use this to track when and where our components render. It also allows us to see what version is rendering. */ function setCanvasKitTags(displayName = '') { // Do not add tags for subcomponents. E.g. Card.Text const shouldAddTag = displayName.length && !displayName.includes('.'); if (shouldAddTag) { return { ['data-uxi-canvas-kit-version']: versionTag, ['data-uxi-canvas-kit-component-type']: (0, canvas_kit_styling_1.slugify)(displayName), }; } // We need to explictily pass these attributes with `undefined` so they will be removed from the DOM. return { ['data-uxi-canvas-kit-version']: undefined, ['data-uxi-canvas-kit-component-type']: undefined, }; } exports.setCanvasKitTags = setCanvasKitTags;