@papernote/ui 1.10.7 → 1.10.8

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.
@@ -1 +1 @@
1
- {"version":3,"file":"SwipeableListItem.d.ts","sourceRoot":"","sources":["../../src/components/SwipeableListItem.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAExE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,uCAAuC;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,wDAAwD;IACxD,KAAK,EAAE,aAAa,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;IAC9E,6BAA6B;IAC7B,IAAI,EAAE,UAAU,CAAC;IACjB,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,OAAO,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,wBAAwB;IACxB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,6DAA6D;IAC7D,WAAW,CAAC,EAAE,eAAe,EAAE,CAAC;IAChC,6DAA6D;IAC7D,YAAY,CAAC,EAAE,eAAe,EAAE,CAAC;IACjC,sDAAsD;IACtD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,2EAA2E;IAC3E,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,iCAAiC;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,4BAA4B;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wCAAwC;IACxC,aAAa,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,KAAK,IA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O,CAAC;IACnB,4BAA4B;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wCAAwC;IACxC,aAAa,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC;CAC9D;AAcD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,EACR,WAAgB,EAChB,YAAiB,EACjB,WAAgB,EAChB,SAAiB,EACjB,kBAAwB,EACxB,QAAgB,EAChB,SAAc,EACd,aAAa,GACd,EAAE,sBAAsB,2CAgexB;AAED,eAAe,iBAAiB,CAAC"}
package/dist/index.esm.js CHANGED
@@ -8162,10 +8162,12 @@ function SwipeableListItem({ children, leftActions = [], rightActions = [], acti
8162
8162
  const [activeDirection, setActiveDirection] = useState(null);
8163
8163
  const [loadingActionId, setLoadingActionId] = useState(null);
8164
8164
  const [focusedActionIndex, setFocusedActionIndex] = useState(-1);
8165
+ const [isCommitted, setIsCommitted] = useState(false); // Tracks if past full-swipe threshold
8165
8166
  const startX = useRef(0);
8166
8167
  const startY = useRef(0);
8167
8168
  const startTime = useRef(0);
8168
8169
  const isHorizontalSwipe = useRef(null);
8170
+ const wasCommitted = useRef(false); // Track previous committed state for haptic
8169
8171
  // Calculate total widths
8170
8172
  const leftActionsWidth = leftActions.length * actionWidth;
8171
8173
  const rightActionsWidth = rightActions.length * actionWidth;
@@ -8185,6 +8187,8 @@ function SwipeableListItem({ children, leftActions = [], rightActions = [], acti
8185
8187
  setOffsetX(0);
8186
8188
  setActiveDirection(null);
8187
8189
  setFocusedActionIndex(-1);
8190
+ setIsCommitted(false);
8191
+ wasCommitted.current = false;
8188
8192
  onSwipeChange?.(null);
8189
8193
  }, [onSwipeChange]);
8190
8194
  // Execute action with async support
@@ -8227,6 +8231,7 @@ function SwipeableListItem({ children, leftActions = [], rightActions = [], acti
8227
8231
  if (isHorizontalSwipe.current !== true)
8228
8232
  return;
8229
8233
  let newOffset = deltaX;
8234
+ const containerWidth = containerRef.current?.offsetWidth || 300;
8230
8235
  // Swiping left (reveals left actions on right side)
8231
8236
  if (deltaX < 0) {
8232
8237
  if (leftActions.length === 0) {
@@ -8234,7 +8239,7 @@ function SwipeableListItem({ children, leftActions = [], rightActions = [], acti
8234
8239
  }
8235
8240
  else {
8236
8241
  const maxSwipe = fullSwipe
8237
- ? -(containerRef.current?.offsetWidth || 300)
8242
+ ? -containerWidth
8238
8243
  : -leftActionsWidth;
8239
8244
  newOffset = Math.max(maxSwipe, deltaX);
8240
8245
  // Apply resistance past the action buttons
@@ -8255,7 +8260,7 @@ function SwipeableListItem({ children, leftActions = [], rightActions = [], acti
8255
8260
  }
8256
8261
  else {
8257
8262
  const maxSwipe = fullSwipe
8258
- ? (containerRef.current?.offsetWidth || 300)
8263
+ ? containerWidth
8259
8264
  : rightActionsWidth;
8260
8265
  newOffset = Math.min(maxSwipe, deltaX);
8261
8266
  // Apply resistance past the action buttons
@@ -8269,8 +8274,19 @@ function SwipeableListItem({ children, leftActions = [], rightActions = [], acti
8269
8274
  onSwipeChange?.('right');
8270
8275
  }
8271
8276
  }
8277
+ // Check if we've crossed the full-swipe threshold
8278
+ if (fullSwipe) {
8279
+ const swipePercentage = Math.abs(newOffset) / containerWidth;
8280
+ const nowCommitted = swipePercentage >= fullSwipeThreshold;
8281
+ // Haptic feedback when crossing threshold (both directions)
8282
+ if (nowCommitted !== wasCommitted.current) {
8283
+ triggerHaptic(nowCommitted ? 'heavy' : 'light');
8284
+ wasCommitted.current = nowCommitted;
8285
+ }
8286
+ setIsCommitted(nowCommitted);
8287
+ }
8272
8288
  setOffsetX(newOffset);
8273
- }, [isDragging, disabled, loadingActionId, leftActions.length, rightActions.length, leftActionsWidth, rightActionsWidth, fullSwipe, activeDirection, onSwipeChange]);
8289
+ }, [isDragging, disabled, loadingActionId, leftActions.length, rightActions.length, leftActionsWidth, rightActionsWidth, fullSwipe, fullSwipeThreshold, activeDirection, onSwipeChange, triggerHaptic]);
8274
8290
  // Handle drag end
8275
8291
  const handleDragEnd = useCallback(() => {
8276
8292
  if (!isDragging)
@@ -8278,10 +8294,21 @@ function SwipeableListItem({ children, leftActions = [], rightActions = [], acti
8278
8294
  setIsDragging(false);
8279
8295
  const velocity = Math.abs(offsetX) / (Date.now() - startTime.current);
8280
8296
  const containerWidth = containerRef.current?.offsetWidth || 300;
8281
- // Check for full swipe trigger
8282
- if (fullSwipe) {
8297
+ // Check for full swipe trigger - use isCommitted state for more reliable detection
8298
+ if (fullSwipe && isCommitted) {
8299
+ if (offsetX < 0 && leftActions.length > 0) {
8300
+ executeAction(leftActions[0]);
8301
+ return;
8302
+ }
8303
+ else if (offsetX > 0 && rightActions.length > 0) {
8304
+ executeAction(rightActions[0]);
8305
+ return;
8306
+ }
8307
+ }
8308
+ // Also check velocity-based trigger for quick swipes
8309
+ if (fullSwipe && velocity > 0.5) {
8283
8310
  const swipePercentage = Math.abs(offsetX) / containerWidth;
8284
- if (swipePercentage >= fullSwipeThreshold || velocity > 0.5) {
8311
+ if (swipePercentage >= fullSwipeThreshold * 0.5) { // Lower threshold for fast swipes
8285
8312
  if (offsetX < 0 && leftActions.length > 0) {
8286
8313
  executeAction(leftActions[0]);
8287
8314
  return;
@@ -8292,6 +8319,9 @@ function SwipeableListItem({ children, leftActions = [], rightActions = [], acti
8292
8319
  }
8293
8320
  }
8294
8321
  }
8322
+ // Reset committed state
8323
+ setIsCommitted(false);
8324
+ wasCommitted.current = false;
8295
8325
  // Snap to open or closed position
8296
8326
  const threshold = actionWidth * 0.5;
8297
8327
  if (Math.abs(offsetX) >= threshold || velocity > 0.3) {
@@ -8313,7 +8343,7 @@ function SwipeableListItem({ children, leftActions = [], rightActions = [], acti
8313
8343
  else {
8314
8344
  resetPosition();
8315
8345
  }
8316
- }, [isDragging, offsetX, fullSwipe, fullSwipeThreshold, leftActions, rightActions, leftActionsWidth, rightActionsWidth, actionWidth, executeAction, resetPosition, onSwipeChange]);
8346
+ }, [isDragging, offsetX, fullSwipe, fullSwipeThreshold, isCommitted, leftActions, rightActions, leftActionsWidth, rightActionsWidth, actionWidth, executeAction, resetPosition, onSwipeChange]);
8317
8347
  // Touch event handlers
8318
8348
  const handleTouchStart = (e) => {
8319
8349
  handleDragStart(e.touches[0].clientX, e.touches[0].clientY);
@@ -8454,7 +8484,24 @@ function SwipeableListItem({ children, leftActions = [], rightActions = [], acti
8454
8484
  const fullSwipeProgress = fullSwipe
8455
8485
  ? Math.min(1, Math.abs(offsetX) / ((containerRef.current?.offsetWidth || 300) * fullSwipeThreshold))
8456
8486
  : 0;
8457
- return (jsxs("div", { ref: containerRef, className: `relative overflow-hidden ${className}`, children: [rightActions.length > 0 && (jsx("div", { className: "absolute left-0 top-0 bottom-0 flex shadow-inner", style: { width: rightActionsWidth }, children: rightActions.map((action, index) => renderActionButton(action, index, 'right')) })), leftActions.length > 0 && (jsx("div", { className: "absolute right-0 top-0 bottom-0 flex shadow-inner", style: { width: leftActionsWidth }, children: leftActions.map((action, index) => renderActionButton(action, index, 'left')) })), fullSwipe && fullSwipeProgress > 0.3 && (jsx("div", { className: `
8487
+ return (jsxs("div", { ref: containerRef, className: `relative overflow-hidden ${className}`, children: [rightActions.length > 0 && (jsx("div", { className: "absolute left-0 top-0 bottom-0 flex shadow-inner", style: { width: rightActionsWidth }, children: rightActions.map((action, index) => renderActionButton(action, index, 'right')) })), leftActions.length > 0 && (jsx("div", { className: "absolute right-0 top-0 bottom-0 flex shadow-inner", style: { width: leftActionsWidth }, children: leftActions.map((action, index) => renderActionButton(action, index, 'left')) })), fullSwipe && isCommitted && isDragging && (jsxs("div", { className: `
8488
+ absolute inset-0 z-10 flex items-center
8489
+ ${offsetX > 0 ? 'justify-start pl-6' : 'justify-end pr-6'}
8490
+ ${offsetX > 0 && rightActions.length > 0
8491
+ ? getColorClasses(rightActions[0].color).bg
8492
+ : offsetX < 0 && leftActions.length > 0
8493
+ ? getColorClasses(leftActions[0].color).bg
8494
+ : ''}
8495
+ transition-opacity duration-150
8496
+ `, children: [offsetX > 0 && rightActions.length > 0 && (() => {
8497
+ const action = rightActions[0];
8498
+ const IconComponent = action.icon;
8499
+ return (jsxs("div", { className: "flex items-center gap-3 text-white animate-pulse", children: [jsx(IconComponent, { className: "h-8 w-8" }), jsxs("span", { className: "text-lg font-semibold uppercase tracking-wide", children: ["Release to ", action.label] })] }));
8500
+ })(), offsetX < 0 && leftActions.length > 0 && (() => {
8501
+ const action = leftActions[0];
8502
+ const IconComponent = action.icon;
8503
+ return (jsxs("div", { className: "flex items-center gap-3 text-white animate-pulse", children: [jsxs("span", { className: "text-lg font-semibold uppercase tracking-wide", children: ["Release to ", action.label] }), jsx(IconComponent, { className: "h-8 w-8" })] }));
8504
+ })()] })), fullSwipe && fullSwipeProgress > 0.3 && !isCommitted && (jsx("div", { className: `
8458
8505
  absolute inset-0 pointer-events-none
8459
8506
  ${offsetX > 0 ? 'bg-gradient-to-r from-success-500/20 to-transparent' : 'bg-gradient-to-l from-error-500/20 to-transparent'}
8460
8507
  `, style: { opacity: fullSwipeProgress } })), jsx("div", { className: `
@@ -12254,44 +12301,52 @@ function getAugmentedNamespace(n) {
12254
12301
  * (A1, A1:C5, ...)
12255
12302
  */
12256
12303
 
12257
- let Collection$3 = class Collection {
12304
+ var collection;
12305
+ var hasRequiredCollection;
12306
+
12307
+ function requireCollection () {
12308
+ if (hasRequiredCollection) return collection;
12309
+ hasRequiredCollection = 1;
12310
+ class Collection {
12258
12311
 
12259
- constructor(data, refs) {
12260
- if (data == null && refs == null) {
12261
- this._data = [];
12262
- this._refs = [];
12263
- } else {
12264
- if (data.length !== refs.length)
12265
- throw Error('Collection: data length should match references length.');
12266
- this._data = data;
12267
- this._refs = refs;
12268
- }
12269
- }
12312
+ constructor(data, refs) {
12313
+ if (data == null && refs == null) {
12314
+ this._data = [];
12315
+ this._refs = [];
12316
+ } else {
12317
+ if (data.length !== refs.length)
12318
+ throw Error('Collection: data length should match references length.');
12319
+ this._data = data;
12320
+ this._refs = refs;
12321
+ }
12322
+ }
12270
12323
 
12271
- get data() {
12272
- return this._data;
12273
- }
12324
+ get data() {
12325
+ return this._data;
12326
+ }
12274
12327
 
12275
- get refs() {
12276
- return this._refs;
12277
- }
12328
+ get refs() {
12329
+ return this._refs;
12330
+ }
12278
12331
 
12279
- get length() {
12280
- return this._data.length;
12281
- }
12332
+ get length() {
12333
+ return this._data.length;
12334
+ }
12282
12335
 
12283
- /**
12284
- * Add data and references to this collection.
12285
- * @param {{}} obj - data
12286
- * @param {{}} ref - reference
12287
- */
12288
- add(obj, ref) {
12289
- this._data.push(obj);
12290
- this._refs.push(ref);
12291
- }
12292
- };
12336
+ /**
12337
+ * Add data and references to this collection.
12338
+ * @param {{}} obj - data
12339
+ * @param {{}} ref - reference
12340
+ */
12341
+ add(obj, ref) {
12342
+ this._data.push(obj);
12343
+ this._refs.push(ref);
12344
+ }
12345
+ }
12293
12346
 
12294
- var collection = Collection$3;
12347
+ collection = Collection;
12348
+ return collection;
12349
+ }
12295
12350
 
12296
12351
  var helpers;
12297
12352
  var hasRequiredHelpers;
@@ -12300,7 +12355,7 @@ function requireHelpers () {
12300
12355
  if (hasRequiredHelpers) return helpers;
12301
12356
  hasRequiredHelpers = 1;
12302
12357
  const FormulaError = requireError();
12303
- const Collection = collection;
12358
+ const Collection = requireCollection();
12304
12359
 
12305
12360
  const Types = {
12306
12361
  NUMBER: 0,
@@ -21954,7 +22009,7 @@ var engineering = EngineeringFunctions;
21954
22009
 
21955
22010
  const FormulaError$b = requireError();
21956
22011
  const {FormulaHelpers: FormulaHelpers$8, Types: Types$6, WildCard, Address: Address$3} = requireHelpers();
21957
- const Collection$2 = collection;
22012
+ const Collection$2 = requireCollection();
21958
22013
  const H$5 = FormulaHelpers$8;
21959
22014
 
21960
22015
  const ReferenceFunctions$1 = {
@@ -33582,7 +33637,7 @@ var parsing = {
33582
33637
  const FormulaError$4 = requireError();
33583
33638
  const {Address: Address$1} = requireHelpers();
33584
33639
  const {Prefix: Prefix$1, Postfix: Postfix$1, Infix: Infix$1, Operators: Operators$1} = operators;
33585
- const Collection$1 = collection;
33640
+ const Collection$1 = requireCollection();
33586
33641
  const MAX_ROW$1 = 1048576, MAX_COLUMN$1 = 16384;
33587
33642
  const {NotAllInputParsedException} = require$$4;
33588
33643
 
@@ -34344,7 +34399,7 @@ var hooks$1 = {
34344
34399
  const FormulaError$2 = requireError();
34345
34400
  const {FormulaHelpers: FormulaHelpers$1, Types, Address} = requireHelpers();
34346
34401
  const {Prefix, Postfix, Infix, Operators} = operators;
34347
- const Collection = collection;
34402
+ const Collection = requireCollection();
34348
34403
  const MAX_ROW = 1048576, MAX_COLUMN = 16384;
34349
34404
 
34350
34405
  let Utils$1 = class Utils {