@neovici/cosmoz-form 2.0.0 → 2.1.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.
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Props as DialogProps } from '@neovici/cosmoz-dialog';
|
|
2
2
|
import '@neovici/cosmoz-dialog/loading';
|
|
3
|
-
import { Props as AddProps } from '../use-validated-form$';
|
|
4
3
|
import '@neovici/cosmoz-spinner';
|
|
5
4
|
import { Renderable, Resolvable } from '../types';
|
|
5
|
+
import { Props as AddProps } from '../use-validated-form$';
|
|
6
6
|
interface Props<T extends object> extends DialogProps, AddProps<T> {
|
|
7
7
|
heading: string;
|
|
8
8
|
description?: Renderable;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-dialog.d.ts","sourceRoot":"","sources":["../../src/form-dialog/form-dialog.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"form-dialog.d.ts","sourceRoot":"","sources":["../../src/form-dialog/form-dialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,IAAI,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,gCAAgC,CAAC;AAExC,OAAO,yBAAyB,CAAC;AAWjC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,KAAK,IAAI,QAAQ,EAAqB,MAAM,wBAAwB,CAAC;AAG9E,UAAU,KAAK,CAAC,CAAC,SAAS,MAAM,CAAE,SAAQ,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC;IACjE,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,UAAU,CAAC;IACzB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAiDD,MAAM,WAAW,MAAM,CAAC,CAAC,SAAS,MAAM,CAAE,SAAQ,KAAK,CAAC,CAAC,CAAC;IACzD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,MAAM,EAAE,QAAQ,MAAM,CAAC,CAAC,CAAC,KAAG,UAoBhE,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,MAAM,EAAE,QAAQ,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;;;;EAIzE,CAAC"}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
+
import { dialog } from '@neovici/cosmoz-dialog';
|
|
2
|
+
import '@neovici/cosmoz-dialog/loading';
|
|
3
|
+
import { _ } from '@neovici/cosmoz-i18next';
|
|
4
|
+
import '@neovici/cosmoz-spinner';
|
|
5
|
+
import { portal } from '@neovici/cosmoz-utils/directives/portal';
|
|
6
|
+
import { invoke } from '@neovici/cosmoz-utils/function';
|
|
1
7
|
import { useEffect } from '@pionjs/pion';
|
|
2
8
|
import { html, nothing } from 'lit-html';
|
|
3
|
-
import { when } from 'lit-html/directives/when.js';
|
|
4
9
|
import { ifDefined } from 'lit-html/directives/if-defined.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import '@neovici/cosmoz-dialog/loading';
|
|
9
|
-
import buttonStyles from '../styles/button';
|
|
10
|
+
import { until } from 'lit-html/directives/until.js';
|
|
11
|
+
import { when } from 'lit-html/directives/when.js';
|
|
12
|
+
import { renderButton$, renderFailure$ } from '../add/render';
|
|
10
13
|
import { renderFields, renderStyles } from '../render';
|
|
11
|
-
import
|
|
14
|
+
import buttonStyles from '../styles/button';
|
|
12
15
|
import { useValidatedForm$ } from '../use-validated-form$';
|
|
13
|
-
import '@neovici/cosmoz-spinner';
|
|
14
16
|
import styles from './style.css';
|
|
15
|
-
import { invoke } from '@neovici/cosmoz-utils/function';
|
|
16
|
-
import { until } from 'lit-html/directives/until.js';
|
|
17
17
|
const FormDialog = (host) => {
|
|
18
18
|
const { description, auto, uncancelable, hideCancelButton, saveText = _('OK'), } = host, { onSave, disabled, save$, progress, ...form } = useValidatedForm$(host);
|
|
19
19
|
useEffect(() => {
|
|
@@ -35,11 +35,13 @@ const FormDialog = (host) => {
|
|
|
35
35
|
</button>`)}
|
|
36
36
|
</div>`;
|
|
37
37
|
};
|
|
38
|
+
customElements.define('cosmoz-form-dialog', dialog(FormDialog, { observedAttributes: ['allow-empty'] }));
|
|
39
|
+
// backwards-compat alias — consumers should migrate to <cosmoz-form-dialog>
|
|
38
40
|
customElements.define('cosmoz-form-dialog-next', dialog(FormDialog, { observedAttributes: ['allow-empty'] }));
|
|
39
41
|
export const formDialog = (props) => {
|
|
40
42
|
if (!props)
|
|
41
43
|
return nothing;
|
|
42
|
-
const dialog = html `<cosmoz-form-dialog
|
|
44
|
+
const dialog = html `<cosmoz-form-dialog
|
|
43
45
|
?backdrop=${props.backdrop ?? true}
|
|
44
46
|
name=${ifDefined(props.name)}
|
|
45
47
|
?allow-empty=${props.allowEmpty}
|
|
@@ -55,7 +57,7 @@ export const formDialog = (props) => {
|
|
|
55
57
|
.hideCancelButton=${props.hideCancelButton}
|
|
56
58
|
.manualFocus=${props.manualFocus}
|
|
57
59
|
.saveText=${props.saveText}
|
|
58
|
-
></cosmoz-form-dialog
|
|
60
|
+
></cosmoz-form-dialog>`;
|
|
59
61
|
return props.renderInPortal ? portal(dialog) : dialog;
|
|
60
62
|
};
|
|
61
63
|
export const formDialog$ = (props$) => until(Promise.resolve(invoke(props$)).then(formDialog, () => nothing), html `<cosmoz-dialog-loading></cosmoz-dialog-loading>`);
|