@genesislcap/foundation-ui 14.256.0 → 14.257.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.
@@ -175,13 +175,13 @@ export declare const baseComponents: {
175
175
  foundationMenuItem: (overrideDefinition?: import("@microsoft/fast-foundation").OverrideFoundationElementDefinition<import("@microsoft/fast-foundation").MenuItemOptions>) => import("@microsoft/fast-foundation").FoundationElementRegistry<import("@microsoft/fast-foundation").MenuItemOptions, import("@microsoft/fast-element").Constructable<import("@microsoft/fast-foundation").FoundationElement>>;
176
176
  foundationModal: (overrideDefinition?: import("@microsoft/fast-foundation").OverrideFoundationElementDefinition<{
177
177
  baseName: string;
178
- styles: import("@microsoft/fast-element").ElementStyles;
179
178
  template: import("@microsoft/fast-element").ViewTemplate<import("./modal").Modal, any>;
179
+ styles: import("@microsoft/fast-element").ElementStyles;
180
180
  shadowOptions: ShadowRootInit;
181
181
  }>) => import("@microsoft/fast-foundation").FoundationElementRegistry<{
182
182
  baseName: string;
183
- styles: import("@microsoft/fast-element").ElementStyles;
184
183
  template: import("@microsoft/fast-element").ViewTemplate<import("./modal").Modal, any>;
184
+ styles: import("@microsoft/fast-element").ElementStyles;
185
185
  shadowOptions: ShadowRootInit;
186
186
  }, typeof import("./modal").Modal>;
187
187
  foundationMultiselect: (overrideDefinition?: import("@microsoft/fast-foundation").OverrideFoundationElementDefinition<{
@@ -1,6 +1,6 @@
1
1
  import { NotificationStructure } from '@genesislcap/foundation-notifications';
2
2
  import { FoundationElement } from '@microsoft/fast-foundation';
3
- import type { DialogType, DialogPosition } from './dialog.types';
3
+ import type { DialogPosition, DialogType } from './dialog.types';
4
4
  /**
5
5
  * Focus trapping will be addressed as part of https://genesisglobal.atlassian.net/browse/FUI-2083
6
6
  */
@@ -12,6 +12,8 @@ export declare abstract class DialogElement extends FoundationElement {
12
12
  * in the component Shadow DOM.
13
13
  */
14
14
  mainElement: HTMLDialogElement;
15
+ topElement: HTMLElement;
16
+ topElementSlot: HTMLSlotElement;
15
17
  notification: NotificationStructure;
16
18
  notificationChanged(): void;
17
19
  type: DialogType;
@@ -1 +1 @@
1
- {"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../../../src/dialog/dialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAE9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAK/D,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEjE;;GAEG;AAGH,eAAO,MAAM,6BAA6B,EAAE,cAG3C,CAAC;AAEF,eAAO,MAAM,mBAAmB,IAAK,CAAC;AAEtC,8BAAsB,aAAc,SAAQ,iBAAiB;IAC3D;;;OAGG;IACH,WAAW,EAAG,iBAAiB,CAAC;IACpB,YAAY,EAAG,qBAAqB,CAAC;IACjD,mBAAmB;IAIU,IAAI,EAAE,UAAU,CAAa;IAEpD,QAAQ,EAAE,cAAc,CAAY;IAE1C;;OAEG;IACsD,aAAa,EAAE,OAAO,CAAQ;IAEvF;;OAEG;IACS,cAAc,EAAE,MAAM,IAAI,CAAC;IAEvC;;OAEG;IACS,eAAe,EAAE,MAAM,IAAI,CAAC;IAExC,iBAAiB;IAgBjB;;OAEG;IACH,IACI,IAAI,IAAI,OAAO,CAElB;IAED;;OAEG;IACH,QAAQ,CAAC,IAAI,IAAI,IAAI;IAErB;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACI,OAAO;IAOd;;OAEG;IACI,WAAW,IAAI,IAAI;CAQ3B;AAED;;GAEG;AACH,qBAAa,MAAO,SAAQ,aAAa;IACvC,IAAI,IAAI,IAAI;CAIb;AAED;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;iBAM3B,CAAC"}
1
+ {"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../../../src/dialog/dialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAE9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAK/D,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjE;;GAEG;AAGH,eAAO,MAAM,6BAA6B,EAAE,cAG3C,CAAC;AAEF,eAAO,MAAM,mBAAmB,IAAK,CAAC;AAEtC,8BAAsB,aAAc,SAAQ,iBAAiB;IAC3D;;;OAGG;IACH,WAAW,EAAG,iBAAiB,CAAC;IAChC,UAAU,EAAG,WAAW,CAAC;IACzB,cAAc,EAAG,eAAe,CAAC;IACrB,YAAY,EAAG,qBAAqB,CAAC;IACjD,mBAAmB;IAIU,IAAI,EAAE,UAAU,CAAa;IAEpD,QAAQ,EAAE,cAAc,CAAY;IAE1C;;OAEG;IACsD,aAAa,EAAE,OAAO,CAAQ;IAEvF;;OAEG;IACS,cAAc,EAAE,MAAM,IAAI,CAAC;IAEvC;;OAEG;IACS,eAAe,EAAE,MAAM,IAAI,CAAC;IAExC,iBAAiB;IAgBjB;;OAEG;IACH,IACI,IAAI,IAAI,OAAO,CAElB;IAED;;OAEG;IACH,QAAQ,CAAC,IAAI,IAAI,IAAI;IAErB;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACI,OAAO;IAOd;;OAEG;IACI,WAAW,IAAI,IAAI;CAQ3B;AAED;;GAEG;AACH,qBAAa,MAAO,SAAQ,aAAa;IACvC,IAAI,IAAI,IAAI;CAIb;AAED;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;iBAM3B,CAAC"}
@@ -5,7 +5,26 @@ export declare const defaultModalConfig: {};
5
5
  * @tagname %%prefix%%-modal
6
6
  */
7
7
  export declare class Modal extends DialogElement {
8
+ private isDragging;
9
+ private offsetX;
10
+ private offsetY;
11
+ private modalWidth;
12
+ private modalHeight;
13
+ private onMouseDownBound;
14
+ private onMouseMoveBound;
15
+ private onMouseUpBound;
16
+ draggable: boolean;
17
+ draggableChanged(ignore: any, newValue: boolean): void;
8
18
  show(): void;
19
+ connectedCallback(): void;
20
+ disconnectedCallback(): void;
21
+ onCloseCallback: () => void;
22
+ private isEventTargetInDraggableTarget;
23
+ private isInsideTopSlot;
24
+ private onMouseDown;
25
+ private onMouseMove;
26
+ private onMouseUp;
27
+ private removeDraggableEventListeners;
9
28
  }
10
29
  /**
11
30
  * The Foundation Modal
@@ -16,13 +35,13 @@ export declare class Modal extends DialogElement {
16
35
  */
17
36
  export declare const foundationModal: (overrideDefinition?: import("@microsoft/fast-foundation").OverrideFoundationElementDefinition<{
18
37
  baseName: string;
19
- styles: import("@microsoft/fast-element").ElementStyles;
20
38
  template: import("@microsoft/fast-element").ViewTemplate<Modal, any>;
39
+ styles: import("@microsoft/fast-element").ElementStyles;
21
40
  shadowOptions: ShadowRootInit;
22
41
  }>) => import("@microsoft/fast-foundation").FoundationElementRegistry<{
23
42
  baseName: string;
24
- styles: import("@microsoft/fast-element").ElementStyles;
25
43
  template: import("@microsoft/fast-element").ViewTemplate<Modal, any>;
44
+ styles: import("@microsoft/fast-element").ElementStyles;
26
45
  shadowOptions: ShadowRootInit;
27
46
  }, typeof Modal>;
28
47
  //# sourceMappingURL=modal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../src/modal/modal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAK1C,eAAO,MAAM,4BAA4B,EAAE,cAG1C,CAAC;AAEF,eAAO,MAAM,kBAAkB,IAAK,CAAC;AAErC;;GAEG;AACH,qBAAa,KAAM,SAAQ,aAAa;IACtC,IAAI,IAAI,IAAI;CAIb;AAED;;;;;;GAMG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;gBAM1B,CAAC"}
1
+ {"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../src/modal/modal.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAK1C,eAAO,MAAM,4BAA4B,EAAE,cAG1C,CAAC;AAEF,eAAO,MAAM,kBAAkB,IAAK,CAAC;AAErC;;GAEG;AACH,qBAAa,KAAM,SAAQ,aAAa;IACtC,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,WAAW,CAAK;IAExB,OAAO,CAAC,gBAAgB,CAA8C;IACtE,OAAO,CAAC,gBAAgB,CAA8C;IACtE,OAAO,CAAC,cAAc,CAA6B;IAExB,SAAS,UAAS;IAC7C,gBAAgB,CAAC,MAAM,KAAA,EAAE,QAAQ,EAAE,OAAO;IAa1C,IAAI,IAAI,IAAI;IAKZ,iBAAiB;IASjB,oBAAoB;IAUpB,eAAe,aASb;IAEF,OAAO,CAAC,8BAA8B;IAMtC,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,WAAW;IAkBnB,OAAO,CAAC,WAAW;IAuBnB,OAAO,CAAC,SAAS;IAKjB,OAAO,CAAC,6BAA6B;CAWtC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;gBAM1B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"modal.styles.d.ts","sourceRoot":"","sources":["../../../src/modal/modal.styles.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAG7D,eAAO,MAAM,qBAAqB,EAAE,aAEnC,CAAC"}
1
+ {"version":3,"file":"modal.styles.d.ts","sourceRoot":"","sources":["../../../src/modal/modal.styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAI7D,eAAO,MAAM,qBAAqB,EAAE,aAMnC,CAAC"}
@@ -3,8 +3,8 @@ import { getPrefix } from '../utils';
3
3
  export const getDialogTemplate = (prefix) => html `
4
4
  <dialog ${ref('mainElement')} part="dialog" type=${(x) => x.type}>
5
5
  <div class="content-wrapper" part="content">
6
- <div part="top" class="top">
7
- <slot name="top">
6
+ <div part="top" class="top" ${ref('topElement')}>
7
+ <slot name="top" ${ref('topElementSlot')}>
8
8
  <h2 slot="top" class="title">${(x) => { var _a; return (_a = x.notification) === null || _a === void 0 ? void 0 : _a.title; }}</h2>
9
9
  </slot>
10
10
  ${when((x) => x.showCloseIcon, html `
@@ -1,3 +1,5 @@
1
+ import { __decorate } from "tslib";
2
+ import { attr } from '@microsoft/fast-element';
1
3
  import { DialogElement } from '../dialog';
2
4
  import { foundationModalStyles as styles } from './modal.styles';
3
5
  import { foundationModalTemplate as template } from './modal.template';
@@ -11,12 +13,126 @@ export const defaultModalConfig = {};
11
13
  * @tagname %%prefix%%-modal
12
14
  */
13
15
  export class Modal extends DialogElement {
16
+ constructor() {
17
+ super(...arguments);
18
+ this.isDragging = false;
19
+ this.offsetX = 0;
20
+ this.offsetY = 0;
21
+ this.modalWidth = 0;
22
+ this.modalHeight = 0;
23
+ this.onMouseDownBound = null;
24
+ this.onMouseMoveBound = null;
25
+ this.onMouseUpBound = null;
26
+ this.draggable = false;
27
+ this.onCloseCallback = () => {
28
+ if (this.draggable && this.mainElement instanceof HTMLElement) {
29
+ Object.assign(this.mainElement.style, {
30
+ position: '',
31
+ left: '',
32
+ top: '',
33
+ margin: '',
34
+ });
35
+ }
36
+ };
37
+ }
38
+ draggableChanged(ignore, newValue) {
39
+ var _a, _b;
40
+ if (newValue) {
41
+ this.onMouseDownBound = this.onMouseDown.bind(this);
42
+ (_a = this.mainElement) === null || _a === void 0 ? void 0 : _a.addEventListener('mousedown', this.onMouseDownBound);
43
+ }
44
+ else {
45
+ if (this.onMouseDownBound) {
46
+ (_b = this.mainElement) === null || _b === void 0 ? void 0 : _b.removeEventListener('mousedown', this.onMouseDownBound);
47
+ this.onMouseDownBound = null;
48
+ }
49
+ this.removeDraggableEventListeners();
50
+ }
51
+ }
14
52
  show() {
15
- if (this.onShowCallback)
16
- this.onShowCallback();
17
- this.mainElement['showModal']();
53
+ var _a, _b;
54
+ (_a = this.onShowCallback) === null || _a === void 0 ? void 0 : _a.call(this);
55
+ (_b = this.mainElement) === null || _b === void 0 ? void 0 : _b.showModal();
56
+ }
57
+ connectedCallback() {
58
+ var _a;
59
+ super.connectedCallback();
60
+ if (this.draggable) {
61
+ this.onMouseDownBound = this.onMouseDown.bind(this);
62
+ (_a = this.mainElement) === null || _a === void 0 ? void 0 : _a.addEventListener('mousedown', this.onMouseDownBound);
63
+ }
64
+ }
65
+ disconnectedCallback() {
66
+ var _a;
67
+ super.disconnectedCallback();
68
+ this.removeDraggableEventListeners();
69
+ if (this.onMouseDownBound) {
70
+ (_a = this.mainElement) === null || _a === void 0 ? void 0 : _a.removeEventListener('mousedown', this.onMouseDownBound);
71
+ this.onMouseDownBound = null;
72
+ }
73
+ }
74
+ isEventTargetInDraggableTarget(event) {
75
+ var _a;
76
+ return (((_a = this.topElement) === null || _a === void 0 ? void 0 : _a.contains(event.target)) || this.isInsideTopSlot(event.target));
77
+ }
78
+ isInsideTopSlot(target) {
79
+ if (!this.topElementSlot)
80
+ return false;
81
+ const assignedNodes = this.topElementSlot.assignedNodes();
82
+ return assignedNodes.some((node) => node === target || node.contains(target));
83
+ }
84
+ onMouseDown(event) {
85
+ if (!this.topElement || !this.isEventTargetInDraggableTarget(event))
86
+ return;
87
+ this.isDragging = true;
88
+ const rect = this.mainElement.getBoundingClientRect();
89
+ this.offsetX = event.clientX - rect.left;
90
+ this.offsetY = event.clientY - rect.top;
91
+ // Store the modal’s width and height to minimize calls to getBoundingClientRect
92
+ this.modalWidth = rect.width;
93
+ this.modalHeight = rect.height;
94
+ this.onMouseMoveBound = this.onMouseMove.bind(this);
95
+ this.onMouseUpBound = this.onMouseUp.bind(this);
96
+ document.addEventListener('mousemove', this.onMouseMoveBound);
97
+ document.addEventListener('mouseup', this.onMouseUpBound);
98
+ }
99
+ onMouseMove(event) {
100
+ if (!this.isDragging || !this.mainElement)
101
+ return;
102
+ const viewportWidth = window.innerWidth;
103
+ const viewportHeight = window.innerHeight;
104
+ let newLeft = event.clientX - this.offsetX;
105
+ let newTop = event.clientY - this.offsetY;
106
+ // Ensure modal stays within screen boundaries
107
+ newLeft = Math.max(0, Math.min(viewportWidth - this.modalWidth, newLeft));
108
+ newTop = Math.max(0, Math.min(viewportHeight - this.modalHeight, newTop));
109
+ requestAnimationFrame(() => {
110
+ Object.assign(this.mainElement.style, {
111
+ position: 'absolute',
112
+ left: `${newLeft}px`,
113
+ top: `${newTop}px`,
114
+ margin: '0',
115
+ });
116
+ });
117
+ }
118
+ onMouseUp() {
119
+ this.isDragging = false;
120
+ this.removeDraggableEventListeners();
121
+ }
122
+ removeDraggableEventListeners() {
123
+ if (this.onMouseMoveBound) {
124
+ document.removeEventListener('mousemove', this.onMouseMoveBound);
125
+ this.onMouseMoveBound = null;
126
+ }
127
+ if (this.onMouseUpBound) {
128
+ document.removeEventListener('mouseup', this.onMouseUpBound);
129
+ this.onMouseUpBound = null;
130
+ }
18
131
  }
19
132
  }
133
+ __decorate([
134
+ attr({ mode: 'boolean' })
135
+ ], Modal.prototype, "draggable", void 0);
20
136
  /**
21
137
  * The Foundation Modal
22
138
  *
@@ -24,5 +140,5 @@ export class Modal extends DialogElement {
24
140
  * @remarks
25
141
  * HTML Element: \<foundation-modal\>
26
142
  */
27
- export const foundationModal = Modal.compose(Object.assign({ baseName: 'modal', styles,
28
- template, shadowOptions: foundationModalShadowOptions }, defaultModalConfig));
143
+ export const foundationModal = Modal.compose(Object.assign({ baseName: 'modal', template,
144
+ styles, shadowOptions: foundationModalShadowOptions }, defaultModalConfig));
@@ -2,4 +2,8 @@ import { css } from '@microsoft/fast-element';
2
2
  import { foundationDialogStyles } from '../dialog';
3
3
  export const foundationModalStyles = css `
4
4
  ${foundationDialogStyles}
5
+
6
+ :host([draggable])::part(top) {
7
+ cursor: move;
8
+ }
5
9
  `;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@genesislcap/foundation-ui",
3
3
  "description": "Genesis Foundation UI",
4
- "version": "14.256.0",
4
+ "version": "14.257.0",
5
5
  "sideEffects": false,
6
6
  "license": "SEE LICENSE IN license.txt",
7
7
  "main": "dist/esm/index.js",
@@ -83,13 +83,13 @@
83
83
  }
84
84
  },
85
85
  "devDependencies": {
86
- "@genesislcap/foundation-testing": "14.256.0",
87
- "@genesislcap/genx": "14.256.0",
88
- "@genesislcap/rollup-builder": "14.256.0",
89
- "@genesislcap/ts-builder": "14.256.0",
90
- "@genesislcap/uvu-playwright-builder": "14.256.0",
91
- "@genesislcap/vite-builder": "14.256.0",
92
- "@genesislcap/webpack-builder": "14.256.0",
86
+ "@genesislcap/foundation-testing": "14.257.0",
87
+ "@genesislcap/genx": "14.257.0",
88
+ "@genesislcap/rollup-builder": "14.257.0",
89
+ "@genesislcap/ts-builder": "14.257.0",
90
+ "@genesislcap/uvu-playwright-builder": "14.257.0",
91
+ "@genesislcap/vite-builder": "14.257.0",
92
+ "@genesislcap/webpack-builder": "14.257.0",
93
93
  "copyfiles": "^2.4.1",
94
94
  "rimraf": "^5.0.0",
95
95
  "rxjs": "^7.5.4"
@@ -100,15 +100,15 @@
100
100
  "@fortawesome/free-regular-svg-icons": "^6.2.1",
101
101
  "@fortawesome/free-solid-svg-icons": "^6.2.1",
102
102
  "@genesiscommunitysuccess/analyzer-import-alias-plugin": "^5.0.3",
103
- "@genesislcap/expression-builder": "14.256.0",
104
- "@genesislcap/foundation-comms": "14.256.0",
105
- "@genesislcap/foundation-criteria": "14.256.0",
106
- "@genesislcap/foundation-errors": "14.256.0",
107
- "@genesislcap/foundation-events": "14.256.0",
108
- "@genesislcap/foundation-logger": "14.256.0",
109
- "@genesislcap/foundation-notifications": "14.256.0",
110
- "@genesislcap/foundation-user": "14.256.0",
111
- "@genesislcap/foundation-utils": "14.256.0",
103
+ "@genesislcap/expression-builder": "14.257.0",
104
+ "@genesislcap/foundation-comms": "14.257.0",
105
+ "@genesislcap/foundation-criteria": "14.257.0",
106
+ "@genesislcap/foundation-errors": "14.257.0",
107
+ "@genesislcap/foundation-events": "14.257.0",
108
+ "@genesislcap/foundation-logger": "14.257.0",
109
+ "@genesislcap/foundation-notifications": "14.257.0",
110
+ "@genesislcap/foundation-user": "14.257.0",
111
+ "@genesislcap/foundation-utils": "14.257.0",
112
112
  "@microsoft/fast-colors": "5.3.1",
113
113
  "@microsoft/fast-components": "2.30.6",
114
114
  "@microsoft/fast-element": "1.14.0",
@@ -130,5 +130,5 @@
130
130
  "access": "public"
131
131
  },
132
132
  "customElements": "dist/custom-elements.json",
133
- "gitHead": "bd99b542c14e7f402e36373b566888f24e4a8c7b"
133
+ "gitHead": "111a319fad6178b896179e8fef9bb79b9da31867"
134
134
  }