@sparkle-learning/core 0.0.54 → 0.0.56

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 (110) hide show
  1. package/dist/cjs/{PrivateRoute-e2047db2.js → PrivateRoute-f97245ce.js} +2 -2
  2. package/dist/cjs/{appdata.service-d28cf2d6.js → appdata.service-c8d71e05.js} +1 -1
  3. package/dist/cjs/assignment.service-690fb59c.js +19 -0
  4. package/dist/cjs/{facilitator.service-0b9f6ac7.js → facilitator.service-ff0e1659.js} +1 -1
  5. package/dist/cjs/{feed.service-6df9382f.js → feed.service-8eca4de6.js} +1 -1
  6. package/dist/cjs/header-mobile-collapse_61.cjs.entry.js +9 -9
  7. package/dist/cjs/{httpService-d8a5b474.js → httpService-d2e7bf8f.js} +1 -1
  8. package/dist/cjs/index.cjs.js +3 -3
  9. package/dist/cjs/{ion-action-sheet_4.cjs.entry.js → ion-action-sheet_7.cjs.entry.js} +728 -0
  10. package/dist/cjs/loader.cjs.js +1 -1
  11. package/dist/cjs/{media.service-2bc73d37.js → media.service-8a1b9bc5.js} +1 -1
  12. package/dist/cjs/{signalR.service-0d5da1d3.js → signalR.service-bd6b42f9.js} +1 -1
  13. package/dist/cjs/sparkle-assignment.cjs.entry.js +90 -5
  14. package/dist/cjs/sparkle-core.cjs.js +1 -1
  15. package/dist/cjs/sparkle-discussion-questions_2.cjs.entry.js +2 -2
  16. package/dist/cjs/sparkle-facilitator-notes-form.cjs.entry.js +3 -3
  17. package/dist/cjs/sparkle-feed-post.cjs.entry.js +116 -0
  18. package/dist/cjs/sparkle-feedback.cjs.entry.js +3 -3
  19. package/dist/cjs/sparkle-file-upload.cjs.entry.js +53 -0
  20. package/dist/cjs/sparkle-goal-form.cjs.entry.js +4 -4
  21. package/dist/cjs/sparkle-input.cjs.entry.js +56 -0
  22. package/dist/cjs/sparkle-video-player.cjs.entry.js +22 -0
  23. package/dist/cjs/{student.service-d8ec2551.js → student.service-7e5385be.js} +1 -1
  24. package/dist/cjs/{token.service-bfb0089b.js → token.service-7a41953d.js} +11 -0
  25. package/dist/collection/collection-manifest.json +3 -0
  26. package/dist/collection/components/sparkle-assignment/sparkle-assignment.css +27 -0
  27. package/dist/collection/components/sparkle-assignment/sparkle-assignment.js +141 -7
  28. package/dist/collection/components/sparkle-feed-post/sparkle-feed-post.js +2 -10
  29. package/dist/collection/components/sparkle-file-upload/sparkle-file-upload.css +0 -0
  30. package/dist/collection/components/sparkle-file-upload/sparkle-file-upload.js +105 -0
  31. package/dist/collection/components/sparkle-input/sparkle-input.css +0 -0
  32. package/dist/collection/components/sparkle-input/sparkle-input.js +212 -0
  33. package/dist/collection/components/sparkle-video-player/sparkle-video-player.css +0 -0
  34. package/dist/collection/components/sparkle-video-player/sparkle-video-player.js +92 -0
  35. package/dist/collection/services/token.service.js +11 -0
  36. package/dist/esm/{PrivateRoute-c6e80d5d.js → PrivateRoute-90ac95b8.js} +2 -2
  37. package/dist/esm/{appdata.service-d1058e00.js → appdata.service-2e84e167.js} +1 -1
  38. package/dist/esm/assignment.service-8d31f141.js +17 -0
  39. package/dist/esm/{facilitator.service-53e05a01.js → facilitator.service-18c47bdf.js} +1 -1
  40. package/dist/esm/{feed.service-8385ad7a.js → feed.service-b4f3cae4.js} +1 -1
  41. package/dist/esm/header-mobile-collapse_61.entry.js +10 -10
  42. package/dist/esm/{httpService-db476835.js → httpService-7986aeed.js} +2 -2
  43. package/dist/esm/index.js +4 -4
  44. package/dist/esm/{ion-action-sheet_4.entry.js → ion-action-sheet_7.entry.js} +729 -4
  45. package/dist/esm/ion-loading.entry.js +1 -1
  46. package/dist/esm/ion-menu.entry.js +1 -1
  47. package/dist/esm/ion-modal.entry.js +1 -1
  48. package/dist/esm/ion-picker.entry.js +1 -1
  49. package/dist/esm/ion-toast.entry.js +1 -1
  50. package/dist/esm/loader.js +1 -1
  51. package/dist/esm/{media.service-b68cbfff.js → media.service-6e90bc41.js} +1 -1
  52. package/dist/esm/{overlays-3b4dca92.js → overlays-4233a39d.js} +1 -1
  53. package/dist/esm/{signalR.service-4a2d5a92.js → signalR.service-c33fba50.js} +1 -1
  54. package/dist/esm/sparkle-assignment.entry.js +91 -6
  55. package/dist/esm/sparkle-core.js +1 -1
  56. package/dist/esm/sparkle-discussion-questions_2.entry.js +2 -2
  57. package/dist/esm/sparkle-facilitator-notes-form.entry.js +4 -4
  58. package/dist/esm/sparkle-feed-post.entry.js +112 -0
  59. package/dist/esm/sparkle-feedback.entry.js +4 -4
  60. package/dist/esm/sparkle-file-upload.entry.js +49 -0
  61. package/dist/esm/sparkle-goal-form.entry.js +5 -5
  62. package/dist/esm/sparkle-input.entry.js +52 -0
  63. package/dist/esm/sparkle-video-player.entry.js +18 -0
  64. package/dist/esm/{student.service-6457aaa0.js → student.service-08af124f.js} +1 -1
  65. package/dist/esm/{token.service-20f1a256.js → token.service-71a5d33f.js} +11 -0
  66. package/dist/sparkle-core/index.esm.js +1 -1
  67. package/dist/sparkle-core/p-08420531.entry.js +1 -0
  68. package/dist/sparkle-core/p-08cca80d.entry.js +1 -0
  69. package/dist/sparkle-core/p-0e8e539f.entry.js +1 -0
  70. package/dist/sparkle-core/{p-11ac00b0.js → p-1adc98f6.js} +1 -1
  71. package/dist/sparkle-core/{p-71720d6e.entry.js → p-38c842d5.entry.js} +1 -1
  72. package/dist/sparkle-core/{p-38f707fb.js → p-39a31e43.js} +1 -1
  73. package/dist/sparkle-core/{p-6a1fc0af.entry.js → p-3daf2915.entry.js} +1 -1
  74. package/dist/sparkle-core/{p-dcff298d.entry.js → p-42ed7d5f.entry.js} +1 -1
  75. package/dist/sparkle-core/{p-6fab3a4b.js → p-4b4a8703.js} +1 -1
  76. package/dist/sparkle-core/{p-98f7780c.entry.js → p-4d1cfcbe.entry.js} +1 -1
  77. package/dist/sparkle-core/p-4fba3e4c.js +1 -0
  78. package/dist/sparkle-core/{p-54dd894f.entry.js → p-6bde0192.entry.js} +1 -1
  79. package/dist/sparkle-core/{p-6faa194c.entry.js → p-6d2f4093.entry.js} +1 -1
  80. package/dist/sparkle-core/{p-ed9de327.js → p-7dae0f0e.js} +1 -1
  81. package/dist/sparkle-core/p-973fe404.entry.js +22 -0
  82. package/dist/sparkle-core/{p-967a2ed7.js → p-b06e2bef.js} +1 -1
  83. package/dist/sparkle-core/{p-e863bf1d.entry.js → p-b6fec622.entry.js} +1 -1
  84. package/dist/sparkle-core/{p-630a4fa0.js → p-b8d71ff4.js} +1 -1
  85. package/dist/sparkle-core/p-c7e21070.entry.js +1 -0
  86. package/dist/sparkle-core/{p-17b6b07e.js → p-c9f753a4.js} +1 -1
  87. package/dist/sparkle-core/{p-d51f30ca.js → p-da391f3f.js} +1 -1
  88. package/dist/sparkle-core/{p-38fa5987.js → p-e0cad1bb.js} +1 -1
  89. package/dist/sparkle-core/{p-ce4b22f7.entry.js → p-f196c124.entry.js} +1 -1
  90. package/dist/sparkle-core/p-f47fe1fe.entry.js +1 -0
  91. package/dist/sparkle-core/{p-e50c8b04.entry.js → p-f714f77a.entry.js} +1 -1
  92. package/dist/sparkle-core/{p-377b04c2.entry.js → p-ff080f82.entry.js} +1 -1
  93. package/dist/sparkle-core/{p-2ff67662.js → p-ff7a8a71.js} +1 -1
  94. package/dist/sparkle-core/sparkle-core.esm.js +1 -1
  95. package/dist/types/components/sparkle-assignment/sparkle-assignment.d.ts +11 -1
  96. package/dist/types/components/sparkle-feed-post/sparkle-feed-post.d.ts +1 -1
  97. package/dist/types/components/sparkle-file-upload/sparkle-file-upload.d.ts +15 -0
  98. package/dist/types/components/sparkle-input/sparkle-input.d.ts +23 -0
  99. package/dist/types/components/sparkle-video-player/sparkle-video-player.d.ts +7 -0
  100. package/dist/types/components.d.ts +83 -0
  101. package/dist/types/services/token.service.d.ts +1 -0
  102. package/package.json +1 -1
  103. package/dist/cjs/ion-select_3.cjs.entry.js +0 -627
  104. package/dist/cjs/ion-textarea.cjs.entry.js +0 -248
  105. package/dist/esm/ion-select_3.entry.js +0 -621
  106. package/dist/esm/ion-textarea.entry.js +0 -244
  107. package/dist/sparkle-core/p-0f1c5899.entry.js +0 -18
  108. package/dist/sparkle-core/p-33a7151d.entry.js +0 -1
  109. package/dist/sparkle-core/p-641bfc92.entry.js +0 -1
  110. package/dist/sparkle-core/p-ca907214.entry.js +0 -4
@@ -1,627 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const index = require('./index-51e8292e.js');
6
- const ionicGlobal = require('./ionic-global-2cde9d3a.js');
7
- const helpers = require('./helpers-c2496722.js');
8
- const overlays = require('./overlays-32df265a.js');
9
- const theme = require('./theme-b0b295c1.js');
10
- const httpService = require('./httpService-d8a5b474.js');
11
- const feed_service = require('./feed.service-6df9382f.js');
12
- const media_service = require('./media.service-2bc73d37.js');
13
- const token_service = require('./token.service-bfb0089b.js');
14
- const util = require('./util-47e320b2.js');
15
- require('./hardware-back-button-92d97ff8.js');
16
- require('./auth.store-1e630a7d.js');
17
- require('./environment-config.service-c8ff1f3d.js');
18
- require('./localstorage.service-6346a41d.js');
19
-
20
- /*!
21
- * (C) Ionic http://ionicframework.com - MIT License
22
- */
23
- const watchForOptions = (containerEl, tagName, onChange) => {
24
- if (typeof MutationObserver === 'undefined') {
25
- return;
26
- }
27
- const mutation = new MutationObserver((mutationList) => {
28
- onChange(getSelectedOption(mutationList, tagName));
29
- });
30
- mutation.observe(containerEl, {
31
- childList: true,
32
- subtree: true,
33
- });
34
- return mutation;
35
- };
36
- const getSelectedOption = (mutationList, tagName) => {
37
- let newOption;
38
- mutationList.forEach((mut) => {
39
- // eslint-disable-next-line @typescript-eslint/prefer-for-of
40
- for (let i = 0; i < mut.addedNodes.length; i++) {
41
- newOption = findCheckedOption(mut.addedNodes[i], tagName) || newOption;
42
- }
43
- });
44
- return newOption;
45
- };
46
- const findCheckedOption = (el, tagName) => {
47
- if (el.nodeType !== 1) {
48
- return undefined;
49
- }
50
- const options = el.tagName === tagName.toUpperCase() ? [el] : Array.from(el.querySelectorAll(tagName));
51
- return options.find((o) => o.value === el.value);
52
- };
53
-
54
- const selectIosCss = ":host{--placeholder-color:currentColor;--placeholder-opacity:0.33;padding-left:var(--padding-start);padding-right:var(--padding-end);padding-top:var(--padding-top);padding-bottom:var(--padding-bottom);display:flex;position:relative;align-items:center;font-family:var(--ion-font-family, inherit);overflow:hidden;z-index:2}@supports (margin-inline-start: 0) or (-webkit-margin-start: 0){:host{padding-left:unset;padding-right:unset;-webkit-padding-start:var(--padding-start);padding-inline-start:var(--padding-start);-webkit-padding-end:var(--padding-end);padding-inline-end:var(--padding-end)}}:host(.in-item){position:static;max-width:45%}:host(.select-disabled){opacity:0.4;pointer-events:none}:host(.ion-focused) button{border:2px solid #5e9ed6}.select-placeholder{color:var(--placeholder-color);opacity:var(--placeholder-opacity)}label{left:0;top:0;margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;position:absolute;width:100%;height:100%;border:0;background:transparent;cursor:pointer;appearance:none;outline:none;display:flex;align-items:center;opacity:0}[dir=rtl] label,:host-context([dir=rtl]) label{left:unset;right:unset;right:0}label::-moz-focus-inner{border:0}button{position:absolute;top:0;left:0;right:0;bottom:0;width:100%;height:100%;margin:0;padding:0;border:0;outline:0;clip:rect(0 0 0 0);opacity:0;overflow:hidden;-webkit-appearance:none;-moz-appearance:none}.select-icon{position:relative}.select-text{flex:1;min-width:16px;font-size:inherit;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.select-icon-inner{left:5px;top:50%;margin-top:-2px;position:absolute;width:0;height:0;border-top:5px solid;border-right:5px solid transparent;border-left:5px solid transparent;color:currentColor;pointer-events:none}[dir=rtl] .select-icon-inner,:host-context([dir=rtl]) .select-icon-inner{left:unset;right:unset;right:5px}:host{--padding-top:10px;--padding-end:10px;--padding-bottom:10px;--padding-start:20px}.select-icon{width:12px;height:18px;opacity:0.33}";
55
-
56
- const selectMdCss = ":host{--placeholder-color:currentColor;--placeholder-opacity:0.33;padding-left:var(--padding-start);padding-right:var(--padding-end);padding-top:var(--padding-top);padding-bottom:var(--padding-bottom);display:flex;position:relative;align-items:center;font-family:var(--ion-font-family, inherit);overflow:hidden;z-index:2}@supports (margin-inline-start: 0) or (-webkit-margin-start: 0){:host{padding-left:unset;padding-right:unset;-webkit-padding-start:var(--padding-start);padding-inline-start:var(--padding-start);-webkit-padding-end:var(--padding-end);padding-inline-end:var(--padding-end)}}:host(.in-item){position:static;max-width:45%}:host(.select-disabled){opacity:0.4;pointer-events:none}:host(.ion-focused) button{border:2px solid #5e9ed6}.select-placeholder{color:var(--placeholder-color);opacity:var(--placeholder-opacity)}label{left:0;top:0;margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;position:absolute;width:100%;height:100%;border:0;background:transparent;cursor:pointer;appearance:none;outline:none;display:flex;align-items:center;opacity:0}[dir=rtl] label,:host-context([dir=rtl]) label{left:unset;right:unset;right:0}label::-moz-focus-inner{border:0}button{position:absolute;top:0;left:0;right:0;bottom:0;width:100%;height:100%;margin:0;padding:0;border:0;outline:0;clip:rect(0 0 0 0);opacity:0;overflow:hidden;-webkit-appearance:none;-moz-appearance:none}.select-icon{position:relative}.select-text{flex:1;min-width:16px;font-size:inherit;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.select-icon-inner{left:5px;top:50%;margin-top:-2px;position:absolute;width:0;height:0;border-top:5px solid;border-right:5px solid transparent;border-left:5px solid transparent;color:currentColor;pointer-events:none}[dir=rtl] .select-icon-inner,:host-context([dir=rtl]) .select-icon-inner{left:unset;right:unset;right:5px}:host{--padding-top:10px;--padding-end:0;--padding-bottom:10px;--padding-start:16px}.select-icon{width:19px;height:19px;transition:transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);opacity:0.55}:host-context(.item-label-stacked) .select-icon,:host-context(.item-label-floating:not(.item-fill-outline)) .select-icon,:host-context(.item-label-floating.item-fill-outline){transform:translate3d(0, -9px, 0)}:host-context(.item-has-focus) .select-icon{transform:rotate(180deg)}:host-context(.item-has-focus.item-label-stacked) .select-icon,:host-context(.item-has-focus.item-label-floating:not(.item-fill-outline)) .select-icon{transform:translate3d(0, -9px, 0) rotate(180deg)}:host-context(ion-item.ion-focused) .select-icon,:host-context(.item-has-focus) .select-icon{color:var(--highlight-color-focused);opacity:1}";
57
-
58
- const Select = class {
59
- constructor(hostRef) {
60
- index.registerInstance(this, hostRef);
61
- this.ionChange = index.createEvent(this, "ionChange", 7);
62
- this.ionCancel = index.createEvent(this, "ionCancel", 7);
63
- this.ionDismiss = index.createEvent(this, "ionDismiss", 7);
64
- this.ionFocus = index.createEvent(this, "ionFocus", 7);
65
- this.ionBlur = index.createEvent(this, "ionBlur", 7);
66
- this.ionStyle = index.createEvent(this, "ionStyle", 7);
67
- this.inputId = `ion-sel-${selectIds++}`;
68
- this.didInit = false;
69
- this.isExpanded = false;
70
- /**
71
- * If `true`, the user cannot interact with the select.
72
- */
73
- this.disabled = false;
74
- /**
75
- * The text to display on the cancel button.
76
- */
77
- this.cancelText = 'Cancel';
78
- /**
79
- * The text to display on the ok button.
80
- */
81
- this.okText = 'OK';
82
- /**
83
- * The name of the control, which is submitted with the form data.
84
- */
85
- this.name = this.inputId;
86
- /**
87
- * If `true`, the select can accept multiple values.
88
- */
89
- this.multiple = false;
90
- /**
91
- * The interface the select should use: `action-sheet`, `popover` or `alert`.
92
- */
93
- this.interface = 'alert';
94
- /**
95
- * Any additional options that the `alert`, `action-sheet` or `popover` interface
96
- * can take. See the [ion-alert docs](./alert), the
97
- * [ion-action-sheet docs](./action-sheet) and the
98
- * [ion-popover docs](./popover) for the
99
- * create options for each interface.
100
- *
101
- * Note: `interfaceOptions` will not override `inputs` or `buttons` with the `alert` interface.
102
- */
103
- this.interfaceOptions = {};
104
- this.onClick = (ev) => {
105
- this.setFocus();
106
- this.open(ev);
107
- };
108
- this.onFocus = () => {
109
- this.ionFocus.emit();
110
- };
111
- this.onBlur = () => {
112
- this.ionBlur.emit();
113
- };
114
- }
115
- styleChanged() {
116
- this.emitStyle();
117
- }
118
- valueChanged() {
119
- this.emitStyle();
120
- // TODO: FW-1160 - Remove the `didInit` property when ionChange behavior is changed in v7.
121
- if (this.didInit) {
122
- this.ionChange.emit({
123
- value: this.value,
124
- });
125
- }
126
- }
127
- async connectedCallback() {
128
- this.updateOverlayOptions();
129
- this.emitStyle();
130
- this.mutationO = watchForOptions(this.el, 'ion-select-option', async () => {
131
- this.updateOverlayOptions();
132
- });
133
- }
134
- disconnectedCallback() {
135
- if (this.mutationO) {
136
- this.mutationO.disconnect();
137
- this.mutationO = undefined;
138
- }
139
- }
140
- componentDidLoad() {
141
- this.didInit = true;
142
- }
143
- /**
144
- * Open the select overlay. The overlay is either an alert, action sheet, or popover,
145
- * depending on the `interface` property on the `ion-select`.
146
- *
147
- * @param event The user interface event that called the open.
148
- */
149
- async open(event) {
150
- if (this.disabled || this.isExpanded) {
151
- return undefined;
152
- }
153
- this.isExpanded = true;
154
- const overlay = (this.overlay = await this.createOverlay(event));
155
- overlay.onDidDismiss().then(() => {
156
- this.overlay = undefined;
157
- this.isExpanded = false;
158
- this.ionDismiss.emit();
159
- this.setFocus();
160
- });
161
- await overlay.present();
162
- // focus selected option for popovers
163
- if (this.interface === 'popover') {
164
- let indexOfSelected = this.childOpts.map((o) => o.value).indexOf(this.value);
165
- indexOfSelected = indexOfSelected > -1 ? indexOfSelected : 0; // default to first option if nothing selected
166
- const selectedEl = overlay.querySelector(`.select-interface-option:nth-child(${indexOfSelected + 1})`);
167
- if (selectedEl) {
168
- helpers.focusElement(selectedEl);
169
- }
170
- }
171
- return overlay;
172
- }
173
- createOverlay(ev) {
174
- let selectInterface = this.interface;
175
- if (selectInterface === 'action-sheet' && this.multiple) {
176
- console.warn(`Select interface cannot be "${selectInterface}" with a multi-value select. Using the "alert" interface instead.`);
177
- selectInterface = 'alert';
178
- }
179
- if (selectInterface === 'popover' && !ev) {
180
- console.warn(`Select interface cannot be a "${selectInterface}" without passing an event. Using the "alert" interface instead.`);
181
- selectInterface = 'alert';
182
- }
183
- if (selectInterface === 'action-sheet') {
184
- return this.openActionSheet();
185
- }
186
- if (selectInterface === 'popover') {
187
- return this.openPopover(ev);
188
- }
189
- return this.openAlert();
190
- }
191
- updateOverlayOptions() {
192
- const overlay = this.overlay;
193
- if (!overlay) {
194
- return;
195
- }
196
- const childOpts = this.childOpts;
197
- const value = this.value;
198
- switch (this.interface) {
199
- case 'action-sheet':
200
- overlay.buttons = this.createActionSheetButtons(childOpts, value);
201
- break;
202
- case 'popover':
203
- const popover = overlay.querySelector('ion-select-popover');
204
- if (popover) {
205
- popover.options = this.createPopoverOptions(childOpts, value);
206
- }
207
- break;
208
- case 'alert':
209
- const inputType = this.multiple ? 'checkbox' : 'radio';
210
- overlay.inputs = this.createAlertInputs(childOpts, inputType, value);
211
- break;
212
- }
213
- }
214
- createActionSheetButtons(data, selectValue) {
215
- const actionSheetButtons = data.map((option) => {
216
- const value = getOptionValue(option);
217
- // Remove hydrated before copying over classes
218
- const copyClasses = Array.from(option.classList)
219
- .filter((cls) => cls !== 'hydrated')
220
- .join(' ');
221
- const optClass = `${OPTION_CLASS} ${copyClasses}`;
222
- return {
223
- role: isOptionSelected(selectValue, value, this.compareWith) ? 'selected' : '',
224
- text: option.textContent,
225
- cssClass: optClass,
226
- handler: () => {
227
- this.value = value;
228
- },
229
- };
230
- });
231
- // Add "cancel" button
232
- actionSheetButtons.push({
233
- text: this.cancelText,
234
- role: 'cancel',
235
- handler: () => {
236
- this.ionCancel.emit();
237
- },
238
- });
239
- return actionSheetButtons;
240
- }
241
- createAlertInputs(data, inputType, selectValue) {
242
- const alertInputs = data.map((option) => {
243
- const value = getOptionValue(option);
244
- // Remove hydrated before copying over classes
245
- const copyClasses = Array.from(option.classList)
246
- .filter((cls) => cls !== 'hydrated')
247
- .join(' ');
248
- const optClass = `${OPTION_CLASS} ${copyClasses}`;
249
- return {
250
- type: inputType,
251
- cssClass: optClass,
252
- label: option.textContent || '',
253
- value,
254
- checked: isOptionSelected(selectValue, value, this.compareWith),
255
- disabled: option.disabled,
256
- };
257
- });
258
- return alertInputs;
259
- }
260
- createPopoverOptions(data, selectValue) {
261
- const popoverOptions = data.map((option) => {
262
- const value = getOptionValue(option);
263
- // Remove hydrated before copying over classes
264
- const copyClasses = Array.from(option.classList)
265
- .filter((cls) => cls !== 'hydrated')
266
- .join(' ');
267
- const optClass = `${OPTION_CLASS} ${copyClasses}`;
268
- return {
269
- text: option.textContent || '',
270
- cssClass: optClass,
271
- value,
272
- checked: isOptionSelected(selectValue, value, this.compareWith),
273
- disabled: option.disabled,
274
- handler: (selected) => {
275
- this.value = selected;
276
- if (!this.multiple) {
277
- this.close();
278
- }
279
- },
280
- };
281
- });
282
- return popoverOptions;
283
- }
284
- async openPopover(ev) {
285
- const interfaceOptions = this.interfaceOptions;
286
- const mode = ionicGlobal.getIonMode(this);
287
- const showBackdrop = mode === 'md' ? false : true;
288
- const multiple = this.multiple;
289
- const value = this.value;
290
- let event = ev;
291
- let size = 'auto';
292
- const item = this.el.closest('ion-item');
293
- // If the select is inside of an item containing a floating
294
- // or stacked label then the popover should take up the
295
- // full width of the item when it presents
296
- if (item && (item.classList.contains('item-label-floating') || item.classList.contains('item-label-stacked'))) {
297
- event = Object.assign(Object.assign({}, ev), { detail: {
298
- ionShadowTarget: item,
299
- } });
300
- size = 'cover';
301
- }
302
- const popoverOpts = Object.assign(Object.assign({ mode,
303
- event, alignment: 'center', size,
304
- showBackdrop }, interfaceOptions), { component: 'ion-select-popover', cssClass: ['select-popover', interfaceOptions.cssClass], componentProps: {
305
- header: interfaceOptions.header,
306
- subHeader: interfaceOptions.subHeader,
307
- message: interfaceOptions.message,
308
- multiple,
309
- value,
310
- options: this.createPopoverOptions(this.childOpts, value),
311
- } });
312
- return overlays.popoverController.create(popoverOpts);
313
- }
314
- async openActionSheet() {
315
- const mode = ionicGlobal.getIonMode(this);
316
- const interfaceOptions = this.interfaceOptions;
317
- const actionSheetOpts = Object.assign(Object.assign({ mode }, interfaceOptions), { buttons: this.createActionSheetButtons(this.childOpts, this.value), cssClass: ['select-action-sheet', interfaceOptions.cssClass] });
318
- return overlays.actionSheetController.create(actionSheetOpts);
319
- }
320
- async openAlert() {
321
- const label = this.getLabel();
322
- const labelText = label ? label.textContent : null;
323
- const interfaceOptions = this.interfaceOptions;
324
- const inputType = this.multiple ? 'checkbox' : 'radio';
325
- const mode = ionicGlobal.getIonMode(this);
326
- const alertOpts = Object.assign(Object.assign({ mode }, interfaceOptions), { header: interfaceOptions.header ? interfaceOptions.header : labelText, inputs: this.createAlertInputs(this.childOpts, inputType, this.value), buttons: [
327
- {
328
- text: this.cancelText,
329
- role: 'cancel',
330
- handler: () => {
331
- this.ionCancel.emit();
332
- },
333
- },
334
- {
335
- text: this.okText,
336
- handler: (selectedValues) => {
337
- this.value = selectedValues;
338
- },
339
- },
340
- ], cssClass: [
341
- 'select-alert',
342
- interfaceOptions.cssClass,
343
- this.multiple ? 'multiple-select-alert' : 'single-select-alert',
344
- ] });
345
- return overlays.alertController.create(alertOpts);
346
- }
347
- /**
348
- * Close the select interface.
349
- */
350
- close() {
351
- // TODO check !this.overlay || !this.isFocus()
352
- if (!this.overlay) {
353
- return Promise.resolve(false);
354
- }
355
- return this.overlay.dismiss();
356
- }
357
- getLabel() {
358
- return helpers.findItemLabel(this.el);
359
- }
360
- hasValue() {
361
- return this.getText() !== '';
362
- }
363
- get childOpts() {
364
- return Array.from(this.el.querySelectorAll('ion-select-option'));
365
- }
366
- getText() {
367
- const selectedText = this.selectedText;
368
- if (selectedText != null && selectedText !== '') {
369
- return selectedText;
370
- }
371
- return generateText(this.childOpts, this.value, this.compareWith);
372
- }
373
- setFocus() {
374
- if (this.focusEl) {
375
- this.focusEl.focus();
376
- }
377
- }
378
- emitStyle() {
379
- this.ionStyle.emit({
380
- interactive: true,
381
- 'interactive-disabled': this.disabled,
382
- select: true,
383
- 'select-disabled': this.disabled,
384
- 'has-placeholder': this.placeholder !== undefined,
385
- 'has-value': this.hasValue(),
386
- 'has-focus': this.isExpanded,
387
- });
388
- }
389
- render() {
390
- const { disabled, el, inputId, isExpanded, name, placeholder, value } = this;
391
- const mode = ionicGlobal.getIonMode(this);
392
- const { labelText, labelId } = helpers.getAriaLabel(el, inputId);
393
- helpers.renderHiddenInput(true, el, name, parseValue(value), disabled);
394
- const displayValue = this.getText();
395
- let addPlaceholderClass = false;
396
- let selectText = displayValue;
397
- if (selectText === '' && placeholder !== undefined) {
398
- selectText = placeholder;
399
- addPlaceholderClass = true;
400
- }
401
- const selectTextClasses = {
402
- 'select-text': true,
403
- 'select-placeholder': addPlaceholderClass,
404
- };
405
- const textPart = addPlaceholderClass ? 'placeholder' : 'text';
406
- // If there is a label then we need to concatenate it with the
407
- // current value (or placeholder) and a comma so it separates
408
- // nicely when the screen reader announces it, otherwise just
409
- // announce the value / placeholder
410
- const displayLabel = labelText !== undefined ? (selectText !== '' ? `${selectText}, ${labelText}` : labelText) : selectText;
411
- return (index.h(index.Host, { onClick: this.onClick, role: "button", "aria-haspopup": "listbox", "aria-disabled": disabled ? 'true' : null, "aria-label": displayLabel, class: {
412
- [mode]: true,
413
- 'in-item': theme.hostContext('ion-item', el),
414
- 'select-disabled': disabled,
415
- 'select-expanded': isExpanded,
416
- } }, index.h("div", { "aria-hidden": "true", class: selectTextClasses, part: textPart }, selectText), index.h("div", { class: "select-icon", role: "presentation", part: "icon" }, index.h("div", { class: "select-icon-inner" })), index.h("label", { id: labelId }, displayLabel), index.h("button", { type: "button", disabled: disabled, id: inputId, "aria-labelledby": labelId, "aria-haspopup": "listbox", "aria-expanded": `${isExpanded}`, onFocus: this.onFocus, onBlur: this.onBlur, ref: (focusEl) => (this.focusEl = focusEl) })));
417
- }
418
- get el() { return index.getElement(this); }
419
- static get watchers() { return {
420
- "disabled": ["styleChanged"],
421
- "placeholder": ["styleChanged"],
422
- "isExpanded": ["styleChanged"],
423
- "value": ["valueChanged"]
424
- }; }
425
- };
426
- const isOptionSelected = (currentValue, compareValue, compareWith) => {
427
- if (currentValue === undefined) {
428
- return false;
429
- }
430
- if (Array.isArray(currentValue)) {
431
- return currentValue.some((val) => compareOptions(val, compareValue, compareWith));
432
- }
433
- else {
434
- return compareOptions(currentValue, compareValue, compareWith);
435
- }
436
- };
437
- const getOptionValue = (el) => {
438
- const value = el.value;
439
- return value === undefined ? el.textContent || '' : value;
440
- };
441
- const parseValue = (value) => {
442
- if (value == null) {
443
- return undefined;
444
- }
445
- if (Array.isArray(value)) {
446
- return value.join(',');
447
- }
448
- return value.toString();
449
- };
450
- const compareOptions = (currentValue, compareValue, compareWith) => {
451
- if (typeof compareWith === 'function') {
452
- return compareWith(currentValue, compareValue);
453
- }
454
- else if (typeof compareWith === 'string') {
455
- return currentValue[compareWith] === compareValue[compareWith];
456
- }
457
- else {
458
- return Array.isArray(compareValue) ? compareValue.includes(currentValue) : currentValue === compareValue;
459
- }
460
- };
461
- const generateText = (opts, value, compareWith) => {
462
- if (value === undefined) {
463
- return '';
464
- }
465
- if (Array.isArray(value)) {
466
- return value
467
- .map((v) => textForValue(opts, v, compareWith))
468
- .filter((opt) => opt !== null)
469
- .join(', ');
470
- }
471
- else {
472
- return textForValue(opts, value, compareWith) || '';
473
- }
474
- };
475
- const textForValue = (opts, value, compareWith) => {
476
- const selectOpt = opts.find((opt) => {
477
- return compareOptions(getOptionValue(opt), value, compareWith);
478
- });
479
- return selectOpt ? selectOpt.textContent : null;
480
- };
481
- let selectIds = 0;
482
- const OPTION_CLASS = 'select-interface-option';
483
- Select.style = {
484
- ios: selectIosCss,
485
- md: selectMdCss
486
- };
487
-
488
- const selectOptionCss = ":host{display:none}";
489
-
490
- const SelectOption = class {
491
- constructor(hostRef) {
492
- index.registerInstance(this, hostRef);
493
- this.inputId = `ion-selopt-${selectOptionIds++}`;
494
- /**
495
- * If `true`, the user cannot interact with the select option. This property does not apply when `interface="action-sheet"` as `ion-action-sheet` does not allow for disabled buttons.
496
- */
497
- this.disabled = false;
498
- }
499
- render() {
500
- return index.h(index.Host, { role: "option", id: this.inputId, class: ionicGlobal.getIonMode(this) });
501
- }
502
- get el() { return index.getElement(this); }
503
- };
504
- let selectOptionIds = 0;
505
- SelectOption.style = selectOptionCss;
506
-
507
- class AssignmentService {
508
- constructor() { }
509
- static getInstance() {
510
- if (!AssignmentService.instance) {
511
- AssignmentService.instance = new AssignmentService();
512
- }
513
- return AssignmentService.instance;
514
- }
515
- async createAssignment(payload) {
516
- let result = await httpService.HttpService.http.post(`api/v1/Assignment/Create`, payload);
517
- return result;
518
- }
519
- }
520
-
521
- const sparkleFeedPostCss = ":host{display:block}.post-footer-container{display:flex;justify-content:flex-end}.post-footer{display:flex;justify-content:space-between;align-items:center}.error{color:red;margin-right:10px}.success{color:green;margin-right:10px}.uploaded-image{display:block;max-height:140px;width:auto !important}.public-post-toggle{display:flex;justify-content:flex-end;align-items:center}.assignment-name{display:none}";
522
-
523
- const SparkleFeedPost = class {
524
- constructor(hostRef) {
525
- index.registerInstance(this, hostRef);
526
- }
527
- // @Prop({ connect: 'ion-toast-controller' })
528
- // toastCtrl: HTMLIonToastControllerElement;
529
- componentDidLoad() {
530
- this.postText = this.textValue;
531
- if (this.ref && this.ref.innerText) {
532
- this.assignmentName = this.ref.innerText;
533
- console.log(this.assignmentName);
534
- }
535
- }
536
- setText(text) {
537
- this.postText = text;
538
- }
539
- isAuthenticated() {
540
- try {
541
- let token = token_service.TokenService.getInstance().getTokenSync();
542
- if (!!token) {
543
- return true;
544
- }
545
- }
546
- catch (_a) {
547
- return false;
548
- }
549
- }
550
- async submitPost() {
551
- this.postLoading = true;
552
- this.errorMessage = '';
553
- this.successMessage = '';
554
- //let formData = new FormData(this.el.querySelector("form")) as any;
555
- //var postText = this.el.getElementsByClassName("PostText")[0] as HTMLInputElement;
556
- var postExternalUrl = this.el.getElementsByClassName('PostExternalUrl')[0];
557
- var isPublic = this.el.getElementsByClassName('IsPublic')[0];
558
- var data = {
559
- PostText: this.postText,
560
- IsPublic: isPublic.checked,
561
- ExternalResourceUrl: postExternalUrl.value,
562
- MiniAppId: util.SparkleGlobal.MY_GOALS_APP_ID,
563
- AssignmentName: this.assignmentName,
564
- AssignmentData: '',
565
- PostTextJSON: null,
566
- };
567
- const result = await feed_service.FeedService.getInstance().createPost(data);
568
- if (result.Succeeded) {
569
- this.postLoading = false;
570
- //show success toast
571
- this.successMessage = 'Posted Successfully.';
572
- this.postText = '';
573
- this.externalResourceUrl = '';
574
- this.uploadedImage = '';
575
- }
576
- else {
577
- this.postLoading = false;
578
- this.errorMessage = 'There is an error while posting to feed.';
579
- }
580
- if (this.assignmentName) {
581
- var assignmentModel = {
582
- AssignmentData: JSON.stringify({ text: data.PostText, url: data.ExternalResourceUrl }),
583
- AssignmentName: this.assignmentName,
584
- };
585
- await AssignmentService.getInstance().createAssignment(assignmentModel);
586
- }
587
- }
588
- async uploadImage(evt) {
589
- this.uploadImageLoading = true;
590
- var files = evt.target.files;
591
- let result = await media_service.MediaService.getInstance().uploadImage(files);
592
- if (result.Succeeded) {
593
- console.log(result);
594
- this.uploadImageLoading = false;
595
- this.uploadedImage = result.Data.length > 0 ? result.Data[0].FullImageUrl : '';
596
- this.externalResourceUrl = result.Data.length > 0 ? result.Data[0].FullImageUrl : '';
597
- }
598
- else {
599
- this.uploadImageLoading = false;
600
- this.errorMessage = 'There is an error while uploading an image.';
601
- }
602
- }
603
- selectFile() {
604
- var fileInput = document.getElementById('fileInput');
605
- fileInput.click();
606
- }
607
- renderUserInfo() {
608
- let authUser = token_service.TokenService.getInstance().getAuthUserSync();
609
- //var tokenInfo = { Token: null, ProfileImageUrl: null };
610
- if (authUser && authUser.JWToken) {
611
- return (index.h("ion-avatar", { class: "header-avatar", slot: "end" }, authUser.PhotoUrl ? index.h("img", { src: authUser.PhotoUrl }) : index.h("img", { src: "/assets/img/user.png" })));
612
- }
613
- else {
614
- return (index.h("ion-button", { slot: "end", href: "/login" }, "Login to Post"));
615
- }
616
- }
617
- render() {
618
- const userInfo = this.renderUserInfo();
619
- return (index.h(index.Host, null, index.h("div", { class: "assignment-name", ref: el => (this.ref = el) }, index.h("slot", null)), index.h("ion-card", null, index.h("ion-item", { class: "header", lines: "full" }, userInfo), index.h("ion-card-content", null, index.h("form", null, index.h("ion-list", null, index.h("ion-item", { class: "padding" }, index.h("ion-textarea", { class: "PostText", required: true, placeholder: "Post Text", name: "PostText", value: this.postText })), index.h("ion-item", { class: "padding" }, index.h("ion-input", { class: "PostExternalUrl", required: true, type: "text", placeholder: "URL", name: "ExternalResourceUrl", value: this.externalResourceUrl })), this.uploadedImage ? (index.h("ion-item", { class: "ion-padding", lines: "none" }, index.h("img", { class: "uploaded-image", src: this.uploadedImage }))) : (''), index.h("ion-item", { lines: "none" }, index.h("input", { type: "file", id: "fileInput", onChange: evt => this.uploadImage(evt), style: { display: 'none' }, accept: "image/*" }), this.uploadImageLoading ? index.h("ion-spinner", { color: "primary" }) : '', index.h("ion-button", { slot: "start", onClick: evt => this.selectFile() }, index.h("ion-icon", { name: "add" }), "Upload Image")), index.h("div", { class: "public-post-toggle" }, index.h("ion-toggle", { class: "IsPublic", color: "primary", name: "IsPublic" }), index.h("div", null, "Public Post")), index.h("div", { class: "post-footer-container" }, index.h("div", { class: "post-footer" }, index.h("div", null, index.h("div", { class: "error" }, this.errorMessage), index.h("div", { class: "success" }, this.successMessage)), index.h("div", null, this.postLoading ? index.h("ion-spinner", { color: "primary" }) : ''), index.h("ion-button", { slot: "end", size: "default", onClick: evt => this.submitPost(), disabled: this.postLoading || !this.isAuthenticated() }, "Post")))))))));
620
- }
621
- get el() { return index.getElement(this); }
622
- };
623
- SparkleFeedPost.style = sparkleFeedPostCss;
624
-
625
- exports.ion_select = Select;
626
- exports.ion_select_option = SelectOption;
627
- exports.sparkle_feed_post = SparkleFeedPost;