@progressive-development/pd-dialog 0.9.1 → 1.0.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.
Files changed (35) hide show
  1. package/LICENSE +21 -2
  2. package/README.md +34 -57
  3. package/dist/index.d.ts +5 -0
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +2 -0
  6. package/dist/pd-confirm-dialog/PdConfirmDialog.d.ts +40 -0
  7. package/dist/pd-confirm-dialog/PdConfirmDialog.d.ts.map +1 -0
  8. package/dist/pd-confirm-dialog/PdConfirmDialog.js +108 -0
  9. package/dist/pd-confirm-dialog/pd-confirm-dialog.d.ts +7 -0
  10. package/dist/pd-confirm-dialog/pd-confirm-dialog.d.ts.map +1 -0
  11. package/dist/pd-confirm-dialog/pd-confirm-dialog.stories.d.ts +107 -0
  12. package/dist/pd-confirm-dialog/pd-confirm-dialog.stories.d.ts.map +1 -0
  13. package/dist/pd-form-dialog/PdFormDialog.d.ts +54 -0
  14. package/dist/pd-form-dialog/PdFormDialog.d.ts.map +1 -0
  15. package/dist/pd-form-dialog/PdFormDialog.js +181 -0
  16. package/dist/pd-form-dialog/pd-form-dialog.d.ts +6 -0
  17. package/dist/pd-form-dialog/pd-form-dialog.d.ts.map +1 -0
  18. package/dist/pd-form-dialog/pd-form-dialog.stories.d.ts +118 -0
  19. package/dist/pd-form-dialog/pd-form-dialog.stories.d.ts.map +1 -0
  20. package/dist/pd-popup/PdPopup.d.ts +36 -6
  21. package/dist/pd-popup/PdPopup.d.ts.map +1 -1
  22. package/dist/pd-popup/PdPopup.js +98 -29
  23. package/dist/pd-popup/pd-popup.stories.d.ts +56 -22
  24. package/dist/pd-popup/pd-popup.stories.d.ts.map +1 -1
  25. package/dist/pd-popup-dialog/PdPopupDialog.d.ts +36 -9
  26. package/dist/pd-popup-dialog/PdPopupDialog.d.ts.map +1 -1
  27. package/dist/pd-popup-dialog/PdPopupDialog.js +90 -50
  28. package/dist/pd-popup-dialog/pd-popup-dialog.stories.d.ts +52 -18
  29. package/dist/pd-popup-dialog/pd-popup-dialog.stories.d.ts.map +1 -1
  30. package/dist/pd-submit-dialog/PdSubmitDialog.d.ts +8 -4
  31. package/dist/pd-submit-dialog/PdSubmitDialog.d.ts.map +1 -1
  32. package/dist/pd-submit-dialog/PdSubmitDialog.js +0 -2
  33. package/dist/pd-submit-dialog/pd-submit-dialog.stories.d.ts +46 -29
  34. package/dist/pd-submit-dialog/pd-submit-dialog.stories.d.ts.map +1 -1
  35. package/package.json +10 -7
package/LICENSE CHANGED
@@ -1,2 +1,21 @@
1
- No License, all rights reserved
2
- @2021 - PD Progressive Development UG
1
+ MIT License
2
+
3
+ Copyright (c) 2021-present PD Progressive Development UG
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,76 +1,53 @@
1
- # \<pd-dialog>
1
+ # @progressive-development/pd-dialog
2
2
 
3
- This webcomponent follows the [open-wc](https://github.com/open-wc/open-wc) recommendation.
3
+ [![npm version](https://img.shields.io/npm/v/@progressive-development/pd-dialog.svg)](https://www.npmjs.com/package/@progressive-development/pd-dialog)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
5
+
6
+ Dialog and popup components for modals, confirmations, and form submissions.
7
+
8
+ ## Features
9
+
10
+ - **Lit 3 & TypeScript** – Modern, type-safe web components
11
+ - **Accessible** – WCAG 2.1 compliant, keyboard navigation, ARIA support
12
+ - **Themeable** – CSS Custom Properties for easy customization
13
+ - **Localized** – Built-in i18n support (EN, DE, BE)
14
+ - **Lightweight** – No heavy dependencies, tree-shakeable
15
+ - **Framework-agnostic** – Works with React, Vue, Angular, or vanilla JS
16
+ - **Flexible Close Strategies** – Close via Escape key, backdrop click, or programmatically
17
+ - **Multi-State Submit Dialog** – Visual progression through send, success, and error states
18
+ - **Configurable Buttons** – Typed button arrays with primary/disabled states and event delegation
19
+ - **Full ARIA Support** – Proper dialog roles, modal behavior, and focus management
4
20
 
5
21
  ## Installation
6
22
 
7
23
  ```bash
8
- npm i pd-dialog
24
+ npm install @progressive-development/pd-dialog
9
25
  ```
10
26
 
11
- ## Usage
27
+ ## Quick Start
12
28
 
13
29
  ```html
14
30
  <script type="module">
15
- import 'pd-dialog/pd-dialog.js';
31
+ import '@progressive-development/pd-dialog';
16
32
  </script>
17
33
 
18
- <pd-dialog></pd-dialog>
34
+ <pd-popup-dialog title="Confirm">
35
+ <p>Are you sure?</p>
36
+ </pd-popup-dialog>
19
37
  ```
20
38
 
21
- ## Linting and formatting
39
+ ## Components
22
40
 
23
- To scan the project for linting and formatting errors, run
41
+ | Component | Description |
42
+ |-----------|-------------|
43
+ | `<pd-popup>` | Basic popup container |
44
+ | `<pd-popup-dialog>` | Modal dialog with header, content, and footer |
45
+ | `<pd-submit-dialog>` | Form submission dialog with loading/success/error states |
24
46
 
25
- ```bash
26
- npm run lint
27
- ```
28
-
29
- To automatically fix linting and formatting errors, run
30
-
31
- ```bash
32
- npm run format
33
- ```
47
+ ## Documentation
34
48
 
35
- ## Testing with Web Test Runner
36
-
37
- To execute a single test run:
38
-
39
- ```bash
40
- npm run test
41
- ```
42
-
43
- To run the tests in interactive watch mode run:
44
-
45
- ```bash
46
- npm run test:watch
47
- ```
49
+ 📖 **Full documentation:** [pd-components.web.app](https://pd-components.web.app/)
48
50
 
49
- ## Demoing with Storybook
50
-
51
- To run a local instance of Storybook for your component, run
52
-
53
- ```bash
54
- npm run storybook
55
- ```
56
-
57
- To build a production version of Storybook, run
58
-
59
- ```bash
60
- npm run storybook:build
61
- ```
62
-
63
-
64
- ## Tooling configs
65
-
66
- For most of the tools, the configuration is in the `package.json` to minimize the amount of files in your project.
67
-
68
- If you customize the configuration a lot, you can consider moving them to individual files.
69
-
70
- ## Local Demo with `web-dev-server`
71
-
72
- ```bash
73
- npm start
74
- ```
51
+ ## License
75
52
 
76
- To run a local development server that serves the basic demo located in `demo/index.html`
53
+ MIT © [PD Progressive Development UG](https://progressive-development.com)
package/dist/index.d.ts CHANGED
@@ -1,6 +1,11 @@
1
1
  export { PdPopup } from './pd-popup/pd-popup.js';
2
2
  export { PdPopupDialog } from './pd-popup-dialog/pd-popup-dialog.js';
3
3
  export { PdSubmitDialog } from './pd-submit-dialog/pd-submit-dialog.js';
4
+ export { PdConfirmDialog } from './pd-confirm-dialog/pd-confirm-dialog.js';
5
+ export { BUTTON_KEY_CANCEL, BUTTON_KEY_CONFIRM, EVENT_CONFIRM, EVENT_CANCEL, } from './pd-confirm-dialog/pd-confirm-dialog.js';
6
+ export type { PdDialogType } from './pd-confirm-dialog/pd-confirm-dialog.js';
7
+ export { PdFormDialog } from './pd-form-dialog/pd-form-dialog.js';
8
+ export { EVENT_FORM_SUBMIT } from './pd-form-dialog/pd-form-dialog.js';
4
9
  export type { PdDialogButton, PdSubmitDialogProps, PdSubmitDialogStatus, } from './types.js';
5
10
  export { templates as beTemplates } from './generated/locales/be.js';
6
11
  export { templates as deTemplates } from './generated/locales/de.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAExE,YAAY,EACV,cAAc,EACd,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAGxE,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,YAAY,GACb,MAAM,0CAA0C,CAAC;AAClD,YAAY,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAE7E,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAGvE,YAAY,EACV,cAAc,EACd,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,2BAA2B,CAAC"}
package/dist/index.js CHANGED
@@ -1,6 +1,8 @@
1
1
  import './pd-popup.js';
2
2
  import './pd-popup-dialog.js';
3
3
  import './pd-submit-dialog.js';
4
+ export { BUTTON_KEY_CANCEL, BUTTON_KEY_CONFIRM, EVENT_CANCEL, EVENT_CONFIRM, PdConfirmDialog } from './pd-confirm-dialog/PdConfirmDialog.js';
5
+ export { EVENT_FORM_SUBMIT, PdFormDialog } from './pd-form-dialog/PdFormDialog.js';
4
6
  export { templates as beTemplates } from './locales/be.js';
5
7
  export { templates as deTemplates } from './locales/de.js';
6
8
  export { templates as enTemplates } from './locales/en.js';
@@ -0,0 +1,40 @@
1
+ import { LitElement, CSSResultGroup, HTMLTemplateResult } from 'lit';
2
+ /** Button key for cancel/abort action */
3
+ export declare const BUTTON_KEY_CANCEL = "cancel";
4
+ /** Button key for confirm/ok action */
5
+ export declare const BUTTON_KEY_CONFIRM = "confirm";
6
+ /** Event name fired when dialog is confirmed */
7
+ export declare const EVENT_CONFIRM = "pd-dialog-confirm";
8
+ /** Event name fired when dialog is cancelled */
9
+ export declare const EVENT_CANCEL = "pd-dialog-cancel";
10
+ /** Available dialog types with corresponding icons */
11
+ export type PdDialogType = "info" | "help" | "warn" | "error";
12
+ export declare abstract class PdConfirmDialog extends LitElement {
13
+ /** Dialog title text */
14
+ protected abstract _dialogTitle: string;
15
+ /** Dialog type for icon display */
16
+ protected abstract _dialogType: PdDialogType;
17
+ /** Whether to show only a single confirm button (no cancel) */
18
+ protected abstract _singleButton: boolean;
19
+ /** Text for the confirm/OK button */
20
+ confirmButtonText: string;
21
+ /** Text for the cancel button */
22
+ cancelButtonText: string;
23
+ /** Enable closing with Escape key */
24
+ closeByEscape: boolean;
25
+ /** Enable closing by clicking the backdrop */
26
+ closeByBackdrop: boolean;
27
+ static styles: CSSResultGroup;
28
+ render(): import('lit').TemplateResult<1>;
29
+ /** Render the dialog content */
30
+ protected abstract _renderContent(): HTMLTemplateResult;
31
+ /**
32
+ * Handle button click events.
33
+ * Override to customize behavior.
34
+ */
35
+ protected _handleButtonClick(e: CustomEvent<{
36
+ button: string;
37
+ }>): void;
38
+ private _generateButtons;
39
+ }
40
+ //# sourceMappingURL=PdConfirmDialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PdConfirmDialog.d.ts","sourceRoot":"","sources":["../../src/pd-confirm-dialog/PdConfirmDialog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,UAAU,EAAa,cAAc,EAAE,kBAAkB,EAAE,MAAM,KAAK,CAAC;AAGhF,OAAO,uCAAuC,CAAC;AAM/C,yCAAyC;AACzC,eAAO,MAAM,iBAAiB,WAAW,CAAC;AAE1C,uCAAuC;AACvC,eAAO,MAAM,kBAAkB,YAAY,CAAC;AAE5C,gDAAgD;AAChD,eAAO,MAAM,aAAa,sBAAsB,CAAC;AAEjD,gDAAgD;AAChD,eAAO,MAAM,YAAY,qBAAqB,CAAC;AAM/C,sDAAsD;AACtD,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAM9D,8BAAsB,eAAgB,SAAQ,UAAU;IAKtD,wBAAwB;IACxB,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAExC,mCAAmC;IACnC,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,YAAY,CAAC;IAE7C,+DAA+D;IAC/D,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAM1C,qCAAqC;IAErC,iBAAiB,SAAQ;IAEzB,iCAAiC;IAEjC,gBAAgB,SAAY;IAE5B,qCAAqC;IAErC,aAAa,UAAS;IAEtB,8CAA8C;IAE9C,eAAe,UAAS;IAMxB,MAAM,CAAC,MAAM,EAWR,cAAc,CAAC;IAMpB,MAAM;IAmBN,gCAAgC;IAChC,SAAS,CAAC,QAAQ,CAAC,cAAc,IAAI,kBAAkB;IAMvD;;;OAGG;IACH,SAAS,CAAC,kBAAkB,CAAC,CAAC,EAAE,WAAW,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAc/D,OAAO,CAAC,gBAAgB;CAezB"}
@@ -0,0 +1,108 @@
1
+ import { LitElement, css, html } from 'lit';
2
+ import { property } from 'lit/decorators.js';
3
+ import '../pd-popup-dialog.js';
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __decorateClass = (decorators, target, key, kind) => {
7
+ var result = void 0 ;
8
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
9
+ if (decorator = decorators[i])
10
+ result = (decorator(target, key, result) ) || result;
11
+ if (result) __defProp(target, key, result);
12
+ return result;
13
+ };
14
+ const BUTTON_KEY_CANCEL = "cancel";
15
+ const BUTTON_KEY_CONFIRM = "confirm";
16
+ const EVENT_CONFIRM = "pd-dialog-confirm";
17
+ const EVENT_CANCEL = "pd-dialog-cancel";
18
+ class PdConfirmDialog extends LitElement {
19
+ constructor() {
20
+ super(...arguments);
21
+ this.confirmButtonText = "Ok";
22
+ this.cancelButtonText = "Cancel";
23
+ this.closeByEscape = false;
24
+ this.closeByBackdrop = false;
25
+ }
26
+ static {
27
+ // ---------------------------------------------------------------------------
28
+ // Styles
29
+ // ---------------------------------------------------------------------------
30
+ this.styles = css`
31
+ :host {
32
+ display: block;
33
+ --pd-popup-max-width: var(--pd-confirm-dialog-max-width, 600px);
34
+ }
35
+
36
+ @media (max-width: 767px) {
37
+ :host {
38
+ --pd-popup-max-width: 90%;
39
+ }
40
+ }
41
+ `;
42
+ }
43
+ // ---------------------------------------------------------------------------
44
+ // Render
45
+ // ---------------------------------------------------------------------------
46
+ render() {
47
+ return html`
48
+ <pd-popup-dialog
49
+ @submit-button-clicked="${this._handleButtonClick}"
50
+ title="${this._dialogTitle}"
51
+ .buttons="${this._generateButtons()}"
52
+ type="${this._dialogType}"
53
+ ?closeByEscape="${this.closeByEscape}"
54
+ ?closeByBackdrop="${this.closeByBackdrop}"
55
+ >
56
+ <div slot="content">${this._renderContent()}</div>
57
+ </pd-popup-dialog>
58
+ `;
59
+ }
60
+ // ---------------------------------------------------------------------------
61
+ // Protected Methods (can be overridden)
62
+ // ---------------------------------------------------------------------------
63
+ /**
64
+ * Handle button click events.
65
+ * Override to customize behavior.
66
+ */
67
+ _handleButtonClick(e) {
68
+ const isConfirm = e.detail.button === BUTTON_KEY_CONFIRM;
69
+ this.dispatchEvent(
70
+ new CustomEvent(isConfirm ? EVENT_CONFIRM : EVENT_CANCEL, {
71
+ bubbles: true,
72
+ composed: true
73
+ })
74
+ );
75
+ }
76
+ // ---------------------------------------------------------------------------
77
+ // Private Methods
78
+ // ---------------------------------------------------------------------------
79
+ _generateButtons() {
80
+ if (this._singleButton) {
81
+ return [
82
+ {
83
+ key: BUTTON_KEY_CONFIRM,
84
+ name: this.confirmButtonText,
85
+ primary: true
86
+ }
87
+ ];
88
+ }
89
+ return [
90
+ { key: BUTTON_KEY_CANCEL, name: this.cancelButtonText },
91
+ { key: BUTTON_KEY_CONFIRM, name: this.confirmButtonText, primary: true }
92
+ ];
93
+ }
94
+ }
95
+ __decorateClass([
96
+ property({ type: String })
97
+ ], PdConfirmDialog.prototype, "confirmButtonText");
98
+ __decorateClass([
99
+ property({ type: String })
100
+ ], PdConfirmDialog.prototype, "cancelButtonText");
101
+ __decorateClass([
102
+ property({ type: Boolean })
103
+ ], PdConfirmDialog.prototype, "closeByEscape");
104
+ __decorateClass([
105
+ property({ type: Boolean })
106
+ ], PdConfirmDialog.prototype, "closeByBackdrop");
107
+
108
+ export { BUTTON_KEY_CANCEL, BUTTON_KEY_CONFIRM, EVENT_CANCEL, EVENT_CONFIRM, PdConfirmDialog };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * PdConfirmDialog barrel export
3
+ */
4
+ export { PdConfirmDialog } from './PdConfirmDialog.js';
5
+ export { BUTTON_KEY_CANCEL, BUTTON_KEY_CONFIRM, EVENT_CONFIRM, EVENT_CANCEL, } from './PdConfirmDialog.js';
6
+ export type { PdDialogType } from './PdConfirmDialog.js';
7
+ //# sourceMappingURL=pd-confirm-dialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pd-confirm-dialog.d.ts","sourceRoot":"","sources":["../../src/pd-confirm-dialog/pd-confirm-dialog.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,YAAY,GACb,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,107 @@
1
+ import { HTMLTemplateResult, CSSResultGroup } from 'lit';
2
+ import { Meta, StoryObj } from '@storybook/web-components-vite';
3
+ import { PdConfirmDialog, PdDialogType } from './PdConfirmDialog.js';
4
+ /**
5
+ * Example: Simple confirm dialog with warning
6
+ */
7
+ declare class ExampleDeleteConfirm extends PdConfirmDialog {
8
+ protected _dialogTitle: string;
9
+ protected _dialogType: PdDialogType;
10
+ protected _singleButton: boolean;
11
+ itemName: string;
12
+ protected _renderContent(): HTMLTemplateResult;
13
+ }
14
+ /**
15
+ * Example: Info dialog with single button
16
+ */
17
+ declare class ExampleInfoDialog extends PdConfirmDialog {
18
+ protected _dialogTitle: string;
19
+ protected _dialogType: PdDialogType;
20
+ protected _singleButton: boolean;
21
+ message: string;
22
+ protected _renderContent(): HTMLTemplateResult;
23
+ }
24
+ /**
25
+ * Example: Error dialog with custom content
26
+ */
27
+ declare class ExampleErrorDialog extends PdConfirmDialog {
28
+ protected _dialogTitle: string;
29
+ protected _dialogType: PdDialogType;
30
+ protected _singleButton: boolean;
31
+ errorCode: string;
32
+ errorMessage: string;
33
+ static styles: CSSResultGroup;
34
+ protected _renderContent(): HTMLTemplateResult;
35
+ }
36
+ /**
37
+ * Example: Help dialog with formatted content
38
+ */
39
+ declare class ExampleHelpDialog extends PdConfirmDialog {
40
+ protected _dialogTitle: string;
41
+ protected _dialogType: PdDialogType;
42
+ protected _singleButton: boolean;
43
+ static styles: CSSResultGroup;
44
+ protected _renderContent(): HTMLTemplateResult;
45
+ }
46
+ declare global {
47
+ interface HTMLElementTagNameMap {
48
+ "example-delete-confirm": ExampleDeleteConfirm;
49
+ "example-info-dialog": ExampleInfoDialog;
50
+ "example-error-dialog": ExampleErrorDialog;
51
+ "example-help-dialog": ExampleHelpDialog;
52
+ }
53
+ }
54
+ /**
55
+ * Story arguments interface for pd-confirm-dialog examples.
56
+ * Maps to the example components' properties.
57
+ */
58
+ interface PdConfirmDialogArgs {
59
+ /** Item name for delete confirmation */
60
+ itemName: string;
61
+ /** Confirm button text */
62
+ confirmButtonText: string;
63
+ /** Cancel button text */
64
+ cancelButtonText: string;
65
+ /** Enable closing with Escape key */
66
+ closeByEscape: boolean;
67
+ /** Enable closing by clicking the backdrop */
68
+ closeByBackdrop: boolean;
69
+ }
70
+ /**
71
+ * ## PdConfirmDialog (Abstract Base Class)
72
+ *
73
+ * Abstract base class for creating standardized confirmation dialogs.
74
+ * Not used directly -- extend it and implement the required abstract members.
75
+ *
76
+ * ### Features
77
+ * - Dialog types: info, warn, error, help with corresponding icons
78
+ * - Two-button mode (confirm + cancel) or single-button mode
79
+ * - Configurable button text via properties
80
+ * - Escape key and backdrop click close support
81
+ * - Standardized events: `pd-dialog-confirm` and `pd-dialog-cancel`
82
+ *
83
+ * ### How to Extend
84
+ * Implement these abstract members:
85
+ * - `_dialogTitle`: Dialog title string
86
+ * - `_dialogType`: One of `"info" | "warn" | "error" | "help"`
87
+ * - `_singleButton`: `true` for single confirm button, `false` for confirm + cancel
88
+ * - `_renderContent()`: Returns the dialog body as `HTMLTemplateResult`
89
+ *
90
+ * ### Exported Constants
91
+ * - `BUTTON_KEY_CONFIRM` / `BUTTON_KEY_CANCEL`: Button key identifiers
92
+ * - `EVENT_CONFIRM` / `EVENT_CANCEL`: Event name constants
93
+ */
94
+ declare const meta: Meta<PdConfirmDialogArgs>;
95
+ export default meta;
96
+ type Story = StoryObj<PdConfirmDialogArgs>;
97
+ /** Warning dialog with confirm and cancel buttons. Typical use case: Delete confirmation. */
98
+ export declare const Default: Story;
99
+ /** Overview of all four dialog types: warning, info, error, and help. */
100
+ export declare const AllTypes: Story;
101
+ /** Info dialog with single button -- typical success notification. */
102
+ export declare const InfoNotification: Story;
103
+ /** Error dialog with styled error details section. */
104
+ export declare const ErrorWithDetails: Story;
105
+ /** Help dialog with formatted keyboard shortcuts list. */
106
+ export declare const HelpDialog: Story;
107
+ //# sourceMappingURL=pd-confirm-dialog.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pd-confirm-dialog.stories.d.ts","sourceRoot":"","sources":["../../src/pd-confirm-dialog/pd-confirm-dialog.stories.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAa,kBAAkB,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAEpE,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAErE,OAAO,EACL,eAAe,EACf,YAAY,EAGb,MAAM,sBAAsB,CAAC;AAM9B;;GAEG;AACH,cACM,oBAAqB,SAAQ,eAAe;IAChD,SAAS,CAAC,YAAY,SAAiB;IACvC,SAAS,CAAC,WAAW,EAAE,YAAY,CAAU;IAC7C,SAAS,CAAC,aAAa,UAAS;IAGhC,QAAQ,SAAe;IAEvB,SAAS,CAAC,cAAc,IAAI,kBAAkB;CAM/C;AAED;;GAEG;AACH,cACM,iBAAkB,SAAQ,eAAe;IAC7C,SAAS,CAAC,YAAY,SAAiB;IACvC,SAAS,CAAC,WAAW,EAAE,YAAY,CAAU;IAC7C,SAAS,CAAC,aAAa,UAAQ;IAG/B,OAAO,SAAuC;IAE9C,SAAS,CAAC,cAAc,IAAI,kBAAkB;CAG/C;AAED;;GAEG;AACH,cACM,kBAAmB,SAAQ,eAAe;IAC9C,SAAS,CAAC,YAAY,SAAoB;IAC1C,SAAS,CAAC,WAAW,EAAE,YAAY,CAAW;IAC9C,SAAS,CAAC,aAAa,UAAQ;IAG/B,SAAS,SAAU;IAGnB,YAAY,SAAmC;IAE/C,MAAM,CAAC,MAAM,EAaR,cAAc,CAAC;IAEpB,SAAS,CAAC,cAAc,IAAI,kBAAkB;CAM/C;AAED;;GAEG;AACH,cACM,iBAAkB,SAAQ,eAAe;IAC7C,SAAS,CAAC,YAAY,SAAwB;IAC9C,SAAS,CAAC,WAAW,EAAE,YAAY,CAAU;IAC7C,SAAS,CAAC,aAAa,UAAQ;IAE/B,MAAM,CAAC,MAAM,EAoBR,cAAc,CAAC;IAEpB,SAAS,CAAC,cAAc,IAAI,kBAAkB;CAY/C;AAGD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,wBAAwB,EAAE,oBAAoB,CAAC;QAC/C,qBAAqB,EAAE,iBAAiB,CAAC;QACzC,sBAAsB,EAAE,kBAAkB,CAAC;QAC3C,qBAAqB,EAAE,iBAAiB,CAAC;KAC1C;CACF;AAMD;;;GAGG;AACH,UAAU,mBAAmB;IAC3B,wCAAwC;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,0BAA0B;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,yBAAyB;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,qCAAqC;IACrC,aAAa,EAAE,OAAO,CAAC;IACvB,8CAA8C;IAC9C,eAAe,EAAE,OAAO,CAAC;CAC1B;AAMD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,mBAAmB,CAgFnC,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,mBAAmB,CAAC,CAAC;AAM3C,6FAA6F;AAC7F,eAAO,MAAM,OAAO,EAAE,KAUrB,CAAC;AAMF,yEAAyE;AACzE,eAAO,MAAM,QAAQ,EAAE,KAmDtB,CAAC;AAMF,sEAAsE;AACtE,eAAO,MAAM,gBAAgB,EAAE,KAoB9B,CAAC;AAMF,sDAAsD;AACtD,eAAO,MAAM,gBAAgB,EAAE,KAqB9B,CAAC;AAMF,0DAA0D;AAC1D,eAAO,MAAM,UAAU,EAAE,KAmBxB,CAAC"}
@@ -0,0 +1,54 @@
1
+ import { LitElement, CSSResultGroup, HTMLTemplateResult } from 'lit';
2
+ /** Event name fired when form is submitted with valid data */
3
+ export declare const EVENT_FORM_SUBMIT = "pd-form-submit";
4
+ export declare abstract class PdFormDialog<T> extends LitElement {
5
+ /** Form data object - managed by subclass */
6
+ protected abstract _formData: T;
7
+ /** Dialog title text */
8
+ protected abstract _dialogTitle: string;
9
+ /** Text for the save/submit button */
10
+ saveButtonText: string;
11
+ /** Text for the cancel button */
12
+ cancelButtonText: string;
13
+ /** Whether to show required field info text */
14
+ showRequiredFieldInfo: boolean;
15
+ /** Timeout in ms to disable save button after submit (prevents double-submit) */
16
+ submitDisableTimeout: number;
17
+ /** Enable closing with Escape key */
18
+ closeByEscape: boolean;
19
+ /** Enable closing by clicking the backdrop overlay */
20
+ closeByBackdrop: boolean;
21
+ /** Block body scroll when dialog is open */
22
+ blockScroll: boolean;
23
+ /** Whether the form is currently valid */
24
+ protected _validForm: boolean;
25
+ /** Common validation error message to display */
26
+ protected _validationError?: string;
27
+ /** Internal button configuration */
28
+ private _buttons;
29
+ private _formContainer;
30
+ static styles: CSSResultGroup;
31
+ constructor();
32
+ render(): import('lit').TemplateResult<1>;
33
+ /** Render the form fields content */
34
+ protected abstract _renderContent(): HTMLTemplateResult;
35
+ /**
36
+ * Additional validation beyond form field validation.
37
+ * Return true if form data is valid.
38
+ */
39
+ protected abstract _isValidFormData(): boolean;
40
+ /** Reset the form to initial state */
41
+ reset(): void;
42
+ /**
43
+ * Handle button click events.
44
+ * Can be overridden for custom behavior.
45
+ */
46
+ protected _handleButtonClick(e: CustomEvent<{
47
+ button: string;
48
+ }>): void;
49
+ private _initializeButtons;
50
+ private _getButtons;
51
+ private _handleFormChange;
52
+ private _disableSaveButtonTemporarily;
53
+ }
54
+ //# sourceMappingURL=PdFormDialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PdFormDialog.d.ts","sourceRoot":"","sources":["../../src/pd-form-dialog/PdFormDialog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,UAAU,EAAa,cAAc,EAAE,kBAAkB,EAAE,MAAM,KAAK,CAAC;AAGhF,OAAO,qDAAqD,CAAC;AAE7D,OAAO,uCAAuC,CAAC;AAc/C,8DAA8D;AAC9D,eAAO,MAAM,iBAAiB,mBAAmB,CAAC;AAkBlD,8BAAsB,YAAY,CAAC,CAAC,CAAE,SAAQ,UAAU;IAKtD,6CAA6C;IAC7C,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC;IAEhC,wBAAwB;IACxB,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAMxC,sCAAsC;IAEtC,cAAc,SAAU;IAExB,iCAAiC;IAEjC,gBAAgB,SAAY;IAE5B,+CAA+C;IAE/C,qBAAqB,UAAQ;IAE7B,iFAAiF;IAEjF,oBAAoB,SAAkC;IAEtD,qCAAqC;IAErC,aAAa,UAAS;IAEtB,sDAAsD;IAEtD,eAAe,UAAS;IAExB,4CAA4C;IAE5C,WAAW,UAAS;IAMpB,0CAA0C;IAE1C,SAAS,CAAC,UAAU,UAAS;IAE7B,iDAAiD;IAEjD,SAAS,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAEpC,oCAAoC;IAEpC,OAAO,CAAC,QAAQ,CAA0B;IAO1C,OAAO,CAAC,cAAc,CAAmD;IAMzE,MAAM,CAAC,MAAM,EAWR,cAAc,CAAC;;IAepB,MAAM;IA0BN,qCAAqC;IACrC,SAAS,CAAC,QAAQ,CAAC,cAAc,IAAI,kBAAkB;IAEvD;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,gBAAgB,IAAI,OAAO;IAM9C,sCAAsC;IAC/B,KAAK,IAAI,IAAI;IAUpB;;;OAGG;IACH,SAAS,CAAC,kBAAkB,CAAC,CAAC,EAAE,WAAW,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAyB/D,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,iBAAiB;IAKzB,OAAO,CAAC,6BAA6B;CAMtC"}