@carbon/ibm-products-web-components 0.48.0 → 0.49.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom-elements.json +55 -17
- package/es/components/page-header/_story-assets/overflowHandler.d.ts.map +1 -1
- package/es/components/page-header/_story-assets/overflowHandler.js +1 -1
- package/es/components/page-header/_story-assets/overflowHandler.js.map +1 -1
- package/es/components/page-header/context.d.ts +3 -0
- package/es/components/page-header/context.d.ts.map +1 -1
- package/es/components/page-header/context.js +4 -1
- package/es/components/page-header/context.js.map +1 -1
- package/es/components/page-header/page-header-actions-set/page-header-actions-set.d.ts +4 -0
- package/es/components/page-header/page-header-actions-set/page-header-actions-set.d.ts.map +1 -1
- package/es/components/page-header/page-header-actions-set/page-header-actions-set.js +22 -13
- package/es/components/page-header/page-header-actions-set/page-header-actions-set.js.map +1 -1
- package/es/components/page-header/page-header-breadcrumb.d.ts +1 -1
- package/es/components/page-header/page-header-breadcrumb.d.ts.map +1 -1
- package/es/components/page-header/page-header-breadcrumb.js +4 -2
- package/es/components/page-header/page-header-breadcrumb.js.map +1 -1
- package/es/components/page-header/page-header-breadcrumbs-set/page-header-breadcrumbs-set.d.ts +11 -2
- package/es/components/page-header/page-header-breadcrumbs-set/page-header-breadcrumbs-set.d.ts.map +1 -1
- package/es/components/page-header/page-header-breadcrumbs-set/page-header-breadcrumbs-set.js +37 -21
- package/es/components/page-header/page-header-breadcrumbs-set/page-header-breadcrumbs-set.js.map +1 -1
- package/es/components/page-header/page-header-content-text.d.ts +8 -0
- package/es/components/page-header/page-header-content-text.d.ts.map +1 -1
- package/es/components/page-header/page-header-content-text.js +21 -5
- package/es/components/page-header/page-header-content-text.js.map +1 -1
- package/es/components/page-header/page-header-content.d.ts +13 -0
- package/es/components/page-header/page-header-content.d.ts.map +1 -1
- package/es/components/page-header/page-header-content.js +37 -14
- package/es/components/page-header/page-header-content.js.map +1 -1
- package/es/components/page-header/page-header-hero-image.d.ts +3 -0
- package/es/components/page-header/page-header-hero-image.d.ts.map +1 -1
- package/es/components/page-header/page-header-hero-image.js +3 -0
- package/es/components/page-header/page-header-hero-image.js.map +1 -1
- package/es/components/page-header/page-header-scroller.d.ts +1 -0
- package/es/components/page-header/page-header-scroller.d.ts.map +1 -1
- package/es/components/page-header/page-header-scroller.js +7 -3
- package/es/components/page-header/page-header-scroller.js.map +1 -1
- package/es/components/page-header/page-header-tabs.d.ts +1 -0
- package/es/components/page-header/page-header-tabs.d.ts.map +1 -1
- package/es/components/page-header/page-header-tabs.js +24 -10
- package/es/components/page-header/page-header-tabs.js.map +1 -1
- package/es/components/page-header/page-header-tags-set/page-header-tags-set.d.ts +2 -1
- package/es/components/page-header/page-header-tags-set/page-header-tags-set.d.ts.map +1 -1
- package/es/components/page-header/page-header-tags-set/page-header-tags-set.js +38 -17
- package/es/components/page-header/page-header-tags-set/page-header-tags-set.js.map +1 -1
- package/es/components/page-header/page-header-tags-set/page-header-tags-set.scss.js +1 -1
- package/es/components/page-header/page-header-tags-set/page-header-tags-set.scss.js.map +1 -1
- package/es/components/page-header/page-header-tags-set/utils.d.ts +0 -8
- package/es/components/page-header/page-header-tags-set/utils.d.ts.map +1 -1
- package/es/components/page-header/page-header-tags-set/utils.js +0 -34
- package/es/components/page-header/page-header-title-breadcrumb.d.ts.map +1 -1
- package/es/components/page-header/page-header-title-breadcrumb.js +8 -5
- package/es/components/page-header/page-header-title-breadcrumb.js.map +1 -1
- package/es/components/page-header/page-header.d.ts +15 -0
- package/es/components/page-header/page-header.d.ts.map +1 -1
- package/es/components/page-header/page-header.js +80 -34
- package/es/components/page-header/page-header.js.map +1 -1
- package/es/components/page-header/page-header.scss.js +1 -1
- package/es/components/page-header/page-header.scss.js.map +1 -1
- package/es/components/tearsheet/tearsheet.scss.js +1 -1
- package/es/components/tearsheet-preview/tearsheet-header-content.scss.js +1 -1
- package/es/components/tearsheet-preview/tearsheet-header-content.scss.js.map +1 -1
- package/es/components/tearsheet-preview/tearsheet-header.scss.js +1 -1
- package/es/components/tearsheet-preview/tearsheet-header.scss.js.map +1 -1
- package/es/components/tearsheet-preview/tearsheet-navigation-bar.scss.js +1 -1
- package/es/components/tearsheet-preview/tearsheet.scss.js +1 -1
- package/es/components/tearsheet-preview/tearsheet.scss.js.map +1 -1
- package/es/ibm-products-web-components/package.js +1 -1
- package/es-custom/components/page-header/_story-assets/overflowHandler.js +1 -1
- package/es-custom/components/page-header/_story-assets/overflowHandler.js.map +1 -1
- package/es-custom/components/page-header/context.js +4 -1
- package/es-custom/components/page-header/context.js.map +1 -1
- package/es-custom/components/page-header/page-header-actions-set/page-header-actions-set.js +22 -13
- package/es-custom/components/page-header/page-header-actions-set/page-header-actions-set.js.map +1 -1
- package/es-custom/components/page-header/page-header-breadcrumb.js +4 -2
- package/es-custom/components/page-header/page-header-breadcrumb.js.map +1 -1
- package/es-custom/components/page-header/page-header-breadcrumbs-set/page-header-breadcrumbs-set.js +37 -21
- package/es-custom/components/page-header/page-header-breadcrumbs-set/page-header-breadcrumbs-set.js.map +1 -1
- package/es-custom/components/page-header/page-header-content-text.js +21 -5
- package/es-custom/components/page-header/page-header-content-text.js.map +1 -1
- package/es-custom/components/page-header/page-header-content.js +37 -14
- package/es-custom/components/page-header/page-header-content.js.map +1 -1
- package/es-custom/components/page-header/page-header-hero-image.js +3 -0
- package/es-custom/components/page-header/page-header-hero-image.js.map +1 -1
- package/es-custom/components/page-header/page-header-scroller.js +7 -3
- package/es-custom/components/page-header/page-header-scroller.js.map +1 -1
- package/es-custom/components/page-header/page-header-tabs.js +24 -10
- package/es-custom/components/page-header/page-header-tabs.js.map +1 -1
- package/es-custom/components/page-header/page-header-tags-set/page-header-tags-set.js +38 -17
- package/es-custom/components/page-header/page-header-tags-set/page-header-tags-set.js.map +1 -1
- package/es-custom/components/page-header/page-header-tags-set/page-header-tags-set.scss.js +1 -1
- package/es-custom/components/page-header/page-header-tags-set/page-header-tags-set.scss.js.map +1 -1
- package/es-custom/components/page-header/page-header-tags-set/utils.js +0 -34
- package/es-custom/components/page-header/page-header-title-breadcrumb.js +8 -5
- package/es-custom/components/page-header/page-header-title-breadcrumb.js.map +1 -1
- package/es-custom/components/page-header/page-header.js +80 -34
- package/es-custom/components/page-header/page-header.js.map +1 -1
- package/es-custom/components/page-header/page-header.scss.js +1 -1
- package/es-custom/components/page-header/page-header.scss.js.map +1 -1
- package/es-custom/components/tearsheet/tearsheet.scss.js +1 -1
- package/es-custom/components/tearsheet-preview/tearsheet-header-content.scss.js +1 -1
- package/es-custom/components/tearsheet-preview/tearsheet-header-content.scss.js.map +1 -1
- package/es-custom/components/tearsheet-preview/tearsheet-header.scss.js +1 -1
- package/es-custom/components/tearsheet-preview/tearsheet-header.scss.js.map +1 -1
- package/es-custom/components/tearsheet-preview/tearsheet-navigation-bar.scss.js +1 -1
- package/es-custom/components/tearsheet-preview/tearsheet.scss.js +1 -1
- package/es-custom/components/tearsheet-preview/tearsheet.scss.js.map +1 -1
- package/es-custom/ibm-products-web-components/package.js +1 -1
- package/lib/components/page-header/_story-assets/overflowHandler.d.ts.map +1 -1
- package/lib/components/page-header/context.d.ts +3 -0
- package/lib/components/page-header/context.d.ts.map +1 -1
- package/lib/components/page-header/page-header-actions-set/page-header-actions-set.d.ts +4 -0
- package/lib/components/page-header/page-header-actions-set/page-header-actions-set.d.ts.map +1 -1
- package/lib/components/page-header/page-header-breadcrumb.d.ts +1 -1
- package/lib/components/page-header/page-header-breadcrumb.d.ts.map +1 -1
- package/lib/components/page-header/page-header-breadcrumbs-set/page-header-breadcrumbs-set.d.ts +11 -2
- package/lib/components/page-header/page-header-breadcrumbs-set/page-header-breadcrumbs-set.d.ts.map +1 -1
- package/lib/components/page-header/page-header-content-text.d.ts +8 -0
- package/lib/components/page-header/page-header-content-text.d.ts.map +1 -1
- package/lib/components/page-header/page-header-content.d.ts +13 -0
- package/lib/components/page-header/page-header-content.d.ts.map +1 -1
- package/lib/components/page-header/page-header-hero-image.d.ts +3 -0
- package/lib/components/page-header/page-header-hero-image.d.ts.map +1 -1
- package/lib/components/page-header/page-header-scroller.d.ts +1 -0
- package/lib/components/page-header/page-header-scroller.d.ts.map +1 -1
- package/lib/components/page-header/page-header-tabs.d.ts +1 -0
- package/lib/components/page-header/page-header-tabs.d.ts.map +1 -1
- package/lib/components/page-header/page-header-tags-set/page-header-tags-set.d.ts +2 -1
- package/lib/components/page-header/page-header-tags-set/page-header-tags-set.d.ts.map +1 -1
- package/lib/components/page-header/page-header-tags-set/utils.d.ts +0 -8
- package/lib/components/page-header/page-header-tags-set/utils.d.ts.map +1 -1
- package/lib/components/page-header/page-header-title-breadcrumb.d.ts.map +1 -1
- package/lib/components/page-header/page-header.d.ts +15 -0
- package/lib/components/page-header/page-header.d.ts.map +1 -1
- package/package.json +4 -4
- package/scss/components/page-header/page-header-tags-set/page-header-tags-set.scss +16 -4
- package/scss/components/page-header/page-header.scss +31 -17
- package/scss/components/tearsheet-preview/tearsheet-header-content.scss +32 -6
- package/scss/components/tearsheet-preview/tearsheet-header.scss +4 -0
- package/scss/components/tearsheet-preview/tearsheet.scss +20 -1
- package/telemetry.yml +4 -1
- package/es/components/page-header/page-header-tags-set/utils.js.map +0 -1
- package/es-custom/components/page-header/page-header-tags-set/utils.js.map +0 -1
package/custom-elements.json
CHANGED
|
@@ -3346,6 +3346,12 @@
|
|
|
3346
3346
|
"type": "PageAction[]",
|
|
3347
3347
|
"default": "[]"
|
|
3348
3348
|
},
|
|
3349
|
+
{
|
|
3350
|
+
"name": "toolbar-aria-label",
|
|
3351
|
+
"description": "Aria label for the toolbar container (`role=\"toolbar\"`).",
|
|
3352
|
+
"type": "string",
|
|
3353
|
+
"default": "\"Page actions\""
|
|
3354
|
+
},
|
|
3349
3355
|
{
|
|
3350
3356
|
"name": "overflow-aria-label",
|
|
3351
3357
|
"description": "Aria label for the overflow menu button.",
|
|
@@ -3367,6 +3373,13 @@
|
|
|
3367
3373
|
"type": "PageAction[]",
|
|
3368
3374
|
"default": "[]"
|
|
3369
3375
|
},
|
|
3376
|
+
{
|
|
3377
|
+
"name": "toolbarAriaLabel",
|
|
3378
|
+
"attribute": "toolbar-aria-label",
|
|
3379
|
+
"description": "Aria label for the toolbar container (`role=\"toolbar\"`).",
|
|
3380
|
+
"type": "string",
|
|
3381
|
+
"default": "\"Page actions\""
|
|
3382
|
+
},
|
|
3370
3383
|
{
|
|
3371
3384
|
"name": "overflowAriaLabel",
|
|
3372
3385
|
"attribute": "overflow-aria-label",
|
|
@@ -3411,7 +3424,7 @@
|
|
|
3411
3424
|
},
|
|
3412
3425
|
{
|
|
3413
3426
|
"name": "actions-aria-label",
|
|
3414
|
-
"description": "Aria label for the page header actions
|
|
3427
|
+
"description": "Aria label for the page header actions toolbar.",
|
|
3415
3428
|
"type": "string",
|
|
3416
3429
|
"default": "\"Page header actions\""
|
|
3417
3430
|
}
|
|
@@ -3448,7 +3461,7 @@
|
|
|
3448
3461
|
{
|
|
3449
3462
|
"name": "actionsAriaLabel",
|
|
3450
3463
|
"attribute": "actions-aria-label",
|
|
3451
|
-
"description": "Aria label for the page header actions
|
|
3464
|
+
"description": "Aria label for the page header actions toolbar.",
|
|
3452
3465
|
"type": "string",
|
|
3453
3466
|
"default": "\"Page header actions\""
|
|
3454
3467
|
},
|
|
@@ -3465,12 +3478,6 @@
|
|
|
3465
3478
|
"name": "c4p-page-header-breadcrumbs-set",
|
|
3466
3479
|
"path": "./src/components/page-header/page-header-breadcrumbs-set/page-header-breadcrumbs-set.ts",
|
|
3467
3480
|
"attributes": [
|
|
3468
|
-
{
|
|
3469
|
-
"name": "hiddenItems",
|
|
3470
|
-
"description": "Hidden items that will be rendered in the overflow menu.",
|
|
3471
|
-
"type": "Breadcrumb[]",
|
|
3472
|
-
"default": "[]"
|
|
3473
|
-
},
|
|
3474
3481
|
{
|
|
3475
3482
|
"name": "breadcrumbs-data",
|
|
3476
3483
|
"description": "The list of breadcrumbs.",
|
|
@@ -3497,13 +3504,6 @@
|
|
|
3497
3504
|
}
|
|
3498
3505
|
],
|
|
3499
3506
|
"properties": [
|
|
3500
|
-
{
|
|
3501
|
-
"name": "hiddenItems",
|
|
3502
|
-
"attribute": "hiddenItems",
|
|
3503
|
-
"description": "Hidden items that will be rendered in the overflow menu.",
|
|
3504
|
-
"type": "Breadcrumb[]",
|
|
3505
|
-
"default": "[]"
|
|
3506
|
-
},
|
|
3507
3507
|
{
|
|
3508
3508
|
"name": "breadcrumbsData",
|
|
3509
3509
|
"attribute": "breadcrumbs-data",
|
|
@@ -3656,6 +3656,12 @@
|
|
|
3656
3656
|
"name": "styles",
|
|
3657
3657
|
"default": "\"styles\""
|
|
3658
3658
|
}
|
|
3659
|
+
],
|
|
3660
|
+
"slots": [
|
|
3661
|
+
{
|
|
3662
|
+
"name": "",
|
|
3663
|
+
"description": "Slotted content (typically an `<img>`). Slotted images must include\na descriptive `alt` attribute for informative images, or `alt=\"\"` for\ndecorative images, to meet WCAG 2.2 SC 1.1.1 (Non-text Content)."
|
|
3664
|
+
}
|
|
3659
3665
|
]
|
|
3660
3666
|
},
|
|
3661
3667
|
{
|
|
@@ -3899,7 +3905,8 @@
|
|
|
3899
3905
|
"type": "{ delegatesFocus: boolean; clonable?: boolean | undefined; customElementRegistry?: CustomElementRegistry | null | undefined; mode: ShadowRootMode; serializable?: boolean | undefined; slotAssignment?: SlotAssignmentMode | undefined; }"
|
|
3900
3906
|
},
|
|
3901
3907
|
{
|
|
3902
|
-
"name": "styles"
|
|
3908
|
+
"name": "styles",
|
|
3909
|
+
"default": "\"styles\""
|
|
3903
3910
|
}
|
|
3904
3911
|
]
|
|
3905
3912
|
},
|
|
@@ -3923,6 +3930,9 @@
|
|
|
3923
3930
|
"type": "boolean",
|
|
3924
3931
|
"default": "false"
|
|
3925
3932
|
},
|
|
3933
|
+
{
|
|
3934
|
+
"name": "context"
|
|
3935
|
+
},
|
|
3926
3936
|
{
|
|
3927
3937
|
"name": "styles",
|
|
3928
3938
|
"default": "\"styles\""
|
|
@@ -3975,11 +3985,39 @@
|
|
|
3975
3985
|
"name": "c4p-page-header",
|
|
3976
3986
|
"path": "./src/components/page-header/page-header.ts",
|
|
3977
3987
|
"description": "Page header.",
|
|
3988
|
+
"attributes": [
|
|
3989
|
+
{
|
|
3990
|
+
"name": "full-width-grid",
|
|
3991
|
+
"description": "Set to `true` to use a full-width Carbon CSS grid (no max-width cap).",
|
|
3992
|
+
"type": "boolean",
|
|
3993
|
+
"default": "false"
|
|
3994
|
+
},
|
|
3995
|
+
{
|
|
3996
|
+
"name": "narrow-grid",
|
|
3997
|
+
"description": "Set to `true` to use the Carbon narrow grid mode (content aligns to\nthe gutter edge).",
|
|
3998
|
+
"type": "boolean",
|
|
3999
|
+
"default": "false"
|
|
4000
|
+
}
|
|
4001
|
+
],
|
|
3978
4002
|
"properties": [
|
|
4003
|
+
{
|
|
4004
|
+
"name": "fullWidthGrid",
|
|
4005
|
+
"attribute": "full-width-grid",
|
|
4006
|
+
"description": "Set to `true` to use a full-width Carbon CSS grid (no max-width cap).",
|
|
4007
|
+
"type": "boolean",
|
|
4008
|
+
"default": "false"
|
|
4009
|
+
},
|
|
4010
|
+
{
|
|
4011
|
+
"name": "narrowGrid",
|
|
4012
|
+
"attribute": "narrow-grid",
|
|
4013
|
+
"description": "Set to `true` to use the Carbon narrow grid mode (content aligns to\nthe gutter edge).",
|
|
4014
|
+
"type": "boolean",
|
|
4015
|
+
"default": "false"
|
|
4016
|
+
},
|
|
3979
4017
|
{
|
|
3980
4018
|
"name": "context",
|
|
3981
4019
|
"type": "pageHeaderContextType",
|
|
3982
|
-
"default": "{}"
|
|
4020
|
+
"default": "{\"fullWidthGrid\":\"fullWidthGrid\",\"narrowGrid\":\"narrowGrid\"}"
|
|
3983
4021
|
},
|
|
3984
4022
|
{
|
|
3985
4023
|
"name": "styles",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overflowHandler.d.ts","sourceRoot":"","sources":["../../../../src/components/page-header/_story-assets/overflowHandler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CACrB,EAAE,EAAE,WAAW,EACf,SAAS,EAAE,OAAO,GAAG,QAAQ,GAC5B,MAAM,
|
|
1
|
+
{"version":3,"file":"overflowHandler.d.ts","sourceRoot":"","sources":["../../../../src/components/page-header/_story-assets/overflowHandler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CACrB,EAAE,EAAE,WAAW,EACf,SAAS,EAAE,OAAO,GAAG,QAAQ,GAC5B,MAAM,CAsBR;AAED;;;;GAIG;AACH,MAAM,WAAW,4BAA4B;IAC3C,kDAAkD;IAClD,SAAS,EAAE,WAAW,CAAC;IACvB,4DAA4D;IAC5D,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,oIAAoI;IACpI,MAAM,EAAE,WAAW,CAAC;IACpB,yEAAyE;IACzE,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,6EAA6E;IAC7E,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,sCAAsC;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,uGAAuG;IACvG,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,0EAA0E;IAC1E,SAAS,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC9B,kFAAkF;IAClF,QAAQ,EAAE,CAAC,YAAY,EAAE,WAAW,EAAE,EAAE,WAAW,EAAE,WAAW,EAAE,KAAK,IAAI,CAAC;IAC5E,mFAAmF;IACnF,mBAAmB,CAAC,EAAE,WAAW,EAAE,CAAC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,SAAS,EACT,KAAK,EACL,MAAM,EACN,KAAK,EACL,UAAU,EACV,UAAU,EACV,eAAe,EACf,SAAS,EACT,QAAQ,EACR,mBAAwB,EACxB,WAAe,GAChB,EAAE,4BAA4B,GAAG,WAAW,EAAE,CAmD9C;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,SAAS,EAAE,WAAW,CAAC;IACvB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,QAAQ,EAAE,CAAC,YAAY,EAAE,WAAW,EAAE,EAAE,WAAW,EAAE,WAAW,EAAE,KAAK,IAAI,CAAC;IAC5E;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,wBAAgB,qBAAqB,CAAC,EACpC,SAAS,EACT,eAAe,EACf,QAAQ,EACR,SAAmB,EACnB,WAAe,GAChB,EAAE,sBAAsB,GAAG,eAAe,CA4D1C"}
|
|
@@ -30,7 +30,7 @@ function getSize(el, dimension) {
|
|
|
30
30
|
let size = el.getBoundingClientRect()[dimension];
|
|
31
31
|
el.style.display = originalDisplay;
|
|
32
32
|
const computedStyles = getComputedStyle(el);
|
|
33
|
-
size = dimension === "width" ? size + parseInt(computedStyles.
|
|
33
|
+
size = dimension === "width" ? size + parseInt(computedStyles.marginLeft) + parseInt(computedStyles.marginRight) : size + parseInt(computedStyles.marginTop) + parseInt(computedStyles.marginBottom);
|
|
34
34
|
return size;
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overflowHandler.js","names":[],"sources":["../../../../src/components/page-header/_story-assets/overflowHandler.ts"],"sourcesContent":["/**\n * Copyright IBM Corp. 2025\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n// TODO: delete this file after overflowHandler from carbon/utils gets updated\n\n/**\n * Calculates the size (width or height) of a given HTML element.\n *\n * This function performs an expensive calculation by temporarily changing the\n * display style of the element if it is not currently visible. It then uses\n * `getBoundingClientRect` to retrieve the size of the element.\n *\n * @param el - The HTML element whose size is to be calculated.\n * @param dimension - The dimension to measure ('width' or 'height').\n * @returns The size of the element in pixels. Returns 0 if the element is not provided.\n */\nexport function getSize(\n el: HTMLElement,\n dimension: 'width' | 'height'\n): number {\n if (!el) {\n return 0;\n }\n const originalDisplay = el.style.display;\n if (!el.offsetParent && getComputedStyle(el).display === 'none') {\n el.style.display = 'inline-block';\n }\n let size = el.getBoundingClientRect()[dimension];\n el.style.display = originalDisplay;\n const computedStyles = getComputedStyle(el);\n size =\n dimension === 'width'\n ? size +\n parseInt(computedStyles.paddingLeft) +\n parseInt(computedStyles.paddingRight) +\n parseInt(computedStyles.marginLeft) +\n parseInt(computedStyles.marginRight)\n : size +\n parseInt(computedStyles.paddingTop) +\n parseInt(computedStyles.paddingBottom) +\n parseInt(computedStyles.marginTop) +\n parseInt(computedStyles.marginBottom);\n return size;\n}\n\n/**\n * Options for updating the overflow handler.\n * Determines which items should be visible and which should be hidden\n * based on the container size, item sizes, and other constraints.\n */\nexport interface UpdateOverflowHandlerOptions {\n /** The container element that holds the items. */\n container: HTMLElement;\n /** An array of item elements to be managed for overflow. */\n items: HTMLElement[];\n /** An element that represents the offset, which can be shown or hidden based on overflow. Identified by `data-offset` attribute. */\n offset: HTMLElement;\n /** An array of sizes corresponding to each item in the `items` array. */\n sizes: number[];\n /** An array of sizes corresponding to each item in the fixed items array. */\n fixedSizes: number[];\n /** The size of the offset element. */\n offsetSize: number;\n /** The maximum number of items that can be visible at once. If undefined, all items can be visible. */\n maxVisibleItems?: number;\n /** The dimension to consider for overflow, either 'width' or 'height'. */\n dimension: 'width' | 'height';\n /** A callback function that is called when the visible or hidden items change. */\n onChange: (visibleItems: HTMLElement[], hiddenItems: HTMLElement[]) => void;\n /** An array of previously hidden items to compare against the new hidden items. */\n previousHiddenItems?: HTMLElement[];\n offsetValue?: number;\n}\n\n/**\n * Updates the overflow handler by determining which items should be visible and which should be hidden.\n *\n * @param options - Configuration options for updating the overflow handler.\n * @param options.container - Container for overflowing\n * @param options.items - Child elements within container\n * @param options.offset - Children with data-offset attribute\n * @param options.sizes - Sizes of child elements\n * @param options.fixedSizes - Fixed sizes of child elements with data-fixed attribute\n * @param options.offsetSize - Total offset size\n * @param options.offsetValue - Additional offset\n * @param options.maxVisibleItems - Max visible items\n * @param options.dimension - width | height used to measure overflow\n * @param options.onChange - onChange callback\n * @param options.previousHiddenItems - Array of previously hidden items\n * @returns An array of hidden items after the update.\n */\nexport function updateOverflowHandler({\n container,\n items,\n offset,\n sizes,\n fixedSizes,\n offsetSize,\n maxVisibleItems,\n dimension,\n onChange,\n previousHiddenItems = [],\n offsetValue = 0,\n}: UpdateOverflowHandlerOptions): HTMLElement[] {\n const containerSize =\n dimension === 'width' ? container.clientWidth : container.clientHeight;\n\n let visibleItems: HTMLElement[] = [];\n let hiddenItems: HTMLElement[] = [];\n\n const totalSize = sizes.reduce((sum, size) => sum + size, 0);\n const totalFixedSize = fixedSizes.reduce((sum, size) => sum + size, 0);\n\n if (totalSize + totalFixedSize <= containerSize) {\n visibleItems = maxVisibleItems\n ? items.slice(0, maxVisibleItems)\n : [...items];\n hiddenItems = maxVisibleItems ? items.slice(maxVisibleItems) : [];\n } else {\n const available = containerSize - offsetSize - totalFixedSize - offsetValue;\n let accumulated = 0;\n let breakIndex = items.length;\n\n for (let i = 0; i < items.length; i++) {\n const size = sizes[i];\n if (\n accumulated + size <= available &&\n (!maxVisibleItems || visibleItems.length < maxVisibleItems)\n ) {\n visibleItems.push(items[i]);\n accumulated += size;\n } else {\n breakIndex = i;\n break;\n }\n }\n hiddenItems = items.slice(breakIndex);\n }\n\n if (\n previousHiddenItems.length === hiddenItems.length &&\n previousHiddenItems.every((item, index) => item === hiddenItems[index])\n ) {\n return previousHiddenItems;\n }\n\n visibleItems.forEach((item) => item.removeAttribute('data-hidden'));\n hiddenItems.forEach((item) => item.setAttribute('data-hidden', ''));\n\n if (offset) {\n offset.toggleAttribute('data-hidden', hiddenItems.length === 0);\n }\n onChange(visibleItems, hiddenItems);\n return hiddenItems;\n}\n\n/**\n * Options for initializing an overflow handler.\n */\nexport interface OverflowHandlerOptions {\n /**\n * The container element that holds the items. along with offset item\n */\n container: HTMLElement;\n /**\n * Maximum number of visible items. If provided, only this number of items will be shown.\n */\n maxVisibleItems?: number;\n /**\n * Callback function invoked when the visible and hidden items change.\n * @param visibleItems - The array of items that are currently visible.\n * @param hiddenItems - The array of items that are currently hidden.\n */\n onChange: (visibleItems: HTMLElement[], hiddenItems: HTMLElement[]) => void;\n /**\n * The dimension to consider for overflow calculations. Defaults to 'width'.\n */\n dimension?: 'width' | 'height';\n offsetValue?: number;\n}\n\n/**\n * Represents an instance of an overflow handler.\n */\nexport interface OverflowHandler {\n /**\n * Disconnects the overflow handler, cleaning up any event listeners or resources.\n */\n disconnect: () => void;\n}\n\nexport function createOverflowHandler({\n container,\n maxVisibleItems,\n onChange,\n dimension = 'width',\n offsetValue = 0,\n}: OverflowHandlerOptions): OverflowHandler {\n // Error handling\n if (!(container instanceof HTMLElement)) {\n throw new Error('container must be an HTMLElement');\n }\n if (typeof onChange !== 'function') {\n throw new Error('onChange must be a function');\n }\n if (\n maxVisibleItems !== undefined &&\n (!Number.isInteger(maxVisibleItems) || maxVisibleItems <= 0)\n ) {\n throw new Error('maxVisibleItems must be a positive integer');\n }\n\n const children = Array.from(container.children) as HTMLElement[];\n const offset = children.find((item) =>\n item.hasAttribute('data-offset')\n ) as HTMLElement;\n const fixedItems = children.filter((item) =>\n item.hasAttribute('data-fixed')\n ) as HTMLElement[];\n const items = children.filter(\n (item) => item !== offset && !fixedItems.includes(item)\n );\n\n const fixedSizes = fixedItems.map((item) => getSize(item, dimension));\n const sizes = items.map((item) => getSize(item, dimension));\n const offsetSize = getSize(offset, dimension);\n\n let previousHiddenItems: HTMLElement[] = [];\n\n function update() {\n previousHiddenItems = updateOverflowHandler({\n container,\n items,\n offset,\n sizes,\n fixedSizes,\n offsetSize,\n maxVisibleItems,\n dimension,\n onChange,\n previousHiddenItems,\n offsetValue,\n });\n }\n\n const resizeObserver = new ResizeObserver(() =>\n requestAnimationFrame(update)\n );\n resizeObserver.observe(container);\n\n requestAnimationFrame(update); // Initial update\n\n return {\n disconnect() {\n resizeObserver.disconnect();\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,QACd,IACA,WACQ;AACR,KAAI,CAAC,GACH,QAAO;CAET,MAAM,kBAAkB,GAAG,MAAM;AACjC,KAAI,CAAC,GAAG,gBAAgB,iBAAiB,GAAG,CAAC,YAAY,OACvD,IAAG,MAAM,UAAU;CAErB,IAAI,OAAO,GAAG,uBAAuB,CAAC;AACtC,IAAG,MAAM,UAAU;CACnB,MAAM,iBAAiB,iBAAiB,GAAG;AAC3C,QACE,cAAc,UACV,OACA,SAAS,eAAe,YAAY,GACpC,SAAS,eAAe,aAAa,GACrC,SAAS,eAAe,WAAW,GACnC,SAAS,eAAe,YAAY,GACpC,OACA,SAAS,eAAe,WAAW,GACnC,SAAS,eAAe,cAAc,GACtC,SAAS,eAAe,UAAU,GAClC,SAAS,eAAe,aAAa;AAC3C,QAAO;;;;;;;;;;;;;;;;;;;AAiDT,SAAgB,sBAAsB,EACpC,WACA,OACA,QACA,OACA,YACA,YACA,iBACA,WACA,UACA,sBAAsB,EAAE,EACxB,cAAc,KACgC;CAC9C,MAAM,gBACJ,cAAc,UAAU,UAAU,cAAc,UAAU;CAE5D,IAAI,eAA8B,EAAE;CACpC,IAAI,cAA6B,EAAE;CAEnC,MAAM,YAAY,MAAM,QAAQ,KAAK,SAAS,MAAM,MAAM,EAAE;CAC5D,MAAM,iBAAiB,WAAW,QAAQ,KAAK,SAAS,MAAM,MAAM,EAAE;AAEtE,KAAI,YAAY,kBAAkB,eAAe;AAC/C,iBAAe,kBACX,MAAM,MAAM,GAAG,gBAAgB,GAC/B,CAAC,GAAG,MAAM;AACd,g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Aa,WAAW,KAAK,SAAS,QAAQ,MAAM,UAAU,CAAC;CACrE,MAAM,QAAQ,MAAM,KAAK,SAAS,QAAQ,MAAM,UAAU,CAAC;CAC3D,MAAM,aAAa,QAAQ,QAAQ,UAAU;CAE7C,IAAI,sBAAqC,EAAE;CAE3C,SAAS,SAAS;AAChB,wBAAsB,sBAAsB;GAC1C;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CAAC;;CAGJ,MAAM,iBAAiB,IAAI,qBACzB,sBAAsB,OAAO,CAC9B;AACD,gBAAe,QAAQ,UAAU;AAEjC,uBAAsB,OAAO;AAE7B,QAAO,EACL,aAAa;AACX,iBAAe,YAAY;IAE9B"}
|
|
1
|
+
{"version":3,"file":"overflowHandler.js","names":[],"sources":["../../../../src/components/page-header/_story-assets/overflowHandler.ts"],"sourcesContent":["/**\n * Copyright IBM Corp. 2025\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n// TODO: delete this file after overflowHandler from carbon/utils gets updated\n\n/**\n * Calculates the size (width or height) of a given HTML element.\n *\n * This function performs an expensive calculation by temporarily changing the\n * display style of the element if it is not currently visible. It then uses\n * `getBoundingClientRect` to retrieve the size of the element.\n *\n * @param el - The HTML element whose size is to be calculated.\n * @param dimension - The dimension to measure ('width' or 'height').\n * @returns The size of the element in pixels. Returns 0 if the element is not provided.\n */\nexport function getSize(\n el: HTMLElement,\n dimension: 'width' | 'height'\n): number {\n if (!el) {\n return 0;\n }\n const originalDisplay = el.style.display;\n if (!el.offsetParent && getComputedStyle(el).display === 'none') {\n el.style.display = 'inline-block';\n }\n let size = el.getBoundingClientRect()[dimension];\n el.style.display = originalDisplay;\n // getBoundingClientRect already includes padding, so only add margins\n // (which are outside the bounding box). Adding padding here would double-count it.\n const computedStyles = getComputedStyle(el);\n size =\n dimension === 'width'\n ? size +\n parseInt(computedStyles.marginLeft) +\n parseInt(computedStyles.marginRight)\n : size +\n parseInt(computedStyles.marginTop) +\n parseInt(computedStyles.marginBottom);\n return size;\n}\n\n/**\n * Options for updating the overflow handler.\n * Determines which items should be visible and which should be hidden\n * based on the container size, item sizes, and other constraints.\n */\nexport interface UpdateOverflowHandlerOptions {\n /** The container element that holds the items. */\n container: HTMLElement;\n /** An array of item elements to be managed for overflow. */\n items: HTMLElement[];\n /** An element that represents the offset, which can be shown or hidden based on overflow. Identified by `data-offset` attribute. */\n offset: HTMLElement;\n /** An array of sizes corresponding to each item in the `items` array. */\n sizes: number[];\n /** An array of sizes corresponding to each item in the fixed items array. */\n fixedSizes: number[];\n /** The size of the offset element. */\n offsetSize: number;\n /** The maximum number of items that can be visible at once. If undefined, all items can be visible. */\n maxVisibleItems?: number;\n /** The dimension to consider for overflow, either 'width' or 'height'. */\n dimension: 'width' | 'height';\n /** A callback function that is called when the visible or hidden items change. */\n onChange: (visibleItems: HTMLElement[], hiddenItems: HTMLElement[]) => void;\n /** An array of previously hidden items to compare against the new hidden items. */\n previousHiddenItems?: HTMLElement[];\n offsetValue?: number;\n}\n\n/**\n * Updates the overflow handler by determining which items should be visible and which should be hidden.\n *\n * @param options - Configuration options for updating the overflow handler.\n * @param options.container - Container for overflowing\n * @param options.items - Child elements within container\n * @param options.offset - Children with data-offset attribute\n * @param options.sizes - Sizes of child elements\n * @param options.fixedSizes - Fixed sizes of child elements with data-fixed attribute\n * @param options.offsetSize - Total offset size\n * @param options.offsetValue - Additional offset\n * @param options.maxVisibleItems - Max visible items\n * @param options.dimension - width | height used to measure overflow\n * @param options.onChange - onChange callback\n * @param options.previousHiddenItems - Array of previously hidden items\n * @returns An array of hidden items after the update.\n */\nexport function updateOverflowHandler({\n container,\n items,\n offset,\n sizes,\n fixedSizes,\n offsetSize,\n maxVisibleItems,\n dimension,\n onChange,\n previousHiddenItems = [],\n offsetValue = 0,\n}: UpdateOverflowHandlerOptions): HTMLElement[] {\n const containerSize =\n dimension === 'width' ? container.clientWidth : container.clientHeight;\n\n let visibleItems: HTMLElement[] = [];\n let hiddenItems: HTMLElement[] = [];\n\n const totalSize = sizes.reduce((sum, size) => sum + size, 0);\n const totalFixedSize = fixedSizes.reduce((sum, size) => sum + size, 0);\n\n if (totalSize + totalFixedSize <= containerSize) {\n visibleItems = maxVisibleItems\n ? items.slice(0, maxVisibleItems)\n : [...items];\n hiddenItems = maxVisibleItems ? items.slice(maxVisibleItems) : [];\n } else {\n const available = containerSize - offsetSize - totalFixedSize - offsetValue;\n let accumulated = 0;\n let breakIndex = items.length;\n\n for (let i = 0; i < items.length; i++) {\n const size = sizes[i];\n if (\n accumulated + size <= available &&\n (!maxVisibleItems || visibleItems.length < maxVisibleItems)\n ) {\n visibleItems.push(items[i]);\n accumulated += size;\n } else {\n breakIndex = i;\n break;\n }\n }\n hiddenItems = items.slice(breakIndex);\n }\n\n if (\n previousHiddenItems.length === hiddenItems.length &&\n previousHiddenItems.every((item, index) => item === hiddenItems[index])\n ) {\n return previousHiddenItems;\n }\n\n visibleItems.forEach((item) => item.removeAttribute('data-hidden'));\n hiddenItems.forEach((item) => item.setAttribute('data-hidden', ''));\n\n if (offset) {\n offset.toggleAttribute('data-hidden', hiddenItems.length === 0);\n }\n onChange(visibleItems, hiddenItems);\n return hiddenItems;\n}\n\n/**\n * Options for initializing an overflow handler.\n */\nexport interface OverflowHandlerOptions {\n /**\n * The container element that holds the items. along with offset item\n */\n container: HTMLElement;\n /**\n * Maximum number of visible items. If provided, only this number of items will be shown.\n */\n maxVisibleItems?: number;\n /**\n * Callback function invoked when the visible and hidden items change.\n * @param visibleItems - The array of items that are currently visible.\n * @param hiddenItems - The array of items that are currently hidden.\n */\n onChange: (visibleItems: HTMLElement[], hiddenItems: HTMLElement[]) => void;\n /**\n * The dimension to consider for overflow calculations. Defaults to 'width'.\n */\n dimension?: 'width' | 'height';\n offsetValue?: number;\n}\n\n/**\n * Represents an instance of an overflow handler.\n */\nexport interface OverflowHandler {\n /**\n * Disconnects the overflow handler, cleaning up any event listeners or resources.\n */\n disconnect: () => void;\n}\n\nexport function createOverflowHandler({\n container,\n maxVisibleItems,\n onChange,\n dimension = 'width',\n offsetValue = 0,\n}: OverflowHandlerOptions): OverflowHandler {\n // Error handling\n if (!(container instanceof HTMLElement)) {\n throw new Error('container must be an HTMLElement');\n }\n if (typeof onChange !== 'function') {\n throw new Error('onChange must be a function');\n }\n if (\n maxVisibleItems !== undefined &&\n (!Number.isInteger(maxVisibleItems) || maxVisibleItems <= 0)\n ) {\n throw new Error('maxVisibleItems must be a positive integer');\n }\n\n const children = Array.from(container.children) as HTMLElement[];\n const offset = children.find((item) =>\n item.hasAttribute('data-offset')\n ) as HTMLElement;\n const fixedItems = children.filter((item) =>\n item.hasAttribute('data-fixed')\n ) as HTMLElement[];\n const items = children.filter(\n (item) => item !== offset && !fixedItems.includes(item)\n );\n\n const fixedSizes = fixedItems.map((item) => getSize(item, dimension));\n const sizes = items.map((item) => getSize(item, dimension));\n const offsetSize = getSize(offset, dimension);\n\n let previousHiddenItems: HTMLElement[] = [];\n\n function update() {\n previousHiddenItems = updateOverflowHandler({\n container,\n items,\n offset,\n sizes,\n fixedSizes,\n offsetSize,\n maxVisibleItems,\n dimension,\n onChange,\n previousHiddenItems,\n offsetValue,\n });\n }\n\n const resizeObserver = new ResizeObserver(() =>\n requestAnimationFrame(update)\n );\n resizeObserver.observe(container);\n\n requestAnimationFrame(update); // Initial update\n\n return {\n disconnect() {\n resizeObserver.disconnect();\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,QACd,IACA,WACQ;AACR,KAAI,CAAC,GACH,QAAO;CAET,MAAM,kBAAkB,GAAG,MAAM;AACjC,KAAI,CAAC,GAAG,gBAAgB,iBAAiB,GAAG,CAAC,YAAY,OACvD,IAAG,MAAM,UAAU;CAErB,IAAI,OAAO,GAAG,uBAAuB,CAAC;AACtC,IAAG,MAAM,UAAU;CAGnB,MAAM,iBAAiB,iBAAiB,GAAG;AAC3C,QACE,cAAc,UACV,OACA,SAA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Ac,YAAY;AACnC,QAAO;;AAsCT,SAAgB,sBAAsB,EACpC,WACA,iBACA,UACA,YAAY,SACZ,cAAc,KAC4B;AAE1C,KAAI,EAAE,qBAAqB,aACzB,OAAM,IAAI,MAAM,mCAAmC;AAErD,KAAI,OAAO,aAAa,WACtB,OAAM,IAAI,MAAM,8BAA8B;AAEhD,KACE,oBAAoB,KAAA,MACnB,CAAC,OAAO,UAAU,gBAAgB,IAAI,mBAAmB,GAE1D,OAAM,IAAI,MAAM,6CAA6C;CAG/D,MAAM,WAAW,MAAM,KAAK,UAAU,SAAS;CAC/C,MAAM,SAAS,SAAS,MAAM,SAC5B,KAAK,aAAa,cAAc,CACjC;CACD,MAAM,aAAa,SAAS,QAAQ,SAClC,KAAK,aAAa,aAAa,CAChC;CACD,MAAM,QAAQ,SAAS,QACpB,SAAS,SAAS,UAAU,CAAC,WAAW,SAAS,KAAK,CACxD;CAED,MAAM,aAAa,WAAW,KAAK,SAAS,QAAQ,MAAM,UAAU,CAAC;CACrE,MAAM,QAAQ,MAAM,KAAK,SAAS,QAAQ,MAAM,UAAU,CAAC;CAC3D,MAAM,aAAa,QAAQ,QAAQ,UAAU;CAE7C,IAAI,sBAAqC,EAAE;CAE3C,SAAS,SAAS;AAChB,wBAAsB,sBAAsB;GAC1C;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CAAC;;CAGJ,MAAM,iBAAiB,IAAI,qBACzB,sBAAsB,OAAO,CAC9B;AACD,gBAAe,QAAQ,UAAU;AAEjC,uBAAsB,OAAO;AAE7B,QAAO,EACL,aAAa;AACX,iBAAe,YAAY;IAE9B"}
|
|
@@ -12,6 +12,9 @@ export declare const pageHeaderContext: import("@lit/context").Context<{
|
|
|
12
12
|
fullyCollapsed: boolean;
|
|
13
13
|
root: null;
|
|
14
14
|
titleClipped: boolean;
|
|
15
|
+
contentActionsClipped: boolean;
|
|
15
16
|
disableStickyTabBar: boolean;
|
|
17
|
+
fullWidthGrid: boolean;
|
|
18
|
+
narrowGrid: boolean;
|
|
16
19
|
}, unknown>;
|
|
17
20
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/components/page-header/context.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,eAAO,MAAM,iBAAiB
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/components/page-header/context.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,eAAO,MAAM,iBAAiB;;;;;;;;;;WAU5B,CAAC"}
|
|
@@ -21,7 +21,10 @@ const pageHeaderContext = createContext({
|
|
|
21
21
|
fullyCollapsed: false,
|
|
22
22
|
root: null,
|
|
23
23
|
titleClipped: false,
|
|
24
|
-
|
|
24
|
+
contentActionsClipped: false,
|
|
25
|
+
disableStickyTabBar: false,
|
|
26
|
+
fullWidthGrid: false,
|
|
27
|
+
narrowGrid: false
|
|
25
28
|
});
|
|
26
29
|
//#endregion
|
|
27
30
|
export { pageHeaderContext };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","names":[],"sources":["../../../src/components/page-header/context.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2025, 2025\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { createContext } from '@lit/context';\n\nexport const pageHeaderContext = createContext({\n headerOffset: 0,\n breadcrumbOffset: 0,\n fullyCollapsed: false,\n root: null,\n titleClipped: false,\n disableStickyTabBar: false,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;AAWA,MAAa,oBAAoB,cAAc;CAC7C,cAAc;CACd,kBAAkB;CAClB,gBAAgB;CAChB,MAAM;CACN,cAAc;CACd,qBAAqB;
|
|
1
|
+
{"version":3,"file":"context.js","names":[],"sources":["../../../src/components/page-header/context.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2025, 2025\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { createContext } from '@lit/context';\n\nexport const pageHeaderContext = createContext({\n headerOffset: 0,\n breadcrumbOffset: 0,\n fullyCollapsed: false,\n root: null,\n titleClipped: false,\n contentActionsClipped: false,\n disableStickyTabBar: false,\n fullWidthGrid: false,\n narrowGrid: false,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;AAWA,MAAa,oBAAoB,cAAc;CAC7C,cAAc;CACd,kBAAkB;CAClB,gBAAgB;CAChB,MAAM;CACN,cAAc;CACd,uBAAuB;CACvB,qBAAqB;CACrB,eAAe;CACf,YAAY;CACb,CAAC"}
|
|
@@ -20,6 +20,10 @@ export default class CDSPageHeaderActionsSet extends LitElement {
|
|
|
20
20
|
* The list of page action labels for overflow menu.
|
|
21
21
|
*/
|
|
22
22
|
actionsData: PageAction[];
|
|
23
|
+
/**
|
|
24
|
+
* Aria label for the toolbar container (`role="toolbar"`).
|
|
25
|
+
*/
|
|
26
|
+
toolbarAriaLabel: string;
|
|
23
27
|
/**
|
|
24
28
|
* Aria label for the overflow menu button.
|
|
25
29
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-header-actions-set.d.ts","sourceRoot":"","sources":["../../../../src/components/page-header/page-header-actions-set/page-header-actions-set.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAQ,MAAM,KAAK,CAAC;AAIvC,OAAO,6DAA6D,CAAC;AAQrE,UAAU,UAAU;IAClB,KAAK,EAAE,MAAM,CAAC;CACf;AAGD,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,UAAU;IAC7D;;OAEG;IAEH,WAAW,EAAE,UAAU,EAAE,CAAM;IAE/B;;OAEG;IAEH,WAAW,EAAE,UAAU,EAAE,CAAM;IAE/B;;OAEG;IAEH,iBAAiB,SAAuB;IAExC;;OAEG;IAEH,OAAO,CAAC,SAAS,CAAe;IAEhC;;OAEG;IAEH,OAAO,CAAC,cAAc,CAAe;IAErC,OAAO,CAAC,cAAc,CAA6B;IACnD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,aAAa,CAAqB;IAC1C,OAAO,CAAC,kBAAkB,CAAK;IAE/B,iBAAiB,IAAI,IAAI;IAKzB,YAAY;IAcZ,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IAa/C,OAAO,CAAC,sBAAsB;
|
|
1
|
+
{"version":3,"file":"page-header-actions-set.d.ts","sourceRoot":"","sources":["../../../../src/components/page-header/page-header-actions-set/page-header-actions-set.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAQ,MAAM,KAAK,CAAC;AAIvC,OAAO,6DAA6D,CAAC;AAQrE,UAAU,UAAU;IAClB,KAAK,EAAE,MAAM,CAAC;CACf;AAGD,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,UAAU;IAC7D;;OAEG;IAEH,WAAW,EAAE,UAAU,EAAE,CAAM;IAE/B;;OAEG;IAEH,WAAW,EAAE,UAAU,EAAE,CAAM;IAE/B;;OAEG;IAEH,gBAAgB,SAAkB;IAElC;;OAEG;IAEH,iBAAiB,SAAuB;IAExC;;OAEG;IAEH,OAAO,CAAC,SAAS,CAAe;IAEhC;;OAEG;IAEH,OAAO,CAAC,cAAc,CAAe;IAErC,OAAO,CAAC,cAAc,CAA6B;IACnD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,aAAa,CAAqB;IAC1C,OAAO,CAAC,kBAAkB,CAAK;IAE/B,iBAAiB,IAAI,IAAI;IAKzB,YAAY;IAcZ,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IAa/C,OAAO,CAAC,sBAAsB;IA6G9B,oBAAoB;IAQpB,OAAO,CAAC,uBAAuB;IAY/B,MAAM;IA4CN,MAAM,CAAC,MAAM,MAAU;CACxB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,6BAA6B,EAAE,uBAAuB,CAAC;KACxD;CACF"}
|
|
@@ -30,6 +30,7 @@ let CDSPageHeaderActionsSet = class CDSPageHeaderActionsSet extends LitElement {
|
|
|
30
30
|
super(..._args);
|
|
31
31
|
this.hiddenItems = [];
|
|
32
32
|
this.actionsData = [];
|
|
33
|
+
this.toolbarAriaLabel = "Page actions";
|
|
33
34
|
this.overflowAriaLabel = "More page actions";
|
|
34
35
|
this.isSetup = false;
|
|
35
36
|
this.lastContainerWidth = 0;
|
|
@@ -60,18 +61,17 @@ let CDSPageHeaderActionsSet = class CDSPageHeaderActionsSet extends LitElement {
|
|
|
60
61
|
const checkOverflow = () => {
|
|
61
62
|
const slottedElements = slot?.assignedElements();
|
|
62
63
|
if (!slottedElements || slottedElements.length === 0) return;
|
|
63
|
-
const containerWidth = this.offsetWidth
|
|
64
|
+
const containerWidth = this.offsetWidth;
|
|
64
65
|
const overflowMenuWidth = 48;
|
|
65
66
|
if (containerWidth === 0) return;
|
|
66
67
|
if (Math.abs(containerWidth - this.lastContainerWidth) < 5) return;
|
|
67
68
|
this.lastContainerWidth = containerWidth;
|
|
69
|
+
slottedElements.forEach((el) => el.removeAttribute("data-hidden"));
|
|
68
70
|
let totalWidth = 0;
|
|
69
71
|
for (let i = 0; i < slottedElements.length; i++) totalWidth += slottedElements[i].offsetWidth;
|
|
70
72
|
if (totalWidth <= containerWidth) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
});
|
|
74
|
-
this.hiddenItems = [];
|
|
73
|
+
const newHiddenItems = [];
|
|
74
|
+
if (this.hiddenItems.length !== 0) this.hiddenItems = newHiddenItems;
|
|
75
75
|
return;
|
|
76
76
|
}
|
|
77
77
|
totalWidth = 0;
|
|
@@ -87,7 +87,8 @@ let CDSPageHeaderActionsSet = class CDSPageHeaderActionsSet extends LitElement {
|
|
|
87
87
|
if (index >= visibleCount) el.setAttribute("data-hidden", "");
|
|
88
88
|
else el.removeAttribute("data-hidden");
|
|
89
89
|
});
|
|
90
|
-
|
|
90
|
+
const newHiddenItems = this.actionsData?.slice(visibleCount) || [];
|
|
91
|
+
if (newHiddenItems.length !== this.hiddenItems.length || newHiddenItems.some((item, i) => item !== this.hiddenItems[i])) this.hiddenItems = newHiddenItems;
|
|
91
92
|
};
|
|
92
93
|
checkOverflow();
|
|
93
94
|
this.resizeObserver = new ResizeObserver(() => {
|
|
@@ -97,7 +98,6 @@ let CDSPageHeaderActionsSet = class CDSPageHeaderActionsSet extends LitElement {
|
|
|
97
98
|
}, 100);
|
|
98
99
|
});
|
|
99
100
|
this.resizeObserver.observe(this);
|
|
100
|
-
this.resizeObserver.observe(this.itemsContainer);
|
|
101
101
|
}
|
|
102
102
|
disconnectedCallback() {
|
|
103
103
|
super.disconnectedCallback();
|
|
@@ -110,12 +110,16 @@ let CDSPageHeaderActionsSet = class CDSPageHeaderActionsSet extends LitElement {
|
|
|
110
110
|
}
|
|
111
111
|
render() {
|
|
112
112
|
return html`
|
|
113
|
-
<
|
|
114
|
-
|
|
113
|
+
<div
|
|
114
|
+
class="${blockClass}"
|
|
115
|
+
role="toolbar"
|
|
116
|
+
aria-label="${this.toolbarAriaLabel}"
|
|
117
|
+
>
|
|
118
|
+
<div class="${blockClass}__items">
|
|
115
119
|
<slot></slot>
|
|
116
|
-
</
|
|
120
|
+
</div>
|
|
117
121
|
|
|
118
|
-
<
|
|
122
|
+
<div data-offset ?data-hidden=${this.hiddenItems.length === 0}>
|
|
119
123
|
<cds-overflow-menu
|
|
120
124
|
size="md"
|
|
121
125
|
close-on-activation
|
|
@@ -140,8 +144,8 @@ let CDSPageHeaderActionsSet = class CDSPageHeaderActionsSet extends LitElement {
|
|
|
140
144
|
`)}
|
|
141
145
|
</cds-overflow-menu-body>
|
|
142
146
|
</cds-overflow-menu>
|
|
143
|
-
</
|
|
144
|
-
</
|
|
147
|
+
</div>
|
|
148
|
+
</div>
|
|
145
149
|
`;
|
|
146
150
|
}
|
|
147
151
|
static {
|
|
@@ -154,6 +158,11 @@ __decorate([property({
|
|
|
154
158
|
attribute: "actions-data",
|
|
155
159
|
reflect: true
|
|
156
160
|
})], CDSPageHeaderActionsSet.prototype, "actionsData", void 0);
|
|
161
|
+
__decorate([property({
|
|
162
|
+
type: String,
|
|
163
|
+
attribute: "toolbar-aria-label",
|
|
164
|
+
reflect: true
|
|
165
|
+
})], CDSPageHeaderActionsSet.prototype, "toolbarAriaLabel", void 0);
|
|
157
166
|
__decorate([property({
|
|
158
167
|
type: String,
|
|
159
168
|
attribute: "overflow-aria-label",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-header-actions-set.js","names":["styles","customElement"],"sources":["../../../../src/components/page-header/page-header-actions-set/page-header-actions-set.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2025, 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { LitElement, html } from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { carbonElement as customElement } from '@carbon/web-components/es/globals/decorators/carbon-element.js';\nimport { repeat } from 'lit/directives/repeat.js';\nimport '@carbon/web-components/es/components/overflow-menu/index.js';\nimport OverflowMenuVertical16 from '@carbon/icons/es/overflow-menu--vertical/16.js';\nimport { iconLoader } from '@carbon/web-components/es/globals/internal/icon-loader.js';\nimport styles from './page-header-actions-set.scss?lit';\nimport { prefix } from '../../../globals/settings';\n\nconst blockClass = `${prefix}--page-header-actions-set`;\n\ninterface PageAction {\n label: string;\n}\n\n@customElement(`${prefix}-page-header-actions-set`)\nexport default class CDSPageHeaderActionsSet extends LitElement {\n /**\n * Hidden actions that will be rendered in the overflow menu.\n */\n @state()\n hiddenItems: PageAction[] = [];\n\n /**\n * The list of page action labels for overflow menu.\n */\n @property({ type: Array, attribute: 'actions-data', reflect: true })\n actionsData: PageAction[] = [];\n\n /**\n * Aria label for the overflow menu button.\n */\n @property({ type: String, attribute: 'overflow-aria-label', reflect: true })\n overflowAriaLabel = 'More page actions';\n\n /**\n * Container holding all action buttons and the overflow menu.\n */\n @query(`.${blockClass}`)\n private container!: HTMLElement;\n\n /**\n * Items wrapper containing the slotted elements.\n */\n @query(`.${blockClass}__items`)\n private itemsContainer!: HTMLElement;\n\n private resizeObserver: ResizeObserver | undefined;\n private isSetup = false;\n private resizeTimeout: number | undefined;\n private lastContainerWidth = 0;\n\n connectedCallback(): void {\n super.connectedCallback();\n this.style.visibility = 'hidden';\n }\n\n firstUpdated() {\n if (!this.container) {\n return;\n }\n\n this.updateComplete.then(() => {\n requestAnimationFrame(() => {\n this.setupOverflowDetection();\n this.isSetup = true;\n this.style.visibility = 'visible';\n });\n });\n }\n\n updated(changedProperties: Map<string, unknown>) {\n // Only re-setup if actionsData changed and we've already done initial setup\n if (\n this.isSetup &&\n changedProperties.has('actionsData') &&\n !changedProperties.has('hiddenItems')\n ) {\n this.updateComplete.then(() => {\n requestAnimationFrame(() => this.setupOverflowDetection());\n });\n }\n }\n\n private setupOverflowDetection() {\n if (!this.itemsContainer) {\n return;\n }\n\n // Disconnect existing observer if any\n this.resizeObserver?.disconnect();\n\n // Get slotted elements\n const slot = this.shadowRoot?.querySelector('slot') as HTMLSlotElement;\n\n const checkOverflow = () => {\n const slottedElements = slot?.assignedElements() as HTMLElement[];\n\n if (!slottedElements || slottedElements.length === 0) {\n return;\n }\n\n // Use the host element's width as it reflects the actual available space\n const containerWidth =\n this.offsetWidth || this.itemsContainer.clientWidth;\n const overflowMenuWidth = 48; // Approximate width of overflow menu button\n\n // If container has no width yet, skip check\n if (containerWidth === 0) {\n return;\n }\n\n // Prevent resize loop - only recalculate if width changed significantly (>5px)\n if (Math.abs(containerWidth - this.lastContainerWidth) < 5) {\n return;\n }\n this.lastContainerWidth = containerWidth;\n\n // First, check if all items fit without overflow menu\n let totalWidth = 0;\n for (let i = 0; i < slottedElements.length; i++) {\n totalWidth += slottedElements[i].offsetWidth;\n }\n\n // If all items fit, show all and hide overflow menu\n if (totalWidth <= containerWidth) {\n slottedElements.forEach((el) => {\n el.removeAttribute('data-hidden');\n });\n this.hiddenItems = [];\n return;\n }\n\n // Items don't fit, calculate how many can fit with overflow menu\n totalWidth = 0;\n let visibleCount = 0;\n\n for (let i = 0; i < slottedElements.length; i++) {\n const itemWidth = slottedElements[i].offsetWidth;\n\n // Check if this item plus overflow menu would fit\n if (totalWidth + itemWidth + overflowMenuWidth <= containerWidth) {\n totalWidth += itemWidth;\n visibleCount = i + 1;\n } else {\n break;\n }\n }\n\n // Update visibility\n slottedElements.forEach((el, index) => {\n if (index >= visibleCount) {\n el.setAttribute('data-hidden', '');\n } else {\n el.removeAttribute('data-hidden');\n }\n });\n\n // Update hidden items for overflow menu\n this.hiddenItems = this.actionsData?.slice(visibleCount) || [];\n };\n\n // Initial check\n checkOverflow();\n\n // Observe both the host element and items container for size changes with debouncing\n this.resizeObserver = new ResizeObserver(() => {\n // Clear existing timeout\n if (this.resizeTimeout) {\n clearTimeout(this.resizeTimeout);\n }\n\n // Debounce the check to prevent rapid recalculations\n this.resizeTimeout = window.setTimeout(() => {\n checkOverflow();\n }, 100);\n });\n\n this.resizeObserver.observe(this);\n this.resizeObserver.observe(this.itemsContainer);\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.resizeObserver?.disconnect();\n if (this.resizeTimeout) {\n clearTimeout(this.resizeTimeout);\n }\n }\n\n private handleOverflowItemClick(index: number) {\n // Get the slot and find the corresponding slotted element\n const slot = this.shadowRoot?.querySelector('slot') as HTMLSlotElement;\n const slottedElements = slot?.assignedElements() as HTMLElement[];\n const hiddenIndex =\n this.actionsData.length - this.hiddenItems.length + index;\n const button = slottedElements[hiddenIndex];\n if (button) {\n button.click();\n }\n }\n\n render() {\n return html`\n <ul class=\"${blockClass}\">\n <li class=\"${blockClass}__items\">\n <slot></slot>\n </li>\n\n <li data-offset ?data-hidden=${this.hiddenItems.length === 0}>\n <cds-overflow-menu\n size=\"md\"\n close-on-activation\n enter-delay-ms=\"0\"\n leave-delay-ms=\"0\"\n align=\"left\"\n data-floating-menu-container\n aria-label=\"${this.overflowAriaLabel}\"\n >\n ${iconLoader(OverflowMenuVertical16, {\n class: `${blockClass}__overflow-svg`,\n slot: 'icon',\n })}\n <span slot=\"tooltip-content\">More actions</span>\n <cds-overflow-menu-body flipped>\n ${repeat(\n this.hiddenItems ?? [],\n (_item, index) => index,\n (item, index) => html`\n <cds-overflow-menu-item\n @click=\"${() => this.handleOverflowItemClick(index)}\"\n >\n ${item.label}\n </cds-overflow-menu-item>\n `\n )}\n </cds-overflow-menu-body>\n </cds-overflow-menu>\n </li>\n </ul>\n `;\n }\n static styles = styles;\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'c4p-page-header-actions-set': CDSPageHeaderActionsSet;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,MAAM,aAAa;AAOJ,IAAA,0BAAA,MAAM,gCAAgC,WAAW;;;qBAKlC,EAAE;qBAMF,EAAE;2BAMV;iBAeF;4BAEW;;CAE7B,oBAA0B;AACxB,QAAM,mBAAmB;AACzB,OAAK,MAAM,aAAa;;CAG1B,eAAe;AACb,MAAI,CAAC,KAAK,UACR;AAGF,OAAK,eAAe,WAAW;AAC7B,+BAA4B;AAC1B,SAAK,wBAAwB;AAC7B,SAAK,UAAU;AACf,SAAK,MAAM,aAAa;KACxB;IACF;;CAGJ,QAAQ,mBAAyC;AAE/C,MACE,KAAK,WACL,kBAAkB,IAAI,cAAc,IACpC,CAAC,kBAAkB,IAAI,cAAc,CAErC,MAAK,eAAe,WAAW;AAC7B,+BAA4B,KAAK,wBAAwB,CAAC;IAC1D;;CAIN,yBAAiC;AAC/B,MAAI,CAAC,KAAK,eACR;AAIF,OAAK,gBAAgB,YAAY;EAGjC,MAAM,OAAO,KAAK,YAAY,cAAc,OAAO;EAEnD,MAAM,sBAAsB;GAC1B,MAAM,kBAAkB,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AkB,EAE9C,KAAK,YAAY,SAAS,KAAK,YAAY,SAAS;AAEtD,MAAI,OACF,QAAO,OAAO;;CAIlB,SAAS;AACP,SAAO,IAAI;mBACI,WAAW;qBACT,WAAW;;;;uCAIO,KAAK,YAAY,WAAW,EAAE;;;;;;;;0BAQ3C,KAAK,kBAAkB;;cAEnC,WAAW,wBAAwB;GACnC,OAAO,GAAG,WAAW;GACrB,MAAM;GACP,CAAC,CAAC;;;gBAGC,OACA,KAAK,eAAe,EAAE,GACrB,OAAO,UAAU,QACjB,MAAM,UAAU,IAAI;;oCAED,KAAK,wBAAwB,MAAM,CAAC;;sBAElD,KAAK,MAAM;;kBAGlB,CAAC;;;;;;;;gBAOEA;;;YA9Nf,OAAO,CAAA,EAAA,wBAAA,WAAA,eAAA,KAAA,EAAA;YAMP,SAAS;CAAE,MAAM;CAAO,WAAW;CAAgB,SAAS;CAAM,CAAC,CAAA,EAAA,wBAAA,WAAA,eAAA,KAAA,EAAA;YAMnE,SAAS;CAAE,MAAM;CAAQ,WAAW;CAAuB,SAAS;CAAM,CAAC,CAAA,EAAA,wBAAA,WAAA,qBAAA,KAAA,EAAA;YAM3E,MAAM,IAAI,aAAa,CAAA,EAAA,wBAAA,WAAA,aAAA,KAAA,EAAA;YAMvB,MAAM,IAAI,WAAW,SAAS,CAAA,EAAA,wBAAA,WAAA,kBAAA,KAAA,EAAA;sCA7BhCC,cAAc,8BAAoC,CAAA,EAAA,wBAAA"}
|
|
1
|
+
{"version":3,"file":"page-header-actions-set.js","names":["styles","customElement"],"sources":["../../../../src/components/page-header/page-header-actions-set/page-header-actions-set.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2025, 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { LitElement, html } from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { carbonElement as customElement } from '@carbon/web-components/es/globals/decorators/carbon-element.js';\nimport { repeat } from 'lit/directives/repeat.js';\nimport '@carbon/web-components/es/components/overflow-menu/index.js';\nimport OverflowMenuVertical16 from '@carbon/icons/es/overflow-menu--vertical/16.js';\nimport { iconLoader } from '@carbon/web-components/es/globals/internal/icon-loader.js';\nimport styles from './page-header-actions-set.scss?lit';\nimport { prefix } from '../../../globals/settings';\n\nconst blockClass = `${prefix}--page-header-actions-set`;\n\ninterface PageAction {\n label: string;\n}\n\n@customElement(`${prefix}-page-header-actions-set`)\nexport default class CDSPageHeaderActionsSet extends LitElement {\n /**\n * Hidden actions that will be rendered in the overflow menu.\n */\n @state()\n hiddenItems: PageAction[] = [];\n\n /**\n * The list of page action labels for overflow menu.\n */\n @property({ type: Array, attribute: 'actions-data', reflect: true })\n actionsData: PageAction[] = [];\n\n /**\n * Aria label for the toolbar container (`role=\"toolbar\"`).\n */\n @property({ type: String, attribute: 'toolbar-aria-label', reflect: true })\n toolbarAriaLabel = 'Page actions';\n\n /**\n * Aria label for the overflow menu button.\n */\n @property({ type: String, attribute: 'overflow-aria-label', reflect: true })\n overflowAriaLabel = 'More page actions';\n\n /**\n * Container holding all action buttons and the overflow menu.\n */\n @query(`.${blockClass}`)\n private container!: HTMLElement;\n\n /**\n * Items wrapper containing the slotted elements.\n */\n @query(`.${blockClass}__items`)\n private itemsContainer!: HTMLElement;\n\n private resizeObserver: ResizeObserver | undefined;\n private isSetup = false;\n private resizeTimeout: number | undefined;\n private lastContainerWidth = 0;\n\n connectedCallback(): void {\n super.connectedCallback();\n this.style.visibility = 'hidden';\n }\n\n firstUpdated() {\n if (!this.container) {\n return;\n }\n\n this.updateComplete.then(() => {\n requestAnimationFrame(() => {\n this.setupOverflowDetection();\n this.isSetup = true;\n this.style.visibility = 'visible';\n });\n });\n }\n\n updated(changedProperties: Map<string, unknown>) {\n // Only re-setup if actionsData changed and we've already done initial setup\n if (\n this.isSetup &&\n changedProperties.has('actionsData') &&\n !changedProperties.has('hiddenItems')\n ) {\n this.updateComplete.then(() => {\n requestAnimationFrame(() => this.setupOverflowDetection());\n });\n }\n }\n\n private setupOverflowDetection() {\n if (!this.itemsContainer) {\n return;\n }\n\n // Disconnect existing observer if any\n this.resizeObserver?.disconnect();\n\n // Get slotted elements\n const slot = this.shadowRoot?.querySelector('slot') as HTMLSlotElement;\n\n const checkOverflow = () => {\n const slottedElements = slot?.assignedElements() as HTMLElement[];\n\n if (!slottedElements || slottedElements.length === 0) {\n return;\n }\n\n // Use the host element's width as it reflects the actual available space\n const containerWidth = this.offsetWidth;\n const overflowMenuWidth = 48; // Approximate width of overflow menu button\n\n // If container has no width yet, skip check\n if (containerWidth === 0) {\n return;\n }\n\n // Prevent resize loop - only recalculate if width changed significantly (>5px)\n if (Math.abs(containerWidth - this.lastContainerWidth) < 5) {\n return;\n }\n this.lastContainerWidth = containerWidth;\n\n // First, make all items temporarily visible to measure their natural widths\n slottedElements.forEach((el) => el.removeAttribute('data-hidden'));\n\n // First, check if all items fit without overflow menu\n let totalWidth = 0;\n for (let i = 0; i < slottedElements.length; i++) {\n totalWidth += slottedElements[i].offsetWidth;\n }\n\n // If all items fit, show all and hide overflow menu\n if (totalWidth <= containerWidth) {\n const newHiddenItems: PageAction[] = [];\n if (this.hiddenItems.length !== 0) {\n this.hiddenItems = newHiddenItems;\n }\n return;\n }\n\n // Items don't fit, calculate how many can fit with overflow menu\n totalWidth = 0;\n let visibleCount = 0;\n\n for (let i = 0; i < slottedElements.length; i++) {\n const itemWidth = slottedElements[i].offsetWidth;\n\n // Check if this item plus overflow menu would fit\n if (totalWidth + itemWidth + overflowMenuWidth <= containerWidth) {\n totalWidth += itemWidth;\n visibleCount = i + 1;\n } else {\n break;\n }\n }\n\n // Update visibility\n slottedElements.forEach((el, index) => {\n if (index >= visibleCount) {\n el.setAttribute('data-hidden', '');\n } else {\n el.removeAttribute('data-hidden');\n }\n });\n\n // Update hidden items only if the set actually changed to avoid a\n // state-change → re-render → ResizeObserver → loop cycle.\n const newHiddenItems = this.actionsData?.slice(visibleCount) || [];\n if (\n newHiddenItems.length !== this.hiddenItems.length ||\n newHiddenItems.some((item, i) => item !== this.hiddenItems[i])\n ) {\n this.hiddenItems = newHiddenItems;\n }\n };\n\n // Initial check\n checkOverflow();\n\n // Observe only the host element for external size changes.\n // Do NOT observe itemsContainer — its size changes are caused by our own\n // state updates (overflow menu appearing/disappearing) which would create\n // a ResizeObserver → setState → re-render → ResizeObserver loop.\n this.resizeObserver = new ResizeObserver(() => {\n // Clear existing timeout\n if (this.resizeTimeout) {\n clearTimeout(this.resizeTimeout);\n }\n\n // Debounce the check to prevent rapid recalculations\n this.resizeTimeout = window.setTimeout(() => {\n checkOverflow();\n }, 100);\n });\n\n this.resizeObserver.observe(this);\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.resizeObserver?.disconnect();\n if (this.resizeTimeout) {\n clearTimeout(this.resizeTimeout);\n }\n }\n\n private handleOverflowItemClick(index: number) {\n // Get the slot and find the corresponding slotted element\n const slot = this.shadowRoot?.querySelector('slot') as HTMLSlotElement;\n const slottedElements = slot?.assignedElements() as HTMLElement[];\n const hiddenIndex =\n this.actionsData.length - this.hiddenItems.length + index;\n const button = slottedElements[hiddenIndex];\n if (button) {\n button.click();\n }\n }\n\n render() {\n return html`\n <div\n class=\"${blockClass}\"\n role=\"toolbar\"\n aria-label=\"${this.toolbarAriaLabel}\"\n >\n <div class=\"${blockClass}__items\">\n <slot></slot>\n </div>\n\n <div data-offset ?data-hidden=${this.hiddenItems.length === 0}>\n <cds-overflow-menu\n size=\"md\"\n close-on-activation\n enter-delay-ms=\"0\"\n leave-delay-ms=\"0\"\n align=\"left\"\n data-floating-menu-container\n aria-label=\"${this.overflowAriaLabel}\"\n >\n ${iconLoader(OverflowMenuVertical16, {\n class: `${blockClass}__overflow-svg`,\n slot: 'icon',\n })}\n <span slot=\"tooltip-content\">More actions</span>\n <cds-overflow-menu-body flipped>\n ${repeat(\n this.hiddenItems ?? [],\n (_item, index) => index,\n (item, index) => html`\n <cds-overflow-menu-item\n @click=\"${() => this.handleOverflowItemClick(index)}\"\n >\n ${item.label}\n </cds-overflow-menu-item>\n `\n )}\n </cds-overflow-menu-body>\n </cds-overflow-menu>\n </div>\n </div>\n `;\n }\n static styles = styles;\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'c4p-page-header-actions-set': CDSPageHeaderActionsSet;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,MAAM,aAAa;AAOJ,IAAA,0BAAA,MAAM,gCAAgC,WAAW;;;qBAKlC,EAAE;qBAMF,EAAE;0BAMX;2BAMC;iBAeF;4BAEW;;CAE7B,oBAA0B;AACxB,QAAM,mBAAmB;AACzB,OAAK,MAAM,aAAa;;CAG1B,eAAe;AACb,MAAI,CAAC,KAAK,UACR;AAGF,OAAK,eAAe,WAAW;AAC7B,+BAA4B;AAC1B,SAAK,wBAAwB;AAC7B,SAAK,UAAU;AACf,SAAK,MAAM,aAAa;KACxB;IACF;;CAGJ,QAAQ,mBAAyC;AAE/C,MACE,KAAK,WACL,kBAAkB,IAAI,cAAc,IACpC,CAAC,kBAAkB,IAAI,cAAc,CAErC,MAAK,eAAe,WAAW;AAC7B,+BAA4B,KAAK,wBAAwB,CAAC;IAC1D;;CAIN,yBAAiC;AAC/B,MAAI,CAAC,KAAK,eACR;AAIF,OAAK,gBAAgB,YAAY;EAGjC,MAAM,OAAO,KAAK,YAAY,cAAc,OAAO;EAEnD,MAAM,sBAAsB;GAC1B,MAAM,kBAAkB,MAAM,kBAAkB;AAEhD,OAAI,CAAC,mBAAmB,gBAAgB,WAAW,EACjD;GAIF,MAAM,iBAAiB,KAAK;GAC5B,MAAM,oBAAoB;AAG1B,OAAI,mBAAmB,EACrB;AAIF,OAAI,KAAK,IAAI,iBAAiB,KAAK,mBAAmB,GAAG,EACvD;AAEF,QAAK,qBAAqB;AAG1B,mBAAgB,SAAS,OAAO,GAAG,gBAAgB,cAAc,CAAC;GAGlE,IAAI,aAAa;AACjB,QAAK,IAAI,IAAI,GAAG,IA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K,kBAAkB;;cAEnC,WAAW,wBAAwB;GACnC,OAAO,GAAG,WAAW;GACrB,MAAM;GACP,CAAC,CAAC;;;gBAGC,OACA,KAAK,eAAe,EAAE,GACrB,OAAO,UAAU,QACjB,MAAM,UAAU,IAAI;;oCAED,KAAK,wBAAwB,MAAM,CAAC;;sBAElD,KAAK,MAAM;;kBAGlB,CAAC;;;;;;;;gBAOEA;;;YAnPf,OAAO,CAAA,EAAA,wBAAA,WAAA,eAAA,KAAA,EAAA;YAMP,SAAS;CAAE,MAAM;CAAO,WAAW;CAAgB,SAAS;CAAM,CAAC,CAAA,EAAA,wBAAA,WAAA,eAAA,KAAA,EAAA;YAMnE,SAAS;CAAE,MAAM;CAAQ,WAAW;CAAsB,SAAS;CAAM,CAAC,CAAA,EAAA,wBAAA,WAAA,oBAAA,KAAA,EAAA;YAM1E,SAAS;CAAE,MAAM;CAAQ,WAAW;CAAuB,SAAS;CAAM,CAAC,CAAA,EAAA,wBAAA,WAAA,qBAAA,KAAA,EAAA;YAM3E,MAAM,IAAI,aAAa,CAAA,EAAA,wBAAA,WAAA,aAAA,KAAA,EAAA;YAMvB,MAAM,IAAI,WAAW,SAAS,CAAA,EAAA,wBAAA,WAAA,kBAAA,KAAA,EAAA;sCAnChCC,cAAc,8BAAoC,CAAA,EAAA,wBAAA"}
|
|
@@ -30,7 +30,7 @@ declare class CDSPageHeaderBreadcrumb extends LitElement {
|
|
|
30
30
|
*/
|
|
31
31
|
contentActionsFlush: boolean;
|
|
32
32
|
/**
|
|
33
|
-
* Aria label for the page header actions
|
|
33
|
+
* Aria label for the page header actions toolbar.
|
|
34
34
|
*/
|
|
35
35
|
actionsAriaLabel: string;
|
|
36
36
|
context: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-header-breadcrumb.d.ts","sourceRoot":"","sources":["../../../src/components/page-header/page-header-breadcrumb.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAQ,MAAM,KAAK,CAAC;AASvC;;;GAGG;AACH,cACM,uBAAwB,SAAQ,UAAU;IAC9C;;OAEG;IAEH,MAAM,UAAQ;IAEd;;;OAGG;IAEH,UAAU,UAAS;IAEnB;;OAEG;IAEH,gBAAgB,UAAS;IAEzB;;OAEG;IAEH,mBAAmB,UAAS;IAE5B;;OAEG;IAEH,gBAAgB,SAAyB;IAIzC,OAAO,MAAC;IAER,iBAAiB;IAMjB,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC;IAO3C,OAAO,CAAC,gBAAgB;IAQxB,MAAM;
|
|
1
|
+
{"version":3,"file":"page-header-breadcrumb.d.ts","sourceRoot":"","sources":["../../../src/components/page-header/page-header-breadcrumb.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAQ,MAAM,KAAK,CAAC;AASvC;;;GAGG;AACH,cACM,uBAAwB,SAAQ,UAAU;IAC9C;;OAEG;IAEH,MAAM,UAAQ;IAEd;;;OAGG;IAEH,UAAU,UAAS;IAEnB;;OAEG;IAEH,gBAAgB,UAAS;IAEzB;;OAEG;IAEH,mBAAmB,UAAS;IAE5B;;OAEG;IAEH,gBAAgB,SAAyB;IAIzC,OAAO,MAAC;IAER,iBAAiB;IAMjB,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC;IAO3C,OAAO,CAAC,gBAAgB;IAQxB,MAAM;IA2CN,MAAM,CAAC,MAAM,MAAU;CACxB;AAED,eAAe,uBAAuB,CAAC"}
|
|
@@ -50,9 +50,11 @@ let CDSPageHeaderBreadcrumb = class CDSPageHeaderBreadcrumb extends LitElement {
|
|
|
50
50
|
}
|
|
51
51
|
render() {
|
|
52
52
|
const { withinGrid, context } = this;
|
|
53
|
-
const { contentActionsClipped } = context ?? {};
|
|
53
|
+
const { contentActionsClipped, fullWidthGrid, narrowGrid } = context ?? {};
|
|
54
54
|
const gridClasses = classMap({
|
|
55
55
|
[`cds--css-grid`]: !withinGrid,
|
|
56
|
+
[`cds--css-grid--full-width`]: !withinGrid && !!fullWidthGrid,
|
|
57
|
+
[`cds--css-grid--narrow`]: !withinGrid && !!narrowGrid,
|
|
56
58
|
[`cds--subgrid cds--subgrid--wide`]: withinGrid
|
|
57
59
|
});
|
|
58
60
|
const contentActionClasses = classMap({
|
|
@@ -71,7 +73,7 @@ let CDSPageHeaderBreadcrumb = class CDSPageHeaderBreadcrumb extends LitElement {
|
|
|
71
73
|
</div>
|
|
72
74
|
<div
|
|
73
75
|
class="${"c4p"}--page-header__breadcrumb__actions"
|
|
74
|
-
role="
|
|
76
|
+
role="toolbar"
|
|
75
77
|
aria-label="${this.actionsAriaLabel}"
|
|
76
78
|
>
|
|
77
79
|
<div class="${contentActionClasses}">
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-header-breadcrumb.js","names":["styles","customElement"],"sources":["../../../src/components/page-header/page-header-breadcrumb.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2025, 2025\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { LitElement, html } from 'lit';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { prefix, carbonPrefix } from '../../globals/settings';\nimport { property, state } from 'lit/decorators.js';\nimport styles from './page-header.scss?lit';\nimport { consume } from '@lit/context';\nimport { pageHeaderContext } from './context';\nimport { carbonElement as customElement } from '@carbon/web-components/es/globals/decorators/carbon-element.js';\n\n/**\n * Page header Breadcrumb Bar.\n * @element c4p-page-header-breadcrumb\n */\n@customElement(`${prefix}-page-header-breadcrumb`)\nclass CDSPageHeaderBreadcrumb extends LitElement {\n /**\n * Specify if breadcrumb bar has bottom border.\n */\n @property({ reflect: true, type: Boolean })\n border = true;\n\n /**\n * Set to `true` if the breadcrumb bar is sitting within a grid\n * (ie. when used in tandem with page-header-hero-image)\n */\n @property({ attribute: 'within-grid', type: Boolean })\n withinGrid = false;\n\n /**\n * Set to `true` if page actions should be flush (no padding)\n */\n @property({ attribute: 'page-actions-flush', type: Boolean })\n pageActionsFlush = false;\n\n /**\n * Set to `true` if content actions should be flush (no padding)\n */\n @property({ attribute: 'content-actions-flush', type: Boolean })\n contentActionsFlush = false;\n\n /**\n * Aria label for the page header actions
|
|
1
|
+
{"version":3,"file":"page-header-breadcrumb.js","names":["styles","customElement"],"sources":["../../../src/components/page-header/page-header-breadcrumb.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2025, 2025\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { LitElement, html } from 'lit';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { prefix, carbonPrefix } from '../../globals/settings';\nimport { property, state } from 'lit/decorators.js';\nimport styles from './page-header.scss?lit';\nimport { consume } from '@lit/context';\nimport { pageHeaderContext } from './context';\nimport { carbonElement as customElement } from '@carbon/web-components/es/globals/decorators/carbon-element.js';\n\n/**\n * Page header Breadcrumb Bar.\n * @element c4p-page-header-breadcrumb\n */\n@customElement(`${prefix}-page-header-breadcrumb`)\nclass CDSPageHeaderBreadcrumb extends LitElement {\n /**\n * Specify if breadcrumb bar has bottom border.\n */\n @property({ reflect: true, type: Boolean })\n border = true;\n\n /**\n * Set to `true` if the breadcrumb bar is sitting within a grid\n * (ie. when used in tandem with page-header-hero-image)\n */\n @property({ attribute: 'within-grid', type: Boolean })\n withinGrid = false;\n\n /**\n * Set to `true` if page actions should be flush (no padding)\n */\n @property({ attribute: 'page-actions-flush', type: Boolean })\n pageActionsFlush = false;\n\n /**\n * Set to `true` if content actions should be flush (no padding)\n */\n @property({ attribute: 'content-actions-flush', type: Boolean })\n contentActionsFlush = false;\n\n /**\n * Aria label for the page header actions toolbar.\n */\n @property({ type: String, attribute: 'actions-aria-label', reflect: true })\n actionsAriaLabel = 'Page header actions';\n\n @consume({ context: pageHeaderContext, subscribe: true })\n @state()\n context;\n\n connectedCallback() {\n super.connectedCallback();\n // Apply class on initial connection\n this.updateFixedClass();\n }\n\n updated(changedProperties: Map<string, any>) {\n super.updated(changedProperties);\n if (changedProperties.has('context')) {\n this.updateFixedClass();\n }\n }\n\n private updateFixedClass() {\n if (this.context?.disableStickyTabBar) {\n this.classList.add(`${prefix}--page-header-breadcrumb--fixed`);\n } else {\n this.classList.remove(`${prefix}--page-header-breadcrumb--fixed`);\n }\n }\n\n render() {\n const { withinGrid, context } = this;\n const { contentActionsClipped, fullWidthGrid, narrowGrid } = context ?? {};\n const gridClasses = classMap({\n [`${carbonPrefix}--css-grid`]: !withinGrid,\n [`${carbonPrefix}--css-grid--full-width`]: !withinGrid && !!fullWidthGrid,\n [`${carbonPrefix}--css-grid--narrow`]: !withinGrid && !!narrowGrid,\n [`${carbonPrefix}--subgrid ${carbonPrefix}--subgrid--wide`]: withinGrid,\n });\n\n const contentActionClasses = classMap({\n [`${prefix}--page-header__breadcrumb__content-actions-with-global-actions`]:\n true,\n [`${prefix}--page-header__breadcrumb__content-actions-with-global-actions--show`]:\n contentActionsClipped,\n });\n\n return html`\n <div class=\"${gridClasses}\">\n <div\n class=\"${carbonPrefix}--sm:col-span-4 ${carbonPrefix}--md:col-span-8 ${carbonPrefix}--lg:col-span-16 ${carbonPrefix}--css-grid-column\"\n >\n <div class=\"${prefix}--page-header__breadcrumb-container\">\n <div class=\"${prefix}--page-header__breadcrumb-wrapper\">\n <slot name=\"icon\"></slot>\n <slot></slot>\n </div>\n <div\n class=\"${prefix}--page-header__breadcrumb__actions\"\n role=\"toolbar\"\n aria-label=\"${this.actionsAriaLabel}\"\n >\n <div class=\"${contentActionClasses}\">\n <slot name=\"content-actions\"></slot>\n </div>\n <slot name=\"page-actions\"></slot>\n </div>\n </div>\n </div>\n </div>\n `;\n }\n\n static styles = styles;\n}\n\nexport default CDSPageHeaderBreadcrumb;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,IAAA,0BAAA,MACM,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AAS;CAAM,CAAC,CAAA,EAAA,wBAAA,WAAA,oBAAA,KAAA,EAAA;YAG1E,QAAQ;CAAE,SAAS;CAAmB,WAAW;CAAM,CAAC,EACxD,OAAO,CAAA,EAAA,wBAAA,WAAA,WAAA,KAAA,EAAA;sCAlCTC,cAAc,6BAAmC,CAAA,EAAA,wBAAA;AAwGlD,IAAA,iCAAe"}
|
package/es/components/page-header/page-header-breadcrumbs-set/page-header-breadcrumbs-set.d.ts
CHANGED
|
@@ -17,9 +17,10 @@ interface Breadcrumb {
|
|
|
17
17
|
}
|
|
18
18
|
export default class CDSPageHeaderBreadcrumbsSet extends LitElement {
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* Data items currently collapsed into the overflow menu.
|
|
21
|
+
* Derived from the DOM nodes the overflow handler marks as hidden.
|
|
21
22
|
*/
|
|
22
|
-
|
|
23
|
+
private _hiddenItems;
|
|
23
24
|
/**
|
|
24
25
|
* The list of breadcrumbs.
|
|
25
26
|
*/
|
|
@@ -28,6 +29,10 @@ export default class CDSPageHeaderBreadcrumbsSet extends LitElement {
|
|
|
28
29
|
* The page title to display in the title breadcrumb.
|
|
29
30
|
*/
|
|
30
31
|
title: string;
|
|
32
|
+
/**
|
|
33
|
+
* Whether custom breadcrumb-content slot content is present.
|
|
34
|
+
*/
|
|
35
|
+
private _hasBreadcrumbContent;
|
|
31
36
|
/**
|
|
32
37
|
* Aria label for the breadcrumb navigation.
|
|
33
38
|
*/
|
|
@@ -41,6 +46,10 @@ export default class CDSPageHeaderBreadcrumbsSet extends LitElement {
|
|
|
41
46
|
*/
|
|
42
47
|
private container;
|
|
43
48
|
private overflowHandler;
|
|
49
|
+
/**
|
|
50
|
+
* Handles slotchange for the breadcrumb-content slot.
|
|
51
|
+
*/
|
|
52
|
+
protected _handleBreadcrumbContentSlotChange({ target }: Event): void;
|
|
44
53
|
connectedCallback(): void;
|
|
45
54
|
firstUpdated(): void;
|
|
46
55
|
disconnectedCallback(): void;
|
package/es/components/page-header/page-header-breadcrumbs-set/page-header-breadcrumbs-set.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-header-breadcrumbs-set.d.ts","sourceRoot":"","sources":["../../../../src/components/page-header/page-header-breadcrumbs-set/page-header-breadcrumbs-set.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAQ,MAAM,KAAK,CAAC;AAKvC,OAAO,0DAA0D,CAAC;AAClE,OAAO,6DAA6D,CAAC;AAIrE,OAAO,sBAAsB,CAAC;AAE9B,OAAO,iCAAiC,CAAC;AAKzC,UAAU,UAAU;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAGD,MAAM,CAAC,OAAO,OAAO,2BAA4B,SAAQ,UAAU;IACjE
|
|
1
|
+
{"version":3,"file":"page-header-breadcrumbs-set.d.ts","sourceRoot":"","sources":["../../../../src/components/page-header/page-header-breadcrumbs-set/page-header-breadcrumbs-set.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAQ,MAAM,KAAK,CAAC;AAKvC,OAAO,0DAA0D,CAAC;AAClE,OAAO,6DAA6D,CAAC;AAIrE,OAAO,sBAAsB,CAAC;AAE9B,OAAO,iCAAiC,CAAC;AAKzC,UAAU,UAAU;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAGD,MAAM,CAAC,OAAO,OAAO,2BAA4B,SAAQ,UAAU;IACjE;;;OAGG;IAEH,OAAO,CAAC,YAAY,CAAoB;IAExC;;OAEG;IAEH,eAAe,EAAE,UAAU,EAAE,CAAM;IAEnC;;OAEG;IAEH,KAAK,SAAM;IAEX;;OAEG;IAEH,OAAO,CAAC,qBAAqB,CAAS;IAEtC;;OAEG;IAEH,mBAAmB,SAAiB;IAEpC;;OAEG;IAEH,iBAAiB,SAAsB;IAEvC;;OAEG;IAEH,OAAO,CAAC,SAAS,CAAe;IAEhC,OAAO,CAAC,eAAe,CAAyC;IAEhE;;OAEG;IACH,SAAS,CAAC,kCAAkC,CAAC,EAAE,MAAM,EAAE,EAAE,KAAK;IAK9D,iBAAiB,IAAI,IAAI;IAKzB,YAAY;IA8DZ,oBAAoB;IAOpB,MAAM;IAiEN,MAAM,CAAC,MAAM,MAAU;CACxB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,iCAAiC,EAAE,2BAA2B,CAAC;KAChE;CACF"}
|