@projectcaluma/ember-form-builder 14.5.0 → 14.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,82 @@
1
+ # ![ember-caluma](https://user-images.githubusercontent.com/6150577/137114875-8b9edb83-92ba-4b3a-ba6e-2e5f86afdcc5.png)
2
+
3
+ [![Test](https://github.com/projectcaluma/ember-caluma/workflows/Test/badge.svg)](https://github.com/projectcaluma/ember-caluma/actions?query=workflow%3ATest)
4
+ [![BrowserStack Status](https://automate.browserstack.com/badge.svg?badge_key=RFNMT2hyTnRjNVZkUitkWUl2d3BWK21KbnU3MU1tTGpHS2tOVHVCU1RrZz0tLXJjZ1J5VEZ6ZmtJWVpFdHpDRnREcFE9PQ==--3034affde596526379b7a0a19798a7ba1f79154c)](https://automate.browserstack.com/public-build/RFNMT2hyTnRjNVZkUitkWUl2d3BWK21KbnU3MU1tTGpHS2tOVHVCU1RrZz0tLXJjZ1J5VEZ6ZmtJWVpFdHpDRnREcFE9PQ==--3034affde596526379b7a0a19798a7ba1f79154c)
5
+ [![Codecov](https://codecov.io/gh/projectcaluma/ember-caluma/branch/main/graph/badge.svg)](https://codecov.io/gh/projectcaluma/ember-caluma)
6
+ [![Code Style: Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
7
+ [![License: LGPL-3.0](https://img.shields.io/badge/License-LGPL--3.0-blue.svg)](https://spdx.org/licenses/LGPL-3.0-or-later.html)
8
+
9
+ The Ember.js addons for [Caluma](https://caluma.io) - a collaborative form editing service.
10
+
11
+ ## Browser support
12
+
13
+ | ![Edge](https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png) | ![Firefox](https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png) | ![Chrome](https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png) | ![Safari](https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari-ios/safari-ios_48x48.png) |
14
+ | :-------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------: |
15
+ | last 2 versions | last 2 versions | last 2 versions | last 2 versions |
16
+
17
+ ## Compatibility
18
+
19
+ `@projectcaluma/ember-*` packages are guaranteed to work with the following LTS versions of Ember.js:
20
+
21
+ - 5.4
22
+ - 4.12
23
+
24
+ ## Documentation
25
+
26
+ You can find the interactive documentation [here](https://docs.caluma.io/ember-caluma).
27
+
28
+ ## Contributing
29
+
30
+ ### Installation
31
+
32
+ - `git clone git@github.com:projectcaluma/ember-caluma`
33
+ - `cd ember-caluma`
34
+ - `pnpm install`
35
+
36
+ ### Linting
37
+
38
+ - `pnpm lint`
39
+
40
+ ### Running tests
41
+
42
+ - `pnpm --filter @projectcaluma/ember-[package] exec ember test` – Runs the test suite on the current Ember version
43
+ - `pnpm --filter @projectcaluma/ember-[package] exec ember test --server` – Runs the test suite in "watch mode"
44
+ - `pnpm --filter @projectcaluma/ember-[package] exec ember try:each` – Runs the test suite against multiple Ember versions
45
+
46
+ Cross-browser testing provided by:
47
+
48
+ <a href="https://browserstack.com"><img alt="BrowserStack" src="https://user-images.githubusercontent.com/6150577/69328224-24f1d680-0c4f-11ea-8b02-5670334923a3.png" height="50"></a>
49
+
50
+ ### Running the dummy application
51
+
52
+ #### With a mocked [Mirage.js](https://github.com/miragejs/ember-cli-mirage) backend
53
+
54
+ - `pnpm start`
55
+ - Visit the dummy application at [http://localhost:4200](http://localhost:4200).
56
+
57
+ #### With a dockerized [Caluma](https://github.com/projectcaluma/caluma) backend
58
+
59
+ - `docker compose up -d`
60
+ - `pnpm start-proxy`
61
+ - Visit the dummy application at [http://localhost:4200](http://localhost:4200).
62
+
63
+ ### Updating the schema
64
+
65
+ The addon includes a mirage server for mocking Caluma's GraphQL API, which is generated from the GraphQL schema definition. If the upstream GraphQL schema changed you can update the addon by running
66
+
67
+ ```bash
68
+ docker compose up -d
69
+ pnpm update-schema
70
+ pnpm update-possible-types
71
+ ```
72
+
73
+ ### Releasing
74
+
75
+ To release a new version, head over to [Actions](https://github.com/projectcaluma/ember-caluma/actions?query=workflow%3ARelease) and trigger a workflow run.
76
+ This will automatically check if a new version can be released, generate a changelog, draft a release and publish it on NPM.
77
+
78
+ ## License
79
+
80
+ This project is licensed under the [LGPL-3.0-or-later license](LICENSE).
81
+
82
+ For further information on our license choice, you can read up on the [corresponding GitHub issue](https://github.com/projectcaluma/ember-caluma/issues/613).
@@ -11,7 +11,7 @@
11
11
  {{did-insert this.didInsertNode}}
12
12
  {{will-destroy this.willDestroyNode}}
13
13
  {{autoresize mode="height"}}
14
- {{on "blur" this.onBlur}}
14
+ {{on "blur" @setDirty}}
15
15
  ></div>
16
16
  </div>
17
17
 
@@ -2,6 +2,7 @@ import { action } from "@ember/object";
2
2
  import { addObserver } from "@ember/object/observers";
3
3
  import Component from "@glimmer/component";
4
4
  import { CodeJar } from "codejar";
5
+ import { task, timeout } from "ember-concurrency";
5
6
  import hljs from "highlight.js/lib/core";
6
7
  import json from "highlight.js/lib/languages/json";
7
8
  import markdown from "highlight.js/lib/languages/markdown";
@@ -15,22 +16,34 @@ hljs.registerLanguage("json", json);
15
16
  hljs.registerLanguage("markdown", markdown);
16
17
  hljs.registerLanguage("jexl", jexl);
17
18
 
19
+ const simplify = (value) => {
20
+ if (typeof value === "object") {
21
+ value = JSON.stringify(value?.unwrap?.() ?? value);
22
+ }
23
+
24
+ return value?.replace(/\s/g, "");
25
+ };
26
+
18
27
  export default class CfbCodeEditorComponent extends Component {
19
28
  _editor = null;
20
- _lastValue = this.args.value;
29
+ _lastValue = null;
21
30
 
22
31
  get stringValue() {
23
32
  if (this.args.language === "json" && typeof this.args.value === "object") {
24
33
  return JSON.stringify(
25
34
  this.args.value?.unwrap?.() ?? this.args.value,
26
35
  null,
27
- 2,
36
+ "\t",
28
37
  );
29
38
  }
30
39
 
31
40
  return this.args.value;
32
41
  }
33
42
 
43
+ _didChange(value) {
44
+ return !isEqual(this._lastValue, simplify(value));
45
+ }
46
+
34
47
  @action
35
48
  onUpdate(value) {
36
49
  if (this.args.language === "json") {
@@ -41,24 +54,22 @@ export default class CfbCodeEditorComponent extends Component {
41
54
  }
42
55
  }
43
56
 
44
- if (isEqual(this._lastValue, value)) return;
57
+ if (!this._didChange(value)) return;
45
58
 
46
- this._lastValue = value;
59
+ this._lastValue = simplify(value);
47
60
  this.args.update(value);
48
61
  }
49
62
 
50
- @action
51
- updateCode() {
52
- if (isEqual(this._lastValue, this.args.value)) return;
63
+ updateEditorContent = task({ restartable: true }, async () => {
64
+ // This function is called everytime `this.args.value` changes. In order to
65
+ // not trigger too many updates, we debounce it for 10ms.
66
+ await timeout(10);
53
67
 
54
- this._editor.updateCode(this.stringValue, false);
55
- }
68
+ if (!this._didChange(this.args.value)) return;
56
69
 
57
- @action
58
- onBlur() {
59
- this._editor.updateCode(this.stringValue);
60
- this.args.setDirty();
61
- }
70
+ this._lastValue = simplify(this.args.value);
71
+ this._editor.updateCode(this.stringValue, false);
72
+ });
62
73
 
63
74
  @action
64
75
  didInsertNode(element) {
@@ -68,13 +79,14 @@ export default class CfbCodeEditorComponent extends Component {
68
79
  });
69
80
 
70
81
  // set initial value
71
- this._editor.updateCode(this.stringValue);
82
+ this._editor.updateCode(this.stringValue, false);
83
+ this._lastValue = simplify(this.args.value);
72
84
 
73
85
  // register update method
74
86
  this._editor.onUpdate(this.onUpdate);
75
87
 
76
88
  // eslint-disable-next-line ember/no-observers
77
- addObserver(this.args, "value", this, "updateCode");
89
+ addObserver(this.args, "value", this.updateEditorContent, "perform");
78
90
  }
79
91
 
80
92
  @action
@@ -12,7 +12,6 @@ module.exports = {
12
12
  */
13
13
  return this.addAddonsToProject({
14
14
  packages: [
15
- { name: "@ember/legacy-built-in-components" },
16
15
  { name: "@projectcaluma/ember-core" },
17
16
  { name: "@projectcaluma/ember-form" },
18
17
  { name: "ember-changeset" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@projectcaluma/ember-form-builder",
3
- "version": "14.5.0",
3
+ "version": "14.6.0",
4
4
  "description": "Ember engine for building Caluma forms.",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -11,14 +11,11 @@
11
11
  "repository": "github:projectcaluma/ember-caluma",
12
12
  "dependencies": {
13
13
  "@babel/core": "^7.26.0",
14
- "@ember/legacy-built-in-components": "^0.5.0",
15
14
  "@ember/render-modifiers": "^2.1.0 || ^3.0.0",
16
15
  "@ember/string": "^3.1.1 || ^4.0.0",
17
16
  "@embroider/macros": "^1.16.10",
18
- "@glimmer/component": "^1.1.2",
19
- "@glimmer/tracking": "^1.1.2",
20
- "codejar": "^4.2.0",
21
- "ember-apollo-client": "~4.0.2",
17
+ "codejar": "^4.3.0",
18
+ "ember-apollo-client": "^5.0.0",
22
19
  "ember-auto-import": "^2.10.0",
23
20
  "ember-basic-dropdown": "^8.4.0",
24
21
  "ember-changeset": "^4.1.2",
@@ -28,7 +25,6 @@
28
25
  "ember-composable-helpers": "^5.0.0",
29
26
  "ember-concurrency": "^4.0.2",
30
27
  "ember-engines-router-service": "^0.6.0",
31
- "ember-fetch": "^8.1.2",
32
28
  "ember-flatpickr": "^8.0.1",
33
29
  "ember-intl": "^7.1.1",
34
30
  "ember-load-initializers": "^2.1.2 || ^3.0.1",
@@ -48,8 +44,8 @@
48
44
  "lodash.isequal": "^4.5.0",
49
45
  "reactiveweb": "^1.3.0",
50
46
  "uikit": "^3.22.0",
51
- "@projectcaluma/ember-core": "^14.5.0",
52
- "@projectcaluma/ember-form": "^14.5.0"
47
+ "@projectcaluma/ember-core": "^14.6.0",
48
+ "@projectcaluma/ember-form": "^14.6.0"
53
49
  },
54
50
  "//": [
55
51
  "TODO: remove obsolete dependency to `ember-data` which is only necessary",
@@ -62,6 +58,8 @@
62
58
  "@ember/test-helpers": "4.0.4",
63
59
  "@embroider/test-setup": "4.0.0",
64
60
  "@faker-js/faker": "10.0.0",
61
+ "@glimmer/component": "1.1.2",
62
+ "@glimmer/tracking": "1.1.2",
65
63
  "broccoli-asset-rev": "3.0.0",
66
64
  "ember-autoresize-modifier": "0.8.0",
67
65
  "ember-cli": "6.1.0",
@@ -85,7 +83,7 @@
85
83
  "qunit-dom": "3.5.0",
86
84
  "sinon": "21.0.0",
87
85
  "webpack": "5.101.3",
88
- "@projectcaluma/ember-testing": "14.5.0"
86
+ "@projectcaluma/ember-testing": "14.6.0"
89
87
  },
90
88
  "peerDependencies": {
91
89
  "ember-engines": "^0.11.0",