@mediafly/js-ui 51.1.1 → 51.1.2
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/.node-version +1 -1
- package/.release-it.json +13 -13
- package/.semaphore/promotion-deploy-docs.yml +35 -35
- package/.semaphore/scripts/notify_jira.sh +115 -115
- package/.semaphore/semaphore.yml +91 -91
- package/.stylelintignore +5 -5
- package/CHANGELOG.md +468 -464
- package/README.md +61 -61
- package/archive/old-changelog.md +1645 -1645
- package/browserslist.config.js +27 -27
- package/cypress.config.ts +26 -26
- package/lib/actionable-empty-state/actionable-empty-state.html +15 -15
- package/lib/auto-complete/auto-complete-match-renderer.component.html +20 -20
- package/lib/auto-complete/auto-complete.component.html +43 -43
- package/lib/badge/badge.html +3 -3
- package/lib/checkbox/checkbox.html +23 -23
- package/lib/color-input/color-input.html +32 -32
- package/lib/date-input/date-input.html +31 -31
- package/lib/date-time-zone-picker/date-time-zone-picker.html +36 -36
- package/lib/date-time-zone-picker/datepicker.html +31 -31
- package/lib/date-time-zone-picker/time-zone-picker.html +21 -21
- package/lib/date-time-zone-picker/timepicker.html +32 -32
- package/lib/dropdown/dropdown.html +21 -21
- package/lib/dropdown-menu/dropdown-menu-action.component.html +25 -25
- package/lib/dropdown-menu/dropdown-menu-contents.html +3 -3
- package/lib/dropdown-menu/dropdown-menu-header.html +1 -1
- package/lib/dropdown-menu/dropdown-menu-item.html +1 -1
- package/lib/dropdown-menu/dropdown-menu-note.html +1 -1
- package/lib/dropdown-menu/dropdown-menu-separator.html +1 -1
- package/lib/dropdown-menu/dropdown-menu.html +1 -1
- package/lib/feedback/feedback.component.html +24 -24
- package/lib/first-time-motivator/first-time-motivator-transclude.html +1 -1
- package/lib/first-time-motivator/first-time-motivator.html +29 -29
- package/lib/font-selector/font-selector.html +67 -67
- package/lib/footer/footer.html +6 -6
- package/lib/hierarchy/hierarchy.html +38 -38
- package/lib/icon/icon.html +1 -1
- package/lib/icon/icon.service.js +3 -1
- package/lib/icon/icon.service.js.map +1 -1
- package/lib/inline-text-input/inline-text-input.component.html +13 -13
- package/lib/jsui.module.css +494 -494
- package/lib/loading-indicator/loading-indicator.component.html +12 -12
- package/lib/login-textinput/login-textinput.html +14 -14
- package/lib/metadata-form/metadata-form.html +547 -547
- package/lib/metadata-form/typeahead-match.template.html +3 -3
- package/lib/modal/modal.component.html +39 -39
- package/lib/paging/pager.html +20 -20
- package/lib/paging/paging-range-bottom.html +8 -8
- package/lib/paging/paging-range-top.html +34 -34
- package/lib/progress-bar/progress-bar.html +6 -6
- package/lib/progress-circle/progress-circle.html +15 -15
- package/lib/rich-text/rich-text.component.html +64 -64
- package/lib/site-header/site-header-navbar-item.component.html +12 -12
- package/lib/site-header/site-header.component.html +28 -28
- package/lib/table-blank-slate/table-blank-slate.html +16 -16
- package/lib/tabs/tab-group.html +20 -20
- package/lib/tabs/tab.html +2 -2
- package/lib/tag-input/tag-input.html +66 -66
- package/lib/textarea/textarea.html +16 -16
- package/lib/textinput/textinput.html +33 -33
- package/lib/time-input/time-input.html +47 -47
- package/lib/tree/tree-node.html +56 -56
- package/lib/tree/tree.html +27 -27
- package/lib/tsconfig.deploy.tsbuildinfo +140 -140
- package/lib/type-string/type-string.component.html +1 -1
- package/package.json +117 -117
- package/src/components/actionable-empty-state/actionable-empty-state.html +15 -15
- package/src/components/actionable-empty-state/actionable-empty-state.less +19 -19
- package/src/components/actionable-empty-state/actionable-empty-state.ts +36 -36
- package/src/components/actionable-empty-state/index.ts +1 -1
- package/src/components/auto-complete/auto-complete-match-renderer.component.html +20 -20
- package/src/components/auto-complete/auto-complete-match-renderer.component.ts +240 -240
- package/src/components/auto-complete/auto-complete.component.html +43 -43
- package/src/components/auto-complete/auto-complete.component.less +66 -66
- package/src/components/auto-complete/auto-complete.component.ts +69 -69
- package/src/components/auto-complete/index.ts +2 -2
- package/src/components/auto-focus/auto-focus.service.ts +24 -24
- package/src/components/auto-focus/auto-focus.ts +13 -13
- package/src/components/auto-focus/index.ts +2 -2
- package/src/components/badge/badge.html +3 -3
- package/src/components/badge/badge.less +47 -47
- package/src/components/badge/badge.ts +14 -14
- package/src/components/badge/index.ts +1 -1
- package/src/components/checkbox/checkbox.html +23 -23
- package/src/components/checkbox/checkbox.js +29 -29
- package/src/components/checkbox/index.ts +1 -1
- package/src/components/collapse/collapse.js +86 -86
- package/src/components/collapse/collapse.less +17 -17
- package/src/components/collapse/index.ts +1 -1
- package/src/components/color-input/color-input.html +32 -32
- package/src/components/color-input/color-input.less +623 -623
- package/src/components/color-input/color-input.ts +95 -95
- package/src/components/color-input/index.ts +2 -2
- package/src/components/color-input/spectrum-color-picker.js +59 -59
- package/src/components/color-utils/color-utils.service.ts +34 -34
- package/src/components/color-utils/index.ts +1 -1
- package/src/components/constants/constants.js +7 -7
- package/src/components/constants/index.ts +1 -1
- package/src/components/date-input/date-input.html +31 -31
- package/src/components/date-input/date-input.js +115 -115
- package/src/components/date-input/date-input.less +20 -20
- package/src/components/date-input/index.ts +2 -2
- package/src/components/date-input/validate-date.js +32 -32
- package/src/components/date-time-zone-picker/date-time-zone-factory.ts +122 -122
- package/src/components/date-time-zone-picker/date-time-zone-picker.html +36 -36
- package/src/components/date-time-zone-picker/date-time-zone-picker.less +55 -55
- package/src/components/date-time-zone-picker/date-time-zone-picker.ts +159 -159
- package/src/components/date-time-zone-picker/datepicker.html +31 -31
- package/src/components/date-time-zone-picker/datepicker.ts +173 -173
- package/src/components/date-time-zone-picker/index.ts +6 -6
- package/src/components/date-time-zone-picker/time-format-filter.ts +60 -60
- package/src/components/date-time-zone-picker/time-zone-picker.html +21 -21
- package/src/components/date-time-zone-picker/time-zone-picker.js +45 -45
- package/src/components/date-time-zone-picker/timepicker.html +32 -32
- package/src/components/date-time-zone-picker/timepicker.js +115 -115
- package/src/components/decorators/index.ts +82 -82
- package/src/components/dropdown/dropdown.html +21 -21
- package/src/components/dropdown/dropdown.less +67 -67
- package/src/components/dropdown/dropdown.ts +96 -96
- package/src/components/dropdown/index.ts +1 -1
- package/src/components/dropdown-menu/dropdown-menu-action.component.html +25 -25
- package/src/components/dropdown-menu/dropdown-menu-action.component.ts +70 -70
- package/src/components/dropdown-menu/dropdown-menu-contents.html +3 -3
- package/src/components/dropdown-menu/dropdown-menu-contents.ts +119 -119
- package/src/components/dropdown-menu/dropdown-menu-header.html +1 -1
- package/src/components/dropdown-menu/dropdown-menu-header.js +12 -12
- package/src/components/dropdown-menu/dropdown-menu-item.html +1 -1
- package/src/components/dropdown-menu/dropdown-menu-item.js +12 -12
- package/src/components/dropdown-menu/dropdown-menu-note.html +1 -1
- package/src/components/dropdown-menu/dropdown-menu-note.js +12 -12
- package/src/components/dropdown-menu/dropdown-menu-separator.html +1 -1
- package/src/components/dropdown-menu/dropdown-menu-separator.js +11 -11
- package/src/components/dropdown-menu/dropdown-menu-toggle.js +74 -74
- package/src/components/dropdown-menu/dropdown-menu.html +1 -1
- package/src/components/dropdown-menu/dropdown-menu.less +141 -141
- package/src/components/dropdown-menu/dropdown-menu.ts +84 -84
- package/src/components/dropdown-menu/index.ts +8 -8
- package/src/components/feedback/clipboard.service.ts +42 -42
- package/src/components/feedback/feedback.component.html +24 -24
- package/src/components/feedback/feedback.component.ts +125 -125
- package/src/components/feedback/feedback.less +126 -126
- package/src/components/feedback/feedback.service.ts +51 -51
- package/src/components/feedback/index.ts +3 -3
- package/src/components/first-time-motivator/first-time-motivator-transclude.html +1 -1
- package/src/components/first-time-motivator/first-time-motivator.html +29 -29
- package/src/components/first-time-motivator/first-time-motivator.less +151 -151
- package/src/components/first-time-motivator/first-time-motivator.ts +337 -337
- package/src/components/first-time-motivator/ftm-target-element.ts +98 -98
- package/src/components/first-time-motivator/index.ts +2 -2
- package/src/components/font-selector/font-selector.html +67 -67
- package/src/components/font-selector/font-selector.less +122 -122
- package/src/components/font-selector/font-selector.ts +258 -258
- package/src/components/font-selector/google-webfonts-api.backend.ts +5 -5
- package/src/components/font-selector/google-webfonts-api.service.ts +28 -28
- package/src/components/font-selector/index.ts +3 -3
- package/src/components/font-selector/webfont-loader.service.ts +42 -42
- package/src/components/footer/footer.html +6 -6
- package/src/components/footer/footer.js +21 -21
- package/src/components/footer/footer.less +9 -9
- package/src/components/footer/index.ts +1 -1
- package/src/components/form-validation-utils/form-validation-utils.ts +11 -11
- package/src/components/form-validation-utils/index.ts +1 -1
- package/src/components/full-screen/full-screen.service.ts +62 -62
- package/src/components/full-screen/index.ts +1 -1
- package/src/components/gesture-handler/gesture-handler.ts +116 -116
- package/src/components/gesture-handler/index.ts +1 -1
- package/src/components/gesture-handler/test/gesture-handler.spec.js +26 -26
- package/src/components/hierarchy/hierarchy.html +38 -38
- package/src/components/hierarchy/hierarchy.js +24 -24
- package/src/components/hierarchy/hierarchy.less +42 -42
- package/src/components/hierarchy/index.ts +1 -1
- package/src/components/hover-tooltip/hover-tooltip.less +85 -85
- package/src/components/hover-tooltip/hover-tooltip.ts +145 -145
- package/src/components/hover-tooltip/index.ts +1 -1
- package/src/components/icon/icon.html +1 -1
- package/src/components/icon/icon.service.ts +70 -68
- package/src/components/icon/icon.ts +34 -34
- package/src/components/icon/index.ts +2 -2
- package/src/components/index.less +34 -34
- package/src/components/index.ts +47 -47
- package/src/components/inline-text-input/index.ts +1 -1
- package/src/components/inline-text-input/inline-text-input.component.html +13 -13
- package/src/components/inline-text-input/inline-text-input.component.ts +10 -10
- package/src/components/inline-text-input/inline-text-input.less +17 -17
- package/src/components/legacy/mediafly-bootstrap.css +2890 -2890
- package/src/components/legacy/mediafly-utils.js +15 -15
- package/src/components/legacy/mediafly.css +2323 -2323
- package/src/components/legacy/oocss.css +77 -77
- package/src/components/less/fonts/font-awesome.less +7146 -7146
- package/src/components/less/fonts/index.less +4 -4
- package/src/components/less/fonts/mfly-webfont.less +93 -93
- package/src/components/less/fonts/poppins.less +26 -26
- package/src/components/less/fonts/roboto.less +38 -38
- package/src/components/less/mixins/vendor-prefixes.less +287 -287
- package/src/components/less/objects/buttons.less +277 -277
- package/src/components/less/objects/buttons.module.css +198 -198
- package/src/components/less/objects/containers.less +246 -246
- package/src/components/less/objects/containers.module.css +18 -18
- package/src/components/less/objects/forms.less +203 -203
- package/src/components/less/objects/grid.less +985 -985
- package/src/components/less/objects/headers.less +81 -81
- package/src/components/less/objects/headers.module.css +85 -85
- package/src/components/less/objects/index.less +11 -11
- package/src/components/less/objects/labels.less +26 -26
- package/src/components/less/objects/links.less +58 -58
- package/src/components/less/objects/links.module.css +57 -57
- package/src/components/less/objects/modals.less +40 -40
- package/src/components/less/objects/radios-checkboxes.less +234 -234
- package/src/components/less/objects/tables.less +237 -237
- package/src/components/less/objects/tabs.less +28 -28
- package/src/components/less/standalone.less +8 -8
- package/src/components/less/utilities/accessibility.less +39 -39
- package/src/components/less/utilities/animations.less +41 -41
- package/src/components/less/utilities/grid-utilities.less +115 -115
- package/src/components/less/utilities/index.less +6 -6
- package/src/components/less/utilities/normalize.less +344 -344
- package/src/components/less/utilities/reset.less +52 -52
- package/src/components/less/utilities/utilities.less +173 -173
- package/src/components/less/variables/colors.less +62 -62
- package/src/components/less/variables/effects.less +17 -17
- package/src/components/less/variables/forms.less +16 -16
- package/src/components/less/variables/index.less +6 -6
- package/src/components/less/variables/pages.less +25 -25
- package/src/components/less/variables/typography.less +19 -19
- package/src/components/less/variables/z-index.less +24 -24
- package/src/components/less/variables.module.css +132 -132
- package/src/components/less/vendor/index.less +2 -2
- package/src/components/less/vendor/pikaday.css +225 -225
- package/src/components/less/vendor/quill.snow.css +10 -10
- package/src/components/loading-indicator/index.ts +1 -1
- package/src/components/loading-indicator/loading-indicator.component.html +12 -12
- package/src/components/loading-indicator/loading-indicator.component.ts +10 -10
- package/src/components/loading-indicator/loading-indicator.less +62 -62
- package/src/components/localization/index.strings.json +50 -50
- package/src/components/login-textinput/index.ts +1 -1
- package/src/components/login-textinput/login-textinput.html +14 -14
- package/src/components/login-textinput/login-textinput.js +26 -26
- package/src/components/metadata-form/index.ts +12 -12
- package/src/components/metadata-form/metadata-form.component.ts +352 -352
- package/src/components/metadata-form/metadata-form.html +547 -547
- package/src/components/metadata-form/metadata-form.less +153 -153
- package/src/components/metadata-form/template-cache.run.ts +8 -8
- package/src/components/metadata-form/typeahead-match.template.html +3 -3
- package/src/components/modal/index.ts +2 -2
- package/src/components/modal/modal.component.html +39 -39
- package/src/components/modal/modal.component.less +136 -136
- package/src/components/modal/modal.component.module.css +126 -126
- package/src/components/modal/modal.component.ts +170 -170
- package/src/components/modal/modal.service.ts +169 -169
- package/src/components/on-media-error/index.ts +1 -1
- package/src/components/on-media-error/on-media-error.js +23 -23
- package/src/components/page-thumbnail/index.ts +1 -1
- package/src/components/page-thumbnail/page-thumbnail.ts +159 -159
- package/src/components/paging/index.ts +4 -4
- package/src/components/paging/pager.html +20 -20
- package/src/components/paging/pager.js +63 -63
- package/src/components/paging/paging-factory.js +36 -36
- package/src/components/paging/paging-range-bottom.html +8 -8
- package/src/components/paging/paging-range-bottom.js +50 -50
- package/src/components/paging/paging-range-top.html +34 -34
- package/src/components/paging/paging-range-top.js +36 -36
- package/src/components/paging/paging.less +36 -36
- package/src/components/progress-bar/index.ts +1 -1
- package/src/components/progress-bar/progress-bar.component.ts +27 -27
- package/src/components/progress-bar/progress-bar.html +6 -6
- package/src/components/progress-bar/progress-bar.less +24 -24
- package/src/components/progress-circle/index.ts +1 -1
- package/src/components/progress-circle/progress-circle.html +15 -15
- package/src/components/progress-circle/progress-circle.less +146 -146
- package/src/components/progress-circle/progress-circle.ts +30 -30
- package/src/components/response-handlers/api-success-handlers.ts +14 -14
- package/src/components/response-handlers/error-response.service.ts +40 -40
- package/src/components/response-handlers/feedback-error-handler.ts +25 -25
- package/src/components/response-handlers/index.ts +4 -4
- package/src/components/response-handlers/log-error-handler.ts +15 -15
- package/src/components/rich-text/index.ts +2 -2
- package/src/components/rich-text/rich-text.component.html +64 -64
- package/src/components/rich-text/rich-text.component.less +139 -139
- package/src/components/rich-text/rich-text.component.ts +622 -622
- package/src/components/rich-text/rich-text.service.ts +158 -158
- package/src/components/site-header/default-background-img.b64.js +1 -1
- package/src/components/site-header/index.ts +2 -2
- package/src/components/site-header/site-header-navbar-item.component.html +12 -12
- package/src/components/site-header/site-header-navbar-item.component.ts +24 -24
- package/src/components/site-header/site-header.component.html +28 -28
- package/src/components/site-header/site-header.component.ts +30 -30
- package/src/components/site-header/site-header.less +196 -196
- package/src/components/style-typings/styles.ts +37 -37
- package/src/components/table-blank-slate/index.ts +1 -1
- package/src/components/table-blank-slate/table-blank-slate.html +16 -16
- package/src/components/table-blank-slate/table-blank-slate.js +17 -17
- package/src/components/table-blank-slate/table-blank-slate.less +22 -22
- package/src/components/tabs/index.ts +4 -4
- package/src/components/tabs/tab-group.html +20 -20
- package/src/components/tabs/tab-group.ts +159 -159
- package/src/components/tabs/tab-html-title-append.ts +17 -17
- package/src/components/tabs/tab-html-title.ts +33 -33
- package/src/components/tabs/tab.html +2 -2
- package/src/components/tabs/tab.ts +55 -55
- package/src/components/tabs/tabs.less +44 -44
- package/src/components/tag-input/index.ts +1 -1
- package/src/components/tag-input/tag-input.component.ts +135 -135
- package/src/components/tag-input/tag-input.html +66 -66
- package/src/components/tag-input/tag-input.less +107 -107
- package/src/components/textarea/index.ts +1 -1
- package/src/components/textarea/textarea.html +16 -16
- package/src/components/textarea/textarea.js +30 -30
- package/src/components/textinput/index.ts +1 -1
- package/src/components/textinput/textinput.html +33 -33
- package/src/components/textinput/textinput.ts +54 -54
- package/src/components/theme/index.ts +1 -1
- package/src/components/theme/theme.service.ts +71 -71
- package/src/components/theme/theme.typings.ts +3 -3
- package/src/components/time-input/index.ts +2 -2
- package/src/components/time-input/time-input.html +47 -47
- package/src/components/time-input/time-input.js +160 -160
- package/src/components/time-input/time-input.less +25 -25
- package/src/components/time-input/validate-time.js +30 -30
- package/src/components/translate/index.ts +1 -1
- package/src/components/translate/translate-factory.ts +49 -49
- package/src/components/tree/index.ts +3 -3
- package/src/components/tree/recursion-factory.js +43 -43
- package/src/components/tree/tree-node.html +56 -56
- package/src/components/tree/tree-node.js +30 -30
- package/src/components/tree/tree.html +27 -27
- package/src/components/tree/tree.less +117 -117
- package/src/components/tree/tree.ts +108 -108
- package/src/components/type-string/index.ts +1 -1
- package/src/components/type-string/type-string.component.html +1 -1
- package/src/components/type-string/type-string.component.ts +63 -63
- package/src/components/url-modification/index.ts +1 -1
- package/src/components/url-modification/url-modification.service.ts +33 -33
- package/src/index.html +90 -90
- package/src/index.js +23 -23
- package/src/index.less +16 -16
- package/src/index.spec.js +39 -39
- package/stylelint.config.js +8 -8
- package/tsconfig.deploy.json +29 -29
- package/tsconfig.json +34 -34
- package/tslint.json +4 -4
- package/typings/index.d.ts +46 -46
- package/webpack.config.js +228 -228
- package/tsconfig.tsbuildinfo +0 -7675
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
import _ from 'lodash'
|
|
2
|
-
import { Component, Inject, Input, Output } from '../decorators'
|
|
3
|
-
import type { TranslateFactory } from '../translate/translate-factory'
|
|
4
|
-
|
|
5
|
-
export type MFDropdownInputEnumOption = { id: MFDropdownInputOptionValue, label: string } | string
|
|
6
|
-
export type MFDropdownInputOption = { id: MFDropdownInputOptionValue, label: string }
|
|
7
|
-
export type MFDropdownInputOptionValue = string | undefined | null
|
|
8
|
-
|
|
9
|
-
@Component({
|
|
10
|
-
selector: 'mflyDropdown',
|
|
11
|
-
template: require('./dropdown.html'),
|
|
12
|
-
})
|
|
13
|
-
export class MflyDropdown implements ng.IComponentController {
|
|
14
|
-
|
|
15
|
-
@Input('@') dropdownTheme?: string
|
|
16
|
-
@Input() enumOptions: MFDropdownInputEnumOption[] | undefined
|
|
17
|
-
@Input('@') inputId: string
|
|
18
|
-
@Input() isDisabled: boolean
|
|
19
|
-
@Input('@') noEmptyOption: boolean
|
|
20
|
-
@Input('@') required: boolean
|
|
21
|
-
@Input('=') value: MFDropdownInputOptionValue
|
|
22
|
-
|
|
23
|
-
@Output() onChange?: (v: { value: MFDropdownInputOptionValue }) => void
|
|
24
|
-
@Output() onClick?: () => void
|
|
25
|
-
|
|
26
|
-
protected options: Array<{ id: MFDropdownInputOptionValue, label: string }> = []
|
|
27
|
-
protected requiredText: string
|
|
28
|
-
|
|
29
|
-
constructor(
|
|
30
|
-
@Inject('translateFactory') private translateFactory: TranslateFactory,
|
|
31
|
-
) {}
|
|
32
|
-
|
|
33
|
-
$onChanges(changes: { enumOptions?: ng.IChangesObject<MFDropdownInputEnumOption[] | undefined> }) {
|
|
34
|
-
|
|
35
|
-
// $onChanges triggers before the first $onInit, so this will handle initializing the options too
|
|
36
|
-
if (changes.enumOptions) {
|
|
37
|
-
this.options = this.transformOptions(changes.enumOptions.currentValue)
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
$onInit() {
|
|
42
|
-
|
|
43
|
-
this.requiredText = this.translateFactory.instant('JSUI.REQUIRED')
|
|
44
|
-
this.manageEmptyOptions()
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
valueWasChanged(value: MFDropdownInputOptionValue) {
|
|
48
|
-
|
|
49
|
-
this.manageEmptyOptions()
|
|
50
|
-
|
|
51
|
-
if (this.onChange) {
|
|
52
|
-
this.onChange({ value })
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
inputWasClicked() {
|
|
57
|
-
|
|
58
|
-
if (this.onClick) {
|
|
59
|
-
this.onClick()
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
private transformOptions(incomingOptions: MFDropdownInputEnumOption[] | undefined): MFDropdownInputOption[] {
|
|
64
|
-
|
|
65
|
-
return (incomingOptions || []).map(option => {
|
|
66
|
-
if (typeof option === 'string') {
|
|
67
|
-
return { id: option, label: option }
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return option
|
|
71
|
-
})
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
private manageEmptyOptions() {
|
|
75
|
-
|
|
76
|
-
// Start by removing all empty options, we will put them back if needed.
|
|
77
|
-
_.remove(this.options, option => !option.id)
|
|
78
|
-
|
|
79
|
-
// This is a weird case; if value is set to something that can't be matched,
|
|
80
|
-
// Angular inserts an option with a value of the string `?`. In this case
|
|
81
|
-
// we don't want to add a null option because the ? option already has a blank label.
|
|
82
|
-
const valueDoesNotMatchAnOption = !this.options.find(option => option.id === this.value)
|
|
83
|
-
if (valueDoesNotMatchAnOption) { return }
|
|
84
|
-
|
|
85
|
-
// There is a selected value and we want to allow empty options.
|
|
86
|
-
// In this case, prepend an empty option to allow the user to clear the value.
|
|
87
|
-
// This id is set to `null` because we use that to indicate "unset this" in bulk editing.
|
|
88
|
-
if (!!this.value && !this.noEmptyOption) {
|
|
89
|
-
this.options.unshift({ id: null, label: '' })
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// If value is null or undefined, we don't need to do anything. Angular will add an
|
|
93
|
-
// option with the current value (that will be blank), which will vanish when the
|
|
94
|
-
// user selects another option. This code will then add back a "blank" value if needed.
|
|
95
|
-
}
|
|
96
|
-
}
|
|
1
|
+
import _ from 'lodash'
|
|
2
|
+
import { Component, Inject, Input, Output } from '../decorators'
|
|
3
|
+
import type { TranslateFactory } from '../translate/translate-factory'
|
|
4
|
+
|
|
5
|
+
export type MFDropdownInputEnumOption = { id: MFDropdownInputOptionValue, label: string } | string
|
|
6
|
+
export type MFDropdownInputOption = { id: MFDropdownInputOptionValue, label: string }
|
|
7
|
+
export type MFDropdownInputOptionValue = string | undefined | null
|
|
8
|
+
|
|
9
|
+
@Component({
|
|
10
|
+
selector: 'mflyDropdown',
|
|
11
|
+
template: require('./dropdown.html'),
|
|
12
|
+
})
|
|
13
|
+
export class MflyDropdown implements ng.IComponentController {
|
|
14
|
+
|
|
15
|
+
@Input('@') dropdownTheme?: string
|
|
16
|
+
@Input() enumOptions: MFDropdownInputEnumOption[] | undefined
|
|
17
|
+
@Input('@') inputId: string
|
|
18
|
+
@Input() isDisabled: boolean
|
|
19
|
+
@Input('@') noEmptyOption: boolean
|
|
20
|
+
@Input('@') required: boolean
|
|
21
|
+
@Input('=') value: MFDropdownInputOptionValue
|
|
22
|
+
|
|
23
|
+
@Output() onChange?: (v: { value: MFDropdownInputOptionValue }) => void
|
|
24
|
+
@Output() onClick?: () => void
|
|
25
|
+
|
|
26
|
+
protected options: Array<{ id: MFDropdownInputOptionValue, label: string }> = []
|
|
27
|
+
protected requiredText: string
|
|
28
|
+
|
|
29
|
+
constructor(
|
|
30
|
+
@Inject('translateFactory') private translateFactory: TranslateFactory,
|
|
31
|
+
) {}
|
|
32
|
+
|
|
33
|
+
$onChanges(changes: { enumOptions?: ng.IChangesObject<MFDropdownInputEnumOption[] | undefined> }) {
|
|
34
|
+
|
|
35
|
+
// $onChanges triggers before the first $onInit, so this will handle initializing the options too
|
|
36
|
+
if (changes.enumOptions) {
|
|
37
|
+
this.options = this.transformOptions(changes.enumOptions.currentValue)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
$onInit() {
|
|
42
|
+
|
|
43
|
+
this.requiredText = this.translateFactory.instant('JSUI.REQUIRED')
|
|
44
|
+
this.manageEmptyOptions()
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
valueWasChanged(value: MFDropdownInputOptionValue) {
|
|
48
|
+
|
|
49
|
+
this.manageEmptyOptions()
|
|
50
|
+
|
|
51
|
+
if (this.onChange) {
|
|
52
|
+
this.onChange({ value })
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
inputWasClicked() {
|
|
57
|
+
|
|
58
|
+
if (this.onClick) {
|
|
59
|
+
this.onClick()
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private transformOptions(incomingOptions: MFDropdownInputEnumOption[] | undefined): MFDropdownInputOption[] {
|
|
64
|
+
|
|
65
|
+
return (incomingOptions || []).map(option => {
|
|
66
|
+
if (typeof option === 'string') {
|
|
67
|
+
return { id: option, label: option }
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return option
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
private manageEmptyOptions() {
|
|
75
|
+
|
|
76
|
+
// Start by removing all empty options, we will put them back if needed.
|
|
77
|
+
_.remove(this.options, option => !option.id)
|
|
78
|
+
|
|
79
|
+
// This is a weird case; if value is set to something that can't be matched,
|
|
80
|
+
// Angular inserts an option with a value of the string `?`. In this case
|
|
81
|
+
// we don't want to add a null option because the ? option already has a blank label.
|
|
82
|
+
const valueDoesNotMatchAnOption = !this.options.find(option => option.id === this.value)
|
|
83
|
+
if (valueDoesNotMatchAnOption) { return }
|
|
84
|
+
|
|
85
|
+
// There is a selected value and we want to allow empty options.
|
|
86
|
+
// In this case, prepend an empty option to allow the user to clear the value.
|
|
87
|
+
// This id is set to `null` because we use that to indicate "unset this" in bulk editing.
|
|
88
|
+
if (!!this.value && !this.noEmptyOption) {
|
|
89
|
+
this.options.unshift({ id: null, label: '' })
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// If value is null or undefined, we don't need to do anything. Angular will add an
|
|
93
|
+
// option with the current value (that will be blank), which will vanish when the
|
|
94
|
+
// user selects another option. This code will then add back a "blank" value if needed.
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import './dropdown'
|
|
1
|
+
import './dropdown'
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
<li>
|
|
2
|
-
<a
|
|
3
|
-
class="o-dropdown-menu__item o-dropdown-menu__item--link"
|
|
4
|
-
ng-class="{ 'is-disabled': $ctrl.disable }"
|
|
5
|
-
ng-disabled="$ctrl.disable"
|
|
6
|
-
ng-if="$ctrl.actionSref"
|
|
7
|
-
ng-keyup="$ctrl.keyPress($event)"
|
|
8
|
-
ng-transclude
|
|
9
|
-
target="{{ $ctrl.actionHrefTarget }}"
|
|
10
|
-
tabindex="0"
|
|
11
|
-
ui-sref="{{ $ctrl.actionSref.state }}({{ $ctrl.actionSref.params }})"
|
|
12
|
-
ui-sref-opts="{{ $ctrl.actionSref.options }}"></a>
|
|
13
|
-
|
|
14
|
-
<a
|
|
15
|
-
class="o-dropdown-menu__item o-dropdown-menu__item--link"
|
|
16
|
-
ng-click="$ctrl.performAction()"
|
|
17
|
-
ng-href="{{ $ctrl.actionHref }}"
|
|
18
|
-
ng-class="{ 'is-disabled': $ctrl.disable }"
|
|
19
|
-
ng-disabled="$ctrl.disable"
|
|
20
|
-
ng-if="!$ctrl.actionSref"
|
|
21
|
-
ng-keyup="$ctrl.keyPress($event)"
|
|
22
|
-
ng-transclude
|
|
23
|
-
target="{{ $ctrl.actionHrefTarget }}"
|
|
24
|
-
tabindex="0"></a>
|
|
25
|
-
</li>
|
|
1
|
+
<li>
|
|
2
|
+
<a
|
|
3
|
+
class="o-dropdown-menu__item o-dropdown-menu__item--link"
|
|
4
|
+
ng-class="{ 'is-disabled': $ctrl.disable }"
|
|
5
|
+
ng-disabled="$ctrl.disable"
|
|
6
|
+
ng-if="$ctrl.actionSref"
|
|
7
|
+
ng-keyup="$ctrl.keyPress($event)"
|
|
8
|
+
ng-transclude
|
|
9
|
+
target="{{ $ctrl.actionHrefTarget }}"
|
|
10
|
+
tabindex="0"
|
|
11
|
+
ui-sref="{{ $ctrl.actionSref.state }}({{ $ctrl.actionSref.params }})"
|
|
12
|
+
ui-sref-opts="{{ $ctrl.actionSref.options }}"></a>
|
|
13
|
+
|
|
14
|
+
<a
|
|
15
|
+
class="o-dropdown-menu__item o-dropdown-menu__item--link"
|
|
16
|
+
ng-click="$ctrl.performAction()"
|
|
17
|
+
ng-href="{{ $ctrl.actionHref }}"
|
|
18
|
+
ng-class="{ 'is-disabled': $ctrl.disable }"
|
|
19
|
+
ng-disabled="$ctrl.disable"
|
|
20
|
+
ng-if="!$ctrl.actionSref"
|
|
21
|
+
ng-keyup="$ctrl.keyPress($event)"
|
|
22
|
+
ng-transclude
|
|
23
|
+
target="{{ $ctrl.actionHrefTarget }}"
|
|
24
|
+
tabindex="0"></a>
|
|
25
|
+
</li>
|
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
import { StateOrName } from '@uirouter/angularjs'
|
|
2
|
-
import { Component, Inject, Input, Output } from '../decorators'
|
|
3
|
-
import DropdownMenuController from './dropdown-menu'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
@Component({
|
|
7
|
-
require: {
|
|
8
|
-
parent: '^mflyDropdownMenu'
|
|
9
|
-
},
|
|
10
|
-
selector: 'mflyDropdownMenuAction',
|
|
11
|
-
template: require('./dropdown-menu-action.component.html'),
|
|
12
|
-
transclude: true
|
|
13
|
-
})
|
|
14
|
-
export default class MflyDropdownMenuAction implements ng.IComponentController {
|
|
15
|
-
|
|
16
|
-
@Input('@') actionHref!: string
|
|
17
|
-
@Input('@') actionHrefTarget!: string
|
|
18
|
-
@Input() actionSref!: { state: StateOrName, params: {}, options: {} }
|
|
19
|
-
@Input() disable!: boolean
|
|
20
|
-
|
|
21
|
-
@Output() action?: () => void
|
|
22
|
-
|
|
23
|
-
private parent: DropdownMenuController
|
|
24
|
-
|
|
25
|
-
constructor(
|
|
26
|
-
@Inject('$attrs') private $attrs: ng.IAttributes,
|
|
27
|
-
@Inject('$element') private $element: JQuery,
|
|
28
|
-
@Inject('$rootScope') private $rootScope: JSUIRootScope,
|
|
29
|
-
) {}
|
|
30
|
-
|
|
31
|
-
$onInit() {
|
|
32
|
-
|
|
33
|
-
// & bindings provide a function even if nothing is bound. This isn't
|
|
34
|
-
// the case for attrs and we want scope to behave that way as well:
|
|
35
|
-
if (!this.$attrs.action) {
|
|
36
|
-
this.action = undefined
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Clicks on `action` type items as well as disabled `action-href`
|
|
40
|
-
// type items should both prevent the menu from closing if that
|
|
41
|
-
// option is set on the dropdown.
|
|
42
|
-
this.$element.on('click', (event) => {
|
|
43
|
-
event.stopPropagation()
|
|
44
|
-
|
|
45
|
-
if (!this.parent.menuStaysOpen) {
|
|
46
|
-
this.$rootScope.$broadcast('dropdown-menu:close')
|
|
47
|
-
}
|
|
48
|
-
})
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Accessibility - call the provided action
|
|
52
|
-
// on space or return
|
|
53
|
-
keyPress = ($event) => {
|
|
54
|
-
const code = $event.charCode || $event.keyCode
|
|
55
|
-
if (code === 32 || code === 13) {
|
|
56
|
-
this.performAction()
|
|
57
|
-
this.$rootScope.$broadcast('dropdown-menu:close')
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Wrap the action so we can disable it if needed
|
|
62
|
-
performAction() {
|
|
63
|
-
|
|
64
|
-
// Otherwise, call the provided action
|
|
65
|
-
if (!this.disable && this.action) {
|
|
66
|
-
this.action()
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
}
|
|
1
|
+
import { StateOrName } from '@uirouter/angularjs'
|
|
2
|
+
import { Component, Inject, Input, Output } from '../decorators'
|
|
3
|
+
import DropdownMenuController from './dropdown-menu'
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@Component({
|
|
7
|
+
require: {
|
|
8
|
+
parent: '^mflyDropdownMenu'
|
|
9
|
+
},
|
|
10
|
+
selector: 'mflyDropdownMenuAction',
|
|
11
|
+
template: require('./dropdown-menu-action.component.html'),
|
|
12
|
+
transclude: true
|
|
13
|
+
})
|
|
14
|
+
export default class MflyDropdownMenuAction implements ng.IComponentController {
|
|
15
|
+
|
|
16
|
+
@Input('@') actionHref!: string
|
|
17
|
+
@Input('@') actionHrefTarget!: string
|
|
18
|
+
@Input() actionSref!: { state: StateOrName, params: {}, options: {} }
|
|
19
|
+
@Input() disable!: boolean
|
|
20
|
+
|
|
21
|
+
@Output() action?: () => void
|
|
22
|
+
|
|
23
|
+
private parent: DropdownMenuController
|
|
24
|
+
|
|
25
|
+
constructor(
|
|
26
|
+
@Inject('$attrs') private $attrs: ng.IAttributes,
|
|
27
|
+
@Inject('$element') private $element: JQuery,
|
|
28
|
+
@Inject('$rootScope') private $rootScope: JSUIRootScope,
|
|
29
|
+
) {}
|
|
30
|
+
|
|
31
|
+
$onInit() {
|
|
32
|
+
|
|
33
|
+
// & bindings provide a function even if nothing is bound. This isn't
|
|
34
|
+
// the case for attrs and we want scope to behave that way as well:
|
|
35
|
+
if (!this.$attrs.action) {
|
|
36
|
+
this.action = undefined
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Clicks on `action` type items as well as disabled `action-href`
|
|
40
|
+
// type items should both prevent the menu from closing if that
|
|
41
|
+
// option is set on the dropdown.
|
|
42
|
+
this.$element.on('click', (event) => {
|
|
43
|
+
event.stopPropagation()
|
|
44
|
+
|
|
45
|
+
if (!this.parent.menuStaysOpen) {
|
|
46
|
+
this.$rootScope.$broadcast('dropdown-menu:close')
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Accessibility - call the provided action
|
|
52
|
+
// on space or return
|
|
53
|
+
keyPress = ($event) => {
|
|
54
|
+
const code = $event.charCode || $event.keyCode
|
|
55
|
+
if (code === 32 || code === 13) {
|
|
56
|
+
this.performAction()
|
|
57
|
+
this.$rootScope.$broadcast('dropdown-menu:close')
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Wrap the action so we can disable it if needed
|
|
62
|
+
performAction() {
|
|
63
|
+
|
|
64
|
+
// Otherwise, call the provided action
|
|
65
|
+
if (!this.disable && this.action) {
|
|
66
|
+
this.action()
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
<ul class="o-dropdown-menu__contents">
|
|
2
|
-
<ng-transclude ng-if="$ctrl.mflyDropdownMenu.isOpen()"></ng-transclude>
|
|
3
|
-
</ul>
|
|
1
|
+
<ul class="o-dropdown-menu__contents">
|
|
2
|
+
<ng-transclude ng-if="$ctrl.mflyDropdownMenu.isOpen()"></ng-transclude>
|
|
3
|
+
</ul>
|
|
@@ -1,119 +1,119 @@
|
|
|
1
|
-
import { Component, Inject, Input } from '../decorators'
|
|
2
|
-
import DropdownMenuController from './dropdown-menu'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
@Component({
|
|
6
|
-
selector: 'mflyDropdownMenuContents',
|
|
7
|
-
require: {
|
|
8
|
-
mflyDropdownMenu: '^mflyDropdownMenu',
|
|
9
|
-
},
|
|
10
|
-
template: require('./dropdown-menu-contents.html'),
|
|
11
|
-
transclude: true,
|
|
12
|
-
})
|
|
13
|
-
export default class DropdownMenuContentsController implements ng.IComponentController {
|
|
14
|
-
|
|
15
|
-
@Input() containerHeight?: number
|
|
16
|
-
|
|
17
|
-
private deregisterCloseHandler: () => void
|
|
18
|
-
private deregisterOpenHandler: () => void
|
|
19
|
-
private menuContentsElement: JQuery
|
|
20
|
-
private mflyDropdownMenu: DropdownMenuController
|
|
21
|
-
|
|
22
|
-
constructor(
|
|
23
|
-
@Inject('$document') private $document: ng.IDocumentService,
|
|
24
|
-
@Inject('$element') private $element: ng.IAugmentedJQuery,
|
|
25
|
-
@Inject('$rootScope') private $rootScope: JSUIRootScope,
|
|
26
|
-
@Inject('$scope') private $scope: ng.IScope,
|
|
27
|
-
) {}
|
|
28
|
-
|
|
29
|
-
$onDestroy() {
|
|
30
|
-
this.deregisterCloseHandler()
|
|
31
|
-
this.deregisterOpenHandler()
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
$onInit() {
|
|
35
|
-
|
|
36
|
-
this.menuContentsElement = this.$element.find('.o-dropdown-menu__contents')
|
|
37
|
-
|
|
38
|
-
this.deregisterCloseHandler = this.$rootScope.$on('dropdown-menu:close', () => {
|
|
39
|
-
|
|
40
|
-
if (!this.mflyDropdownMenu.isOpen()) {
|
|
41
|
-
return
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
this.menuContentsElement.removeClass('is-visible')
|
|
46
|
-
this.mflyDropdownMenu.isOpen(false)
|
|
47
|
-
this.clearPositionalAdjustments(this.menuContentsElement)
|
|
48
|
-
this.$scope.$apply()
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
this.deregisterOpenHandler = this.$scope.$on('dropdown-menu:open', () => {
|
|
52
|
-
|
|
53
|
-
if (this.mflyDropdownMenu.isOpen()) {
|
|
54
|
-
return
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
this.menuContentsElement.addClass('is-visible')
|
|
58
|
-
this.mflyDropdownMenu.isOpen(true)
|
|
59
|
-
this.$scope.$apply()
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
// Adjust dropdown if it is appearing offscreen.
|
|
63
|
-
const menuRect = this.menuContentsElement[0].getBoundingClientRect()
|
|
64
|
-
const rightEdgeX = menuRect.left + menuRect.width
|
|
65
|
-
const bottomEdgeY = menuRect.top + menuRect.height
|
|
66
|
-
let screenHeight = (this.$document[0] as HTMLDocument).body.clientHeight
|
|
67
|
-
if ( this.containerHeight ) {
|
|
68
|
-
screenHeight = this.containerHeight
|
|
69
|
-
}
|
|
70
|
-
const screenWidth = (this.$document[0] as HTMLDocument).body.clientWidth // excludes scrollbar
|
|
71
|
-
|
|
72
|
-
const offscreenLeft = (menuRect.left < 0)
|
|
73
|
-
const offscreenRight = (rightEdgeX > screenWidth)
|
|
74
|
-
const offscreenTop = (menuRect.top < 0)
|
|
75
|
-
const offscreenBottom = (bottomEdgeY > screenHeight)
|
|
76
|
-
|
|
77
|
-
const adjustPosition = () => {
|
|
78
|
-
let translateXValue
|
|
79
|
-
if ( (offscreenLeft && offscreenRight) || (offscreenTop && offscreenBottom) ) {
|
|
80
|
-
return // ¯\_(ツ)_/¯
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (offscreenLeft) {
|
|
84
|
-
translateXValue = -menuRect.left
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (offscreenRight) {
|
|
88
|
-
translateXValue = screenWidth - rightEdgeX - 1
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (offscreenLeft || offscreenRight) {
|
|
92
|
-
this.menuContentsElement.css('transform', `translateX(${translateXValue}px)`)
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (offscreenTop) {
|
|
96
|
-
if (translateXValue) {
|
|
97
|
-
this.menuContentsElement.css('transform', `translateX(${translateXValue}px) translateY(${-menuRect.top}px)`)
|
|
98
|
-
} else {
|
|
99
|
-
this.menuContentsElement.css('transform', `translateY(${-menuRect.top}px)`)
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (offscreenBottom) {
|
|
104
|
-
if (translateXValue) {
|
|
105
|
-
this.menuContentsElement.css('transform', `translateX(${translateXValue}px) translateY(${screenHeight - bottomEdgeY}px)`)
|
|
106
|
-
} else {
|
|
107
|
-
this.menuContentsElement.css('transform', `translateY(${screenHeight - bottomEdgeY}px)`)
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
adjustPosition()
|
|
112
|
-
|
|
113
|
-
})
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
private clearPositionalAdjustments(element: JQuery) {
|
|
117
|
-
element[0].style.removeProperty('transform')
|
|
118
|
-
}
|
|
119
|
-
}
|
|
1
|
+
import { Component, Inject, Input } from '../decorators'
|
|
2
|
+
import DropdownMenuController from './dropdown-menu'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@Component({
|
|
6
|
+
selector: 'mflyDropdownMenuContents',
|
|
7
|
+
require: {
|
|
8
|
+
mflyDropdownMenu: '^mflyDropdownMenu',
|
|
9
|
+
},
|
|
10
|
+
template: require('./dropdown-menu-contents.html'),
|
|
11
|
+
transclude: true,
|
|
12
|
+
})
|
|
13
|
+
export default class DropdownMenuContentsController implements ng.IComponentController {
|
|
14
|
+
|
|
15
|
+
@Input() containerHeight?: number
|
|
16
|
+
|
|
17
|
+
private deregisterCloseHandler: () => void
|
|
18
|
+
private deregisterOpenHandler: () => void
|
|
19
|
+
private menuContentsElement: JQuery
|
|
20
|
+
private mflyDropdownMenu: DropdownMenuController
|
|
21
|
+
|
|
22
|
+
constructor(
|
|
23
|
+
@Inject('$document') private $document: ng.IDocumentService,
|
|
24
|
+
@Inject('$element') private $element: ng.IAugmentedJQuery,
|
|
25
|
+
@Inject('$rootScope') private $rootScope: JSUIRootScope,
|
|
26
|
+
@Inject('$scope') private $scope: ng.IScope,
|
|
27
|
+
) {}
|
|
28
|
+
|
|
29
|
+
$onDestroy() {
|
|
30
|
+
this.deregisterCloseHandler()
|
|
31
|
+
this.deregisterOpenHandler()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
$onInit() {
|
|
35
|
+
|
|
36
|
+
this.menuContentsElement = this.$element.find('.o-dropdown-menu__contents')
|
|
37
|
+
|
|
38
|
+
this.deregisterCloseHandler = this.$rootScope.$on('dropdown-menu:close', () => {
|
|
39
|
+
|
|
40
|
+
if (!this.mflyDropdownMenu.isOpen()) {
|
|
41
|
+
return
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
this.menuContentsElement.removeClass('is-visible')
|
|
46
|
+
this.mflyDropdownMenu.isOpen(false)
|
|
47
|
+
this.clearPositionalAdjustments(this.menuContentsElement)
|
|
48
|
+
this.$scope.$apply()
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
this.deregisterOpenHandler = this.$scope.$on('dropdown-menu:open', () => {
|
|
52
|
+
|
|
53
|
+
if (this.mflyDropdownMenu.isOpen()) {
|
|
54
|
+
return
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
this.menuContentsElement.addClass('is-visible')
|
|
58
|
+
this.mflyDropdownMenu.isOpen(true)
|
|
59
|
+
this.$scope.$apply()
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
// Adjust dropdown if it is appearing offscreen.
|
|
63
|
+
const menuRect = this.menuContentsElement[0].getBoundingClientRect()
|
|
64
|
+
const rightEdgeX = menuRect.left + menuRect.width
|
|
65
|
+
const bottomEdgeY = menuRect.top + menuRect.height
|
|
66
|
+
let screenHeight = (this.$document[0] as HTMLDocument).body.clientHeight
|
|
67
|
+
if ( this.containerHeight ) {
|
|
68
|
+
screenHeight = this.containerHeight
|
|
69
|
+
}
|
|
70
|
+
const screenWidth = (this.$document[0] as HTMLDocument).body.clientWidth // excludes scrollbar
|
|
71
|
+
|
|
72
|
+
const offscreenLeft = (menuRect.left < 0)
|
|
73
|
+
const offscreenRight = (rightEdgeX > screenWidth)
|
|
74
|
+
const offscreenTop = (menuRect.top < 0)
|
|
75
|
+
const offscreenBottom = (bottomEdgeY > screenHeight)
|
|
76
|
+
|
|
77
|
+
const adjustPosition = () => {
|
|
78
|
+
let translateXValue
|
|
79
|
+
if ( (offscreenLeft && offscreenRight) || (offscreenTop && offscreenBottom) ) {
|
|
80
|
+
return // ¯\_(ツ)_/¯
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (offscreenLeft) {
|
|
84
|
+
translateXValue = -menuRect.left
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (offscreenRight) {
|
|
88
|
+
translateXValue = screenWidth - rightEdgeX - 1
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (offscreenLeft || offscreenRight) {
|
|
92
|
+
this.menuContentsElement.css('transform', `translateX(${translateXValue}px)`)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (offscreenTop) {
|
|
96
|
+
if (translateXValue) {
|
|
97
|
+
this.menuContentsElement.css('transform', `translateX(${translateXValue}px) translateY(${-menuRect.top}px)`)
|
|
98
|
+
} else {
|
|
99
|
+
this.menuContentsElement.css('transform', `translateY(${-menuRect.top}px)`)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (offscreenBottom) {
|
|
104
|
+
if (translateXValue) {
|
|
105
|
+
this.menuContentsElement.css('transform', `translateX(${translateXValue}px) translateY(${screenHeight - bottomEdgeY}px)`)
|
|
106
|
+
} else {
|
|
107
|
+
this.menuContentsElement.css('transform', `translateY(${screenHeight - bottomEdgeY}px)`)
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
adjustPosition()
|
|
112
|
+
|
|
113
|
+
})
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
private clearPositionalAdjustments(element: JQuery) {
|
|
117
|
+
element[0].style.removeProperty('transform')
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<li class="o-dropdown-menu__item o-dropdown-menu__header" ng-transclude></li>
|
|
1
|
+
<li class="o-dropdown-menu__item o-dropdown-menu__header" ng-transclude></li>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import angular from 'angular'
|
|
2
|
-
import template from './dropdown-menu-header.html'
|
|
3
|
-
|
|
4
|
-
angular.module('app').directive('mflyDropdownMenuHeader', function mflyDropdownMenuHeader () {
|
|
5
|
-
|
|
6
|
-
return {
|
|
7
|
-
restrict: 'E',
|
|
8
|
-
replace: true,
|
|
9
|
-
transclude: true,
|
|
10
|
-
template
|
|
11
|
-
};
|
|
12
|
-
});
|
|
1
|
+
import angular from 'angular'
|
|
2
|
+
import template from './dropdown-menu-header.html'
|
|
3
|
+
|
|
4
|
+
angular.module('app').directive('mflyDropdownMenuHeader', function mflyDropdownMenuHeader () {
|
|
5
|
+
|
|
6
|
+
return {
|
|
7
|
+
restrict: 'E',
|
|
8
|
+
replace: true,
|
|
9
|
+
transclude: true,
|
|
10
|
+
template
|
|
11
|
+
};
|
|
12
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<li class="o-dropdown-menu__item" ng-transclude></li>
|
|
1
|
+
<li class="o-dropdown-menu__item" ng-transclude></li>
|