@optionfactory/fml 9.0.0-rc21 → 9.0.0-rc23

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/dist/ful.d.mts CHANGED
@@ -782,9 +782,21 @@ declare class Form extends ParsedElement {
782
782
  * A call while a submit is in flight returns at once, doing nothing.
783
783
  * @param {HTMLElement} [submitter] the button that submitted, if any; it is
784
784
  * the only button whose name and value are submitted
785
- * @returns {Promise<void>} settling once the submit has finished, whatever its outcome
785
+ * @returns {Promise<boolean>} settling once the submit has finished: true
786
+ * after `submit:success`, false when it failed, was cancelled or was dropped
787
+ * for one in flight
786
788
  */
787
- submit(submitter?: HTMLElement): Promise<void>;
789
+ submit(submitter?: HTMLElement): Promise<boolean>;
790
+ /**
791
+ * Saves the unsaved edits, for a page action that would lose them, such as
792
+ * one reloading the page: under `track-changes` it submits only while the
793
+ * form is dirty, and without it always submits.
794
+ * @param {HTMLElement} [submitter] as `submit` takes it
795
+ * @returns {Promise<boolean>} whether no unsaved edit is left: false when
796
+ * the submit did not succeed, or when the user edited the form while it
797
+ * was in flight
798
+ */
799
+ save(submitter?: HTMLElement): Promise<boolean>;
788
800
  /**
789
801
  * Resets the native form, each field returning to its default value. Under
790
802
  * `track-changes` every control counts as edited: the form is dirty if the
@@ -817,11 +829,11 @@ declare class Form extends ParsedElement {
817
829
  */
818
830
  commit(): void;
819
831
  /**
820
- * Counts a control as edited by the user, for a value the page writes on
832
+ * Counts controls as edited by the user, for values the page writes on
821
833
  * the user's behalf: assigning `value` reports nothing, as 0019 wants.
822
- * @param {Element} el the control, or an element inside it
834
+ * @param {...Element} els each a control, or an element inside one
823
835
  */
824
- edited(el: Element): void;
836
+ edited(...els: Element[]): void;
825
837
  /**
826
838
  * Marks the form busy or releases it. Calls nest: only the first
827
839
  * `spinner(true)` and the matching last `spinner(false)` act, so a caller's
@@ -2836,21 +2848,24 @@ export type DialogOutcome = {
2836
2848
  * and a press and release both on the backdrop close the dialog, each as a
2837
2849
  * dismissal, as Escape does.
2838
2850
  *
2839
- * Before any of those three gestures closes it, the element dispatches a
2840
- * cancelable, non-bubbling `dialog:dismiss` with `detail: { reason }`, the
2841
- * reason being `button`, `backdrop` or `escape`; a listener calling
2842
- * `preventDefault()` keeps it open, to guard unsaved edits. A `data-result`
2843
- * button, `close-on-submit` and `close()` answer rather than dismiss, and
2844
- * dispatch none.
2851
+ * Those three gestures go through `dismiss(reason)`, the reason being
2852
+ * `button`, `backdrop` or `escape`: before it closes the dialog, the element
2853
+ * dispatches a cancelable, non-bubbling `dialog:dismiss` with
2854
+ * `detail: { reason }`, and a listener calling `preventDefault()` keeps it
2855
+ * open. Under `guard-dismiss`, a dismissal nobody refused, while a `ful-form`
2856
+ * of the dialog holds unsaved edits (see `Form.dirty`), first asks the user,
2857
+ * through `Dialog.confirm`, whether to close and drop them. A `data-result`
2858
+ * button, `close-on-submit`, `close()` and `update()` are answers or the page
2859
+ * deciding: they dispatch nothing and ask nothing.
2845
2860
  *
2846
2861
  * The platform lets a page refuse Escape once per user interaction: a second
2847
2862
  * Escape with no click or keystroke in between closes the dialog whatever the
2848
- * page does, `requires-answer` included. That close is still announced by a
2849
- * `dialog:dismiss`, which is then not cancelable.
2863
+ * page does, `requires-answer` and `guard-dismiss` included. That close is
2864
+ * still announced by a `dialog:dismiss`, which is then not cancelable.
2850
2865
  *
2851
2866
  * `requires-answer` withholds the close button and refuses Escape and the
2852
2867
  * backdrop, so the dialog is closed only by a button carrying `data-result`
2853
- * or from code through `close()`.
2868
+ * or from code, through `close()` or `dismiss()`.
2854
2869
  *
2855
2870
  * `close-on-submit` closes the dialog when a `ful-form` that is a direct child
2856
2871
  * of the body dispatches `submit:success`, answering with its
@@ -2932,6 +2947,17 @@ declare class Dialog extends ParsedElement {
2932
2947
  * nobody answered or the request failed; it never rejects
2933
2948
  */
2934
2949
  refresh(): Promise<any[] | undefined>;
2950
+ /**
2951
+ * Dismisses the dialog as the user would: dispatches the cancelable
2952
+ * `dialog:dismiss` with `detail: { reason }` and, under `guard-dismiss`,
2953
+ * asks before dropping unsaved edits, closing the dialog as a dismissal
2954
+ * unless either refused. `requires-answer` does not refuse it, as it does
2955
+ * not refuse `close()`. Does nothing on a closed dialog.
2956
+ * @param {string} reason why it is dismissed, such as `navigation`
2957
+ * @returns {Promise<boolean>} whether the dialog is closed, false when a
2958
+ * listener or the user kept it open
2959
+ */
2960
+ dismiss(reason: string): Promise<boolean>;
2935
2961
  /**
2936
2962
  * Closes an open dialog, doing nothing on a closed one. A non-empty result
2937
2963
  * answers as the button carrying that `data-result` would; no result, or
@@ -2988,17 +3014,23 @@ declare class Dialog extends ParsedElement {
2988
3014
  * default, when absent) or `start`, following the writing direction.
2989
3015
  *
2990
3016
  * The close button, Escape, and a press and release both on the backdrop all
2991
- * go through `close()`, once a cancelable, non-bubbling `drawer:dismiss` with
2992
- * `detail: { reason }` (`button`, `backdrop` or `escape`) has been dispatched
2993
- * on the element and no listener prevented it: `preventDefault()` keeps the
2994
- * drawer open, to guard unsaved edits. `close()` and `close-on-submit`
2995
- * dispatch none. The platform lets a page refuse Escape once per user
3017
+ * go through `dismiss(reason)`, the reason being `button`, `backdrop` or
3018
+ * `escape`: before it closes the drawer, the element dispatches a cancelable,
3019
+ * non-bubbling `drawer:dismiss` with `detail: { reason }`, and a listener
3020
+ * calling `preventDefault()` keeps it open. Under `guard-dismiss`, a dismissal
3021
+ * nobody refused, while a `ful-form` of the drawer holds unsaved edits (see
3022
+ * `Form.dirty`), first asks the user, through `Dialog.confirm`, whether to
3023
+ * close and drop them. A `data-result` button, `close-on-submit`, `close()`
3024
+ * and `update()` are answers or the page deciding: they dispatch nothing and
3025
+ * ask nothing. The platform lets a page refuse Escape once per user
2996
3026
  * interaction: a second Escape with no click or keystroke in between closes
2997
- * the drawer at once, without the slide, and its `drawer:dismiss` is then not
2998
- * cancelable. Every close dispatches a non-bubbling `close` event on
2999
- * the element with `detail: { dismissed, response }`: `{ dismissed: false,
3000
- * response }` when a form closed it under `close-on-submit`, and
3001
- * `{ dismissed: true, response: null }` for any other close.
3027
+ * the drawer at once, without the slide, `guard-dismiss` included, and its
3028
+ * `drawer:dismiss` is then not cancelable.
3029
+ *
3030
+ * Any button inside the drawer carrying `data-result` closes it with that
3031
+ * result, an empty one being a dismissal. Every close dispatches a
3032
+ * non-bubbling `close` event on the element carrying the `DialogOutcome` as
3033
+ * `detail`, before the pending `ask()` calls resolve.
3002
3034
  *
3003
3035
  * `close-on-submit` closes the drawer when a `ful-form` that is a direct child
3004
3036
  * of the content section dispatches `submit:success`, carrying its
@@ -3053,8 +3085,23 @@ declare class Drawer extends ParsedElement {
3053
3085
  */
3054
3086
  refresh(): Promise<any[] | undefined>;
3055
3087
  /**
3056
- * Shows the drawer as a modal. On a drawer already open nothing happens,
3057
- * except that one sliding out stops and stays open.
3088
+ * Resolves every pending `ask()` and `open()` with the outcome so far,
3089
+ * a dismissal for a drawer still open, so that no caller waits on a drawer
3090
+ * that left the document. The native dialog is not closed and no `close`
3091
+ * event is dispatched.
3092
+ */
3093
+ disconnectedCallback(): void;
3094
+ /**
3095
+ * The same as `ask()`.
3096
+ * @returns {Promise<{ dismissed: boolean, result: string|null, response: any }>}
3097
+ */
3098
+ open(): Promise<{
3099
+ dismissed: boolean;
3100
+ result: string | null;
3101
+ response: any;
3102
+ }>;
3103
+ /**
3104
+ * Shows the drawer as a modal and resolves with how it ends.
3058
3105
  *
3059
3106
  * The call that opens the drawer resets the outcome of the previous
3060
3107
  * opening, hides the error and loading sections, and dispatches
@@ -3062,17 +3109,40 @@ declare class Drawer extends ParsedElement {
3062
3109
  * `detail: { section, first, name: null, index: null }`, `section` being
3063
3110
  * the content section and `first` true only on the first answered request),
3064
3111
  * so a listener can fill the content. A failed request is painted into the
3065
- * content section.
3066
- */
3067
- open(): void;
3112
+ * content section and does not reject. On a drawer already open nothing is
3113
+ * shown or requested, except that one sliding out stops and stays open, and
3114
+ * the call waits for the same ending as the calls before it, which is how
3115
+ * a caller learns the outcome of the opening an `update()` made.
3116
+ * @returns {Promise<{ dismissed: boolean, result: string|null, response: any }>} resolving on
3117
+ * close, or on removal from the document with a dismissal
3118
+ */
3119
+ ask(): Promise<{
3120
+ dismissed: boolean;
3121
+ result: string | null;
3122
+ response: any;
3123
+ }>;
3124
+ /**
3125
+ * Dismisses the drawer as the user would: dispatches the cancelable
3126
+ * `drawer:dismiss` with `detail: { reason }` and, under `guard-dismiss`,
3127
+ * asks before dropping unsaved edits, sliding the drawer out as a
3128
+ * dismissal unless either refused. Does nothing on a drawer that is closed
3129
+ * or already sliding out.
3130
+ * @param {string} reason why it is dismissed, such as `navigation`
3131
+ * @returns {Promise<boolean>} whether the drawer is closed or closing,
3132
+ * false when a listener or the user kept it open
3133
+ */
3134
+ dismiss(reason: string): Promise<boolean>;
3068
3135
  /**
3069
3136
  * Slides the drawer out and closes it when the animation ends, setting the
3070
3137
  * `closing` attribute on the native dialog meanwhile; the `close` event is
3071
3138
  * dispatched then, after this call has returned. Where the user prefers
3072
- * reduced motion, or no animation runs, it closes at once. Does nothing on
3073
- * a drawer that is closed or already sliding out.
3139
+ * reduced motion, or no animation runs, it closes at once. A non-empty
3140
+ * result answers as the button carrying that `data-result` would; no
3141
+ * result, or an empty one, is a dismissal. Does nothing on a drawer that is
3142
+ * closed or already sliding out.
3143
+ * @param {string} [result]
3074
3144
  */
3075
- close(): void;
3145
+ close(result?: string): void;
3076
3146
  }
3077
3147
  /**
3078
3148
  * A menu of commands on the native popover platform, opened by the element