@icure/form 1.0.3 → 1.0.7

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 (121) hide show
  1. package/{lib/components → components}/index.d.ts +0 -0
  2. package/{lib/components → components}/index.js +0 -0
  3. package/{lib/components → components}/iqr-form/fields/datePicker.d.ts +0 -0
  4. package/{lib/components → components}/iqr-form/fields/datePicker.js +0 -0
  5. package/{lib/components → components}/iqr-form/fields/dateTimePicker.d.ts +0 -0
  6. package/{lib/components → components}/iqr-form/fields/dateTimePicker.js +0 -0
  7. package/{lib/components → components}/iqr-form/fields/measureField.d.ts +0 -0
  8. package/{lib/components → components}/iqr-form/fields/measureField.js +0 -0
  9. package/{lib/components → components}/iqr-form/fields/multipleChoice.d.ts +0 -0
  10. package/{lib/components → components}/iqr-form/fields/multipleChoice.js +0 -0
  11. package/{lib/components → components}/iqr-form/fields/numberField.d.ts +0 -0
  12. package/{lib/components → components}/iqr-form/fields/numberField.js +0 -0
  13. package/{lib/components → components}/iqr-form/fields/textfield.d.ts +0 -0
  14. package/{lib/components → components}/iqr-form/fields/textfield.js +0 -0
  15. package/{lib/components → components}/iqr-form/fields/timePicker.d.ts +0 -0
  16. package/{lib/components → components}/iqr-form/fields/timePicker.js +0 -0
  17. package/{lib/components → components}/iqr-form/index.d.ts +0 -0
  18. package/{lib/components → components}/iqr-form/index.js +59 -6
  19. package/{lib/components → components}/iqr-form/model/index.d.ts +0 -0
  20. package/{lib → components}/iqr-form/model/index.js +2 -2
  21. package/{lib/components → components}/iqr-form/renderer/cards.d.ts +0 -0
  22. package/{lib/components → components}/iqr-form/renderer/cards.js +2 -1
  23. package/{lib/components → components}/iqr-form/renderer/form.d.ts +0 -0
  24. package/{lib/components → components}/iqr-form/renderer/form.js +2 -1
  25. package/{lib/components → components}/iqr-form/renderer/index.d.ts +0 -0
  26. package/{lib/components → components}/iqr-form/renderer/index.js +0 -0
  27. package/{lib/components → components}/iqr-text-field/index.d.ts +0 -0
  28. package/{lib/components → components}/iqr-text-field/index.js +751 -7
  29. package/{lib/components → components}/iqr-text-field/plugin/caret-fix-plugin.d.ts +0 -0
  30. package/{lib/components → components}/iqr-text-field/plugin/caret-fix-plugin.js +2 -1
  31. package/{lib/components → components}/iqr-text-field/plugin/has-content-class-plugin.d.ts +0 -0
  32. package/{lib/components → components}/iqr-text-field/plugin/has-content-class-plugin.js +2 -1
  33. package/{lib/components → components}/iqr-text-field/plugin/mask-plugin.d.ts +0 -0
  34. package/{lib/components → components}/iqr-text-field/plugin/mask-plugin.js +2 -1
  35. package/{lib/components → components}/iqr-text-field/plugin/regexp-plugin.d.ts +0 -0
  36. package/{lib/components → components}/iqr-text-field/plugin/regexp-plugin.js +2 -1
  37. package/{lib/components → components}/iqr-text-field/prosemirror-commands.d.ts +0 -0
  38. package/{lib/components → components}/iqr-text-field/prosemirror-commands.js +0 -0
  39. package/{lib/components → components}/iqr-text-field/prosemirror-utils.d.ts +0 -0
  40. package/{lib/components → components}/iqr-text-field/prosemirror-utils.js +0 -0
  41. package/{lib/components → components}/iqr-text-field/schema/common-marks.d.ts +0 -0
  42. package/{lib/components → components}/iqr-text-field/schema/common-marks.js +0 -0
  43. package/{lib/components → components}/iqr-text-field/schema/date-time-schema.d.ts +0 -0
  44. package/{lib/components → components}/iqr-text-field/schema/date-time-schema.js +0 -0
  45. package/{lib/components → components}/iqr-text-field/schema/decimal-schema.d.ts +0 -0
  46. package/{lib/components → components}/iqr-text-field/schema/decimal-schema.js +0 -0
  47. package/{lib/components → components}/iqr-text-field/schema/index.d.ts +0 -0
  48. package/{lib/components → components}/iqr-text-field/schema/index.js +0 -0
  49. package/{lib/components → components}/iqr-text-field/schema/markdown-schema.d.ts +0 -0
  50. package/{lib/components → components}/iqr-text-field/schema/markdown-schema.js +0 -0
  51. package/{lib/components → components}/iqr-text-field/schema/measure-schema.d.ts +0 -0
  52. package/{lib/components → components}/iqr-text-field/schema/measure-schema.js +0 -0
  53. package/{lib/components → components}/iqr-text-field/schema/token-schema.d.ts +0 -0
  54. package/{lib/components → components}/iqr-text-field/schema/token-schema.js +0 -0
  55. package/{lib/components → components}/iqr-text-field/schema/utils.d.ts +0 -0
  56. package/{lib/components → components}/iqr-text-field/schema/utils.js +0 -0
  57. package/{lib/components → components}/iqr-text-field/selection-companion.d.ts +0 -0
  58. package/{lib/components → components}/iqr-text-field/selection-companion.js +0 -0
  59. package/{lib/components → components}/iqr-text-field/suggestion-palette.d.ts +0 -0
  60. package/{lib → components}/iqr-text-field/suggestion-palette.js +5 -5
  61. package/{lib/index.d.ts → index.d.ts} +0 -0
  62. package/{lib/index.js → index.js} +0 -0
  63. package/package.json +14 -47
  64. package/lib/components/iqr-form/model/index.js +0 -114
  65. package/lib/components/iqr-text-field/suggestion-palette.js +0 -139
  66. package/lib/iqr-form/fields/datePicker.d.ts +0 -8
  67. package/lib/iqr-form/fields/datePicker.js +0 -42
  68. package/lib/iqr-form/fields/dateTimePicker.d.ts +0 -8
  69. package/lib/iqr-form/fields/dateTimePicker.js +0 -42
  70. package/lib/iqr-form/fields/measureField.d.ts +0 -8
  71. package/lib/iqr-form/fields/measureField.js +0 -42
  72. package/lib/iqr-form/fields/multipleChoice.d.ts +0 -8
  73. package/lib/iqr-form/fields/multipleChoice.js +0 -42
  74. package/lib/iqr-form/fields/numberField.d.ts +0 -8
  75. package/lib/iqr-form/fields/numberField.js +0 -42
  76. package/lib/iqr-form/fields/textfield.d.ts +0 -1
  77. package/lib/iqr-form/fields/textfield.js +0 -86
  78. package/lib/iqr-form/fields/timePicker.d.ts +0 -8
  79. package/lib/iqr-form/fields/timePicker.js +0 -42
  80. package/lib/iqr-form/index.d.ts +0 -7
  81. package/lib/iqr-form/index.js +0 -83
  82. package/lib/iqr-form/model/index.d.ts +0 -78
  83. package/lib/iqr-form/renderer/cards.d.ts +0 -2
  84. package/lib/iqr-form/renderer/cards.js +0 -43
  85. package/lib/iqr-form/renderer/form.d.ts +0 -2
  86. package/lib/iqr-form/renderer/form.js +0 -44
  87. package/lib/iqr-form/renderer/index.d.ts +0 -3
  88. package/lib/iqr-form/renderer/index.js +0 -2
  89. package/lib/iqr-text-field/index.d.ts +0 -2
  90. package/lib/iqr-text-field/index.js +0 -335
  91. package/lib/iqr-text-field/plugin/caret-fix-plugin.d.ts +0 -2
  92. package/lib/iqr-text-field/plugin/caret-fix-plugin.js +0 -23
  93. package/lib/iqr-text-field/plugin/has-content-class-plugin.d.ts +0 -2
  94. package/lib/iqr-text-field/plugin/has-content-class-plugin.js +0 -18
  95. package/lib/iqr-text-field/plugin/mask-plugin.d.ts +0 -2
  96. package/lib/iqr-text-field/plugin/mask-plugin.js +0 -143
  97. package/lib/iqr-text-field/plugin/regexp-plugin.d.ts +0 -2
  98. package/lib/iqr-text-field/plugin/regexp-plugin.js +0 -46
  99. package/lib/iqr-text-field/prosemirror-commands.d.ts +0 -4
  100. package/lib/iqr-text-field/prosemirror-commands.js +0 -52
  101. package/lib/iqr-text-field/prosemirror-utils.d.ts +0 -5
  102. package/lib/iqr-text-field/prosemirror-utils.js +0 -15
  103. package/lib/iqr-text-field/schema/common-marks.d.ts +0 -10
  104. package/lib/iqr-text-field/schema/common-marks.js +0 -90
  105. package/lib/iqr-text-field/schema/date-time-schema.d.ts +0 -7
  106. package/lib/iqr-text-field/schema/date-time-schema.js +0 -88
  107. package/lib/iqr-text-field/schema/decimal-schema.d.ts +0 -3
  108. package/lib/iqr-text-field/schema/decimal-schema.js +0 -27
  109. package/lib/iqr-text-field/schema/index.d.ts +0 -11
  110. package/lib/iqr-text-field/schema/index.js +0 -18
  111. package/lib/iqr-text-field/schema/markdown-schema.d.ts +0 -8
  112. package/lib/iqr-text-field/schema/markdown-schema.js +0 -139
  113. package/lib/iqr-text-field/schema/measure-schema.d.ts +0 -3
  114. package/lib/iqr-text-field/schema/measure-schema.js +0 -35
  115. package/lib/iqr-text-field/schema/token-schema.d.ts +0 -6
  116. package/lib/iqr-text-field/schema/token-schema.js +0 -36
  117. package/lib/iqr-text-field/schema/utils.d.ts +0 -11
  118. package/lib/iqr-text-field/schema/utils.js +0 -11
  119. package/lib/iqr-text-field/selection-companion.d.ts +0 -11
  120. package/lib/iqr-text-field/selection-companion.js +0 -52
  121. package/lib/iqr-text-field/suggestion-palette.d.ts +0 -33
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.caretFixPlugin = void 0;
4
4
  const prosemirror_state_1 = require("prosemirror-state");
5
- exports.caretFixPlugin = () => {
5
+ const caretFixPlugin = () => {
6
6
  let focusing = false;
7
7
  return new prosemirror_state_1.Plugin({
8
8
  props: {
@@ -21,3 +21,4 @@ exports.caretFixPlugin = () => {
21
21
  }
22
22
  });
23
23
  };
24
+ exports.caretFixPlugin = caretFixPlugin;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.hasContentClassPlugin = void 0;
4
4
  const prosemirror_state_1 = require("prosemirror-state");
5
- exports.hasContentClassPlugin = (root) => {
5
+ const hasContentClassPlugin = (root) => {
6
6
  return new prosemirror_state_1.Plugin({
7
7
  view: (v) => {
8
8
  var _a, _b;
@@ -16,3 +16,4 @@ exports.hasContentClassPlugin = (root) => {
16
16
  }
17
17
  });
18
18
  };
19
+ exports.hasContentClassPlugin = hasContentClassPlugin;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.maskPlugin = void 0;
4
4
  const prosemirror_state_1 = require("prosemirror-state");
5
5
  const prosemirror_view_1 = require("prosemirror-view");
6
- exports.maskPlugin = () => {
6
+ const maskPlugin = () => {
7
7
  const maskText = ($pos, text, mask, tr, setSelection = true) => {
8
8
  const textFromBeginning = $pos.parent.textBetween(0, $pos.parentOffset) + text;
9
9
  const trailingText = $pos.parent.textBetween($pos.parentOffset, $pos.parent.content.size);
@@ -141,3 +141,4 @@ exports.maskPlugin = () => {
141
141
  }
142
142
  });
143
143
  };
144
+ exports.maskPlugin = maskPlugin;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.regexpPlugin = void 0;
4
4
  const prosemirror_state_1 = require("prosemirror-state");
5
- exports.regexpPlugin = () => {
5
+ const regexpPlugin = () => {
6
6
  return new prosemirror_state_1.Plugin({
7
7
  props: {
8
8
  handleTextInput: (view, from, to, text) => {
@@ -44,3 +44,4 @@ exports.regexpPlugin = () => {
44
44
  }
45
45
  });
46
46
  };
47
+ exports.regexpPlugin = regexpPlugin;
@@ -92,7 +92,7 @@ class SuggestionPalette {
92
92
  this.palette.style.display = "none";
93
93
  return;
94
94
  }
95
- const text = state.doc.textBetween($pos.pos ? $pos.before() + 1 : 0, $pos.pos);
95
+ const text = state.doc.textBetween($pos.pos && $pos.depth ? $pos.before() + 1 : 0, $pos.pos);
96
96
  const words = text.split(/\s+/);
97
97
  const terms = words.filter(x => x.length > 2 && !this.suggestionStopWordsProvider().has(x));
98
98
  const lastTerms = terms.length > 3 ? terms.slice(length - 3) : terms;
@@ -109,7 +109,8 @@ class SuggestionPalette {
109
109
  this.palette.innerHTML = `<ul>${res.map(x => `<li id="${x.id}" data-code="${x.code}">${x.text}<div class="icn-container"><svg class="tab-icn" viewBox="0 0 24 24"><path d="M12.29 8.12L15.17 11H2c-.55 0-1 .45-1 1s.45 1 1 1h13.17l-2.88 2.88c-.39.39-.39 1.02 0 1.41.39.39 1.02.39 1.41 0l4.59-4.59c.39-.39.39-1.02 0-1.41L13.7 6.7c-.39-.39-1.02-.39-1.41 0-.38.39-.39 1.03 0 1.42zM20 7v10c0 .55.45 1 1 1s1-.45 1-1V7c0-.55-.45-1-1-1s-1 .45-1 1z"/></svg><svg class="return-icn" viewBox="0 0 24 24"><path d="M19 8v3H5.83l2.88-2.88c.39-.39.39-1.02 0-1.41-.39-.39-1.02-.39-1.41 0L2.71 11.3c-.39.39-.39 1.02 0 1.41L7.3 17.3c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41L5.83 13H20c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1s-1 .45-1 1z"/></svg></div></li>`).join('\n')}</ul>`;
110
110
  // These are in screen coordinates
111
111
  const end = view.coordsAtPos(to);
112
- this.display(end, (this.lastTime = +new Date()));
112
+ const start = view.coordsAtPos(Math.max(0, to - terms[terms.length - 1].length));
113
+ this.display((start.left > end.left) ? end : start, (this.lastTime = +new Date()));
113
114
  }
114
115
  else {
115
116
  this.palette.style.display = "none";
@@ -129,9 +130,8 @@ class SuggestionPalette {
129
130
  const box = (_a = this.palette.offsetParent) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
130
131
  const palBox = this.palette.getBoundingClientRect();
131
132
  if (box) {
132
- const l = (box.left + pos.left);
133
- this.palette.style.left = Math.max(box.left, l - palBox.width) + 'px';
134
- this.palette.style.top = (pos.top + box.top) + "px";
133
+ this.palette.style.left = Math.max(0, Math.min(pos.left - box.left - 12, box.width - palBox.width)) + 'px';
134
+ this.palette.style.top = (pos.bottom - box.top + 2) + "px";
135
135
  }
136
136
  }
137
137
  destroy() { this.palette.remove(); }
File without changes
File without changes
package/package.json CHANGED
@@ -1,60 +1,27 @@
1
1
  {
2
2
  "name": "@icure/form",
3
- "version": "1.0.3",
3
+ "version": "1.0.7",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
- "scripts": {
7
- "start": "webpack-dev-server --env.mode development",
8
- "build": "tsc",
9
- "dist": "webpack --env.mode production",
10
- "test": "echo \"Error: no test specified\" && exit 1"
11
- },
12
- "keywords": [],
13
- "author": "",
14
- "license": "ISC",
6
+ "types": null,
15
7
  "dependencies": {
16
- "@icure/api": "^4.0.8",
17
- "@webcomponents/webcomponentsjs": "^2.4.4",
8
+ "@icure/api": "^4.0.36",
9
+ "@webcomponents/webcomponentsjs": "^2.5.0",
18
10
  "fast-deep-equal": "^3.1.3",
19
- "lit-element": "^2.4.0",
20
- "prosemirror-commands": "^1.1.4",
11
+ "lit-element": "^2.5.0",
12
+ "prosemirror-commands": "^1.1.7",
21
13
  "prosemirror-history": "^1.1.3",
22
14
  "prosemirror-keymap": "^1.1.4",
23
- "prosemirror-markdown": "^1.5.0",
24
- "prosemirror-model": "^1.11.2",
15
+ "prosemirror-markdown": "^1.5.1",
16
+ "prosemirror-model": "^1.14.1",
25
17
  "prosemirror-schema-basic": "^1.1.2",
26
18
  "prosemirror-schema-list": "^1.1.4",
27
19
  "prosemirror-state": "^1.3.4",
28
- "prosemirror-view": "^1.16.0",
29
- "yaml": "^1.10.0"
20
+ "prosemirror-view": "^1.18.4",
21
+ "yaml": "^1.10.2"
30
22
  },
31
- "devDependencies": {
32
- "@types/mocha": "^8.2.0",
33
- "@types/prosemirror-commands": "^1.0.3",
34
- "@types/prosemirror-history": "^1.0.1",
35
- "@types/prosemirror-keymap": "^1.0.3",
36
- "@types/prosemirror-markdown": "^1.0.3",
37
- "@types/prosemirror-schema-basic": "^1.0.1",
38
- "@types/prosemirror-schema-list": "^1.0.1",
39
- "@types/prosemirror-state": "^1.2.6",
40
- "@types/prosemirror-view": "^1.15.1",
41
- "assert": "^2.0.0",
42
- "babel": "^6.23.0",
43
- "babel-preset-es2017": "^6.24.1",
44
- "copy-webpack-plugin": "^6.2.0",
45
- "css-loader": "^5.0.1",
46
- "extract-loader": "^5.1.0",
47
- "html-webpack-plugin": "^4.5.0",
48
- "lit-scss-loader": "^1.0.1",
49
- "minisearch": "^3.0.2",
50
- "mocha": "^8.2.1",
51
- "sass": "^1.32.2",
52
- "sass-loader": "^10.1.1",
53
- "ts-loader": "^8.0.4",
54
- "ts-node": "^9.1.1",
55
- "typescript": "^4.0.3",
56
- "webpack": "^4.44.2",
57
- "webpack-cli": "^3.3.12",
58
- "webpack-dev-server": "^3.11.0"
59
- }
23
+ "author": "",
24
+ "license": "ISC",
25
+ "bugs": null,
26
+ "homepage": null
60
27
  }
@@ -1,114 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Form = exports.Section = exports.Group = exports.MultipleChoice = exports.DateTimePicker = exports.TimePicker = exports.DatePicker = exports.NumberField = exports.MeasureField = exports.TextField = exports.Field = void 0;
4
- class Field {
5
- constructor(type, label, shortLabel, rows, columns, grows, schema, tags, codifications, options) {
6
- this.field = label;
7
- this.type = type;
8
- this.shortLabel = shortLabel;
9
- this.rows = rows;
10
- this.columns = columns;
11
- this.grows = grows;
12
- this.schema = schema;
13
- this.tags = tags;
14
- this.codifications = codifications;
15
- this.options = options;
16
- }
17
- static parse(json) {
18
- switch (json.type) {
19
- case 'textfield':
20
- return new TextField(json.field, json.shortLabel, json.rows, json.grows, json.schema, json.tags, json.codifications, json.options);
21
- case 'measure-field':
22
- return new MeasureField(json.field, json.shortLabel, json.tags, json.codifications, json.options);
23
- case 'number-field':
24
- return new NumberField(json.field, json.shortLabel, json.tags, json.codifications, json.options);
25
- case 'date-picker':
26
- return new DatePicker(json.field, json.shortLabel, json.tags, json.codifications, json.options);
27
- case 'time-picker':
28
- return new TimePicker(json.field, json.shortLabel, json.tags, json.codifications, json.options);
29
- case 'date-time-picker':
30
- return new DateTimePicker(json.field, json.shortLabel, json.tags, json.codifications, json.options);
31
- case 'multiple-choice':
32
- return new MultipleChoice(json.field, json.shortLabel, json.rows, json.columns, json.tags, json.codifications, json.options);
33
- default:
34
- throw Error("Invalid field type " + json.type);
35
- }
36
- }
37
- }
38
- exports.Field = Field;
39
- class TextField extends Field {
40
- constructor(label, shortLabel, rows, grows, schema, tags, codifications, options) {
41
- super('textfield', label, shortLabel, rows, undefined, grows, schema || 'styled-text-with-codes', tags, codifications, options);
42
- }
43
- }
44
- exports.TextField = TextField;
45
- class MeasureField extends Field {
46
- constructor(label, shortLabel, tags, codifications, options) {
47
- super('measure-field', label, shortLabel, undefined, undefined, undefined, undefined, tags, codifications, options);
48
- }
49
- }
50
- exports.MeasureField = MeasureField;
51
- class NumberField extends Field {
52
- constructor(label, shortLabel, tags, codifications, options) {
53
- super('number-field', label, shortLabel, undefined, undefined, undefined, undefined, tags, codifications, options);
54
- }
55
- }
56
- exports.NumberField = NumberField;
57
- class DatePicker extends Field {
58
- constructor(label, shortLabel, tags, codifications, options) {
59
- super('date-picker', label, shortLabel, undefined, undefined, undefined, undefined, tags, codifications, options);
60
- }
61
- }
62
- exports.DatePicker = DatePicker;
63
- class TimePicker extends Field {
64
- constructor(label, shortLabel, tags, codifications, options) {
65
- super('time-picker', label, shortLabel, undefined, undefined, undefined, undefined, tags, codifications, options);
66
- }
67
- }
68
- exports.TimePicker = TimePicker;
69
- class DateTimePicker extends Field {
70
- constructor(label, shortLabel, tags, codifications, options) {
71
- super('date-time-picker', label, shortLabel, undefined, undefined, undefined, undefined, tags, codifications, options);
72
- }
73
- }
74
- exports.DateTimePicker = DateTimePicker;
75
- class MultipleChoice extends Field {
76
- constructor(label, shortLabel, rows, columns, tags, codifications, options) {
77
- super('multiple-choice', label, shortLabel, rows, columns, undefined, undefined, tags, codifications, options);
78
- }
79
- }
80
- exports.MultipleChoice = MultipleChoice;
81
- class Group {
82
- constructor(title, fields) {
83
- this.group = title;
84
- this.fields = fields;
85
- }
86
- static parse(json) {
87
- return new Group(json.group, json.fields.map((s) => s.group ? Group.parse(s) : Field.parse(s)));
88
- }
89
- }
90
- exports.Group = Group;
91
- class Section {
92
- constructor(title, fields, description, keywords) {
93
- this.section = title;
94
- this.fields = fields;
95
- this.description = description;
96
- this.keywords = keywords;
97
- }
98
- static parse(json) {
99
- return new Section(json.section, json.fields.map((s) => s.group ? Group.parse(s) : Field.parse(s)), json.description, json.keywords);
100
- }
101
- }
102
- exports.Section = Section;
103
- class Form {
104
- constructor(title, sections, description, keywords) {
105
- this.form = title;
106
- this.description = description;
107
- this.keywords = keywords;
108
- this.sections = sections;
109
- }
110
- static parse(json) {
111
- return new Form(json.form, json.sections.map((s) => Section.parse(s)), json.description, json.keywords);
112
- }
113
- }
114
- exports.Form = Form;
@@ -1,139 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.SuggestionPalette = void 0;
7
- const fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
8
- class SuggestionPalette {
9
- constructor(view, suggestionProvider, suggestionStopWordsProvider, delay) {
10
- var _a, _b;
11
- this.delay = () => false;
12
- this.lastTime = 0;
13
- this.hasFocus = false;
14
- this.suggestions = [];
15
- this.suggestionStopWordsProvider = suggestionStopWordsProvider;
16
- this.suggestionProvider = suggestionProvider;
17
- this.palette = document.createElement("div");
18
- this.palette.className = "suggestion-palette";
19
- (_b = (_a = view.dom) === null || _a === void 0 ? void 0 : _a.parentNode) === null || _b === void 0 ? void 0 : _b.appendChild(this.palette);
20
- delay && (this.delay = delay);
21
- this.update(view, undefined);
22
- }
23
- focusItem(idx) {
24
- const ul = this.palette.getElementsByTagName('ul')[0];
25
- if (ul) {
26
- ul.classList.add('focused');
27
- const lis = ul.getElementsByTagName('li');
28
- this.currentFocus !== undefined && lis[this.currentFocus].classList.remove('focused');
29
- idx !== undefined && lis[idx].classList.add('focused');
30
- this.currentFocus = idx;
31
- }
32
- }
33
- focus() {
34
- if (this.palette.style.display === "none")
35
- return false;
36
- this.hasFocus = true;
37
- this.focusItem(0);
38
- return true;
39
- }
40
- focusOrInsert(view, transactionProvider) {
41
- if (this.palette.style.display === "none")
42
- return false;
43
- return this.hasFocus ? this.insert(view, transactionProvider) : this.focus();
44
- }
45
- insert(view, transactionProvider) {
46
- if (this.palette.style.display === "none" || !this.hasFocus || this.currentFocus === undefined)
47
- return false;
48
- const sug = this.suggestions[this.currentFocus];
49
- if (sug) {
50
- const sel = view.state.selection;
51
- const stopWords = this.suggestionStopWordsProvider();
52
- let length = sug.terms.join(' ').length - 1;
53
- while (sel.to - length >= 0 && !fast_deep_equal_1.default(view.state.doc.textBetween(sel.to - length, sel.to).split(/\s+/).filter(x => !stopWords.has(x)), sug.terms)) {
54
- length++;
55
- }
56
- if (length > sel.to) {
57
- length = sug.terms.join(' ').length;
58
- while (sel.to - length >= 0 && !view.state.doc.textBetween(sel.to - length, sel.to).startsWith(sug.terms[0])) {
59
- length++;
60
- }
61
- }
62
- if (length <= sel.to) {
63
- transactionProvider(sel.to - length, sel.to, sug).then(tr => tr && view.dispatch(tr.scrollIntoView()));
64
- }
65
- return true;
66
- }
67
- return false;
68
- }
69
- arrowUp() {
70
- if (!this.hasFocus)
71
- return false;
72
- this.currentFocus && this.focusItem(this.currentFocus - 1);
73
- return true;
74
- }
75
- arrowDown() {
76
- if (!this.hasFocus)
77
- return false;
78
- this.currentFocus !== undefined && this.currentFocus < this.palette.getElementsByTagName('ul')[0].childElementCount - 1 && this.focusItem(this.currentFocus + 1);
79
- return true;
80
- }
81
- update(view, lastState) {
82
- let state = view.state;
83
- // Hide the palette if the selection is not empty
84
- this.focusItem(undefined);
85
- this.hasFocus = false;
86
- if (!state.selection.empty) {
87
- this.palette.style.display = "none";
88
- return;
89
- }
90
- let $pos = state.selection.$head;
91
- if ((lastState === null || lastState === void 0 ? void 0 : lastState.doc.textContent) === state.doc.textContent) {
92
- this.palette.style.display = "none";
93
- return;
94
- }
95
- const text = state.doc.textBetween($pos.pos ? $pos.before() + 1 : 0, $pos.pos);
96
- const words = text.split(/\s+/);
97
- const terms = words.filter(x => x.length > 2 && !this.suggestionStopWordsProvider().has(x));
98
- const lastTerms = terms.length > 3 ? terms.slice(length - 3) : terms;
99
- const fingerprint = lastTerms.join(' ');
100
- const { to } = state.selection;
101
- if (this.previousFingerprint !== fingerprint) {
102
- this.previousFingerprint = fingerprint;
103
- setTimeout(() => {
104
- if (this.previousFingerprint !== fingerprint)
105
- return;
106
- const res = this.suggestionProvider(lastTerms);
107
- this.suggestions = res;
108
- if (res.length) {
109
- this.palette.innerHTML = `<ul>${res.map(x => `<li id="${x.id}" data-code="${x.code}">${x.text}<div class="icn-container"><svg class="tab-icn" viewBox="0 0 24 24"><path d="M12.29 8.12L15.17 11H2c-.55 0-1 .45-1 1s.45 1 1 1h13.17l-2.88 2.88c-.39.39-.39 1.02 0 1.41.39.39 1.02.39 1.41 0l4.59-4.59c.39-.39.39-1.02 0-1.41L13.7 6.7c-.39-.39-1.02-.39-1.41 0-.38.39-.39 1.03 0 1.42zM20 7v10c0 .55.45 1 1 1s1-.45 1-1V7c0-.55-.45-1-1-1s-1 .45-1 1z"/></svg><svg class="return-icn" viewBox="0 0 24 24"><path d="M19 8v3H5.83l2.88-2.88c.39-.39.39-1.02 0-1.41-.39-.39-1.02-.39-1.41 0L2.71 11.3c-.39.39-.39 1.02 0 1.41L7.3 17.3c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41L5.83 13H20c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1s-1 .45-1 1z"/></svg></div></li>`).join('\n')}</ul>`;
110
- // These are in screen coordinates
111
- const end = view.coordsAtPos(to);
112
- this.display(end, (this.lastTime = +new Date()));
113
- }
114
- else {
115
- this.palette.style.display = "none";
116
- }
117
- }, 30);
118
- }
119
- }
120
- display(pos, time) {
121
- var _a;
122
- if (time !== this.lastTime)
123
- return;
124
- if (this.delay()) {
125
- setTimeout(() => this.display(pos, time), 100);
126
- return;
127
- }
128
- this.palette.style.display = "";
129
- const box = (_a = this.palette.offsetParent) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
130
- const palBox = this.palette.getBoundingClientRect();
131
- if (box) {
132
- const l = (box.left + pos.left);
133
- this.palette.style.left = Math.max(box.left, l - palBox.width) + 'px';
134
- this.palette.style.top = (pos.top + box.top) + "px";
135
- }
136
- }
137
- destroy() { this.palette.remove(); }
138
- }
139
- exports.SuggestionPalette = SuggestionPalette;
@@ -1,8 +0,0 @@
1
- import { LitElement } from 'lit-element';
2
- import '../../iqr-text-field';
3
- export declare class DatePicker extends LitElement {
4
- label: string;
5
- labelPosition?: string;
6
- static get styles(): import("lit-element").CSSResult[];
7
- render(): import("lit-element").TemplateResult;
8
- }
@@ -1,42 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.DatePicker = void 0;
13
- const lit_element_1 = require("lit-element");
14
- require("../../iqr-text-field");
15
- class DatePicker extends lit_element_1.LitElement {
16
- constructor() {
17
- super(...arguments);
18
- this.label = '';
19
- this.labelPosition = undefined;
20
- }
21
- static get styles() {
22
- return [lit_element_1.css `
23
- :host {
24
- display: block;
25
- }
26
- `];
27
- }
28
- render() {
29
- return lit_element_1.html `
30
- <iqr-text-field labelPosition=${this.labelPosition} label="${this.label}" schema="date" owner="Antoine Duchâteau" style="width: 100%"></iqr-text-field>`;
31
- }
32
- }
33
- __decorate([
34
- lit_element_1.property(),
35
- __metadata("design:type", String)
36
- ], DatePicker.prototype, "label", void 0);
37
- __decorate([
38
- lit_element_1.property(),
39
- __metadata("design:type", String)
40
- ], DatePicker.prototype, "labelPosition", void 0);
41
- exports.DatePicker = DatePicker;
42
- customElements.define('iqr-form-date-picker', DatePicker);
@@ -1,8 +0,0 @@
1
- import { LitElement } from 'lit-element';
2
- import '../../iqr-text-field';
3
- export declare class DateTimePicker extends LitElement {
4
- label: string;
5
- labelPosition?: string;
6
- static get styles(): import("lit-element").CSSResult[];
7
- render(): import("lit-element").TemplateResult;
8
- }
@@ -1,42 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.DateTimePicker = void 0;
13
- const lit_element_1 = require("lit-element");
14
- require("../../iqr-text-field");
15
- class DateTimePicker extends lit_element_1.LitElement {
16
- constructor() {
17
- super(...arguments);
18
- this.label = '';
19
- this.labelPosition = undefined;
20
- }
21
- static get styles() {
22
- return [lit_element_1.css `
23
- :host {
24
- }
25
- `];
26
- }
27
- render() {
28
- return lit_element_1.html `
29
- <iqr-text-field labelPosition=${this.labelPosition} label="${this.label}" schema="date-time"></iqr-text-field>
30
- `;
31
- }
32
- }
33
- __decorate([
34
- lit_element_1.property(),
35
- __metadata("design:type", String)
36
- ], DateTimePicker.prototype, "label", void 0);
37
- __decorate([
38
- lit_element_1.property(),
39
- __metadata("design:type", String)
40
- ], DateTimePicker.prototype, "labelPosition", void 0);
41
- exports.DateTimePicker = DateTimePicker;
42
- customElements.define('iqr-form-date-time-picker', DateTimePicker);
@@ -1,8 +0,0 @@
1
- import { LitElement } from 'lit-element';
2
- import '../../iqr-text-field';
3
- export declare class MeasureField extends LitElement {
4
- label: string;
5
- labelPosition?: string;
6
- static get styles(): import("lit-element").CSSResult[];
7
- render(): import("lit-element").TemplateResult;
8
- }
@@ -1,42 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.MeasureField = void 0;
13
- const lit_element_1 = require("lit-element");
14
- require("../../iqr-text-field");
15
- class MeasureField extends lit_element_1.LitElement {
16
- constructor() {
17
- super(...arguments);
18
- this.label = '';
19
- this.labelPosition = undefined;
20
- }
21
- static get styles() {
22
- return [lit_element_1.css `
23
- :host {
24
- }
25
- `];
26
- }
27
- render() {
28
- return lit_element_1.html `
29
- <iqr-text-field labelPosition=${this.labelPosition} label="${this.label}" schema="measure"></iqr-text-field>
30
- `;
31
- }
32
- }
33
- __decorate([
34
- lit_element_1.property(),
35
- __metadata("design:type", String)
36
- ], MeasureField.prototype, "label", void 0);
37
- __decorate([
38
- lit_element_1.property(),
39
- __metadata("design:type", String)
40
- ], MeasureField.prototype, "labelPosition", void 0);
41
- exports.MeasureField = MeasureField;
42
- customElements.define('iqr-form-measure-field', MeasureField);