@mulsense/xnew 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/addons/xmatter.js +0 -3
- package/dist/addons/xmatter.mjs +0 -3
- package/dist/addons/xpixi.d.ts +6 -4
- package/dist/addons/xpixi.js +0 -23
- package/dist/addons/xpixi.mjs +0 -23
- package/dist/addons/xrapier2d.js +1 -4
- package/dist/addons/xrapier2d.mjs +1 -4
- package/dist/addons/xrapier3d.js +2 -5
- package/dist/addons/xrapier3d.mjs +2 -5
- package/dist/addons/xthree.d.ts +11 -4
- package/dist/addons/xthree.js +4 -7
- package/dist/addons/xthree.mjs +4 -7
- package/dist/xnew.d.ts +14 -46
- package/dist/xnew.js +107 -187
- package/dist/xnew.mjs +107 -187
- package/package.json +8 -6
package/dist/xnew.js
CHANGED
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
//----------------------------------------------------------------------------------------------------
|
|
105
105
|
// ticker
|
|
106
106
|
//----------------------------------------------------------------------------------------------------
|
|
107
|
-
class
|
|
107
|
+
class AnimationTicker {
|
|
108
108
|
constructor(callback, fps = 60) {
|
|
109
109
|
const self = this;
|
|
110
110
|
this.id = null;
|
|
@@ -135,7 +135,7 @@
|
|
|
135
135
|
this.counter = 0;
|
|
136
136
|
this.offset = 0.0;
|
|
137
137
|
this.status = 0;
|
|
138
|
-
this.ticker = new
|
|
138
|
+
this.ticker = new AnimationTicker((time) => {
|
|
139
139
|
var _a, _b;
|
|
140
140
|
let p = Math.min(this.elapsed() / this.options.duration, 1.0);
|
|
141
141
|
if (this.options.easing === 'ease-out') {
|
|
@@ -206,7 +206,7 @@
|
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
-
const SYSTEM_EVENTS = ['start', '
|
|
209
|
+
const SYSTEM_EVENTS = ['start', 'update', 'render', 'stop', 'finalize'];
|
|
210
210
|
|
|
211
211
|
class EventManager {
|
|
212
212
|
constructor() {
|
|
@@ -272,12 +272,12 @@
|
|
|
272
272
|
};
|
|
273
273
|
}
|
|
274
274
|
resize(props) {
|
|
275
|
-
const observer = new ResizeObserver(
|
|
275
|
+
const observer = new ResizeObserver((entries) => {
|
|
276
276
|
for (const entry of entries) {
|
|
277
277
|
props.listener({ type: 'resize' });
|
|
278
278
|
break;
|
|
279
279
|
}
|
|
280
|
-
})
|
|
280
|
+
});
|
|
281
281
|
observer.observe(props.element);
|
|
282
282
|
return () => {
|
|
283
283
|
observer.unobserve(props.element);
|
|
@@ -416,7 +416,7 @@
|
|
|
416
416
|
const element = props.element;
|
|
417
417
|
const options = props.options;
|
|
418
418
|
const dragstart = ({ event, position }) => {
|
|
419
|
-
map.set(event.pointerId,
|
|
419
|
+
map.set(event.pointerId, position);
|
|
420
420
|
isActive = map.size === 2 ? true : false;
|
|
421
421
|
if (isActive === true && props.type === 'gesturestart') {
|
|
422
422
|
props.listener({ event, type: props.type });
|
|
@@ -452,11 +452,11 @@
|
|
|
452
452
|
map.set(event.pointerId, position);
|
|
453
453
|
};
|
|
454
454
|
const dragend = ({ event }) => {
|
|
455
|
-
|
|
455
|
+
map.delete(event.pointerId);
|
|
456
|
+
if (isActive === true && props.type === 'gestureend') {
|
|
456
457
|
props.listener({ event, type: props.type, scale: 1.0 });
|
|
457
458
|
}
|
|
458
459
|
isActive = false;
|
|
459
|
-
map.delete(event.pointerId);
|
|
460
460
|
};
|
|
461
461
|
this.add({ element, options, type: 'dragstart', listener: dragstart });
|
|
462
462
|
this.add({ element, options, type: 'dragmove', listener: dragmove });
|
|
@@ -598,8 +598,8 @@
|
|
|
598
598
|
}
|
|
599
599
|
static initialize(unit, anchor) {
|
|
600
600
|
var _a, _b;
|
|
601
|
-
const backup = Unit.
|
|
602
|
-
Unit.
|
|
601
|
+
const backup = Unit.currentUnit;
|
|
602
|
+
Unit.currentUnit = unit;
|
|
603
603
|
unit._ = Object.assign(unit._, {
|
|
604
604
|
currentElement: unit._.baseElement,
|
|
605
605
|
currentContext: unit._.baseContext,
|
|
@@ -615,7 +615,7 @@
|
|
|
615
615
|
components: [],
|
|
616
616
|
listeners: new MapMap(),
|
|
617
617
|
defines: {},
|
|
618
|
-
systems: { start: [],
|
|
618
|
+
systems: { start: [], update: [], render: [], stop: [], finalize: [] },
|
|
619
619
|
eventManager: new EventManager(),
|
|
620
620
|
});
|
|
621
621
|
// nest html element
|
|
@@ -626,13 +626,13 @@
|
|
|
626
626
|
Unit.extend(unit, unit._.baseComponent, unit._.props);
|
|
627
627
|
// whether the unit promise was resolved
|
|
628
628
|
Promise.all(unit._.promises.map(p => p.promise)).then(() => unit._.state = 'initialized');
|
|
629
|
-
Unit.
|
|
629
|
+
Unit.currentUnit = backup;
|
|
630
630
|
}
|
|
631
631
|
static finalize(unit) {
|
|
632
632
|
if (unit._.state !== 'finalized' && unit._.state !== 'finalizing') {
|
|
633
633
|
unit._.state = 'finalizing';
|
|
634
634
|
unit._.children.forEach((child) => child.finalize());
|
|
635
|
-
unit._.systems.finalize.forEach((
|
|
635
|
+
unit._.systems.finalize.forEach(({ execute }) => execute());
|
|
636
636
|
unit.off();
|
|
637
637
|
unit._.components.forEach((component) => Unit.component2units.delete(component, unit));
|
|
638
638
|
if (unit._.elements.length > 0) {
|
|
@@ -712,7 +712,7 @@
|
|
|
712
712
|
if (unit._.state === 'initialized' || unit._.state === 'stopped') {
|
|
713
713
|
unit._.state = 'started';
|
|
714
714
|
unit._.children.forEach((child) => Unit.start(child));
|
|
715
|
-
unit._.systems.start.forEach((
|
|
715
|
+
unit._.systems.start.forEach(({ execute }) => execute());
|
|
716
716
|
}
|
|
717
717
|
else if (unit._.state === 'started') {
|
|
718
718
|
unit._.children.forEach((child) => Unit.start(child));
|
|
@@ -722,31 +722,31 @@
|
|
|
722
722
|
if (unit._.state === 'started') {
|
|
723
723
|
unit._.state = 'stopped';
|
|
724
724
|
unit._.children.forEach((child) => Unit.stop(child));
|
|
725
|
-
unit._.systems.stop.forEach((
|
|
725
|
+
unit._.systems.stop.forEach(({ execute }) => execute());
|
|
726
726
|
}
|
|
727
727
|
}
|
|
728
728
|
static update(unit) {
|
|
729
|
-
if (unit._.state === 'started'
|
|
729
|
+
if (unit._.state === 'started') {
|
|
730
730
|
unit._.children.forEach((child) => Unit.update(child));
|
|
731
|
-
unit._.systems.update.forEach((
|
|
731
|
+
unit._.systems.update.forEach(({ execute }) => execute());
|
|
732
732
|
}
|
|
733
733
|
}
|
|
734
|
-
static
|
|
735
|
-
if (unit._.state === 'started') {
|
|
736
|
-
unit._.children.forEach((child) => Unit.
|
|
737
|
-
unit._.systems.
|
|
734
|
+
static render(unit) {
|
|
735
|
+
if (unit._.state === 'started' || unit._.state === 'started' || unit._.state === 'stopped') {
|
|
736
|
+
unit._.children.forEach((child) => Unit.render(child));
|
|
737
|
+
unit._.systems.render.forEach(({ execute }) => execute());
|
|
738
738
|
}
|
|
739
739
|
}
|
|
740
740
|
static reset() {
|
|
741
|
-
var _a
|
|
742
|
-
(_a = Unit.
|
|
743
|
-
Unit.
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
Unit.
|
|
747
|
-
Unit.
|
|
748
|
-
Unit.update(Unit.root);
|
|
741
|
+
var _a;
|
|
742
|
+
(_a = Unit.rootUnit) === null || _a === void 0 ? void 0 : _a.finalize();
|
|
743
|
+
Unit.currentUnit = Unit.rootUnit = new Unit(null, null);
|
|
744
|
+
const ticker = new AnimationTicker(() => {
|
|
745
|
+
Unit.start(Unit.rootUnit);
|
|
746
|
+
Unit.update(Unit.rootUnit);
|
|
747
|
+
Unit.render(Unit.rootUnit);
|
|
749
748
|
});
|
|
749
|
+
Unit.rootUnit.on('finalize', () => ticker.clear());
|
|
750
750
|
}
|
|
751
751
|
static wrap(unit, listener) {
|
|
752
752
|
const snapshot = Unit.snapshot(unit);
|
|
@@ -756,25 +756,27 @@
|
|
|
756
756
|
if (snapshot.unit._.state === 'finalized') {
|
|
757
757
|
return;
|
|
758
758
|
}
|
|
759
|
-
const
|
|
759
|
+
const currentUnit = Unit.currentUnit;
|
|
760
760
|
const backup = Unit.snapshot(snapshot.unit);
|
|
761
761
|
try {
|
|
762
|
-
Unit.
|
|
762
|
+
Unit.currentUnit = snapshot.unit;
|
|
763
763
|
snapshot.unit._.currentContext = snapshot.context;
|
|
764
764
|
snapshot.unit._.currentElement = snapshot.element;
|
|
765
|
+
snapshot.unit._.currentComponent = snapshot.component;
|
|
765
766
|
return func(...args);
|
|
766
767
|
}
|
|
767
768
|
catch (error) {
|
|
768
769
|
throw error;
|
|
769
770
|
}
|
|
770
771
|
finally {
|
|
771
|
-
Unit.
|
|
772
|
+
Unit.currentUnit = currentUnit;
|
|
772
773
|
snapshot.unit._.currentContext = backup.context;
|
|
773
774
|
snapshot.unit._.currentElement = backup.element;
|
|
775
|
+
snapshot.unit._.currentComponent = backup.component;
|
|
774
776
|
}
|
|
775
777
|
}
|
|
776
778
|
static snapshot(unit) {
|
|
777
|
-
return { unit, context: unit._.currentContext, element: unit._.currentElement };
|
|
779
|
+
return { unit, context: unit._.currentContext, element: unit._.currentElement, component: unit._.currentComponent };
|
|
778
780
|
}
|
|
779
781
|
static context(unit, key, value) {
|
|
780
782
|
if (value !== undefined) {
|
|
@@ -792,43 +794,46 @@
|
|
|
792
794
|
return [...((_a = Unit.component2units.get(component)) !== null && _a !== void 0 ? _a : [])];
|
|
793
795
|
}
|
|
794
796
|
on(type, listener, options) {
|
|
795
|
-
type.trim().split(/\s+/)
|
|
796
|
-
|
|
797
|
-
this._.systems[type].push(listener);
|
|
798
|
-
}
|
|
799
|
-
if (this._.listeners.has(type, listener) === false) {
|
|
800
|
-
const execute = Unit.wrap(Unit.current, listener);
|
|
801
|
-
this._.listeners.set(type, listener, { element: this.element, execute });
|
|
802
|
-
Unit.type2units.add(type, this);
|
|
803
|
-
if (/^[A-Za-z]/.test(type)) {
|
|
804
|
-
this._.eventManager.add({ element: this.element, type, listener: execute, options });
|
|
805
|
-
}
|
|
806
|
-
}
|
|
807
|
-
});
|
|
797
|
+
const types = type.trim().split(/\s+/);
|
|
798
|
+
types.forEach((type) => Unit.on(this, type, listener, options));
|
|
808
799
|
}
|
|
809
800
|
off(type, listener) {
|
|
810
801
|
const types = typeof type === 'string' ? type.trim().split(/\s+/) : [...this._.listeners.keys()];
|
|
811
|
-
types.forEach((type) =>
|
|
812
|
-
|
|
813
|
-
|
|
802
|
+
types.forEach((type) => Unit.off(this, type, listener));
|
|
803
|
+
}
|
|
804
|
+
static on(unit, type, listener, options) {
|
|
805
|
+
if (SYSTEM_EVENTS.includes(type)) {
|
|
806
|
+
unit._.systems[type].push({ listener, execute: Unit.wrap(Unit.currentUnit, listener) });
|
|
807
|
+
}
|
|
808
|
+
if (unit._.listeners.has(type, listener) === false) {
|
|
809
|
+
const execute = Unit.wrap(Unit.currentUnit, listener);
|
|
810
|
+
unit._.listeners.set(type, listener, { element: unit.element, component: unit._.currentComponent, execute });
|
|
811
|
+
Unit.type2units.add(type, unit);
|
|
812
|
+
if (/^[A-Za-z]/.test(type)) {
|
|
813
|
+
unit._.eventManager.add({ element: unit.element, type, listener: execute, options });
|
|
814
814
|
}
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
static off(unit, type, listener) {
|
|
818
|
+
if (SYSTEM_EVENTS.includes(type)) {
|
|
819
|
+
unit._.systems[type] = unit._.systems[type].filter(({ listener: lis }) => listener ? lis !== listener : false);
|
|
820
|
+
}
|
|
821
|
+
(listener ? [listener] : [...unit._.listeners.keys(type)]).forEach((listener) => {
|
|
822
|
+
const item = unit._.listeners.get(type, listener);
|
|
823
|
+
if (item === undefined)
|
|
824
|
+
return;
|
|
825
|
+
unit._.listeners.delete(type, listener);
|
|
826
|
+
if (/^[A-Za-z]/.test(type)) {
|
|
827
|
+
unit._.eventManager.remove({ type, listener: item.execute });
|
|
826
828
|
}
|
|
827
829
|
});
|
|
830
|
+
if (unit._.listeners.has(type) === false) {
|
|
831
|
+
Unit.type2units.delete(type, unit);
|
|
832
|
+
}
|
|
828
833
|
}
|
|
829
834
|
static emit(type, ...args) {
|
|
830
835
|
var _a, _b;
|
|
831
|
-
const current = Unit.
|
|
836
|
+
const current = Unit.currentUnit;
|
|
832
837
|
if (type[0] === '+') {
|
|
833
838
|
(_a = Unit.type2units.get(type)) === null || _a === void 0 ? void 0 : _a.forEach((unit) => {
|
|
834
839
|
var _a;
|
|
@@ -843,6 +848,7 @@
|
|
|
843
848
|
}
|
|
844
849
|
}
|
|
845
850
|
}
|
|
851
|
+
Unit.currentComponent = () => { };
|
|
846
852
|
Unit.component2units = new MapSet();
|
|
847
853
|
//----------------------------------------------------------------------------------------------------
|
|
848
854
|
// event
|
|
@@ -857,15 +863,15 @@
|
|
|
857
863
|
this.component = component;
|
|
858
864
|
}
|
|
859
865
|
then(callback) {
|
|
860
|
-
this.promise = this.promise.then(Unit.wrap(Unit.
|
|
866
|
+
this.promise = this.promise.then(Unit.wrap(Unit.currentUnit, callback));
|
|
861
867
|
return this;
|
|
862
868
|
}
|
|
863
869
|
catch(callback) {
|
|
864
|
-
this.promise = this.promise.catch(Unit.wrap(Unit.
|
|
870
|
+
this.promise = this.promise.catch(Unit.wrap(Unit.currentUnit, callback));
|
|
865
871
|
return this;
|
|
866
872
|
}
|
|
867
873
|
finally(callback) {
|
|
868
|
-
this.promise = this.promise.finally(Unit.wrap(Unit.
|
|
874
|
+
this.promise = this.promise.finally(Unit.wrap(Unit.currentUnit, callback));
|
|
869
875
|
return this;
|
|
870
876
|
}
|
|
871
877
|
}
|
|
@@ -875,7 +881,7 @@
|
|
|
875
881
|
class UnitTimer {
|
|
876
882
|
constructor(options) {
|
|
877
883
|
this.stack = [];
|
|
878
|
-
this.unit = new Unit(Unit.
|
|
884
|
+
this.unit = new Unit(Unit.currentUnit, UnitTimer.Component, Object.assign({ snapshot: Unit.snapshot(Unit.currentUnit) }, options));
|
|
879
885
|
}
|
|
880
886
|
clear() {
|
|
881
887
|
this.stack = [];
|
|
@@ -895,19 +901,19 @@
|
|
|
895
901
|
}
|
|
896
902
|
static execute(timer, options) {
|
|
897
903
|
if (timer.unit._.state === 'finalized') {
|
|
898
|
-
timer.unit = new Unit(Unit.
|
|
904
|
+
timer.unit = new Unit(Unit.currentUnit, UnitTimer.Component, Object.assign({ snapshot: Unit.snapshot(Unit.currentUnit) }, options));
|
|
899
905
|
}
|
|
900
906
|
else if (timer.stack.length === 0) {
|
|
901
|
-
timer.stack.push(Object.assign({ snapshot: Unit.snapshot(Unit.
|
|
907
|
+
timer.stack.push(Object.assign({ snapshot: Unit.snapshot(Unit.currentUnit) }, options));
|
|
902
908
|
timer.unit.on('finalize', () => { UnitTimer.next(timer); });
|
|
903
909
|
}
|
|
904
910
|
else {
|
|
905
|
-
timer.stack.push(Object.assign({ snapshot: Unit.snapshot(Unit.
|
|
911
|
+
timer.stack.push(Object.assign({ snapshot: Unit.snapshot(Unit.currentUnit) }, options));
|
|
906
912
|
}
|
|
907
913
|
}
|
|
908
914
|
static next(timer) {
|
|
909
915
|
if (timer.stack.length > 0) {
|
|
910
|
-
timer.unit = new Unit(Unit.
|
|
916
|
+
timer.unit = new Unit(Unit.currentUnit, UnitTimer.Component, timer.stack.shift());
|
|
911
917
|
timer.unit.on('finalize', () => { UnitTimer.next(timer); });
|
|
912
918
|
}
|
|
913
919
|
}
|
|
@@ -934,10 +940,10 @@
|
|
|
934
940
|
}
|
|
935
941
|
|
|
936
942
|
const xnew$1 = Object.assign(function (...args) {
|
|
937
|
-
if (Unit.
|
|
943
|
+
if (Unit.rootUnit === undefined) {
|
|
938
944
|
Unit.reset();
|
|
939
945
|
}
|
|
940
|
-
return new Unit(Unit.
|
|
946
|
+
return new Unit(Unit.currentUnit, ...args);
|
|
941
947
|
}, {
|
|
942
948
|
/**
|
|
943
949
|
* Creates a nested HTML/SVG element within the current component
|
|
@@ -950,7 +956,7 @@
|
|
|
950
956
|
*/
|
|
951
957
|
nest(tag) {
|
|
952
958
|
try {
|
|
953
|
-
return Unit.nest(Unit.
|
|
959
|
+
return Unit.nest(Unit.currentUnit, tag);
|
|
954
960
|
}
|
|
955
961
|
catch (error) {
|
|
956
962
|
console.error('xnew.nest(tag: string): ', error);
|
|
@@ -968,7 +974,7 @@
|
|
|
968
974
|
*/
|
|
969
975
|
extend(component, props) {
|
|
970
976
|
try {
|
|
971
|
-
return Unit.extend(Unit.
|
|
977
|
+
return Unit.extend(Unit.currentUnit, component, props);
|
|
972
978
|
}
|
|
973
979
|
catch (error) {
|
|
974
980
|
console.error('xnew.extend(component: Function, props?: Object): ', error);
|
|
@@ -989,7 +995,7 @@
|
|
|
989
995
|
*/
|
|
990
996
|
context(key, value = undefined) {
|
|
991
997
|
try {
|
|
992
|
-
return Unit.context(Unit.
|
|
998
|
+
return Unit.context(Unit.currentUnit, key, value);
|
|
993
999
|
}
|
|
994
1000
|
catch (error) {
|
|
995
1001
|
console.error('xnew.context(key: string, value?: any): ', error);
|
|
@@ -1005,9 +1011,9 @@
|
|
|
1005
1011
|
*/
|
|
1006
1012
|
promise(promise) {
|
|
1007
1013
|
try {
|
|
1008
|
-
const component = Unit.
|
|
1009
|
-
Unit.
|
|
1010
|
-
return Unit.
|
|
1014
|
+
const component = Unit.currentUnit._.currentComponent;
|
|
1015
|
+
Unit.currentUnit._.promises.push(new UnitPromise(promise, component));
|
|
1016
|
+
return Unit.currentUnit._.promises[Unit.currentUnit._.promises.length - 1];
|
|
1011
1017
|
}
|
|
1012
1018
|
catch (error) {
|
|
1013
1019
|
console.error('xnew.promise(promise: Promise<any>): ', error);
|
|
@@ -1023,8 +1029,8 @@
|
|
|
1023
1029
|
*/
|
|
1024
1030
|
then(callback) {
|
|
1025
1031
|
try {
|
|
1026
|
-
const component = Unit.
|
|
1027
|
-
const promises = Unit.
|
|
1032
|
+
const component = Unit.currentUnit._.currentComponent;
|
|
1033
|
+
const promises = Unit.currentUnit._.promises;
|
|
1028
1034
|
return new UnitPromise(Promise.all(promises.map(p => p.promise)), null)
|
|
1029
1035
|
.then((results) => {
|
|
1030
1036
|
callback(results.filter((_result, index) => promises[index].component !== null && promises[index].component === component));
|
|
@@ -1044,7 +1050,7 @@
|
|
|
1044
1050
|
*/
|
|
1045
1051
|
catch(callback) {
|
|
1046
1052
|
try {
|
|
1047
|
-
const promises = Unit.
|
|
1053
|
+
const promises = Unit.currentUnit._.promises;
|
|
1048
1054
|
return new UnitPromise(Promise.all(promises.map(p => p.promise)), null)
|
|
1049
1055
|
.catch(callback);
|
|
1050
1056
|
}
|
|
@@ -1062,7 +1068,7 @@
|
|
|
1062
1068
|
*/
|
|
1063
1069
|
finally(callback) {
|
|
1064
1070
|
try {
|
|
1065
|
-
const promises = Unit.
|
|
1071
|
+
const promises = Unit.currentUnit._.promises;
|
|
1066
1072
|
return new UnitPromise(Promise.all(promises.map(p => p.promise)), null)
|
|
1067
1073
|
.finally(callback);
|
|
1068
1074
|
}
|
|
@@ -1081,7 +1087,7 @@
|
|
|
1081
1087
|
* }), 1000)
|
|
1082
1088
|
*/
|
|
1083
1089
|
scope(callback) {
|
|
1084
|
-
const snapshot = Unit.snapshot(Unit.
|
|
1090
|
+
const snapshot = Unit.snapshot(Unit.currentUnit);
|
|
1085
1091
|
return (...args) => Unit.scope(snapshot, callback, ...args);
|
|
1086
1092
|
},
|
|
1087
1093
|
/**
|
|
@@ -1152,73 +1158,54 @@
|
|
|
1152
1158
|
return new UnitTimer({ transition, duration, easing, iterations: 1 });
|
|
1153
1159
|
},
|
|
1154
1160
|
protect() {
|
|
1155
|
-
Unit.
|
|
1161
|
+
Unit.currentUnit._.protected = true;
|
|
1156
1162
|
}
|
|
1157
1163
|
});
|
|
1158
1164
|
|
|
1159
|
-
function AccordionFrame(
|
|
1165
|
+
function AccordionFrame(unit, { open = false, duration = 200, easing = 'ease' } = {}) {
|
|
1160
1166
|
const internal = xnew$1((internal) => {
|
|
1161
1167
|
return {
|
|
1162
|
-
frame, open, rate: 0.0,
|
|
1163
|
-
|
|
1168
|
+
frame: unit, open, rate: 0.0,
|
|
1169
|
+
transition(rate) {
|
|
1170
|
+
xnew$1.emit('-transition', { rate });
|
|
1171
|
+
}
|
|
1164
1172
|
};
|
|
1165
1173
|
});
|
|
1166
1174
|
xnew$1.context('xnew.accordionframe', internal);
|
|
1167
|
-
internal.on('-transition', ({ rate }) =>
|
|
1168
|
-
|
|
1175
|
+
internal.on('-transition', ({ rate }) => {
|
|
1176
|
+
internal.rate = rate;
|
|
1177
|
+
xnew$1.emit('-transition', { rate });
|
|
1178
|
+
});
|
|
1179
|
+
xnew$1.timeout(() => {
|
|
1180
|
+
internal.transition(open ? 1.0 : 0.0);
|
|
1181
|
+
});
|
|
1169
1182
|
return {
|
|
1170
1183
|
toggle() {
|
|
1171
1184
|
if (internal.rate === 1.0) {
|
|
1172
|
-
|
|
1185
|
+
unit.close();
|
|
1173
1186
|
}
|
|
1174
1187
|
else if (internal.rate === 0.0) {
|
|
1175
|
-
|
|
1188
|
+
unit.open();
|
|
1176
1189
|
}
|
|
1177
1190
|
},
|
|
1178
1191
|
open() {
|
|
1179
1192
|
if (internal.rate === 0.0) {
|
|
1180
|
-
xnew$1.transition((x) => internal.
|
|
1193
|
+
xnew$1.transition((x) => internal.transition(x), duration, easing);
|
|
1181
1194
|
}
|
|
1182
1195
|
},
|
|
1183
1196
|
close() {
|
|
1184
1197
|
if (internal.rate === 1.0) {
|
|
1185
|
-
xnew$1.transition((x) => internal.
|
|
1198
|
+
xnew$1.transition((x) => internal.transition(1.0 - x), duration, easing);
|
|
1186
1199
|
}
|
|
1187
1200
|
}
|
|
1188
1201
|
};
|
|
1189
1202
|
}
|
|
1190
|
-
function
|
|
1191
|
-
const internal = xnew$1.context('xnew.accordionframe');
|
|
1192
|
-
xnew$1.nest('<button style="display: flex; align-items: center; margin: 0; padding: 0; width: 100%; text-align: left; border: none; font: inherit; color: inherit; background: none; cursor: pointer;">');
|
|
1193
|
-
header.on('click', () => internal.frame.toggle());
|
|
1194
|
-
}
|
|
1195
|
-
function AccordionBullet(bullet, { type = 'arrow' } = {}) {
|
|
1196
|
-
const internal = xnew$1.context('xnew.accordionframe');
|
|
1197
|
-
xnew$1.nest('<div style="display:inline-block; position: relative; width: 0.55em; margin: 0 0.3em;">');
|
|
1198
|
-
if (type === 'arrow') {
|
|
1199
|
-
const arrow = xnew$1(`<div style="width: 100%; height: 0.55em; border-right: 0.12em solid currentColor; border-bottom: 0.12em solid currentColor; box-sizing: border-box; transform-origin: center;">`);
|
|
1200
|
-
arrow.element.style.transform = `rotate(${internal.rate * 90 - 45}deg)`;
|
|
1201
|
-
internal.on('-transition', ({ rate }) => {
|
|
1202
|
-
arrow.element.style.transform = `rotate(${rate * 90 - 45}deg)`;
|
|
1203
|
-
});
|
|
1204
|
-
}
|
|
1205
|
-
else if (type === 'plusminus') {
|
|
1206
|
-
const line1 = xnew$1(`<div style="position: absolute; width: 100%; border-top: 0.06em solid currentColor; border-bottom: 0.06em solid currentColor; box-sizing: border-box; transform-origin: center;">`);
|
|
1207
|
-
const line2 = xnew$1(`<div style="position: absolute; width: 100%; border-top: 0.06em solid currentColor; border-bottom: 0.06em solid currentColor; box-sizing: border-box; transform-origin: center;">`);
|
|
1208
|
-
line2.element.style.transform = `rotate(90deg)`;
|
|
1209
|
-
line2.element.style.opacity = `${1.0 - internal.rate}`;
|
|
1210
|
-
internal.on('-transition', ({ rate }) => {
|
|
1211
|
-
line1.element.style.transform = `rotate(${90 + rate * 90}deg)`;
|
|
1212
|
-
line2.element.style.transform = `rotate(${rate * 180}deg)`;
|
|
1213
|
-
});
|
|
1214
|
-
}
|
|
1215
|
-
}
|
|
1216
|
-
function AccordionContent(content, {} = {}) {
|
|
1203
|
+
function AccordionContent(unit, {} = {}) {
|
|
1217
1204
|
const internal = xnew$1.context('xnew.accordionframe');
|
|
1218
1205
|
xnew$1.nest(`<div style="display: ${internal.open ? 'block' : 'none'};">`);
|
|
1219
1206
|
xnew$1.nest('<div style="padding: 0; display: flex; flex-direction: column; box-sizing: border-box;">');
|
|
1220
1207
|
internal.on('-transition', ({ rate }) => {
|
|
1221
|
-
|
|
1208
|
+
unit.transition({ element: unit.element, rate });
|
|
1222
1209
|
});
|
|
1223
1210
|
return {
|
|
1224
1211
|
transition({ element, rate }) {
|
|
@@ -1317,68 +1304,6 @@
|
|
|
1317
1304
|
};
|
|
1318
1305
|
}
|
|
1319
1306
|
|
|
1320
|
-
function TabFrame(frame, { select } = {}) {
|
|
1321
|
-
const internal = xnew$1((internal) => {
|
|
1322
|
-
const buttons = new Map();
|
|
1323
|
-
const contents = new Map();
|
|
1324
|
-
return {
|
|
1325
|
-
frame, buttons, contents,
|
|
1326
|
-
emit(type, ...args) { xnew$1.emit(type, ...args); }
|
|
1327
|
-
};
|
|
1328
|
-
});
|
|
1329
|
-
xnew$1.context('xnew.tabframe', internal);
|
|
1330
|
-
xnew$1.timeout(() => internal.emit('-select', { key: select !== null && select !== void 0 ? select : [...internal.buttons.keys()][0] }));
|
|
1331
|
-
}
|
|
1332
|
-
function TabButton(button, { key } = {}) {
|
|
1333
|
-
const internal = xnew$1.context('xnew.tabframe');
|
|
1334
|
-
const div = xnew$1.nest('<div>');
|
|
1335
|
-
key = key !== null && key !== void 0 ? key : (internal.buttons.size).toString();
|
|
1336
|
-
internal.buttons.set(key, button);
|
|
1337
|
-
button.on('click', () => {
|
|
1338
|
-
internal.emit('-select', { key });
|
|
1339
|
-
});
|
|
1340
|
-
internal.on('-select', ({ key }) => {
|
|
1341
|
-
const select = internal.buttons.get(key);
|
|
1342
|
-
if (select === button) {
|
|
1343
|
-
button.select({ element: div });
|
|
1344
|
-
}
|
|
1345
|
-
else {
|
|
1346
|
-
button.deselect({ element: div });
|
|
1347
|
-
}
|
|
1348
|
-
});
|
|
1349
|
-
return {
|
|
1350
|
-
select({ element }) {
|
|
1351
|
-
Object.assign(element.style, { opacity: 1.0, cursor: 'text' });
|
|
1352
|
-
},
|
|
1353
|
-
deselect({ element }) {
|
|
1354
|
-
Object.assign(element.style, { opacity: 0.6, cursor: 'pointer' });
|
|
1355
|
-
}
|
|
1356
|
-
};
|
|
1357
|
-
}
|
|
1358
|
-
function TabContent(content, { key } = {}) {
|
|
1359
|
-
const internal = xnew$1.context('xnew.tabframe');
|
|
1360
|
-
const div = xnew$1.nest('<div style="display: none;">');
|
|
1361
|
-
key = key !== null && key !== void 0 ? key : (internal.contents.size).toString();
|
|
1362
|
-
internal.contents.set(key, content);
|
|
1363
|
-
internal.on('-select', ({ key }) => {
|
|
1364
|
-
const select = internal.contents.get(key);
|
|
1365
|
-
if (select === content) {
|
|
1366
|
-
content.select({ element: div });
|
|
1367
|
-
}
|
|
1368
|
-
else {
|
|
1369
|
-
content.deselect({ element: div });
|
|
1370
|
-
}
|
|
1371
|
-
});
|
|
1372
|
-
return {
|
|
1373
|
-
select({ element }) {
|
|
1374
|
-
Object.assign(element.style, { display: 'block' });
|
|
1375
|
-
},
|
|
1376
|
-
deselect({ element }) {
|
|
1377
|
-
Object.assign(element.style, { display: 'none' });
|
|
1378
|
-
}
|
|
1379
|
-
};
|
|
1380
|
-
}
|
|
1381
|
-
|
|
1382
1307
|
function DragFrame(frame, { x = 0, y = 0 } = {}) {
|
|
1383
1308
|
const absolute = xnew$1.nest(`<div style="position: absolute; top: ${y}px; left: ${x}px;">`);
|
|
1384
1309
|
xnew$1.context('xnew.dragframe', { frame, absolute });
|
|
@@ -3472,12 +3397,7 @@
|
|
|
3472
3397
|
ModalFrame,
|
|
3473
3398
|
ModalContent,
|
|
3474
3399
|
AccordionFrame,
|
|
3475
|
-
AccordionHeader,
|
|
3476
|
-
AccordionBullet,
|
|
3477
3400
|
AccordionContent,
|
|
3478
|
-
TabFrame,
|
|
3479
|
-
TabButton,
|
|
3480
|
-
TabContent,
|
|
3481
3401
|
TextStream,
|
|
3482
3402
|
DragFrame,
|
|
3483
3403
|
DragTarget,
|