@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,111 @@
1
+
2
+ import $ from '$qui/lib/jquery.module.js'
3
+
4
+ import * as ObjectUtils from '$qui/utils/object.js'
5
+
6
+ import FormField from '../form-field.js'
7
+
8
+
9
+ /**
10
+ * A form field backed by a jQuery UI widget.
11
+ * @alias qui.forms.commonfields.JQueryUIField
12
+ * @extends qui.forms.FormField
13
+ */
14
+ class JQueryUIField extends FormField {
15
+
16
+ /* jQuery UI widget class */
17
+ static WIDGET_CLASS = ''
18
+
19
+
20
+ /**
21
+ * @constructs
22
+ * @param {Object} widgetAttrs attributes to pass to underlying JQueryUI widget
23
+ * @param {...*} args parent class parameters
24
+ */
25
+ constructor({widgetAttrs, ...args}) {
26
+ super(args)
27
+
28
+ this._widgetAttrs = widgetAttrs
29
+ }
30
+
31
+ makeHTML() {
32
+ let html = super.makeHTML()
33
+
34
+ html.addClass(`jquery-ui-${this.constructor.WIDGET_CLASS}`)
35
+
36
+ return html
37
+ }
38
+
39
+ focus() {
40
+ this.getFocusableElement().focus()
41
+ }
42
+
43
+ getFocusableElement() {
44
+ return this.getWidget()
45
+ }
46
+
47
+ makeWidget() {
48
+ let attrs = ObjectUtils.copy(this._widgetAttrs)
49
+
50
+ /* Always supply field name to widget */
51
+ attrs['name'] = this.getName()
52
+
53
+ let div = $('<div></div>')
54
+ div[this.constructor.WIDGET_CLASS](attrs)
55
+
56
+ return div
57
+ }
58
+
59
+ _widgetCall(...args) {
60
+ let widget = this.getWidget()
61
+ return widget[this.constructor.WIDGET_CLASS].apply(widget, args)
62
+ }
63
+
64
+ validateWidget(value) {
65
+ return null
66
+ }
67
+
68
+ valueToWidget(value) {
69
+ this._widgetCall('setValue', value)
70
+ }
71
+
72
+ widgetToValue() {
73
+ return this._widgetCall('getValue')
74
+ }
75
+
76
+ setWidgetReadonly(readonly) {
77
+ this._widgetCall({readonly: readonly})
78
+ }
79
+
80
+ enableWidget() {
81
+ this._widgetCall({disabled: false})
82
+ }
83
+
84
+ disableWidget() {
85
+ this._widgetCall({disabled: true})
86
+ }
87
+
88
+ showWarning(message) {
89
+ super.showWarning(message)
90
+ this._widgetCall({warning: message})
91
+ }
92
+
93
+ hideWarning() {
94
+ super.hideWarning()
95
+ this._widgetCall({warning: null})
96
+ }
97
+
98
+ showError(message) {
99
+ super.showError(message)
100
+ this._widgetCall({error: message})
101
+ }
102
+
103
+ hideError() {
104
+ super.hideError()
105
+ this._widgetCall({error: null})
106
+ }
107
+
108
+ }
109
+
110
+
111
+ export default JQueryUIField
@@ -0,0 +1,69 @@
1
+
2
+ import JQueryUIField from './jquery-ui-field.js'
3
+
4
+
5
+ /**
6
+ * A field backed by colored labels. The value data type is `String[]` (a list of labels) or `Object[]` (a list of
7
+ * objects with `text`, `color` and `background` fields).
8
+ * @alias qui.forms.commonfields.LabelsField
9
+ * @extends qui.forms.commonfields.JQueryUIField
10
+ */
11
+ class LabelsField extends JQueryUIField {
12
+
13
+ static WIDGET_CLASS = 'labels'
14
+
15
+
16
+ // TODO add setters and getters for widget properties
17
+
18
+ /**
19
+ * @constructs
20
+ * @param {String} [color] the label text color (defaults to `@background-color`)
21
+ * @param {String} [background] the default label background color, used unless the given labels specify otherwise
22
+ * (defaults to `@foreground-color`)
23
+ * @param {Boolean} [chevrons] set to `true` if you want to join labels using chevron-like arrows
24
+ * @param {Boolean} [clickable] set to `true` if you want your labels to be clickable
25
+ * @param {Function} [onClick] function to be executed when a label is clicked (see
26
+ * {@link qui.forms.commonfields.LabelsField#onClick})
27
+ * @param {...*} args parent class parameters
28
+ */
29
+ constructor({
30
+ color = '@background-color',
31
+ background = '@foreground-color',
32
+ chevrons = false,
33
+ clickable = false,
34
+ onClick = null,
35
+ ...args
36
+ }) {
37
+ super({
38
+ widgetAttrs: {
39
+ color: color,
40
+ background: background,
41
+ chevrons: chevrons,
42
+ clickable: clickable,
43
+ onClick: function (label, index) {
44
+ return that.onClick(label, index)
45
+ }
46
+ },
47
+ ...args
48
+ })
49
+
50
+ if (onClick) {
51
+ this.onClick = onClick
52
+ }
53
+
54
+ /* "that" needs to be assigned here because we can't refer to "this" before super() */
55
+ let that = this
56
+ }
57
+
58
+ /**
59
+ * Called when a label is clicked.
60
+ * @param {String} label the text of the clicked label
61
+ * @param {Number} index the index of the clicked label (starting at `0`)
62
+ */
63
+ onClick(label, index) {
64
+ }
65
+
66
+ }
67
+
68
+
69
+ export default LabelsField
@@ -0,0 +1,39 @@
1
+
2
+ import TextField from './text-field.js'
3
+
4
+
5
+ /**
6
+ * A numeric text field. The value data type is `String`.
7
+ * @alias qui.forms.commonfields.NumericField
8
+ * @extends qui.forms.commonfields.TextField
9
+ */
10
+ class NumericField extends TextField {
11
+
12
+ static WIDGET_CLASS = 'numericinput'
13
+
14
+
15
+ /**
16
+ * @constructs
17
+ * @param {Number} [min] minimum value
18
+ * @param {Number} [max] maximum value
19
+ * @param {...*} args parent class parameters
20
+ */
21
+ constructor({min = null, max = null, ...args}) {
22
+ super({widgetAttrs: {min, max}, ...args})
23
+ }
24
+
25
+ widgetToValue() {
26
+ let value = super.widgetToValue()
27
+
28
+ if (value) {
29
+ return parseFloat(value)
30
+ }
31
+ else {
32
+ return null
33
+ }
34
+ }
35
+
36
+ }
37
+
38
+
39
+ export default NumericField
@@ -0,0 +1,28 @@
1
+
2
+ import TextField from './text-field.js'
3
+
4
+
5
+ /**
6
+ * A password text field. The value data type is `String`.
7
+ * @alias qui.forms.commonfields.PasswordField
8
+ * @extends qui.forms.commonfields.TextField
9
+ */
10
+ class PasswordField extends TextField {
11
+
12
+ static WIDGET_CLASS = 'passwordinput'
13
+
14
+
15
+ /**
16
+ * @constructs
17
+ * @param {Boolean} [clearEnabled] set to `true` to enable clear button
18
+ * @param {Boolean} [revealOnFocus] set to `true` to enable password revealing when widget is focused
19
+ * @param {...*} args parent class parameters
20
+ */
21
+ constructor({clearEnabled = false, revealOnFocus = false, ...args}) {
22
+ super({widgetAttrs: {clearEnabled, revealOnFocus}, ...args})
23
+ }
24
+
25
+ }
26
+
27
+
28
+ export default PasswordField
@@ -0,0 +1,26 @@
1
+
2
+ import TextField from './text-field.js'
3
+
4
+
5
+ /**
6
+ * A phone number text field. The value data type is `String`.
7
+ * @alias qui.forms.commonfields.PhoneField
8
+ * @extends qui.forms.commonfields.TextField
9
+ */
10
+ class PhoneField extends TextField {
11
+
12
+ static WIDGET_CLASS = 'phoneinput'
13
+
14
+
15
+ /**
16
+ * @constructs
17
+ * @param {...*} args parent class parameters
18
+ */
19
+ constructor({...args}) {
20
+ super(args)
21
+ }
22
+
23
+ }
24
+
25
+
26
+ export default PhoneField
@@ -0,0 +1,69 @@
1
+
2
+ import * as ObjectUtils from '$qui/utils/object.js'
3
+
4
+ import JQueryUIField from './jquery-ui-field.js'
5
+
6
+
7
+ /**
8
+ * A progress disk field. The value data type is `Number`.
9
+ * @alias qui.forms.commonfields.ProgressDiskField
10
+ * @extends qui.forms.commonfields.JQueryUIField
11
+ */
12
+ class ProgressDiskField extends JQueryUIField {
13
+
14
+ static WIDGET_CLASS = 'progressdisk'
15
+
16
+
17
+ /**
18
+ * @constructs
19
+ * @param {Number|String} [radius] the disk radius (defaults to `1em`)
20
+ * @param {String} [caption] the caption template displayed on top of the disk (defaults to `%s%%`)
21
+ * @param {String} [color] the color (defaults to `@interactive-color`)
22
+ * @param {...*} args parent class parameters
23
+ */
24
+ constructor({radius = '1em', caption = '%s%%', color = '@interactive-color', ...args}) {
25
+ /* We always prefer having the widget on the same line with its label */
26
+ ObjectUtils.setDefault(args, 'forceOneLine', true)
27
+
28
+ super({widgetAttrs: {radius, caption, color}, ...args})
29
+ }
30
+
31
+ /**
32
+ * Set radius.
33
+ * @param {String} radius
34
+ */
35
+ setRadius(radius) {
36
+ this._widgetCall({radius})
37
+ }
38
+
39
+ /**
40
+ * Set caption.
41
+ * @param {String} caption
42
+ */
43
+ setCaption(caption) {
44
+ this._widgetCall({caption})
45
+ }
46
+
47
+ /**
48
+ * Set color.
49
+ * @param {String} color
50
+ */
51
+ setColor(color) {
52
+ this._widgetCall({color})
53
+ }
54
+
55
+ setForm(form) {
56
+ // TODO: generalize this code
57
+ super.setForm(form)
58
+
59
+ /* On compact forms, reduce the value width when showing on the same line with label, so that label can take as
60
+ * much space as needed */
61
+ if (form.isCompact() && this.isForceOneLine() && this.getValueWidth() == null) {
62
+ this.setValueWidth(0)
63
+ }
64
+ }
65
+
66
+ }
67
+
68
+
69
+ export default ProgressDiskField
@@ -0,0 +1,138 @@
1
+
2
+ import JQueryUIField from './jquery-ui-field.js'
3
+
4
+
5
+ /**
6
+ * A push button field. The value of this field will always be `null`.
7
+ * @alias qui.forms.commonfields.PushButtonField
8
+ * @extends qui.forms.commonfields.JQueryUIField
9
+ */
10
+ class PushButtonField extends JQueryUIField {
11
+
12
+ static WIDGET_CLASS = 'pushbutton'
13
+
14
+
15
+ /**
16
+ * @constructs
17
+ * @param {String} caption the button caption
18
+ * @param {Function} [onClick] function to be executed when the button is pushed (see
19
+ * {@link qui.forms.commonfields.PushButtonField#onClick})
20
+ * @param {String} caption button caption
21
+ * @param {String} [style] button style:
22
+ * * `"foreground"`
23
+ * * `"interactive"` (default)
24
+ * * `"highlight"`
25
+ * * `"danger"`,
26
+ * * `"colored"`
27
+ * @param {String} [backgroundColor] custom background color (ignored unless `style` is `"colored"`)
28
+ * @param {String} [backgroundActiveColor] custom background active color (ignored unless `style` is `"colored"`)
29
+ * @param {String} [foregroundColor] custom foreground color (ignored unless `style` is `"colored"`)
30
+ * @param {qui.icons.Icon} [icon] an optional button icon
31
+ * @param {...*} args parent class parameters
32
+ */
33
+ constructor({
34
+ caption,
35
+ onClick = null,
36
+ style = 'interactive',
37
+ backgroundColor = '@interactive-color',
38
+ backgroundActiveColor = '@interactive-active-color',
39
+ foregroundColor = '@foreground-interactive-color',
40
+ icon = null,
41
+ ...args
42
+ }) {
43
+ super({
44
+ widgetAttrs: {
45
+ caption,
46
+ style,
47
+ backgroundColor,
48
+ backgroundActiveColor,
49
+ foregroundColor,
50
+ icon
51
+ },
52
+ ...args
53
+ })
54
+
55
+ if (onClick) {
56
+ this.onClick = onClick
57
+ }
58
+ }
59
+
60
+ makeWidget() {
61
+ let div = super.makeWidget()
62
+
63
+ div.addClass('qui-form-push-button')
64
+ div.on('click', () => this.onClick(this.getForm()))
65
+
66
+ if (this.getValueWidth() === 100) {
67
+ div.css('display', 'block')
68
+ }
69
+
70
+ return div
71
+ }
72
+
73
+ /**
74
+ * Called when the button is pushed.
75
+ * @param {qui.forms.Form} form owning form
76
+ */
77
+ onClick(form) {
78
+ }
79
+
80
+ valueToWidget(value) {
81
+ }
82
+
83
+ widgetToValue() {
84
+ return null
85
+ }
86
+
87
+ /**
88
+ * Update button style.
89
+ * @param {String} style
90
+ */
91
+ setStyle(style) {
92
+ this._widgetCall({style: style})
93
+ }
94
+
95
+ /**
96
+ * Update button caption.
97
+ * @param {String} caption
98
+ */
99
+ setCaption(caption) {
100
+ this._widgetCall({caption: caption})
101
+ }
102
+
103
+ /**
104
+ * Update background color.
105
+ * @param {String} color
106
+ */
107
+ setBackgroundColor(color) {
108
+ this._widgetCall({backgroundColor: color})
109
+ }
110
+
111
+ /**
112
+ * Update background active color.
113
+ * @param {String} color
114
+ */
115
+ setBackgroundActiveColor(color) {
116
+ this._widgetCall({backgroundActiveColor: color})
117
+ }
118
+
119
+ /**
120
+ * Update foreground color.
121
+ * @param {String} color
122
+ */
123
+ setForegroundColor(color) {
124
+ this._widgetCall({foregroundColor: color})
125
+ }
126
+
127
+ /**
128
+ * Update button icon.
129
+ * @param {?qui.icons.Icon} icon
130
+ */
131
+ setIcon(icon) {
132
+ this._widgetCall({icon: icon})
133
+ }
134
+
135
+ }
136
+
137
+
138
+ export default PushButtonField
@@ -0,0 +1,51 @@
1
+
2
+ import JQueryUIField from './jquery-ui-field.js'
3
+
4
+
5
+ /**
6
+ * A slider field. The value data type is `Number`.
7
+ * @alias qui.forms.commonfields.SliderField
8
+ * @extends qui.forms.commonfields.JQueryUIField
9
+ */
10
+ class SliderField extends JQueryUIField {
11
+
12
+ static WIDGET_CLASS = 'slider'
13
+
14
+
15
+ // TODO add setters and getters for widget properties
16
+
17
+ /**
18
+ * @constructs
19
+ * @param {Object[]} [ticks] tick marks (pairs of `label` and `value`)
20
+ * @param {Number} [ticksStep] display every `ticksStep` tick (defaults to `1`)
21
+ * @param {Boolean} [equidistant] set to `true` to draw the tick marks equidistantly, even if their corresponding
22
+ * values are not equally distanced
23
+ * @param {Number} [fastFactor] determines how fast the increase or decrease functions will work when using
24
+ * page-up/page-down (defaults to `5`, which is 5 times faster)
25
+ * @param {Boolean} [continuousChange] set to `false` to only trigger a `change` event at the end of the slider move
26
+ * @param {...*} args parent class parameters
27
+ */
28
+ constructor({
29
+ ticks = [],
30
+ ticksStep = 1,
31
+ equidistant = false,
32
+ fastFactor = 5,
33
+ continuousChange = true,
34
+ ...args
35
+ }) {
36
+ super({
37
+ widgetAttrs: {
38
+ ticks: ticks,
39
+ ticksStep: ticksStep,
40
+ equidistant: equidistant,
41
+ fastFactor: fastFactor,
42
+ continuousChange: continuousChange
43
+ },
44
+ ...args
45
+ })
46
+ }
47
+
48
+ }
49
+
50
+
51
+ export default SliderField
@@ -0,0 +1,34 @@
1
+
2
+ import TextField from './text-field.js'
3
+
4
+
5
+ /**
6
+ * A text area field. The value data type is `String`.
7
+ * @alias qui.forms.commonfields.TextAreaField
8
+ * @extends qui.forms.commonfields.TextField
9
+ */
10
+ class TextAreaField extends TextField {
11
+
12
+ static WIDGET_CLASS = 'textarea'
13
+
14
+
15
+ /**
16
+ * @constructs
17
+ * @param {Number} [columns] number of columns
18
+ * @param {Number} [rows] number of rows
19
+ * @param {Boolean} [wrap] enable automatic content wrapping
20
+ * @param {?String} [resize] resize mode (one of `null`, `"horizontal"`, `"vertical"` and `"both"`)
21
+ * @param {...*} args parent class parameters
22
+ */
23
+ constructor({columns = null, rows = null, wrap = false, resize = null, ...args}) {
24
+ super({widgetAttrs: {columns, rows, wrap, resize}, ...args})
25
+ }
26
+
27
+ getInputElement() {
28
+ return this.getWidget().children('textarea')
29
+ }
30
+
31
+ }
32
+
33
+
34
+ export default TextAreaField
@@ -0,0 +1,89 @@
1
+
2
+ import {gettext} from '$qui/base/i18n.js'
3
+
4
+ import JQueryUIField from './jquery-ui-field.js'
5
+
6
+
7
+ /**
8
+ * A simple text field. The value data type is `String`.
9
+ * @alias qui.forms.commonfields.TextField
10
+ * @extends qui.forms.commonfields.JQueryUIField
11
+ */
12
+ class TextField extends JQueryUIField {
13
+
14
+ static WIDGET_CLASS = 'textinput'
15
+
16
+
17
+ /**
18
+ * @constructs
19
+ * @param {?String} [placeholder] an empty-text placeholder
20
+ * @param {Boolean} [clearPlaceholder] set to `true` to clear the placeholder on first change (defaults to `false`)
21
+ * @param {Boolean|String} [autocomplete] enables or disables field autocomplete (disabled by default); if a string
22
+ * value is given, it will be used to set the `autocomplete` element attribute
23
+ * @param {?Number} [minLength] minimum required text length
24
+ * @param {?Number} [maxLength] maximum allowed text length
25
+ * @param {?String|RegExp} [pattern] a regular expression used to validate the value
26
+ * @param {Boolean} [continuousChange] set to `false` to prevent triggering change events at each key stroke
27
+ * @param {Object} [widgetAttrs] extra attributes to pass to underlying JQueryUI widget
28
+ * @param {...*} args parent class parameters
29
+ */
30
+ constructor({
31
+ placeholder = null,
32
+ clearPlaceholder = false,
33
+ autocomplete = false,
34
+ minLength = null,
35
+ maxLength = null,
36
+ pattern = null,
37
+ continuousChange = true,
38
+ widgetAttrs = {},
39
+ ...args
40
+ }) {
41
+ Object.assign(widgetAttrs, {
42
+ placeholder: placeholder,
43
+ clearPlaceholder: clearPlaceholder,
44
+ autocomplete: autocomplete,
45
+ minLength: minLength,
46
+ maxLength: maxLength,
47
+ continuousChange: continuousChange
48
+ })
49
+
50
+ super({widgetAttrs: widgetAttrs, ...args})
51
+
52
+ if (typeof pattern === 'string') {
53
+ pattern = new RegExp(pattern)
54
+ }
55
+
56
+ this._pattern = pattern
57
+ }
58
+
59
+ validateWidget(value) {
60
+ let error = super.validateWidget(value)
61
+ if (error) {
62
+ return error
63
+ }
64
+
65
+ if (!this.isRequired() && !value) {
66
+ return
67
+ }
68
+
69
+ /* Apply pattern validation, if supplied */
70
+ if (this._pattern) {
71
+ let match = value.match(this._pattern)
72
+ if (match == null) {
73
+ return gettext('Value does not match required pattern.')
74
+ }
75
+ }
76
+ }
77
+
78
+ getInputElement() {
79
+ return this.getWidget().children('input')
80
+ }
81
+
82
+ getFocusableElement() {
83
+ return this.getInputElement()
84
+ }
85
+
86
+ }
87
+
88
+
89
+ export default TextField