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.
Files changed (2) hide show
  1. package/README.md +87 -51
  2. 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 TimePicker({ onChange }) {
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
- pickerRef.current = new TimepickerUI(inputRef.current, {
530
- theme: "dark",
531
- onConfirm: (data) => {
532
- onChange?.(data);
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
- pickerRef.current?.destroy();
551
+ picker.destroy();
540
552
  };
541
- }, [onChange]);
553
+ }, []);
542
554
 
543
- return <input ref={inputRef} type="text" />;
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
- <input ref="inputRef" type="text" />
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 { ref, onMounted, onUnmounted } from "vue";
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 inputRef = ref(null);
559
- let picker = null;
560
-
561
- const emit = defineEmits(["time-selected"]);
584
+ const pickerInput = ref(null);
562
585
 
563
586
  onMounted(() => {
564
- picker = new TimepickerUI(inputRef.value, {
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
- ### Angular
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
- ```typescript
599
+ ## Angular
600
+
601
+ ### `app.ts`
602
+
603
+ ```ts
582
604
  import {
583
605
  Component,
584
606
  ElementRef,
585
- ViewChild,
586
607
  AfterViewInit,
587
- OnDestroy,
608
+ ViewChild,
609
+ signal,
588
610
  } from "@angular/core";
589
611
  import { TimepickerUI } from "timepicker-ui";
590
612
 
591
613
  @Component({
592
- selector: "app-timepicker",
593
- template: '<input #timepickerInput type="text" />',
614
+ selector: "app-root",
615
+ standalone: true,
616
+ templateUrl: "./app.html",
617
+ styleUrl: "./app.css",
594
618
  })
595
- export class TimepickerComponent implements AfterViewInit, OnDestroy {
596
- @ViewChild("timepickerInput") inputRef!: ElementRef;
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
- ngOnDestroy() {
610
- this.picker?.destroy();
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.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.js"
21
+ "require": "./dist/index.cjs"
22
22
  },
23
23
  "./main.css": "./dist/css/main.css",
24
24
  "./index.css": "./dist/css/index.css",