@stackoverflow/stacks 0.73.1 → 0.76.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/LICENSE.MD +9 -9
- package/README.md +47 -47
- 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 +441 -141
- package/dist/css/stacks.min.css +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/js/stacks.js +6130 -5488
- package/dist/js/stacks.min.js +1 -1
- package/dist/stacks.d.ts +21 -0
- package/lib/css/atomic/_stacks-borders.less +378 -378
- package/lib/css/atomic/_stacks-colors.less +209 -209
- package/lib/css/atomic/_stacks-flex.less +374 -374
- package/lib/css/atomic/_stacks-grid.less +174 -173
- package/lib/css/atomic/_stacks-misc.less +343 -342
- package/lib/css/atomic/_stacks-spacing.less +168 -162
- package/lib/css/atomic/_stacks-typography.less +273 -270
- package/lib/css/atomic/_stacks-width-height.less +195 -189
- package/lib/css/base/_stacks-body.less +44 -46
- package/lib/css/base/_stacks-configuration-static.less +59 -59
- package/lib/css/base/_stacks-icons.less +20 -20
- package/lib/css/base/_stacks-internals.less +220 -230
- package/lib/css/base/_stacks-reset-meyer.less +64 -64
- package/lib/css/base/_stacks-reset-normalize.less +449 -449
- package/lib/css/base/_stacks-reset.less +20 -20
- package/lib/css/components/_stacks-activity-indicator.less +45 -45
- package/lib/css/components/_stacks-avatars.less +189 -189
- package/lib/css/components/_stacks-badges.less +209 -209
- package/lib/css/components/_stacks-banners.less +80 -81
- package/lib/css/components/_stacks-blank-states.less +26 -26
- package/lib/css/components/_stacks-breadcrumbs.less +44 -44
- package/lib/css/components/_stacks-button-groups.less +104 -104
- package/lib/css/components/_stacks-buttons.less +658 -660
- package/lib/css/components/_stacks-cards.less +44 -44
- package/lib/css/components/_stacks-code-blocks.less +130 -130
- package/lib/css/components/_stacks-collapsible.less +104 -104
- package/lib/css/components/_stacks-inputs.less +728 -724
- package/lib/css/components/_stacks-link-previews.less +136 -136
- package/lib/css/components/_stacks-links.less +218 -218
- package/lib/css/components/_stacks-menu.less +47 -47
- package/lib/css/components/_stacks-modals.less +133 -133
- package/lib/css/components/_stacks-navigation.less +146 -146
- package/lib/css/components/_stacks-notices.less +233 -233
- package/lib/css/components/_stacks-page-titles.less +60 -60
- package/lib/css/components/_stacks-pagination.less +55 -55
- package/lib/css/components/_stacks-popovers.less +197 -197
- package/lib/css/components/_stacks-post-summary.less +425 -311
- package/lib/css/components/_stacks-progress-bars.less +331 -331
- package/lib/css/components/_stacks-prose.less +503 -503
- package/lib/css/components/_stacks-spinner.less +107 -107
- package/lib/css/components/_stacks-tables.less +341 -341
- package/lib/css/components/_stacks-tags.less +237 -209
- package/lib/css/components/_stacks-toggle-switches.less +144 -137
- package/lib/css/components/_stacks-topbar.less +425 -440
- package/lib/css/components/_stacks-uploader.less +210 -210
- package/lib/css/components/_stacks-user-cards.less +169 -193
- package/lib/css/components/_stacks-widget-dynamic.less +33 -33
- package/lib/css/components/_stacks-widget-static.less +272 -272
- package/lib/css/exports/_stacks-constants-colors.less +1112 -1098
- package/lib/css/exports/_stacks-constants-helpers.less +139 -139
- package/lib/css/exports/_stacks-constants-type.less +152 -91
- package/lib/css/exports/_stacks-exports.less +15 -15
- package/lib/css/exports/_stacks-mixins.less +220 -220
- package/lib/css/stacks-dynamic.less +35 -36
- package/lib/css/stacks-static.less +86 -86
- package/lib/ts/controllers/index.ts +8 -0
- package/lib/ts/controllers/s-expandable-control.ts +189 -190
- package/lib/ts/controllers/s-modal.ts +321 -323
- package/lib/ts/controllers/s-navigation-tablist.ts +118 -119
- package/lib/ts/controllers/s-popover.ts +547 -549
- package/lib/ts/controllers/s-table.ts +220 -220
- package/lib/ts/controllers/s-tooltip.ts +246 -247
- package/lib/ts/controllers/s-uploader.ts +172 -174
- package/lib/ts/index.ts +20 -0
- package/lib/ts/stacks.ts +88 -83
- package/lib/tsconfig.json +13 -11
- package/package.json +87 -71
- package/dist/css/stacks-flexgrid-shim.min.css +0 -1
- package/lib/css/base/_stacks-configuration-dynamic.less +0 -106
- package/lib/ts/finalize.ts +0 -1
- package/lib/ts/stimulus.d.ts +0 -4
package/LICENSE.MD
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright 2017-2020 Stack Exchange Inc.
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
-
|
|
7
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
-
|
|
9
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright 2017-2020 Stack Exchange Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
# Stacks
|
|
2
|
-
|
|
3
|
-
Stacks is Stack Overflow’s design system. It includes the resources needed to create consistent, predictable interfaces and workflows that conform to Stack Overflow’s principles, design language, and best practices.
|
|
4
|
-
|
|
5
|
-
Our documentation is built with Stacks itself, using its [immutable, atomic classes](http://johnpolacek.com/rethinking/) and components.
|
|
6
|
-
|
|
7
|
-
The Stacks website documents:
|
|
8
|
-
|
|
9
|
-
### Product
|
|
10
|
-
- Semantic and accessible component markup
|
|
11
|
-
- Cross-browser compatible Less / CSS
|
|
12
|
-
- An [icon library](https://github.com/StackExchange/Stacks-Icons)
|
|
13
|
-
|
|
14
|
-
### Email
|
|
15
|
-
- Email templates & components
|
|
16
|
-
|
|
17
|
-
Stacks documentation can be found at https://stackoverflow.design/
|
|
18
|
-
|
|
19
|
-
## Table of contents
|
|
20
|
-
|
|
21
|
-
- [Using Stacks](#using-stacks)
|
|
22
|
-
- [Building Stacks](#building-stacks)
|
|
23
|
-
- [Bugs and feature requests](#bugs-and-feature-requests)
|
|
24
|
-
- [Contributing](#contributing)
|
|
25
|
-
- [License](#license)
|
|
26
|
-
|
|
27
|
-
## Using Stacks
|
|
28
|
-
Using Stacks is outlined in our [usage guidelines](https://stackoverflow.design/product/guidelines/using-stacks).
|
|
29
|
-
|
|
30
|
-
## Building Stacks
|
|
31
|
-
To contribute to Stacks documentation or its CSS library, you’ll need to build Stacks locally. View our [building guidelines](https://stackoverflow.design/product/guidelines/building).
|
|
32
|
-
|
|
33
|
-
Having trouble getting these steps to work? Open [an issue](https://github.com/StackExchange/Stacks/issues/new) with a `setup` label.
|
|
34
|
-
|
|
35
|
-
## Testing Stacks
|
|
36
|
-
Stacks has implemented visual regression testing with [Backstop](https://github.com/garris/BackstopJS). To test if your new feature introduces visual regressions, run `npm run test` in a new Terminal window while Stacks is running. After the tests have run, a new browser window with any regressions will show. If the regressions are desired, you can run `npm run approve` to establish the new baseline.
|
|
37
|
-
|
|
38
|
-
Individual routes to test are found in [backstop.json](/backstop.json)
|
|
39
|
-
|
|
40
|
-
## Bugs and feature requests
|
|
41
|
-
Have a bug or feature request? First search existing or closed issues to make sure the issue hasn’t been noted yet. If not, review our [issue guidelines](/CONTRIBUTING.md#open-an-issue) for submitting [a bug report](/CONTRIBUTING.md#reporting-bugs) or [feature request](/CONTRIBUTING.md#feature-requests).
|
|
42
|
-
|
|
43
|
-
## Contributing
|
|
44
|
-
If you’d like to contribute to Stacks, please read through our [contribution guidelines](/CONTRIBUTING.md). Included are directions for opening issues, coding standards, and notes on development.
|
|
45
|
-
|
|
46
|
-
## License
|
|
47
|
-
Code and documentation copyright 2017-2022 Stack Exchange, Inc and released under the [MIT License](/LICENSE.MD).
|
|
1
|
+
# Stacks
|
|
2
|
+
|
|
3
|
+
Stacks is Stack Overflow’s design system. It includes the resources needed to create consistent, predictable interfaces and workflows that conform to Stack Overflow’s principles, design language, and best practices.
|
|
4
|
+
|
|
5
|
+
Our documentation is built with Stacks itself, using its [immutable, atomic classes](http://johnpolacek.com/rethinking/) and components.
|
|
6
|
+
|
|
7
|
+
The Stacks website documents:
|
|
8
|
+
|
|
9
|
+
### Product
|
|
10
|
+
- Semantic and accessible component markup
|
|
11
|
+
- Cross-browser compatible Less / CSS
|
|
12
|
+
- An [icon library](https://github.com/StackExchange/Stacks-Icons)
|
|
13
|
+
|
|
14
|
+
### Email
|
|
15
|
+
- Email templates & components
|
|
16
|
+
|
|
17
|
+
Stacks documentation can be found at https://stackoverflow.design/
|
|
18
|
+
|
|
19
|
+
## Table of contents
|
|
20
|
+
|
|
21
|
+
- [Using Stacks](#using-stacks)
|
|
22
|
+
- [Building Stacks](#building-stacks)
|
|
23
|
+
- [Bugs and feature requests](#bugs-and-feature-requests)
|
|
24
|
+
- [Contributing](#contributing)
|
|
25
|
+
- [License](#license)
|
|
26
|
+
|
|
27
|
+
## Using Stacks
|
|
28
|
+
Using Stacks is outlined in our [usage guidelines](https://stackoverflow.design/product/guidelines/using-stacks).
|
|
29
|
+
|
|
30
|
+
## Building Stacks
|
|
31
|
+
To contribute to Stacks documentation or its CSS library, you’ll need to build Stacks locally. View our [building guidelines](https://stackoverflow.design/product/guidelines/building).
|
|
32
|
+
|
|
33
|
+
Having trouble getting these steps to work? Open [an issue](https://github.com/StackExchange/Stacks/issues/new) with a `setup` label.
|
|
34
|
+
|
|
35
|
+
## Testing Stacks
|
|
36
|
+
Stacks has implemented visual regression testing with [Backstop](https://github.com/garris/BackstopJS). To test if your new feature introduces visual regressions, run `npm run test` in a new Terminal window while Stacks is running. After the tests have run, a new browser window with any regressions will show. If the regressions are desired, you can run `npm run approve` to establish the new baseline.
|
|
37
|
+
|
|
38
|
+
Individual routes to test are found in [backstop.json](/backstop.json)
|
|
39
|
+
|
|
40
|
+
## Bugs and feature requests
|
|
41
|
+
Have a bug or feature request? First search existing or closed issues to make sure the issue hasn’t been noted yet. If not, review our [issue guidelines](/CONTRIBUTING.md#open-an-issue) for submitting [a bug report](/CONTRIBUTING.md#reporting-bugs) or [feature request](/CONTRIBUTING.md#feature-requests).
|
|
42
|
+
|
|
43
|
+
## Contributing
|
|
44
|
+
If you’d like to contribute to Stacks, please read through our [contribution guidelines](/CONTRIBUTING.md). Included are directions for opening issues, coding standards, and notes on development.
|
|
45
|
+
|
|
46
|
+
## License
|
|
47
|
+
Code and documentation copyright 2017-2022 Stack Exchange, Inc and released under the [MIT License](/LICENSE.MD).
|
|
@@ -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
|
+
}
|