timepicker-ui 3.0.0 â 3.0.1
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/README.md +87 -51
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -54,6 +54,22 @@ yarn add timepicker-ui
|
|
|
54
54
|
|
|
55
55
|
---
|
|
56
56
|
|
|
57
|
+
## đ Global CSS Required
|
|
58
|
+
|
|
59
|
+
For correct styling, make sure your app includes this global CSS rule:
|
|
60
|
+
|
|
61
|
+
```css
|
|
62
|
+
*,
|
|
63
|
+
*::before,
|
|
64
|
+
*::after {
|
|
65
|
+
box-sizing: border-box;
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
This is a common default in most projects and is required by `timepicker-ui` to avoid layout issues.
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
57
73
|
## đ Quick Start
|
|
58
74
|
|
|
59
75
|
### Basic Usage
|
|
@@ -519,99 +535,119 @@ import "timepicker-ui/theme-dark.css"; // Or any other theme
|
|
|
519
535
|
```tsx
|
|
520
536
|
import { useEffect, useRef } from "react";
|
|
521
537
|
import { TimepickerUI } from "timepicker-ui";
|
|
538
|
+
import "timepicker-ui/main.css";
|
|
539
|
+
import "timepicker-ui/theme-cyberpunk.css";
|
|
522
540
|
|
|
523
|
-
function
|
|
524
|
-
const inputRef = useRef(null);
|
|
525
|
-
const pickerRef = useRef(null);
|
|
541
|
+
function App() {
|
|
542
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
526
543
|
|
|
527
544
|
useEffect(() => {
|
|
528
|
-
if (inputRef.current)
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
},
|
|
534
|
-
});
|
|
535
|
-
pickerRef.current.create();
|
|
536
|
-
}
|
|
537
|
-
|
|
545
|
+
if (!inputRef.current) return;
|
|
546
|
+
const picker = new TimepickerUI(inputRef.current, {
|
|
547
|
+
theme: "cyberpunk",
|
|
548
|
+
});
|
|
549
|
+
picker.create();
|
|
538
550
|
return () => {
|
|
539
|
-
|
|
551
|
+
picker.destroy();
|
|
540
552
|
};
|
|
541
|
-
}, [
|
|
553
|
+
}, []);
|
|
542
554
|
|
|
543
|
-
return
|
|
555
|
+
return (
|
|
556
|
+
<div style={{ padding: "2rem" }}>
|
|
557
|
+
<h1>Timepicker UI React Demo</h1>
|
|
558
|
+
<input ref={inputRef} placeholder="Click me..." />
|
|
559
|
+
</div>
|
|
560
|
+
);
|
|
544
561
|
}
|
|
562
|
+
|
|
563
|
+
export default App;
|
|
545
564
|
```
|
|
546
565
|
|
|
566
|
+
> âšī¸ **Note:** Don't forget to include global `box-sizing` rule in your `styles.css` (see [Global CSS Required](#global-css-required)).
|
|
567
|
+
|
|
547
568
|
### Vue 3
|
|
548
569
|
|
|
549
570
|
```vue
|
|
550
571
|
<template>
|
|
551
|
-
<
|
|
572
|
+
<div style="padding: 2rem">
|
|
573
|
+
<h1>Timepicker UI â Vue Demo</h1>
|
|
574
|
+
<input ref="pickerInput" placeholder="Pick a time..." />
|
|
575
|
+
</div>
|
|
552
576
|
</template>
|
|
553
577
|
|
|
554
578
|
<script setup>
|
|
555
|
-
import {
|
|
579
|
+
import { onMounted, ref } from "vue";
|
|
556
580
|
import { TimepickerUI } from "timepicker-ui";
|
|
581
|
+
import "timepicker-ui/main.css";
|
|
582
|
+
import "timepicker-ui/theme-glassmorphic.css";
|
|
557
583
|
|
|
558
|
-
const
|
|
559
|
-
let picker = null;
|
|
560
|
-
|
|
561
|
-
const emit = defineEmits(["time-selected"]);
|
|
584
|
+
const pickerInput = ref(null);
|
|
562
585
|
|
|
563
586
|
onMounted(() => {
|
|
564
|
-
|
|
587
|
+
if (!pickerInput.value) return;
|
|
588
|
+
|
|
589
|
+
const picker = new TimepickerUI(pickerInput.value, {
|
|
565
590
|
theme: "glassmorphic",
|
|
566
|
-
onConfirm: (data) => {
|
|
567
|
-
emit("time-selected", data);
|
|
568
|
-
},
|
|
569
591
|
});
|
|
570
592
|
picker.create();
|
|
571
593
|
});
|
|
572
|
-
|
|
573
|
-
onUnmounted(() => {
|
|
574
|
-
picker?.destroy();
|
|
575
|
-
});
|
|
576
594
|
</script>
|
|
577
595
|
```
|
|
578
596
|
|
|
579
|
-
|
|
597
|
+
> âšī¸ **Note:** Don't forget to include global `box-sizing` rule in your `styles.css` (see [Global CSS Required](#global-css-required)).
|
|
580
598
|
|
|
581
|
-
|
|
599
|
+
## Angular
|
|
600
|
+
|
|
601
|
+
### `app.ts`
|
|
602
|
+
|
|
603
|
+
```ts
|
|
582
604
|
import {
|
|
583
605
|
Component,
|
|
584
606
|
ElementRef,
|
|
585
|
-
ViewChild,
|
|
586
607
|
AfterViewInit,
|
|
587
|
-
|
|
608
|
+
ViewChild,
|
|
609
|
+
signal,
|
|
588
610
|
} from "@angular/core";
|
|
589
611
|
import { TimepickerUI } from "timepicker-ui";
|
|
590
612
|
|
|
591
613
|
@Component({
|
|
592
|
-
selector: "app-
|
|
593
|
-
|
|
614
|
+
selector: "app-root",
|
|
615
|
+
standalone: true,
|
|
616
|
+
templateUrl: "./app.html",
|
|
617
|
+
styleUrl: "./app.css",
|
|
594
618
|
})
|
|
595
|
-
export class
|
|
596
|
-
|
|
597
|
-
private picker!: TimepickerUI;
|
|
598
|
-
|
|
599
|
-
ngAfterViewInit() {
|
|
600
|
-
this.picker = new TimepickerUI(this.inputRef.nativeElement, {
|
|
601
|
-
theme: "ai",
|
|
602
|
-
onConfirm: (data) => {
|
|
603
|
-
console.log("Time selected:", data);
|
|
604
|
-
},
|
|
605
|
-
});
|
|
606
|
-
this.picker.create();
|
|
607
|
-
}
|
|
619
|
+
export class App implements AfterViewInit {
|
|
620
|
+
protected readonly title = signal("timepicker-ui-demo");
|
|
608
621
|
|
|
609
|
-
|
|
610
|
-
|
|
622
|
+
@ViewChild("timepickerInput", { static: true })
|
|
623
|
+
inputRef!: ElementRef<HTMLInputElement>;
|
|
624
|
+
|
|
625
|
+
ngAfterViewInit(): void {
|
|
626
|
+
const picker = new TimepickerUI(this.inputRef.nativeElement, {
|
|
627
|
+
theme: "glassmorphic",
|
|
628
|
+
});
|
|
629
|
+
picker.create();
|
|
611
630
|
}
|
|
612
631
|
}
|
|
613
632
|
```
|
|
614
633
|
|
|
634
|
+
### `app.html`
|
|
635
|
+
|
|
636
|
+
```html
|
|
637
|
+
<input #timepickerInput placeholder="Select time..." />
|
|
638
|
+
```
|
|
639
|
+
|
|
640
|
+
### `angular.json` â styles section
|
|
641
|
+
|
|
642
|
+
```json
|
|
643
|
+
"styles": [
|
|
644
|
+
"src/styles.css",
|
|
645
|
+
"timepicker-ui/main.css"
|
|
646
|
+
]
|
|
647
|
+
```
|
|
648
|
+
|
|
649
|
+
> âšī¸ **Note:** Don't forget to include global `box-sizing` rule in your `styles.css` (see [Global CSS Required](#global-css-required)).
|
|
650
|
+
|
|
615
651
|
---
|
|
616
652
|
|
|
617
653
|
## đ§ Development
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "timepicker-ui",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "timepicker-ui is a customizable time picker library built with TypeScript, inspired by Google's Material Design. Lightweight, themeable, and easy to integrate.",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"exports": {
|
|
19
19
|
".": {
|
|
20
20
|
"import": "./dist/index.js",
|
|
21
|
-
"require": "./dist/index.
|
|
21
|
+
"require": "./dist/index.cjs"
|
|
22
22
|
},
|
|
23
23
|
"./main.css": "./dist/css/main.css",
|
|
24
24
|
"./index.css": "./dist/css/index.css",
|