@subiz/widget-v4 4.1.206 → 4.1.207

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subiz/widget-v4",
3
- "version": "4.1.206",
3
+ "version": "4.1.207",
4
4
  "main": "./compiled_src/lib.js",
5
5
  "scripts": {
6
6
  "dev": "npx webpack serve --config webpack.dev.js",
@@ -21,19 +21,19 @@
21
21
  "preact": "10.19.3"
22
22
  },
23
23
  "devDependencies": {
24
- "@babel/cli": "^7.28.6",
25
- "@babel/core": "^7.29.0",
24
+ "@babel/cli": "^7.28.7",
25
+ "@babel/core": "^7.29.7",
26
26
  "@babel/plugin-proposal-class-properties": "^7.18.6",
27
- "@babel/plugin-transform-react-jsx": "^7.28.6",
28
- "@babel/preset-env": "^7.29.5",
27
+ "@babel/plugin-transform-react-jsx": "^7.28.7",
28
+ "@babel/preset-env": "^7.29.7",
29
29
  "babel-loader": "^10.1.1",
30
30
  "babel-plugin-syntax-jsx": "^6.18.0",
31
31
  "html-webpack-plugin": "^5.6.8",
32
32
  "puppeteer": "^25.9.0",
33
33
  "tape": "^5.10.2",
34
- "webpack": "^5.110.1",
34
+ "webpack": "^5.110.3",
35
35
  "webpack-bundle-analyzer": "^5.3.2",
36
- "webpack-cli": "^7.2.2",
36
+ "webpack-cli": "^7.2.3",
37
37
  "webpack-dev-server": "^6.0.0"
38
38
  }
39
39
  }
@@ -66,7 +66,9 @@ export default class Main extends Com {
66
66
  this.refreshCSS()
67
67
 
68
68
  let lastview = this.props.store.matchLastview() || {}
69
- let cid = sb.get(lastview, 'opts.cid')
69
+ // Only validate a saved cid when restoring an opened widget.
70
+ // Mobile init may downgrade a saved widget state to preview while keeping stale opts.
71
+ let cid = sb.get(lastview, 'screen') === 'widget' ? sb.get(lastview, 'opts.cid') : ''
70
72
  if (cid) {
71
73
  this._last_cid = cid
72
74
  this.setState({changing: true}, () => {
@@ -177,11 +179,15 @@ export default class Main extends Com {
177
179
  }
178
180
 
179
181
  onNewMessageShowWidget(cid) {
180
- if (this.props.store.isMobile()) modifyViewport()
182
+ if (this.props.store.isMobile()) modifyViewport(this.shouldLockPageScroll())
181
183
  this.props.store.updateLastview({screen: 'widget', previewEvent: {}, view: 'chat', opts: {cid}})
182
184
  this.forceUpdate()
183
185
  }
184
186
 
187
+ shouldLockPageScroll() {
188
+ return sb.get(this.props.plugin, 'chatbox.mobile_height') === undefined
189
+ }
190
+
185
191
  async showWidget(p) {
186
192
  //this.refButton.current && this.refButton.current.ClearPreview()
187
193
 
@@ -196,7 +202,7 @@ export default class Main extends Com {
196
202
  newView.opts = {cid}
197
203
  }
198
204
 
199
- if (this.props.store.isMobile()) modifyViewport()
205
+ if (this.props.store.isMobile()) modifyViewport(this.shouldLockPageScroll())
200
206
  this.props.store.updateLastview(newView)
201
207
  this.forceUpdate()
202
208
  }
@@ -248,11 +254,13 @@ function restoreViewport() {
248
254
  if (metatag) metatag.remove()
249
255
  }
250
256
 
251
- function modifyViewport() {
252
- // dont allow to scroll background document
253
- if (document.body && document.body.classList) document.body.classList.add('sbz_no_scroll')
254
- if (document.documentElement && document.documentElement.classList)
255
- document.documentElement.classList.add('sbz_no_scroll')
257
+ function modifyViewport(lockPageScroll) {
258
+ if (lockPageScroll) {
259
+ // dont allow to scroll background document
260
+ if (document.body && document.body.classList) document.body.classList.add('sbz_no_scroll')
261
+ if (document.documentElement && document.documentElement.classList)
262
+ document.documentElement.classList.add('sbz_no_scroll')
263
+ }
256
264
 
257
265
  let currentMetas = document.querySelectorAll('meta[name="viewport"]')
258
266
  let shouldAddMetaTag = true
@@ -682,6 +682,7 @@ export function replaceCssVariable(css, setting) {
682
682
  //tokens = tokenize(tokens, "'@mobile_button.background_mask_url'")
683
683
  tokens = tokenize(tokens, "'@mobile_button.margin_x'")
684
684
  tokens = tokenize(tokens, "'@mobile_button.margin_y'")
685
+ tokens = tokenize(tokens, "'@mobile_height'")
685
686
  tokens = tokenize(tokens, "'@widget_position'")
686
687
  tokens = tokenize(tokens, "'@z_index'")
687
688
  tokens = tokenize(tokens, "'@z_index_2'")
@@ -838,6 +839,7 @@ export const DEFVAL = {
838
839
  margin_x: 0.3,
839
840
  margin_y: 0.3,
840
841
  },
842
+ mobile_height: '100%',
841
843
  widget_position: 'fixed',
842
844
  z_index: 2000000000,
843
845
  }
@@ -56,6 +56,13 @@ test('util.randomString', (t) => {
56
56
  t.end()
57
57
  })
58
58
 
59
+ test('replaceCssVariable mobile height', (t) => {
60
+ let css = "height: '@mobile_height';"
61
+ t.equal(util.replaceCssVariable(css, {}), 'height: 100%;', 'defaults to full mobile height')
62
+ t.equal(util.replaceCssVariable(css, {mobile_height: '50%'}), 'height: 50%;', 'uses configured mobile height')
63
+ t.end()
64
+ })
65
+
59
66
  test('convert message event first msg send', (t) => {
60
67
  var events = [
61
68
  {by: {id: 1}, type: 'message_sent', created: 1100},