@fluid-topics/ft-dialog 0.3.1 → 0.3.2

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.
@@ -28,6 +28,7 @@ export declare class FtDialog extends FtLitElement implements FtDialogProperties
28
28
  closeOnEsc: boolean;
29
29
  closeOnClickOutside: boolean;
30
30
  closable: boolean;
31
+ beforeClose: () => boolean;
31
32
  heading: string;
32
33
  icon: string;
33
34
  static get styles(): import("lit").CSSResult;
@@ -31,6 +31,7 @@ export class FtDialog extends FtLitElement {
31
31
  this.closeOnEsc = false;
32
32
  this.closeOnClickOutside = false;
33
33
  this.closable = false;
34
+ this.beforeClose = () => true;
34
35
  this.heading = "";
35
36
  this.icon = "";
36
37
  }
@@ -167,7 +168,9 @@ export class FtDialog extends FtLitElement {
167
168
  document.removeEventListener("keydown", this.watchEscapeKey.bind(this));
168
169
  }
169
170
  close() {
170
- this.opened = false;
171
+ if (this.beforeClose()) {
172
+ this.opened = false;
173
+ }
171
174
  }
172
175
  open() {
173
176
  this.opened = true;
@@ -206,6 +209,9 @@ __decorate([
206
209
  __decorate([
207
210
  property({ type: Boolean })
208
211
  ], FtDialog.prototype, "closable", void 0);
212
+ __decorate([
213
+ property({ type: () => Boolean })
214
+ ], FtDialog.prototype, "beforeClose", void 0);
209
215
  __decorate([
210
216
  property({ type: String })
211
217
  ], FtDialog.prototype, "heading", void 0);
@@ -538,7 +538,7 @@ const D=Symbol.for(""),U=t=>{if((null==t?void 0:t.r)===D)return null==t?void 0:t
538
538
  </ft-tooltip>
539
539
  `}resolveIcon(){return this.loading?e.html`
540
540
  <ft-loader></ft-loader> `:this.icon?e.html`
541
- <ft-icon variant="material">${this.icon}</ft-icon> `:e.nothing}focus(){var t;null===(t=this.button)||void 0===t||t.focus()}getLabel(){return this.label||this.textContent}get textContent(){return this.unslotText(this.slottedContent).trim()}unslotText(t){return t instanceof HTMLSlotElement?t.assignedNodes().map((t=>this.unslotText(t))).join(""):(null==t?void 0:t.textContent)||""}hasTextContent(){return this.textContent.length>0}onSlotchange(){this.requestUpdate()}isDisabled(){return this.disabled||this.loading}}Zi.elementDefinitions={"ft-ripple":ki,"ft-tooltip":Ni,"ft-typography":ai,"ft-icon":ci,"ft-loader":Ii},Ti([o.property({type:Boolean})],Zi.prototype,"primary",void 0),Ti([o.property({type:Boolean})],Zi.prototype,"outlined",void 0),Ti([o.property({type:Boolean})],Zi.prototype,"disabled",void 0),Ti([o.property({type:Boolean})],Zi.prototype,"dense",void 0),Ti([o.property({type:Boolean})],Zi.prototype,"round",void 0),Ti([o.property({type:String})],Zi.prototype,"label",void 0),Ti([o.property({type:String})],Zi.prototype,"icon",void 0),Ti([o.property({type:Boolean})],Zi.prototype,"trailingIcon",void 0),Ti([o.property({type:Boolean})],Zi.prototype,"loading",void 0),Ti([o.property({type:String})],Zi.prototype,"tooltipPosition",void 0),Ti([o.query(".ft-button")],Zi.prototype,"button",void 0),Ti([o.query(".ft-button--label slot")],Zi.prototype,"slottedContent",void 0),i.customElement("ft-button")(Zi);var Di=function(t,i,e,o){for(var n,s=arguments.length,r=s<3?i:null===o?o=Object.getOwnPropertyDescriptor(i,e):o,a=t.length-1;a>=0;a--)(n=t[a])&&(r=(s<3?n(r):s>3?n(i,e,r):n(i,e))||r);return s>3&&r&&Object.defineProperty(i,e,r),r};const Ui={zIndex:i.FtCssVariableFactory.create("--ft-dialog-z-index","NUMBER","2"),overlayBackgroundColor:i.FtCssVariableFactory.create("--ft-dialog-overlay-background-color","COLOR","rgba(0, 0, 0, 0.3)"),height:i.FtCssVariableFactory.create("--ft-dialog-height","SIZE","unset"),width:i.FtCssVariableFactory.create("--ft-dialog-width","SIZE","unset"),minWidth:i.FtCssVariableFactory.create("--ft-dialog-min-width","SIZE","unset"),paddingTop:i.FtCssVariableFactory.create("--ft-dialog-padding-top","SIZE","20px"),paddingSide:i.FtCssVariableFactory.create("--ft-dialog-padding-side","SIZE","16px"),paddingButtons:i.FtCssVariableFactory.create("--ft-dialog-padding-buttons","SIZE","20px"),colorSurface:i.FtCssVariableFactory.external(i.designSystemVariables.colorSurface,"Design system"),headingColor:i.FtCssVariableFactory.external(i.designSystemVariables.colorOnSurfaceMedium,"Design system"),borderRadiusS:i.FtCssVariableFactory.external(i.designSystemVariables.borderRadiusS,"Design system"),elevation24:i.FtCssVariableFactory.external(i.designSystemVariables.elevation24,"Design system")};class Wi extends i.FtLitElement{constructor(){super(...arguments),this.opened=!1,this.closeOnEsc=!1,this.closeOnClickOutside=!1,this.closable=!1,this.heading="",this.icon=""}static get styles(){return e.css`
541
+ <ft-icon variant="material">${this.icon}</ft-icon> `:e.nothing}focus(){var t;null===(t=this.button)||void 0===t||t.focus()}getLabel(){return this.label||this.textContent}get textContent(){return this.unslotText(this.slottedContent).trim()}unslotText(t){return t instanceof HTMLSlotElement?t.assignedNodes().map((t=>this.unslotText(t))).join(""):(null==t?void 0:t.textContent)||""}hasTextContent(){return this.textContent.length>0}onSlotchange(){this.requestUpdate()}isDisabled(){return this.disabled||this.loading}}Zi.elementDefinitions={"ft-ripple":ki,"ft-tooltip":Ni,"ft-typography":ai,"ft-icon":ci,"ft-loader":Ii},Ti([o.property({type:Boolean})],Zi.prototype,"primary",void 0),Ti([o.property({type:Boolean})],Zi.prototype,"outlined",void 0),Ti([o.property({type:Boolean})],Zi.prototype,"disabled",void 0),Ti([o.property({type:Boolean})],Zi.prototype,"dense",void 0),Ti([o.property({type:Boolean})],Zi.prototype,"round",void 0),Ti([o.property({type:String})],Zi.prototype,"label",void 0),Ti([o.property({type:String})],Zi.prototype,"icon",void 0),Ti([o.property({type:Boolean})],Zi.prototype,"trailingIcon",void 0),Ti([o.property({type:Boolean})],Zi.prototype,"loading",void 0),Ti([o.property({type:String})],Zi.prototype,"tooltipPosition",void 0),Ti([o.query(".ft-button")],Zi.prototype,"button",void 0),Ti([o.query(".ft-button--label slot")],Zi.prototype,"slottedContent",void 0),i.customElement("ft-button")(Zi);var Di=function(t,i,e,o){for(var n,s=arguments.length,r=s<3?i:null===o?o=Object.getOwnPropertyDescriptor(i,e):o,a=t.length-1;a>=0;a--)(n=t[a])&&(r=(s<3?n(r):s>3?n(i,e,r):n(i,e))||r);return s>3&&r&&Object.defineProperty(i,e,r),r};const Ui={zIndex:i.FtCssVariableFactory.create("--ft-dialog-z-index","NUMBER","2"),overlayBackgroundColor:i.FtCssVariableFactory.create("--ft-dialog-overlay-background-color","COLOR","rgba(0, 0, 0, 0.3)"),height:i.FtCssVariableFactory.create("--ft-dialog-height","SIZE","unset"),width:i.FtCssVariableFactory.create("--ft-dialog-width","SIZE","unset"),minWidth:i.FtCssVariableFactory.create("--ft-dialog-min-width","SIZE","unset"),paddingTop:i.FtCssVariableFactory.create("--ft-dialog-padding-top","SIZE","20px"),paddingSide:i.FtCssVariableFactory.create("--ft-dialog-padding-side","SIZE","16px"),paddingButtons:i.FtCssVariableFactory.create("--ft-dialog-padding-buttons","SIZE","20px"),colorSurface:i.FtCssVariableFactory.external(i.designSystemVariables.colorSurface,"Design system"),headingColor:i.FtCssVariableFactory.external(i.designSystemVariables.colorOnSurfaceMedium,"Design system"),borderRadiusS:i.FtCssVariableFactory.external(i.designSystemVariables.borderRadiusS,"Design system"),elevation24:i.FtCssVariableFactory.external(i.designSystemVariables.elevation24,"Design system")};class Wi extends i.FtLitElement{constructor(){super(...arguments),this.opened=!1,this.closeOnEsc=!1,this.closeOnClickOutside=!1,this.closable=!1,this.beforeClose=()=>!0,this.heading="",this.icon=""}static get styles(){return e.css`
542
542
  .ft-dialog {
543
543
  position: fixed;
544
544
  top: 0;
@@ -646,4 +646,4 @@ const D=Symbol.for(""),U=t=>{if((null==t?void 0:t.r)===D)return null==t?void 0:t
646
646
  </div>
647
647
  </div>
648
648
  </div>
649
- `:null}updated(t){if(t.has("opened")){const t=new CustomEvent("opened-changed",{detail:{opened:this.opened}});this.dispatchEvent(t)}}connectedCallback(){super.connectedCallback(),document.addEventListener("keydown",this.watchEscapeKey.bind(this))}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("keydown",this.watchEscapeKey.bind(this))}close(){this.opened=!1}open(){this.opened=!0}watchEscapeKey(t){"Escape"===t.key&&this.closeOnEsc&&this.close()}watchClickOutside(){this.closeOnClickOutside&&this.close()}}Wi.elementDefinitions={"ft-typography":ai,"ft-icon":ci,"ft-button":Zi},Di([o.property({type:Boolean,hasChanged:(t,i)=>!1===i&&!0===t||!0===i&&!1===t})],Wi.prototype,"opened",void 0),Di([o.property({type:Boolean})],Wi.prototype,"closeOnEsc",void 0),Di([o.property({type:Boolean})],Wi.prototype,"closeOnClickOutside",void 0),Di([o.property({type:Boolean})],Wi.prototype,"closable",void 0),Di([o.property({type:String})],Wi.prototype,"heading",void 0),Di([o.property({type:String})],Wi.prototype,"icon",void 0),i.customElement("ft-dialog")(Wi),t.FtDialog=Wi,t.FtDialogCssVariables=Ui,t.default=Wi,Object.defineProperty(t,"t",{value:!0})}({},ftGlobals.wcUtils,ftGlobals.lit,ftGlobals.litDecorators,ftGlobals.litUnsafeHTML,ftGlobals.litClassMap);
649
+ `:null}updated(t){if(t.has("opened")){const t=new CustomEvent("opened-changed",{detail:{opened:this.opened}});this.dispatchEvent(t)}}connectedCallback(){super.connectedCallback(),document.addEventListener("keydown",this.watchEscapeKey.bind(this))}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("keydown",this.watchEscapeKey.bind(this))}close(){this.beforeClose()&&(this.opened=!1)}open(){this.opened=!0}watchEscapeKey(t){"Escape"===t.key&&this.closeOnEsc&&this.close()}watchClickOutside(){this.closeOnClickOutside&&this.close()}}Wi.elementDefinitions={"ft-typography":ai,"ft-icon":ci,"ft-button":Zi},Di([o.property({type:Boolean,hasChanged:(t,i)=>!1===i&&!0===t||!0===i&&!1===t})],Wi.prototype,"opened",void 0),Di([o.property({type:Boolean})],Wi.prototype,"closeOnEsc",void 0),Di([o.property({type:Boolean})],Wi.prototype,"closeOnClickOutside",void 0),Di([o.property({type:Boolean})],Wi.prototype,"closable",void 0),Di([o.property({type:()=>Boolean})],Wi.prototype,"beforeClose",void 0),Di([o.property({type:String})],Wi.prototype,"heading",void 0),Di([o.property({type:String})],Wi.prototype,"icon",void 0),i.customElement("ft-dialog")(Wi),t.FtDialog=Wi,t.FtDialogCssVariables=Ui,t.default=Wi,Object.defineProperty(t,"t",{value:!0})}({},ftGlobals.wcUtils,ftGlobals.lit,ftGlobals.litDecorators,ftGlobals.litUnsafeHTML,ftGlobals.litClassMap);
@@ -637,7 +637,7 @@ function(t,e,i){let o,n=t;return"object"==typeof t?(n=t.slot,o=t):o={flatten:e},
637
637
  </ft-tooltip>
638
638
  `}resolveIcon(){return this.loading?W`
639
639
  <ft-loader></ft-loader> `:this.icon?W`
640
- <ft-icon variant="material">${this.icon}</ft-icon> `:K}focus(){var t;null===(t=this.button)||void 0===t||t.focus()}getLabel(){return this.label||this.textContent}get textContent(){return this.unslotText(this.slottedContent).trim()}unslotText(t){return t instanceof HTMLSlotElement?t.assignedNodes().map((t=>this.unslotText(t))).join(""):(null==t?void 0:t.textContent)||""}hasTextContent(){return this.textContent.length>0}onSlotchange(){this.requestUpdate()}isDisabled(){return this.disabled||this.loading}}Ci.elementDefinitions={"ft-ripple":hi,"ft-tooltip":vi,"ft-typography":_e,"ft-icon":Qe,"ft-loader":bi},mi([o({type:Boolean})],Ci.prototype,"primary",void 0),mi([o({type:Boolean})],Ci.prototype,"outlined",void 0),mi([o({type:Boolean})],Ci.prototype,"disabled",void 0),mi([o({type:Boolean})],Ci.prototype,"dense",void 0),mi([o({type:Boolean})],Ci.prototype,"round",void 0),mi([o({type:String})],Ci.prototype,"label",void 0),mi([o({type:String})],Ci.prototype,"icon",void 0),mi([o({type:Boolean})],Ci.prototype,"trailingIcon",void 0),mi([o({type:Boolean})],Ci.prototype,"loading",void 0),mi([o({type:String})],Ci.prototype,"tooltipPosition",void 0),mi([r(".ft-button")],Ci.prototype,"button",void 0),mi([r(".ft-button--label slot")],Ci.prototype,"slottedContent",void 0),p("ft-button")(Ci);var Ni=function(t,e,i,o){for(var n,s=arguments.length,r=s<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o,a=t.length-1;a>=0;a--)(n=t[a])&&(r=(s<3?n(r):s>3?n(e,i,r):n(e,i))||r);return s>3&&r&&Object.defineProperty(e,i,r),r};const Ei={zIndex:ht.create("--ft-dialog-z-index","NUMBER","2"),overlayBackgroundColor:ht.create("--ft-dialog-overlay-background-color","COLOR","rgba(0, 0, 0, 0.3)"),height:ht.create("--ft-dialog-height","SIZE","unset"),width:ht.create("--ft-dialog-width","SIZE","unset"),minWidth:ht.create("--ft-dialog-min-width","SIZE","unset"),paddingTop:ht.create("--ft-dialog-padding-top","SIZE","20px"),paddingSide:ht.create("--ft-dialog-padding-side","SIZE","16px"),paddingButtons:ht.create("--ft-dialog-padding-buttons","SIZE","20px"),colorSurface:ht.external(dt.colorSurface,"Design system"),headingColor:ht.external(dt.colorOnSurfaceMedium,"Design system"),borderRadiusS:ht.external(dt.borderRadiusS,"Design system"),elevation24:ht.external(dt.elevation24,"Design system")};class Ri extends ut{constructor(){super(...arguments),this.opened=!1,this.closeOnEsc=!1,this.closeOnClickOutside=!1,this.closable=!1,this.heading="",this.icon=""}static get styles(){return y`
640
+ <ft-icon variant="material">${this.icon}</ft-icon> `:K}focus(){var t;null===(t=this.button)||void 0===t||t.focus()}getLabel(){return this.label||this.textContent}get textContent(){return this.unslotText(this.slottedContent).trim()}unslotText(t){return t instanceof HTMLSlotElement?t.assignedNodes().map((t=>this.unslotText(t))).join(""):(null==t?void 0:t.textContent)||""}hasTextContent(){return this.textContent.length>0}onSlotchange(){this.requestUpdate()}isDisabled(){return this.disabled||this.loading}}Ci.elementDefinitions={"ft-ripple":hi,"ft-tooltip":vi,"ft-typography":_e,"ft-icon":Qe,"ft-loader":bi},mi([o({type:Boolean})],Ci.prototype,"primary",void 0),mi([o({type:Boolean})],Ci.prototype,"outlined",void 0),mi([o({type:Boolean})],Ci.prototype,"disabled",void 0),mi([o({type:Boolean})],Ci.prototype,"dense",void 0),mi([o({type:Boolean})],Ci.prototype,"round",void 0),mi([o({type:String})],Ci.prototype,"label",void 0),mi([o({type:String})],Ci.prototype,"icon",void 0),mi([o({type:Boolean})],Ci.prototype,"trailingIcon",void 0),mi([o({type:Boolean})],Ci.prototype,"loading",void 0),mi([o({type:String})],Ci.prototype,"tooltipPosition",void 0),mi([r(".ft-button")],Ci.prototype,"button",void 0),mi([r(".ft-button--label slot")],Ci.prototype,"slottedContent",void 0),p("ft-button")(Ci);var Ni=function(t,e,i,o){for(var n,s=arguments.length,r=s<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o,a=t.length-1;a>=0;a--)(n=t[a])&&(r=(s<3?n(r):s>3?n(e,i,r):n(e,i))||r);return s>3&&r&&Object.defineProperty(e,i,r),r};const Ei={zIndex:ht.create("--ft-dialog-z-index","NUMBER","2"),overlayBackgroundColor:ht.create("--ft-dialog-overlay-background-color","COLOR","rgba(0, 0, 0, 0.3)"),height:ht.create("--ft-dialog-height","SIZE","unset"),width:ht.create("--ft-dialog-width","SIZE","unset"),minWidth:ht.create("--ft-dialog-min-width","SIZE","unset"),paddingTop:ht.create("--ft-dialog-padding-top","SIZE","20px"),paddingSide:ht.create("--ft-dialog-padding-side","SIZE","16px"),paddingButtons:ht.create("--ft-dialog-padding-buttons","SIZE","20px"),colorSurface:ht.external(dt.colorSurface,"Design system"),headingColor:ht.external(dt.colorOnSurfaceMedium,"Design system"),borderRadiusS:ht.external(dt.borderRadiusS,"Design system"),elevation24:ht.external(dt.elevation24,"Design system")};class Ri extends ut{constructor(){super(...arguments),this.opened=!1,this.closeOnEsc=!1,this.closeOnClickOutside=!1,this.closable=!1,this.beforeClose=()=>!0,this.heading="",this.icon=""}static get styles(){return y`
641
641
  .ft-dialog {
642
642
  position: fixed;
643
643
  top: 0;
@@ -745,4 +745,4 @@ function(t,e,i){let o,n=t;return"object"==typeof t?(n=t.slot,o=t):o={flatten:e},
745
745
  </div>
746
746
  </div>
747
747
  </div>
748
- `:null}updated(t){if(t.has("opened")){const t=new CustomEvent("opened-changed",{detail:{opened:this.opened}});this.dispatchEvent(t)}}connectedCallback(){super.connectedCallback(),document.addEventListener("keydown",this.watchEscapeKey.bind(this))}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("keydown",this.watchEscapeKey.bind(this))}close(){this.opened=!1}open(){this.opened=!0}watchEscapeKey(t){"Escape"===t.key&&this.closeOnEsc&&this.close()}watchClickOutside(){this.closeOnClickOutside&&this.close()}}Ri.elementDefinitions={"ft-typography":_e,"ft-icon":Qe,"ft-button":Ci},Ni([o({type:Boolean,hasChanged:(t,e)=>!1===e&&!0===t||!0===e&&!1===t})],Ri.prototype,"opened",void 0),Ni([o({type:Boolean})],Ri.prototype,"closeOnEsc",void 0),Ni([o({type:Boolean})],Ri.prototype,"closeOnClickOutside",void 0),Ni([o({type:Boolean})],Ri.prototype,"closable",void 0),Ni([o({type:String})],Ri.prototype,"heading",void 0),Ni([o({type:String})],Ri.prototype,"icon",void 0),p("ft-dialog")(Ri),t.FtDialog=Ri,t.FtDialogCssVariables=Ei,t.default=Ri,Object.defineProperty(t,"i",{value:!0})}({});
748
+ `:null}updated(t){if(t.has("opened")){const t=new CustomEvent("opened-changed",{detail:{opened:this.opened}});this.dispatchEvent(t)}}connectedCallback(){super.connectedCallback(),document.addEventListener("keydown",this.watchEscapeKey.bind(this))}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("keydown",this.watchEscapeKey.bind(this))}close(){this.beforeClose()&&(this.opened=!1)}open(){this.opened=!0}watchEscapeKey(t){"Escape"===t.key&&this.closeOnEsc&&this.close()}watchClickOutside(){this.closeOnClickOutside&&this.close()}}Ri.elementDefinitions={"ft-typography":_e,"ft-icon":Qe,"ft-button":Ci},Ni([o({type:Boolean,hasChanged:(t,e)=>!1===e&&!0===t||!0===e&&!1===t})],Ri.prototype,"opened",void 0),Ni([o({type:Boolean})],Ri.prototype,"closeOnEsc",void 0),Ni([o({type:Boolean})],Ri.prototype,"closeOnClickOutside",void 0),Ni([o({type:Boolean})],Ri.prototype,"closable",void 0),Ni([o({type:()=>Boolean})],Ri.prototype,"beforeClose",void 0),Ni([o({type:String})],Ri.prototype,"heading",void 0),Ni([o({type:String})],Ri.prototype,"icon",void 0),p("ft-dialog")(Ri),t.FtDialog=Ri,t.FtDialogCssVariables=Ei,t.default=Ri,Object.defineProperty(t,"i",{value:!0})}({});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-dialog",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "A simple dialog component",
5
5
  "keywords": [
6
6
  "Lit"
@@ -19,11 +19,11 @@
19
19
  "url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
20
20
  },
21
21
  "dependencies": {
22
- "@fluid-topics/ft-button": "0.3.1",
23
- "@fluid-topics/ft-icon": "0.3.1",
24
- "@fluid-topics/ft-typography": "0.3.1",
25
- "@fluid-topics/ft-wc-utils": "0.3.1",
22
+ "@fluid-topics/ft-button": "0.3.2",
23
+ "@fluid-topics/ft-icon": "0.3.2",
24
+ "@fluid-topics/ft-typography": "0.3.2",
25
+ "@fluid-topics/ft-wc-utils": "0.3.2",
26
26
  "lit": "2.2.8"
27
27
  },
28
- "gitHead": "59991498f66c54210024c0fc6702955901f94952"
28
+ "gitHead": "c1ecfa5c8c0216ac178b5d8363142c3db3d75ef9"
29
29
  }