@bigbinary/neeto-time-zones 0.5.8 → 0.5.10

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 (4) hide show
  1. package/README.md +70 -25
  2. package/index.d.ts +24 -0
  3. package/package.json +10 -17
  4. package/react.d.ts +20 -0
package/README.md CHANGED
@@ -7,20 +7,76 @@ A simple and lightweight NPM package for working with time zones. This package p
7
7
 
8
8
  ## Installation
9
9
 
10
- You can install the package using npm:
10
+ You can install the package using yarn:
11
11
 
12
12
  ```bash
13
- npm install @bigbinary/neeto-time-zones
13
+ yarn add @bigbinary/neeto-time-zones
14
14
  ```
15
15
 
16
+ ## Importing CSS styles to the main stylesheet
17
+
18
+ You should add the following to `main.scss` file:
19
+
20
+ ```css
21
+ @import "@bigbinary/neeto-time-zones/dist/style.css";
22
+ ```
16
23
 
17
24
  ## NeetoTimezoneSelector
18
25
 
19
26
  [Check out the live demo](https://codepen.io/Jijin-Haridas/full/wvQbeOr)
20
- ```js
27
+
28
+ ### Usage 1
29
+
30
+ ```jsx
21
31
  import { NeetoTimezoneSelector } from "@bigbinary/neeto-time-zones";
22
32
 
23
- new NeetoTimezoneSelector(document.getElementById("elementId"));
33
+ const ReactComponent = () => {
34
+ const timezoneRef = useCallback(node => {
35
+ if (!(node !== null)) return;
36
+
37
+ new NeetoTimezoneSelector(node, {
38
+ elementId: "custom-selector-element",
39
+ className: "custom-selector-class",
40
+ initialValue: "initial-timezone",
41
+ position: "top",
42
+ onChange: (timezone) => {
43
+ console.log(timezone);
44
+ },
45
+ onHourFormatChange: (timeFormat) => {
46
+ console.log(timeFormat);
47
+ }
48
+ });
49
+ }, []);
50
+
51
+ return (
52
+ <div
53
+ ref={timezoneRef}
54
+ />
55
+ );
56
+ };
57
+ ```
58
+
59
+ ### Usage 2
60
+
61
+ ```jsx
62
+ import NeetoTimezoneSelector from "@bigbinary/neeto-time-zones/react";
63
+
64
+ const ReactComponent = () => {
65
+ return (
66
+ <NeetoTimezoneSelector
67
+ elementId="custom-selector-element"
68
+ className="custom-selector-class"
69
+ initialValue="initial-timezone"
70
+ position="top"
71
+ onChange={(timezone) => {
72
+ console.log(timezone);
73
+ }}
74
+ onHourFormatChange={(timeFormat) => {
75
+ console.log(timeFormat);
76
+ }}
77
+ />
78
+ );
79
+ }
24
80
  ```
25
81
 
26
82
  ### Configuration
@@ -28,24 +84,13 @@ You can pass options as the second parameter to configure the timezone selector
28
84
 
29
85
  1. elementId: ID for the NeetoTimezoneSelector. By default the ID will be `timezone-selector`
30
86
  2. className: Custom classes that can be added to the component.
31
- 3. onChange: Function to be called when the timezone selector changes.
87
+ 3. initialValue: Initial Value of the timezone selector.
32
88
  4. position: Position in which the selector should open in. Available options: `top`, `bottom`. Default position is `bottom`.
33
- 5. onHourFormatChange: Function to be called when the time format changes.
34
-
35
- ```js
36
- import { NeetoTimezoneSelector } from "@bigbinary/neeto-time-zones";
89
+ 5. onChange: Function to be called when the timezone selector changes.
90
+ 6. onHourFormatChange: Function to be called when the time format changes.
37
91
 
38
- new NeetoTimezoneSelector(document.getElementById("elementId"), {
39
- className: "custom-selector-class",
40
- onChange: (timezone) => {
41
- console.log(timezone);
42
- },
43
- elementId: "custom-selector-element",
44
- position: "top",
45
- });
46
- ```
47
92
 
48
- ### ianaTimezoneToHumanReadble
93
+ ### ianaTimezoneToHumanReadable
49
94
 
50
95
  ```js
51
96
  import { ianaTimezoneToHumanReadable } from "@bigbinary/neeto-time-zones";
@@ -64,12 +109,12 @@ ianaTimezoneToHumanReadable("Europe/Berlin") // => Central Standard Time
64
109
  ```bash
65
110
  git clone git@github.com:bigbinary/neeto-time-zones.git
66
111
  cd neeto-timezones/js
67
- pnpm install
68
- pnpm dev
112
+ yarn install
113
+ yarn dev
69
114
  ```
70
115
 
71
- ### Publishing to npm
116
+ ## Instructions for Publishing
117
+
118
+ A package is released upon merging a PR labeled as patch, minor, or major into the main branch. The patch label addresses bug fixes, minor signifies the addition of new features, and major denotes breaking changes, adhering to the principles outlined in [Semantic Versioning (SemVer)](https://semver.org/).
72
119
 
73
- 1. Bump `package.json` version
74
- 2. Commit and push
75
- 3. `pnpm build && pnpm publish`
120
+ You can checkout the Create and publish releases workflow in GitHub Actions to get a live update.
package/index.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ declare module "@bigbinary/neeto-time-zones" {
2
+ export interface TimezoneObject {
3
+ utc: string[];
4
+ label: string;
5
+ keywords: string;
6
+ isDst: boolean;
7
+ cities: string;
8
+ }
9
+
10
+ export interface NeetoTimezoneSelectorProps {
11
+ className?: string;
12
+ elementId?: string;
13
+ initialValue?: string;
14
+ position?: "top" | "bottom";
15
+ onChange?: (timezone: TimezoneObject) => void;
16
+ onHourFormatChange?: (timeFormat: string) => void;
17
+ }
18
+
19
+ export class NeetoTimezoneSelector {
20
+ constructor(node: HTMLElement, props: NeetoTimezoneSelectorProps);
21
+ }
22
+
23
+ export function ianaTimezoneToHumanReadable(timezone: string): string;
24
+ }
package/package.json CHANGED
@@ -1,20 +1,25 @@
1
1
  {
2
2
  "name": "@bigbinary/neeto-time-zones",
3
- "version": "0.5.8",
3
+ "version": "0.5.10",
4
4
  "license": "MIT",
5
+ "types": "./index.d.ts",
5
6
  "exports": {
6
7
  ".": {
7
8
  "import": "./dist/index.es.js",
8
- "require": "./dist/index.cjs.js"
9
+ "require": "./dist/index.cjs.js",
10
+ "types": "./dist/index.d.ts"
9
11
  },
10
12
  "./react": {
11
13
  "import": "./dist/react.es.js",
12
- "require": "./dist/react.cjs.js"
14
+ "require": "./dist/react.cjs.js",
15
+ "types": "./dist/react.d.ts"
13
16
  }
14
17
  },
15
18
  "type": "module",
16
19
  "files": [
17
- "dist"
20
+ "dist",
21
+ "index.d.ts",
22
+ "react.d.ts"
18
23
  ],
19
24
  "scripts": {
20
25
  "dev": "vite",
@@ -28,18 +33,12 @@
28
33
  },
29
34
  "peerDependencies": {
30
35
  "@bigbinary/neeto-cist": "^1.0.4",
31
- "@bigbinary/neeto-commons-frontend": "^3.0.1",
32
36
  "ramda": "^0.29.1",
33
37
  "react": "^18 || ^17.0.1 || ^16",
34
38
  "react-dom": "^18 || ^17.0.1 || ^16"
35
39
  },
36
40
  "devDependencies": {
37
- "@bigbinary/eslint-plugin-neeto": "^1.1.14",
38
41
  "@bigbinary/neeto-cist": "^1.0.4",
39
- "@bigbinary/neeto-commons-frontend": "^3.0.1",
40
- "@bigbinary/neeto-icons": "^1.11.0",
41
- "@bigbinary/neeto-molecules": "^1.0.19",
42
- "@bigbinary/neetoui": "5.0.2",
43
42
  "@typescript-eslint/eslint-plugin": "^6.2.1",
44
43
  "@typescript-eslint/parser": "^6.2.1",
45
44
  "@vitejs/plugin-react": "^4.0.3",
@@ -47,16 +46,10 @@
47
46
  "cssnano": "4.1.11",
48
47
  "eslint": "8.14.0",
49
48
  "eslint-config-airbnb": "^19.0.4",
50
- "eslint-plugin-import": "2.26.0",
51
- "eslint-plugin-jsx-a11y": "^6.7.1",
52
- "eslint-plugin-react": "7.29.4",
53
- "eslint-plugin-react-hooks": "4.5.0",
54
- "lint-staged": "12.4.1",
49
+ "eslint-plugin-jsx-a11y": "6.7.1",
55
50
  "postcss": "^8.4.17",
56
51
  "postcss-import": "^15.0.0",
57
- "postcss-prefixwrap": "1.40.0",
58
52
  "postcss-preset-env": "7.8.2",
59
- "postcss-wrap": "^0.0.4",
60
53
  "prettier": "2.6.2",
61
54
  "ramda": "^0.29.1",
62
55
  "react": "^18.2.0",
package/react.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ export interface TimezoneObject {
2
+ utc: string[];
3
+ label: string;
4
+ keywords: string;
5
+ isDst: boolean;
6
+ cities: string;
7
+ }
8
+
9
+ export interface NeetoTimezoneSelectorProps {
10
+ className?: string;
11
+ elementId?: string;
12
+ initialValue?: string;
13
+ position?: "top" | "bottom";
14
+ onChange?: (timezone: TimezoneObject) => void;
15
+ onHourFormatChange?: (timeFormat: string) => void;
16
+ }
17
+
18
+ export default function NeetoTimezoneSelector(
19
+ props: NeetoTimezoneSelectorProps
20
+ );