stalefish 8.0.6 → 8.0.7

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.
@@ -117,8 +117,28 @@ export default ({ wrapperStyle = null, holdingPen, label, placeholder, property,
117
117
 
118
118
  // Create a stable id for the outer wrapper so we can query a real DOM node
119
119
  // after the template is rendered. Prefer the provided uniqueKey from callers
120
- // (report-pal already supplies it), otherwise fall back to property/name.
121
- const wrapperId = `sf-flatpickr-${uniqueKey || property || Math.random().toString(36).slice(2)}`
120
+ // but DO NOT require it. For robustness, memoize a per-(holdingPen, property)
121
+ // id so re-renders don't generate new ids and callers don't have to pass
122
+ // uniqueKey.
123
+ const ID_MAP_SYMBOL = Symbol.for('stalefish.flatpickr.idMap')
124
+ if (holdingPen && !holdingPen[ID_MAP_SYMBOL]) {
125
+ Object.defineProperty(holdingPen, ID_MAP_SYMBOL, {
126
+ value: {},
127
+ enumerable: false,
128
+ configurable: false,
129
+ writable: false
130
+ })
131
+ }
132
+ const memoId = (() => {
133
+ if (!holdingPen || !property) return null
134
+ const map = holdingPen[ID_MAP_SYMBOL]
135
+ if (!map) return null
136
+ if (!map[property]) {
137
+ map[property] = `sf-flatpickr-${property}-${Math.random().toString(36).slice(2)}`
138
+ }
139
+ return map[property]
140
+ })()
141
+ const wrapperId = `sf-flatpickr-${uniqueKey || memoId || property || Math.random().toString(36).slice(2)}`
122
142
 
123
143
  const inputType = resolvedDisableMobile ? 'text' : (detectTouchscreen() ? (timeOnly ? 'time' : 'date') : 'text')
124
144
 
@@ -166,12 +186,14 @@ export default ({ wrapperStyle = null, holdingPen, label, placeholder, property,
166
186
  flatpickrConfig,
167
187
  {
168
188
  wrap: true,
169
- onValueUpdate: (fpDate, dateString) => {
189
+ // Avoid triggering rerenders on every spinner click which would
190
+ // destroy and recreate the popup, making it seem to "disappear".
191
+ // We update holdingPen once on close instead.
192
+ onValueUpdate: () => {},
193
+ onClose: (selectedDates, dateString) => {
170
194
  const fauxE = {
171
195
  currentTarget: {
172
- validity: {
173
- valid: true
174
- },
196
+ validity: { valid: true },
175
197
  value: dateString
176
198
  }
177
199
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stalefish",
3
- "version": "8.0.6",
3
+ "version": "8.0.7",
4
4
  "description": "Simple function based component library for halfcab tagged template literals",
5
5
  "main": "index.mjs",
6
6
  "module": "index.mjs",