x4js 1.4.35 → 1.4.37
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/lib/component.d.ts +37 -0
- package/lib/component.js +3 -3
- package/lib/formatters.js +2 -1
- package/lib/svgcomponent.d.ts +6 -0
- package/lib/svgcomponent.js +31 -1
- package/lib/x4.css +2 -0
- package/package.json +1 -1
- package/src/component.ts +1 -1
- package/src/formatters.ts +3 -1
- package/src/svgcomponent.ts +43 -3
- package/src/x4.less +2 -0
package/lib/component.d.ts
CHANGED
|
@@ -44,6 +44,43 @@ export interface ICaptureInfo {
|
|
|
44
44
|
handler: EventHandler<UIEvent>;
|
|
45
45
|
iframes: NodeListOf<HTMLIFrameElement>;
|
|
46
46
|
}
|
|
47
|
+
/** @ignore properties without 'px' unit */
|
|
48
|
+
export declare const _x4_unitless: {
|
|
49
|
+
animationIterationCount: number;
|
|
50
|
+
borderImageOutset: number;
|
|
51
|
+
borderImageSlice: number;
|
|
52
|
+
borderImageWidth: number;
|
|
53
|
+
boxFlex: number;
|
|
54
|
+
boxFlexGroup: number;
|
|
55
|
+
boxOrdinalGroup: number;
|
|
56
|
+
columnCount: number;
|
|
57
|
+
flex: number;
|
|
58
|
+
flexGrow: number;
|
|
59
|
+
flexPositive: number;
|
|
60
|
+
flexShrink: number;
|
|
61
|
+
flexNegative: number;
|
|
62
|
+
flexOrder: number;
|
|
63
|
+
gridRow: number;
|
|
64
|
+
gridColumn: number;
|
|
65
|
+
fontWeight: number;
|
|
66
|
+
lineClamp: number;
|
|
67
|
+
lineHeight: number;
|
|
68
|
+
opacity: number;
|
|
69
|
+
order: number;
|
|
70
|
+
orphans: number;
|
|
71
|
+
tabSize: number;
|
|
72
|
+
widows: number;
|
|
73
|
+
zIndex: number;
|
|
74
|
+
zoom: number;
|
|
75
|
+
fillOpacity: number;
|
|
76
|
+
floodOpacity: number;
|
|
77
|
+
stopOpacity: number;
|
|
78
|
+
strokeDasharray: number;
|
|
79
|
+
strokeDashoffset: number;
|
|
80
|
+
strokeMiterlimit: number;
|
|
81
|
+
strokeOpacity: number;
|
|
82
|
+
strokeWidth: number;
|
|
83
|
+
};
|
|
47
84
|
/**
|
|
48
85
|
*
|
|
49
86
|
*/
|
package/lib/component.js
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
29
29
|
*/
|
|
30
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.Container = exports.SizerOverlay = exports.EvOverlayResize = exports.Separator = exports.EvSize = exports.Space = exports.Flex = exports.flyWrap = exports.Component = exports.EvFocus = exports.EvDblClick = exports.html = exports.isHtmlString = exports.HtmlString = void 0;
|
|
31
|
+
exports.Container = exports.SizerOverlay = exports.EvOverlayResize = exports.Separator = exports.EvSize = exports.Space = exports.Flex = exports.flyWrap = exports.Component = exports.EvFocus = exports.EvDblClick = exports._x4_unitless = exports.html = exports.isHtmlString = exports.HtmlString = void 0;
|
|
32
32
|
/**
|
|
33
33
|
* @todo
|
|
34
34
|
* create Container class
|
|
@@ -50,7 +50,7 @@ const _x4_el_store = Symbol();
|
|
|
50
50
|
/** @ignore where Component is stored in dom */
|
|
51
51
|
const _x4_el_sym = Symbol();
|
|
52
52
|
/** @ignore properties without 'px' unit */
|
|
53
|
-
|
|
53
|
+
exports._x4_unitless = {
|
|
54
54
|
animationIterationCount: 1, borderImageOutset: 1, borderImageSlice: 1, borderImageWidth: 1, boxFlex: 1, boxFlexGroup: 1,
|
|
55
55
|
boxOrdinalGroup: 1, columnCount: 1, flex: 1, flexGrow: 1, flexPositive: 1, flexShrink: 1, flexNegative: 1, flexOrder: 1,
|
|
56
56
|
gridRow: 1, gridColumn: 1, fontWeight: 1, lineClamp: 1, lineHeight: 1, opacity: 1, order: 1, orphans: 1, tabSize: 1, widows: 1,
|
|
@@ -273,7 +273,7 @@ class Component extends base_component_1.BaseComponent {
|
|
|
273
273
|
if (value === undefined) {
|
|
274
274
|
value = null;
|
|
275
275
|
}
|
|
276
|
-
else if (!_x4_unitless[name] && ((0, tools_1.isNumber)(value) || reNumber.test(value))) {
|
|
276
|
+
else if (!exports._x4_unitless[name] && ((0, tools_1.isNumber)(value) || reNumber.test(value))) {
|
|
277
277
|
value = value + 'px';
|
|
278
278
|
}
|
|
279
279
|
this.m_dom.style[name] = value;
|
package/lib/formatters.js
CHANGED
|
@@ -64,8 +64,9 @@ function money_formatter(input) {
|
|
|
64
64
|
return '';
|
|
65
65
|
}
|
|
66
66
|
let val = (0, tools_1.roundTo)(typeof (input) == 'string' ? parseFloat(input) : input, 2);
|
|
67
|
-
if (val
|
|
67
|
+
if (Object.is(val, -0.00)) {
|
|
68
68
|
val = 0.00;
|
|
69
|
+
}
|
|
69
70
|
let res = moneyFmt.format(val);
|
|
70
71
|
return res;
|
|
71
72
|
}
|
package/lib/svgcomponent.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ import { Component, CProps } from './component';
|
|
|
33
33
|
declare abstract class SVGItem {
|
|
34
34
|
private m_tag;
|
|
35
35
|
private m_attrs;
|
|
36
|
+
private m_style;
|
|
36
37
|
constructor(tag: string);
|
|
37
38
|
/**
|
|
38
39
|
* render the item
|
|
@@ -61,6 +62,7 @@ declare abstract class SVGItem {
|
|
|
61
62
|
* @returns this
|
|
62
63
|
*/
|
|
63
64
|
attr(name: string, value: string): this;
|
|
65
|
+
style(name: string, value: string): this;
|
|
64
66
|
/**
|
|
65
67
|
* add a class
|
|
66
68
|
* @param name class name to add
|
|
@@ -70,6 +72,10 @@ declare abstract class SVGItem {
|
|
|
70
72
|
*
|
|
71
73
|
*/
|
|
72
74
|
renderAttrs(): string;
|
|
75
|
+
/**
|
|
76
|
+
*
|
|
77
|
+
*/
|
|
78
|
+
renderStyle(): string;
|
|
73
79
|
renderContent(): string;
|
|
74
80
|
}
|
|
75
81
|
/**
|
package/lib/svgcomponent.js
CHANGED
|
@@ -30,6 +30,8 @@
|
|
|
30
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
31
|
exports.SVGComponent = exports.SVGPathBuilder = void 0;
|
|
32
32
|
const component_1 = require("./component");
|
|
33
|
+
const tools_1 = require("./tools");
|
|
34
|
+
const reNumber = /^-?\d+(\.\d+)?$/;
|
|
33
35
|
// degrees to radian
|
|
34
36
|
function d2r(d) {
|
|
35
37
|
return d * Math.PI / 180.0;
|
|
@@ -61,16 +63,18 @@ function clean(a, ...b) {
|
|
|
61
63
|
class SVGItem {
|
|
62
64
|
m_tag;
|
|
63
65
|
m_attrs;
|
|
66
|
+
m_style;
|
|
64
67
|
constructor(tag) {
|
|
65
68
|
this.m_tag = tag;
|
|
66
69
|
this.m_attrs = new Map();
|
|
70
|
+
this.m_style = new Map();
|
|
67
71
|
}
|
|
68
72
|
/**
|
|
69
73
|
* render the item
|
|
70
74
|
* @returns
|
|
71
75
|
*/
|
|
72
76
|
render() {
|
|
73
|
-
return `<${this.m_tag} ${this.renderAttrs()}>${this.renderContent()}</${this.m_tag}>`;
|
|
77
|
+
return `<${this.m_tag} ${this.renderAttrs()} ${this.renderStyle()}>${this.renderContent()}</${this.m_tag}>`;
|
|
74
78
|
}
|
|
75
79
|
/**
|
|
76
80
|
* change the stroke color
|
|
@@ -109,6 +113,16 @@ class SVGItem {
|
|
|
109
113
|
this.m_attrs.set(name, value);
|
|
110
114
|
return this;
|
|
111
115
|
}
|
|
116
|
+
style(name, value) {
|
|
117
|
+
if (value === undefined) {
|
|
118
|
+
value = null;
|
|
119
|
+
}
|
|
120
|
+
else if (!component_1._x4_unitless[name] && ((0, tools_1.isNumber)(value) || reNumber.test(value))) {
|
|
121
|
+
value = value + 'px';
|
|
122
|
+
}
|
|
123
|
+
this.m_style.set(name, value);
|
|
124
|
+
return this;
|
|
125
|
+
}
|
|
112
126
|
/**
|
|
113
127
|
* add a class
|
|
114
128
|
* @param name class name to add
|
|
@@ -122,12 +136,28 @@ class SVGItem {
|
|
|
122
136
|
*
|
|
123
137
|
*/
|
|
124
138
|
renderAttrs() {
|
|
139
|
+
if (!this.m_attrs.size) {
|
|
140
|
+
return "";
|
|
141
|
+
}
|
|
125
142
|
let result = '';
|
|
126
143
|
this.m_attrs.forEach((v, k) => {
|
|
127
144
|
result += ` ${k} = "${v}"`;
|
|
128
145
|
});
|
|
129
146
|
return result;
|
|
130
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
*
|
|
150
|
+
*/
|
|
151
|
+
renderStyle() {
|
|
152
|
+
if (!this.m_style.size) {
|
|
153
|
+
return "";
|
|
154
|
+
}
|
|
155
|
+
let result = 'style="';
|
|
156
|
+
this.m_style.forEach((v, k) => {
|
|
157
|
+
result += `${k}:${v};`;
|
|
158
|
+
});
|
|
159
|
+
return result + '"';
|
|
160
|
+
}
|
|
131
161
|
renderContent() {
|
|
132
162
|
return '';
|
|
133
163
|
}
|
package/lib/x4.css
CHANGED
package/package.json
CHANGED
package/src/component.ts
CHANGED
|
@@ -67,7 +67,7 @@ const _x4_el_store = Symbol();
|
|
|
67
67
|
const _x4_el_sym = Symbol();
|
|
68
68
|
|
|
69
69
|
/** @ignore properties without 'px' unit */
|
|
70
|
-
const _x4_unitless = {
|
|
70
|
+
export const _x4_unitless = {
|
|
71
71
|
animationIterationCount: 1, borderImageOutset: 1, borderImageSlice: 1, borderImageWidth: 1, boxFlex: 1, boxFlexGroup: 1,
|
|
72
72
|
boxOrdinalGroup: 1, columnCount: 1, flex: 1, flexGrow: 1, flexPositive: 1, flexShrink: 1, flexNegative: 1, flexOrder: 1,
|
|
73
73
|
gridRow: 1, gridColumn: 1, fontWeight: 1, lineClamp: 1, lineHeight: 1, opacity: 1, order: 1, orphans: 1, tabSize: 1, widows: 1,
|
package/src/formatters.ts
CHANGED
|
@@ -74,7 +74,9 @@ export function money_formatter(input: any): string {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
let val: number = roundTo(typeof (input) == 'string' ? parseFloat(input) : input, 2);
|
|
77
|
-
if (val
|
|
77
|
+
if (Object.is(val, -0.00)) {
|
|
78
|
+
val = 0.00;
|
|
79
|
+
}
|
|
78
80
|
|
|
79
81
|
let res = moneyFmt.format(val);
|
|
80
82
|
return res;
|
package/src/svgcomponent.ts
CHANGED
|
@@ -27,8 +27,10 @@
|
|
|
27
27
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
28
28
|
**/
|
|
29
29
|
|
|
30
|
-
import { Component, CProps } from './component'
|
|
30
|
+
import { Component, CProps, _x4_unitless } from './component'
|
|
31
|
+
import { isNumber } from "./tools"
|
|
31
32
|
|
|
33
|
+
const reNumber = /^-?\d+(\.\d+)?$/;
|
|
32
34
|
|
|
33
35
|
// degrees to radian
|
|
34
36
|
function d2r( d: number ): number {
|
|
@@ -69,10 +71,12 @@ function clean( a, ...b ) {
|
|
|
69
71
|
abstract class SVGItem {
|
|
70
72
|
private m_tag: string
|
|
71
73
|
private m_attrs: Map<string,string>;
|
|
74
|
+
private m_style: Map<string,string>;
|
|
72
75
|
|
|
73
76
|
constructor( tag: string ) {
|
|
74
77
|
this.m_tag = tag;
|
|
75
78
|
this.m_attrs = new Map( );
|
|
79
|
+
this.m_style = new Map( );
|
|
76
80
|
}
|
|
77
81
|
|
|
78
82
|
/**
|
|
@@ -80,7 +84,7 @@ abstract class SVGItem {
|
|
|
80
84
|
* @returns
|
|
81
85
|
*/
|
|
82
86
|
render( ) : string {
|
|
83
|
-
return `<${this.m_tag} ${this.renderAttrs()}>${this.renderContent( )}</${this.m_tag}>`;
|
|
87
|
+
return `<${this.m_tag} ${this.renderAttrs()} ${this.renderStyle()}>${this.renderContent( )}</${this.m_tag}>`;
|
|
84
88
|
}
|
|
85
89
|
|
|
86
90
|
/**
|
|
@@ -127,6 +131,19 @@ abstract class SVGItem {
|
|
|
127
131
|
return this;
|
|
128
132
|
}
|
|
129
133
|
|
|
134
|
+
style( name: string, value: string ) : this {
|
|
135
|
+
|
|
136
|
+
if (value === undefined) {
|
|
137
|
+
value = null;
|
|
138
|
+
}
|
|
139
|
+
else if (!_x4_unitless[name] && (isNumber(value) || reNumber.test(value))) {
|
|
140
|
+
value = value + 'px';
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
this.m_style.set( name, value );
|
|
144
|
+
return this;
|
|
145
|
+
}
|
|
146
|
+
|
|
130
147
|
/**
|
|
131
148
|
* add a class
|
|
132
149
|
* @param name class name to add
|
|
@@ -142,13 +159,36 @@ abstract class SVGItem {
|
|
|
142
159
|
*
|
|
143
160
|
*/
|
|
144
161
|
|
|
145
|
-
renderAttrs( ) {
|
|
162
|
+
renderAttrs( ): string {
|
|
163
|
+
if( !this.m_attrs.size ) {
|
|
164
|
+
return "";
|
|
165
|
+
}
|
|
166
|
+
|
|
146
167
|
let result = '';
|
|
147
168
|
this.m_attrs.forEach( (v,k) => {
|
|
148
169
|
result += ` ${k} = "${v}"`
|
|
149
170
|
});
|
|
171
|
+
|
|
150
172
|
return result;
|
|
151
173
|
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
*
|
|
177
|
+
*/
|
|
178
|
+
|
|
179
|
+
renderStyle( ): string {
|
|
180
|
+
|
|
181
|
+
if( !this.m_style.size ) {
|
|
182
|
+
return "";
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
let result = 'style="';
|
|
186
|
+
this.m_style.forEach( (v,k) => {
|
|
187
|
+
result += `${k}:${v};`
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
return result+'"';
|
|
191
|
+
}
|
|
152
192
|
|
|
153
193
|
renderContent( ): string {
|
|
154
194
|
return '';
|