@hashicorp/design-system-components 4.21.0 → 4.21.1

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.
Files changed (106) hide show
  1. package/declarations/components/hds/accordion/item/index.d.ts +2 -2
  2. package/declarations/components/hds/advanced-table/models/column.d.ts +7 -0
  3. package/declarations/components/hds/advanced-table/th-context-menu.d.ts +2 -4
  4. package/declarations/components/hds/advanced-table/th-resize-handle.d.ts +0 -1
  5. package/declarations/components/hds/advanced-table/th-sort.d.ts +1 -5
  6. package/declarations/components/hds/advanced-table/th.d.ts +0 -3
  7. package/declarations/components/hds/alert/index.d.ts +3 -4
  8. package/declarations/components/hds/app-header/index.d.ts +11 -2
  9. package/declarations/components/hds/badge/index.d.ts +3 -3
  10. package/declarations/components/hds/copy/button/index.d.ts +1 -1
  11. package/declarations/components/hds/copy/snippet/index.d.ts +1 -1
  12. package/declarations/components/hds/dropdown/index.d.ts +9 -9
  13. package/declarations/components/hds/dropdown/list-item/interactive.d.ts +1 -1
  14. package/declarations/components/hds/dropdown/toggle/button.d.ts +2 -2
  15. package/declarations/components/hds/dropdown/types.d.ts +2 -2
  16. package/declarations/components/hds/form/fieldset/index.d.ts +1 -0
  17. package/declarations/components/hds/form/header/title.d.ts +1 -1
  18. package/declarations/components/hds/form/super-select/multiple/base.d.ts +4 -3
  19. package/declarations/components/hds/form/super-select/single/base.d.ts +4 -3
  20. package/declarations/components/hds/form/text-input/base.d.ts +1 -1
  21. package/declarations/components/hds/layout/flex/index.d.ts +6 -5
  22. package/declarations/components/hds/layout/flex/types.d.ts +1 -0
  23. package/declarations/components/hds/layout/grid/index.d.ts +4 -2
  24. package/declarations/components/hds/layout/grid/types.d.ts +1 -0
  25. package/declarations/components/hds/link/inline.d.ts +3 -3
  26. package/declarations/components/hds/link/standalone.d.ts +4 -4
  27. package/declarations/components/hds/popover-primitive/index.d.ts +3 -3
  28. package/declarations/components/hds/rich-tooltip/bubble.d.ts +10 -10
  29. package/declarations/components/hds/stepper/step/indicator.d.ts +1 -1
  30. package/declarations/components/hds/stepper/task/indicator.d.ts +2 -2
  31. package/declarations/components/hds/tag/index.d.ts +4 -5
  32. package/declarations/components/hds/text/body.d.ts +2 -18
  33. package/declarations/components/hds/text/code.d.ts +2 -18
  34. package/declarations/components/hds/text/display.d.ts +2 -18
  35. package/declarations/components/hds/text/index.d.ts +2 -40
  36. package/declarations/components/hds/tooltip-button/index.d.ts +1 -1
  37. package/declarations/modifiers/hds-anchored-position.d.ts +5 -6
  38. package/declarations/template-registry.d.ts +2 -0
  39. package/dist/components/hds/accordion/item/index.js.map +1 -1
  40. package/dist/components/hds/advanced-table/index.js +1 -1
  41. package/dist/components/hds/advanced-table/models/column.js +31 -0
  42. package/dist/components/hds/advanced-table/models/column.js.map +1 -1
  43. package/dist/components/hds/advanced-table/th-context-menu.js +15 -7
  44. package/dist/components/hds/advanced-table/th-context-menu.js.map +1 -1
  45. package/dist/components/hds/advanced-table/th-resize-handle.js +16 -8
  46. package/dist/components/hds/advanced-table/th-resize-handle.js.map +1 -1
  47. package/dist/components/hds/advanced-table/th-sort.js +1 -2
  48. package/dist/components/hds/advanced-table/th-sort.js.map +1 -1
  49. package/dist/components/hds/advanced-table/th.js +1 -1
  50. package/dist/components/hds/advanced-table/th.js.map +1 -1
  51. package/dist/components/hds/alert/index.js.map +1 -1
  52. package/dist/components/hds/app-header/index.js +9 -1
  53. package/dist/components/hds/app-header/index.js.map +1 -1
  54. package/dist/components/hds/app-side-nav/list/index.js +1 -1
  55. package/dist/components/hds/badge/index.js.map +1 -1
  56. package/dist/components/hds/copy/button/index.js.map +1 -1
  57. package/dist/components/hds/copy/snippet/index.js.map +1 -1
  58. package/dist/components/hds/dropdown/index.js.map +1 -1
  59. package/dist/components/hds/dropdown/list-item/interactive.js.map +1 -1
  60. package/dist/components/hds/dropdown/toggle/button.js.map +1 -1
  61. package/dist/components/hds/dropdown/types.js.map +1 -1
  62. package/dist/components/hds/form/fieldset/index.js +2 -1
  63. package/dist/components/hds/form/fieldset/index.js.map +1 -1
  64. package/dist/components/hds/form/header/title.js +3 -3
  65. package/dist/components/hds/form/header/title.js.map +1 -1
  66. package/dist/components/hds/form/key-value-inputs/generic.js +1 -1
  67. package/dist/components/hds/form/super-select/multiple/base.js +12 -3
  68. package/dist/components/hds/form/super-select/multiple/base.js.map +1 -1
  69. package/dist/components/hds/form/super-select/single/base.js +11 -2
  70. package/dist/components/hds/form/super-select/single/base.js.map +1 -1
  71. package/dist/components/hds/form/text-input/base.js.map +1 -1
  72. package/dist/components/hds/layout/flex/index.js +4 -3
  73. package/dist/components/hds/layout/flex/index.js.map +1 -1
  74. package/dist/components/hds/layout/flex/types.js +1 -0
  75. package/dist/components/hds/layout/flex/types.js.map +1 -1
  76. package/dist/components/hds/layout/grid/index.js +4 -3
  77. package/dist/components/hds/layout/grid/index.js.map +1 -1
  78. package/dist/components/hds/layout/grid/types.js +1 -0
  79. package/dist/components/hds/layout/grid/types.js.map +1 -1
  80. package/dist/components/hds/link/inline.js +5 -5
  81. package/dist/components/hds/link/inline.js.map +1 -1
  82. package/dist/components/hds/link/standalone.js +5 -5
  83. package/dist/components/hds/link/standalone.js.map +1 -1
  84. package/dist/components/hds/popover-primitive/index.js.map +1 -1
  85. package/dist/components/hds/rich-tooltip/bubble.js.map +1 -1
  86. package/dist/components/hds/stepper/step/indicator.js.map +1 -1
  87. package/dist/components/hds/stepper/task/indicator.js.map +1 -1
  88. package/dist/components/hds/tag/index.js +26 -14
  89. package/dist/components/hds/tag/index.js.map +1 -1
  90. package/dist/components/hds/text/body.js +8 -22
  91. package/dist/components/hds/text/body.js.map +1 -1
  92. package/dist/components/hds/text/code.js +8 -22
  93. package/dist/components/hds/text/code.js.map +1 -1
  94. package/dist/components/hds/text/display.js +8 -22
  95. package/dist/components/hds/text/display.js.map +1 -1
  96. package/dist/components/hds/text/index.js +11 -45
  97. package/dist/components/hds/text/index.js.map +1 -1
  98. package/dist/components/hds/tooltip-button/index.js.map +1 -1
  99. package/dist/modifiers/hds-anchored-position.js.map +1 -1
  100. package/dist/styles/@hashicorp/design-system-components.css +35 -11
  101. package/dist/styles/components/app-side-nav/content.scss +9 -3
  102. package/dist/styles/components/form/radio-card.scss +8 -4
  103. package/dist/styles/components/layout/flex.scss +11 -1
  104. package/dist/styles/components/layout/grid.scss +18 -5
  105. package/dist/styles/components/side-nav/content.scss +1 -0
  106. package/package.json +4 -3
@@ -1 +1 @@
1
- {"version":3,"file":"standalone.js","sources":["../../../../src/components/hds/link/standalone.ts"],"sourcesContent":["/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { assert } from '@ember/debug';\nimport {\n HdsLinkIconPositionValues,\n HdsLinkColorValues,\n HdsLinkStandaloneSizeValues,\n} from './types.ts';\n\nimport type { HdsInteractiveSignature } from '../interactive/';\nimport type {\n HdsLinkColors,\n HdsLinkIconPositions,\n HdsLinkStandaloneSizes,\n} from './types.ts';\nimport type { HdsIconSignature } from '../icon';\nimport type Owner from '@ember/owner';\n\nexport interface HdsLinkStandaloneSignature {\n Args: HdsInteractiveSignature['Args'] & {\n size?: HdsLinkStandaloneSizes;\n color?: HdsLinkColors;\n text: string;\n icon: HdsIconSignature['Args']['name'];\n iconPosition?: HdsLinkIconPositions;\n };\n Element: HdsInteractiveSignature['Element'];\n}\n\nexport const DEFAULT_ICONPOSITION = HdsLinkIconPositionValues.Leading;\nexport const DEFAULT_COLOR = HdsLinkColorValues.Primary;\nexport const DEFAULT_SIZE = HdsLinkStandaloneSizeValues.Medium;\nexport const ICONPOSITIONS: string[] = Object.values(HdsLinkIconPositionValues);\nexport const COLORS: string[] = Object.values(HdsLinkColorValues);\nexport const SIZES: string[] = Object.values(HdsLinkStandaloneSizeValues);\n\nexport default class HdsLinkStandalone extends Component<HdsLinkStandaloneSignature> {\n constructor(owner: Owner, args: HdsLinkStandaloneSignature['Args']) {\n super(owner, args);\n if (!(this.args.href || this.args.route)) {\n assert('@href or @route must be defined for <Hds::Link::Standalone>');\n }\n }\n\n /**\n * @param text\n * @type {string}\n * @description The text of the link. If no text value is defined an error will be thrown.\n */\n get text(): string {\n const { text } = this.args;\n\n assert(\n '@text for \"Hds::Link::Standalone\" must have a valid value',\n text !== undefined\n );\n\n return text;\n }\n\n /**\n * @param color\n * @type {string}\n * @default primary\n * @description Determines the color of link to be used; acceptable values are `primary` and `secondary`\n */\n get color(): HdsLinkColors {\n const { color = DEFAULT_COLOR } = this.args;\n\n assert(\n `@color for \"Hds::Link::Standalone\" must be one of the following: ${COLORS.join(\n ', '\n )}; received: ${color}`,\n COLORS.includes(color)\n );\n\n return color;\n }\n\n /**\n * @param icon\n * @type {string|null}\n * @default null\n * @description The name of the icon to be used. An icon name must be defined.\n */\n get icon(): HdsIconSignature['Args']['name'] {\n const { icon } = this.args;\n\n assert(\n '@icon for \"Hds::Link::Standalone\" must have a valid value',\n icon !== undefined\n );\n\n return icon;\n }\n\n /**\n * @param iconPosition\n * @type {HdsLinkIconPositions}\n * @default leading\n * @description Positions the icon before or after the text; allowed values are `leading` or `trailing`\n */\n get iconPosition(): HdsLinkIconPositions {\n const { iconPosition = DEFAULT_ICONPOSITION } = this.args;\n\n assert(\n `@iconPosition for \"Hds::Link::Standalone\" must be one of the following: ${ICONPOSITIONS.join(\n ', '\n )}; received: ${iconPosition}`,\n ICONPOSITIONS.includes(iconPosition)\n );\n\n return iconPosition;\n }\n\n /**\n * @param size\n * @type {HdsLinkStandaloneSizes}\n * @default medium\n * @description The size of the standalone link; acceptable values are `small`, `medium`, and `large`\n */\n get size(): HdsLinkStandaloneSizes {\n const { size = DEFAULT_SIZE } = this.args;\n\n assert(\n `@size for \"Hds::Link::Standalone\" must be one of the following: ${SIZES.join(\n ', '\n )}; received: ${size}`,\n SIZES.includes(size)\n );\n\n return size;\n }\n\n /**\n * @param iconSize\n * @type {string}\n * @default 16\n * @description ensures that the correct icon size is used. Automatically calculated.\n */\n get iconSize(): HdsIconSignature['Args']['size'] {\n if (this.args.size === 'large') {\n return '24';\n } else {\n return '16';\n }\n }\n\n /**\n * Get the class names to apply to the component.\n * @method LinkStandalone#classNames\n * @return {string} The \"class\" attribute to apply to the component.\n */\n get classNames(): string {\n const classes = ['hds-link-standalone'];\n\n // add a class based on the @size argument\n classes.push(`hds-link-standalone--size-${this.size}`);\n\n // add a class based on the @color argument\n classes.push(`hds-link-standalone--color-${this.color}`);\n\n // add a class based on the @iconPosition argument\n classes.push(`hds-link-standalone--icon-position-${this.iconPosition}`);\n\n return classes.join(' ');\n }\n}\n"],"names":["DEFAULT_ICONPOSITION","HdsLinkIconPositionValues","Leading","DEFAULT_COLOR","HdsLinkColorValues","Primary","DEFAULT_SIZE","HdsLinkStandaloneSizeValues","Medium","ICONPOSITIONS","Object","values","COLORS","SIZES","HdsLinkStandalone","Component","constructor","owner","args","href","route","assert","text","undefined","color","join","includes","icon","iconPosition","size","iconSize","classNames","classes","push","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;;AA8BaA,MAAAA,oBAAoB,GAAGC,yBAAyB,CAACC;AACjDC,MAAAA,aAAa,GAAGC,kBAAkB,CAACC;AACnCC,MAAAA,YAAY,GAAGC,2BAA2B,CAACC;AACjD,MAAMC,aAAuB,GAAGC,MAAM,CAACC,MAAM,CAACV,yBAAyB;AACvE,MAAMW,MAAgB,GAAGF,MAAM,CAACC,MAAM,CAACP,kBAAkB;AACzD,MAAMS,KAAe,GAAGH,MAAM,CAACC,MAAM,CAACJ,2BAA2B;AAEzD,MAAMO,iBAAiB,SAASC,SAAS,CAA6B;AACnFC,EAAAA,WAAWA,CAACC,KAAY,EAAEC,IAAwC,EAAE;AAClE,IAAA,KAAK,CAACD,KAAK,EAAEC,IAAI,CAAC;AAClB,IAAA,IAAI,EAAE,IAAI,CAACA,IAAI,CAACC,IAAI,IAAI,IAAI,CAACD,IAAI,CAACE,KAAK,CAAC,EAAE;MACxCC,MAAM,CA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AAG,IAAI,CAACY,IAAI;AAEzCG,IAAAA,MAAM,CACJ,CAAmER,gEAAAA,EAAAA,KAAK,CAACY,IAAI,CAC3E,IACF,CAAC,CAAA,YAAA,EAAeI,IAAI,CAAA,CAAE,EACtBhB,KAAK,CAACa,QAAQ,CAACG,IAAI,CACrB,CAAC;AAED,IAAA,OAAOA,IAAI;AACb;;AAEA;AACF;AACA;AACA;AACA;AACA;EACE,IAAIC,QAAQA,GAAqC;AAC/C,IAAA,IAAI,IAAI,CAACZ,IAAI,CAACW,IAAI,KAAK,OAAO,EAAE;AAC9B,MAAA,OAAO,IAAI;AACb,KAAC,MAAM;AACL,MAAA,OAAO,IAAI;AACb;AACF;;AAEA;AACF;AACA;AACA;AACA;EACE,IAAIE,UAAUA,GAAW;AACvB,IAAA,MAAMC,OAAO,GAAG,CAAC,qBAAqB,CAAC;;AAEvC;IACAA,OAAO,CAACC,IAAI,CAAC,CAAA,0BAAA,EAA6B,IAAI,CAACJ,IAAI,EAAE,CAAC;;AAEtD;IACAG,OAAO,CAACC,IAAI,CAAC,CAAA,2BAAA,EAA8B,IAAI,CAACT,KAAK,EAAE,CAAC;;AAExD;IACAQ,OAAO,CAACC,IAAI,CAAC,CAAA,mCAAA,EAAsC,IAAI,CAACL,YAAY,EAAE,CAAC;AAEvE,IAAA,OAAOI,OAAO,CAACP,IAAI,CAAC,GAAG,CAAC;AAC1B;AACF;AAACS,oBAAA,CAAAC,QAAA,EAnIoBrB,iBAAiB,CAAA;;;;"}
1
+ {"version":3,"file":"standalone.js","sources":["../../../../src/components/hds/link/standalone.ts"],"sourcesContent":["/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { assert } from '@ember/debug';\nimport {\n HdsLinkIconPositionValues,\n HdsLinkColorValues,\n HdsLinkStandaloneSizeValues,\n} from './types.ts';\n\nimport type { HdsInteractiveSignature } from '../interactive/';\nimport type {\n HdsLinkColors,\n HdsLinkIconPositions,\n HdsLinkStandaloneSizes,\n} from './types.ts';\nimport type { HdsIconSignature } from '../icon';\nimport type Owner from '@ember/owner';\n\nexport interface HdsLinkStandaloneSignature {\n Args: HdsInteractiveSignature['Args'] & {\n size?: HdsLinkStandaloneSizes;\n color?: HdsLinkColors;\n text: string;\n icon: HdsIconSignature['Args']['name'];\n iconPosition?: HdsLinkIconPositions;\n };\n Element: HdsInteractiveSignature['Element'];\n}\n\nexport const DEFAULT_ICON_POSITION = HdsLinkIconPositionValues.Leading;\nexport const DEFAULT_COLOR = HdsLinkColorValues.Primary;\nexport const DEFAULT_SIZE = HdsLinkStandaloneSizeValues.Medium;\nexport const ICON_POSITIONS: HdsLinkIconPositions[] = Object.values(\n HdsLinkIconPositionValues\n);\nexport const COLORS: HdsLinkColors[] = Object.values(HdsLinkColorValues);\nexport const SIZES: HdsLinkStandaloneSizes[] = Object.values(\n HdsLinkStandaloneSizeValues\n);\n\nexport default class HdsLinkStandalone extends Component<HdsLinkStandaloneSignature> {\n constructor(owner: Owner, args: HdsLinkStandaloneSignature['Args']) {\n super(owner, args);\n if (!(this.args.href || this.args.route)) {\n assert('@href or @route must be defined for <Hds::Link::Standalone>');\n }\n }\n\n /**\n * @param text\n * @type {string}\n * @description The text of the link. If no text value is defined an error will be thrown.\n */\n get text(): string {\n const { text } = this.args;\n\n assert(\n '@text for \"Hds::Link::Standalone\" must have a valid value',\n text !== undefined\n );\n\n return text;\n }\n\n /**\n * @param color\n * @type {string}\n * @default primary\n * @description Determines the color of link to be used; acceptable values are `primary` and `secondary`\n */\n get color(): HdsLinkColors {\n const { color = DEFAULT_COLOR } = this.args;\n\n assert(\n `@color for \"Hds::Link::Standalone\" must be one of the following: ${COLORS.join(\n ', '\n )}; received: ${color}`,\n COLORS.includes(color)\n );\n\n return color;\n }\n\n /**\n * @param icon\n * @type {string|null}\n * @default null\n * @description The name of the icon to be used. An icon name must be defined.\n */\n get icon(): HdsIconSignature['Args']['name'] {\n const { icon } = this.args;\n\n assert(\n '@icon for \"Hds::Link::Standalone\" must have a valid value',\n icon !== undefined\n );\n\n return icon;\n }\n\n /**\n * @param iconPosition\n * @type {HdsLinkIconPositions}\n * @default leading\n * @description Positions the icon before or after the text; allowed values are `leading` or `trailing`\n */\n get iconPosition(): HdsLinkIconPositions {\n const { iconPosition = DEFAULT_ICON_POSITION } = this.args;\n\n assert(\n `@iconPosition for \"Hds::Link::Standalone\" must be one of the following: ${ICON_POSITIONS.join(\n ', '\n )}; received: ${iconPosition}`,\n ICON_POSITIONS.includes(iconPosition)\n );\n\n return iconPosition;\n }\n\n /**\n * @param size\n * @type {HdsLinkStandaloneSizes}\n * @default medium\n * @description The size of the standalone link; acceptable values are `small`, `medium`, and `large`\n */\n get size(): HdsLinkStandaloneSizes {\n const { size = DEFAULT_SIZE } = this.args;\n\n assert(\n `@size for \"Hds::Link::Standalone\" must be one of the following: ${SIZES.join(\n ', '\n )}; received: ${size}`,\n SIZES.includes(size)\n );\n\n return size;\n }\n\n /**\n * @param iconSize\n * @type {string}\n * @default 16\n * @description ensures that the correct icon size is used. Automatically calculated.\n */\n get iconSize(): HdsIconSignature['Args']['size'] {\n if (this.args.size === 'large') {\n return '24';\n } else {\n return '16';\n }\n }\n\n /**\n * Get the class names to apply to the component.\n * @method LinkStandalone#classNames\n * @return {string} The \"class\" attribute to apply to the component.\n */\n get classNames(): string {\n const classes = ['hds-link-standalone'];\n\n // add a class based on the @size argument\n classes.push(`hds-link-standalone--size-${this.size}`);\n\n // add a class based on the @color argument\n classes.push(`hds-link-standalone--color-${this.color}`);\n\n // add a class based on the @iconPosition argument\n classes.push(`hds-link-standalone--icon-position-${this.iconPosition}`);\n\n return classes.join(' ');\n }\n}\n"],"names":["DEFAULT_ICON_POSITION","HdsLinkIconPositionValues","Leading","DEFAULT_COLOR","HdsLinkColorValues","Primary","DEFAULT_SIZE","HdsLinkStandaloneSizeValues","Medium","ICON_POSITIONS","Object","values","COLORS","SIZES","HdsLinkStandalone","Component","constructor","owner","args","href","route","assert","text","undefined","color","join","includes","icon","iconPosition","size","iconSize","classNames","classes","push","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;;AA8BaA,MAAAA,qBAAqB,GAAGC,yBAAyB,CAACC;AAClDC,MAAAA,aAAa,GAAGC,kBAAkB,CAACC;AACnCC,MAAAA,YAAY,GAAGC,2BAA2B,CAACC;AACjD,MAAMC,cAAsC,GAAGC,MAAM,CAACC,MAAM,CACjEV,yBACF;AACO,MAAMW,MAAuB,GAAGF,MAAM,CAACC,MAAM,CAACP,kBAAkB;AAChE,MAAMS,KAA+B,GAAGH,MAAM,CAACC,MAAM,CAC1DJ,2BACF;AAEe,MAAMO,iBAAiB,SAASC,SAAS,CAA6B;AACnFC,EAAAA,WAAWA,CAACC,KAAY,EAAEC,IAAwC,EAAE;AAClE,IAAA,KAAK,CAACD,KAAK,EAAEC,IAAI,CAAC;AAClB,IAAA,IAAI,EAAE,IAAI,CAACA,IAAI,CAACC,IAAI,IAAI,IAAI,CAACD,IAAI,CAACE,KAAK,CAAC,EAAE;MACxCC,MAAM,CAAC,6DAA6D,CAAC;AACvE;AACF;;AAEA;AACF;AACA;AACA;AACA;EACE,IAAIC,IAAIA,GAAW;IACjB,MAAM;AAAEA,MAAAA;KAAM,GAAG,IAAI,CAACJ,IAAI;AAE1BG,IAAAA,MAAM,CACJ,2DAA2D,EAC3DC,IAAI,KAAKC,SACX,CAAC;AAED,IAAA,OAAOD,IAAI;AACb;;AAEA;AACF;AACA;AACA;AACA;AACA;EACE,IAAIE,KAAKA,GAAkB;IACzB,MAAM;AAAEA,MAAAA,KAAK,GAAGrB;KAAe,GAAG,IAAI,CAACe,IAAI;AAE3CG,IAAAA,MAAM,CACJ,CAAoET,iEAAAA,EAAAA,MAAM,CAACa,IAAI,CAC7E,IACF,CAAC,CAAA,YAAA,EAAeD,KAAK,CAAA,CAAE,EACvBZ,MAAM,CAACc,QAAQ,CAACF,KAAK,CACvB,CAAC;AAED,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,OAAO,CAACC,IAAI,CAAC,CAAA,0BAAA,EAA6B,IAAI,CAACJ,IAAI,EAAE,CAAC;;AAEtD;IACAG,OAAO,CAACC,IAAI,CAAC,CAAA,2BAAA,EAA8B,IAAI,CAACT,KAAK,EAAE,CAAC;;AAExD;IACAQ,OAAO,CAACC,IAAI,CAAC,CAAA,mCAAA,EAAsC,IAAI,CAACL,YAAY,EAAE,CAAC;AAEvE,IAAA,OAAOI,OAAO,CAACP,IAAI,CAAC,GAAG,CAAC;AAC1B;AACF;AAACS,oBAAA,CAAAC,QAAA,EAnIoBrB,iBAAiB,CAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/components/hds/popover-primitive/index.ts"],"sourcesContent":["/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { action } from '@ember/object';\nimport { assert, warn } from '@ember/debug';\nimport { next } from '@ember/runloop';\nimport { guidFor } from '@ember/object/internals';\nimport { modifier } from 'ember-modifier';\n\nimport registerEvent from '../../../modifiers/hds-register-event.ts';\nimport anchoredPositionModifier from '../../../modifiers/hds-anchored-position.ts';\n\nimport type { FloatingUIOptions } from '../../../modifiers/hds-anchored-position.ts';\nimport type { ModifierLike } from '@glint/template';\nimport type Owner from '@ember/owner';\n\nexport interface HdsPopoverPrimitiveSignature {\n Args: {\n isOpen?: boolean;\n enableSoftEvents?: boolean;\n enableClickEvents?: boolean;\n onOpen?: () => void;\n onClose?: () => void;\n };\n Blocks: {\n default: [\n {\n setupPrimitiveContainer: ModifierLike<SetupPrimitiveContainerModifier>;\n setupPrimitiveToggle: ModifierLike<SetupPrimitiveToggleModifier>;\n setupPrimitivePopover: ModifierLike<SetupPrimitivePopoverModifier>;\n toggleElement?: HTMLButtonElement;\n popoverElement?: HTMLElement;\n isOpen: boolean;\n showPopover: () => void;\n hidePopover: () => void;\n togglePopover: () => void;\n },\n ];\n };\n}\n\ninterface SetupPrimitiveContainerModifier {\n Element: HTMLElement;\n}\n\nexport interface SetupPrimitiveToggleModifier {\n Element: HTMLButtonElement;\n}\n\nexport interface SetupPrimitivePopoverModifier {\n Element: HTMLElement;\n Args: {\n Positional: [];\n Named: { anchoredPositionOptions: FloatingUIOptions };\n };\n}\n\nexport default class HdsPopoverPrimitive extends Component<HdsPopoverPrimitiveSignature> {\n @tracked private _isOpen;\n @tracked private _isClosing = false;\n private _containerElement?: HTMLElement;\n private _toggleElement?: HTMLButtonElement;\n private _popoverElement?: HTMLElement;\n // this will enable \"soft\" events for the toggle (\"hover\" and \"focus\")\n enableSoftEvents = this.args.enableSoftEvents ?? false;\n // this will enable \"click\" events for the toggle\n enableClickEvents = this.args.enableClickEvents ?? false;\n private _timer?: ReturnType<typeof setTimeout> | null;\n\n constructor(owner: Owner, args: HdsPopoverPrimitiveSignature['Args']) {\n super(owner, args);\n this._isOpen = this.args.isOpen ?? false;\n }\n\n setupPrimitiveContainer = modifier<SetupPrimitiveContainerModifier>(\n (element: HTMLElement): void => {\n this._containerElement = element;\n\n // we register the \"soft\" events\n if (this.enableSoftEvents) {\n // @ts-expect-error: known issue with type of invocation\n registerEvent(this._containerElement, [\n 'mouseenter',\n // eslint-disable-next-line @typescript-eslint/unbound-method\n this.onMouseEnter,\n ]);\n // @ts-expect-error: known issue with type of invocation\n registerEvent(this._containerElement, [\n 'mouseleave',\n // eslint-disable-next-line @typescript-eslint/unbound-method\n this.onMouseLeave,\n ]);\n // @ts-expect-error: known issue with type of invocation\n // eslint-disable-next-line @typescript-eslint/unbound-method\n registerEvent(this._containerElement, ['focusin', this.onFocusIn]);\n }\n // we always want the focusOut event\n // @ts-expect-error: known issue with type of invocation\n // eslint-disable-next-line @typescript-eslint/unbound-method\n registerEvent(this._containerElement, ['focusout', this.onFocusOut]);\n }\n );\n\n setupPrimitiveToggle = modifier<SetupPrimitiveToggleModifier>(\n (element: HTMLButtonElement): void => {\n this._toggleElement = element;\n\n assert(\n `The toggle element of \"Hds::PopoverPrimitive\" must be a <button>; element received: <${element.tagName.toLowerCase()}>`,\n element instanceof HTMLButtonElement\n );\n }\n );\n\n setupPrimitivePopover = modifier(\n (\n element: HTMLElement,\n _positional,\n named: { anchoredPositionOptions: FloatingUIOptions }\n ): void => {\n this._popoverElement = element;\n\n // We need to create a popoverId in order to connect the popover and the toggle with aria-controls\n // and an id is needed to implement `onclick` event listeners\n if (this._toggleElement) {\n let popoverId;\n if (this._popoverElement.id) {\n popoverId = this._popoverElement.id;\n } else {\n // we need a DOM id for the `aria-controls` and `popovertarget` attributes\n popoverId = guidFor(this);\n this._popoverElement.id = popoverId;\n }\n this._toggleElement.setAttribute('aria-controls', popoverId);\n\n // for the click events we don't use `onclick` event listeners, but we rely on the `popovertarget` attribute\n // provided by the Popover API which does all the magic for us without needing JS code\n // (important: to work it needs to be applied to a button)\n if (this.enableClickEvents) {\n this._toggleElement.setAttribute('popovertarget', popoverId);\n }\n }\n\n // this should be an extremely edge case, but in the case the popover needs to be initially forced to be open\n // we need to use the \"manual\" state to support the case of multiple \"menus\" opened at the same time\n // IMPORTANT! if a \"popover\" is set to \"open\" with a \"manual\" state, then it can't be closed via `esc` and `click outside`\n if (this.args.isOpen) {\n this._popoverElement.popover = 'manual';\n this._popoverElement.showPopover();\n } else {\n this._popoverElement.popover = 'auto';\n }\n\n // Register \"onBeforeToggle\" + \"onToggle\" callback functions to be called when a native 'toggle' event is dispatched\n // @ts-expect-error: known issue with type of invocation\n registerEvent(this._popoverElement, [\n 'beforetoggle',\n // eslint-disable-next-line @typescript-eslint/unbound-method\n this.onBeforeTogglePopover,\n ]);\n // @ts-expect-error: known issue with type of invocation\n // eslint-disable-next-line @typescript-eslint/unbound-method\n registerEvent(this._popoverElement, ['toggle', this.onTogglePopover]);\n\n // we need to spread the argument because if it's set via `{{ hash … }}` Ember complains when we overwrite one of its values\n const anchoredPositionOptions: FloatingUIOptions = {\n ...named.anchoredPositionOptions,\n };\n\n // Apply the `hds-anchored-position` modifier to the \"popover\" element\n // (notice: this function runs the first time when the element the modifier was applied to is inserted into the DOM, and it autotracks while running.\n // Any tracked values that it accesses will be tracked, including the arguments it receives, and if any of them changes, the function will run again)\n // This modifiers uses the Floating UI library to provide:\n // - positioning of the \"popover\" in relation to the \"toggle\"\n // - collision detection (optional)\n // eslint-disable-next-line ember/no-runloop\n next((): void => {\n // @ts-expect-error: known issue with type of invocation\n anchoredPositionModifier(\n this._popoverElement, // element the modifier is attached to\n [this._toggleElement], // positional arguments\n anchoredPositionOptions // named arguments\n );\n });\n }\n );\n\n @action\n showPopover(): void {\n try {\n if (this._popoverElement) {\n this._popoverElement.showPopover();\n }\n } catch (error) {\n warn(\n `The invocation of \\`showPopover\\` for the popover element caused an unexpected error: ${JSON.stringify(\n error\n )}`,\n {\n id: 'hds-popover.show-popover-action.invocation-failed',\n }\n );\n }\n }\n\n @action\n hidePopover(): void {\n try {\n if (this._popoverElement) {\n this._popoverElement.hidePopover();\n }\n } catch (error) {\n warn(\n `The invocation of \\`hidePopover\\` for the popover element caused an unexpected error: ${JSON.stringify(\n error\n )}`,\n {\n id: 'hds-popover.hide-popover-action.invocation-failed',\n }\n );\n }\n }\n\n @action\n togglePopover(): void {\n try {\n if (this._popoverElement) {\n this._popoverElement.togglePopover();\n }\n } catch (error) {\n warn(\n `The invocation of \\`togglePopover\\` for the popover element caused an unexpected error: ${JSON.stringify(\n error\n )}`,\n {\n id: 'hds-popover.toggle-popover-action.invocation-failed',\n }\n );\n }\n }\n\n // fired just _before_ the \"popover\" is shown or hidden\n @action\n onBeforeTogglePopover(event: ToggleEvent): void {\n if (event.newState === 'closed') {\n // we need this flag to check if it's in the \"closing\" process,\n // because the browser automatically returns the focus to the \"trigger\" button\n // and this would re-open immediately the popover because of the `focusin` event\n this._isClosing = true;\n }\n }\n\n // fired just _after_ the \"popover\" is shown or hidden\n @action\n onTogglePopover(event: ToggleEvent): void {\n if (event.newState === 'open') {\n this._isOpen = true;\n\n // we call the \"onOpen\" callback if it exists (and is a function)\n const { onOpen } = this.args;\n if (typeof onOpen === 'function') {\n onOpen();\n }\n } else {\n this._isOpen = false;\n\n // reset the \"isClosing\" flag (the `toggle` event is fired _after_ the popover is closed)\n this._isClosing = false;\n\n // if the popover was initially forced to be open (using the \"manual\" state) then revert its status to `auto` once the user interacts with it\n if (this.args.isOpen) {\n if (this._popoverElement) {\n this._popoverElement.popover = 'auto';\n }\n }\n\n // we call the \"onClose\" callback if it exists (and is a function)\n const { onClose } = this.args;\n if (typeof onClose === 'function') {\n onClose();\n }\n }\n }\n\n @action\n onMouseEnter(): void {\n if (this._timer) {\n clearTimeout(this._timer);\n }\n this.showPopover();\n }\n\n @action\n onFocusIn(): void {\n // don't re-open the popover if the focus is returned because the closing\n if (!this._isClosing) {\n if (this._timer) {\n clearTimeout(this._timer);\n }\n this.showPopover();\n }\n }\n\n @action\n onMouseLeave(): void {\n this._timer = setTimeout((): void => this.hidePopover(), 500);\n }\n\n @action\n onFocusOut(event: FocusEvent): void {\n if (this._containerElement) {\n let isFocusStillInside = false;\n if (\n event.relatedTarget &&\n // if the related target is not part of the disclosed content we close the disclosed container\n this._containerElement.contains(event.relatedTarget as Node)\n ) {\n isFocusStillInside = true;\n } else if (\n document.activeElement &&\n // due to inconsistent implementation of relatedTarget across browsers we use the activeElement as a fallback\n this._containerElement.contains(document.activeElement)\n ) {\n isFocusStillInside = true;\n }\n // if the target receiving the focus is _not_ part of the disclosed content we close the disclosed container\n if (!isFocusStillInside) {\n this.hidePopover();\n }\n }\n }\n}\n"],"names":["HdsPopoverPrimitive","Component","g","prototype","tracked","i","void 0","_containerElement","_toggleElement","_popoverElement","enableSoftEvents","args","enableClickEvents","_timer","constructor","owner","_isOpen","isOpen","setupPrimitiveContainer","modifier","element","registerEvent","onMouseEnter","onMouseLeave","onFocusIn","onFocusOut","setupPrimitiveToggle","assert","tagName","toLowerCase","HTMLButtonElement","setupPrimitivePopover","_positional","named","popoverId","id","guidFor","setAttribute","popover","showPopover","onBeforeTogglePopover","onTogglePopover","anchoredPositionOptions","next","anchoredPositionModifier","error","warn","JSON","stringify","n","action","hidePopover","togglePopover","event","newState","_isClosing","onOpen","onClose","clearTimeout","setTimeout","isFocusStillInside","relatedTarget","contains","document","activeElement","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;;AA0De,MAAMA,mBAAmB,SAASC,SAAS,CAA+B;AAAA,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,SAAA,EAAA,CACtFC,OAAO,CAAA,CAAA;AAAA;AAAA,EAAA,QAAA,IAAAC,CAAA,CAAA,IAAA,EAAA,SAAA,CAAA,EAAAC,MAAA;AAAA,EAAA;IAAAJ,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,YAAA,EAAA,CACPC,OAAO,CAAA,EAAA,YAAA;AAAA,MAAA,OAAsB,KAAK;AAAA,KAAA,CAAA;AAAA;AAAA,EAAA,WAAA,IAAAC,CAAA,CAAA,IAAA,EAAA,YAAA,CAAA,EAAAC,MAAA;EAC3BC,iBAAiB;EACjBC,cAAc;EACdC,eAAe;AACvB;AACAC,EAAAA,gBAAgB,GAAG,IAAI,CAACC,IAAI,CAACD,gBAAgB,IAAI,KAAK;AACtD;AACAE,EAAAA,iBAAiB,GAAG,IAAI,CAACD,IAAI,CAACC,iBAAiB,IAAI,KAAK;EAChDC,MAAM;AAEdC,EAAAA,WAAWA,CAACC,KAAY,EAAEJ,IAA0C,EAAE;AACpE,IAAA,KAAK,CAACI,KAAK,EAAEJ,IAAI,CAAC;IAClB,IAAI,CAACK,OAAO,GAAG,IAAI,CAACL,IAAI,CAACM,MAAM,IAAI,KAAK;AAC1C;AAEAC,EAAAA,uBAAuB,GAAGC,QAAQ,CAC/BC,OAAoB,IAAW;IAC9B,IAAI,CAACb,iBAAiB,GAAGa,OAAO;;AAEhC;IACA,IAAI,IAAI,CAACV,gBAAgB,EAAE;AACzB;AACAW,MA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ACpB;AACF;AAAC,EAAA;IAAAU,CAAA,CAAA,IAAA,CAAA9C,SAAA,EAAA,WAAA,EAAA,CATA+C,MAAM,CAAA,CAAA;AAAA;AAYP3B,EAAAA,YAAYA,GAAS;AACnB,IAAA,IAAI,CAACV,MAAM,GAAG8C,UAAU,CAAC,MAAY,IAAI,CAACR,WAAW,EAAE,EAAE,GAAG,CAAC;AAC/D;AAAC,EAAA;IAAAF,CAAA,CAAA,IAAA,CAAA9C,SAAA,EAAA,cAAA,EAAA,CAHA+C,MAAM,CAAA,CAAA;AAAA;EAMPzB,UAAUA,CAAC4B,KAAiB,EAAQ;IAClC,IAAI,IAAI,CAAC9C,iBAAiB,EAAE;MAC1B,IAAIqD,kBAAkB,GAAG,KAAK;MAC9B,IACEP,KAAK,CAACQ,aAAa;AACnB;MACA,IAAI,CAACtD,iBAAiB,CAACuD,QAAQ,CAACT,KAAK,CAACQ,aAAqB,CAAC,EAC5D;AACAD,QAAAA,kBAAkB,GAAG,IAAI;AAC3B,OAAC,MAAM,IACLG,QAAQ,CAACC,aAAa;AACtB;MACA,IAAI,CAACzD,iBAAiB,CAACuD,QAAQ,CAACC,QAAQ,CAACC,aAAa,CAAC,EACvD;AACAJ,QAAAA,kBAAkB,GAAG,IAAI;AAC3B;AACA;MACA,IAAI,CAACA,kBAAkB,EAAE;QACvB,IAAI,CAACT,WAAW,EAAE;AACpB;AACF;AACF;AAAC,EAAA;IAAAF,CAAA,CAAA,IAAA,CAAA9C,SAAA,EAAA,YAAA,EAAA,CAtBA+C,MAAM,CAAA,CAAA;AAAA;AAuBT;AAACe,oBAAA,CAAAC,QAAA,EAlRoBlE,mBAAmB,CAAA;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/components/hds/popover-primitive/index.ts"],"sourcesContent":["/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { action } from '@ember/object';\nimport { assert, warn } from '@ember/debug';\nimport { next } from '@ember/runloop';\nimport { guidFor } from '@ember/object/internals';\nimport { modifier } from 'ember-modifier';\n\nimport registerEvent from '../../../modifiers/hds-register-event.ts';\nimport anchoredPositionModifier from '../../../modifiers/hds-anchored-position.ts';\n\nimport type { HdsAnchoredPositionOptions } from '../../../modifiers/hds-anchored-position.ts';\nimport type { ModifierLike } from '@glint/template';\nimport type Owner from '@ember/owner';\n\nexport interface HdsPopoverPrimitiveSignature {\n Args: {\n isOpen?: boolean;\n enableSoftEvents?: boolean;\n enableClickEvents?: boolean;\n onOpen?: () => void;\n onClose?: () => void;\n };\n Blocks: {\n default: [\n {\n setupPrimitiveContainer: ModifierLike<SetupPrimitiveContainerModifier>;\n setupPrimitiveToggle: ModifierLike<SetupPrimitiveToggleModifier>;\n setupPrimitivePopover: ModifierLike<SetupPrimitivePopoverModifier>;\n toggleElement?: HTMLButtonElement;\n popoverElement?: HTMLElement;\n isOpen: boolean;\n showPopover: () => void;\n hidePopover: () => void;\n togglePopover: () => void;\n },\n ];\n };\n}\n\ninterface SetupPrimitiveContainerModifier {\n Element: HTMLElement;\n}\n\nexport interface SetupPrimitiveToggleModifier {\n Element: HTMLButtonElement;\n}\n\nexport interface SetupPrimitivePopoverModifier {\n Element: HTMLElement;\n Args: {\n Positional: [];\n Named: { anchoredPositionOptions: HdsAnchoredPositionOptions };\n };\n}\n\nexport default class HdsPopoverPrimitive extends Component<HdsPopoverPrimitiveSignature> {\n @tracked private _isOpen;\n @tracked private _isClosing = false;\n private _containerElement?: HTMLElement;\n private _toggleElement?: HTMLButtonElement;\n private _popoverElement?: HTMLElement;\n // this will enable \"soft\" events for the toggle (\"hover\" and \"focus\")\n enableSoftEvents = this.args.enableSoftEvents ?? false;\n // this will enable \"click\" events for the toggle\n enableClickEvents = this.args.enableClickEvents ?? false;\n private _timer?: ReturnType<typeof setTimeout> | null;\n\n constructor(owner: Owner, args: HdsPopoverPrimitiveSignature['Args']) {\n super(owner, args);\n this._isOpen = this.args.isOpen ?? false;\n }\n\n setupPrimitiveContainer = modifier<SetupPrimitiveContainerModifier>(\n (element: HTMLElement): void => {\n this._containerElement = element;\n\n // we register the \"soft\" events\n if (this.enableSoftEvents) {\n // @ts-expect-error: known issue with type of invocation\n registerEvent(this._containerElement, [\n 'mouseenter',\n // eslint-disable-next-line @typescript-eslint/unbound-method\n this.onMouseEnter,\n ]);\n // @ts-expect-error: known issue with type of invocation\n registerEvent(this._containerElement, [\n 'mouseleave',\n // eslint-disable-next-line @typescript-eslint/unbound-method\n this.onMouseLeave,\n ]);\n // @ts-expect-error: known issue with type of invocation\n // eslint-disable-next-line @typescript-eslint/unbound-method\n registerEvent(this._containerElement, ['focusin', this.onFocusIn]);\n }\n // we always want the focusOut event\n // @ts-expect-error: known issue with type of invocation\n // eslint-disable-next-line @typescript-eslint/unbound-method\n registerEvent(this._containerElement, ['focusout', this.onFocusOut]);\n }\n );\n\n setupPrimitiveToggle = modifier<SetupPrimitiveToggleModifier>(\n (element: HTMLButtonElement): void => {\n this._toggleElement = element;\n\n assert(\n `The toggle element of \"Hds::PopoverPrimitive\" must be a <button>; element received: <${element.tagName.toLowerCase()}>`,\n element instanceof HTMLButtonElement\n );\n }\n );\n\n setupPrimitivePopover = modifier(\n (\n element: HTMLElement,\n _positional,\n named: { anchoredPositionOptions: HdsAnchoredPositionOptions }\n ): void => {\n this._popoverElement = element;\n\n // We need to create a popoverId in order to connect the popover and the toggle with aria-controls\n // and an id is needed to implement `onclick` event listeners\n if (this._toggleElement) {\n let popoverId;\n if (this._popoverElement.id) {\n popoverId = this._popoverElement.id;\n } else {\n // we need a DOM id for the `aria-controls` and `popovertarget` attributes\n popoverId = guidFor(this);\n this._popoverElement.id = popoverId;\n }\n this._toggleElement.setAttribute('aria-controls', popoverId);\n\n // for the click events we don't use `onclick` event listeners, but we rely on the `popovertarget` attribute\n // provided by the Popover API which does all the magic for us without needing JS code\n // (important: to work it needs to be applied to a button)\n if (this.enableClickEvents) {\n this._toggleElement.setAttribute('popovertarget', popoverId);\n }\n }\n\n // this should be an extremely edge case, but in the case the popover needs to be initially forced to be open\n // we need to use the \"manual\" state to support the case of multiple \"menus\" opened at the same time\n // IMPORTANT! if a \"popover\" is set to \"open\" with a \"manual\" state, then it can't be closed via `esc` and `click outside`\n if (this.args.isOpen) {\n this._popoverElement.popover = 'manual';\n this._popoverElement.showPopover();\n } else {\n this._popoverElement.popover = 'auto';\n }\n\n // Register \"onBeforeToggle\" + \"onToggle\" callback functions to be called when a native 'toggle' event is dispatched\n // @ts-expect-error: known issue with type of invocation\n registerEvent(this._popoverElement, [\n 'beforetoggle',\n // eslint-disable-next-line @typescript-eslint/unbound-method\n this.onBeforeTogglePopover,\n ]);\n // @ts-expect-error: known issue with type of invocation\n // eslint-disable-next-line @typescript-eslint/unbound-method\n registerEvent(this._popoverElement, ['toggle', this.onTogglePopover]);\n\n // we need to spread the argument because if it's set via `{{ hash … }}` Ember complains when we overwrite one of its values\n const anchoredPositionOptions: HdsAnchoredPositionOptions = {\n ...named.anchoredPositionOptions,\n };\n\n // Apply the `hds-anchored-position` modifier to the \"popover\" element\n // (notice: this function runs the first time when the element the modifier was applied to is inserted into the DOM, and it autotracks while running.\n // Any tracked values that it accesses will be tracked, including the arguments it receives, and if any of them changes, the function will run again)\n // This modifiers uses the Floating UI library to provide:\n // - positioning of the \"popover\" in relation to the \"toggle\"\n // - collision detection (optional)\n // eslint-disable-next-line ember/no-runloop\n next((): void => {\n // @ts-expect-error: known issue with type of invocation\n anchoredPositionModifier(\n this._popoverElement, // element the modifier is attached to\n [this._toggleElement], // positional arguments\n anchoredPositionOptions // named arguments\n );\n });\n }\n );\n\n @action\n showPopover(): void {\n try {\n if (this._popoverElement) {\n this._popoverElement.showPopover();\n }\n } catch (error) {\n warn(\n `The invocation of \\`showPopover\\` for the popover element caused an unexpected error: ${JSON.stringify(\n error\n )}`,\n {\n id: 'hds-popover.show-popover-action.invocation-failed',\n }\n );\n }\n }\n\n @action\n hidePopover(): void {\n try {\n if (this._popoverElement) {\n this._popoverElement.hidePopover();\n }\n } catch (error) {\n warn(\n `The invocation of \\`hidePopover\\` for the popover element caused an unexpected error: ${JSON.stringify(\n error\n )}`,\n {\n id: 'hds-popover.hide-popover-action.invocation-failed',\n }\n );\n }\n }\n\n @action\n togglePopover(): void {\n try {\n if (this._popoverElement) {\n this._popoverElement.togglePopover();\n }\n } catch (error) {\n warn(\n `The invocation of \\`togglePopover\\` for the popover element caused an unexpected error: ${JSON.stringify(\n error\n )}`,\n {\n id: 'hds-popover.toggle-popover-action.invocation-failed',\n }\n );\n }\n }\n\n // fired just _before_ the \"popover\" is shown or hidden\n @action\n onBeforeTogglePopover(event: ToggleEvent): void {\n if (event.newState === 'closed') {\n // we need this flag to check if it's in the \"closing\" process,\n // because the browser automatically returns the focus to the \"trigger\" button\n // and this would re-open immediately the popover because of the `focusin` event\n this._isClosing = true;\n }\n }\n\n // fired just _after_ the \"popover\" is shown or hidden\n @action\n onTogglePopover(event: ToggleEvent): void {\n if (event.newState === 'open') {\n this._isOpen = true;\n\n // we call the \"onOpen\" callback if it exists (and is a function)\n const { onOpen } = this.args;\n if (typeof onOpen === 'function') {\n onOpen();\n }\n } else {\n this._isOpen = false;\n\n // reset the \"isClosing\" flag (the `toggle` event is fired _after_ the popover is closed)\n this._isClosing = false;\n\n // if the popover was initially forced to be open (using the \"manual\" state) then revert its status to `auto` once the user interacts with it\n if (this.args.isOpen) {\n if (this._popoverElement) {\n this._popoverElement.popover = 'auto';\n }\n }\n\n // we call the \"onClose\" callback if it exists (and is a function)\n const { onClose } = this.args;\n if (typeof onClose === 'function') {\n onClose();\n }\n }\n }\n\n @action\n onMouseEnter(): void {\n if (this._timer) {\n clearTimeout(this._timer);\n }\n this.showPopover();\n }\n\n @action\n onFocusIn(): void {\n // don't re-open the popover if the focus is returned because the closing\n if (!this._isClosing) {\n if (this._timer) {\n clearTimeout(this._timer);\n }\n this.showPopover();\n }\n }\n\n @action\n onMouseLeave(): void {\n this._timer = setTimeout((): void => this.hidePopover(), 500);\n }\n\n @action\n onFocusOut(event: FocusEvent): void {\n if (this._containerElement) {\n let isFocusStillInside = false;\n if (\n event.relatedTarget &&\n // if the related target is not part of the disclosed content we close the disclosed container\n this._containerElement.contains(event.relatedTarget as Node)\n ) {\n isFocusStillInside = true;\n } else if (\n document.activeElement &&\n // due to inconsistent implementation of relatedTarget across browsers we use the activeElement as a fallback\n this._containerElement.contains(document.activeElement)\n ) {\n isFocusStillInside = true;\n }\n // if the target receiving the focus is _not_ part of the disclosed content we close the disclosed container\n if (!isFocusStillInside) {\n this.hidePopover();\n }\n }\n }\n}\n"],"names":["HdsPopoverPrimitive","Component","g","prototype","tracked","i","void 0","_containerElement","_toggleElement","_popoverElement","enableSoftEvents","args","enableClickEvents","_timer","constructor","owner","_isOpen","isOpen","setupPrimitiveContainer","modifier","element","registerEvent","onMouseEnter","onMouseLeave","onFocusIn","onFocusOut","setupPrimitiveToggle","assert","tagName","toLowerCase","HTMLButtonElement","setupPrimitivePopover","_positional","named","popoverId","id","guidFor","setAttribute","popover","showPopover","onBeforeTogglePopover","onTogglePopover","anchoredPositionOptions","next","anchoredPositionModifier","error","warn","JSON","stringify","n","action","hidePopover","togglePopover","event","newState","_isClosing","onOpen","onClose","clearTimeout","setTimeout","isFocusStillInside","relatedTarget","contains","document","activeElement","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;;AA0De,MAAMA,mBAAmB,SAASC,SAAS,CAA+B;AAAA,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,SAAA,EAAA,CACtFC,OAAO,CAAA,CAAA;AAAA;AAAA,EAAA,QAAA,IAAAC,CAAA,CAAA,IAAA,EAAA,SAAA,CAAA,EAAAC,MAAA;AAAA,EAAA;IAAAJ,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,YAAA,EAAA,CACPC,OAAO,CAAA,EAAA,YAAA;AAAA,MAAA,OA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qB,CAAC,EAC5D;AACAD,QAAAA,kBAAkB,GAAG,IAAI;AAC3B,OAAC,MAAM,IACLG,QAAQ,CAACC,aAAa;AACtB;MACA,IAAI,CAACzD,iBAAiB,CAACuD,QAAQ,CAACC,QAAQ,CAACC,aAAa,CAAC,EACvD;AACAJ,QAAAA,kBAAkB,GAAG,IAAI;AAC3B;AACA;MACA,IAAI,CAACA,kBAAkB,EAAE;QACvB,IAAI,CAACT,WAAW,EAAE;AACpB;AACF;AACF;AAAC,EAAA;IAAAF,CAAA,CAAA,IAAA,CAAA9C,SAAA,EAAA,YAAA,EAAA,CAtBA+C,MAAM,CAAA,CAAA;AAAA;AAuBT;AAACe,oBAAA,CAAAC,QAAA,EAlRoBlE,mBAAmB,CAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"bubble.js","sources":["../../../../src/components/hds/rich-tooltip/bubble.ts"],"sourcesContent":["/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { assert } from '@ember/debug';\n\nimport type { ModifierLike } from '@glint/template';\nimport type { SetupPrimitivePopoverModifier } from '../popover-primitive';\nimport type { FloatingUIOptions } from '../../../modifiers/hds-anchored-position.ts';\nimport {\n DEFAULT_PLACEMENT,\n PLACEMENTS,\n} from '../../../modifiers/hds-anchored-position.ts';\n\nexport interface HdsRichTooltipBubbleSignature {\n Args: {\n placement?: FloatingUIOptions['placement'];\n offset?: FloatingUIOptions['offsetOptions'];\n enableCollisionDetection?: FloatingUIOptions['enableCollisionDetection'];\n width?: string;\n height?: string;\n isOpen?: boolean;\n popoverId: string;\n arrowId: string;\n setupPrimitivePopover: ModifierLike<SetupPrimitivePopoverModifier>;\n };\n Blocks: {\n default: [];\n };\n Element: HTMLDivElement;\n}\n\nexport default class HdsRichTooltipBubble extends Component<HdsRichTooltipBubbleSignature> {\n /**\n * @param placement\n * @type {string}\n * @description Determines the position of the \"popover\"\n */\n get placement(): FloatingUIOptions['placement'] {\n const { placement = DEFAULT_PLACEMENT } = this.args;\n\n assert(\n `@placement for \"Hds::RichTooltip::Bubble\" must be one of the following: ${PLACEMENTS.join(\n ', '\n )}; received: ${placement}`,\n PLACEMENTS.includes(placement)\n );\n\n return placement;\n }\n\n get enableCollisionDetection(): FloatingUIOptions['enableCollisionDetection'] {\n return this.args.enableCollisionDetection ?? true;\n }\n\n get sizingStyles(): Record<string, string> {\n const sizingStyles: {\n width?: string;\n 'max-width'?: string;\n height?: string;\n 'max-height'?: string;\n } = {};\n\n if (this.args.width) {\n sizingStyles['width'] = this.args.width;\n sizingStyles['max-width'] = 'none';\n }\n\n if (this.args.height) {\n sizingStyles['height'] = this.args.height;\n sizingStyles['max-height'] = 'none';\n }\n\n return sizingStyles;\n }\n\n get anchoredPositionOptions(): {\n placement: FloatingUIOptions['placement'];\n offsetOptions: FloatingUIOptions['offsetOptions'];\n enableCollisionDetection: FloatingUIOptions['enableCollisionDetection'];\n arrowSelector: string;\n arrowPadding: FloatingUIOptions['arrowPadding'];\n } {\n // custom options specific for the `RichTooltip` component\n // for details see the `hds-anchored-position` modifier\n return {\n placement: this.placement,\n offsetOptions: this.args.offset ?? 12,\n enableCollisionDetection: this.args.enableCollisionDetection ?? true,\n arrowSelector: `#${this.args.arrowId}`,\n arrowPadding: 12,\n };\n }\n}\n"],"names":["HdsRichTooltipBubble","Component","placement","DEFAULT_PLACEMENT","args","assert","PLACEMENTS","join","includes","enableCollisionDetection","sizingStyles","width","height","anchoredPositionOptions","offsetOptions","offset","arrowSelector","arrowId","arrowPadding","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;;AA+Be,MAAMA,oBAAoB,SAASC,SAAS,CAAgC;AACzF;AACF;AACA;AACA;AACA;EACE,IAAIC,SAASA,GAAmC;IAC9C,MAAM;AAAEA,MAAAA,SAAS,GAAGC;KAAmB,GAAG,IAAI,CAACC,IAAI;AAEnDC,IAAAA,MAAM,CACJ,CAA2EC,wEAAAA,EAAAA,UAAU,CAACC,IAAI,CACxF,IACF,CAAC,CAAA,YAAA,EAAeL,SAAS,CAAA,CAAE,EAC3BI,UAAU,CAACE,QAAQ,CAACN,SAAS,CAC/B,CAAC;AAED,IAAA,OAAOA,SAAS;AAClB;EAEA,IAAIO,wBAAwBA,GAAkD;AAC5E,IAAA,OAAO,IAAI,CAACL,IAAI,CAACK,wBAAwB,IAAI,IAAI;AACnD;EAEA,IAAIC,YAAYA,GAA2B;IACzC,MAAMA,YAKL,GAAG,EAAE;AAEN,IAAA,IAAI,IAAI,CAACN,IAAI,CAACO,KAAK,EAAE;MACnBD,YAAY,CAAC,OAAO,CAAC,GAAG,IAAI,CAACN,IAAI,CAACO,KAAK;AACvCD,MAAAA,YAAY,CAAC,WAAW,CAAC,GAAG,MAAM;AACpC;AAEA,IAAA,IAAI,IAAI,CAACN,IAAI,CAACQ,MAAM,EAAE;MACpBF,YAAY,CAAC,QAAQ,CAAC,GAAG,IAAI,CAACN,IAAI,CAACQ,MAAM;AACzCF,MAAAA,YAAY,CAAC,YAAY,CAAC,GAAG,MAAM;AACrC;AAEA,IAAA,OAAOA,YAAY;AACrB;EAEA,IAAIG,uBAAuBA,GAMzB;AACA;AACA;IACA,OAAO;MACLX,SAAS,EAAE,IAAI,CAACA,SAAS;AACzBY,MAAAA,aAAa,EAAE,IAAI,CAACV,IAAI,CAACW,MAAM,IAAI,EAAE;AACrCN,MAAAA,wBAAwB,EAAE,IAAI,CAACL,IAAI,CAACK,wBAAwB,IAAI,IAAI;AACpEO,MAAAA,aAAa,EAAE,CAAI,CAAA,EAAA,IAAI,CAACZ,IAAI,CAACa,OAAO,CAAE,CAAA;AACtCC,MAAAA,YAAY,EAAE;KACf;AACH;AACF;AAACC,oBAAA,CAAAC,QAAA,EA7DoBpB,oBAAoB,CAAA;;;;"}
1
+ {"version":3,"file":"bubble.js","sources":["../../../../src/components/hds/rich-tooltip/bubble.ts"],"sourcesContent":["/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { assert } from '@ember/debug';\n\nimport type { ModifierLike } from '@glint/template';\nimport type { SetupPrimitivePopoverModifier } from '../popover-primitive';\nimport type { HdsAnchoredPositionOptions } from '../../../modifiers/hds-anchored-position.ts';\nimport {\n DEFAULT_PLACEMENT,\n PLACEMENTS,\n} from '../../../modifiers/hds-anchored-position.ts';\n\nexport interface HdsRichTooltipBubbleSignature {\n Args: {\n placement?: HdsAnchoredPositionOptions['placement'];\n offset?: HdsAnchoredPositionOptions['offsetOptions'];\n enableCollisionDetection?: HdsAnchoredPositionOptions['enableCollisionDetection'];\n width?: string;\n height?: string;\n isOpen?: boolean;\n popoverId: string;\n arrowId: string;\n setupPrimitivePopover: ModifierLike<SetupPrimitivePopoverModifier>;\n };\n Blocks: {\n default: [];\n };\n Element: HTMLDivElement;\n}\n\nexport default class HdsRichTooltipBubble extends Component<HdsRichTooltipBubbleSignature> {\n /**\n * @param placement\n * @type {string}\n * @description Determines the position of the \"popover\"\n */\n get placement(): HdsAnchoredPositionOptions['placement'] {\n const { placement = DEFAULT_PLACEMENT } = this.args;\n\n assert(\n `@placement for \"Hds::RichTooltip::Bubble\" must be one of the following: ${PLACEMENTS.join(\n ', '\n )}; received: ${placement}`,\n PLACEMENTS.includes(placement)\n );\n\n return placement;\n }\n\n get enableCollisionDetection(): HdsAnchoredPositionOptions['enableCollisionDetection'] {\n return this.args.enableCollisionDetection ?? true;\n }\n\n get sizingStyles(): Record<string, string> {\n const sizingStyles: {\n width?: string;\n 'max-width'?: string;\n height?: string;\n 'max-height'?: string;\n } = {};\n\n if (this.args.width) {\n sizingStyles['width'] = this.args.width;\n sizingStyles['max-width'] = 'none';\n }\n\n if (this.args.height) {\n sizingStyles['height'] = this.args.height;\n sizingStyles['max-height'] = 'none';\n }\n\n return sizingStyles;\n }\n\n get anchoredPositionOptions(): {\n placement: HdsAnchoredPositionOptions['placement'];\n offsetOptions: HdsAnchoredPositionOptions['offsetOptions'];\n enableCollisionDetection: HdsAnchoredPositionOptions['enableCollisionDetection'];\n arrowSelector: string;\n arrowPadding: HdsAnchoredPositionOptions['arrowPadding'];\n } {\n // custom options specific for the `RichTooltip` component\n // for details see the `hds-anchored-position` modifier\n return {\n placement: this.placement,\n offsetOptions: this.args.offset ?? 12,\n enableCollisionDetection: this.args.enableCollisionDetection ?? true,\n arrowSelector: `#${this.args.arrowId}`,\n arrowPadding: 12,\n };\n }\n}\n"],"names":["HdsRichTooltipBubble","Component","placement","DEFAULT_PLACEMENT","args","assert","PLACEMENTS","join","includes","enableCollisionDetection","sizingStyles","width","height","anchoredPositionOptions","offsetOptions","offset","arrowSelector","arrowId","arrowPadding","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;;AA+Be,MAAMA,oBAAoB,SAASC,SAAS,CAAgC;AACzF;AACF;AACA;AACA;AACA;EACE,IAAIC,SAASA,GAA4C;IACvD,MAAM;AAAEA,MAAAA,SAAS,GAAGC;KAAmB,GAAG,IAAI,CAACC,IAAI;AAEnDC,IAAAA,MAAM,CACJ,CAA2EC,wEAAAA,EAAAA,UAAU,CAACC,IAAI,CACxF,IACF,CAAC,CAAA,YAAA,EAAeL,SAAS,CAAA,CAAE,EAC3BI,UAAU,CAACE,QAAQ,CAACN,SAAS,CAC/B,CAAC;AAED,IAAA,OAAOA,SAAS;AAClB;EAEA,IAAIO,wBAAwBA,GAA2D;AACrF,IAAA,OAAO,IAAI,CAACL,IAAI,CAACK,wBAAwB,IAAI,IAAI;AACnD;EAEA,IAAIC,YAAYA,GAA2B;IACzC,MAAMA,YAKL,GAAG,EAAE;AAEN,IAAA,IAAI,IAAI,CAACN,IAAI,CAACO,KAAK,EAAE;MACnBD,YAAY,CAAC,OAAO,CAAC,GAAG,IAAI,CAACN,IAAI,CAACO,KAAK;AACvCD,MAAAA,YAAY,CAAC,WAAW,CAAC,GAAG,MAAM;AACpC;AAEA,IAAA,IAAI,IAAI,CAACN,IAAI,CAACQ,MAAM,EAAE;MACpBF,YAAY,CAAC,QAAQ,CAAC,GAAG,IAAI,CAACN,IAAI,CAACQ,MAAM;AACzCF,MAAAA,YAAY,CAAC,YAAY,CAAC,GAAG,MAAM;AACrC;AAEA,IAAA,OAAOA,YAAY;AACrB;EAEA,IAAIG,uBAAuBA,GAMzB;AACA;AACA;IACA,OAAO;MACLX,SAAS,EAAE,IAAI,CAACA,SAAS;AACzBY,MAAAA,aAAa,EAAE,IAAI,CAACV,IAAI,CAACW,MAAM,IAAI,EAAE;AACrCN,MAAAA,wBAAwB,EAAE,IAAI,CAACL,IAAI,CAACK,wBAAwB,IAAI,IAAI;AACpEO,MAAAA,aAAa,EAAE,CAAI,CAAA,EAAA,IAAI,CAACZ,IAAI,CAACa,OAAO,CAAE,CAAA;AACtCC,MAAAA,YAAY,EAAE;KACf;AACH;AACF;AAACC,oBAAA,CAAAC,QAAA,EA7DoBpB,oBAAoB,CAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"indicator.js","sources":["../../../../../src/components/hds/stepper/step/indicator.ts"],"sourcesContent":["/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { assert } from '@ember/debug';\n\nimport { HdsStepperStatusesValues } from '../types.ts';\nimport type { HdsStepperStatuses } from '../types.ts';\n\nexport const DEFAULT_STATUS = HdsStepperStatusesValues.Incomplete;\nexport const STATUSES: string[] = Object.values(HdsStepperStatusesValues);\n\nexport interface HdsStepperStepIndicatorSignature {\n Args: {\n status?: HdsStepperStatuses;\n isInteractive?: boolean;\n text?: string;\n };\n Element: HTMLDivElement;\n}\n\nexport default class HdsStepperStepIndicator extends Component<HdsStepperStepIndicatorSignature> {\n /**\n * @param status\n * @type {string}\n * @default \"incomplete\"\n */\n\n get status(): HdsStepperStatuses {\n const { status = DEFAULT_STATUS } = this.args;\n\n assert(\n `@status for \"Hds::Stepper::Step::Indicator\" must be one of the following: ${STATUSES.join(\n ', '\n )}; received: ${status}`,\n STATUSES.includes(status)\n );\n\n return status;\n }\n\n /**\n * @param isInteractive\n * @type {boolean}\n * @default false\n */\n\n get isInteractive(): boolean {\n return this.args.isInteractive || false;\n }\n\n /**\n * Get the class names to apply to the component.\n * @method IndicatorStep#classNames\n * @return {string} The \"class\" attribute to apply to the component.\n */\n get classNames(): string {\n const classes = ['hds-stepper-indicator-step'];\n\n // Based on the @status arg\n classes.push(`hds-stepper-indicator-step--status-${this.status}`);\n\n if (this.isInteractive) {\n classes.push(`hds-stepper-indicator-step--is-interactive`);\n }\n\n return classes.join(' ');\n }\n}\n"],"names":["DEFAULT_STATUS","HdsStepperStatusesValues","Incomplete","STATUSES","Object","values","HdsStepperStepIndicator","Component","status","args","assert","join","includes","isInteractive","classNames","classes","push","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;;AAQaA,MAAAA,cAAc,GAAGC,wBAAwB,CAACC;AAChD,MAAMC,QAAkB,GAAGC,MAAM,CAACC,MAAM,CAACJ,wBAAwB;AAWzD,MAAMK,uBAAuB,SAASC,SAAS,CAAmC;AAC/F;AACF;AACA;AACA;AACA;;EAEE,IAAIC,MAAMA,GAAuB;IAC/B,MAAM;AAAEA,MAAAA,MAAM,GAAGR;KAAgB,GAAG,IAAI,CAACS,IAAI;AAE7CC,IAAAA,MAAM,CACJ,CAA6EP,0EAAAA,EAAAA,QAAQ,CAACQ,IAAI,CACxF,IACF,CAAC,CAAA,YAAA,EAAeH,MAAM,CAAA,CAAE,EACxBL,QAAQ,CAACS,QAAQ,CAACJ,MAAM,CAC1B,CAAC;AAED,IAAA,OAAOA,MAAM;AACf;;AAEA;AACF;AACA;AACA;AACA;;EAEE,IAAIK,aAAaA,GAAY;AAC3B,IAAA,OAAO,IAAI,CAACJ,IAAI,CAACI,aAAa,IAAI,KAAK;AACzC;;AAEA;AACF;AACA;AACA;AACA;EACE,IAAIC,UAAUA,GAAW;AACvB,IAAA,MAAMC,OAAO,GAAG,CAAC,4BAA4B,CAAC;;AAE9C;IACAA,OAAO,CAACC,IAAI,CAAC,CAAA,mCAAA,EAAsC,IAAI,CAACR,MAAM,EAAE,CAAC;IAEjE,IAAI,IAAI,CAACK,aAAa,EAAE;AACtBE,MAAAA,OAAO,CAACC,IAAI,CAAC,CAAA,0CAAA,CAA4C,CAAC;AAC5D;AAEA,IAAA,OAAOD,OAAO,CAACJ,IAAI,CAAC,GAAG,CAAC;AAC1B;AACF;AAACM,oBAAA,CAAAC,QAAA,EA/CoBZ,uBAAuB,CAAA;;;;"}
1
+ {"version":3,"file":"indicator.js","sources":["../../../../../src/components/hds/stepper/step/indicator.ts"],"sourcesContent":["/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { assert } from '@ember/debug';\n\nimport { HdsStepperStatusesValues } from '../types.ts';\nimport type { HdsStepperStatuses } from '../types.ts';\n\nexport const DEFAULT_STATUS = HdsStepperStatusesValues.Incomplete;\nexport const STATUSES: HdsStepperStatuses[] = Object.values(\n HdsStepperStatusesValues\n);\n\nexport interface HdsStepperStepIndicatorSignature {\n Args: {\n status?: HdsStepperStatuses;\n isInteractive?: boolean;\n text?: string;\n };\n Element: HTMLDivElement;\n}\n\nexport default class HdsStepperStepIndicator extends Component<HdsStepperStepIndicatorSignature> {\n /**\n * @param status\n * @type {string}\n * @default \"incomplete\"\n */\n\n get status(): HdsStepperStatuses {\n const { status = DEFAULT_STATUS } = this.args;\n\n assert(\n `@status for \"Hds::Stepper::Step::Indicator\" must be one of the following: ${STATUSES.join(\n ', '\n )}; received: ${status}`,\n STATUSES.includes(status)\n );\n\n return status;\n }\n\n /**\n * @param isInteractive\n * @type {boolean}\n * @default false\n */\n\n get isInteractive(): boolean {\n return this.args.isInteractive || false;\n }\n\n /**\n * Get the class names to apply to the component.\n * @method IndicatorStep#classNames\n * @return {string} The \"class\" attribute to apply to the component.\n */\n get classNames(): string {\n const classes = ['hds-stepper-indicator-step'];\n\n // Based on the @status arg\n classes.push(`hds-stepper-indicator-step--status-${this.status}`);\n\n if (this.isInteractive) {\n classes.push(`hds-stepper-indicator-step--is-interactive`);\n }\n\n return classes.join(' ');\n }\n}\n"],"names":["DEFAULT_STATUS","HdsStepperStatusesValues","Incomplete","STATUSES","Object","values","HdsStepperStepIndicator","Component","status","args","assert","join","includes","isInteractive","classNames","classes","push","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;;AAQaA,MAAAA,cAAc,GAAGC,wBAAwB,CAACC;AAChD,MAAMC,QAA8B,GAAGC,MAAM,CAACC,MAAM,CACzDJ,wBACF;AAWe,MAAMK,uBAAuB,SAASC,SAAS,CAAmC;AAC/F;AACF;AACA;AACA;AACA;;EAEE,IAAIC,MAAMA,GAAuB;IAC/B,MAAM;AAAEA,MAAAA,MAAM,GAAGR;KAAgB,GAAG,IAAI,CAACS,IAAI;AAE7CC,IAAAA,MAAM,CACJ,CAA6EP,0EAAAA,EAAAA,QAAQ,CAACQ,IAAI,CACxF,IACF,CAAC,CAAA,YAAA,EAAeH,MAAM,CAAA,CAAE,EACxBL,QAAQ,CAACS,QAAQ,CAACJ,MAAM,CAC1B,CAAC;AAED,IAAA,OAAOA,MAAM;AACf;;AAEA;AACF;AACA;AACA;AACA;;EAEE,IAAIK,aAAaA,GAAY;AAC3B,IAAA,OAAO,IAAI,CAACJ,IAAI,CAACI,aAAa,IAAI,KAAK;AACzC;;AAEA;AACF;AACA;AACA;AACA;EACE,IAAIC,UAAUA,GAAW;AACvB,IAAA,MAAMC,OAAO,GAAG,CAAC,4BAA4B,CAAC;;AAE9C;IACAA,OAAO,CAACC,IAAI,CAAC,CAAA,mCAAA,EAAsC,IAAI,CAACR,MAAM,EAAE,CAAC;IAEjE,IAAI,IAAI,CAACK,aAAa,EAAE;AACtBE,MAAAA,OAAO,CAACC,IAAI,CAAC,CAAA,0CAAA,CAA4C,CAAC;AAC5D;AAEA,IAAA,OAAOD,OAAO,CAACJ,IAAI,CAAC,GAAG,CAAC;AAC1B;AACF;AAACM,oBAAA,CAAAC,QAAA,EA/CoBZ,uBAAuB,CAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"indicator.js","sources":["../../../../../src/components/hds/stepper/task/indicator.ts"],"sourcesContent":["/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { assert } from '@ember/debug';\n\nimport {\n HdsStepperStatusesValues,\n HdsStepperStatusToIconsValues,\n} from '../types.ts';\nimport type { HdsIconSignature } from '../../icon';\nimport type { HdsStepperStatuses } from '../types.ts';\n\nexport const DEFAULT_STATUS = HdsStepperStatusesValues.Incomplete;\nexport const STATUSES: string[] = Object.values(HdsStepperStatusesValues);\n\nexport const MAPPING_STATUS_TO_ICONS = HdsStepperStatusToIconsValues;\n\nexport interface HdsStepperTaskIndicatorSignature {\n Args: {\n status?: HdsStepperStatuses;\n isInteractive?: boolean;\n };\n Element: HTMLDivElement;\n}\n\nexport default class HdsStepperTaskIndicator extends Component<HdsStepperTaskIndicatorSignature> {\n /**\n * @param status\n * @type {string}\n * @default \"incomplete\"\n */\n\n get status(): HdsStepperStatuses {\n const { status = DEFAULT_STATUS } = this.args;\n\n assert(\n `@status for \"Hds::Stepper::Task::Indicator\" must be one of the following: ${STATUSES.join(\n ', '\n )}; received: ${status}`,\n STATUSES.includes(status)\n );\n\n return status;\n }\n\n /**\n * @param isInteractive\n * @type {boolean}\n * @default false\n */\n\n get isInteractive(): boolean {\n return this.args.isInteractive || false;\n }\n\n /**\n * @param iconName\n * @type {string}\n */\n\n get iconName(): HdsIconSignature['Args']['name'] {\n return MAPPING_STATUS_TO_ICONS[this.status];\n }\n\n /**\n * Get the class names to apply to the component.\n * @method IndicatorTask#classNames\n * @return {string} The \"class\" attribute to apply to the component.\n */\n get classNames(): string {\n const classes = ['hds-stepper-indicator-task'];\n\n // Based on the @status arg\n classes.push(`hds-stepper-indicator-task--status-${this.status}`);\n\n if (this.isInteractive) {\n classes.push(`hds-stepper-indicator-task--is-interactive`);\n }\n\n return classes.join(' ');\n }\n}\n"],"names":["DEFAULT_STATUS","HdsStepperStatusesValues","Incomplete","STATUSES","Object","values","MAPPING_STATUS_TO_ICONS","HdsStepperStatusToIconsValues","HdsStepperTaskIndicator","Component","status","args","assert","join","includes","isInteractive","iconName","classNames","classes","push","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;;AAYaA,MAAAA,cAAc,GAAGC,wBAAwB,CAACC;AAChD,MAAMC,QAAkB,GAAGC,MAAM,CAACC,MAAM,CAACJ,wBAAwB;AAEjE,MAAMK,uBAAuB,GAAGC;AAUxB,MAAMC,uBAAuB,SAASC,SAAS,CAAmC;AAC/F;AACF;AACA;AACA;AACA;;EAEE,IAAIC,MAAMA,GAAuB;IAC/B,MAAM;AAAEA,MAAAA,MAAM,GAAGV;KAAgB,GAAG,IAAI,CAACW,IAAI;AAE7CC,IAAAA,MAAM,CACJ,CAA6ET,0EAAAA,EAAAA,QAAQ,CAACU,IAAI,CACxF,IACF,CAAC,CAAA,YAAA,EAAeH,MAAM,CAAA,CAAE,EACxBP,QAAQ,CAACW,QAAQ,CAACJ,MAAM,CAC1B,CAAC;AAED,IAAA,OAAOA,MAAM;AACf;;AAEA;AACF;AACA;AACA;AACA;;EAEE,IAAIK,aAAaA,GAAY;AAC3B,IAAA,OAAO,IAAI,CAACJ,IAAI,CAACI,aAAa,IAAI,KAAK;AACzC;;AAEA;AACF;AACA;AACA;;EAEE,IAAIC,QAAQA,GAAqC;AAC/C,IAAA,OAAOV,uBAAuB,CAAC,IAAI,CAACI,MAAM,CAAC;AAC7C;;AAEA;AACF;AACA;AACA;AACA;EACE,IAAIO,UAAUA,GAAW;AACvB,IAAA,MAAMC,OAAO,GAAG,CAAC,4BAA4B,CAAC;;AAE9C;IACAA,OAAO,CAACC,IAAI,CAAC,CAAA,mCAAA,EAAsC,IAAI,CAACT,MAAM,EAAE,CAAC;IAEjE,IAAI,IAAI,CAACK,aAAa,EAAE;AACtBG,MAAAA,OAAO,CAACC,IAAI,CAAC,CAAA,0CAAA,CAA4C,CAAC;AAC5D;AAEA,IAAA,OAAOD,OAAO,CAACL,IAAI,CAAC,GAAG,CAAC;AAC1B;AACF;AAACO,oBAAA,CAAAC,QAAA,EAxDoBb,uBAAuB,CAAA;;;;"}
1
+ {"version":3,"file":"indicator.js","sources":["../../../../../src/components/hds/stepper/task/indicator.ts"],"sourcesContent":["/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { assert } from '@ember/debug';\n\nimport {\n HdsStepperStatusesValues,\n HdsStepperStatusToIconsValues,\n} from '../types.ts';\nimport type { HdsIconSignature } from '../../icon';\nimport type { HdsStepperStatuses } from '../types.ts';\n\nexport const DEFAULT_STATUS = HdsStepperStatusesValues.Incomplete;\nexport const STATUSES: HdsStepperStatuses[] = Object.values(\n HdsStepperStatusesValues\n);\n\nexport const MAPPING_STATUS_TO_ICONS = HdsStepperStatusToIconsValues;\n\nexport interface HdsStepperTaskIndicatorSignature {\n Args: {\n status?: HdsStepperStatuses;\n isInteractive?: boolean;\n };\n Element: HTMLDivElement;\n}\n\nexport default class HdsStepperTaskIndicator extends Component<HdsStepperTaskIndicatorSignature> {\n /**\n * @param status\n * @type {string}\n * @default \"incomplete\"\n */\n\n get status(): HdsStepperStatuses {\n const { status = DEFAULT_STATUS } = this.args;\n\n assert(\n `@status for \"Hds::Stepper::Task::Indicator\" must be one of the following: ${STATUSES.join(\n ', '\n )}; received: ${status}`,\n STATUSES.includes(status)\n );\n\n return status;\n }\n\n /**\n * @param isInteractive\n * @type {boolean}\n * @default false\n */\n\n get isInteractive(): boolean {\n return this.args.isInteractive || false;\n }\n\n /**\n * @param iconName\n * @type {string}\n */\n\n get iconName(): HdsIconSignature['Args']['name'] {\n return MAPPING_STATUS_TO_ICONS[this.status];\n }\n\n /**\n * Get the class names to apply to the component.\n * @method IndicatorTask#classNames\n * @return {string} The \"class\" attribute to apply to the component.\n */\n get classNames(): string {\n const classes = ['hds-stepper-indicator-task'];\n\n // Based on the @status arg\n classes.push(`hds-stepper-indicator-task--status-${this.status}`);\n\n if (this.isInteractive) {\n classes.push(`hds-stepper-indicator-task--is-interactive`);\n }\n\n return classes.join(' ');\n }\n}\n"],"names":["DEFAULT_STATUS","HdsStepperStatusesValues","Incomplete","STATUSES","Object","values","MAPPING_STATUS_TO_ICONS","HdsStepperStatusToIconsValues","HdsStepperTaskIndicator","Component","status","args","assert","join","includes","isInteractive","iconName","classNames","classes","push","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;;AAYaA,MAAAA,cAAc,GAAGC,wBAAwB,CAACC;AAChD,MAAMC,QAA8B,GAAGC,MAAM,CAACC,MAAM,CACzDJ,wBACF;AAEO,MAAMK,uBAAuB,GAAGC;AAUxB,MAAMC,uBAAuB,SAASC,SAAS,CAAmC;AAC/F;AACF;AACA;AACA;AACA;;EAEE,IAAIC,MAAMA,GAAuB;IAC/B,MAAM;AAAEA,MAAAA,MAAM,GAAGV;KAAgB,GAAG,IAAI,CAACW,IAAI;AAE7CC,IAAAA,MAAM,CACJ,CAA6ET,0EAAAA,EAAAA,QAAQ,CAACU,IAAI,CACxF,IACF,CAAC,CAAA,YAAA,EAAeH,MAAM,CAAA,CAAE,EACxBP,QAAQ,CAACW,QAAQ,CAACJ,MAAM,CAC1B,CAAC;AAED,IAAA,OAAOA,MAAM;AACf;;AAEA;AACF;AACA;AACA;AACA;;EAEE,IAAIK,aAAaA,GAAY;AAC3B,IAAA,OAAO,IAAI,CAACJ,IAAI,CAACI,aAAa,IAAI,KAAK;AACzC;;AAEA;AACF;AACA;AACA;;EAEE,IAAIC,QAAQA,GAAqC;AAC/C,IAAA,OAAOV,uBAAuB,CAAC,IAAI,CAACI,MAAM,CAAC;AAC7C;;AAEA;AACF;AACA;AACA;AACA;EACE,IAAIO,UAAUA,GAAW;AACvB,IAAA,MAAMC,OAAO,GAAG,CAAC,4BAA4B,CAAC;;AAE9C;IACAA,OAAO,CAACC,IAAI,CAAC,CAAA,mCAAA,EAAsC,IAAI,CAACT,MAAM,EAAE,CAAC;IAEjE,IAAI,IAAI,CAACK,aAAa,EAAE;AACtBG,MAAAA,OAAO,CAACC,IAAI,CAAC,CAAA,0CAAA,CAA4C,CAAC;AAC5D;AAEA,IAAA,OAAOD,OAAO,CAACL,IAAI,CAAC,GAAG,CAAC;AAC1B;AACF;AAACO,oBAAA,CAAAC,QAAA,EAxDoBb,uBAAuB,CAAA;;;;"}
@@ -1,5 +1,6 @@
1
1
  import Component from '@glimmer/component';
2
2
  import { tracked } from '@glimmer/tracking';
3
+ import { TrackedWeakSet } from 'tracked-built-ins';
3
4
  import { assert } from '@ember/debug';
4
5
  import { modifier } from 'ember-modifier';
5
6
  import { HdsTagTooltipPlacementValues, HdsTagColorValues } from './types.js';
@@ -18,22 +19,36 @@ const COLORS = Object.values(HdsTagColorValues);
18
19
  const DEFAULT_COLOR = HdsTagColorValues.Primary;
19
20
  const TOOLTIP_PLACEMENTS = Object.values(HdsTagTooltipPlacementValues);
20
21
  const DEFAULT_TOOLTIP_PLACEMENT = HdsTagTooltipPlacementValues.Top;
22
+ const overflowed = new TrackedWeakSet();
23
+ const observer = new ResizeObserver(entries => {
24
+ entries.forEach(entry => {
25
+ const textContainer = entry.target.querySelector('.hds-tag__text-container');
26
+ if (textContainer && textContainer.scrollHeight > textContainer.clientHeight) {
27
+ overflowed.add(entry.target);
28
+ } else {
29
+ overflowed.delete(entry.target);
30
+ }
31
+ });
32
+ });
21
33
  class HdsTag extends Component {
22
34
  static {
23
- g(this.prototype, "_isTextOverflow", [tracked]);
35
+ g(this.prototype, "_element", [tracked]);
36
+ }
37
+ #_element = (i(this, "_element"), void 0);
38
+ get _isTextOverflow() {
39
+ if (!this._element) {
40
+ return false;
41
+ }
42
+ return overflowed.has(this._element);
24
43
  }
25
- #_isTextOverflow = (i(this, "_isTextOverflow"), void 0);
26
- _observer;
27
44
  _setUpObserver = modifier(element => {
28
- // Used to detect when text is clipped to one line, and tooltip should be added
29
- this._observer = new ResizeObserver(entries => {
30
- entries.forEach(entry => {
31
- this._isTextOverflow = this._isOverflow(entry.target.querySelector('.hds-tag__text-container'));
32
- });
33
- });
34
- this._observer.observe(element);
45
+ this._element = element;
46
+ observer.observe(element);
35
47
  return () => {
36
- this._observer.disconnect();
48
+ if (this._element) {
49
+ observer.unobserve(this._element);
50
+ }
51
+ delete this._element;
37
52
  };
38
53
  });
39
54
 
@@ -124,9 +139,6 @@ class HdsTag extends Component {
124
139
  }
125
140
  return classes.join(' ');
126
141
  }
127
- _isOverflow(el) {
128
- return el.scrollHeight > el.clientHeight;
129
- }
130
142
  }
131
143
  setComponentTemplate(TEMPLATE, HdsTag);
132
144
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/components/hds/tag/index.ts"],"sourcesContent":["/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { assert } from '@ember/debug';\nimport { modifier } from 'ember-modifier';\n\nimport { HdsTagColorValues } from './types.ts';\nimport type { HdsTagColors } from './types.ts';\nimport { HdsTagTooltipPlacementValues } from './types.ts';\nimport type { HdsTagTooltipPlacements } from './types.ts';\nimport type { HdsInteractiveSignature } from '../interactive/';\n\nexport const COLORS: string[] = Object.values(HdsTagColorValues);\nexport const DEFAULT_COLOR = HdsTagColorValues.Primary;\nexport const TOOLTIP_PLACEMENTS: string[] = Object.values(\n HdsTagTooltipPlacementValues\n);\nexport const DEFAULT_TOOLTIP_PLACEMENT = HdsTagTooltipPlacementValues.Top;\n\nexport interface HdsTagSignature {\n Args: HdsInteractiveSignature['Args'] & {\n color?: HdsTagColors;\n text: string;\n ariaLabel?: string;\n tooltipPlacement?: HdsTagTooltipPlacements;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onDismiss?: (event: MouseEvent, ...args: any[]) => void;\n };\n Element: HTMLSpanElement;\n}\n\nexport default class HdsTag extends Component<HdsTagSignature> {\n @tracked private _isTextOverflow!: boolean;\n private _observer!: ResizeObserver;\n\n private _setUpObserver = modifier((element: HTMLElement) => {\n // Used to detect when text is clipped to one line, and tooltip should be added\n this._observer = new ResizeObserver((entries) => {\n entries.forEach((entry) => {\n this._isTextOverflow = this._isOverflow(\n entry.target.querySelector('.hds-tag__text-container')!\n );\n });\n });\n this._observer.observe(element);\n\n return () => {\n this._observer.disconnect();\n };\n });\n\n /**\n * @param tooltioPlacement\n * @type {string}\n * @default top\n * @description The placement property of the tooltip attached to the tag text.\n */\n get tooltipPlacement(): HdsTagTooltipPlacements {\n const { tooltipPlacement = DEFAULT_TOOLTIP_PLACEMENT } = this.args;\n\n assert(\n '@tooltipPlacement for \"Hds::Tag\" must have a valid value',\n tooltipPlacement == undefined ||\n TOOLTIP_PLACEMENTS.includes(tooltipPlacement)\n );\n\n return tooltipPlacement;\n }\n\n /**\n * @param onDismiss\n * @type {function}\n * @default () => {}\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n get onDismiss(): ((event: MouseEvent, ...args: any[]) => void) | false {\n const { onDismiss } = this.args;\n\n if (typeof onDismiss === 'function') {\n return onDismiss;\n } else {\n return false;\n }\n }\n\n /**\n * @param text\n * @type {string}\n * @description The text of the tag. If no text value is defined, an error will be thrown.\n */\n get text(): string {\n const { text } = this.args;\n\n assert('@text for \"Hds::Tag\" must have a valid value', text !== undefined);\n\n return text;\n }\n\n /**\n * @param ariaLabel\n * @type {string}\n * @default 'Dismiss'\n */\n get ariaLabel(): string {\n const tagAriaLabel = this.args.ariaLabel ?? 'Dismiss';\n return tagAriaLabel + ' ' + this.args.text;\n }\n\n /**\n * @param color\n * @type {string}\n * @default primary\n * @description Determines the color of link to be used; acceptable values are `primary` and `secondary`\n */\n get color(): HdsTagColors | false {\n if (this.args.href || this.args.route) {\n const { color = DEFAULT_COLOR } = this.args;\n assert(\n `@color for \"Hds::Tag\" must be one of the following: ${COLORS.join(\n ', '\n )}; received: ${color}`,\n COLORS.includes(color)\n );\n return color;\n } else if (this.args.color) {\n assert(\n '@color can only be applied to \"Hds::Tag\" along with either @href or @route',\n this.args.href || this.args.route\n );\n }\n return false;\n }\n\n /**\n * Get the class names to apply to the component.\n * @method classNames\n * @return {string} The \"class\" attribute to apply to the component.\n */\n get classNames(): string {\n const classes = ['hds-tag'];\n\n // add a class based on the @color argument\n if (this.color) {\n classes.push(`hds-tag--color-${this.color}`);\n }\n\n return classes.join(' ');\n }\n\n private _isOverflow(el: Element): boolean {\n return el.scrollHeight > el.clientHeight;\n }\n}\n"],"names":["COLORS","Object","values","HdsTagColorValues","DEFAULT_COLOR","Primary","TOOLTIP_PLACEMENTS","HdsTagTooltipPlacementValues","DEFAULT_TOOLTIP_PLACEMENT","Top","HdsTag","Component","g","prototype","tracked","i","void 0","_observer","_setUpObserver","modifier","element","ResizeObserver","entries","forEach","entry","_isTextOverflow","_isOverflow","target","querySelector","observe","disconnect","tooltipPlacement","args","assert","undefined","includes","onDismiss","text","ariaLabel","tagAriaLabel","color","href","route","join","classNames","classes","push","el","scrollHeight","clientHeight","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;;;;AAAA;AACA;AACA;AACA;;AAaO,MAAMA,MAAgB,GAAGC,MAAM,CAACC,MAAM,CAACC,iBAAiB;AAClDC,MAAAA,aAAa,GAAGD,iBAAiB,CAACE;AACxC,MAAMC,kBAA4B,GAAGL,MAAM,CAACC,MAAM,CACvDK,4BACF;AACaC,MAAAA,yBAAyB,GAAGD,4BAA4B,CAACE;AAcvD,MAAMC,MAAM,SAASC,SAAS,CAAkB;AAAA,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,iBAAA,EAAA,CAC5DC,OAAO,CAAA,CA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AACqB,EAAW,EAAW;AACxC,IAAA,OAAOA,EAAE,CAACC,YAAY,GAAGD,EAAE,CAACE,YAAY;AAC1C;AACF;AAACC,oBAAA,CAAAC,QAAA,EAzHoBzC,MAAM,CAAA;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/components/hds/tag/index.ts"],"sourcesContent":["/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { TrackedWeakSet } from 'tracked-built-ins';\nimport { assert } from '@ember/debug';\nimport { modifier } from 'ember-modifier';\n\nimport { HdsTagColorValues } from './types.ts';\nimport type { HdsTagColors } from './types.ts';\nimport { HdsTagTooltipPlacementValues } from './types.ts';\nimport type { HdsTagTooltipPlacements } from './types.ts';\nimport type { HdsInteractiveSignature } from '../interactive/';\n\nexport const COLORS: HdsTagColors[] = Object.values(HdsTagColorValues);\nexport const DEFAULT_COLOR = HdsTagColorValues.Primary;\nexport const TOOLTIP_PLACEMENTS: HdsTagTooltipPlacements[] = Object.values(\n HdsTagTooltipPlacementValues\n);\nexport const DEFAULT_TOOLTIP_PLACEMENT = HdsTagTooltipPlacementValues.Top;\n\nexport interface HdsTagSignature {\n Args: HdsInteractiveSignature['Args'] & {\n color?: HdsTagColors;\n text: string;\n ariaLabel?: string;\n tooltipPlacement?: HdsTagTooltipPlacements;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onDismiss?: (event: MouseEvent, ...args: any[]) => void;\n };\n Element: HTMLSpanElement;\n}\n\nconst overflowed = new TrackedWeakSet<Element>();\n\nconst observer = new ResizeObserver((entries) => {\n entries.forEach((entry) => {\n const textContainer = entry.target.querySelector(\n '.hds-tag__text-container'\n );\n if (\n textContainer &&\n textContainer.scrollHeight > textContainer.clientHeight\n ) {\n overflowed.add(entry.target);\n } else {\n overflowed.delete(entry.target);\n }\n });\n});\n\nexport default class HdsTag extends Component<HdsTagSignature> {\n @tracked private _element?: HTMLElement;\n private get _isTextOverflow(): boolean {\n if (!this._element) {\n return false;\n }\n return overflowed.has(this._element);\n }\n\n private _setUpObserver = modifier((element: HTMLElement) => {\n this._element = element;\n observer.observe(element);\n\n return () => {\n if (this._element) {\n observer.unobserve(this._element);\n }\n delete this._element;\n };\n });\n\n /**\n * @param tooltioPlacement\n * @type {string}\n * @default top\n * @description The placement property of the tooltip attached to the tag text.\n */\n get tooltipPlacement(): HdsTagTooltipPlacements {\n const { tooltipPlacement = DEFAULT_TOOLTIP_PLACEMENT } = this.args;\n\n assert(\n '@tooltipPlacement for \"Hds::Tag\" must have a valid value',\n tooltipPlacement == undefined ||\n TOOLTIP_PLACEMENTS.includes(tooltipPlacement)\n );\n\n return tooltipPlacement;\n }\n\n /**\n * @param onDismiss\n * @type {function}\n * @default () => {}\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n get onDismiss(): ((event: MouseEvent, ...args: any[]) => void) | false {\n const { onDismiss } = this.args;\n\n if (typeof onDismiss === 'function') {\n return onDismiss;\n } else {\n return false;\n }\n }\n\n /**\n * @param text\n * @type {string}\n * @description The text of the tag. If no text value is defined, an error will be thrown.\n */\n get text(): string {\n const { text } = this.args;\n\n assert('@text for \"Hds::Tag\" must have a valid value', text !== undefined);\n\n return text;\n }\n\n /**\n * @param ariaLabel\n * @type {string}\n * @default 'Dismiss'\n */\n get ariaLabel(): string {\n const tagAriaLabel = this.args.ariaLabel ?? 'Dismiss';\n return tagAriaLabel + ' ' + this.args.text;\n }\n\n /**\n * @param color\n * @type {string}\n * @default primary\n * @description Determines the color of link to be used; acceptable values are `primary` and `secondary`\n */\n get color(): HdsTagColors | false {\n if (this.args.href || this.args.route) {\n const { color = DEFAULT_COLOR } = this.args;\n assert(\n `@color for \"Hds::Tag\" must be one of the following: ${COLORS.join(\n ', '\n )}; received: ${color}`,\n COLORS.includes(color)\n );\n return color;\n } else if (this.args.color) {\n assert(\n '@color can only be applied to \"Hds::Tag\" along with either @href or @route',\n this.args.href || this.args.route\n );\n }\n return false;\n }\n\n /**\n * Get the class names to apply to the component.\n * @method classNames\n * @return {string} The \"class\" attribute to apply to the component.\n */\n get classNames(): string {\n const classes = ['hds-tag'];\n\n // add a class based on the @color argument\n if (this.color) {\n classes.push(`hds-tag--color-${this.color}`);\n }\n\n return classes.join(' ');\n }\n}\n"],"names":["COLORS","Object","values","HdsTagColorValues","DEFAULT_COLOR","Primary","TOOLTIP_PLACEMENTS","HdsTagTooltipPlacementValues","DEFAULT_TOOLTIP_PLACEMENT","Top","overflowed","TrackedWeakSet","observer","ResizeObserver","entries","forEach","entry","textContainer","target","querySelector","scrollHeight","clientHeight","add","delete","HdsTag","Component","g","prototype","tracked","i","void 0","_isTextOverflow","_element","has","_setUpObserver","modifier","element","observe","unobserve","tooltipPlacement","args","assert","undefined","includes","onDismiss","text","ariaLabel","tagAriaLabel","color","href","route","join","classNames","classes","push","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;;;;;AAAA;AACA;AACA;AACA;;AAcO,MAAMA,MAAsB,GAAGC,MAAM,CAACC,MAAM,CAACC,iBAAiB;AACxDC,MAAAA,aAAa,GAAGD,iBAAiB,CAACE;AACxC,MAAMC,kBAA6C,GAAGL,MAAM,CAACC,MAAM,CACxEK,4BACF;AACaC,MAAAA,yBAAyB,GAAGD,4BAA4B,CAACE;AActE,MAAMC,UAAU,GAAG,IAAIC,cAAc,EAAW;AAEhD,MAAMC,QAAQ,GAAG,IAAIC,cAAc,CAAEC,OAAO,IAAK;AAC/CA,EAAAA,OAAO,CAACC,OAAO,CAAEC,KAAK,IAAK;IACzB,MAAMC,aAAa,GAAGD,KAAK,CAACE,MAAM,CAACC,aAAa,CAC9C,0BACF,CAAC;IACD,IACEF,aAAa,IACbA,aAAa,CAACG,YAAY,GAAGH,aAAa,CAACI,YAAY,EACvD;AACAX,MAAAA,UAAU,CAACY,GAAG,CAACN,KAAK,CAACE,MAAM,CAAC;AAC9B,KAAC,MAAM;AACLR,MAAAA,UAAU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,CAAC,SAAS,CAAC;;AAE3B;IACA,IAAI,IAAI,CAACL,KAAK,EAAE;MACdK,OAAO,CAACC,IAAI,CAAC,CAAA,eAAA,EAAkB,IAAI,CAACN,KAAK,EAAE,CAAC;AAC9C;AAEA,IAAA,OAAOK,OAAO,CAACF,IAAI,CAAC,GAAG,CAAC;AAC1B;AACF;AAACI,oBAAA,CAAAC,QAAA,EAtHoBhC,MAAM,CAAA;;;;"}
@@ -11,23 +11,16 @@ var TEMPLATE = precompileTemplate("{{!\n Copyright (c) HashiCorp, Inc.\n SPDX-
11
11
  * SPDX-License-Identifier: MPL-2.0
12
12
  */
13
13
 
14
- const AVAILABLE_SIZES = [HdsTextSizeValues.ThreeHundred, HdsTextSizeValues.TwoHundred, HdsTextSizeValues.OneHundred];
14
+ const SIZES = [HdsTextSizeValues.ThreeHundred, HdsTextSizeValues.TwoHundred, HdsTextSizeValues.OneHundred];
15
15
  const DEFAULT_SIZE = HdsTextSizeValues.TwoHundred;
16
16
  const DEFAULT_WEIGHT = HdsTextWeightValues.Regular;
17
- const AVAILABLE_WEIGHTS_PER_SIZE = {
17
+ const WEIGHTS_PER_SIZE = {
18
18
  300: [HdsTextWeightValues.Regular, HdsTextWeightValues.Medium, HdsTextWeightValues.Semibold],
19
19
  200: [HdsTextWeightValues.Regular, HdsTextWeightValues.Medium, HdsTextWeightValues.Semibold],
20
20
  100: [HdsTextWeightValues.Regular, HdsTextWeightValues.Medium, HdsTextWeightValues.Semibold]
21
21
  };
22
22
  class HdsTextBody extends Component {
23
- /**
24
- * Sets the "size" for the text
25
- * Accepted values: see AVAILABLE_SIZES
26
- *
27
- * @param size
28
- * @type {HdsTextBodySizes}
29
- *
30
- */
23
+ // Sets the "size" for the text
31
24
  get size() {
32
25
  let {
33
26
  size = DEFAULT_SIZE
@@ -37,28 +30,21 @@ class HdsTextBody extends Component {
37
30
  if (typeof size === 'string') {
38
31
  size = parseInt(size, 10);
39
32
  }
40
- assert(`@size for "Hds::Text::Body" must be one of the following: ${AVAILABLE_SIZES.join(', ')}; received: ${size}`, AVAILABLE_SIZES.includes(size));
33
+ assert(`@size for "Hds::Text::Body" must be one of the following: ${SIZES.join(', ')}; received: ${size}`, SIZES.includes(size));
41
34
  return size;
42
35
  }
43
36
 
44
- /**
45
- * Sets the "weight" for the text
46
- * Accepted values: see AVAILABLE_WEIGHTS_PER_SIZE
47
- *
48
- * @param weight
49
- * @type {HdsTextWeights}
50
- *
51
- */
37
+ // Sets the "weight" for the text
52
38
  get weight() {
53
39
  const {
54
40
  weight = DEFAULT_WEIGHT
55
41
  } = this.args;
56
- const availableWeights = AVAILABLE_WEIGHTS_PER_SIZE[this.size];
57
- assert(`@weight for "Hds::Text::Body" with @size=${this.size} must be one of the following: ${availableWeights.join(', ')}; received: ${weight}`, availableWeights.includes(weight));
42
+ const weights = WEIGHTS_PER_SIZE[this.size];
43
+ assert(`@weight for "Hds::Text::Body" with @size=${this.size} must be one of the following: ${weights.join(', ')}; received: ${weight}`, weights.includes(weight));
58
44
  return weight;
59
45
  }
60
46
  }
61
47
  setComponentTemplate(TEMPLATE, HdsTextBody);
62
48
 
63
- export { AVAILABLE_SIZES, AVAILABLE_WEIGHTS_PER_SIZE, DEFAULT_SIZE, DEFAULT_WEIGHT, HdsTextBody as default };
49
+ export { DEFAULT_SIZE, DEFAULT_WEIGHT, SIZES, WEIGHTS_PER_SIZE, HdsTextBody as default };
64
50
  //# sourceMappingURL=body.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"body.js","sources":["../../../../src/components/hds/text/body.ts"],"sourcesContent":["/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { assert } from '@ember/debug';\nimport { HdsTextSizeValues, HdsTextWeightValues } from './types.ts';\nimport type {\n HdsTextAligns,\n HdsTextColors,\n HdsTextTags,\n HdsTextWeights,\n} from './types.ts';\n\n// notice: only some combinations of size + font-weight are allowed (per design specs)\n// see: https://www.figma.com/file/oQsMzMMnynfPWpMEt91OpH/HDS-Product---Foundations?node-id=1262%3A9192\n\n// Allow consumers to provide either string or number representation of size\ntype HdsTextBodySizeNumber = Extract<\n HdsTextSizeValues,\n | HdsTextSizeValues.OneHundred\n | HdsTextSizeValues.TwoHundred\n | HdsTextSizeValues.ThreeHundred\n>;\ntype HdsTextBodySizeString = `${HdsTextBodySizeNumber}`;\nexport type HdsTextBodySizes = HdsTextBodySizeNumber | HdsTextBodySizeString;\nexport const AVAILABLE_SIZES = [\n HdsTextSizeValues.ThreeHundred,\n HdsTextSizeValues.TwoHundred,\n HdsTextSizeValues.OneHundred,\n];\nexport const DEFAULT_SIZE = HdsTextSizeValues.TwoHundred;\n\nexport const DEFAULT_WEIGHT = HdsTextWeightValues.Regular;\nexport type HdsTextBodyWeight = Extract<\n HdsTextWeights,\n 'regular' | 'medium' | 'semibold'\n>;\nexport const AVAILABLE_WEIGHTS_PER_SIZE: Record<\n HdsTextBodySizes,\n HdsTextBodyWeight[]\n> = {\n 300: [\n HdsTextWeightValues.Regular,\n HdsTextWeightValues.Medium,\n HdsTextWeightValues.Semibold,\n ],\n 200: [\n HdsTextWeightValues.Regular,\n HdsTextWeightValues.Medium,\n HdsTextWeightValues.Semibold,\n ],\n 100: [\n HdsTextWeightValues.Regular,\n HdsTextWeightValues.Medium,\n HdsTextWeightValues.Semibold,\n ],\n};\n\nexport interface HdsTextBodySignature {\n Args: {\n size?: HdsTextBodySizes;\n tag?: HdsTextTags;\n weight?: HdsTextBodyWeight;\n align?: HdsTextAligns;\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n color?: string | HdsTextColors;\n };\n Element:\n | HTMLSpanElement\n | HTMLHeadingElement\n | HTMLParagraphElement\n | HTMLDivElement;\n Blocks: {\n default: [];\n };\n}\n\nexport default class HdsTextBody extends Component<HdsTextBodySignature> {\n /**\n * Sets the \"size\" for the text\n * Accepted values: see AVAILABLE_SIZES\n *\n * @param size\n * @type {HdsTextBodySizes}\n *\n */\n get size(): HdsTextBodySizes {\n let { size = DEFAULT_SIZE } = this.args;\n\n // let's be a bit forgiving with the consumers\n if (typeof size === 'string') {\n size = parseInt(size, 10);\n }\n\n assert(\n `@size for \"Hds::Text::Body\" must be one of the following: ${AVAILABLE_SIZES.join(\n ', '\n )}; received: ${size}`,\n AVAILABLE_SIZES.includes(size)\n );\n\n return size;\n }\n\n /**\n * Sets the \"weight\" for the text\n * Accepted values: see AVAILABLE_WEIGHTS_PER_SIZE\n *\n * @param weight\n * @type {HdsTextWeights}\n *\n */\n get weight(): HdsTextWeights {\n const { weight = DEFAULT_WEIGHT } = this.args;\n\n const availableWeights = AVAILABLE_WEIGHTS_PER_SIZE[this.size];\n\n assert(\n `@weight for \"Hds::Text::Body\" with @size=${\n this.size\n } must be one of the following: ${availableWeights.join(\n ', '\n )}; received: ${weight}`,\n availableWeights.includes(weight)\n );\n\n return weight;\n }\n}\n"],"names":["AVAILABLE_SIZES","HdsTextSizeValues","ThreeHundred","TwoHundred","OneHundred","DEFAULT_SIZE","DEFAULT_WEIGHT","HdsTextWeightValues","Regular","AVAILABLE_WEIGHTS_PER_SIZE","Medium","Semibold","HdsTextBody","Component","size","args","parseInt","assert","join","includes","weight","availableWeights","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;;AAwBaA,MAAAA,eAAe,GAAG,CAC7BC,iBAAiB,CAACC,YAAY,EAC9BD,iBAAiB,CAACE,UAAU,EAC5BF,iBAAiB,CAACG,UAAU;AAEjBC,MAAAA,YAAY,GAAGJ,iBAAiB,CAACE;AAEjCG,MAAAA,cAAc,GAAGC,mBAAmB,CAACC;AAK3C,MAAMC,0BAGZ,GAAG;AACF,EAAA,GAAG,EAAE,CACHF,mBAAmB,CAACC,OAAO,EAC3BD,mBAAmB,CAACG,MAAM,EAC1BH,mBAAmB,CAACI,QAAQ,CAC7B;AACD,EAAA,GAAG,EAAE,CACHJ,mBAAmB,CAACC,OAAO,EAC3BD,mBAAmB,CA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Content":["/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { assert } from '@ember/debug';\nimport { HdsTextSizeValues, HdsTextWeightValues } from './types.ts';\nimport type {\n HdsTextAligns,\n HdsTextColors,\n HdsTextTags,\n HdsTextWeights,\n} from './types.ts';\n\n// notice: only some combinations of size + font-weight are allowed (per design specs)\n// see: https://www.figma.com/file/oQsMzMMnynfPWpMEt91OpH/HDS-Product---Foundations?node-id=1262%3A9192\n\n// Allow consumers to provide either string or number representation of size\ntype HdsTextBodySizeNumber = Extract<\n HdsTextSizeValues,\n | HdsTextSizeValues.OneHundred\n | HdsTextSizeValues.TwoHundred\n | HdsTextSizeValues.ThreeHundred\n>;\ntype HdsTextBodySizeString = `${HdsTextBodySizeNumber}`;\nexport type HdsTextBodySizes = HdsTextBodySizeNumber | HdsTextBodySizeString;\nexport const SIZES: HdsTextBodySizes[] = [\n HdsTextSizeValues.ThreeHundred,\n HdsTextSizeValues.TwoHundred,\n HdsTextSizeValues.OneHundred,\n];\nexport const DEFAULT_SIZE = HdsTextSizeValues.TwoHundred;\n\nexport const DEFAULT_WEIGHT = HdsTextWeightValues.Regular;\nexport type HdsTextBodyWeight = Extract<\n HdsTextWeights,\n 'regular' | 'medium' | 'semibold'\n>;\nexport const WEIGHTS_PER_SIZE: Record<HdsTextBodySizes, HdsTextBodyWeight[]> = {\n 300: [\n HdsTextWeightValues.Regular,\n HdsTextWeightValues.Medium,\n HdsTextWeightValues.Semibold,\n ],\n 200: [\n HdsTextWeightValues.Regular,\n HdsTextWeightValues.Medium,\n HdsTextWeightValues.Semibold,\n ],\n 100: [\n HdsTextWeightValues.Regular,\n HdsTextWeightValues.Medium,\n HdsTextWeightValues.Semibold,\n ],\n};\n\nexport interface HdsTextBodySignature {\n Args: {\n size?: HdsTextBodySizes;\n tag?: HdsTextTags;\n weight?: HdsTextBodyWeight;\n align?: HdsTextAligns;\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n color?: string | HdsTextColors;\n };\n Element:\n | HTMLSpanElement\n | HTMLHeadingElement\n | HTMLParagraphElement\n | HTMLDivElement;\n Blocks: {\n default: [];\n };\n}\n\nexport default class HdsTextBody extends Component<HdsTextBodySignature> {\n // Sets the \"size\" for the text\n get size(): HdsTextBodySizes {\n let { size = DEFAULT_SIZE } = this.args;\n\n // let's be a bit forgiving with the consumers\n if (typeof size === 'string') {\n size = parseInt(size, 10);\n }\n\n assert(\n `@size for \"Hds::Text::Body\" must be one of the following: ${SIZES.join(\n ', '\n )}; received: ${size}`,\n SIZES.includes(size)\n );\n\n return size;\n }\n\n // Sets the \"weight\" for the text\n get weight(): HdsTextWeights {\n const { weight = DEFAULT_WEIGHT } = this.args;\n\n const weights = WEIGHTS_PER_SIZE[this.size];\n\n assert(\n `@weight for \"Hds::Text::Body\" with @size=${\n this.size\n } must be one of the following: ${weights.join(\n ', '\n )}; received: ${weight}`,\n weights.includes(weight)\n );\n\n return weight;\n }\n}\n"],"names":["SIZES","HdsTextSizeValues","ThreeHundred","TwoHundred","OneHundred","DEFAULT_SIZE","DEFAULT_WEIGHT","HdsTextWeightValues","Regular","WEIGHTS_PER_SIZE","Medium","Semibold","HdsTextBody","Component","size","args","parseInt","assert","join","includes","weight","weights","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;;AAwBaA,MAAAA,KAAyB,GAAG,CACvCC,iBAAiB,CAACC,YAAY,EAC9BD,iBAAiB,CAACE,UAAU,EAC5BF,iBAAiB,CAACG,UAAU;AAEjBC,MAAAA,YAAY,GAAGJ,iBAAiB,CAACE;AAEjCG,MAAAA,cAAc,GAAGC,mBAAmB,CAACC;AAK3C,MAAMC,gBAA+D,GAAG;AAC7E,EAAA,GAAG,EAAE,CACHF,mBAAmB,CAACC,OAAO,EAC3BD,mBAAmB,CAACG,MAAM,EAC1BH,mBAAmB,CAACI,QAAQ,CAC7B;AACD,EAAA,GAAG,EAAE,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PDX-License-Identifier: MPL-2.0
12
12
  */
13
13
 
14
- const AVAILABLE_SIZES = [HdsTextSizeValues.ThreeHundred, HdsTextSizeValues.TwoHundred, HdsTextSizeValues.OneHundred];
14
+ const SIZES = [HdsTextSizeValues.ThreeHundred, HdsTextSizeValues.TwoHundred, HdsTextSizeValues.OneHundred];
15
15
  const DEFAULT_SIZE = HdsTextSizeValues.TwoHundred;
16
16
  const DEFAULT_WEIGHT = HdsTextWeightValues.Regular;
17
- const AVAILABLE_WEIGHTS_PER_SIZE = {
17
+ const WEIGHTS_PER_SIZE = {
18
18
  [HdsTextSizeValues.ThreeHundred]: [HdsTextWeightValues.Regular, HdsTextWeightValues.Bold],
19
19
  [HdsTextSizeValues.TwoHundred]: [HdsTextWeightValues.Regular, HdsTextWeightValues.Bold],
20
20
  [HdsTextSizeValues.OneHundred]: [HdsTextWeightValues.Regular, HdsTextWeightValues.Bold]
21
21
  };
22
22
  class HdsTextCode extends Component {
23
- /**
24
- * Sets the "size" for the text
25
- * Accepted values: see AVAILABLE_SIZES
26
- *
27
- * @type {HdsTextCodeSizes}
28
- *
29
- * @param size
30
- */
23
+ // Sets the "size" for the text
31
24
  get size() {
32
25
  let {
33
26
  size = DEFAULT_SIZE
@@ -37,28 +30,21 @@ class HdsTextCode extends Component {
37
30
  if (typeof size === 'string') {
38
31
  size = parseInt(size, 10);
39
32
  }
40
- assert(`@size for "Hds::Text::Code" must be one of the following: ${AVAILABLE_SIZES.join(', ')}; received: ${size}`, AVAILABLE_SIZES.includes(size));
33
+ assert(`@size for "Hds::Text::Code" must be one of the following: ${SIZES.join(', ')}; received: ${size}`, SIZES.includes(size));
41
34
  return size;
42
35
  }
43
36
 
44
- /**
45
- * Sets the "weight" for the text
46
- * Accepted values: see AVAILABLE_WEIGHTS_PER_SIZE
47
- *
48
- * @type {string}
49
- *
50
- * @param variant
51
- */
37
+ // Sets the "weight" for the text
52
38
  get weight() {
53
39
  const {
54
40
  weight = DEFAULT_WEIGHT
55
41
  } = this.args;
56
- const availableWeights = AVAILABLE_WEIGHTS_PER_SIZE[this.size];
57
- assert(`@weight for "Hds::Text::Code" with @size=${this.size} must be one of the following: ${availableWeights.join(', ')}; received: ${weight}`, availableWeights.includes(weight));
42
+ const weights = WEIGHTS_PER_SIZE[this.size];
43
+ assert(`@weight for "Hds::Text::Code" with @size=${this.size} must be one of the following: ${weights.join(', ')}; received: ${weight}`, weights.includes(weight));
58
44
  return weight;
59
45
  }
60
46
  }
61
47
  setComponentTemplate(TEMPLATE, HdsTextCode);
62
48
 
63
- export { AVAILABLE_SIZES, AVAILABLE_WEIGHTS_PER_SIZE, DEFAULT_SIZE, DEFAULT_WEIGHT, HdsTextCode as default };
49
+ export { DEFAULT_SIZE, DEFAULT_WEIGHT, SIZES, WEIGHTS_PER_SIZE, HdsTextCode as default };
64
50
  //# sourceMappingURL=code.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"code.js","sources":["../../../../src/components/hds/text/code.ts"],"sourcesContent":["/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { assert } from '@ember/debug';\nimport { HdsTextSizeValues, HdsTextWeightValues } from './types.ts';\nimport type {\n HdsTextAligns,\n HdsTextColors,\n HdsTextTags,\n HdsTextWeights,\n} from './types.ts';\n\n// notice: only some combinations of size + font-weight are allowed (per design specs)\n// see: https://www.figma.com/file/oQsMzMMnynfPWpMEt91OpH/HDS-Product---Foundations?node-id=1262%3A9192\n\n// Allow consumers to provide either string or number representation of size\ntype HdsTextCodeSizeNumber = Extract<\n HdsTextSizeValues,\n | HdsTextSizeValues.OneHundred\n | HdsTextSizeValues.TwoHundred\n | HdsTextSizeValues.ThreeHundred\n>;\ntype HdsTextCodeSizeString = `${HdsTextCodeSizeNumber}`;\nexport type HdsTextCodeSizes = HdsTextCodeSizeNumber | HdsTextCodeSizeString;\nexport const AVAILABLE_SIZES = [\n HdsTextSizeValues.ThreeHundred,\n HdsTextSizeValues.TwoHundred,\n HdsTextSizeValues.OneHundred,\n];\nexport const DEFAULT_SIZE = HdsTextSizeValues.TwoHundred;\n\nexport const DEFAULT_WEIGHT = HdsTextWeightValues.Regular;\nexport type HdsTextCodeWeight = Extract<HdsTextWeights, 'regular' | 'bold'>;\nexport const AVAILABLE_WEIGHTS_PER_SIZE: Record<\n HdsTextCodeSizes,\n HdsTextCodeWeight[]\n> = {\n [HdsTextSizeValues.ThreeHundred]: [\n HdsTextWeightValues.Regular,\n HdsTextWeightValues.Bold,\n ],\n [HdsTextSizeValues.TwoHundred]: [\n HdsTextWeightValues.Regular,\n HdsTextWeightValues.Bold,\n ],\n [HdsTextSizeValues.OneHundred]: [\n HdsTextWeightValues.Regular,\n HdsTextWeightValues.Bold,\n ],\n};\n\nexport interface HdsTextCodeSignature {\n Args: {\n size?: HdsTextCodeSizes;\n tag?: HdsTextTags;\n weight?: HdsTextCodeWeight;\n align?: HdsTextAligns;\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n color?: string | HdsTextColors;\n };\n Element:\n | HTMLSpanElement\n | HTMLHeadingElement\n | HTMLParagraphElement\n | HTMLDivElement;\n Blocks: {\n default: [];\n };\n}\n\nexport default class HdsTextCode extends Component<HdsTextCodeSignature> {\n /**\n * Sets the \"size\" for the text\n * Accepted values: see AVAILABLE_SIZES\n *\n * @type {HdsTextCodeSizes}\n *\n * @param size\n */\n get size(): HdsTextCodeSizes {\n let { size = DEFAULT_SIZE } = this.args;\n\n // let's be a bit forgiving with the consumers\n if (typeof size === 'string') {\n size = parseInt(size, 10);\n }\n\n assert(\n `@size for \"Hds::Text::Code\" must be one of the following: ${AVAILABLE_SIZES.join(\n ', '\n )}; received: ${size}`,\n AVAILABLE_SIZES.includes(size)\n );\n\n return size;\n }\n\n /**\n * Sets the \"weight\" for the text\n * Accepted values: see AVAILABLE_WEIGHTS_PER_SIZE\n *\n * @type {string}\n *\n * @param variant\n */\n get weight(): HdsTextCodeWeight {\n const { weight = DEFAULT_WEIGHT } = this.args;\n\n const availableWeights = AVAILABLE_WEIGHTS_PER_SIZE[this.size];\n\n assert(\n `@weight for \"Hds::Text::Code\" with @size=${\n this.size\n } must be one of the following: ${availableWeights.join(\n ', '\n )}; received: ${weight}`,\n availableWeights.includes(weight)\n );\n\n return weight;\n }\n}\n"],"names":["AVAILABLE_SIZES","HdsTextSizeValues","ThreeHundred","TwoHundred","OneHundred","DEFAULT_SIZE","DEFAULT_WEIGHT","HdsTextWeightValues","Regular","AVAILABLE_WEIGHTS_PER_SIZE","Bold","HdsTextCode","Component","size","args","parseInt","assert","join","includes","weight","availableWeights","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;;AAwBaA,MAAAA,eAAe,GAAG,CAC7BC,iBAAiB,CAACC,YAAY,EAC9BD,iBAAiB,CAACE,UAAU,EAC5BF,iBAAiB,CAACG,UAAU;AAEjBC,MAAAA,YAAY,GAAGJ,iBAAiB,CAACE;AAEjCG,MAAAA,cAAc,GAAGC,mBAAmB,CAACC;AAE3C,MAAMC,0BAGZ,GAAG;AACF,EAAA,CAACR,iBAAiB,CAACC,YAAY,GAAG,CAChCK,mBAAmB,CAACC,OAAO,EAC3BD,mBAAmB,CAACG,IAAI,CACzB;AACD,EAAA,CAACT,iBAAiB,CAACE,UAAU,GAAG,CAC9BI,mBAAmB,CAACC,OAAO,EAC3BD,mBAAmB,CAACG,IAAI,CACzB;EACD,CAACT,iBAAiB,CAACG,UAAU,GAAG,CAC9BG,mBAAmB,CAACC,OAAO,EAC3BD,mBAAmB,CAACG,IAAI;AAE5B;AAqBe,MAAMC,WAAW,SAASC,SAAS,CAAuB;AACvE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE,IAAIC,IAAIA,GAAqB;IAC3B,IAAI;AAAEA,MAAAA,IAAI,GAAGR;KAAc,GAAG,IAAI,CAACS,IAAI;;AAEvC;AACA,IAAA,IAAI,OAAOD,IAAI,KAAK,QAAQ,EAAE;AAC5BA,MAAAA,IAAI,GAAGE,QAAQ,CAACF,IAAI,EAAE,EAAE,CAAC;AAC3B;AAEAG,IAAAA,MAAM,CACJ,CAA6DhB,0DAAAA,EAAAA,eAAe,CAACiB,IAAI,CAC/E,IACF,CAAC,CAAA,YAAA,EAAeJ,IAAI,CAAA,CAAE,EACtBb,eAAe,CAACkB,QAAQ,CAACL,IAAI,CAC/B,CAAC;AAED,IAAA,OAAOA,IAAI;AACb;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE,IAAIM,MAAMA,GAAsB;IAC9B,MAAM;AAAEA,MAAAA,MAAM,GAAGb;KAAgB,GAAG,IAAI,CAACQ,IAAI;AAE7C,IAAA,MAAMM,gBAAgB,GAAGX,0BAA0B,CAAC,IAAI,CAACI,IAAI,CAAC;IAE9DG,MAAM,CACJ,4CACE,IAAI,CAACH,IAAI,CACuBO,+BAAAA,EAAAA,gBAAgB,CAACH,IAAI,CACrD,IACF,CAAC,CAAeE,YAAAA,EAAAA,MAAM,EAAE,EACxBC,gBAAgB,CAACF,QAAQ,CAACC,MAAM,CAClC,CAAC;AAED,IAAA,OAAOA,MAAM;AACf;AACF;AAACE,oBAAA,CAAAC,QAAA,EAnDoBX,WAAW,CAAA;;;;"}
1
+ {"version":3,"file":"code.js","sources":["../../../../src/components/hds/text/code.ts"],"sourcesContent":["/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { assert } from '@ember/debug';\nimport { HdsTextSizeValues, HdsTextWeightValues } from './types.ts';\nimport type {\n HdsTextAligns,\n HdsTextColors,\n HdsTextTags,\n HdsTextWeights,\n} from './types.ts';\n\n// notice: only some combinations of size + font-weight are allowed (per design specs)\n// see: https://www.figma.com/file/oQsMzMMnynfPWpMEt91OpH/HDS-Product---Foundations?node-id=1262%3A9192\n\n// Allow consumers to provide either string or number representation of size\ntype HdsTextCodeSizeNumber = Extract<\n HdsTextSizeValues,\n | HdsTextSizeValues.OneHundred\n | HdsTextSizeValues.TwoHundred\n | HdsTextSizeValues.ThreeHundred\n>;\ntype HdsTextCodeSizeString = `${HdsTextCodeSizeNumber}`;\nexport type HdsTextCodeSizes = HdsTextCodeSizeNumber | HdsTextCodeSizeString;\nexport const SIZES: HdsTextCodeSizes[] = [\n HdsTextSizeValues.ThreeHundred,\n HdsTextSizeValues.TwoHundred,\n HdsTextSizeValues.OneHundred,\n];\nexport const DEFAULT_SIZE = HdsTextSizeValues.TwoHundred;\n\nexport const DEFAULT_WEIGHT = HdsTextWeightValues.Regular;\nexport type HdsTextCodeWeight = Extract<HdsTextWeights, 'regular' | 'bold'>;\nexport const WEIGHTS_PER_SIZE: Record<HdsTextCodeSizes, HdsTextCodeWeight[]> = {\n [HdsTextSizeValues.ThreeHundred]: [\n HdsTextWeightValues.Regular,\n HdsTextWeightValues.Bold,\n ],\n [HdsTextSizeValues.TwoHundred]: [\n HdsTextWeightValues.Regular,\n HdsTextWeightValues.Bold,\n ],\n [HdsTextSizeValues.OneHundred]: [\n HdsTextWeightValues.Regular,\n HdsTextWeightValues.Bold,\n ],\n};\n\nexport interface HdsTextCodeSignature {\n Args: {\n size?: HdsTextCodeSizes;\n tag?: HdsTextTags;\n weight?: HdsTextCodeWeight;\n align?: HdsTextAligns;\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n color?: string | HdsTextColors;\n };\n Element:\n | HTMLSpanElement\n | HTMLHeadingElement\n | HTMLParagraphElement\n | HTMLDivElement;\n Blocks: {\n default: [];\n };\n}\n\nexport default class HdsTextCode extends Component<HdsTextCodeSignature> {\n // Sets the \"size\" for the text\n get size(): HdsTextCodeSizes {\n let { size = DEFAULT_SIZE } = this.args;\n\n // let's be a bit forgiving with the consumers\n if (typeof size === 'string') {\n size = parseInt(size, 10);\n }\n\n assert(\n `@size for \"Hds::Text::Code\" must be one of the following: ${SIZES.join(\n ', '\n )}; received: ${size}`,\n SIZES.includes(size)\n );\n\n return size;\n }\n\n // Sets the \"weight\" for the text\n get weight(): HdsTextCodeWeight {\n const { weight = DEFAULT_WEIGHT } = this.args;\n\n const weights = WEIGHTS_PER_SIZE[this.size];\n\n assert(\n `@weight for \"Hds::Text::Code\" with @size=${\n this.size\n } must be one of the following: ${weights.join(\n ', '\n )}; received: ${weight}`,\n weights.includes(weight)\n );\n\n return weight;\n }\n}\n"],"names":["SIZES","HdsTextSizeValues","ThreeHundred","TwoHundred","OneHundred","DEFAULT_SIZE","DEFAULT_WEIGHT","HdsTextWeightValues","Regular","WEIGHTS_PER_SIZE","Bold","HdsTextCode","Component","size","args","parseInt","assert","join","includes","weight","weights","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;;AAwBaA,MAAAA,KAAyB,GAAG,CACvCC,iBAAiB,CAACC,YAAY,EAC9BD,iBAAiB,CAACE,UAAU,EAC5BF,iBAAiB,CAACG,UAAU;AAEjBC,MAAAA,YAAY,GAAGJ,iBAAiB,CAACE;AAEjCG,MAAAA,cAAc,GAAGC,mBAAmB,CAACC;AAE3C,MAAMC,gBAA+D,GAAG;AAC7E,EAAA,CAACR,iBAAiB,CAACC,YAAY,GAAG,CAChCK,mBAAmB,CAACC,OAAO,EAC3BD,mBAAmB,CAACG,IAAI,CACzB;AACD,EAAA,CAACT,iBAAiB,CAACE,UAAU,GAAG,CAC9BI,mBAAmB,CAACC,OAAO,EAC3BD,mBAAmB,CAACG,IAAI,CACzB;EACD,CAACT,iBAAiB,CAACG,UAAU,GAAG,CAC9BG,mBAAmB,CAACC,OAAO,EAC3BD,mBAAmB,CAACG,IAAI;AAE5B;AAqBe,MAAMC,WAAW,SAASC,SAAS,CAAuB;AACvE;EACA,IAAIC,IAAIA,GAAqB;IAC3B,IAAI;AAAEA,MAAAA,IAAI,GAAGR;KAAc,GAAG,IAAI,CAACS,IAAI;;AAEvC;AACA,IAAA,IAAI,OAAOD,IAAI,KAAK,QAAQ,EAAE;AAC5BA,MAAAA,IAAI,GAAGE,QAAQ,CAACF,IAAI,EAAE,EAAE,CAAC;AAC3B;AAEAG,IAAAA,MAAM,CACJ,CAA6DhB,0DAAAA,EAAAA,KAAK,CAACiB,IAAI,CACrE,IACF,CAAC,CAAA,YAAA,EAAeJ,IAAI,CAAA,CAAE,EACtBb,KAAK,CAACkB,QAAQ,CAACL,IAAI,CACrB,CAAC;AAED,IAAA,OAAOA,IAAI;AACb;;AAEA;EACA,IAAIM,MAAMA,GAAsB;IAC9B,MAAM;AAAEA,MAAAA,MAAM,GAAGb;KAAgB,GAAG,IAAI,CAACQ,IAAI;AAE7C,IAAA,MAAMM,OAAO,GAAGX,gBAAgB,CAAC,IAAI,CAACI,IAAI,CAAC;IAE3CG,MAAM,CACJ,4CACE,IAAI,CAACH,IAAI,CACuBO,+BAAAA,EAAAA,OAAO,CAACH,IAAI,CAC5C,IACF,CAAC,CAAeE,YAAAA,EAAAA,MAAM,EAAE,EACxBC,OAAO,CAACF,QAAQ,CAACC,MAAM,CACzB,CAAC;AAED,IAAA,OAAOA,MAAM;AACf;AACF;AAACE,oBAAA,CAAAC,QAAA,EArCoBX,WAAW,CAAA;;;;"}
@@ -18,7 +18,7 @@ const DEFAULT_SIZE = HdsTextSizeValues.TwoHundred;
18
18
 
19
19
  // Filter out reverse mappings from enum
20
20
  // https://www.typescriptlang.org/docs/handbook/enums.html#reverse-mappings
21
- const AVAILABLE_SIZES = Object.values(HdsTextSizeValues).filter(v => typeof v === 'number');
21
+ const SIZES = Object.values(HdsTextSizeValues).filter(v => typeof v === 'number');
22
22
  const DEFAULT_WEIGHTS_PER_SIZE = {
23
23
  [HdsTextSizeValues.FiveHundred]: HdsTextWeightValues.Bold,
24
24
  [HdsTextSizeValues.FourHundred]: HdsTextWeightValues.Semibold,
@@ -26,7 +26,7 @@ const DEFAULT_WEIGHTS_PER_SIZE = {
26
26
  [HdsTextSizeValues.TwoHundred]: HdsTextWeightValues.Semibold,
27
27
  [HdsTextSizeValues.OneHundred]: HdsTextWeightValues.Medium
28
28
  };
29
- const AVAILABLE_WEIGHTS_PER_SIZE = {
29
+ const WEIGHTS_PER_SIZE = {
30
30
  [HdsTextSizeValues.FiveHundred]: [HdsTextWeightValues.Bold],
31
31
  [HdsTextSizeValues.FourHundred]: [HdsTextWeightValues.Medium, HdsTextWeightValues.Semibold, HdsTextWeightValues.Bold],
32
32
  [HdsTextSizeValues.ThreeHundred]: [HdsTextWeightValues.Medium, HdsTextWeightValues.Semibold, HdsTextWeightValues.Bold],
@@ -34,14 +34,7 @@ const AVAILABLE_WEIGHTS_PER_SIZE = {
34
34
  [HdsTextSizeValues.OneHundred]: [HdsTextWeightValues.Medium]
35
35
  };
36
36
  class HdsTextDisplay extends Component {
37
- /**
38
- * Sets the "size" for the text
39
- * Accepted values: see AVAILABLE_SIZES
40
- *
41
- * @type {HdsTextSizes}
42
- *
43
- * @param size
44
- */
37
+ // Sets the "size" for the text
45
38
  get size() {
46
39
  let {
47
40
  size = DEFAULT_SIZE
@@ -51,25 +44,18 @@ class HdsTextDisplay extends Component {
51
44
  if (typeof size === 'string') {
52
45
  size = parseInt(size, 10);
53
46
  }
54
- assert(`@size for "Hds::Text::Display" must be one of the following: ${AVAILABLE_SIZES.join(', ')}; received: ${size}`, AVAILABLE_SIZES.includes(size));
47
+ assert(`@size for "Hds::Text::Display" must be one of the following: ${SIZES.join(', ')}; received: ${size}`, SIZES.includes(size));
55
48
  return size;
56
49
  }
57
50
 
58
- /**
59
- * Sets the "weight" for the text
60
- * Accepted values: see AVAILABLE_WEIGHTS_PER_SIZE
61
- *
62
- * @type {HdsTextDisplayWeight}
63
- *
64
- * @param variant
65
- */
51
+ // Sets the "weight" for the text
66
52
  get weight() {
67
53
  let {
68
54
  weight
69
55
  } = this.args;
70
56
  if (weight) {
71
- const availableWeights = AVAILABLE_WEIGHTS_PER_SIZE[this.size];
72
- assert(`@weight for "Hds::Text::Display" with @size=${this.size} must be one of the following: ${availableWeights.join(', ')}; received: ${weight}`, availableWeights.includes(weight));
57
+ const weights = WEIGHTS_PER_SIZE[this.size];
58
+ assert(`@weight for "Hds::Text::Display" with @size=${this.size} must be one of the following: ${weights.join(', ')}; received: ${weight}`, weights.includes(weight));
73
59
  } else {
74
60
  // use the default (first item in the array)
75
61
  weight = DEFAULT_WEIGHTS_PER_SIZE[this.size];
@@ -79,5 +65,5 @@ class HdsTextDisplay extends Component {
79
65
  }
80
66
  setComponentTemplate(TEMPLATE, HdsTextDisplay);
81
67
 
82
- export { AVAILABLE_SIZES, AVAILABLE_WEIGHTS_PER_SIZE, DEFAULT_SIZE, DEFAULT_WEIGHTS_PER_SIZE, HdsTextDisplay as default };
68
+ export { DEFAULT_SIZE, DEFAULT_WEIGHTS_PER_SIZE, SIZES, WEIGHTS_PER_SIZE, HdsTextDisplay as default };
83
69
  //# sourceMappingURL=display.js.map