@pie-element/passage 1.6.4-ps.1 → 1.6.4-ps.5

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/module/demo.js CHANGED
@@ -1,6 +1,8 @@
1
- import PrintElement from './print.js';
1
+ import Element from './element.js';
2
2
 
3
- var model$1 = (id, element) => ({
3
+ var generate = {};
4
+
5
+ generate.model = (id, element) => ({
4
6
  id,
5
7
  element,
6
8
  passages: [
@@ -30,10 +32,6 @@ var model$1 = (id, element) => ({
30
32
  ]
31
33
  });
32
34
 
33
- var generate = {
34
- model: model$1
35
- };
36
-
37
35
  const { model } = generate;
38
36
 
39
37
  var config = {
@@ -43,52 +41,23 @@ var config = {
43
41
  models: [model('1', 'passage-element')]
44
42
  };
45
43
 
46
- // new init - just shows off print!
47
-
48
- const init = async () => {
49
- console.log('define the element...');
50
- await Promise.all(
51
- config.models.map(async (m) => {
52
- try {
53
- const printTag = `${m.element}-print`;
54
- if (customElements.get(printTag)) {
55
- return true;
56
- } else {
57
- customElements.define(printTag, PrintElement);
58
- await customElements.whenDefined(printTag);
59
- return true;
60
- }
61
- } catch (e) {
62
- return false;
63
- }
64
- })
65
- );
66
-
67
- console.log('now apply the model...');
68
- config.models.forEach((m) => {
69
- const printTag = `${m.element}-print`;
70
- const h3s = document.createElement('h3');
71
- h3s.textContent = 'student mode';
72
- document.body.appendChild(h3s);
73
- const de = document.createElement(printTag);
74
- document.body.appendChild(de);
75
- de.options = {};
76
- de.model = m;
77
-
78
- const h3 = document.createElement('h3');
79
- h3.textContent = 'instructor mode';
80
- document.body.appendChild(h3);
81
- const instr = document.createElement(printTag);
82
- document.body.appendChild(instr);
83
- instr.options = { mode: 'instructor' };
84
- instr.model = JSON.parse(JSON.stringify(m));
85
- });
86
- };
87
-
88
- init()
89
- .then(() => {
90
- console.log('ready');
91
- })
92
- .catch((e) => {
93
- console.error(e);
44
+ // configure
45
+ class Configure extends HTMLElement{}
46
+
47
+
48
+ // controller
49
+ const controller = {
50
+ model: (q) => Promise.resolve(q),
51
+ outcome: (q) => Promise.resolve(q)
52
+ };
53
+
54
+
55
+ //Note: demo-el is a custom element loaded in the markup.
56
+ customElements.whenDefined("demo-el").then(() => {
57
+ config.models.forEach((m) => {
58
+ const de = document.createElement("demo-el");
59
+ document.body.appendChild(de);
60
+ de.def = { tagName: m.element, Element, Configure, controller };
61
+ de.model = m;
62
+ });
94
63
  });