@vortexm/vjt 0.1.9 → 0.1.11
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/index.js +70 -2
- package/dist/lib/action-runtime.d.ts +3 -0
- package/dist/lib/types.d.ts +1 -1
- package/package.json +1 -1
- package/vjt-styles.css +23 -0
package/dist/index.js
CHANGED
|
@@ -4939,6 +4939,12 @@ var ActionRuntime = class {
|
|
|
4939
4939
|
}
|
|
4940
4940
|
return this.resolveReference(reference, context.currentValue, context.responseValue);
|
|
4941
4941
|
}
|
|
4942
|
+
if (name.startsWith("getFirst ")) {
|
|
4943
|
+
return this.getCollectionBoundary(name.slice(9), "first");
|
|
4944
|
+
}
|
|
4945
|
+
if (name.startsWith("getLast ")) {
|
|
4946
|
+
return this.getCollectionBoundary(name.slice(8), "last");
|
|
4947
|
+
}
|
|
4942
4948
|
if (name.startsWith("count ")) {
|
|
4943
4949
|
return this.countValue(this.resolveReference(name.slice(6), context.currentValue, context.responseValue));
|
|
4944
4950
|
}
|
|
@@ -4972,6 +4978,12 @@ var ActionRuntime = class {
|
|
|
4972
4978
|
if (name === "dec") {
|
|
4973
4979
|
return this.toNumber(inputValue) - 1;
|
|
4974
4980
|
}
|
|
4981
|
+
if (name === "trim") {
|
|
4982
|
+
return this.stringifyValue(inputValue).trim();
|
|
4983
|
+
}
|
|
4984
|
+
if (name === "dedupLineBreaks") {
|
|
4985
|
+
return this.stringifyValue(inputValue).replaceAll(/\r\n/g, "\n").replaceAll(/\n{3,}/g, "\n\n");
|
|
4986
|
+
}
|
|
4975
4987
|
if (name.startsWith("equals ")) {
|
|
4976
4988
|
return this.resolveReference(name.slice(7), context.currentValue, context.responseValue) === action.args;
|
|
4977
4989
|
}
|
|
@@ -4998,6 +5010,12 @@ var ActionRuntime = class {
|
|
|
4998
5010
|
this.assignReference(name.slice(4), inputValue, context.currentValue, args);
|
|
4999
5011
|
return inputValue;
|
|
5000
5012
|
}
|
|
5013
|
+
if (name.startsWith("setFirst ")) {
|
|
5014
|
+
return this.setCollectionBoundary(name.slice(9), inputValue, "first");
|
|
5015
|
+
}
|
|
5016
|
+
if (name.startsWith("setLast ")) {
|
|
5017
|
+
return this.setCollectionBoundary(name.slice(8), inputValue, "last");
|
|
5018
|
+
}
|
|
5001
5019
|
if (name.startsWith("append ")) {
|
|
5002
5020
|
const reference = name.slice(7);
|
|
5003
5021
|
const currentText = this.resolveReference(reference, context.currentValue, context.responseValue);
|
|
@@ -5128,6 +5146,47 @@ var ActionRuntime = class {
|
|
|
5128
5146
|
}
|
|
5129
5147
|
return JSON.stringify(value);
|
|
5130
5148
|
}
|
|
5149
|
+
getCollectionBoundary(widgetId, boundary) {
|
|
5150
|
+
const state = this.stateById.get(widgetId) ?? this.stateByKey.get(widgetId);
|
|
5151
|
+
const collection = this.getWidgetCollection(state);
|
|
5152
|
+
if (!collection || collection.length === 0) {
|
|
5153
|
+
return null;
|
|
5154
|
+
}
|
|
5155
|
+
const index = boundary === "first" ? 0 : collection.length - 1;
|
|
5156
|
+
const value = collection[index];
|
|
5157
|
+
return isListElementLike(value) ? this.unwrapListValue(value) : value;
|
|
5158
|
+
}
|
|
5159
|
+
setCollectionBoundary(widgetId, inputValue, boundary) {
|
|
5160
|
+
const state = this.stateById.get(widgetId) ?? this.stateByKey.get(widgetId);
|
|
5161
|
+
if (!state) {
|
|
5162
|
+
return inputValue;
|
|
5163
|
+
}
|
|
5164
|
+
const collection = this.getWidgetCollection(state);
|
|
5165
|
+
if (!collection || collection.length === 0) {
|
|
5166
|
+
return inputValue;
|
|
5167
|
+
}
|
|
5168
|
+
const index = boundary === "first" ? 0 : collection.length - 1;
|
|
5169
|
+
collection[index] = this.cloneValue(this.unwrapListValue(inputValue));
|
|
5170
|
+
if (state.widget === "list" || state.widget === "grid-view") {
|
|
5171
|
+
this.clearListElementState(state.key);
|
|
5172
|
+
}
|
|
5173
|
+
return inputValue;
|
|
5174
|
+
}
|
|
5175
|
+
getWidgetCollection(state) {
|
|
5176
|
+
if (!state) {
|
|
5177
|
+
return null;
|
|
5178
|
+
}
|
|
5179
|
+
if (state.widget === "list" || state.widget === "grid-view") {
|
|
5180
|
+
return state.elements ?? null;
|
|
5181
|
+
}
|
|
5182
|
+
if (state.widget === "listbox") {
|
|
5183
|
+
return state.listboxElements ?? null;
|
|
5184
|
+
}
|
|
5185
|
+
if (state.widget === "combobox") {
|
|
5186
|
+
return state.comboboxElements ?? null;
|
|
5187
|
+
}
|
|
5188
|
+
return null;
|
|
5189
|
+
}
|
|
5131
5190
|
isCurrentScopedReference(reference) {
|
|
5132
5191
|
return reference === "current" || reference.startsWith("current.") || reference.startsWith("this.") || reference === "this";
|
|
5133
5192
|
}
|
|
@@ -6315,7 +6374,7 @@ var VERTICAL_ALIGN_MAP2 = { top: "flex-start", center: "center", bottom: "flex-e
|
|
|
6315
6374
|
var markdownConverter = new import_showdown.default.Converter({
|
|
6316
6375
|
simpleLineBreaks: true,
|
|
6317
6376
|
ghCompatibleHeaderId: true,
|
|
6318
|
-
tables:
|
|
6377
|
+
tables: true,
|
|
6319
6378
|
strikethrough: false,
|
|
6320
6379
|
tasklists: false
|
|
6321
6380
|
});
|
|
@@ -7479,7 +7538,11 @@ var RuntimeRenderer = class {
|
|
|
7479
7538
|
const nextIsMobile = isMobileViewport();
|
|
7480
7539
|
if (nextIsMobile !== previousIsMobile) {
|
|
7481
7540
|
previousIsMobile = nextIsMobile;
|
|
7482
|
-
|
|
7541
|
+
void this.handleLayoutSwitch(nextIsMobile).catch((error) => {
|
|
7542
|
+
logRuntimeError("handleLayoutSwitch", error, {
|
|
7543
|
+
nextIsMobile
|
|
7544
|
+
});
|
|
7545
|
+
});
|
|
7483
7546
|
}
|
|
7484
7547
|
};
|
|
7485
7548
|
window.addEventListener("resize", handleResize);
|
|
@@ -7544,6 +7607,11 @@ var RuntimeRenderer = class {
|
|
|
7544
7607
|
}
|
|
7545
7608
|
return Promise.resolve();
|
|
7546
7609
|
}
|
|
7610
|
+
async handleLayoutSwitch(nextIsMobile) {
|
|
7611
|
+
await this.rerenderRoot();
|
|
7612
|
+
await this.runSystemEvent(nextIsMobile ? "onLayoutSwitchToMobile" : "onLayoutSwitchToDesktop");
|
|
7613
|
+
await this.rerenderRoot();
|
|
7614
|
+
}
|
|
7547
7615
|
async runSystemEvent(eventName) {
|
|
7548
7616
|
const actions = this.systemEvents[eventName];
|
|
7549
7617
|
if (!actions?.length) {
|
|
@@ -124,6 +124,9 @@ export declare class ActionRuntime {
|
|
|
124
124
|
private getCurrentListState;
|
|
125
125
|
private cloneValue;
|
|
126
126
|
private stringifyValue;
|
|
127
|
+
private getCollectionBoundary;
|
|
128
|
+
private setCollectionBoundary;
|
|
129
|
+
private getWidgetCollection;
|
|
127
130
|
private isCurrentScopedReference;
|
|
128
131
|
private countValue;
|
|
129
132
|
private toNumber;
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export type TextAlign = 'left' | 'center' | 'right';
|
|
|
4
4
|
export type VerticalAlign = 'top' | 'center' | 'bottom';
|
|
5
5
|
export type HeadingTag = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
6
6
|
export type WidgetEventName = 'onClick' | 'onUserValueChange' | 'onRefresh' | 'onEnter' | 'onShiftEnter' | 'onControlEnter' | 'onPaste';
|
|
7
|
-
export type SystemEventName = 'onBeforeRender' | 'onAfterRender' | 'onBeforeNavigate' | 'onAfterNavigate' | 'onSpeechDetected' | 'onRecordingStarted' | 'onRecordingStopped' | 'onRecordingError' | 'onListeningError' | 'onListeringError' | 'onPlayFinished' | 'onPlayingStopped';
|
|
7
|
+
export type SystemEventName = 'onBeforeRender' | 'onAfterRender' | 'onBeforeNavigate' | 'onAfterNavigate' | 'onLayoutSwitchToMobile' | 'onLayoutSwitchToDesktop' | 'onSpeechDetected' | 'onRecordingStarted' | 'onRecordingStopped' | 'onRecordingError' | 'onListeningError' | 'onListeringError' | 'onPlayFinished' | 'onPlayingStopped';
|
|
8
8
|
export type PrimitiveRequestType = 'int' | 'float' | 'boolean' | 'string';
|
|
9
9
|
export type RouteDefinition = {
|
|
10
10
|
path: string;
|
package/package.json
CHANGED
package/vjt-styles.css
CHANGED
|
@@ -122,6 +122,29 @@ body {
|
|
|
122
122
|
background: color-mix(in srgb, var(--vjt-surface-muted) 86%, transparent);
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
+
.vjt-md-text-body table {
|
|
126
|
+
width: 100%;
|
|
127
|
+
border-collapse: collapse;
|
|
128
|
+
margin: 10px 0;
|
|
129
|
+
overflow: hidden;
|
|
130
|
+
border: 1px solid var(--vjt-border);
|
|
131
|
+
border-radius: 12px;
|
|
132
|
+
background: color-mix(in srgb, var(--vjt-surface) 92%, transparent);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.vjt-md-text-body th,
|
|
136
|
+
.vjt-md-text-body td {
|
|
137
|
+
padding: 10px 12px;
|
|
138
|
+
border: 1px solid color-mix(in srgb, var(--vjt-border) 78%, transparent);
|
|
139
|
+
text-align: left;
|
|
140
|
+
vertical-align: top;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.vjt-md-text-body th {
|
|
144
|
+
font-weight: 700;
|
|
145
|
+
background: color-mix(in srgb, var(--vjt-surface-muted) 82%, transparent);
|
|
146
|
+
}
|
|
147
|
+
|
|
125
148
|
.vjt-static-text:is(h1, h2, h3, h4, h5, h6) {
|
|
126
149
|
font-family: var(--vjt-font-heading);
|
|
127
150
|
letter-spacing: -0.02em;
|