ember-primitives 0.61.1 → 0.62.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.
- package/README.md +8 -1
- package/declarations/components/command-palette.d.ts +316 -0
- package/declarations/components/command-palette.d.ts.map +1 -0
- package/declarations/components/dialog.d.ts +51 -1
- package/declarations/components/dialog.d.ts.map +1 -1
- package/declarations/index.d.ts +2 -1
- package/declarations/index.d.ts.map +1 -1
- package/dist/components/command-palette.js +363 -0
- package/dist/components/command-palette.js.map +1 -0
- package/dist/components/dialog.js +50 -1
- package/dist/components/dialog.js.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/src/components/command-palette.gts +719 -0
- package/src/components/dialog.gts +71 -1
- package/src/index.ts +2 -1
|
@@ -228,7 +228,77 @@ class ModalDialog extends Component<Signature> {
|
|
|
228
228
|
};
|
|
229
229
|
}
|
|
230
230
|
|
|
231
|
+
export interface SimpleSignature {
|
|
232
|
+
Element: HTMLDialogElement;
|
|
233
|
+
Blocks: {
|
|
234
|
+
default: [
|
|
235
|
+
{
|
|
236
|
+
/**
|
|
237
|
+
* Opens the dialog, modally.
|
|
238
|
+
*/
|
|
239
|
+
open: () => void;
|
|
240
|
+
/**
|
|
241
|
+
* Closes the dialog.
|
|
242
|
+
*/
|
|
243
|
+
close: () => void;
|
|
244
|
+
},
|
|
245
|
+
];
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* A modal `<dialog>` around whatever you put in it, and the two things needed
|
|
251
|
+
* to drive it.
|
|
252
|
+
*
|
|
253
|
+
* ```gjs
|
|
254
|
+
* <Dialog as |d|>
|
|
255
|
+
* <CommandPalette @onSelect={{d.close}} @onOpen={{d.open}} @hotkey="mod+k" />
|
|
256
|
+
* </Dialog>
|
|
257
|
+
* ```
|
|
258
|
+
*
|
|
259
|
+
* The element is here, so a trigger cannot be: whatever opens this either
|
|
260
|
+
* lives inside it, or is a key combination. For a dialog opened by a button
|
|
261
|
+
* beside it, use `<Modal>`, which hands you the element to place.
|
|
262
|
+
*
|
|
263
|
+
* <kbd>Escape</kbd> closes it and focus returns to whatever opened it, which
|
|
264
|
+
* is the `<dialog>` element's own behaviour. Set `closedby` to change which
|
|
265
|
+
* actions dismiss it.
|
|
266
|
+
*/
|
|
267
|
+
export class Dialog extends Component<SimpleSignature> {
|
|
268
|
+
/**
|
|
269
|
+
* A plain field rather than tracked state: it is read when somebody calls
|
|
270
|
+
* `open` or `close`, never while rendering, so nothing has to settle in a
|
|
271
|
+
* second pass.
|
|
272
|
+
*/
|
|
273
|
+
#element: HTMLDialogElement | undefined;
|
|
274
|
+
|
|
275
|
+
register = eModifier((element: HTMLDialogElement) => {
|
|
276
|
+
this.#element = element;
|
|
277
|
+
|
|
278
|
+
return () => {
|
|
279
|
+
this.#element = undefined;
|
|
280
|
+
};
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* `showModal` on an open dialog, and `close` on a closed one, are both
|
|
285
|
+
* no-ops per spec, so neither needs guarding here.
|
|
286
|
+
*/
|
|
287
|
+
open = () => {
|
|
288
|
+
this.#element?.showModal();
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
close = () => {
|
|
292
|
+
this.#element?.close();
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
<template>
|
|
296
|
+
<dialog {{this.register}} ...attributes>
|
|
297
|
+
{{yield (hash open=this.open close=this.close)}}
|
|
298
|
+
</dialog>
|
|
299
|
+
</template>
|
|
300
|
+
}
|
|
301
|
+
|
|
231
302
|
export const Modal = ModalDialog;
|
|
232
|
-
export const Dialog = ModalDialog;
|
|
233
303
|
|
|
234
304
|
export default ModalDialog;
|
package/src/index.ts
CHANGED
|
@@ -20,7 +20,8 @@ export type {
|
|
|
20
20
|
} from './components/accordion/public.ts';
|
|
21
21
|
export { Avatar } from './components/avatar.gts';
|
|
22
22
|
export { Breadcrumb } from './components/breadcrumb.gts';
|
|
23
|
-
export {
|
|
23
|
+
export { CommandPalette } from './components/command-palette.gts';
|
|
24
|
+
export { Dialog, Modal } from './components/dialog.gts';
|
|
24
25
|
export { Drawer } from './components/drawer.gts';
|
|
25
26
|
export { ExternalLink } from './components/external-link.gts';
|
|
26
27
|
export { Form } from './components/form.gts';
|