@qtoggle/qui 0.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.
Files changed (202) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc.json +492 -0
  3. package/.github/ISSUE_TEMPLATE/bug_report.md +33 -0
  4. package/.github/ISSUE_TEMPLATE/feature_request.md +23 -0
  5. package/.github/ISSUE_TEMPLATE/improvement_proposal.md +20 -0
  6. package/.github/workflows/main.yml +74 -0
  7. package/.pre-commit-config.yaml +8 -0
  8. package/LICENSE.txt +177 -0
  9. package/README.md +4 -0
  10. package/font/dejavusans-bold.woff +0 -0
  11. package/font/dejavusans-bolditalic.woff +0 -0
  12. package/font/dejavusans-italic.woff +0 -0
  13. package/font/dejavusans-regular.woff +0 -0
  14. package/img/qui-icons.svg +1937 -0
  15. package/js/base/base.js +47 -0
  16. package/js/base/condition-variable.js +92 -0
  17. package/js/base/errors.js +36 -0
  18. package/js/base/i18n.js +20 -0
  19. package/js/base/mixwith.js +135 -0
  20. package/js/base/require-js-compat.js +78 -0
  21. package/js/base/signal.js +91 -0
  22. package/js/base/singleton.js +66 -0
  23. package/js/base/timer.js +126 -0
  24. package/js/config.js +184 -0
  25. package/js/forms/common-fields/check-field.js +42 -0
  26. package/js/forms/common-fields/choice-buttons-field.js +30 -0
  27. package/js/forms/common-fields/color-combo-field.js +37 -0
  28. package/js/forms/common-fields/combo-field.js +108 -0
  29. package/js/forms/common-fields/common-fields.js +23 -0
  30. package/js/forms/common-fields/composite-field.js +132 -0
  31. package/js/forms/common-fields/custom-html-field.js +51 -0
  32. package/js/forms/common-fields/email-field.js +30 -0
  33. package/js/forms/common-fields/file-picker-field.js +46 -0
  34. package/js/forms/common-fields/jquery-ui-field.js +111 -0
  35. package/js/forms/common-fields/labels-field.js +69 -0
  36. package/js/forms/common-fields/numeric-field.js +39 -0
  37. package/js/forms/common-fields/password-field.js +28 -0
  38. package/js/forms/common-fields/phone-field.js +26 -0
  39. package/js/forms/common-fields/progress-disk-field.js +69 -0
  40. package/js/forms/common-fields/push-button-field.js +138 -0
  41. package/js/forms/common-fields/slider-field.js +51 -0
  42. package/js/forms/common-fields/text-area-field.js +34 -0
  43. package/js/forms/common-fields/text-field.js +89 -0
  44. package/js/forms/common-fields/up-down-field.js +85 -0
  45. package/js/forms/common-forms/common-forms.js +16 -0
  46. package/js/forms/common-forms/options-form.js +77 -0
  47. package/js/forms/common-forms/page-form.js +115 -0
  48. package/js/forms/form-button.js +202 -0
  49. package/js/forms/form-field.js +1183 -0
  50. package/js/forms/form.js +1181 -0
  51. package/js/forms/forms.js +68 -0
  52. package/js/global-glass.js +100 -0
  53. package/js/icons/default-stock.js +173 -0
  54. package/js/icons/icon.js +64 -0
  55. package/js/icons/icons.js +16 -0
  56. package/js/icons/multi-state-sprites-icon.js +362 -0
  57. package/js/icons/stock-icon.js +219 -0
  58. package/js/icons/stock.js +98 -0
  59. package/js/icons/stocks.js +57 -0
  60. package/js/index.js +232 -0
  61. package/js/lib/jquery.longpress.js +79 -0
  62. package/js/lib/jquery.module.js +4 -0
  63. package/js/lib/logger.module.js +4 -0
  64. package/js/lib/pep.module.js +4 -0
  65. package/js/lists/common-items/common-items.js +5 -0
  66. package/js/lists/common-items/icon-label-list-item.js +86 -0
  67. package/js/lists/common-lists/common-lists.js +5 -0
  68. package/js/lists/common-lists/page-list.js +53 -0
  69. package/js/lists/list-item.js +147 -0
  70. package/js/lists/list.js +636 -0
  71. package/js/lists/lists.js +26 -0
  72. package/js/main-ui/main-ui.js +64 -0
  73. package/js/main-ui/menu-bar.js +144 -0
  74. package/js/main-ui/options-bar.js +181 -0
  75. package/js/main-ui/status.js +185 -0
  76. package/js/main-ui/top-bar.js +59 -0
  77. package/js/messages/common-message-forms/common-message-forms.js +7 -0
  78. package/js/messages/common-message-forms/confirm-message-form.js +81 -0
  79. package/js/messages/common-message-forms/simple-message-form.js +67 -0
  80. package/js/messages/common-message-forms/sticky-simple-message-form.js +27 -0
  81. package/js/messages/message-form.js +107 -0
  82. package/js/messages/messages.js +21 -0
  83. package/js/messages/sticky-modal-page.js +98 -0
  84. package/js/messages/sticky-modal-progress-message.js +27 -0
  85. package/js/messages/toast.js +164 -0
  86. package/js/navigation.js +654 -0
  87. package/js/pages/breadcrumbs.js +124 -0
  88. package/js/pages/common-pages/common-pages.js +6 -0
  89. package/js/pages/common-pages/modal-progress-page.js +83 -0
  90. package/js/pages/common-pages/structured-page.js +46 -0
  91. package/js/pages/page.js +1018 -0
  92. package/js/pages/pages-context.js +154 -0
  93. package/js/pages/pages.js +252 -0
  94. package/js/pwa.js +337 -0
  95. package/js/sections/section.js +612 -0
  96. package/js/sections/sections.js +300 -0
  97. package/js/tables/common-cells/common-cells.js +7 -0
  98. package/js/tables/common-cells/icon-label-table-cell.js +68 -0
  99. package/js/tables/common-cells/push-button-table-cell.js +133 -0
  100. package/js/tables/common-cells/simple-table-cell.js +37 -0
  101. package/js/tables/common-tables/common-tables.js +5 -0
  102. package/js/tables/common-tables/page-table.js +55 -0
  103. package/js/tables/table-cell.js +198 -0
  104. package/js/tables/table-row.js +126 -0
  105. package/js/tables/table.js +492 -0
  106. package/js/tables/tables.js +36 -0
  107. package/js/theme.js +304 -0
  108. package/js/utils/ajax.js +126 -0
  109. package/js/utils/array.js +194 -0
  110. package/js/utils/colors.js +445 -0
  111. package/js/utils/cookies.js +65 -0
  112. package/js/utils/crypto.js +439 -0
  113. package/js/utils/css.js +234 -0
  114. package/js/utils/date.js +300 -0
  115. package/js/utils/files.js +27 -0
  116. package/js/utils/gestures.js +165 -0
  117. package/js/utils/html.js +76 -0
  118. package/js/utils/misc.js +81 -0
  119. package/js/utils/object.js +324 -0
  120. package/js/utils/promise.js +49 -0
  121. package/js/utils/string.js +192 -0
  122. package/js/utils/url.js +187 -0
  123. package/js/utils/utils.js +3 -0
  124. package/js/utils/visibility-manager.js +211 -0
  125. package/js/views/common-views/common-views.js +7 -0
  126. package/js/views/common-views/icon-label-view.js +210 -0
  127. package/js/views/common-views/progress-view.js +89 -0
  128. package/js/views/common-views/structured-view.js +368 -0
  129. package/js/views/view.js +467 -0
  130. package/js/views/views.js +3 -0
  131. package/js/widgets/base-widget.js +23 -0
  132. package/js/widgets/common-widgets/check-button.js +109 -0
  133. package/js/widgets/common-widgets/choice-buttons.js +322 -0
  134. package/js/widgets/common-widgets/color-combo.js +104 -0
  135. package/js/widgets/common-widgets/combo.js +645 -0
  136. package/js/widgets/common-widgets/common-widgets.js +17 -0
  137. package/js/widgets/common-widgets/email-input.js +7 -0
  138. package/js/widgets/common-widgets/file-picker.js +133 -0
  139. package/js/widgets/common-widgets/labels.js +132 -0
  140. package/js/widgets/common-widgets/numeric-input.js +49 -0
  141. package/js/widgets/common-widgets/password-input.js +91 -0
  142. package/js/widgets/common-widgets/phone-input.js +7 -0
  143. package/js/widgets/common-widgets/progress-disk.js +174 -0
  144. package/js/widgets/common-widgets/push-button.js +155 -0
  145. package/js/widgets/common-widgets/slider.js +455 -0
  146. package/js/widgets/common-widgets/text-area.js +52 -0
  147. package/js/widgets/common-widgets/text-input.js +174 -0
  148. package/js/widgets/common-widgets/up-down.js +351 -0
  149. package/js/widgets/widgets.js +57 -0
  150. package/js/window.js +557 -0
  151. package/jsdoc.conf.json +20 -0
  152. package/less/base.less +123 -0
  153. package/less/forms/common-fields.less +101 -0
  154. package/less/forms/common-forms.less +5 -0
  155. package/less/forms/form-button.less +21 -0
  156. package/less/forms/form-field.less +266 -0
  157. package/less/forms/form.less +131 -0
  158. package/less/global-glass.less +64 -0
  159. package/less/icon-label-view.less +82 -0
  160. package/less/icons.less +144 -0
  161. package/less/lists.less +105 -0
  162. package/less/main-ui.less +328 -0
  163. package/less/messages.less +189 -0
  164. package/less/no-effects.less +24 -0
  165. package/less/pages/breadcrumbs.less +98 -0
  166. package/less/pages/common-pages.less +36 -0
  167. package/less/pages/page.less +70 -0
  168. package/less/progress-view.less +51 -0
  169. package/less/stock-icons.less +43 -0
  170. package/less/structured-view.less +245 -0
  171. package/less/tables.less +84 -0
  172. package/less/theme-dark.less +133 -0
  173. package/less/theme-light.less +132 -0
  174. package/less/theme.less +419 -0
  175. package/less/visibility-manager.less +11 -0
  176. package/less/widgets/check-button.less +96 -0
  177. package/less/widgets/choice-buttons.less +160 -0
  178. package/less/widgets/color-combo.less +33 -0
  179. package/less/widgets/combo.less +230 -0
  180. package/less/widgets/common-buttons.less +120 -0
  181. package/less/widgets/common.less +24 -0
  182. package/less/widgets/input.less +258 -0
  183. package/less/widgets/labels.less +81 -0
  184. package/less/widgets/progress-disk.less +70 -0
  185. package/less/widgets/slider.less +199 -0
  186. package/less/widgets/updown.less +115 -0
  187. package/less/widgets/various.less +36 -0
  188. package/package.json +47 -0
  189. package/pyproject.toml +45 -0
  190. package/qui/__init__.py +110 -0
  191. package/qui/constants.py +1 -0
  192. package/qui/exceptions.py +2 -0
  193. package/qui/j2template.py +71 -0
  194. package/qui/settings.py +60 -0
  195. package/qui/templates/manifest.json +25 -0
  196. package/qui/templates/qui.html +126 -0
  197. package/qui/templates/service-worker.js +188 -0
  198. package/qui/web/__init__.py +0 -0
  199. package/qui/web/tornado.py +220 -0
  200. package/scripts/postinstall.sh +10 -0
  201. package/webpack/webpack-adjust-css-urls-loader.js +36 -0
  202. package/webpack/webpack-common.js +384 -0
@@ -0,0 +1,124 @@
1
+
2
+ import $ from '$qui/lib/jquery.module.js'
3
+ import Logger from '$qui/lib/logger.module.js'
4
+
5
+ import Config from '$qui/config.js'
6
+ import * as MenuBar from '$qui/main-ui/menu-bar.js'
7
+ import * as OptionsBar from '$qui/main-ui/options-bar.js'
8
+ import * as TopBar from '$qui/main-ui/top-bar.js'
9
+ import * as Navigation from '$qui/navigation.js'
10
+ import * as ArrayUtils from '$qui/utils/array.js'
11
+ import * as HTML from '$qui/utils/html.js'
12
+ import * as Window from '$qui/window.js'
13
+
14
+ import * as Pages from './pages.js'
15
+
16
+
17
+ const MAX_BREADCRUMBS = 10
18
+ const logger = Logger.get('qui.pages')
19
+
20
+ let breadcrumbsContainer = null
21
+ let menuButton = null
22
+
23
+
24
+ export function update() {
25
+ let currentContext = Pages.getCurrentContext()
26
+
27
+ breadcrumbsContainer.children('div.qui-breadcrumb').removeClass('used selected back last first-used')
28
+
29
+ currentContext.getPages().forEach(function (page, i) {
30
+ if (!page.getTitle()) {
31
+ return
32
+ }
33
+
34
+ let breadcrumb = breadcrumbsContainer.children(`div.qui-breadcrumb:eq(${i})`)
35
+ breadcrumb.addClass('used')
36
+ breadcrumb.html(page.getTitle())
37
+ })
38
+
39
+ breadcrumbsContainer.children('div.qui-breadcrumb.used:first').addClass('first-used')
40
+
41
+ let lastIndex = 0
42
+ currentContext.getPages().forEach(function (page, i) {
43
+ if (!page.getTitle()) {
44
+ return
45
+ }
46
+
47
+ let breadcrumb = breadcrumbsContainer.children(`div.qui-breadcrumb:eq(${i})`)
48
+ breadcrumb.toggleClass('selected', i === currentContext.getSize() - 1)
49
+ breadcrumb.toggleClass('back', (i === currentContext.getSize() - 2) && (i >= 0) && Window.isSmallScreen())
50
+
51
+ lastIndex = i
52
+ })
53
+
54
+ let breadcrumb = breadcrumbsContainer.children(`div.qui-breadcrumb:eq(${lastIndex})`)
55
+ breadcrumb.addClass('last')
56
+
57
+ /* Update window title */
58
+ let windowTitle = Config.appDisplayName
59
+ let currentPageTitle = null
60
+ if (currentContext.getSize()) {
61
+ let currentPage = currentContext.getCurrentPage()
62
+ if (currentPage.getTitle()) {
63
+ currentPageTitle = currentPage.getTitle()
64
+ windowTitle += ` - ${currentPageTitle}`
65
+ }
66
+ }
67
+
68
+ /* Set menu button visibility */
69
+ let menuButtonVisible = true
70
+ if (Window.isSmallScreen() && currentContext.getSize() > 1) {
71
+ menuButtonVisible = false
72
+ }
73
+
74
+ menuButton.toggleClass('hidden', !menuButtonVisible)
75
+
76
+ /* Update top bar title */
77
+ TopBar.setTitle(currentPageTitle)
78
+
79
+ /* Update document title */
80
+ document.title = HTML.plainText(windowTitle)
81
+ }
82
+
83
+ export function init() {
84
+ breadcrumbsContainer = $('div.qui-breadcrumbs-container')
85
+ menuButton = $('div.qui-top-bar > div.qui-menu-button')
86
+
87
+ /* Create placeholders for breadcrumbs */
88
+ ArrayUtils.range(0, MAX_BREADCRUMBS).forEach(function (i) {
89
+ let breadcrumb = $('<div></div>', {class: 'qui-base-button qui-breadcrumb'})
90
+ breadcrumb.attr('data-index', i)
91
+ breadcrumbsContainer.append(breadcrumb)
92
+
93
+ breadcrumb.on('click', function () {
94
+ let currentContext = Pages.getCurrentContext()
95
+
96
+ /* Close menu and option bars when clicking on a breadcrumb */
97
+ MenuBar.close()
98
+ OptionsBar.close()
99
+
100
+ if (currentContext.getSize() <= i + 1) {
101
+ return /* Already there */
102
+ }
103
+
104
+ let state = Navigation.getCurrentHistoryEntryState()
105
+ let isBackButton = breadcrumb.hasClass('back')
106
+
107
+ /* Close all pages following the page associated to clicked breadcrumb */
108
+ let page = currentContext.getPageAt(i + 1)
109
+ if (page) {
110
+ if ((Navigation.getBackMode() === Navigation.BACK_MODE_CLOSE) && isBackButton) {
111
+ window.history.back()
112
+ }
113
+ else {
114
+ page.close().then(function () {
115
+ Navigation.addHistoryEntry(state)
116
+ Navigation.updateHistoryEntry()
117
+ }).catch(function () {
118
+ logger.debug('breadcrumb navigation cancelled by rejected page close')
119
+ })
120
+ }
121
+ }
122
+ })
123
+ })
124
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @namespace qui.pages.commonpages
3
+ */
4
+
5
+ export {default as ModalProgressPage} from './modal-progress-page.js'
6
+ export {default as StructuredPageMixin} from './structured-page.js'
@@ -0,0 +1,83 @@
1
+
2
+ import $ from '$qui/lib/jquery.module.js'
3
+
4
+ import {mix} from '$qui/base/mixwith.js'
5
+ import * as ObjectUtils from '$qui/utils/object.js'
6
+
7
+ import PageMixin from '../page.js'
8
+
9
+
10
+ /**
11
+ * A modal page with a progress widget and an optional message.
12
+ * @alias qui.pages.commonpages.ModalProgressPage
13
+ * @mixes qui.pages.PageMixin
14
+ */
15
+ class ModalProgressPage extends mix().with(PageMixin) {
16
+
17
+ /**
18
+ * @constructs
19
+ * @param {String} [message] an optional progress message
20
+ * @param {Number} [progressPercent] initial progress percent (defaults to `-1`)
21
+ * @param {Object} [progressOptions] extra options for the progress widget
22
+ * @param {...*} args parent class parameters
23
+ */
24
+ constructor({message = null, progressPercent = -1, progressOptions = {}, ...args} = {}) {
25
+ args.modal = true
26
+
27
+ super(args)
28
+
29
+ this._progressPercent = progressPercent
30
+ this._progressOptions = progressOptions
31
+ this._message = message
32
+
33
+ this._progressWidget = null
34
+ this._messageContainer = null
35
+ }
36
+
37
+ makeHTML() {
38
+ let panelDiv = $('<div></div>', {class: 'qui-modal-progress-page-panel'})
39
+ let containerDiv = $('<div></div>', {class: 'qui-modal-progress-page-container'})
40
+ containerDiv.append(panelDiv)
41
+
42
+ let progressOptions = ObjectUtils.copy(this._progressOptions)
43
+ ObjectUtils.setDefault(progressOptions, 'radius', '2em')
44
+ this._progressWidget = $('<div></div>', {class: 'qui-modal-progress-page-progress-widget'})
45
+ this._progressWidget.progressdisk(progressOptions)
46
+ this._progressWidget.progressdisk('setValue', this._progressPercent)
47
+
48
+ this._messageContainer = $('<div></div>', {class: 'qui-modal-progress-page-message'})
49
+ this._messageContainer.html(this._message)
50
+ this._messageContainer.toggleClass('empty', !this._message)
51
+
52
+ panelDiv.append(this._progressWidget).append(this._messageContainer)
53
+
54
+ return containerDiv
55
+ }
56
+
57
+ /**
58
+ * Update the percent value of the progress widget.
59
+ * @param {Number} percent
60
+ */
61
+ setProgressPercent(percent) {
62
+ this.getPageHTML() /* Ensure all HTML elements are created */
63
+
64
+ this._progressPercent = percent
65
+ this._progressWidget.progressdisk('setValue', percent)
66
+ }
67
+
68
+ /**
69
+ * Set or clear the progress message.
70
+ * @param {?String} message the message to set, or `null` to clear the existing message
71
+ */
72
+ setMessage(message) {
73
+ this.getPageHTML() /* Ensure all HTML elements are created */
74
+
75
+ this._message = message
76
+ this._messageContainer.html(message || '')
77
+ this._messageContainer.toggleClass('empty', !this._message)
78
+ }
79
+
80
+ }
81
+
82
+
83
+ export default ModalProgressPage
@@ -0,0 +1,46 @@
1
+
2
+ import {Mixin} from '$qui/base/mixwith.js'
3
+ import {mix} from '$qui/base/mixwith.js'
4
+ import StockIcon from '$qui/icons/stock-icon.js'
5
+ import {StructuredViewMixin} from '$qui/views/common-views/common-views.js'
6
+
7
+ import PageMixin from '../page.js'
8
+
9
+
10
+ /** @lends qui.pages.commonpages.StructuredPageMixin */
11
+ const StructuredPageMixin = Mixin((superclass = Object) => {
12
+
13
+ /**
14
+ * A mixin that combines {@link qui.views.commonviews.StructuredViewMixin} and {@link qui.pages.PageMixin}.
15
+ * @alias qui.pages.commonpages.StructuredPageMixin
16
+ * @mixin
17
+ * @extends qui.views.commonviews.StructuredViewMixin
18
+ * @mixes qui.pages.PageMixin
19
+ */
20
+ class StructuredPageMixin extends mix(StructuredViewMixin(superclass)).with(PageMixin) {
21
+
22
+ /**
23
+ * @constructs
24
+ * @param {...*} args parent class parameters
25
+ */
26
+ constructor({...args} = {}) {
27
+ super(args)
28
+ }
29
+
30
+ prepareIcon(icon) {
31
+ /* Popup page views should normally have the default foreground icon color, even on small screens */
32
+ if (this.isPopup() && (icon instanceof StockIcon)) {
33
+ icon = icon.alterDefault({variant: 'foreground'})
34
+ }
35
+
36
+ return super.prepareIcon(icon)
37
+ }
38
+
39
+ }
40
+
41
+ return StructuredPageMixin
42
+
43
+ })
44
+
45
+
46
+ export default StructuredPageMixin