@capillarytech/blaze-ui 5.4.1 → 5.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/CapAskAira/index.js +312 -341
- package/CapAskAira/index.js.map +1 -1
- package/CapExpressionEditor/README.md +32 -0
- package/CapExpressionEditor/index.d.ts +1654 -0
- package/CapExpressionEditor/index.d.ts.map +1 -0
- package/CapExpressionEditor/index.js +312 -349
- package/CapExpressionEditor/index.js.map +1 -1
- package/CapExpressionEditor/js/fixGrammar.d.ts +3 -0
- package/CapExpressionEditor/js/fixGrammar.d.ts.map +1 -0
- package/CapExpressionEditor/js/grammar.d.ts +1628 -0
- package/CapExpressionEditor/js/grammar.d.ts.map +1 -0
- package/CapExpressionEditor/types.d.ts +18 -0
- package/CapExpressionEditor/types.d.ts.map +1 -0
- package/CapLevelGraphRenderer/index.js +130 -127
- package/CapLevelGraphRenderer/index.js.map +1 -1
- package/index.d.ts +2 -2
- package/index.d.ts.map +1 -1
- package/index.js +4352 -1108
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/.npmrc +0 -2
- package/CapLevelGraphRenderer/CapLevelGraphRenderer-test-cases.md +0 -50
- package/CapLevelGraphRenderer/README.md +0 -123
- package/CapLevelGraphRenderer/Tooltip.d.ts +0 -24
- package/CapLevelGraphRenderer/Tooltip.d.ts.map +0 -1
- package/CapLevelGraphRenderer/Tooltip_MIGRATION_ANALYSIS.md +0 -120
- package/CapLevelGraphRenderer/index.d.ts +0 -16
- package/CapLevelGraphRenderer/index.d.ts.map +0 -1
- package/CapLevelGraphRenderer/types.d.ts +0 -151
- package/CapLevelGraphRenderer/types.d.ts.map +0 -1
|
@@ -2477,6 +2477,7 @@ var _default = exports["default"] = (0, _ComponentWithLabelHOC.default)(CapInput
|
|
|
2477
2477
|
exports.__esModule = true;
|
|
2478
2478
|
exports["default"] = void 0;
|
|
2479
2479
|
/* eslint-disable */
|
|
2480
|
+
// @ts-nocheck - Legacy grammar fix utility; types would require extensive interface definitions
|
|
2480
2481
|
/*
|
|
2481
2482
|
Please use this fix function.
|
|
2482
2483
|
|
|
@@ -2563,7 +2564,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
2563
2564
|
/* eslint-disable */
|
|
2564
2565
|
|
|
2565
2566
|
_jquery.default.fn.expredit = function (grammar, options) {
|
|
2566
|
-
|
|
2567
|
+
'use strict';
|
|
2567
2568
|
|
|
2568
2569
|
//pickers.js
|
|
2569
2570
|
var pickers = {};
|
|
@@ -2575,7 +2576,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
2575
2576
|
|
|
2576
2577
|
function makeRegex(str, atBegin, atEnd) {
|
|
2577
2578
|
try {
|
|
2578
|
-
return new RegExp((atBegin ?
|
|
2579
|
+
return new RegExp((atBegin ? '^' : '') + str.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&') + (atEnd ? '$' : ''), 'i');
|
|
2579
2580
|
} catch (e) {
|
|
2580
2581
|
return null;
|
|
2581
2582
|
}
|
|
@@ -2599,21 +2600,21 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
2599
2600
|
};
|
|
2600
2601
|
//
|
|
2601
2602
|
//pickers.datetime = function(value, type, setValue, onKey) {
|
|
2602
|
-
//
|
|
2603
|
+
//
|
|
2603
2604
|
// return getCalender();;//$("<div>").addClass("info").html("Date picker will come here.");
|
|
2604
2605
|
//},
|
|
2605
2606
|
|
|
2606
2607
|
pickers.interval = function (value, type, setValue, onKey) {
|
|
2607
|
-
return (0, _jquery.default)(
|
|
2608
|
+
return (0, _jquery.default)('<div>').addClass('info').html('Time interval picker will come here.');
|
|
2608
2609
|
}, pickers.enumset = function (value, type, setValue, onKey) {
|
|
2609
2610
|
var list = pickers.enum(value, type.valueType);
|
|
2610
|
-
return (0, _jquery.default)(
|
|
2611
|
+
return (0, _jquery.default)('<div>').addClass('info').html('Multiselect box with options ' + node.getType(type.valueType).values.join(', '));
|
|
2611
2612
|
},
|
|
2612
2613
|
// ----- Calltips from the current scope -----
|
|
2613
2614
|
|
|
2614
2615
|
pickers.any = function (node, sort) {
|
|
2615
2616
|
// This populates calltips.
|
|
2616
|
-
if (typeof sort ===
|
|
2617
|
+
if (typeof sort === 'undefined') sort = false;
|
|
2617
2618
|
var r = [],
|
|
2618
2619
|
calltipDiv,
|
|
2619
2620
|
scope = node.scope,
|
|
@@ -2624,7 +2625,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
2624
2625
|
m,
|
|
2625
2626
|
t,
|
|
2626
2627
|
root,
|
|
2627
|
-
prefix =
|
|
2628
|
+
prefix = '';
|
|
2628
2629
|
|
|
2629
2630
|
// turn the name into a regex for matching.
|
|
2630
2631
|
try {
|
|
@@ -2652,7 +2653,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
2652
2653
|
// return calltipDiv;
|
|
2653
2654
|
// }
|
|
2654
2655
|
}
|
|
2655
|
-
prefix +=
|
|
2656
|
+
prefix += 'outer.';
|
|
2656
2657
|
scope = scope.outer;
|
|
2657
2658
|
}
|
|
2658
2659
|
return r.length && (r.length > 1 || node.text != r[0]) ? calltipDiv : false;
|
|
@@ -2664,7 +2665,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
2664
2665
|
// Aravind R S, Capillary Technologies, 2012-02-09
|
|
2665
2666
|
|
|
2666
2667
|
var tokenize = function (str) {
|
|
2667
|
-
|
|
2668
|
+
'use strict';
|
|
2668
2669
|
|
|
2669
2670
|
var rex = {
|
|
2670
2671
|
space: /^\s+/,
|
|
@@ -2678,31 +2679,31 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
2678
2679
|
tok,
|
|
2679
2680
|
pos = 0,
|
|
2680
2681
|
r;
|
|
2681
|
-
while (str !=
|
|
2682
|
+
while (str != '') {
|
|
2682
2683
|
tok = null;
|
|
2683
2684
|
for (r in rex) {
|
|
2684
2685
|
str = str.replace(rex[r], function (m) {
|
|
2685
2686
|
var len = m.length,
|
|
2686
2687
|
val;
|
|
2687
|
-
if (r ==
|
|
2688
|
+
if (r == 'space') {
|
|
2688
2689
|
pos += len;
|
|
2689
|
-
return
|
|
2690
|
-
} else if (r ==
|
|
2690
|
+
return '';
|
|
2691
|
+
} else if (r == 'number') {
|
|
2691
2692
|
val = parseFloat(m);
|
|
2692
|
-
} else if (r ==
|
|
2693
|
+
} else if (r == 'date') {
|
|
2693
2694
|
val = new Date(m.substring(2, m.length - 2));
|
|
2694
|
-
} else if (r ==
|
|
2695
|
-
case
|
|
2695
|
+
} else if (r == 'name') switch (m) {
|
|
2696
|
+
case 'true':
|
|
2696
2697
|
val = true;
|
|
2697
|
-
r =
|
|
2698
|
+
r = 'boolean';
|
|
2698
2699
|
break;
|
|
2699
|
-
case
|
|
2700
|
+
case 'false':
|
|
2700
2701
|
val = false;
|
|
2701
|
-
r =
|
|
2702
|
+
r = 'boolean';
|
|
2702
2703
|
break;
|
|
2703
2704
|
default:
|
|
2704
2705
|
val = m;
|
|
2705
|
-
} else if (r ==
|
|
2706
|
+
} else if (r == 'string') {
|
|
2706
2707
|
val = m.substr(1, len - 2);
|
|
2707
2708
|
} else {
|
|
2708
2709
|
val = m;
|
|
@@ -2715,7 +2716,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
2715
2716
|
len: len
|
|
2716
2717
|
};
|
|
2717
2718
|
pos += len;
|
|
2718
|
-
return
|
|
2719
|
+
return '';
|
|
2719
2720
|
});
|
|
2720
2721
|
if (tok) break;
|
|
2721
2722
|
}
|
|
@@ -2736,13 +2737,13 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
2736
2737
|
|
|
2737
2738
|
var protonode = {};
|
|
2738
2739
|
var parse = function () {
|
|
2739
|
-
|
|
2740
|
+
'use strict';
|
|
2740
2741
|
|
|
2741
2742
|
var symbol_table = {},
|
|
2742
2743
|
token,
|
|
2743
2744
|
tokens,
|
|
2744
2745
|
token_nr,
|
|
2745
|
-
terminators = [
|
|
2746
|
+
terminators = ['(end)'],
|
|
2746
2747
|
has_errors;
|
|
2747
2748
|
var itself = function () {
|
|
2748
2749
|
return this;
|
|
@@ -2756,7 +2757,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
2756
2757
|
e = "Expected '" + id + "'";
|
|
2757
2758
|
}
|
|
2758
2759
|
if (token_nr >= tokens.length) {
|
|
2759
|
-
token = symbol_table[
|
|
2760
|
+
token = symbol_table['(end)'];
|
|
2760
2761
|
t = tokens[tokens.length - 1];
|
|
2761
2762
|
token.pos = t ? t.pos + t.len : 0;
|
|
2762
2763
|
token.len = 0;
|
|
@@ -2766,30 +2767,30 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
2766
2767
|
token_nr += 1;
|
|
2767
2768
|
v = t.value;
|
|
2768
2769
|
a = t.arity;
|
|
2769
|
-
if (a ===
|
|
2770
|
-
o = symbol_table[
|
|
2771
|
-
} else if (a ===
|
|
2770
|
+
if (a === 'name') {
|
|
2771
|
+
o = symbol_table['(name)'];
|
|
2772
|
+
} else if (a === 'operator') {
|
|
2772
2773
|
o = symbol_table[v];
|
|
2773
2774
|
if (!o) {
|
|
2774
|
-
e =
|
|
2775
|
+
e = 'Unknown operator.';
|
|
2775
2776
|
}
|
|
2776
|
-
} else if (a ===
|
|
2777
|
-
o = symbol_table[
|
|
2777
|
+
} else if (a === 'string' || a === 'number' || a === 'boolean' || a === 'datetime') {
|
|
2778
|
+
o = symbol_table['(literal)'];
|
|
2778
2779
|
type = a;
|
|
2779
|
-
a =
|
|
2780
|
+
a = 'literal';
|
|
2780
2781
|
} else {
|
|
2781
|
-
e =
|
|
2782
|
+
e = 'Unexpected token.';
|
|
2782
2783
|
}
|
|
2783
2784
|
if (o) {
|
|
2784
2785
|
token = Object.create(o);
|
|
2785
2786
|
} else {
|
|
2786
2787
|
token = missing();
|
|
2787
|
-
a =
|
|
2788
|
+
a = 'missing';
|
|
2788
2789
|
}
|
|
2789
2790
|
token.value = v;
|
|
2790
2791
|
token.arity = a;
|
|
2791
2792
|
token.type = type;
|
|
2792
|
-
token.text = t.text ||
|
|
2793
|
+
token.text = t.text || '';
|
|
2793
2794
|
token.pos = t.pos;
|
|
2794
2795
|
token.len = t.len;
|
|
2795
2796
|
if (e) {
|
|
@@ -2817,14 +2818,14 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
2817
2818
|
return left;
|
|
2818
2819
|
};
|
|
2819
2820
|
protonode.nud = function () {
|
|
2820
|
-
this.arity =
|
|
2821
|
-
this.error(
|
|
2821
|
+
this.arity = 'missing';
|
|
2822
|
+
this.error('Unknown operator.');
|
|
2822
2823
|
return this;
|
|
2823
2824
|
};
|
|
2824
2825
|
protonode.led = function (left) {
|
|
2825
2826
|
var n = missing();
|
|
2826
|
-
this.arity =
|
|
2827
|
-
this.error(
|
|
2827
|
+
this.arity = 'group';
|
|
2828
|
+
this.error('Unknown operator.');
|
|
2828
2829
|
n.children = [left, this];
|
|
2829
2830
|
return n;
|
|
2830
2831
|
};
|
|
@@ -2846,7 +2847,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
2846
2847
|
var group = function (e) {
|
|
2847
2848
|
var g = Object.create(protonode);
|
|
2848
2849
|
g.value = undefined;
|
|
2849
|
-
g.arity =
|
|
2850
|
+
g.arity = 'group';
|
|
2850
2851
|
g.children = [];
|
|
2851
2852
|
if (e) g.error(e);
|
|
2852
2853
|
return g;
|
|
@@ -2854,18 +2855,18 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
2854
2855
|
var missing = function (e) {
|
|
2855
2856
|
var m = Object.create(protonode);
|
|
2856
2857
|
m.value = undefined;
|
|
2857
|
-
m.arity =
|
|
2858
|
+
m.arity = 'missing';
|
|
2858
2859
|
if (e) {
|
|
2859
2860
|
m.error(e);
|
|
2860
2861
|
} else if (e !== false) {
|
|
2861
|
-
m.error(
|
|
2862
|
+
m.error('Missing value.');
|
|
2862
2863
|
}
|
|
2863
2864
|
return m;
|
|
2864
2865
|
};
|
|
2865
2866
|
var pos_missing = function (node, pos) {
|
|
2866
|
-
if (node.arity !==
|
|
2867
|
-
if (typeof node.pos ===
|
|
2868
|
-
if (typeof node.len ===
|
|
2867
|
+
if (node.arity !== 'missing') return node;
|
|
2868
|
+
if (typeof node.pos === 'undefined') node.pos = pos;
|
|
2869
|
+
if (typeof node.len === 'undefined') node.len = node.text ? node.text.length : 1;
|
|
2869
2870
|
return node;
|
|
2870
2871
|
};
|
|
2871
2872
|
var infix = function (id, bp, led) {
|
|
@@ -2874,7 +2875,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
2874
2875
|
this.children = [left, expression(bp)];
|
|
2875
2876
|
pos_missing(this.children[0], this.pos);
|
|
2876
2877
|
pos_missing(this.children[1], this.pos + this.len);
|
|
2877
|
-
this.arity =
|
|
2878
|
+
this.arity = 'binary_operation';
|
|
2878
2879
|
return this;
|
|
2879
2880
|
};
|
|
2880
2881
|
return s;
|
|
@@ -2885,7 +2886,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
2885
2886
|
this.children = [left, expression(bp - 1)];
|
|
2886
2887
|
pos_missing(this.children[0], this.pos);
|
|
2887
2888
|
pos_missing(this.children[1], this.pos + this.len);
|
|
2888
|
-
this.arity =
|
|
2889
|
+
this.arity = 'binary_operation';
|
|
2889
2890
|
return this;
|
|
2890
2891
|
};
|
|
2891
2892
|
return s;
|
|
@@ -2895,61 +2896,61 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
2895
2896
|
s.nud = nud || function () {
|
|
2896
2897
|
this.children = [expression(70)];
|
|
2897
2898
|
pos_missing(this.children[0], this.pos + this.len);
|
|
2898
|
-
this.arity =
|
|
2899
|
+
this.arity = 'unary_operation';
|
|
2899
2900
|
return this;
|
|
2900
2901
|
};
|
|
2901
2902
|
return s;
|
|
2902
2903
|
};
|
|
2903
|
-
symbol(
|
|
2904
|
-
symbol(
|
|
2905
|
-
symbol(
|
|
2904
|
+
symbol('(end)').nud = nothing;
|
|
2905
|
+
symbol('(name)').nud = itself;
|
|
2906
|
+
symbol(')');
|
|
2906
2907
|
// symbol("]");
|
|
2907
|
-
symbol(
|
|
2908
|
-
symbol(
|
|
2909
|
-
symbol(
|
|
2910
|
-
infix(
|
|
2908
|
+
symbol(':');
|
|
2909
|
+
symbol(',');
|
|
2910
|
+
symbol('(literal)').nud = itself;
|
|
2911
|
+
infix('?', 20, function (left) {
|
|
2911
2912
|
var s_tok;
|
|
2912
2913
|
this.children = [left];
|
|
2913
2914
|
pos_missing(this.children[0], this.pos);
|
|
2914
|
-
terminators.push(
|
|
2915
|
+
terminators.push(':');
|
|
2915
2916
|
this.children[1] = expression(0);
|
|
2916
2917
|
pos_missing(this.children[1], this.pos + this.len);
|
|
2917
2918
|
s_tok = token;
|
|
2918
|
-
if (terminators[terminators.length - 1] ==
|
|
2919
|
-
advance(
|
|
2919
|
+
if (terminators[terminators.length - 1] == ':') terminators.pop();
|
|
2920
|
+
advance(':');
|
|
2920
2921
|
this.children[2] = expression(0);
|
|
2921
2922
|
pos_missing(this.children[2], s_tok.pos + s_tok.len);
|
|
2922
|
-
this.arity =
|
|
2923
|
+
this.arity = 'ternary_operation';
|
|
2923
2924
|
return this;
|
|
2924
2925
|
});
|
|
2925
|
-
infixr(
|
|
2926
|
-
infixr(
|
|
2927
|
-
infixr(
|
|
2928
|
-
infixr(
|
|
2929
|
-
infixr(
|
|
2930
|
-
infixr(
|
|
2931
|
-
infixr(
|
|
2932
|
-
infixr(
|
|
2933
|
-
infix(
|
|
2934
|
-
infix(
|
|
2935
|
-
infix(
|
|
2936
|
-
infix(
|
|
2937
|
-
infix(
|
|
2938
|
-
infix(
|
|
2926
|
+
infixr('&&', 30);
|
|
2927
|
+
infixr('||', 30);
|
|
2928
|
+
infixr('==', 40);
|
|
2929
|
+
infixr('!=', 40);
|
|
2930
|
+
infixr('<', 40);
|
|
2931
|
+
infixr('<=', 40);
|
|
2932
|
+
infixr('>', 40);
|
|
2933
|
+
infixr('>=', 40);
|
|
2934
|
+
infix('+', 50);
|
|
2935
|
+
infix('-', 50);
|
|
2936
|
+
infix('*', 60);
|
|
2937
|
+
infix('/', 60);
|
|
2938
|
+
infix('%', 60);
|
|
2939
|
+
infix('.', 80, function (left) {
|
|
2939
2940
|
var n;
|
|
2940
2941
|
this.children = [left];
|
|
2941
|
-
this.arity =
|
|
2942
|
+
this.arity = 'object_dereference';
|
|
2942
2943
|
this.value = undefined;
|
|
2943
|
-
if (token.arity ===
|
|
2944
|
+
if (token.arity === 'name') {
|
|
2944
2945
|
this.children[1] = token;
|
|
2945
2946
|
advance();
|
|
2946
|
-
} else if (token.id ===
|
|
2947
|
-
token.arity =
|
|
2948
|
-
token.error(
|
|
2947
|
+
} else if (token.id === '(literal)') {
|
|
2948
|
+
token.arity = 'missing';
|
|
2949
|
+
token.error('Expected a property name.');
|
|
2949
2950
|
this.children[1] = token;
|
|
2950
2951
|
advance();
|
|
2951
2952
|
} else {
|
|
2952
|
-
this.children[1] = missing(
|
|
2953
|
+
this.children[1] = missing('Expected a property name.');
|
|
2953
2954
|
}
|
|
2954
2955
|
pos_missing(this.children[0], this.pos);
|
|
2955
2956
|
pos_missing(this.children[1], this.pos + this.len);
|
|
@@ -2957,59 +2958,56 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
2957
2958
|
});
|
|
2958
2959
|
|
|
2959
2960
|
/* infix("[", 80, function (left) {
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
});*/
|
|
2990
|
-
|
|
2991
|
-
infix("(", 80, function (left) {
|
|
2961
|
+
var g, n, e;
|
|
2962
|
+
if(left.id === "(literal)") {
|
|
2963
|
+
left.error("Expected a collection.");
|
|
2964
|
+
}
|
|
2965
|
+
terminators.push("]");
|
|
2966
|
+
this.children = [left];
|
|
2967
|
+
pos_missing(this.children[0], this.pos);
|
|
2968
|
+
n = expression(0);
|
|
2969
|
+
e = [n];
|
|
2970
|
+
while(token.id !== "]" && token.id !== "(end)") {
|
|
2971
|
+
e.push(expression(0));
|
|
2972
|
+
}
|
|
2973
|
+
if(e.length > 1) {
|
|
2974
|
+
g = group();
|
|
2975
|
+
g.paren = false;
|
|
2976
|
+
g.children = e;
|
|
2977
|
+
this.children.push(g);
|
|
2978
|
+
} else {
|
|
2979
|
+
this.children.push(n);
|
|
2980
|
+
}
|
|
2981
|
+
pos_missing(this.children[1], this.pos + this.len);
|
|
2982
|
+
this.arity = "array_lookup";
|
|
2983
|
+
this.value = undefined;
|
|
2984
|
+
if(terminators[terminators.length-1]=="]") terminators.pop();
|
|
2985
|
+
advance("]");
|
|
2986
|
+
return this;
|
|
2987
|
+
});*/
|
|
2988
|
+
|
|
2989
|
+
infix('(', 80, function (left) {
|
|
2992
2990
|
var g, n, e;
|
|
2993
|
-
if (left.arity ===
|
|
2994
|
-
this.arity =
|
|
2991
|
+
if (left.arity === 'object_dereference') {
|
|
2992
|
+
this.arity = 'method_call';
|
|
2995
2993
|
this.value = undefined;
|
|
2996
2994
|
this.children = left.children;
|
|
2997
|
-
if (left.children[1].arity !==
|
|
2998
|
-
left.children[1].error(
|
|
2995
|
+
if (left.children[1].arity !== 'name') {
|
|
2996
|
+
left.children[1].error('Expected a method name.');
|
|
2999
2997
|
}
|
|
3000
2998
|
} else {
|
|
3001
|
-
this.arity =
|
|
2999
|
+
this.arity = 'function_call';
|
|
3002
3000
|
this.value = undefined;
|
|
3003
3001
|
this.children = [left];
|
|
3004
|
-
if (left.arity !==
|
|
3005
|
-
left.error(
|
|
3002
|
+
if (left.arity !== 'name') {
|
|
3003
|
+
left.error('Expected a function name.');
|
|
3006
3004
|
}
|
|
3007
3005
|
}
|
|
3008
|
-
terminators.push(
|
|
3006
|
+
terminators.push(')');
|
|
3009
3007
|
n = missing(false);
|
|
3010
3008
|
pos_missing(n, token.pos);
|
|
3011
|
-
while (token.id !==
|
|
3012
|
-
if (token.id ===
|
|
3009
|
+
while (token.id !== ')' && token.id !== '(end)') {
|
|
3010
|
+
if (token.id === ',') {
|
|
3013
3011
|
n = missing();
|
|
3014
3012
|
} else {
|
|
3015
3013
|
n = expression(0);
|
|
@@ -3018,7 +3016,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3018
3016
|
e = [n];
|
|
3019
3017
|
|
|
3020
3018
|
// Gather any malformed tokens from here to the next ) or ,
|
|
3021
|
-
while (token.id !==
|
|
3019
|
+
while (token.id !== ',' && token.id !== ')' && token.id !== '(end)') {
|
|
3022
3020
|
e.push(expression(0));
|
|
3023
3021
|
}
|
|
3024
3022
|
if (e.length > 1) {
|
|
@@ -3030,35 +3028,35 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3030
3028
|
this.children.push(n);
|
|
3031
3029
|
}
|
|
3032
3030
|
n = null;
|
|
3033
|
-
if (token.id ===
|
|
3031
|
+
if (token.id === ',') {
|
|
3034
3032
|
n = missing();
|
|
3035
3033
|
pos_missing(n, token.pos + token.len);
|
|
3036
|
-
advance(
|
|
3034
|
+
advance(',');
|
|
3037
3035
|
}
|
|
3038
3036
|
}
|
|
3039
3037
|
if (n) {
|
|
3040
3038
|
this.children.push(n);
|
|
3041
3039
|
}
|
|
3042
|
-
if (terminators[terminators.length - 1] ==
|
|
3043
|
-
advance(
|
|
3040
|
+
if (terminators[terminators.length - 1] == ')') terminators.pop();
|
|
3041
|
+
advance(')');
|
|
3044
3042
|
return this;
|
|
3045
3043
|
});
|
|
3046
|
-
prefix(
|
|
3047
|
-
prefix(
|
|
3048
|
-
prefix(
|
|
3049
|
-
prefix(
|
|
3044
|
+
prefix('!');
|
|
3045
|
+
prefix('-');
|
|
3046
|
+
prefix('+');
|
|
3047
|
+
prefix('(', function () {
|
|
3050
3048
|
var e;
|
|
3051
|
-
this.arity =
|
|
3049
|
+
this.arity = 'group';
|
|
3052
3050
|
this.value = undefined;
|
|
3053
|
-
this.text =
|
|
3051
|
+
this.text = '';
|
|
3054
3052
|
this.children = [];
|
|
3055
|
-
terminators.push(
|
|
3056
|
-
if (token.id ===
|
|
3053
|
+
terminators.push(')');
|
|
3054
|
+
if (token.id === ')' || token.id === '(end)') {
|
|
3057
3055
|
e = missing();
|
|
3058
3056
|
pos_missing(e, token.pos);
|
|
3059
3057
|
this.children.push(e);
|
|
3060
3058
|
} else {
|
|
3061
|
-
while (token.id !==
|
|
3059
|
+
while (token.id !== ')' && token.id !== '(end)') {
|
|
3062
3060
|
e = expression(0);
|
|
3063
3061
|
pos_missing(e, token.pos);
|
|
3064
3062
|
if (this.children.length > 0) {
|
|
@@ -3067,8 +3065,8 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3067
3065
|
this.children.push(e);
|
|
3068
3066
|
}
|
|
3069
3067
|
}
|
|
3070
|
-
if (terminators[terminators.length - 1] ==
|
|
3071
|
-
advance(
|
|
3068
|
+
if (terminators[terminators.length - 1] == ')') terminators.pop();
|
|
3069
|
+
advance(')');
|
|
3072
3070
|
return this;
|
|
3073
3071
|
});
|
|
3074
3072
|
protonode.error = function (e) {
|
|
@@ -3087,15 +3085,15 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3087
3085
|
token_nr = 0;
|
|
3088
3086
|
advance();
|
|
3089
3087
|
do {
|
|
3090
|
-
terminators = [
|
|
3088
|
+
terminators = ['(end)'];
|
|
3091
3089
|
tree = expression(0);
|
|
3092
|
-
if (token.id !==
|
|
3093
|
-
token.error(
|
|
3090
|
+
if (token.id !== '(end)') {
|
|
3091
|
+
token.error('Expected an operator.');
|
|
3094
3092
|
}
|
|
3095
|
-
if (!(tree.arity ==
|
|
3093
|
+
if (!(tree.arity == 'missing' && (tree.value == ')' || tree.value == ']'))) {
|
|
3096
3094
|
trees.push(tree);
|
|
3097
3095
|
}
|
|
3098
|
-
} while (token.id !==
|
|
3096
|
+
} while (token.id !== '(end)');
|
|
3099
3097
|
if (trees.length == 1) {
|
|
3100
3098
|
tree = trees[0];
|
|
3101
3099
|
} else {
|
|
@@ -3114,7 +3112,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3114
3112
|
*/
|
|
3115
3113
|
protonode.crosslink = function (parent) {
|
|
3116
3114
|
var i, l, subtree;
|
|
3117
|
-
if (this.arity ===
|
|
3115
|
+
if (this.arity === 'group' && this.children && this.children.length === 1) {
|
|
3118
3116
|
this.operands = this.children;
|
|
3119
3117
|
return this.children[0].crosslink(parent);
|
|
3120
3118
|
}
|
|
@@ -3135,7 +3133,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3135
3133
|
// this is the prototype of the primitive types
|
|
3136
3134
|
|
|
3137
3135
|
var primitive = {
|
|
3138
|
-
ancestry:
|
|
3136
|
+
ancestry: 'primitive',
|
|
3139
3137
|
prepared: true,
|
|
3140
3138
|
//Adding isStrict to match the exact type and not any super type.(Author:Susi)
|
|
3141
3139
|
is: function (type, isStrict) {
|
|
@@ -3145,9 +3143,9 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3145
3143
|
if (type.ancestry && !/\banonymous\b/.test(type.ancestry)) {
|
|
3146
3144
|
type = type.ancestry;
|
|
3147
3145
|
}
|
|
3148
|
-
if (typeof type ===
|
|
3146
|
+
if (typeof type === 'string') {
|
|
3149
3147
|
if (this.ancestry) {
|
|
3150
|
-
if (isStrict === true) return this.ancestry === type;else return new RegExp(
|
|
3148
|
+
if (isStrict === true) return this.ancestry === type;else return new RegExp('\\b' + type + '\\b').test(this.ancestry);
|
|
3151
3149
|
} else {
|
|
3152
3150
|
return false;
|
|
3153
3151
|
}
|
|
@@ -3161,9 +3159,9 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3161
3159
|
|
|
3162
3160
|
var traverse = function (root, path) {
|
|
3163
3161
|
var res;
|
|
3164
|
-
path = path.replace(/\$/g,
|
|
3162
|
+
path = path.replace(/\$/g, 'this');
|
|
3165
3163
|
try {
|
|
3166
|
-
res = new Function(
|
|
3164
|
+
res = new Function('return ' + path).call(root);
|
|
3167
3165
|
} catch (e) {}
|
|
3168
3166
|
return res;
|
|
3169
3167
|
};
|
|
@@ -3189,7 +3187,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3189
3187
|
if (currentScope && currentScope.idents) {
|
|
3190
3188
|
scope.idents.outer = {
|
|
3191
3189
|
type: this.getType({
|
|
3192
|
-
form:
|
|
3190
|
+
form: 'object',
|
|
3193
3191
|
memberScope: currentScope,
|
|
3194
3192
|
members: currentScope.idents
|
|
3195
3193
|
})
|
|
@@ -3253,12 +3251,12 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3253
3251
|
};
|
|
3254
3252
|
protonode.getType = function (p) {
|
|
3255
3253
|
var type, t, typeName, i, pp, inherit, scope;
|
|
3256
|
-
if (p ===
|
|
3254
|
+
if (p === 'any') {
|
|
3257
3255
|
return primitive;
|
|
3258
3256
|
}
|
|
3259
|
-
if (typeof p ===
|
|
3260
|
-
if (typeof p ===
|
|
3261
|
-
if (p.indexOf(
|
|
3257
|
+
if (typeof p === 'undefined') p = this.type;
|
|
3258
|
+
if (typeof p === 'string') {
|
|
3259
|
+
if (p.indexOf('$') === -1) {
|
|
3262
3260
|
type = grammar.types[p];
|
|
3263
3261
|
if (!type) {
|
|
3264
3262
|
if (type !== false) {
|
|
@@ -3276,12 +3274,12 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3276
3274
|
}
|
|
3277
3275
|
if (pp) {
|
|
3278
3276
|
type = this.getType(pp);
|
|
3279
|
-
typeName =
|
|
3277
|
+
typeName = 'anonymous';
|
|
3280
3278
|
}
|
|
3281
3279
|
}
|
|
3282
3280
|
} else {
|
|
3283
3281
|
type = p;
|
|
3284
|
-
typeName =
|
|
3282
|
+
typeName = 'anonymous';
|
|
3285
3283
|
}
|
|
3286
3284
|
if (!type) {
|
|
3287
3285
|
return null;
|
|
@@ -3296,7 +3294,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3296
3294
|
var i,
|
|
3297
3295
|
newObj = Object.create(oldObj);
|
|
3298
3296
|
for (i in props) {
|
|
3299
|
-
if (typeof oldObj[i] ===
|
|
3297
|
+
if (typeof oldObj[i] === 'object' && typeof props[i] === 'object' && oldObj[i] !== null && props[i] !== null) {
|
|
3300
3298
|
newObj[i] = inherit(oldObj[i], props[i]);
|
|
3301
3299
|
} else {
|
|
3302
3300
|
newObj[i] = props[i];
|
|
@@ -3304,7 +3302,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3304
3302
|
}
|
|
3305
3303
|
return newObj;
|
|
3306
3304
|
};
|
|
3307
|
-
if (type.form ===
|
|
3305
|
+
if (type.form === 'primitive') {
|
|
3308
3306
|
t = inherit(primitive, type);
|
|
3309
3307
|
} else {
|
|
3310
3308
|
p = this.getType(type.form);
|
|
@@ -3314,7 +3312,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3314
3312
|
return;
|
|
3315
3313
|
}
|
|
3316
3314
|
}
|
|
3317
|
-
t.ancestry = typeName +
|
|
3315
|
+
t.ancestry = typeName + ':' + t.ancestry;
|
|
3318
3316
|
t.prepared = true;
|
|
3319
3317
|
return t;
|
|
3320
3318
|
};
|
|
@@ -3328,13 +3326,13 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3328
3326
|
i,
|
|
3329
3327
|
l = node.operands.length - offset;
|
|
3330
3328
|
fnType = node.operands[offset - 1].type;
|
|
3331
|
-
if (!fnType || !fnType.is(
|
|
3329
|
+
if (!fnType || !fnType.is('function')) {
|
|
3332
3330
|
return;
|
|
3333
3331
|
}
|
|
3334
3332
|
node.type = fnType.type;
|
|
3335
3333
|
if (fnType.params && fnType.params.length !== l) {
|
|
3336
3334
|
//Handling wherever the function doesnt have parameters.Not an error.
|
|
3337
|
-
if (fnType.params.length != 0) node.error(
|
|
3335
|
+
if (fnType.params.length != 0) node.error('Expected ' + fnType.params.length + ' arguments.');
|
|
3338
3336
|
l = Math.min(l, fnType.params.length);
|
|
3339
3337
|
}
|
|
3340
3338
|
for (i = 0; i < l; i += 1) {
|
|
@@ -3351,11 +3349,11 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3351
3349
|
};
|
|
3352
3350
|
this.scope = scope;
|
|
3353
3351
|
switch (this.arity) {
|
|
3354
|
-
case
|
|
3352
|
+
case 'literal':
|
|
3355
3353
|
break;
|
|
3356
|
-
case
|
|
3354
|
+
case 'missing':
|
|
3357
3355
|
break;
|
|
3358
|
-
case
|
|
3356
|
+
case 'name':
|
|
3359
3357
|
while (scope) {
|
|
3360
3358
|
this.ident = scope.find(this.value);
|
|
3361
3359
|
if (this.ident) break;
|
|
@@ -3365,12 +3363,12 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3365
3363
|
this.type = this.ident.type;
|
|
3366
3364
|
this.scope = scope;
|
|
3367
3365
|
} else {
|
|
3368
|
-
this.error(
|
|
3366
|
+
this.error('Unknown identifier.');
|
|
3369
3367
|
}
|
|
3370
3368
|
break;
|
|
3371
|
-
case
|
|
3372
|
-
case
|
|
3373
|
-
case
|
|
3369
|
+
case 'unary_operation':
|
|
3370
|
+
case 'binary_operation':
|
|
3371
|
+
case 'ternary_operation':
|
|
3374
3372
|
for (i = 0, l = this.operands.length; i < l; i += 1) {
|
|
3375
3373
|
this.operands[i].setType(scope);
|
|
3376
3374
|
}
|
|
@@ -3385,24 +3383,24 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3385
3383
|
for (i = 0, l = this.operands.length; i < l; i += 1) {
|
|
3386
3384
|
e.push(getTypeName(this.operands[i]));
|
|
3387
3385
|
}
|
|
3388
|
-
this.error(
|
|
3386
|
+
this.error('Invalid ' + this.value + ' between ' + e.join(', '));
|
|
3389
3387
|
}
|
|
3390
3388
|
break;
|
|
3391
|
-
case
|
|
3389
|
+
case 'object_dereference':
|
|
3392
3390
|
this.operands[0].setType(scope);
|
|
3393
3391
|
if (this.operands[0].type) {
|
|
3394
3392
|
this.operands[1].setType(this.operands[0].type.memberScope || this.getScope(this.operands[0].type.members, null));
|
|
3395
3393
|
}
|
|
3396
3394
|
this.type = this.operands[1].type;
|
|
3397
|
-
this.operands[0].setExpectedTypes([
|
|
3395
|
+
this.operands[0].setExpectedTypes(['object']);
|
|
3398
3396
|
break;
|
|
3399
|
-
case
|
|
3397
|
+
case 'function_call':
|
|
3400
3398
|
this.operands[0].setType(scope);
|
|
3401
3399
|
setParamTypes(this, 1, scope);
|
|
3402
|
-
this.operands[0].setExpectedTypes([
|
|
3400
|
+
this.operands[0].setExpectedTypes(['function']);
|
|
3403
3401
|
break;
|
|
3404
|
-
case
|
|
3405
|
-
//TODO : auto braces with number of arguments
|
|
3402
|
+
case 'method_call':
|
|
3403
|
+
//TODO : auto braces with number of arguments
|
|
3406
3404
|
//might have to make some changes here for inserting braces automatically
|
|
3407
3405
|
//console.log(this);
|
|
3408
3406
|
this.operands[0].setType(scope);
|
|
@@ -3410,8 +3408,8 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3410
3408
|
this.operands[1].setType(this.operands[0].type.memberScope || this.getScope(this.operands[0].type.members, null));
|
|
3411
3409
|
}
|
|
3412
3410
|
setParamTypes(this, 2, scope);
|
|
3413
|
-
this.operands[0].setExpectedTypes([
|
|
3414
|
-
this.operands[1].setExpectedTypes([
|
|
3411
|
+
this.operands[0].setExpectedTypes(['object']);
|
|
3412
|
+
this.operands[1].setExpectedTypes(['function']);
|
|
3415
3413
|
|
|
3416
3414
|
//Handling wherever the function doesnt have parameters. Remove the last node.
|
|
3417
3415
|
if (this.operands[1] && this.operands[1].type && this.operands[1].type.params == 0) {
|
|
@@ -3419,7 +3417,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3419
3417
|
this.operands.length = 2;
|
|
3420
3418
|
}
|
|
3421
3419
|
break;
|
|
3422
|
-
case
|
|
3420
|
+
case 'array_lookup':
|
|
3423
3421
|
this.operands[0].setType(scope);
|
|
3424
3422
|
this.operands[1].setType(scope);
|
|
3425
3423
|
if (this.operands[0].type) {
|
|
@@ -3456,8 +3454,8 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3456
3454
|
for (j = 0; j < l; j++) {
|
|
3457
3455
|
if (i !== j && types[j] && types[i].is(types[j]) && (!types[j].is(types[i]) || i < j)
|
|
3458
3456
|
/* Don't push types[i] if it is a proper subtype
|
|
3459
|
-
|
|
3460
|
-
|
|
3457
|
+
of types[j]; However if both are the same type,
|
|
3458
|
+
push one of them (the last one). */) {
|
|
3461
3459
|
break;
|
|
3462
3460
|
}
|
|
3463
3461
|
}
|
|
@@ -3473,21 +3471,21 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3473
3471
|
}
|
|
3474
3472
|
this.expectedTypes = types;
|
|
3475
3473
|
for (i = 0; i < l; i += 1) {
|
|
3476
|
-
typeNames[i] = types[i].ancestry.split(
|
|
3474
|
+
typeNames[i] = types[i].ancestry.split(':')[0];
|
|
3477
3475
|
}
|
|
3478
3476
|
|
|
3479
3477
|
// Check if the current type is one of the expected ones.
|
|
3480
3478
|
if (this.type) {
|
|
3481
3479
|
for (i = 0; i < l; i += 1) {
|
|
3482
3480
|
expectedType = types[i];
|
|
3483
|
-
if (this.arity ===
|
|
3481
|
+
if (this.arity === 'literal') {
|
|
3484
3482
|
//brackets are a must!
|
|
3485
3483
|
//console.log(expectedType, this.type);
|
|
3486
3484
|
}
|
|
3487
3485
|
if (this.type.is(expectedType)) {
|
|
3488
3486
|
break;
|
|
3489
3487
|
}
|
|
3490
|
-
if (this.arity ===
|
|
3488
|
+
if (this.arity === 'literal' && expectedType.is(this.type)) {
|
|
3491
3489
|
// Auto-cast literals to subtypes.
|
|
3492
3490
|
// This is done to handle enums, etc.
|
|
3493
3491
|
this.type = expectedType;
|
|
@@ -3498,18 +3496,18 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3498
3496
|
|
|
3499
3497
|
// Put type mismatch errors
|
|
3500
3498
|
if (i === l) {
|
|
3501
|
-
e =
|
|
3499
|
+
e = 'Expected: ' + typeNames.join('/');
|
|
3502
3500
|
if (this.type && this.type.ancestry) {
|
|
3503
|
-
e +=
|
|
3501
|
+
e += ', not ' + this.type.ancestry.split(':')[0];
|
|
3504
3502
|
}
|
|
3505
3503
|
this.error(e);
|
|
3506
3504
|
}
|
|
3507
3505
|
};
|
|
3508
3506
|
|
|
3509
3507
|
/*
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3508
|
+
* Type annotates nodes with "type" and "expectedType" attributes
|
|
3509
|
+
* and adds error messages if needed.
|
|
3510
|
+
*/
|
|
3513
3511
|
var loadType;
|
|
3514
3512
|
return function (tree, expected, loader) {
|
|
3515
3513
|
loadType = loader;
|
|
@@ -3527,13 +3525,13 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3527
3525
|
pos: pos
|
|
3528
3526
|
};
|
|
3529
3527
|
}
|
|
3530
|
-
t = node.textContent || node.innerText ||
|
|
3528
|
+
t = node.textContent || node.innerText || '';
|
|
3531
3529
|
if (pos > t.length) {
|
|
3532
3530
|
pos = t.length;
|
|
3533
3531
|
}
|
|
3534
3532
|
for (i = 0, l = node.childNodes.length; i < l; i += 1) {
|
|
3535
3533
|
n = node.childNodes[i];
|
|
3536
|
-
t = n.textContent || n.innerText ||
|
|
3534
|
+
t = n.textContent || n.innerText || '';
|
|
3537
3535
|
if (t.length < pos) {
|
|
3538
3536
|
pos -= t.length;
|
|
3539
3537
|
} else {
|
|
@@ -3546,7 +3544,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3546
3544
|
};
|
|
3547
3545
|
},
|
|
3548
3546
|
getCursor: function (editor) {
|
|
3549
|
-
|
|
3547
|
+
'use strict';
|
|
3550
3548
|
|
|
3551
3549
|
var range = _rangy.default.createRange(),
|
|
3552
3550
|
select = _rangy.default.getSelection(),
|
|
@@ -3565,7 +3563,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3565
3563
|
};
|
|
3566
3564
|
},
|
|
3567
3565
|
putCursor: function (start, end, reverse) {
|
|
3568
|
-
|
|
3566
|
+
'use strict';
|
|
3569
3567
|
|
|
3570
3568
|
var range = _rangy.default.createRange(),
|
|
3571
3569
|
select = _rangy.default.getSelection();
|
|
@@ -3575,16 +3573,16 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3575
3573
|
select.addRange(range, reverse);
|
|
3576
3574
|
},
|
|
3577
3575
|
expr: function (d) {
|
|
3578
|
-
|
|
3576
|
+
'use strict';
|
|
3579
3577
|
|
|
3580
3578
|
var t = (0, _jquery.default)(d);
|
|
3581
|
-
t.find(
|
|
3579
|
+
t.find('br').remove();
|
|
3582
3580
|
return t.text();
|
|
3583
3581
|
},
|
|
3584
3582
|
balloon: function (node) {
|
|
3585
|
-
|
|
3583
|
+
'use strict';
|
|
3586
3584
|
|
|
3587
|
-
var popup = (0, _jquery.default)(
|
|
3585
|
+
var popup = (0, _jquery.default)('.balloon'),
|
|
3588
3586
|
editor,
|
|
3589
3587
|
t,
|
|
3590
3588
|
i,
|
|
@@ -3597,31 +3595,38 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3597
3595
|
show = false,
|
|
3598
3596
|
calltipDiv,
|
|
3599
3597
|
calltipEls;
|
|
3600
|
-
if (!node.dom || node.dom.hasClass(
|
|
3601
|
-
editor = node.dom.closest(
|
|
3602
|
-
if (!editor.is(
|
|
3598
|
+
if (!node.dom || node.dom.hasClass('selected')) return;
|
|
3599
|
+
editor = node.dom.closest('.expredit').eq(0);
|
|
3600
|
+
if (!editor.is(':focus')) return;
|
|
3603
3601
|
if (popup.length) {
|
|
3604
3602
|
io.removeBalloon();
|
|
3605
3603
|
}
|
|
3606
|
-
editor.find(
|
|
3607
|
-
node.dom.addClass(
|
|
3608
|
-
var
|
|
3609
|
-
|
|
3610
|
-
|
|
3604
|
+
editor.find('.selected').removeClass('selected');
|
|
3605
|
+
node.dom.addClass('selected');
|
|
3606
|
+
var rect = node.dom[0].getBoundingClientRect();
|
|
3607
|
+
popup = (0, _jquery.default)('<div>').addClass('balloon').data('node', node).css({
|
|
3608
|
+
position: 'fixed',
|
|
3609
|
+
top: rect.bottom + 8 + 'px',
|
|
3610
|
+
left: rect.left + 'px',
|
|
3611
|
+
zIndex: 2147483647,
|
|
3612
|
+
background: '#fff',
|
|
3613
|
+
boxShadow: '0 2px 8px rgba(0,0,0,0.15)',
|
|
3614
|
+
border: '1px solid #d9d9d9'
|
|
3615
|
+
});
|
|
3611
3616
|
var setValue = function (value) {
|
|
3612
3617
|
var range;
|
|
3613
3618
|
node.dom.html(value);
|
|
3614
3619
|
range = _rangy.default.createRange();
|
|
3615
3620
|
range.collapseAfter(node.dom[0]);
|
|
3616
3621
|
_rangy.default.getSelection().setSingleRange(range);
|
|
3617
|
-
node.dom.trigger(
|
|
3622
|
+
node.dom.trigger('keyup');
|
|
3618
3623
|
};
|
|
3619
3624
|
var calltipHover = function (e) {
|
|
3620
|
-
if ((0, _jquery.default)(this).hasClass(
|
|
3625
|
+
if ((0, _jquery.default)(this).hasClass('sel')) {
|
|
3621
3626
|
return;
|
|
3622
3627
|
}
|
|
3623
|
-
(0, _jquery.default)(
|
|
3624
|
-
(0, _jquery.default)(this).addClass(
|
|
3628
|
+
(0, _jquery.default)('.calltip.sel').removeClass('sel');
|
|
3629
|
+
(0, _jquery.default)(this).addClass('sel');
|
|
3625
3630
|
};
|
|
3626
3631
|
var calltipClick = function (e) {
|
|
3627
3632
|
setValue((0, _jquery.default)(this).html());
|
|
@@ -3635,18 +3640,18 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3635
3640
|
selection,
|
|
3636
3641
|
numTips;
|
|
3637
3642
|
if (e.which === UP || e.which === DOWN || e.which === ENTER || e.which === ESC) {
|
|
3638
|
-
selection = (0, _jquery.default)(
|
|
3639
|
-
var callTipDiv = (0, _jquery.default)(
|
|
3643
|
+
selection = (0, _jquery.default)('.calltip.sel');
|
|
3644
|
+
var callTipDiv = (0, _jquery.default)('.calltips');
|
|
3640
3645
|
numTips = calltipEls.length;
|
|
3641
3646
|
if (selection.length) {
|
|
3642
3647
|
if (e.which === UP) {
|
|
3643
|
-
(0, _jquery.default)(
|
|
3648
|
+
(0, _jquery.default)('.balloon').removeClass('hide');
|
|
3644
3649
|
selection = calltipEls.eq((calltipEls.index(selection) + numTips - 1) % numTips);
|
|
3645
3650
|
callTipDiv.animate({
|
|
3646
3651
|
scrollTop: calltipEls.index(selection) * selection.outerHeight()
|
|
3647
3652
|
}, 100);
|
|
3648
3653
|
} else if (e.which === DOWN) {
|
|
3649
|
-
(0, _jquery.default)(
|
|
3654
|
+
(0, _jquery.default)('.balloon').removeClass('hide');
|
|
3650
3655
|
selection = calltipEls.eq((calltipEls.index(selection) + 1) % numTips);
|
|
3651
3656
|
callTipDiv.animate({
|
|
3652
3657
|
scrollTop: calltipEls.index(selection) * selection.outerHeight()
|
|
@@ -3655,7 +3660,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3655
3660
|
//console.log(grammar);
|
|
3656
3661
|
setValue(selection.html());
|
|
3657
3662
|
} else if (e.which === ESC) {
|
|
3658
|
-
(0, _jquery.default)(
|
|
3663
|
+
(0, _jquery.default)('.balloon').addClass('hide');
|
|
3659
3664
|
}
|
|
3660
3665
|
} else {
|
|
3661
3666
|
if (e.which === UP) {
|
|
@@ -3665,8 +3670,8 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3665
3670
|
}
|
|
3666
3671
|
}
|
|
3667
3672
|
if (selection.length) {
|
|
3668
|
-
(0, _jquery.default)(
|
|
3669
|
-
selection.addClass(
|
|
3673
|
+
(0, _jquery.default)('.calltip.sel').removeClass('sel');
|
|
3674
|
+
selection.addClass('sel');
|
|
3670
3675
|
}
|
|
3671
3676
|
e.preventDefault();
|
|
3672
3677
|
e.stopPropagation();
|
|
@@ -3677,16 +3682,16 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3677
3682
|
|
|
3678
3683
|
/* Add error messages */
|
|
3679
3684
|
if (node.err) {
|
|
3680
|
-
popup.append((0, _jquery.default)(
|
|
3685
|
+
popup.append((0, _jquery.default)('<div>').addClass('expressionError').html(node.err.join('<br />')));
|
|
3681
3686
|
show = true;
|
|
3682
3687
|
}
|
|
3683
3688
|
|
|
3684
3689
|
/* Add info messages */
|
|
3685
|
-
var info =
|
|
3690
|
+
var info = '',
|
|
3686
3691
|
expDescs = [],
|
|
3687
|
-
expinfo =
|
|
3692
|
+
expinfo = '';
|
|
3688
3693
|
if (node.param && node.param.desc) {
|
|
3689
|
-
expinfo +=
|
|
3694
|
+
expinfo += 'argument: ' + node.param.desc + ' ';
|
|
3690
3695
|
}
|
|
3691
3696
|
if (node.expectedTypes) {
|
|
3692
3697
|
for (i = 0, l = node.expectedTypes.length; i < l; i += 1) {
|
|
@@ -3694,20 +3699,20 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3694
3699
|
expDescs.push(node.expectedTypes[i].desc);
|
|
3695
3700
|
}
|
|
3696
3701
|
}
|
|
3697
|
-
expinfo += expDescs.length ? (expinfo ?
|
|
3702
|
+
expinfo += expDescs.length ? (expinfo ? '(' : '') + expDescs.join(', ') + (expinfo ? ')' : '') : '';
|
|
3698
3703
|
}
|
|
3699
3704
|
if (node.ident && node.ident.desc) {
|
|
3700
|
-
info += node.ident.desc +
|
|
3705
|
+
info += node.ident.desc + ' ';
|
|
3701
3706
|
}
|
|
3702
3707
|
if (node.type && node.type.desc) {
|
|
3703
|
-
info += (info ?
|
|
3708
|
+
info += (info ? '(' : 'Found: ') + node.type.desc + (info ? ')' : '');
|
|
3704
3709
|
}
|
|
3705
3710
|
if (expinfo) {
|
|
3706
|
-
popup.append((0, _jquery.default)(
|
|
3711
|
+
popup.append((0, _jquery.default)('<div>').addClass('info').html('Expected ' + expinfo));
|
|
3707
3712
|
show = true;
|
|
3708
3713
|
}
|
|
3709
3714
|
if (info) {
|
|
3710
|
-
popup.append((0, _jquery.default)(
|
|
3715
|
+
popup.append((0, _jquery.default)('<div>').addClass('info').html(info));
|
|
3711
3716
|
show = true;
|
|
3712
3717
|
}
|
|
3713
3718
|
|
|
@@ -3716,7 +3721,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3716
3721
|
for (j = 0; j < m; j += 1) {
|
|
3717
3722
|
expected = node.getType(node.expectedTypes[j]);
|
|
3718
3723
|
if (expected && expected.ancestry) {
|
|
3719
|
-
t = expected.ancestry.split(
|
|
3724
|
+
t = expected.ancestry.split(':');
|
|
3720
3725
|
for (i = 0, l = t.length; i < l; i += 1) {
|
|
3721
3726
|
if (pickers[t[i]]) {
|
|
3722
3727
|
picker = pickers[t[i]](node.value, expected, setValue);
|
|
@@ -3738,44 +3743,45 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3738
3743
|
show = true;
|
|
3739
3744
|
}
|
|
3740
3745
|
if (show) {
|
|
3741
|
-
popup.data(
|
|
3742
|
-
editor.on(
|
|
3743
|
-
|
|
3744
|
-
|
|
3746
|
+
popup.data('editor', editor);
|
|
3747
|
+
editor.on('keydown.balloon', calltipKey);
|
|
3748
|
+
var targetBody = editor[0] && editor[0].ownerDocument ? editor[0].ownerDocument.body : document.body;
|
|
3749
|
+
popup.on('mousedown', function () {
|
|
3750
|
+
editor.trigger('focus');
|
|
3745
3751
|
ignoreBlur = true;
|
|
3746
|
-
}).appendTo(
|
|
3747
|
-
(0, _jquery.default)(
|
|
3752
|
+
}).appendTo(targetBody);
|
|
3753
|
+
(0, _jquery.default)('.calltip').on('mousemove', calltipHover).on('click', calltipClick);
|
|
3748
3754
|
}
|
|
3749
|
-
calltipEls = (0, _jquery.default)(
|
|
3750
|
-
calltipEls.eq(0).addClass(
|
|
3755
|
+
calltipEls = (0, _jquery.default)('.calltip');
|
|
3756
|
+
calltipEls.eq(0).addClass('sel');
|
|
3751
3757
|
},
|
|
3752
3758
|
removeBalloon: function () {
|
|
3753
3759
|
var editor;
|
|
3754
|
-
editor = (0, _jquery.default)(
|
|
3760
|
+
editor = (0, _jquery.default)('.balloon').data('editor');
|
|
3755
3761
|
if (editor) {
|
|
3756
|
-
editor.off(
|
|
3762
|
+
editor.off('keydown.balloon');
|
|
3757
3763
|
}
|
|
3758
|
-
(0, _jquery.default)(
|
|
3759
|
-
(0, _jquery.default)(
|
|
3764
|
+
(0, _jquery.default)('.balloon').remove();
|
|
3765
|
+
(0, _jquery.default)('.selected').removeClass('selected');
|
|
3760
3766
|
}
|
|
3761
3767
|
};
|
|
3762
3768
|
|
|
3763
3769
|
/*
|
|
3764
|
-
|
|
3770
|
+
selectNode could be rewritten as protonode.findSelectedLeaf(cursor)
|
|
3765
3771
|
*/
|
|
3766
3772
|
|
|
3767
3773
|
var selectNode = function (tree, cursor) {
|
|
3768
|
-
|
|
3774
|
+
'use strict';
|
|
3769
3775
|
|
|
3770
3776
|
var selDist = 99999,
|
|
3771
3777
|
selNode,
|
|
3772
3778
|
t;
|
|
3773
3779
|
var affinity = function (node) {
|
|
3774
3780
|
switch (node.arity) {
|
|
3775
|
-
case
|
|
3781
|
+
case 'missing':
|
|
3776
3782
|
return 2;
|
|
3777
|
-
case
|
|
3778
|
-
case
|
|
3783
|
+
case 'literal':
|
|
3784
|
+
case 'name':
|
|
3779
3785
|
return 1;
|
|
3780
3786
|
default:
|
|
3781
3787
|
return 0;
|
|
@@ -3801,13 +3807,13 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3801
3807
|
if (selNode) {
|
|
3802
3808
|
if (selNode.dom) {
|
|
3803
3809
|
t = selNode.dom[0];
|
|
3804
|
-
t = (t.textContent || t.innerText ||
|
|
3810
|
+
t = (t.textContent || t.innerText || '').length;
|
|
3805
3811
|
}
|
|
3806
3812
|
return {
|
|
3807
3813
|
node: selNode,
|
|
3808
3814
|
pos: Math.min(t, cursor - selNode.pos)
|
|
3809
3815
|
};
|
|
3810
|
-
} else if (tree.arity ===
|
|
3816
|
+
} else if (tree.arity === 'missing') {
|
|
3811
3817
|
return {
|
|
3812
3818
|
node: tree,
|
|
3813
3819
|
pos: 0
|
|
@@ -3819,7 +3825,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3819
3825
|
var getTypeName = function (node, full) {
|
|
3820
3826
|
var type = node.type;
|
|
3821
3827
|
if (type) {
|
|
3822
|
-
if (typeof type ===
|
|
3828
|
+
if (typeof type === 'string') {
|
|
3823
3829
|
if (full) {
|
|
3824
3830
|
return node.getType(type).ancestry;
|
|
3825
3831
|
}
|
|
@@ -3829,13 +3835,13 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3829
3835
|
if (full) {
|
|
3830
3836
|
return type.ancestry;
|
|
3831
3837
|
}
|
|
3832
|
-
return type.ancestry.replace(/anonymous\:/g,
|
|
3838
|
+
return type.ancestry.replace(/anonymous\:/g, '').split(':')[0];
|
|
3833
3839
|
}
|
|
3834
3840
|
}
|
|
3835
|
-
return
|
|
3841
|
+
return 'unknown';
|
|
3836
3842
|
};
|
|
3837
3843
|
protonode.toJson = function (prefix, indent) {
|
|
3838
|
-
|
|
3844
|
+
'use strict';
|
|
3839
3845
|
|
|
3840
3846
|
var i, l, str, delim;
|
|
3841
3847
|
str = prefix + '{';
|
|
@@ -3861,12 +3867,12 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3861
3867
|
return str;
|
|
3862
3868
|
};
|
|
3863
3869
|
protonode.toDom = function (pos) {
|
|
3864
|
-
|
|
3870
|
+
'use strict';
|
|
3865
3871
|
|
|
3866
3872
|
var i,
|
|
3867
3873
|
l,
|
|
3868
3874
|
el,
|
|
3869
|
-
className =
|
|
3875
|
+
className = 'node',
|
|
3870
3876
|
node = this,
|
|
3871
3877
|
typeName;
|
|
3872
3878
|
pos = pos || 0;
|
|
@@ -3883,29 +3889,29 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3883
3889
|
if (delim) d = delim.clone(false);
|
|
3884
3890
|
}
|
|
3885
3891
|
};
|
|
3886
|
-
this.dom = el = (0, _jquery.default)(
|
|
3887
|
-
className +=
|
|
3888
|
-
className += this.err ?
|
|
3889
|
-
typeName =
|
|
3890
|
-
className += typeName ?
|
|
3892
|
+
this.dom = el = (0, _jquery.default)('<span>');
|
|
3893
|
+
className += ' ' + this.arity;
|
|
3894
|
+
className += this.err ? ' has_errors' : '';
|
|
3895
|
+
typeName = 'expredit_' + getTypeName(this, true);
|
|
3896
|
+
className += typeName ? ' ' + typeName.replace(/anonymous/g, '').replace(/\:+/g, ' ') : '';
|
|
3891
3897
|
el.addClass(className);
|
|
3892
3898
|
switch (this.arity) {
|
|
3893
|
-
case
|
|
3894
|
-
case
|
|
3895
|
-
addChildren(this, 0, (0, _jquery.default)("<span class='operator'>" + this.text +
|
|
3899
|
+
case 'binary_operation':
|
|
3900
|
+
case 'object_dereference':
|
|
3901
|
+
addChildren(this, 0, (0, _jquery.default)("<span class='operator'>" + this.text + '</span>'));
|
|
3896
3902
|
break;
|
|
3897
|
-
case
|
|
3898
|
-
el.append((0, _jquery.default)("<span class='operator'>" + this.text +
|
|
3903
|
+
case 'unary_operation':
|
|
3904
|
+
el.append((0, _jquery.default)("<span class='operator'>" + this.text + '</span>'));
|
|
3899
3905
|
el.append(this.children[0].toDom(pos));
|
|
3900
3906
|
break;
|
|
3901
|
-
case
|
|
3907
|
+
case 'ternary_operation':
|
|
3902
3908
|
el.append(this.children[0].toDom(pos));
|
|
3903
3909
|
el.append((0, _jquery.default)("<span class='operator'>?</span>"));
|
|
3904
3910
|
el.append(this.children[1].toDom(pos));
|
|
3905
3911
|
el.append((0, _jquery.default)("<span class='operator'>:</span>"));
|
|
3906
3912
|
el.append(this.children[2].toDom(pos));
|
|
3907
3913
|
break;
|
|
3908
|
-
case
|
|
3914
|
+
case 'method_call':
|
|
3909
3915
|
el.append(this.children[0].toDom(pos));
|
|
3910
3916
|
el.append((0, _jquery.default)("<span class='operator'>.</span>"));
|
|
3911
3917
|
el.append(this.children[1].toDom(pos));
|
|
@@ -3913,19 +3919,19 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3913
3919
|
addChildren(this, 2, (0, _jquery.default)("<span class='operator'>,</span>"));
|
|
3914
3920
|
el.append((0, _jquery.default)("<span class='operator paren'>)</span>"));
|
|
3915
3921
|
break;
|
|
3916
|
-
case
|
|
3922
|
+
case 'function_call':
|
|
3917
3923
|
el.append(this.children[0].toDom(pos));
|
|
3918
3924
|
el.append((0, _jquery.default)("<span class='operator paren'>(</span>"));
|
|
3919
3925
|
addChildren(this, 1, (0, _jquery.default)("<span class='operator'>,</span>"));
|
|
3920
3926
|
el.append((0, _jquery.default)("<span class='operator paren'>)</span>"));
|
|
3921
3927
|
break;
|
|
3922
|
-
case
|
|
3928
|
+
case 'array_lookup':
|
|
3923
3929
|
el.append(this.children[0].toDom(pos));
|
|
3924
3930
|
el.append((0, _jquery.default)("<span class='operator paren'>[</span>"));
|
|
3925
3931
|
addChildren(this, 1, (0, _jquery.default)("<span class='operator'> </span>"));
|
|
3926
3932
|
el.append((0, _jquery.default)("<span class='operator paren'>]</span>"));
|
|
3927
3933
|
break;
|
|
3928
|
-
case
|
|
3934
|
+
case 'group':
|
|
3929
3935
|
if (this.paren !== false) {
|
|
3930
3936
|
el.append((0, _jquery.default)("<span class='operator paren'>(</span>"));
|
|
3931
3937
|
}
|
|
@@ -3934,18 +3940,18 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3934
3940
|
el.append((0, _jquery.default)("<span class='operator paren'>)</span>"));
|
|
3935
3941
|
}
|
|
3936
3942
|
break;
|
|
3937
|
-
case
|
|
3943
|
+
case 'missing':
|
|
3938
3944
|
if (this.text) {
|
|
3939
3945
|
el.html(this.text);
|
|
3940
3946
|
} else {
|
|
3941
|
-
el.html(
|
|
3947
|
+
el.html(' ');
|
|
3942
3948
|
}
|
|
3943
3949
|
break;
|
|
3944
3950
|
default:
|
|
3945
|
-
el.html(this.text ||
|
|
3951
|
+
el.html(this.text || '');
|
|
3946
3952
|
break;
|
|
3947
3953
|
}
|
|
3948
|
-
el.on(
|
|
3954
|
+
el.on('mousemove', function (e) {
|
|
3949
3955
|
io.balloon(node);
|
|
3950
3956
|
e.stopPropagation();
|
|
3951
3957
|
});
|
|
@@ -3960,7 +3966,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3960
3966
|
missingPos;
|
|
3961
3967
|
var loadType = function (typeName) {
|
|
3962
3968
|
if (!options.typeSource) return;
|
|
3963
|
-
var notif = (0, _jquery.default)(
|
|
3969
|
+
var notif = (0, _jquery.default)('<div>').addClass('notification').insertAfter(xedit).html('Loading ' + typeName + '...').fadeIn(200);
|
|
3964
3970
|
_jquery.default.getJSON(options.typeSource, {
|
|
3965
3971
|
t: typeName
|
|
3966
3972
|
}).done(function (data) {
|
|
@@ -3973,7 +3979,7 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3973
3979
|
if (!options.offline) handleCursor();
|
|
3974
3980
|
}).fail(function () {
|
|
3975
3981
|
//console.log(this);
|
|
3976
|
-
notif.html(
|
|
3982
|
+
notif.html('Error loading ' + typeName);
|
|
3977
3983
|
grammar.types[typeName] = false;
|
|
3978
3984
|
setTimeout(function () {
|
|
3979
3985
|
notif.fadeOut(500);
|
|
@@ -3987,19 +3993,19 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
3987
3993
|
typify(tree, options.expected, loadType);
|
|
3988
3994
|
xedit.empty().append(tree.toDom());
|
|
3989
3995
|
//console.log(tree);
|
|
3990
|
-
input.val(io.expr(xedit)).data(
|
|
3996
|
+
input.val(io.expr(xedit)).data('json', tree.toJson('\n', ' ')).trigger('change');
|
|
3991
3997
|
}
|
|
3992
3998
|
};
|
|
3993
3999
|
var handleCursor = function () {
|
|
3994
4000
|
var reverse = cursor.reverse;
|
|
3995
4001
|
var node_s = selectNode(tree, cursor.start);
|
|
3996
4002
|
var node_e = selectNode(tree, cursor.end);
|
|
3997
|
-
var cur_s = node_s && node_s.node.dom && node_s.node.arity ===
|
|
3998
|
-
var cur_e = node_e && node_s.node.dom && node_e.node.arity ===
|
|
4003
|
+
var cur_s = node_s && node_s.node.dom && node_s.node.arity === 'missing' ? io.charOffset(node_s.node.dom[0], node_s.pos) : io.charOffset(xedit[0], cursor.start);
|
|
4004
|
+
var cur_e = node_e && node_s.node.dom && node_e.node.arity === 'missing' ? io.charOffset(node_e.node.dom[0], node_e.pos) : io.charOffset(xedit[0], cursor.end);
|
|
3999
4005
|
onMissing = false;
|
|
4000
4006
|
if (node_e && node_s && node_e.node === node_s.node) {
|
|
4001
4007
|
selectedNode = node_s.node;
|
|
4002
|
-
if (selectedNode.arity ===
|
|
4008
|
+
if (selectedNode.arity === 'missing' && !selectedNode.text) {
|
|
4003
4009
|
cur_s.pos = 0;
|
|
4004
4010
|
cur_e.pos = 1;
|
|
4005
4011
|
missingPos = node_s.pos;
|
|
@@ -4024,34 +4030,34 @@ _jquery.default.fn.expredit = function (grammar, options) {
|
|
|
4024
4030
|
(0, _jquery.default)(document.body).attr({
|
|
4025
4031
|
spellcheck: false
|
|
4026
4032
|
});
|
|
4027
|
-
var xedit = (0, _jquery.default)(
|
|
4033
|
+
var xedit = (0, _jquery.default)('<div>').attr({
|
|
4028
4034
|
contenteditable: true,
|
|
4029
4035
|
spellcheck: false,
|
|
4030
|
-
|
|
4031
|
-
style: input.attr(
|
|
4036
|
+
class: 'expredit ' + input[0].className,
|
|
4037
|
+
style: input.attr('style')
|
|
4032
4038
|
}).css({
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
}).on(
|
|
4039
|
+
width: input.width(),
|
|
4040
|
+
height: 'auto',
|
|
4041
|
+
display: input.is(':visible') ? 'inline-block' : 'none'
|
|
4042
|
+
}).on('keyup', function (e) {
|
|
4037
4043
|
if (onMissing && selectedNode != tree && (e.which == 8 || e.which == 46 || e.which == 37 && missingPos == 0 || e.which == 39 && missingPos == 1)) {
|
|
4038
4044
|
onMissing = false;
|
|
4039
4045
|
}
|
|
4040
4046
|
if (!options.offline) cursor = io.getCursor(xedit[0]);
|
|
4041
4047
|
handleText();
|
|
4042
4048
|
if (!options.offline) handleCursor();
|
|
4043
|
-
}).on(
|
|
4049
|
+
}).on('mouseup', function () {
|
|
4044
4050
|
if (!options.offline) {
|
|
4045
4051
|
cursor = io.getCursor(xedit[0]);
|
|
4046
4052
|
handleCursor();
|
|
4047
4053
|
}
|
|
4048
|
-
}).on(
|
|
4054
|
+
}).on('blur', handleBlur).insertAfter(input);
|
|
4049
4055
|
|
|
4050
4056
|
//TODO: Do it in a better way. Escaping the special characters.
|
|
4051
|
-
var initVal1 = initVal.replace(/</g,
|
|
4052
|
-
initVal1 = initVal1.replace(/>/g,
|
|
4053
|
-
initVal1 = initVal1.replace(/&&/g,
|
|
4054
|
-
initVal1 = initVal1.replace(/'/g,
|
|
4057
|
+
var initVal1 = initVal.replace(/</g, '<');
|
|
4058
|
+
initVal1 = initVal1.replace(/>/g, '>');
|
|
4059
|
+
initVal1 = initVal1.replace(/&&/g, '&&');
|
|
4060
|
+
initVal1 = initVal1.replace(/'/g, '"');
|
|
4055
4061
|
xedit.html(initVal1);
|
|
4056
4062
|
input.hide();
|
|
4057
4063
|
handleText(true);
|
|
@@ -4133,14 +4139,6 @@ module.exports = require("jquery");
|
|
|
4133
4139
|
|
|
4134
4140
|
/***/ }),
|
|
4135
4141
|
|
|
4136
|
-
/***/ 43363:
|
|
4137
|
-
/***/ ((module) => {
|
|
4138
|
-
|
|
4139
|
-
"use strict";
|
|
4140
|
-
module.exports = require("prop-types");
|
|
4141
|
-
|
|
4142
|
-
/***/ }),
|
|
4143
|
-
|
|
4144
4142
|
/***/ 46942:
|
|
4145
4143
|
/***/ ((module, exports) => {
|
|
4146
4144
|
|
|
@@ -4615,34 +4613,10 @@ var ___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___ = __webpack_require__(31601);
|
|
|
4615
4613
|
var ___CSS_LOADER_API_IMPORT___ = __webpack_require__(76314);
|
|
4616
4614
|
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___);
|
|
4617
4615
|
// Module
|
|
4618
|
-
___CSS_LOADER_EXPORT___.push([module.id, `.
|
|
4616
|
+
___CSS_LOADER_EXPORT___.push([module.id, `.root .expredit-container{background:#fff;border-radius:2px;border:1px solid #dcdee2;padding:2px;width:200px;cursor:text;overflow:hidden;font:1 monospace}.root .expredit-container.input{white-space:nowrap;vertical-align:baseline}.root .expredit-container.textarea{vertical-align:bottom;white-space:pre;height:100px}.root .expredit-field{box-shadow:0 1px 0 0 #e9f0fc}.root .operator:after,.root .operator:before{content:" ";font-size:0}.root .expredit{background:#fff;border-radius:2px;border:1px solid #dcdee2;padding:8px 12px;cursor:text;font-size:.857rem;font-family:"Roboto",sans-serif;line-height:1.5;overflow:auto;white-space:pre-wrap;word-wrap:break-word;min-height:32px;box-sizing:border-box}.root .expredit:focus{outline:none;border-color:#47af46}.root .expredit:hover{border-color:#47af46}.root .node{color:#2a2a2a;background:rgba(0,0,0,0);border-bottom:1px solid rgba(0,0,0,0)}.root .operator{display:inline;color:#97a0af}.root .node.selected{background:#e9f0fc !important}.root .node.has_errors>.operator{color:#f5222d}.root .node.has_errors{border-bottom:1px solid #f5222d;margin-bottom:-1px}.root .name{color:#2a2a2a;background:rgba(0,0,0,0);box-shadow:none}.root .literal.expredit_number,.root .name.expredit_number{color:#2466eb;background:rgba(0,0,0,0);box-shadow:none}.root .literal.expredit_string,.root .name.expredit_string{color:#42b040;background:rgba(0,0,0,0);box-shadow:none}.root .literal.expredit_boolean,.root .name.expredit_boolean{color:#f79600;background:rgba(0,0,0,0);box-shadow:none}.root .literal.expredit_date,.root .name.expredit_date,.root .expredit_date{color:#2466eb;background:rgba(0,0,0,0);box-shadow:none}.root .operator.paren{display:inline}.root .node.selected>.arglist{border-color:#97a0af}.root .node.missing>.operator{color:#f5222d}.balloon,.notification{font:1 "Roboto",sans-serif}.balloon{position:absolute;color:#fff;line-height:1em;background:#fff;box-shadow:inset 0 1px 1px 1px rgba(0,0,0,.56);z-index:2147483002;min-width:200px;max-width:400px}.balloon:after{content:"";display:block;position:absolute;top:-8px;left:8px;width:0;border-width:0 8px 8px 0;border-style:solid;border-color:#dcdee2 rgba(0,0,0,0)}.expressionError{color:#f5222d;padding:0 .571rem;margin:.571rem 0}.info{color:#97a0af;padding:0 .571rem;margin:.571rem 0}.picker{margin:0;padding:0}.calltips{text-align:left;padding:0 .571rem;margin:.571rem 0 0 0;max-height:180px;overflow-y:auto;overflow-x:auto}a.calltip{display:block;color:#5e6c84;text-decoration:none;cursor:pointer;margin:0 -0.571rem;padding:.571rem}.calltip.sel{background:#5e6c84;color:#fff}.notification{position:absolute;background:#2a2a2a;color:#fff;padding:.571rem}`, ""]);
|
|
4619
4617
|
// Exports
|
|
4620
4618
|
___CSS_LOADER_EXPORT___.locals = {
|
|
4621
|
-
"
|
|
4622
|
-
"notification": `notification`,
|
|
4623
|
-
"expredit-container": `expredit-container`,
|
|
4624
|
-
"input": `input`,
|
|
4625
|
-
"textarea": `textarea`,
|
|
4626
|
-
"expredit-field": `expredit-field`,
|
|
4627
|
-
"operator": `operator`,
|
|
4628
|
-
"expredit": `expredit`,
|
|
4629
|
-
"node": `node`,
|
|
4630
|
-
"selected": `selected`,
|
|
4631
|
-
"has_errors": `has_errors`,
|
|
4632
|
-
"name": `name`,
|
|
4633
|
-
"literal": `literal`,
|
|
4634
|
-
"expredit_number": `expredit_number`,
|
|
4635
|
-
"expredit_string": `expredit_string`,
|
|
4636
|
-
"expredit_boolean": `expredit_boolean`,
|
|
4637
|
-
"expredit_date": `expredit_date`,
|
|
4638
|
-
"arglist": `arglist`,
|
|
4639
|
-
"missing": `missing`,
|
|
4640
|
-
"expressionError": `expressionError`,
|
|
4641
|
-
"info": `info`,
|
|
4642
|
-
"picker": `picker`,
|
|
4643
|
-
"calltips": `calltips`,
|
|
4644
|
-
"calltip": `calltip`,
|
|
4645
|
-
"sel": `sel`
|
|
4619
|
+
"root": `root`
|
|
4646
4620
|
};
|
|
4647
4621
|
module.exports = ___CSS_LOADER_EXPORT___;
|
|
4648
4622
|
|
|
@@ -5094,26 +5068,23 @@ var exports = __webpack_exports__;
|
|
|
5094
5068
|
|
|
5095
5069
|
exports.__esModule = true;
|
|
5096
5070
|
exports["default"] = void 0;
|
|
5071
|
+
var _classnames = _interopRequireDefault(__webpack_require__(46942));
|
|
5097
5072
|
var _jquery = _interopRequireDefault(__webpack_require__(42812));
|
|
5098
|
-
var _propTypes = _interopRequireDefault(__webpack_require__(43363));
|
|
5099
5073
|
var _react = _interopRequireDefault(__webpack_require__(9206));
|
|
5100
5074
|
var _CapInput = _interopRequireDefault(__webpack_require__(15773));
|
|
5101
5075
|
var _fixGrammar = _interopRequireDefault(__webpack_require__(29666));
|
|
5102
5076
|
var _grammar2 = _interopRequireDefault(__webpack_require__(22193));
|
|
5103
|
-
__webpack_require__(77792);
|
|
5077
|
+
var _styles = _interopRequireDefault(__webpack_require__(77792));
|
|
5104
5078
|
var _jsxRuntime = __webpack_require__(74848);
|
|
5105
|
-
const _excluded = ["className", "onChange", "grammar", "
|
|
5079
|
+
const _excluded = ["className", "onChange", "grammar", "expected", "typeSource", "delims", "expression"];
|
|
5106
5080
|
/**
|
|
5107
|
-
*
|
|
5108
|
-
* ExpressionEditor
|
|
5109
|
-
*
|
|
5081
|
+
* CapExpressionEditor - Expression editor with grammar validation and autocomplete
|
|
5110
5082
|
*/
|
|
5111
|
-
|
|
5083
|
+
/* global JQuery */
|
|
5112
5084
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
5113
5085
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
5114
5086
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
5115
5087
|
__webpack_require__(29925);
|
|
5116
|
-
const classNames = __webpack_require__(46942);
|
|
5117
5088
|
const {
|
|
5118
5089
|
TextArea
|
|
5119
5090
|
} = _CapInput.default;
|
|
@@ -5121,19 +5092,19 @@ let idCounter = 0;
|
|
|
5121
5092
|
class CapExpressionEditor extends _react.default.Component {
|
|
5122
5093
|
constructor(props) {
|
|
5123
5094
|
super(props);
|
|
5095
|
+
this.$expressionEditorContainer = null;
|
|
5096
|
+
this.$expressionEditor = null;
|
|
5124
5097
|
this.onChange = () => {
|
|
5098
|
+
var _this$$expressionEdit, _this$$expressionEdit2, _this$$expressionEdit3, _this$$expressionEdit4;
|
|
5125
5099
|
const {
|
|
5126
5100
|
onChange
|
|
5127
5101
|
} = this.props;
|
|
5128
5102
|
this.setState({
|
|
5129
|
-
expressionJSON: this.$expressionEditor.data('json'),
|
|
5130
|
-
expression: this.$expressionEditor.val(),
|
|
5131
|
-
isError: this.$expressionEditorContainer.find('span.has_errors').length > 0
|
|
5103
|
+
expressionJSON: (_this$$expressionEdit = this.$expressionEditor) == null ? void 0 : _this$$expressionEdit.data('json'),
|
|
5104
|
+
expression: (_this$$expressionEdit2 = this.$expressionEditor) == null ? void 0 : _this$$expressionEdit2.val(),
|
|
5105
|
+
isError: ((_this$$expressionEdit3 = (_this$$expressionEdit4 = this.$expressionEditorContainer) == null ? void 0 : _this$$expressionEdit4.find('span.has_errors').length) != null ? _this$$expressionEdit3 : 0) > 0
|
|
5132
5106
|
}, () => onChange && onChange(this.state.expressionJSON, this.state.expression, this.state.isError));
|
|
5133
5107
|
};
|
|
5134
|
-
this.setRef = textArea => {
|
|
5135
|
-
this.expressionEditorContainer = textArea;
|
|
5136
|
-
};
|
|
5137
5108
|
this.state = {
|
|
5138
5109
|
expressionJSON: {},
|
|
5139
5110
|
expression: props.expression || '',
|
|
@@ -5146,10 +5117,6 @@ class CapExpressionEditor extends _react.default.Component {
|
|
|
5146
5117
|
return "expression-editor-" + idCounter;
|
|
5147
5118
|
}
|
|
5148
5119
|
componentDidMount() {
|
|
5149
|
-
/**
|
|
5150
|
-
* this.$expressionEditorContainer => This is the Jquery ref for entire expressionJSON container, will help us traverse through all the DOM node using jquery
|
|
5151
|
-
* this.$expressionEditor => this refers to the textArea of the expressionEditor
|
|
5152
|
-
*/
|
|
5153
5120
|
const {
|
|
5154
5121
|
grammar,
|
|
5155
5122
|
expected,
|
|
@@ -5159,15 +5126,18 @@ class CapExpressionEditor extends _react.default.Component {
|
|
|
5159
5126
|
disabled
|
|
5160
5127
|
} = this.props;
|
|
5161
5128
|
if (!disabled) {
|
|
5162
|
-
|
|
5129
|
+
const containerEl = document.querySelector("." + this.state.refTargetId);
|
|
5130
|
+
if (!containerEl) return;
|
|
5131
|
+
this.$expressionEditorContainer = (0, _jquery.default)(containerEl);
|
|
5163
5132
|
this.$expressionEditor = this.$expressionEditorContainer.find('textarea');
|
|
5133
|
+
if (!this.$expressionEditor.length) return;
|
|
5164
5134
|
this.$expressionEditor.expredit((0, _fixGrammar.default)(grammar), {
|
|
5165
5135
|
expected,
|
|
5166
5136
|
typeSource,
|
|
5167
5137
|
delims
|
|
5168
5138
|
}).on('change', () => this.onChange());
|
|
5169
5139
|
|
|
5170
|
-
//If we are already passing the expression then trigger a onchange to keep the JSON updated in the state
|
|
5140
|
+
// If we are already passing the expression then trigger a onchange to keep the JSON updated in the state
|
|
5171
5141
|
if (expression) {
|
|
5172
5142
|
this.$expressionEditor.trigger('change');
|
|
5173
5143
|
}
|
|
@@ -5183,26 +5153,19 @@ class CapExpressionEditor extends _react.default.Component {
|
|
|
5183
5153
|
expression: value
|
|
5184
5154
|
} = this.state;
|
|
5185
5155
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(TextArea, _extends({
|
|
5186
|
-
className:
|
|
5156
|
+
className: (0, _classnames.default)(_styles.default.root, 'cap-expression-editor', this.state.refTargetId, className)
|
|
5187
5157
|
}, rest, {
|
|
5188
|
-
ref: this.setRef,
|
|
5189
5158
|
value: value,
|
|
5190
5159
|
onChange: this.onChange
|
|
5191
5160
|
}));
|
|
5192
5161
|
}
|
|
5193
5162
|
}
|
|
5163
|
+
CapExpressionEditor.displayName = 'CapExpressionEditor';
|
|
5194
5164
|
CapExpressionEditor.defaultProps = {
|
|
5195
5165
|
grammar: _grammar2.default,
|
|
5196
5166
|
expected: ['boolean'],
|
|
5197
5167
|
delims: ['{{', '}}']
|
|
5198
5168
|
};
|
|
5199
|
-
CapExpressionEditor.propTypes = {
|
|
5200
|
-
grammar: _propTypes.default.object,
|
|
5201
|
-
expected: _propTypes.default.array,
|
|
5202
|
-
typeSource: _propTypes.default.string,
|
|
5203
|
-
delims: _propTypes.default.array,
|
|
5204
|
-
expression: _propTypes.default.string
|
|
5205
|
-
};
|
|
5206
5169
|
var _default = exports["default"] = CapExpressionEditor;
|
|
5207
5170
|
})();
|
|
5208
5171
|
|