@stackoverflow/stacks 0.75.0 → 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.
- package/dist/controllers/index.d.ts +7 -0
- package/dist/controllers/s-expandable-control.d.ts +17 -0
- package/dist/controllers/s-modal.d.ts +97 -0
- package/dist/controllers/s-navigation-tablist.d.ts +36 -0
- package/dist/controllers/s-popover.d.ts +155 -0
- package/dist/controllers/s-table.d.ts +8 -0
- package/dist/controllers/s-tooltip.d.ts +82 -0
- package/dist/controllers/s-uploader.d.ts +48 -0
- package/dist/css/stacks.css +4379 -2660
- package/dist/css/stacks.min.css +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/js/stacks.js +6026 -5403
- package/dist/js/stacks.min.js +1 -1
- package/dist/stacks.d.ts +21 -0
- package/lib/css/atomic/{_stacks-borders.less → borders.less} +30 -30
- package/lib/css/atomic/{_stacks-colors.less → colors.less} +0 -0
- package/lib/css/atomic/{_stacks-flex.less → flex.less} +14 -13
- package/lib/css/atomic/{_stacks-grid.less → grid.less} +12 -11
- package/lib/css/atomic/{_stacks-misc.less → misc.less} +22 -22
- package/lib/css/atomic/spacing.less +314 -0
- package/lib/css/atomic/{_stacks-typography.less → typography.less} +29 -29
- package/lib/css/atomic/width-height.less +194 -0
- package/lib/css/base/{_stacks-body.less → body.less} +3 -5
- package/lib/css/base/{_stacks-configuration-static.less → configuration-static.less} +3 -1
- package/lib/css/base/{_stacks-icons.less → icons.less} +0 -0
- package/lib/css/base/{_stacks-internals.less → internals.less} +0 -10
- package/lib/css/base/{_stacks-reset-meyer.less → reset-meyer.less} +0 -0
- package/lib/css/base/{_stacks-reset-normalize.less → reset-normalize.less} +0 -0
- package/lib/css/base/{_stacks-reset.less → reset.less} +2 -2
- package/lib/css/components/{_stacks-activity-indicator.less → activity-indicator.less} +9 -9
- package/lib/css/components/{_stacks-avatars.less → avatars.less} +40 -40
- package/lib/css/components/{_stacks-badges.less → badges.less} +11 -11
- package/lib/css/components/{_stacks-banners.less → banners.less} +5 -6
- package/lib/css/components/{_stacks-blank-states.less → blank-states.less} +2 -2
- package/lib/css/components/{_stacks-breadcrumbs.less → breadcrumbs.less} +7 -7
- package/lib/css/components/{_stacks-button-groups.less → button-groups.less} +2 -2
- package/lib/css/components/{_stacks-buttons.less → buttons.less} +77 -72
- package/lib/css/components/{_stacks-cards.less → cards.less} +2 -2
- package/lib/css/components/{_stacks-code-blocks.less → code-blocks.less} +8 -8
- package/lib/css/components/{_stacks-collapsible.less → collapsible.less} +0 -0
- package/lib/css/components/{_stacks-inputs.less → inputs.less} +41 -41
- package/lib/css/components/{_stacks-link-previews.less → link-previews.less} +17 -17
- package/lib/css/components/{_stacks-links.less → links.less} +4 -4
- package/lib/css/components/{_stacks-menu.less → menu.less} +5 -5
- package/lib/css/components/{_stacks-modals.less → modals.less} +20 -20
- package/lib/css/components/{_stacks-navigation.less → navigation.less} +12 -12
- package/lib/css/components/{_stacks-notices.less → notices.less} +12 -12
- package/lib/css/components/{_stacks-page-titles.less → page-titles.less} +9 -9
- package/lib/css/components/{_stacks-pagination.less → pagination.less} +8 -8
- package/lib/css/components/{_stacks-popovers.less → popovers.less} +17 -17
- package/lib/css/components/{_stacks-post-summary.less → post-summary.less} +35 -35
- package/lib/css/components/{_stacks-progress-bars.less → progress-bars.less} +29 -30
- package/lib/css/components/{_stacks-prose.less → prose.less} +31 -31
- package/lib/css/components/{_stacks-spinner.less → spinner.less} +14 -14
- package/lib/css/components/{_stacks-tables.less → tables.less} +10 -10
- package/lib/css/components/{_stacks-tags.less → tags.less} +33 -41
- package/lib/css/components/{_stacks-toggle-switches.less → toggle-switches.less} +5 -5
- package/lib/css/components/{_stacks-topbar.less → topbar.less} +27 -40
- package/lib/css/components/{_stacks-uploader.less → uploader.less} +18 -18
- package/lib/css/components/{_stacks-user-cards.less → user-cards.less} +14 -14
- package/lib/css/components/{_stacks-widget-dynamic.less → widget-dynamic.less} +1 -1
- package/lib/css/components/{_stacks-widget-static.less → widget-static.less} +39 -38
- package/lib/css/exports/{_stacks-constants-colors.less → constants-colors.less} +10 -30
- package/lib/css/exports/constants-helpers.less +108 -0
- package/lib/css/exports/constants-type.less +153 -0
- package/lib/css/exports/{_stacks-exports.less → exports.less} +4 -4
- package/lib/css/exports/{_stacks-mixins.less → mixins.less} +18 -1
- package/lib/css/stacks-dynamic.less +12 -13
- package/lib/css/stacks-static.less +38 -38
- package/lib/ts/controllers/index.ts +8 -0
- package/lib/ts/controllers/s-expandable-control.ts +163 -164
- package/lib/ts/controllers/s-modal.ts +259 -261
- package/lib/ts/controllers/s-navigation-tablist.ts +96 -97
- package/lib/ts/controllers/s-popover.ts +438 -440
- package/lib/ts/controllers/s-table.ts +203 -203
- package/lib/ts/controllers/s-tooltip.ts +195 -196
- package/lib/ts/controllers/s-uploader.ts +162 -164
- package/lib/ts/index.ts +20 -0
- package/lib/ts/stacks.ts +73 -68
- package/lib/tsconfig.json +8 -6
- package/package.json +40 -24
- package/dist/css/stacks-flexgrid-shim.min.css +0 -1
- package/lib/css/atomic/_stacks-spacing.less +0 -168
- package/lib/css/atomic/_stacks-width-height.less +0 -195
- package/lib/css/base/_stacks-configuration-dynamic.less +0 -106
- package/lib/css/exports/_stacks-constants-helpers.less +0 -139
- package/lib/css/exports/_stacks-constants-type.less +0 -91
- package/lib/ts/finalize.ts +0 -1
- package/lib/ts/stimulus.d.ts +0 -4
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { ExpandableController } from './s-expandable-control';
|
|
2
|
+
export { hideModal, ModalController, showModal } from './s-modal';
|
|
3
|
+
export { TabListController } from './s-navigation-tablist';
|
|
4
|
+
export { attachPopover, detachPopover, hidePopover, BasePopoverController, PopoverController, showPopover } from './s-popover';
|
|
5
|
+
export { TableController } from './s-table';
|
|
6
|
+
export { setTooltipHtml, setTooltipText, TooltipController } from './s-tooltip';
|
|
7
|
+
export { UploaderController } from './s-uploader';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as Stacks from '../stacks';
|
|
2
|
+
export declare class ExpandableController extends Stacks.StacksController {
|
|
3
|
+
private isCollapsed;
|
|
4
|
+
private events;
|
|
5
|
+
private isCheckable;
|
|
6
|
+
private isRadio;
|
|
7
|
+
private lastKeydownClickTimestamp;
|
|
8
|
+
initialize(): void;
|
|
9
|
+
_isCollapsedForClickable(): boolean;
|
|
10
|
+
_isCollapsedForCheckable(): boolean;
|
|
11
|
+
get controlledCollapsibles(): HTMLElement[];
|
|
12
|
+
_dispatchShowHideEvent(isShow: boolean): void;
|
|
13
|
+
_toggleClass(doAdd: boolean): void;
|
|
14
|
+
listener(e: Event): void;
|
|
15
|
+
connect(): void;
|
|
16
|
+
disconnect(): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import * as Stacks from "../stacks";
|
|
2
|
+
export declare class ModalController extends Stacks.StacksController {
|
|
3
|
+
static targets: string[];
|
|
4
|
+
private modalTarget;
|
|
5
|
+
private initialFocusTargets;
|
|
6
|
+
private _boundClickFn;
|
|
7
|
+
private _boundKeypressFn;
|
|
8
|
+
private returnElement;
|
|
9
|
+
private _boundTabTrap;
|
|
10
|
+
connect(): void;
|
|
11
|
+
/**
|
|
12
|
+
* Disconnects all added event listeners on controller disconnect
|
|
13
|
+
*/
|
|
14
|
+
disconnect(): void;
|
|
15
|
+
/**
|
|
16
|
+
* Toggles the visibility of the modal
|
|
17
|
+
*/
|
|
18
|
+
toggle(dispatcher?: Event | Element | null): void;
|
|
19
|
+
/**
|
|
20
|
+
* Shows the modal
|
|
21
|
+
*/
|
|
22
|
+
show(dispatcher?: Event | Element | null): void;
|
|
23
|
+
/**
|
|
24
|
+
* Hides the modal
|
|
25
|
+
*/
|
|
26
|
+
hide(dispatcher?: Event | Element | null): void;
|
|
27
|
+
/**
|
|
28
|
+
* Validates the modal settings and attempts to set necessary internal variables
|
|
29
|
+
*/
|
|
30
|
+
private validate;
|
|
31
|
+
/**
|
|
32
|
+
* Toggles the visibility of the modal element
|
|
33
|
+
* @param show Optional parameter that force shows/hides the element or toggles it if left undefined
|
|
34
|
+
*/
|
|
35
|
+
private _toggle;
|
|
36
|
+
/**
|
|
37
|
+
* Listens for the s-modal:hidden event and focuses the returnElement when it is fired
|
|
38
|
+
*/
|
|
39
|
+
private focusReturnElement;
|
|
40
|
+
/**
|
|
41
|
+
* Remove the element on hide if the `remove-when-hidden` flag is set
|
|
42
|
+
*/
|
|
43
|
+
private removeModalOnHide;
|
|
44
|
+
/**
|
|
45
|
+
* Gets all elements within the modal that could receive keyboard focus.
|
|
46
|
+
*/
|
|
47
|
+
private getAllTabbables;
|
|
48
|
+
/**
|
|
49
|
+
* Returns the first visible element in an array or `undefined` if no elements are visible.
|
|
50
|
+
*/
|
|
51
|
+
private firstVisible;
|
|
52
|
+
/**
|
|
53
|
+
* Returns the last visible element in an array or `undefined` if no elements are visible.
|
|
54
|
+
*/
|
|
55
|
+
private lastVisible;
|
|
56
|
+
/**
|
|
57
|
+
* Attempts to shift keyboard focus into the modal.
|
|
58
|
+
* If elements with `data-s-modal-target="initialFocus"` are present and visible, one of those will be selected.
|
|
59
|
+
* Otherwise, the first visible focusable element will receive focus.
|
|
60
|
+
*/
|
|
61
|
+
private focusInsideModal;
|
|
62
|
+
/**
|
|
63
|
+
* Returns keyboard focus to the modal if it has left or is about to leave.
|
|
64
|
+
*/
|
|
65
|
+
private keepFocusWithinModal;
|
|
66
|
+
/**
|
|
67
|
+
* Binds global events to the document for hiding popovers on user interaction
|
|
68
|
+
*/
|
|
69
|
+
private bindDocumentEvents;
|
|
70
|
+
/**
|
|
71
|
+
* Unbinds global events to the document for hiding popovers on user interaction
|
|
72
|
+
*/
|
|
73
|
+
private unbindDocumentEvents;
|
|
74
|
+
/**
|
|
75
|
+
* Forces the popover to hide if a user clicks outside of it or its reference element
|
|
76
|
+
*/
|
|
77
|
+
private hideOnOutsideClick;
|
|
78
|
+
/**
|
|
79
|
+
* Forces the popover to hide if the user presses escape while it, one of its childen, or the reference element are focused
|
|
80
|
+
*/
|
|
81
|
+
private hideOnEscapePress;
|
|
82
|
+
/**
|
|
83
|
+
* Determines the correct dispatching element from a potential input
|
|
84
|
+
* @param dispatcher The event or element to get the dispatcher from
|
|
85
|
+
*/
|
|
86
|
+
private getDispatcher;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Helper to manually show an s-modal element via external JS
|
|
90
|
+
* @param element the element the `data-controller="s-modal"` attribute is on
|
|
91
|
+
*/
|
|
92
|
+
export declare function showModal(element: HTMLElement): void;
|
|
93
|
+
/**
|
|
94
|
+
* Helper to manually hide an s-modal element via external JS
|
|
95
|
+
* @param element the element the `data-controller="s-modal"` attribute is on
|
|
96
|
+
*/
|
|
97
|
+
export declare function hideModal(element: HTMLElement): void;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as Stacks from "../stacks";
|
|
2
|
+
export declare class TabListController extends Stacks.StacksController {
|
|
3
|
+
private boundSelectTab;
|
|
4
|
+
private boundHandleKeydown;
|
|
5
|
+
connect(): void;
|
|
6
|
+
disconnect(): void;
|
|
7
|
+
/**
|
|
8
|
+
* Gets all tabs within the controller.
|
|
9
|
+
*/
|
|
10
|
+
get tabTargets(): HTMLElement[];
|
|
11
|
+
/**
|
|
12
|
+
* Handles click events on individual tabs, causing them to be selected.
|
|
13
|
+
*/
|
|
14
|
+
selectTab(event: MouseEvent): void;
|
|
15
|
+
/**
|
|
16
|
+
* Handles left and right arrow keydown events on individual tabs,
|
|
17
|
+
* selecting the adjacent tab corresponding to the event.
|
|
18
|
+
*/
|
|
19
|
+
handleKeydown(event: KeyboardEvent): void;
|
|
20
|
+
/**
|
|
21
|
+
* Attempts to switch to a new tab, doing nothing if the tab is already selected or
|
|
22
|
+
* the s-navigation-tablist:select event is prevented.
|
|
23
|
+
*/
|
|
24
|
+
private switchToTab;
|
|
25
|
+
/**
|
|
26
|
+
* Returns the currently selected tab or null if no tabs are selected.
|
|
27
|
+
*/
|
|
28
|
+
get selectedTab(): HTMLElement | null;
|
|
29
|
+
/**
|
|
30
|
+
* Switches the tablist to the provided tab, updating the tabs and panels
|
|
31
|
+
* to reflect the change.
|
|
32
|
+
* @param selectedTab The tab to select. If `null` is provided or the element
|
|
33
|
+
* is not a valid tab, all tabs will be unselected.
|
|
34
|
+
*/
|
|
35
|
+
set selectedTab(selectedTab: HTMLElement | null);
|
|
36
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import * as Stacks from "../stacks";
|
|
2
|
+
export declare abstract class BasePopoverController extends Stacks.StacksController {
|
|
3
|
+
private popper;
|
|
4
|
+
protected popoverElement: HTMLElement;
|
|
5
|
+
protected referenceElement: HTMLElement;
|
|
6
|
+
/**
|
|
7
|
+
* An attribute containing the ID of the popover element to render, e.g. aria-controls or aria-describedby.
|
|
8
|
+
*/
|
|
9
|
+
protected abstract popoverSelectorAttribute: string;
|
|
10
|
+
/**
|
|
11
|
+
* Binds events to the document on element show
|
|
12
|
+
*/
|
|
13
|
+
protected abstract bindDocumentEvents(): void;
|
|
14
|
+
/**
|
|
15
|
+
* Unbinds events on the document on element hide
|
|
16
|
+
*/
|
|
17
|
+
protected abstract unbindDocumentEvents(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Returns true if the if the popover is currently visible.
|
|
20
|
+
*/
|
|
21
|
+
get isVisible(): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Gets whether the element is visible in the browser's viewport.
|
|
24
|
+
*/
|
|
25
|
+
get isInViewport(): boolean;
|
|
26
|
+
protected get shouldHideOnOutsideClick(): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Initializes and validates controller variables
|
|
29
|
+
*/
|
|
30
|
+
connect(): void;
|
|
31
|
+
/**
|
|
32
|
+
* Cleans up popper.js elements and disconnects all added event listeners
|
|
33
|
+
*/
|
|
34
|
+
disconnect(): void;
|
|
35
|
+
/**
|
|
36
|
+
* Toggles the visibility of the popover
|
|
37
|
+
*/
|
|
38
|
+
toggle(dispatcher?: Event | Element | null): void;
|
|
39
|
+
/**
|
|
40
|
+
* Shows the popover if not already visible
|
|
41
|
+
*/
|
|
42
|
+
show(dispatcher?: Event | Element | null): void;
|
|
43
|
+
/**
|
|
44
|
+
* Hides the popover if not already hidden
|
|
45
|
+
*/
|
|
46
|
+
hide(dispatcher?: Event | Element | null): void;
|
|
47
|
+
/**
|
|
48
|
+
* Binds document events for this popover and fires the shown event
|
|
49
|
+
*/
|
|
50
|
+
protected shown(dispatcher?: Element | null): void;
|
|
51
|
+
/**
|
|
52
|
+
* Unbinds document events for this popover and fires the hidden event
|
|
53
|
+
*/
|
|
54
|
+
protected hidden(dispatcher?: Element | null): void;
|
|
55
|
+
/**
|
|
56
|
+
* Generates the popover if not found during initialization
|
|
57
|
+
*/
|
|
58
|
+
protected generatePopover(): HTMLElement | null;
|
|
59
|
+
/**
|
|
60
|
+
* Initializes the Popper for this instance
|
|
61
|
+
*/
|
|
62
|
+
private initializePopper;
|
|
63
|
+
/**
|
|
64
|
+
* Validates the popover settings and attempts to set necessary internal variables
|
|
65
|
+
*/
|
|
66
|
+
private validate;
|
|
67
|
+
/**
|
|
68
|
+
* Determines the correct dispatching element from a potential input
|
|
69
|
+
* @param dispatcher The event or element to get the dispatcher from
|
|
70
|
+
*/
|
|
71
|
+
protected getDispatcher(dispatcher?: Event | Element | null): Element;
|
|
72
|
+
/**
|
|
73
|
+
* Schedules the popover to update on the next animation frame if visible
|
|
74
|
+
*/
|
|
75
|
+
protected scheduleUpdate(): void;
|
|
76
|
+
}
|
|
77
|
+
export declare class PopoverController extends BasePopoverController {
|
|
78
|
+
static targets: never[];
|
|
79
|
+
protected popoverSelectorAttribute: string;
|
|
80
|
+
private boundHideOnOutsideClick;
|
|
81
|
+
private boundHideOnEscapePress;
|
|
82
|
+
/**
|
|
83
|
+
* Toggles optional classes in addition to BasePopoverController.shown
|
|
84
|
+
*/
|
|
85
|
+
protected shown(dispatcher?: Element | null): void;
|
|
86
|
+
/**
|
|
87
|
+
* Toggles optional classes in addition to BasePopoverController.hidden
|
|
88
|
+
*/
|
|
89
|
+
protected hidden(dispatcher?: Element | null): void;
|
|
90
|
+
/**
|
|
91
|
+
* Binds global events to the document for hiding popovers on user interaction
|
|
92
|
+
*/
|
|
93
|
+
protected bindDocumentEvents(): void;
|
|
94
|
+
/**
|
|
95
|
+
* Unbinds global events to the document for hiding popovers on user interaction
|
|
96
|
+
*/
|
|
97
|
+
protected unbindDocumentEvents(): void;
|
|
98
|
+
/**
|
|
99
|
+
* Forces the popover to hide if a user clicks outside of it or its reference element
|
|
100
|
+
* @param {Event} e - The document click event
|
|
101
|
+
*/
|
|
102
|
+
private hideOnOutsideClick;
|
|
103
|
+
/**
|
|
104
|
+
* Forces the popover to hide if the user presses escape while it, one of its childen, or the reference element are focused
|
|
105
|
+
* @param {Event} e - The document keyup event
|
|
106
|
+
*/
|
|
107
|
+
private hideOnEscapePress;
|
|
108
|
+
/**
|
|
109
|
+
* Toggles all classes on the originating element based on the `class-toggle` data
|
|
110
|
+
* @param {boolean=} show - A boolean indicating whether this is being triggered by a show or hide.
|
|
111
|
+
*/
|
|
112
|
+
private toggleOptionalClasses;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Helper to manually show an s-popover element via external JS
|
|
116
|
+
* @param element the element the `data-controller="s-popover"` attribute is on
|
|
117
|
+
*/
|
|
118
|
+
export declare function showPopover(element: HTMLElement): void;
|
|
119
|
+
/**
|
|
120
|
+
* Helper to manually hide an s-popover element via external JS
|
|
121
|
+
* @param element the element the `data-controller="s-popover"` attribute is on
|
|
122
|
+
*/
|
|
123
|
+
export declare function hidePopover(element: Element): void;
|
|
124
|
+
/**
|
|
125
|
+
* Options to use when attaching a popover via `Stacks.attachPopover`.
|
|
126
|
+
* @see Stacks.attachPopover
|
|
127
|
+
*/
|
|
128
|
+
export interface PopoverOptions {
|
|
129
|
+
/**
|
|
130
|
+
* When true, the `click->s-popover#toggle` action will be attached to the controller element or reference element.
|
|
131
|
+
*/
|
|
132
|
+
toggleOnClick?: boolean;
|
|
133
|
+
/**
|
|
134
|
+
* When set, `data-s-popover-placement` will be set to this value on the controller element.
|
|
135
|
+
*/
|
|
136
|
+
placement?: string;
|
|
137
|
+
/**
|
|
138
|
+
* When true, the popover will appear immediately when the controller connects.
|
|
139
|
+
*/
|
|
140
|
+
autoShow?: boolean;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Attaches a popover to an element and performs additional configuration.
|
|
144
|
+
* @param element the element that will receive the `data-controller="s-popover"` attribute.
|
|
145
|
+
* @param popover an element with the `.s-popover` class or HTML string containing a single element with the `.s-popover` class.
|
|
146
|
+
* If the popover does not have a parent element, it will be inserted as a immediately after the reference element.
|
|
147
|
+
* @param options an optional collection of options to use when configuring the popover.
|
|
148
|
+
*/
|
|
149
|
+
export declare function attachPopover(element: Element, popover: Element | string, options?: PopoverOptions): void;
|
|
150
|
+
/**
|
|
151
|
+
* Removes the popover controller from an element and removes the popover from the DOM.
|
|
152
|
+
* @param element the element that has the `data-controller="s-popover"` attribute.
|
|
153
|
+
* @returns The popover that was attached to the element.
|
|
154
|
+
*/
|
|
155
|
+
export declare function detachPopover(element: Element): HTMLElement | null;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as Stacks from "../stacks";
|
|
2
|
+
export declare class TableController extends Stacks.StacksController {
|
|
3
|
+
static targets: string[];
|
|
4
|
+
readonly columnTarget: Element;
|
|
5
|
+
readonly columnTargets: Element[];
|
|
6
|
+
setCurrentSort(headElem: Element, direction: "asc" | "desc" | "none"): void;
|
|
7
|
+
sort(evt: Event): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { BasePopoverController } from "./s-popover";
|
|
2
|
+
export interface TooltipOptions {
|
|
3
|
+
placement: string;
|
|
4
|
+
}
|
|
5
|
+
export declare class TooltipController extends BasePopoverController {
|
|
6
|
+
static targets: never[];
|
|
7
|
+
protected popoverSelectorAttribute: string;
|
|
8
|
+
private boundScheduleShow;
|
|
9
|
+
private boundHide;
|
|
10
|
+
private boundHideIfWithin;
|
|
11
|
+
private activeTimeout;
|
|
12
|
+
/**
|
|
13
|
+
* Binds mouseover and mouseout events in addition to BasePopoverController.connect
|
|
14
|
+
*/
|
|
15
|
+
connect(): void;
|
|
16
|
+
/**
|
|
17
|
+
* Unbinds mouse events in addition to BasePopoverController.disconnect
|
|
18
|
+
*/
|
|
19
|
+
disconnect(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Attempts to show the tooltip popover so long as no other Stacks-managed popover is
|
|
22
|
+
* present on the page.
|
|
23
|
+
*/
|
|
24
|
+
show(dispatcher?: Event | Element | null): void;
|
|
25
|
+
/**
|
|
26
|
+
* Sets up a tooltip popover show after a delay.
|
|
27
|
+
*/
|
|
28
|
+
scheduleShow(dispatcher?: Event | Element | null): void;
|
|
29
|
+
/**
|
|
30
|
+
* Cancels the scheduled tooltip popover display and hides it if already displayed
|
|
31
|
+
*/
|
|
32
|
+
hide(dispatcher?: Event | Element | null): void;
|
|
33
|
+
/**
|
|
34
|
+
* Applies data-s-tooltip-html-title and title attributes.
|
|
35
|
+
*/
|
|
36
|
+
applyTitleAttributes(): HTMLElement | null;
|
|
37
|
+
/**
|
|
38
|
+
* Automatically hides the tooltip popover when a Stacks popover is shown anywhere on
|
|
39
|
+
* the page.
|
|
40
|
+
*/
|
|
41
|
+
protected bindDocumentEvents(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Unbinds all mouse events
|
|
44
|
+
*/
|
|
45
|
+
protected unbindDocumentEvents(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Attempts to generate a new tooltip popover from the title attribute if no popover
|
|
48
|
+
* was present when requested, otherwise throws an error.
|
|
49
|
+
*/
|
|
50
|
+
protected generatePopover(): HTMLElement | null;
|
|
51
|
+
/**
|
|
52
|
+
* Hides the tooltip if is or is within the event's target.
|
|
53
|
+
* @param event An event object from s-popover:shown
|
|
54
|
+
*/
|
|
55
|
+
private hideIfWithin;
|
|
56
|
+
/**
|
|
57
|
+
* Binds mouse events to show/hide on reference element hover
|
|
58
|
+
*/
|
|
59
|
+
private bindMouseEvents;
|
|
60
|
+
/**
|
|
61
|
+
* Unbinds all mouse events
|
|
62
|
+
*/
|
|
63
|
+
private unbindMouseEvents;
|
|
64
|
+
/**
|
|
65
|
+
* Generates an ID for tooltips created with setTooltip.
|
|
66
|
+
*/
|
|
67
|
+
private static generateId;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Adds or updates a Stacks tooltip on a given element, initializing the controller if necessary
|
|
71
|
+
* @param element The element to add a tooltip to.
|
|
72
|
+
* @param html An HTML string to populate the tooltip with.
|
|
73
|
+
* @param options Options for rendering the tooltip.
|
|
74
|
+
*/
|
|
75
|
+
export declare function setTooltipHtml(element: Element, html: string, options?: TooltipOptions): void;
|
|
76
|
+
/**
|
|
77
|
+
* Adds or updates a Stacks tooltip on a given element, initializing the controller if necessary
|
|
78
|
+
* @param element The element to add a tooltip to.
|
|
79
|
+
* @param text A plain text string to populate the tooltip with.
|
|
80
|
+
* @param options Options for rendering the tooltip.
|
|
81
|
+
*/
|
|
82
|
+
export declare function setTooltipText(element: Element, text: string, options?: TooltipOptions): void;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as Stacks from "../stacks";
|
|
2
|
+
export declare class UploaderController extends Stacks.StacksController {
|
|
3
|
+
static targets: string[];
|
|
4
|
+
private inputTarget;
|
|
5
|
+
private previewsTarget;
|
|
6
|
+
private uploaderTarget;
|
|
7
|
+
private boundDragEnter;
|
|
8
|
+
private boundDragLeave;
|
|
9
|
+
private static readonly FILE_DISPLAY_LIMIT;
|
|
10
|
+
private static readonly MAX_FILE_SIZE;
|
|
11
|
+
connect(): void;
|
|
12
|
+
disconnect(): void;
|
|
13
|
+
/**
|
|
14
|
+
* Handles rendering the file preview state on input change
|
|
15
|
+
*/
|
|
16
|
+
handleInput(): void;
|
|
17
|
+
/**
|
|
18
|
+
* Resets the Uploader to initial state
|
|
19
|
+
*/
|
|
20
|
+
reset(): void;
|
|
21
|
+
/**
|
|
22
|
+
* Set hide/show and disabled state on elements depending on preview state
|
|
23
|
+
* @param {boolean} shouldPreview - Uploader is entering a preview state
|
|
24
|
+
*/
|
|
25
|
+
private handleVisible;
|
|
26
|
+
/**
|
|
27
|
+
* Adds a DOM element to preview a selected file
|
|
28
|
+
* @param {FilePreview} file
|
|
29
|
+
*/
|
|
30
|
+
private addFilePreview;
|
|
31
|
+
/**
|
|
32
|
+
* Toggles display and disabled state for select elements on valid input
|
|
33
|
+
* @param {boolean} active - Uploader is in active state (typically on 'dragenter')
|
|
34
|
+
*/
|
|
35
|
+
private handleUploaderActive;
|
|
36
|
+
/**
|
|
37
|
+
* Converts the file data into a data URL
|
|
38
|
+
* @param {File} file
|
|
39
|
+
* @returns an object containing a FilePreview object
|
|
40
|
+
*/
|
|
41
|
+
private fileToDataURL;
|
|
42
|
+
/**
|
|
43
|
+
* Gets an array of FilePreviews from a FileList
|
|
44
|
+
* @param {FileList|[]} files
|
|
45
|
+
* @returns an array of FilePreview objects from a FileList
|
|
46
|
+
*/
|
|
47
|
+
private getDataURLs;
|
|
48
|
+
}
|