@atscript/ui-fns 0.1.96 → 0.1.98

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/dist/plugin.cjs CHANGED
@@ -15,14 +15,32 @@ function validateFnString(fnStr, range) {
15
15
  }];
16
16
  }
17
17
  }
18
+ const FN_MODES = {
19
+ field: {
20
+ nodeType: ["prop", "type"],
21
+ argDoc: "(value, data, context, entry) => result"
22
+ },
23
+ top: {
24
+ nodeType: ["interface", "type"],
25
+ argDoc: "(data, context) => result"
26
+ },
27
+ both: {
28
+ nodeType: [
29
+ "prop",
30
+ "interface",
31
+ "type"
32
+ ],
33
+ argDoc: "(value, data, context, entry) => result on fields; (data, context) => result on the root interface"
34
+ }
35
+ };
18
36
  function makeFnAnnotation(description, mode) {
19
37
  return new _atscript_core.AnnotationSpec({
20
38
  description,
21
- nodeType: mode === "field" ? ["prop", "type"] : ["interface", "type"],
39
+ nodeType: [...FN_MODES[mode].nodeType],
22
40
  argument: {
23
41
  name: "fn",
24
42
  type: "string",
25
- description: mode === "field" ? "JS function string: (value, data, context, entry) => result" : "JS function string: (data, context) => result"
43
+ description: `JS function string: ${FN_MODES[mode].argDoc}`
26
44
  },
27
45
  validate: validateFirstArg
28
46
  });
@@ -33,6 +51,7 @@ function validateFirstArg(_token, args) {
33
51
  }
34
52
  const fnAnnotation = (description) => makeFnAnnotation(description, "field");
35
53
  const fnTopAnnotation = (description) => makeFnAnnotation(description, "top");
54
+ const fnBothAnnotation = (description) => makeFnAnnotation(description, "both");
36
55
  const TABLE_ROW_SCOPE_DOC = "Receives `{ row, ctx }` where `row` is the current row's data object and `ctx` carries table-level context (minimum keys: `searchTerm`, `filters`, `sorters`, `rowIndex`). Per-row+cell scope only — every expression must be meaningful when applied to a single cell.";
37
56
  function tableFnAnnotation(description) {
38
57
  return new _atscript_core.AnnotationSpec({
@@ -109,7 +128,7 @@ const uiFnsAnnotations = { ui: {
109
128
  disabled: fnTopAnnotation("Computed submit disabled state: (data, context) => boolean")
110
129
  },
111
130
  label: fnAnnotation("Computed label: (value, data, context, entry) => string"),
112
- description: fnAnnotation("Computed description: (value, data, context, entry) => string"),
131
+ description: fnBothAnnotation("Computed description: (value, data, context, entry) => string on fields; (data, context) => string on the root interface"),
113
132
  hint: fnAnnotation("Computed hint: (value, data, context, entry) => string"),
114
133
  placeholder: fnAnnotation("Computed placeholder: (value, data, context, entry) => string"),
115
134
  disabled: fnAnnotation("Computed disabled state: (value, data, context, entry) => boolean"),
package/dist/plugin.mjs CHANGED
@@ -15,14 +15,32 @@ function validateFnString(fnStr, range) {
15
15
  }];
16
16
  }
17
17
  }
18
+ const FN_MODES = {
19
+ field: {
20
+ nodeType: ["prop", "type"],
21
+ argDoc: "(value, data, context, entry) => result"
22
+ },
23
+ top: {
24
+ nodeType: ["interface", "type"],
25
+ argDoc: "(data, context) => result"
26
+ },
27
+ both: {
28
+ nodeType: [
29
+ "prop",
30
+ "interface",
31
+ "type"
32
+ ],
33
+ argDoc: "(value, data, context, entry) => result on fields; (data, context) => result on the root interface"
34
+ }
35
+ };
18
36
  function makeFnAnnotation(description, mode) {
19
37
  return new AnnotationSpec({
20
38
  description,
21
- nodeType: mode === "field" ? ["prop", "type"] : ["interface", "type"],
39
+ nodeType: [...FN_MODES[mode].nodeType],
22
40
  argument: {
23
41
  name: "fn",
24
42
  type: "string",
25
- description: mode === "field" ? "JS function string: (value, data, context, entry) => result" : "JS function string: (data, context) => result"
43
+ description: `JS function string: ${FN_MODES[mode].argDoc}`
26
44
  },
27
45
  validate: validateFirstArg
28
46
  });
@@ -33,6 +51,7 @@ function validateFirstArg(_token, args) {
33
51
  }
34
52
  const fnAnnotation = (description) => makeFnAnnotation(description, "field");
35
53
  const fnTopAnnotation = (description) => makeFnAnnotation(description, "top");
54
+ const fnBothAnnotation = (description) => makeFnAnnotation(description, "both");
36
55
  const TABLE_ROW_SCOPE_DOC = "Receives `{ row, ctx }` where `row` is the current row's data object and `ctx` carries table-level context (minimum keys: `searchTerm`, `filters`, `sorters`, `rowIndex`). Per-row+cell scope only — every expression must be meaningful when applied to a single cell.";
37
56
  function tableFnAnnotation(description) {
38
57
  return new AnnotationSpec({
@@ -109,7 +128,7 @@ const uiFnsAnnotations = { ui: {
109
128
  disabled: fnTopAnnotation("Computed submit disabled state: (data, context) => boolean")
110
129
  },
111
130
  label: fnAnnotation("Computed label: (value, data, context, entry) => string"),
112
- description: fnAnnotation("Computed description: (value, data, context, entry) => string"),
131
+ description: fnBothAnnotation("Computed description: (value, data, context, entry) => string on fields; (data, context) => string on the root interface"),
113
132
  hint: fnAnnotation("Computed hint: (value, data, context, entry) => string"),
114
133
  placeholder: fnAnnotation("Computed placeholder: (value, data, context, entry) => string"),
115
134
  disabled: fnAnnotation("Computed disabled state: (value, data, context, entry) => boolean"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atscript/ui-fns",
3
- "version": "0.1.96",
3
+ "version": "0.1.98",
4
4
  "description": "Dynamic fn-compiled field properties for @atscript/ui (opt-in, uses new Function)",
5
5
  "keywords": [
6
6
  "annotations",
@@ -27,6 +27,7 @@
27
27
  "dist"
28
28
  ],
29
29
  "type": "module",
30
+ "sideEffects": false,
30
31
  "main": "dist/index.mjs",
31
32
  "types": "dist/index.d.mts",
32
33
  "exports": {
@@ -47,16 +48,16 @@
47
48
  },
48
49
  "dependencies": {
49
50
  "@prostojs/deserialize-fn": "^0.0.5",
50
- "@atscript/ui": "^0.1.96"
51
+ "@atscript/ui": "^0.1.98"
51
52
  },
52
53
  "devDependencies": {
53
- "@atscript/core": "^0.1.74",
54
- "@atscript/typescript": "^0.1.74",
54
+ "@atscript/core": "^0.1.75",
55
+ "@atscript/typescript": "^0.1.75",
55
56
  "vitest": "npm:@voidzero-dev/vite-plus-test@0.1.14"
56
57
  },
57
58
  "peerDependencies": {
58
- "@atscript/core": "^0.1.74",
59
- "@atscript/typescript": "^0.1.74"
59
+ "@atscript/core": "^0.1.75",
60
+ "@atscript/typescript": "^0.1.75"
60
61
  },
61
62
  "scripts": {
62
63
  "build": "vp pack",