@icure/form 1.0.1 → 1.0.2

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 (69) hide show
  1. package/lib/components/index.d.ts +2 -0
  2. package/lib/components/index.js +14 -0
  3. package/lib/components/iqr-form/fields/datePicker.d.ts +8 -0
  4. package/lib/components/iqr-form/fields/datePicker.js +42 -0
  5. package/lib/components/iqr-form/fields/dateTimePicker.d.ts +8 -0
  6. package/lib/components/iqr-form/fields/dateTimePicker.js +42 -0
  7. package/lib/components/iqr-form/fields/measureField.d.ts +8 -0
  8. package/lib/components/iqr-form/fields/measureField.js +42 -0
  9. package/lib/components/iqr-form/fields/multipleChoice.d.ts +8 -0
  10. package/lib/components/iqr-form/fields/multipleChoice.js +42 -0
  11. package/lib/components/iqr-form/fields/numberField.d.ts +8 -0
  12. package/lib/components/iqr-form/fields/numberField.js +42 -0
  13. package/lib/components/iqr-form/fields/textfield.d.ts +1 -0
  14. package/lib/components/iqr-form/fields/textfield.js +86 -0
  15. package/lib/components/iqr-form/fields/timePicker.d.ts +8 -0
  16. package/lib/components/iqr-form/fields/timePicker.js +42 -0
  17. package/lib/components/iqr-form/index.d.ts +7 -0
  18. package/lib/components/iqr-form/index.js +83 -0
  19. package/lib/components/iqr-form/model/index.d.ts +78 -0
  20. package/lib/components/iqr-form/model/index.js +114 -0
  21. package/lib/components/iqr-form/renderer/cards.d.ts +2 -0
  22. package/lib/components/iqr-form/renderer/cards.js +43 -0
  23. package/lib/components/iqr-form/renderer/form.d.ts +2 -0
  24. package/lib/components/iqr-form/renderer/form.js +44 -0
  25. package/lib/components/iqr-form/renderer/index.d.ts +3 -0
  26. package/lib/components/iqr-form/renderer/index.js +2 -0
  27. package/lib/components/iqr-text-field/index.d.ts +2 -0
  28. package/lib/components/iqr-text-field/index.js +335 -0
  29. package/lib/components/iqr-text-field/plugin/caret-fix-plugin.d.ts +2 -0
  30. package/lib/components/iqr-text-field/plugin/caret-fix-plugin.js +23 -0
  31. package/lib/components/iqr-text-field/plugin/has-content-class-plugin.d.ts +2 -0
  32. package/lib/components/iqr-text-field/plugin/has-content-class-plugin.js +18 -0
  33. package/lib/components/iqr-text-field/plugin/mask-plugin.d.ts +2 -0
  34. package/lib/components/iqr-text-field/plugin/mask-plugin.js +143 -0
  35. package/lib/components/iqr-text-field/plugin/regexp-plugin.d.ts +2 -0
  36. package/lib/components/iqr-text-field/plugin/regexp-plugin.js +46 -0
  37. package/lib/components/iqr-text-field/prosemirror-commands.d.ts +4 -0
  38. package/lib/components/iqr-text-field/prosemirror-commands.js +52 -0
  39. package/lib/components/iqr-text-field/prosemirror-utils.d.ts +5 -0
  40. package/lib/components/iqr-text-field/prosemirror-utils.js +15 -0
  41. package/lib/components/iqr-text-field/schema/common-marks.d.ts +10 -0
  42. package/lib/components/iqr-text-field/schema/common-marks.js +90 -0
  43. package/lib/components/iqr-text-field/schema/date-time-schema.d.ts +7 -0
  44. package/lib/components/iqr-text-field/schema/date-time-schema.js +88 -0
  45. package/lib/components/iqr-text-field/schema/decimal-schema.d.ts +3 -0
  46. package/lib/components/iqr-text-field/schema/decimal-schema.js +27 -0
  47. package/lib/components/iqr-text-field/schema/index.d.ts +11 -0
  48. package/lib/components/iqr-text-field/schema/index.js +18 -0
  49. package/lib/components/iqr-text-field/schema/markdown-schema.d.ts +8 -0
  50. package/lib/components/iqr-text-field/schema/markdown-schema.js +139 -0
  51. package/lib/components/iqr-text-field/schema/measure-schema.d.ts +3 -0
  52. package/lib/components/iqr-text-field/schema/measure-schema.js +35 -0
  53. package/lib/components/iqr-text-field/schema/token-schema.d.ts +6 -0
  54. package/lib/components/iqr-text-field/schema/token-schema.js +36 -0
  55. package/lib/components/iqr-text-field/schema/utils.d.ts +11 -0
  56. package/lib/components/iqr-text-field/schema/utils.js +11 -0
  57. package/lib/components/iqr-text-field/selection-companion.d.ts +11 -0
  58. package/lib/components/iqr-text-field/selection-companion.js +52 -0
  59. package/lib/components/iqr-text-field/suggestion-palette.d.ts +33 -0
  60. package/lib/components/iqr-text-field/suggestion-palette.js +139 -0
  61. package/lib/index.d.ts +1 -2
  62. package/lib/index.js +1 -2
  63. package/package.json +1 -1
  64. package/.editorconfig +0 -12
  65. package/.mocharc.json +0 -5
  66. package/app/demo-app.ts +0 -191
  67. package/test/form.yaml +0 -96
  68. package/test/simple/test.spec.ts +0 -303
  69. package/webpack.config.js +0 -41
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getMarkdownSpec = void 0;
4
+ const utils_1 = require("./utils");
5
+ const common_marks_1 = require("./common-marks");
6
+ function getMarkdownSpec(type, contentProvider, colorProvider) {
7
+ const nodesSelector = (key, spec) => {
8
+ // noinspection RedundantConditionalExpressionJS
9
+ return (key === 'paragraph') ? true :
10
+ ((spec.group === 'block' || ['doc', 'list_item', 'hard_break', 'image'].includes(key)) && type !== 'text-document') ? false : true;
11
+ };
12
+ const marksSelector = (key) => {
13
+ // noinspection RedundantConditionalExpressionJS
14
+ return (key !== 'link' && ['text-document', 'styled-text', 'styled-text-with-codes'].includes(type)) ? true :
15
+ (key === 'link' && ['text-document', 'text-with-codes', 'styled-text-with-codes']) ? true : false;
16
+ };
17
+ return {
18
+ topNode: type === 'text-document' ? 'doc' : 'paragraph',
19
+ nodes: utils_1.reduceNodes({
20
+ doc: {
21
+ content: 'block+'
22
+ },
23
+ paragraph: {
24
+ content: 'inline*',
25
+ group: 'block',
26
+ parseDOM: [{ tag: 'p' }],
27
+ toDOM() {
28
+ return ['p', 0];
29
+ }
30
+ },
31
+ blockquote: {
32
+ content: 'block+',
33
+ group: 'block',
34
+ parseDOM: [{ tag: 'blockquote' }],
35
+ toDOM() {
36
+ return ['blockquote', 0];
37
+ }
38
+ },
39
+ horizontal_rule: {
40
+ group: 'block',
41
+ parseDOM: [{ tag: 'hr' }],
42
+ toDOM() {
43
+ return ['div', ['hr']];
44
+ }
45
+ },
46
+ heading: {
47
+ attrs: { level: { default: 1 } },
48
+ content: '(text | image)*',
49
+ group: 'block',
50
+ defining: true,
51
+ parseDOM: [{ tag: 'h1', attrs: { level: 1 } },
52
+ { tag: 'h2', attrs: { level: 2 } },
53
+ { tag: 'h3', attrs: { level: 3 } },
54
+ { tag: 'h4', attrs: { level: 4 } },
55
+ { tag: 'h5', attrs: { level: 5 } },
56
+ { tag: 'h6', attrs: { level: 6 } }],
57
+ toDOM(node) {
58
+ return ['h' + node.attrs.level, 0];
59
+ }
60
+ },
61
+ ordered_list: {
62
+ content: 'list_item+',
63
+ group: 'block',
64
+ attrs: { order: { default: 1 }, tight: { default: false } },
65
+ parseDOM: [{
66
+ tag: 'ol',
67
+ getAttrs(dom) {
68
+ const el = dom;
69
+ return {
70
+ order: el.hasAttribute('start') ? +(el.getAttribute('start') || 0) : 1,
71
+ tight: el.hasAttribute('data-tight')
72
+ };
73
+ }
74
+ }],
75
+ toDOM(node) {
76
+ return ['ol', {
77
+ start: node.attrs.order === 1 ? null : node.attrs.order,
78
+ 'data-tight': node.attrs.tight ? 'true' : null
79
+ }, 0];
80
+ }
81
+ },
82
+ bullet_list: {
83
+ content: 'list_item+',
84
+ group: 'block',
85
+ attrs: { tight: { default: false } },
86
+ parseDOM: [{ tag: 'ul', getAttrs: dom => ({ tight: dom.hasAttribute('data-tight') }) }],
87
+ toDOM(node) {
88
+ return ['ul', { 'data-tight': node.attrs.tight ? 'true' : null }, 0];
89
+ }
90
+ },
91
+ list_item: {
92
+ content: 'paragraph block*',
93
+ defining: true,
94
+ parseDOM: [{ tag: 'li' }],
95
+ toDOM() {
96
+ return ['li', 0];
97
+ }
98
+ },
99
+ text: {
100
+ group: 'inline'
101
+ },
102
+ image: {
103
+ inline: true,
104
+ attrs: {
105
+ src: {},
106
+ alt: { default: null },
107
+ title: { default: null }
108
+ },
109
+ group: 'inline',
110
+ draggable: true,
111
+ parseDOM: [{
112
+ tag: 'img[src]',
113
+ getAttrs(dom) {
114
+ const el = dom;
115
+ return {
116
+ src: el.getAttribute('src'),
117
+ title: el.getAttribute('title'),
118
+ alt: el.getAttribute('alt')
119
+ };
120
+ }
121
+ }],
122
+ toDOM(node) {
123
+ return ['img', node.attrs];
124
+ }
125
+ },
126
+ hard_break: {
127
+ inline: true,
128
+ group: 'inline',
129
+ selectable: false,
130
+ parseDOM: [{ tag: 'br' }],
131
+ toDOM() {
132
+ return ['br'];
133
+ }
134
+ }
135
+ }, nodesSelector),
136
+ marks: utils_1.reduceMarks(common_marks_1.getMarks(contentProvider, colorProvider), marksSelector)
137
+ };
138
+ }
139
+ exports.getMarkdownSpec = getMarkdownSpec;
@@ -0,0 +1,3 @@
1
+ import { SchemaSpec } from 'prosemirror-model';
2
+ export declare type MeasureSchema = 'measure';
3
+ export declare function getMeasureSpec(): SchemaSpec;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getMeasureSpec = void 0;
4
+ function getMeasureSpec() {
5
+ return {
6
+ topNode: 'paragraph',
7
+ nodes: {
8
+ paragraph: {
9
+ content: 'decimal unit',
10
+ },
11
+ decimal: {
12
+ content: 'inline*',
13
+ group: 'block',
14
+ parseDOM: [{ tag: 'span' }],
15
+ toDOM() {
16
+ return ['span', { class: 'measure' }, 0];
17
+ },
18
+ regexp: '[,.0-9-]'
19
+ },
20
+ unit: {
21
+ content: 'inline*',
22
+ group: 'block',
23
+ parseDOM: [{ tag: 'span' }],
24
+ toDOM() {
25
+ return ['span', { class: 'unit' }, 0];
26
+ }
27
+ },
28
+ text: {
29
+ group: 'inline'
30
+ }
31
+ },
32
+ marks: {}
33
+ };
34
+ }
35
+ exports.getMeasureSpec = getMeasureSpec;
@@ -0,0 +1,6 @@
1
+ import { SchemaSpec } from 'prosemirror-model';
2
+ export declare type TokensSchema = 'tokens-list' | 'styled-tokens-list' | 'tokens-list-with-codes' | 'styled-tokens-list-with-codes';
3
+ export declare function getTokensSpec(type: TokensSchema, contentProvider: (codes: {
4
+ type: string;
5
+ code: string;
6
+ }[]) => string, colorProvider: (type: string, code: string, isCode: boolean) => string): SchemaSpec;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getTokensSpec = void 0;
4
+ const utils_1 = require("./utils");
5
+ const common_marks_1 = require("./common-marks");
6
+ function getTokensSpec(type, contentProvider, colorProvider) {
7
+ const marksSelector = (key) => {
8
+ // noinspection RedundantConditionalExpressionJS
9
+ return (key !== 'link' && ['styled-tokens-list', 'styled-tokens-list-with-codes'].includes(type)) ? true :
10
+ (key === 'link' && ['tokens-list-with-codes', 'styled-text-with-codes']) ? true : false;
11
+ };
12
+ return {
13
+ nodes: utils_1.reduceNodes({
14
+ doc: {
15
+ content: 'token+',
16
+ parseDOM: [{ tag: 'ul' }],
17
+ toDOM() {
18
+ return ['ul', 0];
19
+ }
20
+ },
21
+ token: {
22
+ content: 'inline*',
23
+ group: 'block',
24
+ parseDOM: [{ tag: 'li' }],
25
+ toDOM() {
26
+ return ['li', 0];
27
+ }
28
+ },
29
+ text: {
30
+ group: 'inline'
31
+ }
32
+ }),
33
+ marks: utils_1.reduceMarks(common_marks_1.getMarks(contentProvider, colorProvider), marksSelector)
34
+ };
35
+ }
36
+ exports.getTokensSpec = getTokensSpec;
@@ -0,0 +1,11 @@
1
+ import { MarkSpec, NodeSpec } from "prosemirror-model";
2
+ export declare function reduceNodes(nodes: {
3
+ [key: string]: NodeSpec;
4
+ }, selector?: (key: string, spec: NodeSpec) => boolean): {
5
+ [key: string]: NodeSpec;
6
+ };
7
+ export declare function reduceMarks(marks: {
8
+ [key: string]: MarkSpec;
9
+ }, selector?: (key: string, spec: MarkSpec) => boolean): {
10
+ [key: string]: MarkSpec;
11
+ };
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.reduceMarks = exports.reduceNodes = void 0;
4
+ function reduceNodes(nodes, selector = () => true) {
5
+ return Object.keys(nodes).reduce((r, k) => selector(k, nodes[k]) ? Object.assign(r, { [k]: nodes[k] }) : r, {});
6
+ }
7
+ exports.reduceNodes = reduceNodes;
8
+ function reduceMarks(marks, selector = () => true) {
9
+ return Object.keys(marks).reduce((r, k) => selector(k, marks[k]) ? Object.assign(r, { [k]: marks[k] }) : r, {});
10
+ }
11
+ exports.reduceMarks = reduceMarks;
@@ -0,0 +1,11 @@
1
+ import { EditorView } from "prosemirror-view";
2
+ import { EditorState } from "prosemirror-state";
3
+ export declare class SelectionCompanion {
4
+ private readonly companion;
5
+ private delay;
6
+ private lastTime;
7
+ constructor(view: EditorView, delay: () => boolean);
8
+ update(view: EditorView, lastState?: EditorState): void;
9
+ private display;
10
+ destroy(): void;
11
+ }
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SelectionCompanion = void 0;
4
+ class SelectionCompanion {
5
+ constructor(view, delay) {
6
+ var _a, _b;
7
+ this.delay = () => false;
8
+ this.lastTime = 0;
9
+ this.companion = document.createElement("div");
10
+ this.companion.className = "companion";
11
+ (_b = (_a = view.dom) === null || _a === void 0 ? void 0 : _a.parentNode) === null || _b === void 0 ? void 0 : _b.appendChild(this.companion);
12
+ this.delay = delay;
13
+ this.update(view, undefined);
14
+ }
15
+ update(view, lastState) {
16
+ let state = view.state;
17
+ // Don't do anything if the document/selection didn't change
18
+ if (lastState && lastState.doc.eq(state.doc) &&
19
+ lastState.selection.eq(state.selection)) {
20
+ return;
21
+ }
22
+ // Hide the companion if the selection is empty
23
+ if (state.selection.empty) {
24
+ this.companion.style.display = "none";
25
+ return;
26
+ }
27
+ // Otherwise, reposition it and update its content
28
+ const { to } = state.selection;
29
+ // These are in screen coordinates
30
+ const end = view.coordsAtPos(to);
31
+ this.display(end, (this.lastTime = +new Date()));
32
+ }
33
+ display(pos, time) {
34
+ var _a;
35
+ if (time !== this.lastTime)
36
+ return;
37
+ if (this.delay()) {
38
+ setTimeout(() => this.display(pos, time), 100);
39
+ return;
40
+ }
41
+ this.companion.style.display = "";
42
+ const box = (_a = this.companion.offsetParent) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
43
+ if (box) {
44
+ this.companion.style.left = pos.right + "px";
45
+ this.companion.style.top = (pos.top + box.top - 20) + "px";
46
+ this.companion.style.height = (pos.bottom - pos.top) + "px";
47
+ this.companion.textContent = "+";
48
+ }
49
+ }
50
+ destroy() { this.companion.remove(); }
51
+ }
52
+ exports.SelectionCompanion = SelectionCompanion;
@@ -0,0 +1,33 @@
1
+ import { EditorView } from "prosemirror-view";
2
+ import { EditorState, Transaction } from "prosemirror-state";
3
+ export declare class SuggestionPalette {
4
+ private readonly palette;
5
+ private delay;
6
+ private lastTime;
7
+ private suggestionProvider;
8
+ private previousFingerprint?;
9
+ private suggestionStopWordsProvider;
10
+ private currentFocus?;
11
+ private hasFocus;
12
+ private suggestions;
13
+ constructor(view: EditorView, suggestionProvider: (terms: string[]) => any[], suggestionStopWordsProvider: () => Set<string>, delay?: () => boolean);
14
+ focusItem(idx?: number): void;
15
+ focus(): boolean;
16
+ focusOrInsert(view: EditorView, transactionProvider: (from: number, to: number, sug: {
17
+ id: string;
18
+ code: string;
19
+ text: string;
20
+ terms: string[];
21
+ }) => Promise<Transaction | undefined>): boolean;
22
+ insert(view: EditorView, transactionProvider: (from: number, to: number, sug: {
23
+ id: string;
24
+ code: string;
25
+ text: string;
26
+ terms: string[];
27
+ }) => Promise<Transaction | undefined>): boolean;
28
+ arrowUp(): boolean;
29
+ arrowDown(): boolean;
30
+ update(view: EditorView, lastState?: EditorState): void;
31
+ private display;
32
+ destroy(): void;
33
+ }
@@ -0,0 +1,139 @@
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;
package/lib/index.d.ts CHANGED
@@ -1,2 +1 @@
1
- export * from './iqr-form';
2
- export * from './iqr-text-field';
1
+ export * from './components';
package/lib/index.js CHANGED
@@ -10,5 +10,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./iqr-form"), exports);
14
- __exportStar(require("./iqr-text-field"), exports);
13
+ __exportStar(require("./components"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icure/form",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
package/.editorconfig DELETED
@@ -1,12 +0,0 @@
1
- # EditorConfig is awesome: https://EditorConfig.org
2
-
3
- # top-most EditorConfig file
4
- root = true
5
-
6
- # Unix-style newlines with a newline ending every file
7
- [*]
8
- end_of_line = lf
9
- insert_final_newline = true
10
- indent_style = tab
11
- indent_size = 2
12
-
package/.mocharc.json DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "extension": ["ts"],
3
- "spec": "test/**/*.spec.ts",
4
- "require": "ts-node/register"
5
- }