Skip to content

Commit 635ae6d

Browse files
committed
- support change event when value changed
- bump version
1 parent c12545d commit 635ae6d

File tree

6 files changed

+21
-9
lines changed

6 files changed

+21
-9
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Change Logs
22

3+
## v0.0.5
4+
5+
- support `change` event when value changed.
6+
7+
38
## v0.0.4
49

510
- update widget based on initial value of host if available

dist/index.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@
254254
}
255255
},
256256
update: function(now){
257-
var ref$, y, m, start, ny, nm, nd, ty, tm, td, sy, sm, sd;
257+
var ref$, y, m, start, ny, nm, nd, ty, tm, td, sy, sm, sd, ov, nv;
258258
now = now || this.cur;
259259
ref$ = [now.year(), now.month()], y = ref$[0], m = ref$[1];
260260
now = dayjs(new Date(now.year(), now.month(), 1));
@@ -283,7 +283,12 @@
283283
return n.classList.toggle('selected', sy === dy && sm === dm && sd === dd);
284284
});
285285
if (this.host) {
286-
return this.host.value = this.value();
286+
ov = this.host.value;
287+
nv = this.value();
288+
this.host.value = nv;
289+
if (ov !== nv) {
290+
return this.fire('change', nv);
291+
}
287292
}
288293
},
289294
value: function(v){

dist/index.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lddatetimepicker",
3-
"version": "0.0.4",
3+
"version": "0.0.5",
44
"description": "vanilla date/time picker",
55
"browser": "dist/index.min.js",
66
"main": "dist/index.js",

src/index.ls

+5-3
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ lddatetimepicker.prototype = Object.create(Object.prototype) <<< do
180180
c.style.transform = "translate(#{x}px, #{y}px)"
181181
c.style <<< top: 0, left: 0
182182

183-
184183
update: (now) ->
185184
now = now or @cur
186185
[y,m] = [now.year!, now.month!]
@@ -201,11 +200,14 @@ lddatetimepicker.prototype = Object.create(Object.prototype) <<< do
201200
n.classList.toggle \dim, (d.month! != m)
202201
n.classList.toggle \today, (ty == dy and tm == dm and td == dd)
203202
n.classList.toggle \selected, (sy == dy and sm == dm and sd == dd)
204-
if @host => @host.value = @value!
203+
if @host =>
204+
ov = @host.value
205+
nv = @value!
206+
@host.value = nv
207+
if ov != nv => @fire \change, nv
205208
value: (v) ->
206209
if !arguments.length =>
207210
if @_enabled.time =>
208-
#ret = dayjs new Date( @sel.year!, @sel.month!, @sel.date!, @sel.hour!, @sel.minute! )
209211
ret = dayjs new Date( @sel.year!, @sel.month!, @sel.date!, @sel.hour!, @sel.minute! )
210212
return ret.format('YYYY-MM-DDTHH:mm:ssZ')
211213
else return dayjs(new Date( @sel.year!, @sel.month!, @sel.date!)).format('YYYY-MM-DD')

0 commit comments

Comments
 (0)