domma-js 0.55.0 → 0.56.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/assets/types/elements.d.ts +486 -0
- package/assets/types/i18n.d.ts +99 -0
- package/assets/types/index.d.ts +10 -0
- package/package.json +1 -1
- package/public/dist/bundles/domma-complete.css +1078 -14
- package/public/dist/bundles/domma-data-focused.css +1078 -14
- package/public/dist/bundles/domma-essentials.css +1078 -14
- package/public/dist/bundles/domma-full.css +1078 -14
- package/public/dist/bundles/domma-minimal.css +8 -8
- package/public/dist/domma-flags.esm.js +3 -3
- package/public/dist/domma-flags.min.js +3 -3
- package/public/dist/domma-syntax.min.js +3 -3
- package/public/dist/domma.css +3 -3
- package/public/dist/domma.esm.js +5 -5
- package/public/dist/domma.esm.js.map +1 -1
- package/public/dist/domma.min.js +5 -5
- package/public/dist/domma.min.js.map +1 -1
- package/public/dist/elements.css +1067 -3
- package/public/dist/grid.css +3 -3
- package/public/dist/syntax.css +3 -3
- package/public/dist/themes/domma-themes.css +3 -3
|
@@ -624,10 +624,308 @@ export interface BackToTopInstance extends ComponentInstance {
|
|
|
624
624
|
getButton(): HTMLElement;
|
|
625
625
|
}
|
|
626
626
|
|
|
627
|
+
// ============================================
|
|
628
|
+
// Split Pane
|
|
629
|
+
// ============================================
|
|
630
|
+
|
|
631
|
+
/** A pane size limit: px as a number, or a percentage string such as '20%' */
|
|
632
|
+
export type SplitPaneSize = number | string;
|
|
633
|
+
|
|
634
|
+
export interface SplitPaneOptions {
|
|
635
|
+
/** 'horizontal' = side by side (default), 'vertical' = stacked */
|
|
636
|
+
direction?: 'horizontal' | 'vertical';
|
|
637
|
+
/** Percentages, one per pane (scaled to add up to 100); equal by default */
|
|
638
|
+
sizes?: number[];
|
|
639
|
+
/** Minimum size, one value or one per pane (default 0) */
|
|
640
|
+
minSize?: SplitPaneSize | SplitPaneSize[];
|
|
641
|
+
/** Maximum size, one value or one per pane (default none) */
|
|
642
|
+
maxSize?: SplitPaneSize | null | Array<SplitPaneSize | null>;
|
|
643
|
+
/** Gutter thickness in px (default 8) */
|
|
644
|
+
gutterSize?: number;
|
|
645
|
+
/** Snap to a limit when dragged within this many px of it (default 0) */
|
|
646
|
+
snapOffset?: number;
|
|
647
|
+
/** Which panes the gutter gestures may collapse */
|
|
648
|
+
collapsible?: boolean | boolean[];
|
|
649
|
+
/** What a collapsed pane shrinks to (default 0) */
|
|
650
|
+
collapsedSize?: SplitPaneSize | SplitPaneSize[];
|
|
651
|
+
/** A small toggle button in gutters next to a collapsible pane */
|
|
652
|
+
collapseButton?: boolean;
|
|
653
|
+
/** Remember sizes and collapse state with S under 'split-pane:<key>' */
|
|
654
|
+
persistKey?: string | null;
|
|
655
|
+
/** Gutter cursor (default col-resize / row-resize) */
|
|
656
|
+
cursor?: string | null;
|
|
657
|
+
disabled?: boolean;
|
|
658
|
+
/** Percent per arrow key (default 1) */
|
|
659
|
+
step?: number;
|
|
660
|
+
/** Percent per Shift+arrow (default 10) */
|
|
661
|
+
largeStep?: number;
|
|
662
|
+
/** The gutters' aria-label */
|
|
663
|
+
gutterLabel?: string;
|
|
664
|
+
/** Return false to refuse a drag */
|
|
665
|
+
onBeforeDrag?: (gutterIndex: number, event: PointerEvent) => boolean | void;
|
|
666
|
+
onDragStart?: (sizes: number[], gutterIndex: number) => void;
|
|
667
|
+
onDrag?: (sizes: number[], gutterIndex: number) => void;
|
|
668
|
+
onDragEnd?: (sizes: number[], gutterIndex: number) => void;
|
|
669
|
+
/** Any size change: drag, keys, setSizes, collapse */
|
|
670
|
+
onResize?: (sizes: number[]) => void;
|
|
671
|
+
onCollapse?: (paneIndex: number) => void;
|
|
672
|
+
onExpand?: (paneIndex: number) => void;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
export interface SplitPaneInstance extends ComponentInstance {
|
|
676
|
+
/** The pane elements */
|
|
677
|
+
readonly panes: HTMLElement[];
|
|
678
|
+
/** Current sizes, percentages that add up to 100 */
|
|
679
|
+
getSizes(): number[];
|
|
680
|
+
/** Set every pane's size (clamped to the limits) */
|
|
681
|
+
setSizes(sizes: number[]): this;
|
|
682
|
+
collapse(index: number): this;
|
|
683
|
+
expand(index: number): this;
|
|
684
|
+
isCollapsed(index: number): boolean;
|
|
685
|
+
/** Remove the gutters and listeners and restore the panes' own styles */
|
|
686
|
+
destroy(): void;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
// ============================================
|
|
690
|
+
// Virtual List
|
|
691
|
+
// ============================================
|
|
692
|
+
|
|
693
|
+
export interface VirtualListRange {
|
|
694
|
+
/** First index, inclusive */
|
|
695
|
+
start: number;
|
|
696
|
+
/** Last index, inclusive (-1 for an empty list) */
|
|
697
|
+
end: number;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
export type VirtualListTemplate = string | Node | ((error?: unknown) => string | Node | null) | null;
|
|
701
|
+
|
|
702
|
+
export interface VirtualListOptions<T = any> {
|
|
703
|
+
items?: T[] | null;
|
|
704
|
+
/** With getItem, instead of items */
|
|
705
|
+
count?: number;
|
|
706
|
+
getItem?: ((index: number) => T) | null;
|
|
707
|
+
/** px, or 'auto' to measure each row (default 40) */
|
|
708
|
+
itemHeight?: number | 'auto';
|
|
709
|
+
/** Height assumed for unmeasured rows in 'auto' mode (default 40) */
|
|
710
|
+
estimatedItemHeight?: number;
|
|
711
|
+
/** Rows rendered beyond each edge (default 4) */
|
|
712
|
+
overscan?: number;
|
|
713
|
+
/** A string is HTML (sanitised unless safe: false); an Element goes in as it is */
|
|
714
|
+
render?: ((item: T, index: number) => string | Node) | null;
|
|
715
|
+
/** false: render() strings are inserted unsanitised (default true) */
|
|
716
|
+
safe?: boolean;
|
|
717
|
+
/** Property name or function giving each item a stable key (default: the index) */
|
|
718
|
+
keyField?: string | ((item: T, index: number) => unknown) | null;
|
|
719
|
+
/** aria-label for the list */
|
|
720
|
+
label?: string | null;
|
|
721
|
+
/** Extra class on every row */
|
|
722
|
+
rowClass?: string;
|
|
723
|
+
/** Called near the end; resolves to the next items, or {items, done} */
|
|
724
|
+
loadMore?: ((info: {count: number; page: number}) => Promise<T[] | {items: T[]; done?: boolean}>) | null;
|
|
725
|
+
/** px from the end at which loadMore is called (default 200) */
|
|
726
|
+
threshold?: number;
|
|
727
|
+
loadingTemplate?: VirtualListTemplate;
|
|
728
|
+
endTemplate?: VirtualListTemplate;
|
|
729
|
+
/** A [data-vlist-retry] element inside it retries */
|
|
730
|
+
errorTemplate?: VirtualListTemplate;
|
|
731
|
+
onRender?: (range: VirtualListRange) => void;
|
|
732
|
+
onScroll?: (visible: VirtualListRange) => void;
|
|
733
|
+
onLoadMore?: (info: {count: number; page: number}) => void;
|
|
734
|
+
onLoaded?: (items: T[]) => void;
|
|
735
|
+
onEnd?: () => void;
|
|
736
|
+
onError?: (error: unknown) => void;
|
|
737
|
+
onItemClick?: (item: T, index: number, event: MouseEvent | KeyboardEvent) => void;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
export interface VirtualListInstance<T = any> extends ComponentInstance {
|
|
741
|
+
/** Number of rows */
|
|
742
|
+
readonly count: number;
|
|
743
|
+
setItems(items: T[]): this;
|
|
744
|
+
append(items: T[]): this;
|
|
745
|
+
/** Add at the start without moving what is on screen */
|
|
746
|
+
prepend(items: T[]): this;
|
|
747
|
+
/** A number is an index; anything else is a key */
|
|
748
|
+
update(indexOrKey: number | unknown, item: T): this;
|
|
749
|
+
indexOfKey(key: unknown): number;
|
|
750
|
+
scrollToIndex(index: number, options?: {align?: 'start' | 'center' | 'end' | 'auto'; smooth?: boolean}): this;
|
|
751
|
+
/** Scroll to a row and focus it */
|
|
752
|
+
focusIndex(index: number): this;
|
|
753
|
+
/** Re-render (and re-measure) the rendered rows */
|
|
754
|
+
refresh(): this;
|
|
755
|
+
/** Rows at least partly on screen */
|
|
756
|
+
getVisibleRange(): VirtualListRange;
|
|
757
|
+
/** Rows in the DOM, overscan included */
|
|
758
|
+
getRenderedRange(): VirtualListRange;
|
|
759
|
+
/** Retry a failed load */
|
|
760
|
+
retry(): this;
|
|
761
|
+
/** Whether loadMore has said there is nothing more */
|
|
762
|
+
isDone(): boolean;
|
|
763
|
+
/** Count mode: change the number of rows */
|
|
764
|
+
setCount(count: number): this;
|
|
765
|
+
/** Remove the rows and listeners and give the container its children back */
|
|
766
|
+
destroy(): void;
|
|
767
|
+
}
|
|
768
|
+
|
|
627
769
|
// ============================================
|
|
628
770
|
// Elements Module
|
|
629
771
|
// ============================================
|
|
630
772
|
|
|
773
|
+
// ============================================
|
|
774
|
+
// Focus trap
|
|
775
|
+
// ============================================
|
|
776
|
+
|
|
777
|
+
type FocusTarget = string | HTMLElement;
|
|
778
|
+
|
|
779
|
+
export interface FocusTrapOptions {
|
|
780
|
+
/** Where focus goes on activate: a selector, an element, a function returning one, or false to leave it. Default: focus already inside stays, else the first tabbable, else the container. */
|
|
781
|
+
initialFocus?: FocusTarget | (() => HTMLElement | null) | false;
|
|
782
|
+
/** Where focus goes when nothing is tabbable (default: the first container, given tabindex="-1") */
|
|
783
|
+
fallbackFocus?: FocusTarget | (() => HTMLElement | null);
|
|
784
|
+
/** true (default): back to what had focus before activate(); or an element / selector; false: nowhere */
|
|
785
|
+
returnFocus?: boolean | FocusTarget;
|
|
786
|
+
/** Escape deactivates (default false - the owning overlay decides) */
|
|
787
|
+
escapeDeactivates?: boolean | ((e: KeyboardEvent) => boolean);
|
|
788
|
+
/** A press outside deactivates (default false) */
|
|
789
|
+
clickOutsideDeactivates?: boolean | ((e: MouseEvent) => boolean);
|
|
790
|
+
/** Let clicks outside through (default false: they are blocked) */
|
|
791
|
+
allowOutsideClick?: boolean | ((e: MouseEvent) => boolean);
|
|
792
|
+
/** Set `inert` on everything outside the containers while active (default false) */
|
|
793
|
+
inert?: boolean;
|
|
794
|
+
/** Walk open shadow roots (default true) */
|
|
795
|
+
shadow?: boolean;
|
|
796
|
+
preventScroll?: boolean;
|
|
797
|
+
onActivate?: (trap: FocusTrapInstance) => void;
|
|
798
|
+
onDeactivate?: (trap: FocusTrapInstance) => void;
|
|
799
|
+
onPause?: (trap: FocusTrapInstance) => void;
|
|
800
|
+
onUnpause?: (trap: FocusTrapInstance) => void;
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
export interface FocusTrapInstance extends ComponentInstance {
|
|
804
|
+
/** Start trapping; pauses the trap that was on top */
|
|
805
|
+
activate(opts?: {initialFocus?: FocusTrapOptions['initialFocus']}): this;
|
|
806
|
+
/** Stop trapping; unpauses the trap beneath */
|
|
807
|
+
deactivate(opts?: {returnFocus?: boolean | FocusTarget}): this;
|
|
808
|
+
pause(): this;
|
|
809
|
+
unpause(opts?: {focus?: boolean}): this;
|
|
810
|
+
updateContainers(containers: FocusTarget | FocusTarget[]): this;
|
|
811
|
+
containers(): HTMLElement[];
|
|
812
|
+
isActive(): boolean;
|
|
813
|
+
isPaused(): boolean;
|
|
814
|
+
/** The tabbable elements in the containers right now, in Tab order */
|
|
815
|
+
tabbables(): HTMLElement[];
|
|
816
|
+
destroy(): void;
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
export interface FocusTrapFactory {
|
|
820
|
+
(containers: FocusTarget | FocusTarget[], options?: FocusTrapOptions): FocusTrapInstance | null;
|
|
821
|
+
/** What Tab would reach in some containers, in order */
|
|
822
|
+
tabbables(containers: HTMLElement | HTMLElement[], opts?: {shadow?: boolean}): HTMLElement[];
|
|
823
|
+
/** The trap that currently listens */
|
|
824
|
+
top(): FocusTrapInstance | null;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
// ============================================
|
|
828
|
+
// Command palette
|
|
829
|
+
// ============================================
|
|
830
|
+
|
|
831
|
+
export interface PaletteCommand {
|
|
832
|
+
id?: string;
|
|
833
|
+
title: string;
|
|
834
|
+
subtitle?: string;
|
|
835
|
+
/** Heading the command is listed under */
|
|
836
|
+
group?: string;
|
|
837
|
+
/** Domma icon name */
|
|
838
|
+
icon?: string;
|
|
839
|
+
/** More words that find it */
|
|
840
|
+
keywords?: string[];
|
|
841
|
+
/** Shown as a hint, e.g. 'mod+s' (mod = Cmd on a Mac, Ctrl elsewhere) */
|
|
842
|
+
shortcut?: string;
|
|
843
|
+
/** Followed when run (http(s), mailto, tel or relative only) */
|
|
844
|
+
href?: string;
|
|
845
|
+
/** '_blank' opens href in a new tab */
|
|
846
|
+
target?: string;
|
|
847
|
+
action?: (command: PaletteCommand, palette: CommandPaletteInstance, event?: Event) => void;
|
|
848
|
+
disabled?: boolean;
|
|
849
|
+
hidden?: boolean;
|
|
850
|
+
/** Running it leaves the palette open */
|
|
851
|
+
keepOpen?: boolean;
|
|
852
|
+
/** A nested page: a list, or a function returning one (called once on entering) */
|
|
853
|
+
children?: PaletteCommand[] | ((command: PaletteCommand, ctx: {signal?: AbortSignal, palette: CommandPaletteInstance}) => Promise<PaletteCommand[]> | PaletteCommand[]);
|
|
854
|
+
/** Placeholder for the box while this command's page is open */
|
|
855
|
+
placeholder?: string;
|
|
856
|
+
[key: string]: any;
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
export interface CommandPaletteOptions {
|
|
860
|
+
commands?: PaletteCommand[];
|
|
861
|
+
/** Search elsewhere: debounced, the previous request aborted through `signal` */
|
|
862
|
+
source?: (query: string, ctx: {signal?: AbortSignal, palette: CommandPaletteInstance}) => Promise<PaletteCommand[]> | PaletteCommand[];
|
|
863
|
+
/** ms (default 150) */
|
|
864
|
+
debounce?: number;
|
|
865
|
+
/** 'mod+k' (default), several, or false */
|
|
866
|
+
hotkey?: string | string[] | false;
|
|
867
|
+
placeholder?: string;
|
|
868
|
+
/** Accessible name of the dialog and list (default 'Command palette') */
|
|
869
|
+
label?: string;
|
|
870
|
+
maxResults?: number;
|
|
871
|
+
/** Storage (S) key for recent commands; null (default) = off */
|
|
872
|
+
recentKey?: string | null;
|
|
873
|
+
recentLimit?: number;
|
|
874
|
+
recentLabel?: string;
|
|
875
|
+
sourceGroup?: string | null;
|
|
876
|
+
emptyText?: string;
|
|
877
|
+
loadingText?: string;
|
|
878
|
+
/** While a nested page's async children load (default 'Loading…') */
|
|
879
|
+
pageLoadingText?: string;
|
|
880
|
+
errorText?: string;
|
|
881
|
+
backLabel?: string;
|
|
882
|
+
/** Key hints under the list (default true) */
|
|
883
|
+
footer?: boolean;
|
|
884
|
+
resultsText?: (count: number) => string;
|
|
885
|
+
/** Replaces the default navigation for href commands */
|
|
886
|
+
navigate?: (href: string, ctx: {newTab: boolean, command: PaletteCommand}) => void;
|
|
887
|
+
animationDuration?: number;
|
|
888
|
+
className?: string;
|
|
889
|
+
/** Force Mac (true) or other (false) key names; default detects */
|
|
890
|
+
mac?: boolean;
|
|
891
|
+
onBeforeOpen?: (palette: CommandPaletteInstance) => boolean | void;
|
|
892
|
+
onOpen?: (palette: CommandPaletteInstance) => void;
|
|
893
|
+
onBeforeClose?: (palette: CommandPaletteInstance) => boolean | void;
|
|
894
|
+
onClose?: (palette: CommandPaletteInstance) => void;
|
|
895
|
+
onQuery?: (query: string, palette: CommandPaletteInstance) => void;
|
|
896
|
+
onBeforeSelect?: (command: PaletteCommand, palette: CommandPaletteInstance) => boolean | void;
|
|
897
|
+
onSelect?: (command: PaletteCommand, palette: CommandPaletteInstance) => void;
|
|
898
|
+
onRun?: (command: PaletteCommand, palette: CommandPaletteInstance) => void;
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
export interface CommandPaletteInstance extends ComponentInstance {
|
|
902
|
+
open(query?: string): this;
|
|
903
|
+
close(): this;
|
|
904
|
+
toggle(query?: string): this;
|
|
905
|
+
isOpen(): boolean;
|
|
906
|
+
show(query?: string): this;
|
|
907
|
+
hide(): this;
|
|
908
|
+
isVisible(): boolean;
|
|
909
|
+
setCommands(list: PaletteCommand[]): this;
|
|
910
|
+
addCommands(list: PaletteCommand | PaletteCommand[]): this;
|
|
911
|
+
removeCommand(id: string): this;
|
|
912
|
+
getCommands(): PaletteCommand[];
|
|
913
|
+
/** Up one nested page; false at the top */
|
|
914
|
+
back(): boolean;
|
|
915
|
+
query(): string;
|
|
916
|
+
recent(): string[];
|
|
917
|
+
clearRecent(): this;
|
|
918
|
+
destroy(): void;
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
export interface CommandPaletteFactory {
|
|
922
|
+
(options?: CommandPaletteOptions): CommandPaletteInstance;
|
|
923
|
+
formatShortcut(combo: string, mac?: boolean): string[];
|
|
924
|
+
fuzzyMatch(query: string, text: string): {score: number, indices: number[]} | null;
|
|
925
|
+
/** Whether a live palette's hotkey answers this keydown (for page scripts with their own shortcut) */
|
|
926
|
+
claims(e: KeyboardEvent): boolean;
|
|
927
|
+
}
|
|
928
|
+
|
|
631
929
|
export interface Elements {
|
|
632
930
|
/** Create a Card component */
|
|
633
931
|
card(selector: string | HTMLElement, options?: CardOptions): CardInstance;
|
|
@@ -663,6 +961,27 @@ export interface Elements {
|
|
|
663
961
|
/** Toast notification system */
|
|
664
962
|
toast: ToastStatic;
|
|
665
963
|
|
|
964
|
+
/** Keep Tab and focus inside containers while active */
|
|
965
|
+
focusTrap: FocusTrapFactory;
|
|
966
|
+
|
|
967
|
+
/** A Cmd/Ctrl+K command palette (builds its own overlay) */
|
|
968
|
+
commandPalette: CommandPaletteFactory;
|
|
969
|
+
|
|
970
|
+
/** Resizable panes from a container's children; null when nothing matches */
|
|
971
|
+
splitPane(container: string | HTMLElement, options?: SplitPaneOptions): SplitPaneInstance | null;
|
|
972
|
+
|
|
973
|
+
/** A scrolling list that renders only the visible rows; null when nothing matches */
|
|
974
|
+
virtualList<T = any>(container: string | HTMLElement, options?: VirtualListOptions<T>): VirtualListInstance<T> | null;
|
|
975
|
+
|
|
976
|
+
/** A file drop / browse / paste area over a real file input. Null when the target matches nothing. */
|
|
977
|
+
dropzone(target: string | HTMLElement, options?: DropzoneOptions): DropzoneInstance | null;
|
|
978
|
+
|
|
979
|
+
/** A one- or two-thumb slider over real range inputs. Null when the target matches nothing. */
|
|
980
|
+
rangeSlider(target: string | HTMLElement, options?: RangeSliderOptions): RangeSliderInstance | null;
|
|
981
|
+
|
|
982
|
+
/** Alias of rangeSlider() */
|
|
983
|
+
slider(target: string | HTMLElement, options?: RangeSliderOptions): RangeSliderInstance | null;
|
|
984
|
+
|
|
666
985
|
/** Get the component on an element - factory-made ones too. `name` picks one when an element hosts several. */
|
|
667
986
|
get(selector: string | HTMLElement, name?: string): ComponentInstance | undefined;
|
|
668
987
|
|
|
@@ -680,3 +999,170 @@ export interface Elements {
|
|
|
680
999
|
}
|
|
681
1000
|
|
|
682
1001
|
export declare const elements: Elements;
|
|
1002
|
+
|
|
1003
|
+
// ============================================
|
|
1004
|
+
// Dropzone
|
|
1005
|
+
// ============================================
|
|
1006
|
+
|
|
1007
|
+
export type DropzoneStatus = 'queued' | 'uploading' | 'done' | 'error' | 'cancelled';
|
|
1008
|
+
export type DropzoneRejectReason = 'type' | 'size' | 'count';
|
|
1009
|
+
|
|
1010
|
+
/** One file in a dropzone, as every event hands it over */
|
|
1011
|
+
export interface DropzoneEntry {
|
|
1012
|
+
id: string;
|
|
1013
|
+
file: File;
|
|
1014
|
+
name: string;
|
|
1015
|
+
size: number;
|
|
1016
|
+
type: string;
|
|
1017
|
+
status: DropzoneStatus;
|
|
1018
|
+
/** Upload progress, 0-100 */
|
|
1019
|
+
progress: number;
|
|
1020
|
+
/** The upload's response (parsed when it was JSON) */
|
|
1021
|
+
response: any;
|
|
1022
|
+
error: DropzoneUploadError | null;
|
|
1023
|
+
/** Object URL of an image preview, revoked when the file goes */
|
|
1024
|
+
preview: string | null;
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
export interface DropzoneUploadError {
|
|
1028
|
+
/** HTTP status, 0 for a network failure */
|
|
1029
|
+
status: number;
|
|
1030
|
+
message: string;
|
|
1031
|
+
response: any;
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
export interface DropzoneUploadOptions {
|
|
1035
|
+
url: string | ((entry: DropzoneEntry) => string);
|
|
1036
|
+
/** Default 'POST' */
|
|
1037
|
+
method?: string;
|
|
1038
|
+
/** FormData field for the file. Default 'file' */
|
|
1039
|
+
field?: string;
|
|
1040
|
+
headers?: Record<string, string> | ((entry: DropzoneEntry) => Record<string, string>);
|
|
1041
|
+
withCredentials?: boolean;
|
|
1042
|
+
/** Files sent at once. Default 2 */
|
|
1043
|
+
concurrency?: number;
|
|
1044
|
+
/** Extra FormData fields */
|
|
1045
|
+
data?: Record<string, string | Blob> | ((entry: DropzoneEntry) => Record<string, string | Blob>);
|
|
1046
|
+
/** Make the request object (tests, pages without a server). Default: new XMLHttpRequest() */
|
|
1047
|
+
xhr?: (entry: DropzoneEntry) => XMLHttpRequest;
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
export interface DropzoneOptions {
|
|
1051
|
+
/** Like the input's accept: '.pdf,image/*' or ['.pdf', 'image/*']. Default: the input's */
|
|
1052
|
+
accept?: string | string[] | null;
|
|
1053
|
+
/** Default: the input's `multiple`, or true when the component makes the input */
|
|
1054
|
+
multiple?: boolean | null;
|
|
1055
|
+
maxFiles?: number | null;
|
|
1056
|
+
/** Bytes */
|
|
1057
|
+
maxSize?: number | null;
|
|
1058
|
+
/** Bytes */
|
|
1059
|
+
minSize?: number | null;
|
|
1060
|
+
/** Image thumbnails. Default true */
|
|
1061
|
+
previews?: boolean;
|
|
1062
|
+
/** Form field name. Default: the input's */
|
|
1063
|
+
name?: string | null;
|
|
1064
|
+
/** The file input, when it is not inside or next to the area */
|
|
1065
|
+
input?: string | HTMLInputElement | null;
|
|
1066
|
+
/** true = after the area (default), an element/selector to draw into, false = no list */
|
|
1067
|
+
list?: boolean | string | HTMLElement;
|
|
1068
|
+
upload?: DropzoneUploadOptions | null;
|
|
1069
|
+
/** Default true */
|
|
1070
|
+
autoUpload?: boolean;
|
|
1071
|
+
/** Automatic retries per file. Default 0 */
|
|
1072
|
+
retry?: number;
|
|
1073
|
+
/** Text: prompt, hint, remove, retry, cancel, added, removed, type, size, small, count, uploading, done, failed, cancelled, required ({name}, {max}, {min}, {percent}) */
|
|
1074
|
+
labels?: Record<string, string>;
|
|
1075
|
+
disabled?: boolean;
|
|
1076
|
+
className?: string;
|
|
1077
|
+
/** Return false to refuse the file */
|
|
1078
|
+
onBeforeAdd?: (entry: DropzoneEntry) => boolean | void;
|
|
1079
|
+
onAdd?: (entry: DropzoneEntry) => void;
|
|
1080
|
+
onReject?: (entry: DropzoneEntry, reason: DropzoneRejectReason) => void;
|
|
1081
|
+
onRemove?: (entry: DropzoneEntry) => void;
|
|
1082
|
+
onChange?: (files: File[]) => void;
|
|
1083
|
+
onUploadStart?: (entry: DropzoneEntry) => void;
|
|
1084
|
+
onProgress?: (entry: DropzoneEntry, percent: number) => void;
|
|
1085
|
+
onSuccess?: (entry: DropzoneEntry, response: any) => void;
|
|
1086
|
+
onError?: (entry: DropzoneEntry, error: DropzoneUploadError) => void;
|
|
1087
|
+
onComplete?: (entries: DropzoneEntry[]) => void;
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
export interface DropzoneInstance extends ComponentInstance {
|
|
1091
|
+
/** The drop area (the element, or the one drawn after a file input given as the target) */
|
|
1092
|
+
zone: HTMLElement;
|
|
1093
|
+
/** The real file input */
|
|
1094
|
+
input: HTMLInputElement;
|
|
1095
|
+
getFiles(): File[];
|
|
1096
|
+
getEntries(): DropzoneEntry[];
|
|
1097
|
+
addFiles(files: FileList | File[] | File): DropzoneEntry[];
|
|
1098
|
+
removeFile(ref: string | DropzoneEntry | File): boolean;
|
|
1099
|
+
clear(): this;
|
|
1100
|
+
/** Open the file picker */
|
|
1101
|
+
browse(): this;
|
|
1102
|
+
upload(): this;
|
|
1103
|
+
retry(ref?: string | DropzoneEntry | File): this;
|
|
1104
|
+
cancel(ref?: string | DropzoneEntry | File): this;
|
|
1105
|
+
enable(): this;
|
|
1106
|
+
disable(): this;
|
|
1107
|
+
isDisabled(): boolean;
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
// ============================================
|
|
1111
|
+
// Range slider
|
|
1112
|
+
// ============================================
|
|
1113
|
+
|
|
1114
|
+
export type RangeSliderValue = number | [number, number];
|
|
1115
|
+
|
|
1116
|
+
export interface RangeSliderMark {
|
|
1117
|
+
value: number;
|
|
1118
|
+
label?: string;
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
export interface RangeSliderOptions {
|
|
1122
|
+
/** Default: the input's min, else 0 */
|
|
1123
|
+
min?: number;
|
|
1124
|
+
/** Default: the input's max, else 100 */
|
|
1125
|
+
max?: number;
|
|
1126
|
+
/** Default: the input's step, else 1 */
|
|
1127
|
+
step?: number | 'any';
|
|
1128
|
+
/** A number, or [low, high] / "low,high" with range: true */
|
|
1129
|
+
value?: RangeSliderValue | string | null;
|
|
1130
|
+
/** Two thumbs; two inputs, sharing `name` unless `names` is given */
|
|
1131
|
+
range?: boolean;
|
|
1132
|
+
orientation?: 'horizontal' | 'vertical';
|
|
1133
|
+
/** true = every step, n = every n units, or the values to draw at */
|
|
1134
|
+
ticks?: boolean | number | number[];
|
|
1135
|
+
/** Label the ticks (always on for an array) */
|
|
1136
|
+
tickLabels?: boolean;
|
|
1137
|
+
/** Formats the value for ticks, marks, the tooltip and aria-valuetext */
|
|
1138
|
+
labels?: ((value: number, where: 'tick' | 'mark' | 'tooltip' | 'aria') => string) | null;
|
|
1139
|
+
/** Default 'hover' (also shown on focus and while dragging) */
|
|
1140
|
+
tooltip?: 'always' | 'hover' | 'never';
|
|
1141
|
+
marks?: RangeSliderMark[] | null;
|
|
1142
|
+
disabled?: boolean;
|
|
1143
|
+
name?: string | null;
|
|
1144
|
+
/** [lowName, highName] for range: true */
|
|
1145
|
+
names?: [string, string] | null;
|
|
1146
|
+
/** range: true - the closest the thumbs may come */
|
|
1147
|
+
minDistance?: number;
|
|
1148
|
+
/** null = follow the page's direction */
|
|
1149
|
+
rtl?: boolean | null;
|
|
1150
|
+
ariaLabel?: string | null;
|
|
1151
|
+
ariaLabels?: [string, string] | null;
|
|
1152
|
+
className?: string;
|
|
1153
|
+
/** While dragging, and on each key press */
|
|
1154
|
+
onInput?: (value: RangeSliderValue) => void;
|
|
1155
|
+
/** When the value is committed */
|
|
1156
|
+
onChange?: (value: RangeSliderValue) => void;
|
|
1157
|
+
/** Return false to refuse a move */
|
|
1158
|
+
onBeforeChange?: (next: RangeSliderValue, current: RangeSliderValue) => boolean | void;
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
export interface RangeSliderInstance extends ComponentInstance {
|
|
1162
|
+
getValue(): RangeSliderValue;
|
|
1163
|
+
setValue(value: RangeSliderValue | string, opts?: {silent?: boolean}): this;
|
|
1164
|
+
setRange(min: number, max: number): this;
|
|
1165
|
+
enable(): this;
|
|
1166
|
+
disable(): this;
|
|
1167
|
+
isDisabled(): boolean;
|
|
1168
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domma i18n Module - TypeScript Declarations
|
|
3
|
+
* Translations, plurals and Intl formatting: `Domma.i18n`, plus `Domma.t()`.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/** A plural message: chosen by `params.count`; `=N` keys match exactly, `zero` matches 0. */
|
|
7
|
+
export interface I18nPluralForms {
|
|
8
|
+
zero?: string;
|
|
9
|
+
one?: string;
|
|
10
|
+
two?: string;
|
|
11
|
+
few?: string;
|
|
12
|
+
many?: string;
|
|
13
|
+
other: string;
|
|
14
|
+
/** Use ordinal rules (1st, 2nd, 3rd...) */
|
|
15
|
+
ordinal?: boolean;
|
|
16
|
+
[exact: `=${number}`]: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** A select message: `select` names the param whose value picks the form; `other` otherwise. */
|
|
20
|
+
export interface I18nSelectForms {
|
|
21
|
+
select: string;
|
|
22
|
+
other: string;
|
|
23
|
+
[value: string]: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Nested message tree; nesting becomes dot keys. */
|
|
27
|
+
export interface I18nMessages {
|
|
28
|
+
[key: string]: string | number | boolean | I18nPluralForms | I18nSelectForms | I18nMessages;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface I18nTranslateOptions {
|
|
32
|
+
/** Translate in this locale instead of the current one */
|
|
33
|
+
locale?: string;
|
|
34
|
+
/** Returned (interpolated) when the key is missing, instead of the key */
|
|
35
|
+
default?: string;
|
|
36
|
+
/** Choose plural forms by ordinal rules */
|
|
37
|
+
ordinal?: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface I18nDetectOptions {
|
|
41
|
+
/** Sources in order. Default ['storage', 'navigator', 'html'] */
|
|
42
|
+
from?: Array<'storage' | 'navigator' | 'html'>;
|
|
43
|
+
/** S key: read in 'storage', and every later locale(code) is saved there */
|
|
44
|
+
storageKey?: string;
|
|
45
|
+
/** Only these locales (or their base language) are accepted */
|
|
46
|
+
supported?: string[];
|
|
47
|
+
/** Used when nothing matches (else the current locale stays) */
|
|
48
|
+
fallback?: string;
|
|
49
|
+
/** Set the found locale (default true) */
|
|
50
|
+
apply?: boolean;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface I18nChangeDetail { locale: string; previous: string; }
|
|
54
|
+
export interface I18nMissingDetail { key: string; locale: string; }
|
|
55
|
+
export interface I18nLoadedDetail { locale: string; messages: I18nMessages; }
|
|
56
|
+
|
|
57
|
+
type WithLocale<T> = T & { locale?: string };
|
|
58
|
+
|
|
59
|
+
export interface I18n {
|
|
60
|
+
/** Add (merge) messages for a locale */
|
|
61
|
+
add(locale: string, messages: I18nMessages): I18n;
|
|
62
|
+
/** Load JSON via H.get (`{locale}` in the URL is replaced) or a loader. Cached and deduped. */
|
|
63
|
+
load(locale: string, source: string | ((locale: string) => Promise<I18nMessages> | I18nMessages), options?: { reload?: boolean }): Promise<I18nMessages>;
|
|
64
|
+
/** Current locale */
|
|
65
|
+
locale(): string;
|
|
66
|
+
/** Set the locale: fires change, sets <html lang dir>, re-translates the document */
|
|
67
|
+
locale(code: string): string;
|
|
68
|
+
/** Fallback locales searched after the current one */
|
|
69
|
+
fallback(codes?: string | string[]): string[];
|
|
70
|
+
has(key: string, options?: { locale?: string }): boolean;
|
|
71
|
+
/** Plain text: params are not escaped */
|
|
72
|
+
t(key: string, params?: Record<string, any> | null, options?: I18nTranslateOptions): string;
|
|
73
|
+
/** HTML: the message's markup is kept, params are escaped */
|
|
74
|
+
html(key: string, params?: Record<string, any> | null, options?: I18nTranslateOptions): string;
|
|
75
|
+
/** Hook for a missing key; a returned string is used as the translation */
|
|
76
|
+
onMissing(fn: ((key: string, locale: string) => string | void) | null): I18n;
|
|
77
|
+
on(event: 'change', fn: (detail: I18nChangeDetail) => void): () => void;
|
|
78
|
+
on(event: 'missing', fn: (detail: I18nMissingDetail) => void): () => void;
|
|
79
|
+
on(event: 'loaded', fn: (detail: I18nLoadedDetail) => void): () => void;
|
|
80
|
+
off(event: 'change' | 'missing' | 'loaded', fn?: (...args: any[]) => void): I18n;
|
|
81
|
+
/** Locales that have messages */
|
|
82
|
+
locales(): string[];
|
|
83
|
+
/** Text direction of a locale (default: the current one) */
|
|
84
|
+
dir(code?: string): 'rtl' | 'ltr';
|
|
85
|
+
/** Fill [data-i18n], [data-i18n-html] (sanitised) and [data-i18n-attr] under root */
|
|
86
|
+
translate(root?: Element | Document | string | ArrayLike<Element>): number;
|
|
87
|
+
/** Pick and set a locale from storage / navigator / <html lang> */
|
|
88
|
+
detect(options?: I18nDetectOptions): string;
|
|
89
|
+
number(n: number | bigint, opts?: WithLocale<Intl.NumberFormatOptions>): string;
|
|
90
|
+
currency(n: number | bigint, code: string, opts?: WithLocale<Intl.NumberFormatOptions>): string;
|
|
91
|
+
/** Date, timestamp, string or a D() wrapper; '' when invalid */
|
|
92
|
+
date(d: Date | number | string | { toDate(): Date }, opts?: WithLocale<Intl.DateTimeFormatOptions>): string;
|
|
93
|
+
relative(value: number, unit: Intl.RelativeTimeFormatUnit, opts?: WithLocale<Intl.RelativeTimeFormatOptions>): string;
|
|
94
|
+
list(items: Iterable<string>, opts?: WithLocale<{ type?: 'conjunction' | 'disjunction' | 'unit'; style?: 'long' | 'short' | 'narrow' }>): string;
|
|
95
|
+
/** Forget all messages, loads, listeners and settings */
|
|
96
|
+
reset(): I18n;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export declare const i18n: I18n;
|
package/assets/types/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export * from './theme';
|
|
|
20
20
|
export * from './icons';
|
|
21
21
|
export * from './flags';
|
|
22
22
|
export * from './smooth-caret';
|
|
23
|
+
export * from './i18n';
|
|
23
24
|
|
|
24
25
|
// Import types for the main Domma object
|
|
25
26
|
import {DommaCollection} from './dom';
|
|
@@ -35,6 +36,7 @@ import {Theme, theme} from './theme';
|
|
|
35
36
|
import {Icons, icons} from './icons';
|
|
36
37
|
import {Flags} from './flags';
|
|
37
38
|
import {SmoothCaret} from './smooth-caret';
|
|
39
|
+
import {I18n, I18nTranslateOptions} from './i18n';
|
|
38
40
|
|
|
39
41
|
// ============================================
|
|
40
42
|
// Main Domma Interface
|
|
@@ -85,6 +87,12 @@ export interface DommaStatic {
|
|
|
85
87
|
/** Icon library */
|
|
86
88
|
icons: Icons;
|
|
87
89
|
|
|
90
|
+
/** Translations, plurals and Intl formatting */
|
|
91
|
+
i18n: I18n;
|
|
92
|
+
|
|
93
|
+
/** Shortcut for {@link I18n.t} */
|
|
94
|
+
t(key: string, params?: Record<string, any> | null, options?: I18nTranslateOptions): string;
|
|
95
|
+
|
|
88
96
|
/** Nation flags (opt-in module - present when domma-flags is loaded) */
|
|
89
97
|
flags?: Flags;
|
|
90
98
|
|
|
@@ -224,6 +232,8 @@ export interface DommaLoadOptions {
|
|
|
224
232
|
purifyWarning?: boolean;
|
|
225
233
|
/** false: no deprecation warnings */
|
|
226
234
|
deprecationWarnings?: boolean;
|
|
235
|
+
/** false: no console warning for a missing translation */
|
|
236
|
+
i18nWarnings?: boolean;
|
|
227
237
|
}
|
|
228
238
|
|
|
229
239
|
declare global {
|
package/package.json
CHANGED